Completed
Push — master ( cad9a1...6c0d65 )
by Yannick
37:35
created
require/class.MapMatching.php 1 patch
Braces   +54 added lines, -18 removed lines patch added patch discarded remove patch
@@ -46,7 +46,9 @@  discard block
 block discarded – undo
46 46
 		$gpx .= '<trkseg>';
47 47
 		foreach($spotter_history_array as $spotter_data) {
48 48
 			$gpx .= '<trkpt lat="'.sprintf("%.8f",$spotter_data['latitude']).'" lon="'.sprintf("%.8f",$spotter_data['longitude']).'">';
49
-			if (isset($spotter_data['altitude'])) $gpx .= '<ele>'.sprintf("%.6f",$spotter_data['altitude']).'</ele>';
49
+			if (isset($spotter_data['altitude'])) {
50
+				$gpx .= '<ele>'.sprintf("%.6f",$spotter_data['altitude']).'</ele>';
51
+			}
50 52
 			$gpx .= '<time>'.date("Y-m-d\TH:i:s\Z",strtotime($spotter_data['date'])).'</time>';
51 53
 			$gpx .= '</trkpt>';
52 54
 		}
@@ -82,9 +84,15 @@  discard block
 block discarded – undo
82 84
 
83 85
 	public function TrackMatching($spotter_history_array) {
84 86
 		global $globalMapMatchingMaxPts, $globalTrackMatchingAppKey, $globalTrackMatchingAppId;
85
-		if (!isset($globalMapMatchingMaxPts)) $globalMapMatchingMaxPts = 100;
86
-		if (count($spotter_history_array) < 2) return $spotter_history_array;
87
-		if (count($spotter_history_array) > $globalMapMatchingMaxPts) $spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts);
87
+		if (!isset($globalMapMatchingMaxPts)) {
88
+			$globalMapMatchingMaxPts = 100;
89
+		}
90
+		if (count($spotter_history_array) < 2) {
91
+			return $spotter_history_array;
92
+		}
93
+		if (count($spotter_history_array) > $globalMapMatchingMaxPts) {
94
+			$spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts);
95
+		}
88 96
 		$data = $this->create_gpx($spotter_history_array);
89 97
 		$url = 'https://test.roadmatching.com/rest/mapmatch/?app_id='.$globalTrackMatchingAppId.'&app_key='.$globalTrackMatchingAppKey.'&output.waypoints=true';
90 98
 		$Common = new Common();
@@ -111,8 +119,12 @@  discard block
 block discarded – undo
111 119
 	*/
112 120
 	public function GraphHopper($spotter_history_array) {
113 121
 		global $globalMapMatchingMaxPts, $globalGraphHopperKey;
114
-		if (!isset($globalMapMatchingMaxPts)) $globalMapMatchingMaxPts = 100;
115
-		if (count($spotter_history_array) < 2) return $spotter_history_array;
122
+		if (!isset($globalMapMatchingMaxPts)) {
123
+			$globalMapMatchingMaxPts = 100;
124
+		}
125
+		if (count($spotter_history_array) < 2) {
126
+			return $spotter_history_array;
127
+		}
116 128
 		$spotter_history_initial_array = array();
117 129
 		if (count($spotter_history_array) > $globalMapMatchingMaxPts) {
118 130
 			$spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts);
@@ -142,8 +154,12 @@  discard block
 block discarded – undo
142 154
 	*/
143 155
 	public function FAMMapMatching($spotter_history_array) {
144 156
 		global $globalMapMatchingMaxPts;
145
-		if (!isset($globalMapMatchingMaxPts)) $globalMapMatchingMaxPts = 100;
146
-		if (count($spotter_history_array) < 2) return $spotter_history_array;
157
+		if (!isset($globalMapMatchingMaxPts)) {
158
+			$globalMapMatchingMaxPts = 100;
159
+		}
160
+		if (count($spotter_history_array) < 2) {
161
+			return $spotter_history_array;
162
+		}
147 163
 		$spotter_history_initial_array = array();
148 164
 		if (count($spotter_history_array) > $globalMapMatchingMaxPts) {
149 165
 			$spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts);
@@ -174,8 +190,12 @@  discard block
 block discarded – undo
174 190
 	*/
175 191
 	public function osmr($spotter_history_array) {
176 192
 		global $globalMapMatchingMaxPts;
177
-		if (!isset($globalMapMatchingMaxPts)) $globalMapMatchingMaxPts = 50;
178
-		if (count($spotter_history_array) < 2) return $spotter_history_array;
193
+		if (!isset($globalMapMatchingMaxPts)) {
194
+			$globalMapMatchingMaxPts = 50;
195
+		}
196
+		if (count($spotter_history_array) < 2) {
197
+			return $spotter_history_array;
198
+		}
179 199
 		$spotter_history_initial_array = array();
180 200
 		if (count($spotter_history_array) > $globalMapMatchingMaxPts) {
181 201
 			$spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts);
@@ -185,11 +205,17 @@  discard block
 block discarded – undo
185 205
 		$ts = '';
186 206
 		$rd = '';
187 207
 		foreach ($spotter_history_array as $spotter_data) {
188
-			if ($coord != '') $coord .= ';';
208
+			if ($coord != '') {
209
+				$coord .= ';';
210
+			}
189 211
 			$coord .= $spotter_data['longitude'].','.$spotter_data['latitude'];
190
-			if ($ts != '') $ts .= ';';
212
+			if ($ts != '') {
213
+				$ts .= ';';
214
+			}
191 215
 			$ts .= strtotime($spotter_data['date']);
192
-			if ($rd != '') $rd .= ';';
216
+			if ($rd != '') {
217
+				$rd .= ';';
218
+			}
193 219
 			$rd .= '20';
194 220
 		}
195 221
 		$url = 'https://router.project-osrm.org/match/v1/driving/'.$coord.'?timestamps='.$ts.'&overview=full&geometries=geojson&tidy=true&gaps=ignore';
@@ -215,8 +241,12 @@  discard block
 block discarded – undo
215 241
 	*/
216 242
 	public function mapbox($spotter_history_array) {
217 243
 		global $globalMapMatchingMaxPts, $globalMapboxToken;
218
-		if (!isset($globalMapMatchingMaxPts)) $globalMapMatchingMaxPts = 60;
219
-		if (count($spotter_history_array) < 2) return $spotter_history_array;
244
+		if (!isset($globalMapMatchingMaxPts)) {
245
+			$globalMapMatchingMaxPts = 60;
246
+		}
247
+		if (count($spotter_history_array) < 2) {
248
+			return $spotter_history_array;
249
+		}
220 250
 		$spotter_history_initial_array = array();
221 251
 		if (count($spotter_history_array) > $globalMapMatchingMaxPts) {
222 252
 			$spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts);
@@ -226,11 +256,17 @@  discard block
 block discarded – undo
226 256
 		$ts = '';
227 257
 		$rd = '';
228 258
 		foreach ($spotter_history_array as $spotter_data) {
229
-			if ($coord != '') $coord .= ';';
259
+			if ($coord != '') {
260
+				$coord .= ';';
261
+			}
230 262
 			$coord .= $spotter_data['longitude'].','.$spotter_data['latitude'];
231
-			if ($ts != '') $ts .= ';';
263
+			if ($ts != '') {
264
+				$ts .= ';';
265
+			}
232 266
 			$ts .= strtotime($spotter_data['date']);
233
-			if ($rd != '') $rd .= ';';
267
+			if ($rd != '') {
268
+				$rd .= ';';
269
+			}
234 270
 			$rd .= '20';
235 271
 		}
236 272
 		//$url = 'https://api.mapbox.com/matching/v5/mapbox/driving/'.$coord.'?access_token='.$globalMapboxToken.'&timestamps='.$ts.'&overview=full&tidy=true&geometries=geojson&radiuses='.$rd;
Please login to merge, or discard this patch.
require/class.Marine.php 2 patches
Indentation   +463 added lines, -463 removed lines patch added patch discarded remove patch
@@ -18,13 +18,13 @@  discard block
 block discarded – undo
18 18
 		if ($this->db === null) die('Error: No DB connection. (Marine)');
19 19
 	}
20 20
 
21
-    /**
22
-     * Get SQL query part for filter used
23
-     * @param array $filter the filter
24
-     * @param bool $where
25
-     * @param bool $and
26
-     * @return string the SQL part
27
-     */
21
+	/**
22
+	 * Get SQL query part for filter used
23
+	 * @param array $filter the filter
24
+	 * @param bool $where
25
+	 * @param bool $and
26
+	 * @return string the SQL part
27
+	 */
28 28
 	public function getFilter($filter = array(),$where = false,$and = false) {
29 29
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
30 30
 		$filters = array();
@@ -95,15 +95,15 @@  discard block
 block discarded – undo
95 95
 		return $filter_query;
96 96
 	}
97 97
 
98
-    /**
99
-     * Executes the SQL statements to get the spotter information
100
-     *
101
-     * @param String $query the SQL query
102
-     * @param array $params parameter of the query
103
-     * @param String $limitQuery the limit query
104
-     * @param bool $schedules
105
-     * @return array the spotter information
106
-     */
98
+	/**
99
+	 * Executes the SQL statements to get the spotter information
100
+	 *
101
+	 * @param String $query the SQL query
102
+	 * @param array $params parameter of the query
103
+	 * @param String $limitQuery the limit query
104
+	 * @param bool $schedules
105
+	 * @return array the spotter information
106
+	 */
107 107
 	public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false)
108 108
 	{
109 109
 		global $globalVM;
@@ -253,14 +253,14 @@  discard block
 block discarded – undo
253 253
 	}
254 254
 
255 255
 
256
-    /**
257
-     * Gets all the spotter information based on the latest data entry
258
-     *
259
-     * @param string $limit
260
-     * @param string $sort
261
-     * @param array $filter
262
-     * @return array the spotter information
263
-     */
256
+	/**
257
+	 * Gets all the spotter information based on the latest data entry
258
+	 *
259
+	 * @param string $limit
260
+	 * @param string $sort
261
+	 * @param array $filter
262
+	 * @return array the spotter information
263
+	 */
264 264
 	public function getLatestMarineData($limit = '', $sort = '', $filter = array())
265 265
 	{
266 266
 		global $global_marine_query;
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
      * @param string $id
296 296
      * @return array the spotter information
297 297
      */
298
-    public function getMarineDataByID($id = '')
298
+	public function getMarineDataByID($id = '')
299 299
 	{
300 300
 		global $global_marine_query;
301 301
 		
@@ -308,15 +308,15 @@  discard block
 block discarded – undo
308 308
 		return $spotter_array;
309 309
 	}
310 310
 
311
-    /**
312
-     * Gets all the spotter information based on the callsign
313
-     *
314
-     * @param string $ident
315
-     * @param string $limit
316
-     * @param string $sort
317
-     * @param array $filter
318
-     * @return array the spotter information
319
-     */
311
+	/**
312
+	 * Gets all the spotter information based on the callsign
313
+	 *
314
+	 * @param string $ident
315
+	 * @param string $limit
316
+	 * @param string $sort
317
+	 * @param array $filter
318
+	 * @return array the spotter information
319
+	 */
320 320
 	public function getMarineDataByIdent($ident = '', $limit = '', $sort = '', $filter = array())
321 321
 	{
322 322
 		global $global_marine_query;
@@ -367,15 +367,15 @@  discard block
 block discarded – undo
367 367
 		return $spotter_array;
368 368
 	}
369 369
 
370
-    /**
371
-     * Gets all the marine information based on the type
372
-     *
373
-     * @param string $type
374
-     * @param string $limit
375
-     * @param string $sort
376
-     * @param array $filter
377
-     * @return array the marine information
378
-     */
370
+	/**
371
+	 * Gets all the marine information based on the type
372
+	 *
373
+	 * @param string $type
374
+	 * @param string $limit
375
+	 * @param string $sort
376
+	 * @param array $filter
377
+	 * @return array the marine information
378
+	 */
379 379
 	public function getMarineDataByType($type = '', $limit = '', $sort = '', $filter = array())
380 380
 	{
381 381
 		global $global_marine_query;
@@ -421,14 +421,14 @@  discard block
 block discarded – undo
421 421
 		return $spotter_array;
422 422
 	}
423 423
 
424
-    /**
425
-     * @param string $date
426
-     * @param string $limit
427
-     * @param string $sort
428
-     * @param array $filter
429
-     * @return array
430
-     */
431
-    public function getMarineDataByDate($date = '', $limit = '', $sort = '', $filter = array())
424
+	/**
425
+	 * @param string $date
426
+	 * @param string $limit
427
+	 * @param string $sort
428
+	 * @param array $filter
429
+	 * @return array
430
+	 */
431
+	public function getMarineDataByDate($date = '', $limit = '', $sort = '', $filter = array())
432 432
 	{
433 433
 		global $global_marine_query, $globalTimezone, $globalDBdriver;
434 434
 		
@@ -485,15 +485,15 @@  discard block
 block discarded – undo
485 485
 		return $spotter_array;
486 486
 	}
487 487
 
488
-    /**
489
-     * Gets all the marine information based on the captain
490
-     *
491
-     * @param string $captain
492
-     * @param string $limit
493
-     * @param string $sort
494
-     * @param array $filter
495
-     * @return array the marine information
496
-     */
488
+	/**
489
+	 * Gets all the marine information based on the captain
490
+	 *
491
+	 * @param string $captain
492
+	 * @param string $limit
493
+	 * @param string $sort
494
+	 * @param array $filter
495
+	 * @return array the marine information
496
+	 */
497 497
 	public function getMarineDataByCaptain($captain = '', $limit = '', $sort = '', $filter = array())
498 498
 	{
499 499
 		global $global_marine_query;
@@ -531,15 +531,15 @@  discard block
 block discarded – undo
531 531
 		return $spotter_array;
532 532
 	}
533 533
 
534
-    /**
535
-     * Gets all the marine information based on the race
536
-     *
537
-     * @param string $race
538
-     * @param string $limit
539
-     * @param string $sort
540
-     * @param array $filter
541
-     * @return array the marine information
542
-     */
534
+	/**
535
+	 * Gets all the marine information based on the race
536
+	 *
537
+	 * @param string $race
538
+	 * @param string $limit
539
+	 * @param string $sort
540
+	 * @param array $filter
541
+	 * @return array the marine information
542
+	 */
543 543
 	public function getMarineDataByRace($race = '', $limit = '', $sort = '', $filter = array())
544 544
 	{
545 545
 		global $global_marine_query,$globalDBdriver;
@@ -581,13 +581,13 @@  discard block
 block discarded – undo
581 581
 		return $spotter_array;
582 582
 	}
583 583
 
584
-    /**
585
-     * Count races by captain
586
-     *
587
-     * @param $captain
588
-     * @param array $filters
589
-     * @return Integer number of race for a captain
590
-     */
584
+	/**
585
+	 * Count races by captain
586
+	 *
587
+	 * @param $captain
588
+	 * @param array $filters
589
+	 * @return Integer number of race for a captain
590
+	 */
591 591
 	public function countRacesByCaptain($captain,$filters = array())
592 592
 	{
593 593
 		$captain = filter_var($captain,FILTER_SANITIZE_STRING);
@@ -602,13 +602,13 @@  discard block
 block discarded – undo
602 602
 		return $result[0]['nb'];
603 603
 	}
604 604
 
605
-    /**
606
-     * Count captains by race
607
-     *
608
-     * @param $race
609
-     * @param array $filters
610
-     * @return String Duration of all races
611
-     */
605
+	/**
606
+	 * Count captains by race
607
+	 *
608
+	 * @param $race
609
+	 * @param array $filters
610
+	 * @return String Duration of all races
611
+	 */
612 612
 	public function countCaptainsByRace($race,$filters = array())
613 613
 	{
614 614
 		$race = filter_var($race,FILTER_SANITIZE_STRING);
@@ -623,16 +623,16 @@  discard block
 block discarded – undo
623 623
 		return $result[0]['nb'];
624 624
 	}
625 625
 
626
-    /**
627
-     * Gets all boat types that have been used by a captain
628
-     *
629
-     * @param $captain
630
-     * @param array $filters
631
-     * @param string $year
632
-     * @param string $month
633
-     * @param string $day
634
-     * @return array the boat list
635
-     */
626
+	/**
627
+	 * Gets all boat types that have been used by a captain
628
+	 *
629
+	 * @param $captain
630
+	 * @param array $filters
631
+	 * @param string $year
632
+	 * @param string $month
633
+	 * @param string $day
634
+	 * @return array the boat list
635
+	 */
636 636
 	public function countAllBoatTypesByCaptain($captain,$filters = array(),$year = '',$month = '',$day = '')
637 637
 	{
638 638
 		global $globalDBdriver;
@@ -676,16 +676,16 @@  discard block
 block discarded – undo
676 676
 		return $sth->fetchAll(PDO::FETCH_ASSOC);
677 677
 	}
678 678
 
679
-    /**
680
-     * Gets all boat types that have been used on a race
681
-     *
682
-     * @param $race
683
-     * @param array $filters
684
-     * @param string $year
685
-     * @param string $month
686
-     * @param string $day
687
-     * @return array the boat list
688
-     */
679
+	/**
680
+	 * Gets all boat types that have been used on a race
681
+	 *
682
+	 * @param $race
683
+	 * @param array $filters
684
+	 * @param string $year
685
+	 * @param string $month
686
+	 * @param string $day
687
+	 * @return array the boat list
688
+	 */
689 689
 	public function countAllBoatTypesByRace($race,$filters = array(),$year = '',$month = '',$day = '')
690 690
 	{
691 691
 		global $globalDBdriver;
@@ -729,16 +729,16 @@  discard block
 block discarded – undo
729 729
 		return $sth->fetchAll(PDO::FETCH_ASSOC);
730 730
 	}
731 731
 
732
-    /**
733
-     * Gets race duration by captain
734
-     *
735
-     * @param $captain
736
-     * @param array $filters
737
-     * @param string $year
738
-     * @param string $month
739
-     * @param string $day
740
-     * @return String Duration of all race
741
-     */
732
+	/**
733
+	 * Gets race duration by captain
734
+	 *
735
+	 * @param $captain
736
+	 * @param array $filters
737
+	 * @param string $year
738
+	 * @param string $month
739
+	 * @param string $day
740
+	 * @return String Duration of all race
741
+	 */
742 742
 	public function getRaceDurationByCaptain($captain,$filters = array(),$year = '',$month = '',$day = '')
743 743
 	{
744 744
 		global $globalDBdriver;
@@ -783,16 +783,16 @@  discard block
 block discarded – undo
783 783
 		else return $result[0]['duration'];
784 784
 	}
785 785
 
786
-    /**
787
-     * Gets race duration by captains
788
-     *
789
-     * @param bool $limit
790
-     * @param array $filters
791
-     * @param string $year
792
-     * @param string $month
793
-     * @param string $day
794
-     * @return array Duration of all race
795
-     */
786
+	/**
787
+	 * Gets race duration by captains
788
+	 *
789
+	 * @param bool $limit
790
+	 * @param array $filters
791
+	 * @param string $year
792
+	 * @param string $month
793
+	 * @param string $day
794
+	 * @return array Duration of all race
795
+	 */
796 796
 	public function getRaceDurationByCaptains($limit = true,$filters = array(),$year = '',$month = '',$day = '')
797 797
 	{
798 798
 		global $globalDBdriver;
@@ -850,12 +850,12 @@  discard block
 block discarded – undo
850 850
 
851 851
 	}
852 852
 
853
-    /**
854
-     * Gets a list of all captain names and captain ids
855
-     *
856
-     * @param array $filters
857
-     * @return array list of captain names and captain ids
858
-     */
853
+	/**
854
+	 * Gets a list of all captain names and captain ids
855
+	 *
856
+	 * @param array $filters
857
+	 * @return array list of captain names and captain ids
858
+	 */
859 859
 	public function getAllCaptainNames($filters = array())
860 860
 	{
861 861
 		$filter_query = $this->getFilter($filters,true,true);
@@ -868,12 +868,12 @@  discard block
 block discarded – undo
868 868
 		return $sth->fetchAll(PDO::FETCH_ASSOC);
869 869
 	}
870 870
 
871
-    /**
872
-     * Gets a list of all race names and race ids
873
-     *
874
-     * @param array $filters
875
-     * @return array list of race names and race ids
876
-     */
871
+	/**
872
+	 * Gets a list of all race names and race ids
873
+	 *
874
+	 * @param array $filters
875
+	 * @return array list of race names and race ids
876
+	 */
877 877
 	public function getAllRaceNames($filters = array())
878 878
 	{
879 879
 		$filter_query = $this->getFilter($filters,true,true);
@@ -887,13 +887,13 @@  discard block
 block discarded – undo
887 887
 	}
888 888
 
889 889
 
890
-    /**
891
-     * Gets all source name
892
-     *
893
-     * @param String type format of source
894
-     * @param array $filters
895
-     * @return array list of source name
896
-     */
890
+	/**
891
+	 * Gets all source name
892
+	 *
893
+	 * @param String type format of source
894
+	 * @param array $filters
895
+	 * @return array list of source name
896
+	 */
897 897
 	public function getAllSourceName($type = '',$filters = array())
898 898
 	{
899 899
 		$filter_query = $this->getFilter($filters,true,true);
@@ -922,12 +922,12 @@  discard block
 block discarded – undo
922 922
 	}
923 923
 
924 924
 
925
-    /**
926
-     * Gets a list of all idents/callsigns
927
-     *
928
-     * @param array $filters
929
-     * @return array list of ident/callsign names
930
-     */
925
+	/**
926
+	 * Gets a list of all idents/callsigns
927
+	 *
928
+	 * @param array $filters
929
+	 * @return array list of ident/callsign names
930
+	 */
931 931
 	public function getAllIdents($filters = array())
932 932
 	{
933 933
 		$filter_query = $this->getFilter($filters,true,true);
@@ -950,12 +950,12 @@  discard block
 block discarded – undo
950 950
 		return $ident_array;
951 951
 	}
952 952
 
953
-    /**
954
-     * Gets all info from a mmsi
955
-     *
956
-     * @param $mmsi
957
-     * @return array ident
958
-     */
953
+	/**
954
+	 * Gets all info from a mmsi
955
+	 *
956
+	 * @param $mmsi
957
+	 * @return array ident
958
+	 */
959 959
 	public function getIdentity($mmsi)
960 960
 	{
961 961
 		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
@@ -967,14 +967,14 @@  discard block
 block discarded – undo
967 967
 		else return array();
968 968
 	}
969 969
 
970
-    /**
971
-     * Add identity
972
-     * @param $mmsi
973
-     * @param $imo
974
-     * @param $ident
975
-     * @param $callsign
976
-     * @param $type
977
-     */
970
+	/**
971
+	 * Add identity
972
+	 * @param $mmsi
973
+	 * @param $imo
974
+	 * @param $ident
975
+	 * @param $callsign
976
+	 * @param $type
977
+	 */
978 978
 	public function addIdentity($mmsi,$imo,$ident,$callsign,$type)
979 979
 	{
980 980
 		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
@@ -1040,13 +1040,13 @@  discard block
 block discarded – undo
1040 1040
 	}
1041 1041
 
1042 1042
 	/**
1043
-	* Update ident tracker data
1044
-	*
1045
-	* @param String $fammarine_id the ID
1046
-	* @param String $ident the marine ident
1047
-	* @return String success or false
1048
-	*
1049
-	*/
1043
+	 * Update ident tracker data
1044
+	 *
1045
+	 * @param String $fammarine_id the ID
1046
+	 * @param String $ident the marine ident
1047
+	 * @return String success or false
1048
+	 *
1049
+	 */
1050 1050
 	public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL)
1051 1051
 	{
1052 1052
 		$query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id';
@@ -1061,13 +1061,13 @@  discard block
 block discarded – undo
1061 1061
 	}
1062 1062
 
1063 1063
 	/**
1064
-	* Update arrival marine data
1065
-	*
1066
-	* @param String $fammarine_id the ID
1067
-	* @param String $arrival_code the marine ident
1068
-	* @return String success or false
1069
-	*
1070
-	*/
1064
+	 * Update arrival marine data
1065
+	 *
1066
+	 * @param String $fammarine_id the ID
1067
+	 * @param String $arrival_code the marine ident
1068
+	 * @return String success or false
1069
+	 *
1070
+	 */
1071 1071
 	public function updateArrivalPortNameMarineData($fammarine_id = '', $arrival_code = '',$fromsource = NULL)
1072 1072
 	{
1073 1073
 		$query = 'UPDATE marine_output SET arrival_port_name = :arrival_code WHERE fammarine_id = :fammarine_id';
@@ -1082,19 +1082,19 @@  discard block
 block discarded – undo
1082 1082
 	}
1083 1083
 
1084 1084
 	/**
1085
-	* Update Status data
1086
-	*
1087
-	* @param String $fammarine_id the ID
1088
-	* @param String $status_id the marine status id
1089
-	* @param String $status the marine status
1090
-	* @return String success or false
1091
-	*
1092
-	*/
1085
+	 * Update Status data
1086
+	 *
1087
+	 * @param String $fammarine_id the ID
1088
+	 * @param String $status_id the marine status id
1089
+	 * @param String $status the marine status
1090
+	 * @return String success or false
1091
+	 *
1092
+	 */
1093 1093
 	public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '')
1094 1094
 	{
1095 1095
 
1096 1096
 		$query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id';
1097
-                $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id);
1097
+				$query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id);
1098 1098
 
1099 1099
 		try {
1100 1100
 			$sth = $this->db->prepare($query);
@@ -1107,22 +1107,22 @@  discard block
 block discarded – undo
1107 1107
 
1108 1108
 	}
1109 1109
 
1110
-    /**
1111
-     * Update latest marine data
1112
-     *
1113
-     * @param String $fammarine_id the ID
1114
-     * @param String $ident the marine ident
1115
-     * @param string $latitude
1116
-     * @param string $longitude
1117
-     * @param float $groundspeed
1118
-     * @param string $date
1119
-     * @param float $distance
1120
-     * @param integer $race_rank
1121
-     * @param integer $race_time
1122
-     * @param string $status
1123
-     * @param string $race_begin
1124
-     * @return String success or false
1125
-     */
1110
+	/**
1111
+	 * Update latest marine data
1112
+	 *
1113
+	 * @param String $fammarine_id the ID
1114
+	 * @param String $ident the marine ident
1115
+	 * @param string $latitude
1116
+	 * @param string $longitude
1117
+	 * @param float $groundspeed
1118
+	 * @param string $date
1119
+	 * @param float $distance
1120
+	 * @param integer $race_rank
1121
+	 * @param integer $race_time
1122
+	 * @param string $status
1123
+	 * @param string $race_begin
1124
+	 * @return String success or false
1125
+	 */
1126 1126
 	public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '',$distance = NULL,$race_rank = NULL, $race_time = NULL, $status = '', $race_begin = '')
1127 1127
 	{
1128 1128
 		if ($latitude == '') $latitude = NULL;
@@ -1147,36 +1147,36 @@  discard block
 block discarded – undo
1147 1147
 
1148 1148
 	}
1149 1149
 
1150
-    /**
1151
-     * Adds a new marine data
1152
-     *
1153
-     * @param String $fammarine_id the ID
1154
-     * @param String $ident the marine ident
1155
-     * @param String $latitude latitude of flight
1156
-     * @param String $longitude latitude of flight
1157
-     * @param String $heading heading of flight
1158
-     * @param String $groundspeed speed of flight
1159
-     * @param String $date date of flight
1160
-     * @param string $mmsi
1161
-     * @param string $type
1162
-     * @param string $typeid
1163
-     * @param string $imo
1164
-     * @param string $callsign
1165
-     * @param string $arrival_code
1166
-     * @param string $arrival_date
1167
-     * @param string $status
1168
-     * @param string $statusid
1169
-     * @param string $format_source
1170
-     * @param string $source_name
1171
-     * @param string $captain_id
1172
-     * @param string $captain_name
1173
-     * @param string $race_id
1174
-     * @param string $race_name
1175
-     * @param string $distance
1176
-     * @param string $race_rank
1177
-     * @param string $race_time
1178
-     * @return String success or false
1179
-     */
1150
+	/**
1151
+	 * Adds a new marine data
1152
+	 *
1153
+	 * @param String $fammarine_id the ID
1154
+	 * @param String $ident the marine ident
1155
+	 * @param String $latitude latitude of flight
1156
+	 * @param String $longitude latitude of flight
1157
+	 * @param String $heading heading of flight
1158
+	 * @param String $groundspeed speed of flight
1159
+	 * @param String $date date of flight
1160
+	 * @param string $mmsi
1161
+	 * @param string $type
1162
+	 * @param string $typeid
1163
+	 * @param string $imo
1164
+	 * @param string $callsign
1165
+	 * @param string $arrival_code
1166
+	 * @param string $arrival_date
1167
+	 * @param string $status
1168
+	 * @param string $statusid
1169
+	 * @param string $format_source
1170
+	 * @param string $source_name
1171
+	 * @param string $captain_id
1172
+	 * @param string $captain_name
1173
+	 * @param string $race_id
1174
+	 * @param string $race_name
1175
+	 * @param string $distance
1176
+	 * @param string $race_rank
1177
+	 * @param string $race_time
1178
+	 * @return String success or false
1179
+	 */
1180 1180
 	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 = '', $captain_id = '',$captain_name = '',$race_id = '', $race_name = '', $distance = '',$race_rank = '', $race_time = '')
1181 1181
 	{
1182 1182
 		global $globalMarineImageFetch;
@@ -1309,12 +1309,12 @@  discard block
 block discarded – undo
1309 1309
 	}
1310 1310
 
1311 1311
 
1312
-    /**
1313
-     * Gets the aircraft ident within the last hour
1314
-     *
1315
-     * @param $ident
1316
-     * @return String the ident
1317
-     */
1312
+	/**
1313
+	 * Gets the aircraft ident within the last hour
1314
+	 *
1315
+	 * @param $ident
1316
+	 * @return String the ident
1317
+	 */
1318 1318
 	public function getIdentFromLastHour($ident)
1319 1319
 	{
1320 1320
 		global $globalDBdriver, $globalTimezone;
@@ -1330,11 +1330,11 @@  discard block
 block discarded – undo
1330 1330
 								AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
1331 1331
 								AND marine_output.date < now() AT TIME ZONE 'UTC'";
1332 1332
 			$query_data = array(':ident' => $ident);
1333
-    		}
1333
+			}
1334 1334
 		
1335 1335
 		$sth = $this->db->prepare($query);
1336 1336
 		$sth->execute($query_data);
1337
-    		$ident_result='';
1337
+			$ident_result='';
1338 1338
 		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1339 1339
 		{
1340 1340
 			$ident_result = $row['ident'];
@@ -1344,12 +1344,12 @@  discard block
 block discarded – undo
1344 1344
 	}
1345 1345
 
1346 1346
 
1347
-    /**
1348
-     * Gets the aircraft data from the last 20 seconds
1349
-     *
1350
-     * @param string $q
1351
-     * @return array the marine data
1352
-     */
1347
+	/**
1348
+	 * Gets the aircraft data from the last 20 seconds
1349
+	 *
1350
+	 * @param string $q
1351
+	 * @return array the marine data
1352
+	 */
1353 1353
 	public function getRealTimeData($q = '')
1354 1354
 	{
1355 1355
 		global $globalDBdriver;
@@ -1384,15 +1384,15 @@  discard block
 block discarded – undo
1384 1384
 	}
1385 1385
 
1386 1386
 
1387
-    /**
1388
-     * Gets all number of flight over countries
1389
-     *
1390
-     * @param bool $limit
1391
-     * @param int $olderthanmonths
1392
-     * @param string $sincedate
1393
-     * @param array $filters
1394
-     * @return array the airline country list
1395
-     */
1387
+	/**
1388
+	 * Gets all number of flight over countries
1389
+	 *
1390
+	 * @param bool $limit
1391
+	 * @param int $olderthanmonths
1392
+	 * @param string $sincedate
1393
+	 * @param array $filters
1394
+	 * @return array the airline country list
1395
+	 */
1396 1396
 
1397 1397
 	public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
1398 1398
 	{
@@ -1463,18 +1463,18 @@  discard block
 block discarded – undo
1463 1463
 	}
1464 1464
 
1465 1465
 
1466
-    /**
1467
-     * Gets all callsigns that have flown over
1468
-     *
1469
-     * @param bool $limit
1470
-     * @param int $olderthanmonths
1471
-     * @param string $sincedate
1472
-     * @param array $filters
1473
-     * @param string $year
1474
-     * @param string $month
1475
-     * @param string $day
1476
-     * @return array the callsign list
1477
-     */
1466
+	/**
1467
+	 * Gets all callsigns that have flown over
1468
+	 *
1469
+	 * @param bool $limit
1470
+	 * @param int $olderthanmonths
1471
+	 * @param string $sincedate
1472
+	 * @param array $filters
1473
+	 * @param string $year
1474
+	 * @param string $month
1475
+	 * @param string $day
1476
+	 * @return array the callsign list
1477
+	 */
1478 1478
 	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
1479 1479
 	{
1480 1480
 		global $globalDBdriver;
@@ -1540,12 +1540,12 @@  discard block
 block discarded – undo
1540 1540
 	}
1541 1541
 
1542 1542
 
1543
-    /**
1544
-     * Counts all dates
1545
-     *
1546
-     * @param array $filters
1547
-     * @return array the date list
1548
-     */
1543
+	/**
1544
+	 * Counts all dates
1545
+	 *
1546
+	 * @param array $filters
1547
+	 * @return array the date list
1548
+	 */
1549 1549
 	public function countAllDates($filters = array())
1550 1550
 	{
1551 1551
 		global $globalTimezone, $globalDBdriver;
@@ -1590,12 +1590,12 @@  discard block
 block discarded – undo
1590 1590
 	}
1591 1591
 
1592 1592
 
1593
-    /**
1594
-     * Counts all dates during the last 7 days
1595
-     *
1596
-     * @param array $filters
1597
-     * @return array the date list
1598
-     */
1593
+	/**
1594
+	 * Counts all dates during the last 7 days
1595
+	 *
1596
+	 * @param array $filters
1597
+	 * @return array the date list
1598
+	 */
1599 1599
 	public function countAllDatesLast7Days($filters = array())
1600 1600
 	{
1601 1601
 		global $globalTimezone, $globalDBdriver;
@@ -1617,7 +1617,7 @@  discard block
 block discarded – undo
1617 1617
 			$query .= " GROUP BY date_name 
1618 1618
 								ORDER BY date_name ASC";
1619 1619
 			$query_data = array(':offset' => $offset);
1620
-    		}
1620
+			}
1621 1621
 		
1622 1622
 		$sth = $this->db->prepare($query);
1623 1623
 		$sth->execute($query_data);
@@ -1636,12 +1636,12 @@  discard block
 block discarded – undo
1636 1636
 		return $date_array;
1637 1637
 	}
1638 1638
 
1639
-    /**
1640
-     * Counts all dates during the last month
1641
-     *
1642
-     * @param array $filters
1643
-     * @return array the date list
1644
-     */
1639
+	/**
1640
+	 * Counts all dates during the last month
1641
+	 *
1642
+	 * @param array $filters
1643
+	 * @return array the date list
1644
+	 */
1645 1645
 	public function countAllDatesLastMonth($filters = array())
1646 1646
 	{
1647 1647
 		global $globalTimezone, $globalDBdriver;
@@ -1663,7 +1663,7 @@  discard block
 block discarded – undo
1663 1663
 			$query .= " GROUP BY date_name 
1664 1664
 								ORDER BY date_name ASC";
1665 1665
 			$query_data = array(':offset' => $offset);
1666
-    		}
1666
+			}
1667 1667
 		
1668 1668
 		$sth = $this->db->prepare($query);
1669 1669
 		$sth->execute($query_data);
@@ -1683,12 +1683,12 @@  discard block
 block discarded – undo
1683 1683
 	}
1684 1684
 
1685 1685
 
1686
-    /**
1687
-     * Counts all month
1688
-     *
1689
-     * @param array $filters
1690
-     * @return array the month list
1691
-     */
1686
+	/**
1687
+	 * Counts all month
1688
+	 *
1689
+	 * @param array $filters
1690
+	 * @return array the month list
1691
+	 */
1692 1692
 	public function countAllMonths($filters = array())
1693 1693
 	{
1694 1694
 		global $globalTimezone, $globalDBdriver;
@@ -1730,12 +1730,12 @@  discard block
 block discarded – undo
1730 1730
 	}
1731 1731
 
1732 1732
 
1733
-    /**
1734
-     * Counts all dates during the last year
1735
-     *
1736
-     * @param $filters
1737
-     * @return array the date list
1738
-     */
1733
+	/**
1734
+	 * Counts all dates during the last year
1735
+	 *
1736
+	 * @param $filters
1737
+	 * @return array the date list
1738
+	 */
1739 1739
 	public function countAllMonthsLastYear($filters)
1740 1740
 	{
1741 1741
 		global $globalTimezone, $globalDBdriver;
@@ -1757,7 +1757,7 @@  discard block
 block discarded – undo
1757 1757
 			$query .= " GROUP BY year_name, month_name
1758 1758
 								ORDER BY year_name, month_name ASC";
1759 1759
 			$query_data = array(':offset' => $offset);
1760
-    		}
1760
+			}
1761 1761
 		
1762 1762
 		$sth = $this->db->prepare($query);
1763 1763
 		$sth->execute($query_data);
@@ -1778,13 +1778,13 @@  discard block
 block discarded – undo
1778 1778
 	}
1779 1779
 
1780 1780
 
1781
-    /**
1782
-     * Counts all hours
1783
-     *
1784
-     * @param $orderby
1785
-     * @param array $filters
1786
-     * @return array the hour list
1787
-     */
1781
+	/**
1782
+	 * Counts all hours
1783
+	 *
1784
+	 * @param $orderby
1785
+	 * @param array $filters
1786
+	 * @return array the hour list
1787
+	 */
1788 1788
 	public function countAllHours($orderby,$filters = array())
1789 1789
 	{
1790 1790
 		global $globalTimezone, $globalDBdriver;
@@ -1845,13 +1845,13 @@  discard block
 block discarded – undo
1845 1845
 	}
1846 1846
 
1847 1847
 
1848
-    /**
1849
-     * Counts all hours by date
1850
-     *
1851
-     * @param $date
1852
-     * @param array $filters
1853
-     * @return array the hour list
1854
-     */
1848
+	/**
1849
+	 * Counts all hours by date
1850
+	 *
1851
+	 * @param $date
1852
+	 * @param array $filters
1853
+	 * @return array the hour list
1854
+	 */
1855 1855
 	public function countAllHoursByDate($date, $filters = array())
1856 1856
 	{
1857 1857
 		global $globalTimezone, $globalDBdriver;
@@ -1893,13 +1893,13 @@  discard block
 block discarded – undo
1893 1893
 	}
1894 1894
 
1895 1895
 
1896
-    /**
1897
-     * Counts all hours by a ident/callsign
1898
-     *
1899
-     * @param $ident
1900
-     * @param array $filters
1901
-     * @return array the hour list
1902
-     */
1896
+	/**
1897
+	 * Counts all hours by a ident/callsign
1898
+	 *
1899
+	 * @param $ident
1900
+	 * @param array $filters
1901
+	 * @return array the hour list
1902
+	 */
1903 1903
 	public function countAllHoursByIdent($ident, $filters = array())
1904 1904
 	{
1905 1905
 		global $globalTimezone, $globalDBdriver;
@@ -1941,15 +1941,15 @@  discard block
 block discarded – undo
1941 1941
 		return $hour_array;
1942 1942
 	}
1943 1943
 
1944
-    /**
1945
-     * Gets all aircraft registrations that have flown over
1946
-     *
1947
-     * @param bool $limit
1948
-     * @param int $olderthanmonths
1949
-     * @param string $sincedate
1950
-     * @param array $filters
1951
-     * @return array the aircraft list
1952
-     */
1944
+	/**
1945
+	 * Gets all aircraft registrations that have flown over
1946
+	 *
1947
+	 * @param bool $limit
1948
+	 * @param int $olderthanmonths
1949
+	 * @param string $sincedate
1950
+	 * @param array $filters
1951
+	 * @return array the aircraft list
1952
+	 */
1953 1953
 	public function countAllCaptainsByRaces($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
1954 1954
 	{
1955 1955
 		global $globalDBdriver;
@@ -1987,14 +1987,14 @@  discard block
 block discarded – undo
1987 1987
 		return $marine_array;
1988 1988
 	}
1989 1989
 
1990
-    /**
1991
-     * Counts all vessels
1992
-     *
1993
-     * @param array $filters
1994
-     * @param string $year
1995
-     * @param string $month
1996
-     * @return Integer the number of vessels
1997
-     */
1990
+	/**
1991
+	 * Counts all vessels
1992
+	 *
1993
+	 * @param array $filters
1994
+	 * @param string $year
1995
+	 * @param string $month
1996
+	 * @return Integer the number of vessels
1997
+	 */
1998 1998
 	public function countOverallMarine($filters = array(),$year = '',$month = '')
1999 1999
 	{
2000 2000
 		global $globalDBdriver;
@@ -2028,14 +2028,14 @@  discard block
 block discarded – undo
2028 2028
 		return $sth->fetchColumn();
2029 2029
 	}
2030 2030
 
2031
-    /**
2032
-     * Counts all vessel type
2033
-     *
2034
-     * @param array $filters
2035
-     * @param string $year
2036
-     * @param string $month
2037
-     * @return Integer the number of vessels
2038
-     */
2031
+	/**
2032
+	 * Counts all vessel type
2033
+	 *
2034
+	 * @param array $filters
2035
+	 * @param string $year
2036
+	 * @param string $month
2037
+	 * @return Integer the number of vessels
2038
+	 */
2039 2039
 	public function countOverallMarineTypes($filters = array(),$year = '',$month = '')
2040 2040
 	{
2041 2041
 		global $globalDBdriver;
@@ -2068,14 +2068,14 @@  discard block
 block discarded – undo
2068 2068
 		return $sth->fetchColumn();
2069 2069
 	}
2070 2070
 
2071
-    /**
2072
-     * Gets a number of all race
2073
-     *
2074
-     * @param array $filters
2075
-     * @param string $year
2076
-     * @param string $month
2077
-     * @return Integer number of races
2078
-     */
2071
+	/**
2072
+	 * Gets a number of all race
2073
+	 *
2074
+	 * @param array $filters
2075
+	 * @param string $year
2076
+	 * @param string $month
2077
+	 * @return Integer number of races
2078
+	 */
2079 2079
 	public function countOverallMarineRaces($filters = array(),$year = '',$month = '')
2080 2080
 	{
2081 2081
 		global $globalDBdriver;
@@ -2108,14 +2108,14 @@  discard block
 block discarded – undo
2108 2108
 		return $sth->fetchColumn();
2109 2109
 	}
2110 2110
 
2111
-    /**
2112
-     * Gets a number of all captain
2113
-     *
2114
-     * @param array $filters
2115
-     * @param string $year
2116
-     * @param string $month
2117
-     * @return Integer number of captain
2118
-     */
2111
+	/**
2112
+	 * Gets a number of all captain
2113
+	 *
2114
+	 * @param array $filters
2115
+	 * @param string $year
2116
+	 * @param string $month
2117
+	 * @return Integer number of captain
2118
+	 */
2119 2119
 	public function countOverallMarineCaptains($filters = array(),$year = '',$month = '')
2120 2120
 	{
2121 2121
 		global $globalDBdriver;
@@ -2148,12 +2148,12 @@  discard block
 block discarded – undo
2148 2148
 		return $sth->fetchColumn();
2149 2149
 	}
2150 2150
 
2151
-    /**
2152
-     * Counts all hours of today
2153
-     *
2154
-     * @param array $filters
2155
-     * @return array the hour list
2156
-     */
2151
+	/**
2152
+	 * Counts all hours of today
2153
+	 *
2154
+	 * @param array $filters
2155
+	 * @return array the hour list
2156
+	 */
2157 2157
 	public function countAllHoursFromToday($filters = array())
2158 2158
 	{
2159 2159
 		global $globalTimezone, $globalDBdriver;
@@ -2193,12 +2193,12 @@  discard block
 block discarded – undo
2193 2193
 	}
2194 2194
 
2195 2195
 
2196
-    /**
2197
-     * Gets the Barrie Spotter ID based on the FlightAware ID
2198
-     *
2199
-     * @param $fammarine_id
2200
-     * @return Integer the Barrie Spotter ID
2201
-     */
2196
+	/**
2197
+	 * Gets the Barrie Spotter ID based on the FlightAware ID
2198
+	 *
2199
+	 * @param $fammarine_id
2200
+	 * @return Integer the Barrie Spotter ID
2201
+	 */
2202 2202
 	public function getMarineIDBasedOnFamMarineID($fammarine_id)
2203 2203
 	{
2204 2204
 		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
@@ -2219,13 +2219,13 @@  discard block
 block discarded – undo
2219 2219
   
2220 2220
  
2221 2221
 	/**
2222
-	* Parses a date string
2223
-	*
2224
-	* @param String $dateString the date string
2225
-	* @param String $timezone the timezone of a user
2226
-	* @return array the time information
2227
-	*
2228
-	*/
2222
+	 * Parses a date string
2223
+	 *
2224
+	 * @param String $dateString the date string
2225
+	 * @param String $timezone the timezone of a user
2226
+	 * @return array the time information
2227
+	 *
2228
+	 */
2229 2229
 	public function parseDateString($dateString, $timezone = '')
2230 2230
 	{
2231 2231
 		$time_array = array();
@@ -2258,12 +2258,12 @@  discard block
 block discarded – undo
2258 2258
 	}
2259 2259
 	
2260 2260
 	/**
2261
-	* Parses the direction degrees to working
2262
-	*
2263
-	* @param Float $direction the direction in degrees
2264
-	* @return array the direction information
2265
-	*
2266
-	*/
2261
+	 * Parses the direction degrees to working
2262
+	 *
2263
+	 * @param Float $direction the direction in degrees
2264
+	 * @return array the direction information
2265
+	 *
2266
+	 */
2267 2267
 	public function parseDirection($direction = 0)
2268 2268
 	{
2269 2269
 		if ($direction == '') $direction = 0;
@@ -2342,12 +2342,12 @@  discard block
 block discarded – undo
2342 2342
 	
2343 2343
 	
2344 2344
 	/**
2345
-	* Gets Country from latitude/longitude
2346
-	*
2347
-	* @param Float $latitude latitute of the flight
2348
-	* @param Float $longitude longitute of the flight
2349
-	* @return String the countries
2350
-	*/
2345
+	 * Gets Country from latitude/longitude
2346
+	 *
2347
+	 * @param Float $latitude latitute of the flight
2348
+	 * @param Float $longitude longitute of the flight
2349
+	 * @return String the countries
2350
+	 */
2351 2351
 	public function getCountryFromLatitudeLongitude($latitude,$longitude)
2352 2352
 	{
2353 2353
 		global $globalDebug;
@@ -2384,11 +2384,11 @@  discard block
 block discarded – undo
2384 2384
 	}
2385 2385
 
2386 2386
 	/**
2387
-	* Gets Country from iso2
2388
-	*
2389
-	* @param String $iso2 ISO2 country code
2390
-	* @return String the countries
2391
-	*/
2387
+	 * Gets Country from iso2
2388
+	 *
2389
+	 * @param String $iso2 ISO2 country code
2390
+	 * @return String the countries
2391
+	 */
2392 2392
 	public function getCountryFromISO2($iso2)
2393 2393
 	{
2394 2394
 		global $globalDebug;
@@ -2417,12 +2417,12 @@  discard block
 block discarded – undo
2417 2417
 
2418 2418
 	
2419 2419
 	/**
2420
-	* Gets the short url from bit.ly
2421
-	*
2422
-	* @param String $url the full url
2423
-	* @return String the bit.ly url
2424
-	*
2425
-	*/
2420
+	 * Gets the short url from bit.ly
2421
+	 *
2422
+	 * @param String $url the full url
2423
+	 * @return String the bit.ly url
2424
+	 *
2425
+	 */
2426 2426
 	public function getBitlyURL($url)
2427 2427
 	{
2428 2428
 		global $globalBitlyAccessToken;
@@ -2448,18 +2448,18 @@  discard block
 block discarded – undo
2448 2448
 	}
2449 2449
 
2450 2450
 
2451
-    /**
2452
-     * Gets all vessels types that have flown over
2453
-     *
2454
-     * @param bool $limit
2455
-     * @param int $olderthanmonths
2456
-     * @param string $sincedate
2457
-     * @param array $filters
2458
-     * @param string $year
2459
-     * @param string $month
2460
-     * @param string $day
2461
-     * @return array the vessel type list
2462
-     */
2451
+	/**
2452
+	 * Gets all vessels types that have flown over
2453
+	 *
2454
+	 * @param bool $limit
2455
+	 * @param int $olderthanmonths
2456
+	 * @param string $sincedate
2457
+	 * @param array $filters
2458
+	 * @param string $year
2459
+	 * @param string $month
2460
+	 * @param string $day
2461
+	 * @return array the vessel type list
2462
+	 */
2463 2463
 	public function countAllMarineTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
2464 2464
 	{
2465 2465
 		global $globalDBdriver;
@@ -2524,27 +2524,27 @@  discard block
 block discarded – undo
2524 2524
 		return $marine_array;
2525 2525
 	}
2526 2526
 
2527
-    /**
2528
-     * Gets all the tracker information
2529
-     *
2530
-     * @param string $q
2531
-     * @param string $callsign
2532
-     * @param string $mmsi
2533
-     * @param string $imo
2534
-     * @param string $date_posted
2535
-     * @param string $limit
2536
-     * @param string $sort
2537
-     * @param string $includegeodata
2538
-     * @param string $origLat
2539
-     * @param string $origLon
2540
-     * @param string $dist
2541
-     * @param string $captain_id
2542
-     * @param string $captain_name
2543
-     * @param string $race_id
2544
-     * @param string $race_name
2545
-     * @param array $filters
2546
-     * @return array the tracker information
2547
-     */
2527
+	/**
2528
+	 * Gets all the tracker information
2529
+	 *
2530
+	 * @param string $q
2531
+	 * @param string $callsign
2532
+	 * @param string $mmsi
2533
+	 * @param string $imo
2534
+	 * @param string $date_posted
2535
+	 * @param string $limit
2536
+	 * @param string $sort
2537
+	 * @param string $includegeodata
2538
+	 * @param string $origLat
2539
+	 * @param string $origLon
2540
+	 * @param string $dist
2541
+	 * @param string $captain_id
2542
+	 * @param string $captain_name
2543
+	 * @param string $race_id
2544
+	 * @param string $race_name
2545
+	 * @param array $filters
2546
+	 * @return array the tracker information
2547
+	 */
2548 2548
 	public function searchMarineData($q = '', $callsign = '',$mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '',$captain_id = '',$captain_name = '',$race_id = '',$race_name = '',$filters = array())
2549 2549
 	{
2550 2550
 		global $globalTimezone, $globalDBdriver;
@@ -2720,12 +2720,12 @@  discard block
 block discarded – undo
2720 2720
 		return $marine_array;
2721 2721
 	}
2722 2722
 
2723
-    /**
2724
-     * Check marine by id
2725
-     *
2726
-     * @param $id
2727
-     * @return String the ident
2728
-     */
2723
+	/**
2724
+	 * Check marine by id
2725
+	 *
2726
+	 * @param $id
2727
+	 * @return String the ident
2728
+	 */
2729 2729
 	public function checkId($id)
2730 2730
 	{
2731 2731
 		$query  = 'SELECT marine_output.ident, marine_output.fammarine_id FROM marine_output WHERE marine_output.fammarine_id = :id';
@@ -2740,12 +2740,12 @@  discard block
 block discarded – undo
2740 2740
 		return $ident_result;
2741 2741
 	}
2742 2742
 
2743
-    /**
2744
-     * Gets all info from a race
2745
-     *
2746
-     * @param $race_name
2747
-     * @return array race
2748
-     */
2743
+	/**
2744
+	 * Gets all info from a race
2745
+	 *
2746
+	 * @param $race_name
2747
+	 * @return array race
2748
+	 */
2749 2749
 	public function getRaceByName($race_name)
2750 2750
 	{
2751 2751
 		$race_name = filter_var($race_name,FILTER_SANITIZE_STRING);
@@ -2757,12 +2757,12 @@  discard block
 block discarded – undo
2757 2757
 		else return array();
2758 2758
 	}
2759 2759
 
2760
-    /**
2761
-     * Gets all info from a race
2762
-     *
2763
-     * @param $race_id
2764
-     * @return array race
2765
-     */
2760
+	/**
2761
+	 * Gets all info from a race
2762
+	 *
2763
+	 * @param $race_id
2764
+	 * @return array race
2765
+	 */
2766 2766
 	public function getRace($race_id)
2767 2767
 	{
2768 2768
 		$race_id = filter_var($race_id,FILTER_SANITIZE_NUMBER_INT);
@@ -2774,15 +2774,15 @@  discard block
 block discarded – undo
2774 2774
 		else return array();
2775 2775
 	}
2776 2776
 
2777
-    /**
2778
-     * Add race
2779
-     * @param $race_id
2780
-     * @param $race_name
2781
-     * @param $race_creator
2782
-     * @param $race_desc
2783
-     * @param $race_startdate
2784
-     * @param $race_markers
2785
-     */
2777
+	/**
2778
+	 * Add race
2779
+	 * @param $race_id
2780
+	 * @param $race_name
2781
+	 * @param $race_creator
2782
+	 * @param $race_desc
2783
+	 * @param $race_startdate
2784
+	 * @param $race_markers
2785
+	 */
2786 2786
 	public function addRace($race_id,$race_name,$race_creator,$race_desc,$race_startdate,$race_markers)
2787 2787
 	{
2788 2788
 		$race_id = filter_var($race_id,FILTER_SANITIZE_NUMBER_INT);
Please login to merge, or discard this patch.
Spacing   +326 added lines, -326 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 require_once(dirname(__FILE__).'/class.Image.php');
10 10
 $global_marine_query = "SELECT marine_output.* FROM marine_output";
11 11
 
12
-class Marine{
12
+class Marine {
13 13
 	public $db;
14 14
 	
15 15
 	public function __construct($dbc = null) {
@@ -25,33 +25,33 @@  discard block
 block discarded – undo
25 25
      * @param bool $and
26 26
      * @return string the SQL part
27 27
      */
28
-	public function getFilter($filter = array(),$where = false,$and = false) {
28
+	public function getFilter($filter = array(), $where = false, $and = false) {
29 29
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
30 30
 		$filters = array();
31 31
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
32 32
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
33 33
 				$filters = $globalStatsFilters[$globalFilterName];
34 34
 			} else {
35
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
35
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
36 36
 			}
37 37
 		}
38 38
 		if (isset($filter[0]['source'])) {
39
-			$filters = array_merge($filters,$filter);
39
+			$filters = array_merge($filters, $filter);
40 40
 		}
41
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
41
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
42 42
 		$filter_query_join = '';
43 43
 		$filter_query_where = '';
44
-		foreach($filters as $flt) {
44
+		foreach ($filters as $flt) {
45 45
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
46 46
 				if (isset($flt['source'])) {
47
-					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."') AND marine_output.format_source IN ('".implode("','",$flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id";
47
+					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND marine_output.format_source IN ('".implode("','", $flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id";
48 48
 				} else {
49
-					$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";
49
+					$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";
50 50
 				}
51 51
 			}
52 52
 		}
53 53
 		if (isset($filter['source']) && !empty($filter['source'])) {
54
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
54
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
55 55
 		}
56 56
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
57 57
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
90 90
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
91 91
 		if ($filter_query_where != '') {
92
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
92
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
93 93
 		}
94 94
 		$filter_query = $filter_query_join.$filter_query_where;
95 95
 		return $filter_query;
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
      * @param bool $schedules
105 105
      * @return array the spotter information
106 106
      */
107
-	public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false)
107
+	public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false)
108 108
 	{
109 109
 		global $globalVM;
110 110
 		date_default_timezone_set('UTC');
@@ -125,13 +125,13 @@  discard block
 block discarded – undo
125 125
 			$sth = $this->db->prepare($query.$limitQuery);
126 126
 			$sth->execute($params);
127 127
 		} catch (PDOException $e) {
128
-			printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery);
128
+			printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery);
129 129
 			exit();
130 130
 		}
131 131
 		
132 132
 		$num_rows = 0;
133 133
 		$spotter_array = array();
134
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
134
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
135 135
 		{
136 136
 			$num_rows++;
137 137
 			$temp_array = array();
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 			}
151 151
 			if (isset($row['fammarine_id'])) $temp_array['fammarine_id'] = $row['fammarine_id'];
152 152
 			if (isset($row['mmsi'])) $temp_array['mmsi'] = $row['mmsi'];
153
-			if (isset($row['type'])) $temp_array['type'] = html_entity_decode($row['type'],ENT_QUOTES);
153
+			if (isset($row['type'])) $temp_array['type'] = html_entity_decode($row['type'], ENT_QUOTES);
154 154
 			if (isset($row['type_id'])) $temp_array['type_id'] = $row['type_id'];
155 155
 			if (isset($row['status'])) $temp_array['status'] = $row['status'];
156 156
 			if (isset($row['status_id'])) $temp_array['status_id'] = $row['status_id'];
@@ -173,10 +173,10 @@  discard block
 block discarded – undo
173 173
 			}
174 174
 			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];
175 175
 
176
-			if(isset($temp_array['mmsi']) && $temp_array['mmsi'] != "")
176
+			if (isset($temp_array['mmsi']) && $temp_array['mmsi'] != "")
177 177
 			{
178 178
 				$Image = new Image($this->db);
179
-				if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']);
179
+				if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'], '', $temp_array['ident']);
180 180
 				else $image_array = $Image->getMarineImage($temp_array['mmsi']);
181 181
 				unset($Image);
182 182
 				if (count($image_array) > 0) {
@@ -186,10 +186,10 @@  discard block
 block discarded – undo
186 186
 					$temp_array['image_source_website'] = $image_array[0]['image_source_website'];
187 187
 					$temp_array['image_copyright'] = $image_array[0]['image_copyright'];
188 188
 				}
189
-			} elseif(isset($temp_array['type']) && $temp_array['type'] != "")
189
+			} elseif (isset($temp_array['type']) && $temp_array['type'] != "")
190 190
 			{
191 191
 				$Image = new Image($this->db);
192
-				$image_array = $Image->getMarineImage('','','',$temp_array['type']);
192
+				$image_array = $Image->getMarineImage('', '', '', $temp_array['type']);
193 193
 				unset($Image);
194 194
 				if (count($image_array) > 0) {
195 195
 					$temp_array['image'] = $image_array[0]['image'];
@@ -224,17 +224,17 @@  discard block
 block discarded – undo
224 224
 				{
225 225
 					$temp_array['date'] = "about ".$dateArray['hours']." hours ago";
226 226
 				} else {
227
-					$temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC"));
227
+					$temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC"));
228 228
 				}
229 229
 				$temp_array['date_minutes_past'] = $dateArray['minutes'];
230
-				$temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC"));
231
-				$temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC"));
230
+				$temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC"));
231
+				$temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC"));
232 232
 				$temp_array['date_unix'] = strtotime($row['date']." UTC");
233 233
 				if (isset($row['last_seen']) && $row['last_seen'] != '') {
234 234
 					if (strtotime($row['last_seen']) > strtotime($row['date'])) {
235 235
 						$temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']);
236
-						$temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC"));
237
-						$temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC"));
236
+						$temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC"));
237
+						$temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC"));
238 238
 						$temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC");
239 239
 					}
240 240
 				}
@@ -269,8 +269,8 @@  discard block
 block discarded – undo
269 269
 		if ($limit != "")
270 270
 		{
271 271
 			$limit_array = explode(",", $limit);
272
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
273
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
272
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
273
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
274 274
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
275 275
 			{
276 276
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
@@ -284,8 +284,8 @@  discard block
 block discarded – undo
284 284
 		} else {
285 285
 			$orderby_query = " ORDER BY marine_output.date DESC";
286 286
 		}
287
-		$query  = $global_marine_query.$filter_query." ".$orderby_query;
288
-		$spotter_array = $this->getDataFromDB($query, array(),$limit_query,true);
287
+		$query = $global_marine_query.$filter_query." ".$orderby_query;
288
+		$spotter_array = $this->getDataFromDB($query, array(), $limit_query, true);
289 289
 		return $spotter_array;
290 290
 	}
291 291
     
@@ -303,8 +303,8 @@  discard block
 block discarded – undo
303 303
 		if ($id == '') return array();
304 304
 		$additional_query = "marine_output.fammarine_id = :id";
305 305
 		$query_values = array(':id' => $id);
306
-		$query  = $global_marine_query." WHERE ".$additional_query." ";
307
-		$spotter_array = $this->getDataFromDB($query,$query_values);
306
+		$query = $global_marine_query." WHERE ".$additional_query." ";
307
+		$spotter_array = $this->getDataFromDB($query, $query_values);
308 308
 		return $spotter_array;
309 309
 	}
310 310
 
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
 		$query_values = array();
327 327
 		$limit_query = '';
328 328
 		$additional_query = '';
329
-		$filter_query = $this->getFilter($filter,true,true);
329
+		$filter_query = $this->getFilter($filter, true, true);
330 330
 		if ($ident != "")
331 331
 		{
332 332
 			if (!is_string($ident))
@@ -342,8 +342,8 @@  discard block
 block discarded – undo
342 342
 		{
343 343
 			$limit_array = explode(",", $limit);
344 344
 			
345
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
346
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
345
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
346
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
347 347
 			
348 348
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
349 349
 			{
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
 		date_default_timezone_set('UTC');
384 384
 		
385 385
 		$limit_query = '';
386
-		$filter_query = $this->getFilter($filter,true,true);
386
+		$filter_query = $this->getFilter($filter, true, true);
387 387
 		if (!is_string($type))
388 388
 		{
389 389
 			return array();
@@ -396,8 +396,8 @@  discard block
 block discarded – undo
396 396
 		{
397 397
 			$limit_array = explode(",", $limit);
398 398
 			
399
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
400
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
399
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
400
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
401 401
 			
402 402
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
403 403
 			{
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
 		$limit_query = '';
437 437
 		$additional_query = '';
438 438
 
439
-		$filter_query = $this->getFilter($filter,true,true);
439
+		$filter_query = $this->getFilter($filter, true, true);
440 440
 		
441 441
 		if ($date != "")
442 442
 		{
@@ -462,8 +462,8 @@  discard block
 block discarded – undo
462 462
 		{
463 463
 			$limit_array = explode(",", $limit);
464 464
 			
465
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
466
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
465
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
466
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
467 467
 			
468 468
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
469 469
 			{
@@ -501,8 +501,8 @@  discard block
 block discarded – undo
501 501
 		$query_values = array();
502 502
 		$limit_query = '';
503 503
 		$additional_query = '';
504
-		$filter_query = $this->getFilter($filter,true,true);
505
-		$captain = filter_var($captain,FILTER_SANITIZE_STRING);
504
+		$filter_query = $this->getFilter($filter, true, true);
505
+		$captain = filter_var($captain, FILTER_SANITIZE_STRING);
506 506
 		if ($captain != "")
507 507
 		{
508 508
 			$additional_query = " AND (marine_output.captain_name = :captain OR marine_output.captain_id = :captain)";
@@ -511,8 +511,8 @@  discard block
 block discarded – undo
511 511
 		if ($limit != "")
512 512
 		{
513 513
 			$limit_array = explode(",", $limit);
514
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
515
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
514
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
515
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
516 516
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
517 517
 			{
518 518
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
@@ -542,13 +542,13 @@  discard block
 block discarded – undo
542 542
      */
543 543
 	public function getMarineDataByRace($race = '', $limit = '', $sort = '', $filter = array())
544 544
 	{
545
-		global $global_marine_query,$globalDBdriver;
545
+		global $global_marine_query, $globalDBdriver;
546 546
 		date_default_timezone_set('UTC');
547 547
 		$query_values = array();
548 548
 		$limit_query = '';
549 549
 		$additional_query = '';
550
-		$filter_query = $this->getFilter($filter,true,true);
551
-		$race = filter_var($race,FILTER_SANITIZE_STRING);
550
+		$filter_query = $this->getFilter($filter, true, true);
551
+		$race = filter_var($race, FILTER_SANITIZE_STRING);
552 552
 		if ($race != "")
553 553
 		{
554 554
 			$additional_query = " AND (marine_output.race_name = :race OR marine_output.race_id = :race)";
@@ -557,8 +557,8 @@  discard block
 block discarded – undo
557 557
 		if ($limit != "")
558 558
 		{
559 559
 			$limit_array = explode(",", $limit);
560
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
561
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
560
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
561
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
562 562
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
563 563
 			{
564 564
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
@@ -588,14 +588,14 @@  discard block
 block discarded – undo
588 588
      * @param array $filters
589 589
      * @return Integer number of race for a captain
590 590
      */
591
-	public function countRacesByCaptain($captain,$filters = array())
591
+	public function countRacesByCaptain($captain, $filters = array())
592 592
 	{
593
-		$captain = filter_var($captain,FILTER_SANITIZE_STRING);
594
-		$filter_query = $this->getFilter($filters,true,true);
595
-		$query  = "SELECT COUNT(*) AS nb 
593
+		$captain = filter_var($captain, FILTER_SANITIZE_STRING);
594
+		$filter_query = $this->getFilter($filters, true, true);
595
+		$query = "SELECT COUNT(*) AS nb 
596 596
 			FROM marine_output".$filter_query." (marine_output.captain_name = :captain OR marine_output.captain_id = :captain)";
597 597
 		$query_values = array();
598
-		$query_values = array_merge($query_values,array(':captain' => $captain));
598
+		$query_values = array_merge($query_values, array(':captain' => $captain));
599 599
 		$sth = $this->db->prepare($query);
600 600
 		$sth->execute($query_values);
601 601
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -609,14 +609,14 @@  discard block
 block discarded – undo
609 609
      * @param array $filters
610 610
      * @return String Duration of all races
611 611
      */
612
-	public function countCaptainsByRace($race,$filters = array())
612
+	public function countCaptainsByRace($race, $filters = array())
613 613
 	{
614
-		$race = filter_var($race,FILTER_SANITIZE_STRING);
615
-		$filter_query = $this->getFilter($filters,true,true);
616
-		$query  = "SELECT COUNT(*) AS nb 
614
+		$race = filter_var($race, FILTER_SANITIZE_STRING);
615
+		$filter_query = $this->getFilter($filters, true, true);
616
+		$query = "SELECT COUNT(*) AS nb 
617 617
 			FROM marine_output".$filter_query." (marine_output.race_name = :race OR marine_output.race_id = :race)";
618 618
 		$query_values = array();
619
-		$query_values = array_merge($query_values,array(':race' => $race));
619
+		$query_values = array_merge($query_values, array(':race' => $race));
620 620
 		$sth = $this->db->prepare($query);
621 621
 		$sth->execute($query_values);
622 622
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -633,44 +633,44 @@  discard block
 block discarded – undo
633 633
      * @param string $day
634 634
      * @return array the boat list
635 635
      */
636
-	public function countAllBoatTypesByCaptain($captain,$filters = array(),$year = '',$month = '',$day = '')
636
+	public function countAllBoatTypesByCaptain($captain, $filters = array(), $year = '', $month = '', $day = '')
637 637
 	{
638 638
 		global $globalDBdriver;
639
-		$filter_query = $this->getFilter($filters,true,true);
640
-		$captain = filter_var($captain,FILTER_SANITIZE_STRING);
641
-		$query  = "SELECT DISTINCT marine_output.type, COUNT(marine_output.type) AS type_count
639
+		$filter_query = $this->getFilter($filters, true, true);
640
+		$captain = filter_var($captain, FILTER_SANITIZE_STRING);
641
+		$query = "SELECT DISTINCT marine_output.type, COUNT(marine_output.type) AS type_count
642 642
 			FROM marine_output".$filter_query." (marine_output.captain_id = :captain OR marine_output.captain_name = :captain)";
643 643
 		$query_values = array();
644 644
 		if ($year != '') {
645 645
 			if ($globalDBdriver == 'mysql') {
646 646
 				$query .= " AND YEAR(marine_output.date) = :year";
647
-				$query_values = array_merge($query_values,array(':year' => $year));
647
+				$query_values = array_merge($query_values, array(':year' => $year));
648 648
 			} else {
649 649
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
650
-				$query_values = array_merge($query_values,array(':year' => $year));
650
+				$query_values = array_merge($query_values, array(':year' => $year));
651 651
 			}
652 652
 		}
653 653
 		if ($month != '') {
654 654
 			if ($globalDBdriver == 'mysql') {
655 655
 				$query .= " AND MONTH(marine_output.date) = :month";
656
-				$query_values = array_merge($query_values,array(':month' => $month));
656
+				$query_values = array_merge($query_values, array(':month' => $month));
657 657
 			} else {
658 658
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
659
-				$query_values = array_merge($query_values,array(':month' => $month));
659
+				$query_values = array_merge($query_values, array(':month' => $month));
660 660
 			}
661 661
 		}
662 662
 		if ($day != '') {
663 663
 			if ($globalDBdriver == 'mysql') {
664 664
 				$query .= " AND DAY(marine_output.date) = :day";
665
-				$query_values = array_merge($query_values,array(':day' => $day));
665
+				$query_values = array_merge($query_values, array(':day' => $day));
666 666
 			} else {
667 667
 				$query .= " AND EXTRACT(DAY FROM marine_output.date) = :day";
668
-				$query_values = array_merge($query_values,array(':day' => $day));
668
+				$query_values = array_merge($query_values, array(':day' => $day));
669 669
 			}
670 670
 		}
671 671
 		$query .= " GROUP BY marine_output.type
672 672
 			ORDER BY type_count DESC";
673
-		$query_values = array_merge($query_values,array(':captain' => $captain));
673
+		$query_values = array_merge($query_values, array(':captain' => $captain));
674 674
 		$sth = $this->db->prepare($query);
675 675
 		$sth->execute($query_values);
676 676
 		return $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -686,44 +686,44 @@  discard block
 block discarded – undo
686 686
      * @param string $day
687 687
      * @return array the boat list
688 688
      */
689
-	public function countAllBoatTypesByRace($race,$filters = array(),$year = '',$month = '',$day = '')
689
+	public function countAllBoatTypesByRace($race, $filters = array(), $year = '', $month = '', $day = '')
690 690
 	{
691 691
 		global $globalDBdriver;
692
-		$filter_query = $this->getFilter($filters,true,true);
693
-		$race = filter_var($race,FILTER_SANITIZE_STRING);
694
-		$query  = "SELECT DISTINCT marine_output.type, COUNT(marine_output.type) AS type_count
692
+		$filter_query = $this->getFilter($filters, true, true);
693
+		$race = filter_var($race, FILTER_SANITIZE_STRING);
694
+		$query = "SELECT DISTINCT marine_output.type, COUNT(marine_output.type) AS type_count
695 695
 			FROM marine_output".$filter_query." (marine_output.race_id = :race OR marine_output.race_name = :race)";
696 696
 		$query_values = array();
697 697
 		if ($year != '') {
698 698
 			if ($globalDBdriver == 'mysql') {
699 699
 				$query .= " AND YEAR(marine_output.date) = :year";
700
-				$query_values = array_merge($query_values,array(':year' => $year));
700
+				$query_values = array_merge($query_values, array(':year' => $year));
701 701
 			} else {
702 702
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
703
-				$query_values = array_merge($query_values,array(':year' => $year));
703
+				$query_values = array_merge($query_values, array(':year' => $year));
704 704
 			}
705 705
 		}
706 706
 		if ($month != '') {
707 707
 			if ($globalDBdriver == 'mysql') {
708 708
 				$query .= " AND MONTH(marine_output.date) = :month";
709
-				$query_values = array_merge($query_values,array(':month' => $month));
709
+				$query_values = array_merge($query_values, array(':month' => $month));
710 710
 			} else {
711 711
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
712
-				$query_values = array_merge($query_values,array(':month' => $month));
712
+				$query_values = array_merge($query_values, array(':month' => $month));
713 713
 			}
714 714
 		}
715 715
 		if ($day != '') {
716 716
 			if ($globalDBdriver == 'mysql') {
717 717
 				$query .= " AND DAY(marine_output.date) = :day";
718
-				$query_values = array_merge($query_values,array(':day' => $day));
718
+				$query_values = array_merge($query_values, array(':day' => $day));
719 719
 			} else {
720 720
 				$query .= " AND EXTRACT(DAY FROM marine_output.date) = :day";
721
-				$query_values = array_merge($query_values,array(':day' => $day));
721
+				$query_values = array_merge($query_values, array(':day' => $day));
722 722
 			}
723 723
 		}
724 724
 		$query .= " GROUP BY marine_output.type
725 725
 			ORDER BY type_count DESC";
726
-		$query_values = array_merge($query_values,array(':race' => $race));
726
+		$query_values = array_merge($query_values, array(':race' => $race));
727 727
 		$sth = $this->db->prepare($query);
728 728
 		$sth->execute($query_values);
729 729
 		return $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -739,47 +739,47 @@  discard block
 block discarded – undo
739 739
      * @param string $day
740 740
      * @return String Duration of all race
741 741
      */
742
-	public function getRaceDurationByCaptain($captain,$filters = array(),$year = '',$month = '',$day = '')
742
+	public function getRaceDurationByCaptain($captain, $filters = array(), $year = '', $month = '', $day = '')
743 743
 	{
744 744
 		global $globalDBdriver;
745
-		$captain = filter_var($captain,FILTER_SANITIZE_STRING);
746
-		$filter_query = $this->getFilter($filters,true,true);
747
-		$query  = "SELECT SUM(last_seen - date) AS duration 
745
+		$captain = filter_var($captain, FILTER_SANITIZE_STRING);
746
+		$filter_query = $this->getFilter($filters, true, true);
747
+		$query = "SELECT SUM(last_seen - date) AS duration 
748 748
 		    FROM marine_output".$filter_query." (marine_output.captain_name = :captain OR marine_output.captain_id = :captain) 
749 749
 		    AND last_seen > date";
750 750
 		$query_values = array();
751 751
 		if ($year != '') {
752 752
 			if ($globalDBdriver == 'mysql') {
753 753
 				$query .= " AND YEAR(marine_output.date) = :year";
754
-				$query_values = array_merge($query_values,array(':year' => $year));
754
+				$query_values = array_merge($query_values, array(':year' => $year));
755 755
 			} else {
756 756
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
757
-				$query_values = array_merge($query_values,array(':year' => $year));
757
+				$query_values = array_merge($query_values, array(':year' => $year));
758 758
 			}
759 759
 		}
760 760
 		if ($month != '') {
761 761
 			if ($globalDBdriver == 'mysql') {
762 762
 				$query .= " AND MONTH(marine_output.date) = :month";
763
-				$query_values = array_merge($query_values,array(':month' => $month));
763
+				$query_values = array_merge($query_values, array(':month' => $month));
764 764
 			} else {
765 765
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
766
-				$query_values = array_merge($query_values,array(':month' => $month));
766
+				$query_values = array_merge($query_values, array(':month' => $month));
767 767
 			}
768 768
 		}
769 769
 		if ($day != '') {
770 770
 			if ($globalDBdriver == 'mysql') {
771 771
 				$query .= " AND DAY(marine_output.date) = :day";
772
-				$query_values = array_merge($query_values,array(':day' => $day));
772
+				$query_values = array_merge($query_values, array(':day' => $day));
773 773
 			} else {
774 774
 				$query .= " AND EXTRACT(DAY FROM marine_output.date) = :day";
775
-				$query_values = array_merge($query_values,array(':day' => $day));
775
+				$query_values = array_merge($query_values, array(':day' => $day));
776 776
 			}
777 777
 		}
778
-		$query_values = array_merge($query_values,array(':captain' => $captain));
778
+		$query_values = array_merge($query_values, array(':captain' => $captain));
779 779
 		$sth = $this->db->prepare($query);
780 780
 		$sth->execute($query_values);
781 781
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
782
-		if (is_int($result[0]['duration'])) return gmdate('H:i:s',$result[0]['duration']);
782
+		if (is_int($result[0]['duration'])) return gmdate('H:i:s', $result[0]['duration']);
783 783
 		else return $result[0]['duration'];
784 784
 	}
785 785
 
@@ -793,38 +793,38 @@  discard block
 block discarded – undo
793 793
      * @param string $day
794 794
      * @return array Duration of all race
795 795
      */
796
-	public function getRaceDurationByCaptains($limit = true,$filters = array(),$year = '',$month = '',$day = '')
796
+	public function getRaceDurationByCaptains($limit = true, $filters = array(), $year = '', $month = '', $day = '')
797 797
 	{
798 798
 		global $globalDBdriver;
799
-		$filter_query = $this->getFilter($filters,true,true);
800
-		$query  = "SELECT SUM(last_seen - date) AS duration, captain_id, captain_name 
799
+		$filter_query = $this->getFilter($filters, true, true);
800
+		$query = "SELECT SUM(last_seen - date) AS duration, captain_id, captain_name 
801 801
 		    FROM marine_output".$filter_query." last_seen > date";
802 802
 		$query_values = array();
803 803
 		if ($year != '') {
804 804
 			if ($globalDBdriver == 'mysql') {
805 805
 				$query .= " AND YEAR(marine_output.date) = :year";
806
-				$query_values = array_merge($query_values,array(':year' => $year));
806
+				$query_values = array_merge($query_values, array(':year' => $year));
807 807
 			} else {
808 808
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
809
-				$query_values = array_merge($query_values,array(':year' => $year));
809
+				$query_values = array_merge($query_values, array(':year' => $year));
810 810
 			}
811 811
 		}
812 812
 		if ($month != '') {
813 813
 			if ($globalDBdriver == 'mysql') {
814 814
 				$query .= " AND MONTH(marine_output.date) = :month";
815
-				$query_values = array_merge($query_values,array(':month' => $month));
815
+				$query_values = array_merge($query_values, array(':month' => $month));
816 816
 			} else {
817 817
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
818
-				$query_values = array_merge($query_values,array(':month' => $month));
818
+				$query_values = array_merge($query_values, array(':month' => $month));
819 819
 			}
820 820
 		}
821 821
 		if ($day != '') {
822 822
 			if ($globalDBdriver == 'mysql') {
823 823
 				$query .= " AND DAY(marine_output.date) = :day";
824
-				$query_values = array_merge($query_values,array(':day' => $day));
824
+				$query_values = array_merge($query_values, array(':day' => $day));
825 825
 			} else {
826 826
 				$query .= " AND EXTRACT(DAY FROM marine_output.date) = :day";
827
-				$query_values = array_merge($query_values,array(':day' => $day));
827
+				$query_values = array_merge($query_values, array(':day' => $day));
828 828
 			}
829 829
 		}
830 830
 		$query .= " GROUP BY marine_output.captain_id,marine_output.captain_name ORDER BY duration DESC";
@@ -836,7 +836,7 @@  discard block
 block discarded – undo
836 836
 		$duration_array = array();
837 837
 		$temp_array = array();
838 838
         
839
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
839
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
840 840
 		{
841 841
 			if ($row['duration'] != '') {
842 842
 				$temp_array['marine_duration_days'] = $row['duration'];
@@ -858,8 +858,8 @@  discard block
 block discarded – undo
858 858
      */
859 859
 	public function getAllCaptainNames($filters = array())
860 860
 	{
861
-		$filter_query = $this->getFilter($filters,true,true);
862
-		$query  = "SELECT DISTINCT marine_output.captain_name, marine_output.captain_id
861
+		$filter_query = $this->getFilter($filters, true, true);
862
+		$query = "SELECT DISTINCT marine_output.captain_name, marine_output.captain_id
863 863
 			FROM marine_output".$filter_query." marine_output.captain_name <> '' 
864 864
 			ORDER BY marine_output.captain_name ASC";
865 865
 	
@@ -876,8 +876,8 @@  discard block
 block discarded – undo
876 876
      */
877 877
 	public function getAllRaceNames($filters = array())
878 878
 	{
879
-		$filter_query = $this->getFilter($filters,true,true);
880
-		$query  = "SELECT DISTINCT marine_output.race_name, marine_output.race_id
879
+		$filter_query = $this->getFilter($filters, true, true);
880
+		$query = "SELECT DISTINCT marine_output.race_name, marine_output.race_id
881 881
 			FROM marine_output".$filter_query." marine_output.race_name <> '' 
882 882
 			ORDER BY marine_output.race_name ASC";
883 883
 	
@@ -894,11 +894,11 @@  discard block
 block discarded – undo
894 894
      * @param array $filters
895 895
      * @return array list of source name
896 896
      */
897
-	public function getAllSourceName($type = '',$filters = array())
897
+	public function getAllSourceName($type = '', $filters = array())
898 898
 	{
899
-		$filter_query = $this->getFilter($filters,true,true);
899
+		$filter_query = $this->getFilter($filters, true, true);
900 900
 		$query_values = array();
901
-		$query  = "SELECT DISTINCT marine_output.source_name 
901
+		$query = "SELECT DISTINCT marine_output.source_name 
902 902
 				FROM marine_output".$filter_query." marine_output.source_name <> ''";
903 903
 		if ($type != '') {
904 904
 			$query_values = array(':type' => $type);
@@ -913,7 +913,7 @@  discard block
 block discarded – undo
913 913
 		$source_array = array();
914 914
 		$temp_array = array();
915 915
 		
916
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
916
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
917 917
 		{
918 918
 			$temp_array['source_name'] = $row['source_name'];
919 919
 			$source_array[] = $temp_array;
@@ -930,8 +930,8 @@  discard block
 block discarded – undo
930 930
      */
931 931
 	public function getAllIdents($filters = array())
932 932
 	{
933
-		$filter_query = $this->getFilter($filters,true,true);
934
-		$query  = "SELECT DISTINCT marine_output.ident
933
+		$filter_query = $this->getFilter($filters, true, true);
934
+		$query = "SELECT DISTINCT marine_output.ident
935 935
 								FROM marine_output".$filter_query." marine_output.ident <> '' 
936 936
 								ORDER BY marine_output.date ASC LIMIT 700 OFFSET 0";
937 937
 
@@ -941,7 +941,7 @@  discard block
 block discarded – undo
941 941
 		$ident_array = array();
942 942
 		$temp_array = array();
943 943
 		
944
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
944
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
945 945
 		{
946 946
 			$temp_array['ident'] = $row['ident'];
947 947
 			$ident_array[] = $temp_array;
@@ -958,7 +958,7 @@  discard block
 block discarded – undo
958 958
      */
959 959
 	public function getIdentity($mmsi)
960 960
 	{
961
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
961
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT);
962 962
 		$query  = "SELECT * FROM marine_identity WHERE mmsi = :mmsi LIMIT 1";
963 963
 		$sth = $this->db->prepare($query);
964 964
 		$sth->execute(array(':mmsi' => $mmsi));
@@ -975,23 +975,23 @@  discard block
 block discarded – undo
975 975
      * @param $callsign
976 976
      * @param $type
977 977
      */
978
-	public function addIdentity($mmsi,$imo,$ident,$callsign,$type)
978
+	public function addIdentity($mmsi, $imo, $ident, $callsign, $type)
979 979
 	{
980
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
980
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT);
981 981
 		if ($mmsi != '') {
982
-			$imo = filter_var($imo,FILTER_SANITIZE_NUMBER_INT);
983
-			$ident = filter_var($ident,FILTER_SANITIZE_STRING);
984
-			$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
985
-			$type = filter_var($type,FILTER_SANITIZE_STRING);
982
+			$imo = filter_var($imo, FILTER_SANITIZE_NUMBER_INT);
983
+			$ident = filter_var($ident, FILTER_SANITIZE_STRING);
984
+			$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
985
+			$type = filter_var($type, FILTER_SANITIZE_STRING);
986 986
 			$identinfo = $this->getIdentity($mmsi);
987 987
 			if (empty($identinfo)) {
988
-				$query  = "INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:type)";
988
+				$query = "INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:type)";
989 989
 				$sth = $this->db->prepare($query);
990
-				$sth->execute(array(':mmsi' => $mmsi,':imo' => $imo,':call_sign' => $callsign,':ship_name' => $ident,':type' => $type));
990
+				$sth->execute(array(':mmsi' => $mmsi, ':imo' => $imo, ':call_sign' => $callsign, ':ship_name' => $ident, ':type' => $type));
991 991
 			} elseif ($ident != '' && $identinfo['ship_name'] != $ident) {
992
-				$query  = "UPDATE marine_identity SET ship_name = :ship_name,type = :type WHERE mmsi = :mmsi";
992
+				$query = "UPDATE marine_identity SET ship_name = :ship_name,type = :type WHERE mmsi = :mmsi";
993 993
 				$sth = $this->db->prepare($query);
994
-				$sth->execute(array(':mmsi' => $mmsi,':ship_name' => $ident,':type' => $type));
994
+				$sth->execute(array(':mmsi' => $mmsi, ':ship_name' => $ident, ':type' => $type));
995 995
 			}
996 996
 		}
997 997
 	}
@@ -1012,12 +1012,12 @@  discard block
 block discarded – undo
1012 1012
 		} else $offset = '+00:00';
1013 1013
 
1014 1014
 		if ($globalDBdriver == 'mysql') {
1015
-			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date
1015
+			$query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date
1016 1016
 								FROM marine_output
1017 1017
 								WHERE marine_output.date <> '' 
1018 1018
 								ORDER BY marine_output.date ASC LIMIT 0,100";
1019 1019
 		} else {
1020
-			$query  = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
1020
+			$query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
1021 1021
 								FROM marine_output
1022 1022
 								WHERE marine_output.date <> '' 
1023 1023
 								ORDER BY marine_output.date ASC LIMIT 0,100";
@@ -1029,7 +1029,7 @@  discard block
 block discarded – undo
1029 1029
 		$date_array = array();
1030 1030
 		$temp_array = array();
1031 1031
 		
1032
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1032
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1033 1033
 		{
1034 1034
 			$temp_array['date'] = $row['date'];
1035 1035
 
@@ -1047,10 +1047,10 @@  discard block
 block discarded – undo
1047 1047
 	* @return String success or false
1048 1048
 	*
1049 1049
 	*/
1050
-	public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL)
1050
+	public function updateIdentMarineData($fammarine_id = '', $ident = '', $fromsource = NULL)
1051 1051
 	{
1052 1052
 		$query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id';
1053
-		$query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident);
1053
+		$query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident);
1054 1054
 		try {
1055 1055
 			$sth = $this->db->prepare($query);
1056 1056
 			$sth->execute($query_values);
@@ -1068,10 +1068,10 @@  discard block
 block discarded – undo
1068 1068
 	* @return String success or false
1069 1069
 	*
1070 1070
 	*/
1071
-	public function updateArrivalPortNameMarineData($fammarine_id = '', $arrival_code = '',$fromsource = NULL)
1071
+	public function updateArrivalPortNameMarineData($fammarine_id = '', $arrival_code = '', $fromsource = NULL)
1072 1072
 	{
1073 1073
 		$query = 'UPDATE marine_output SET arrival_port_name = :arrival_code WHERE fammarine_id = :fammarine_id';
1074
-		$query_values = array(':fammarine_id' => $fammarine_id,':arrival_code' => $arrival_code);
1074
+		$query_values = array(':fammarine_id' => $fammarine_id, ':arrival_code' => $arrival_code);
1075 1075
 		try {
1076 1076
 			$sth = $this->db->prepare($query);
1077 1077
 			$sth->execute($query_values);
@@ -1090,11 +1090,11 @@  discard block
 block discarded – undo
1090 1090
 	* @return String success or false
1091 1091
 	*
1092 1092
 	*/
1093
-	public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '')
1093
+	public function updateStatusMarineData($fammarine_id = '', $status_id = '', $status = '')
1094 1094
 	{
1095 1095
 
1096 1096
 		$query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id';
1097
-                $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id);
1097
+                $query_values = array(':fammarine_id' => $fammarine_id, ':status' => $status, ':status_id' => $status_id);
1098 1098
 
1099 1099
 		try {
1100 1100
 			$sth = $this->db->prepare($query);
@@ -1123,17 +1123,17 @@  discard block
 block discarded – undo
1123 1123
      * @param string $race_begin
1124 1124
      * @return String success or false
1125 1125
      */
1126
-	public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '',$distance = NULL,$race_rank = NULL, $race_time = NULL, $status = '', $race_begin = '')
1126
+	public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '', $distance = NULL, $race_rank = NULL, $race_time = NULL, $status = '', $race_begin = '')
1127 1127
 	{
1128 1128
 		if ($latitude == '') $latitude = NULL;
1129 1129
 		if ($longitude == '') $longitude = NULL;
1130 1130
 		$groundspeed = round($groundspeed);
1131 1131
 		if ($race_begin != '') {
1132 1132
 			$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, distance = :distance, race_rank = :race_rank, race_time = :race_time, status = :status, date = :race_begin WHERE fammarine_id = :fammarine_id';
1133
-			$query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident,':distance' => $distance,':race_rank' => $race_rank,':race_time' => $race_time,':status' => $status,':race_begin' => $race_begin);
1133
+			$query_values = array(':fammarine_id' => $fammarine_id, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident, ':distance' => $distance, ':race_rank' => $race_rank, ':race_time' => $race_time, ':status' => $status, ':race_begin' => $race_begin);
1134 1134
 		} else {
1135 1135
 			$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, distance = :distance, race_rank = :race_rank, race_time = :race_time, status = :status WHERE fammarine_id = :fammarine_id';
1136
-			$query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident,':distance' => $distance,':race_rank' => $race_rank,':race_time' => $race_time,':status' => $status);
1136
+			$query_values = array(':fammarine_id' => $fammarine_id, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident, ':distance' => $distance, ':race_rank' => $race_rank, ':race_time' => $race_time, ':status' => $status);
1137 1137
 		}
1138 1138
 		try {
1139 1139
 			$sth = $this->db->prepare($query);
@@ -1177,7 +1177,7 @@  discard block
 block discarded – undo
1177 1177
      * @param string $race_time
1178 1178
      * @return String success or false
1179 1179
      */
1180
-	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 = '', $captain_id = '',$captain_name = '',$race_id = '', $race_name = '', $distance = '',$race_rank = '', $race_time = '')
1180
+	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 = '', $captain_id = '', $captain_name = '', $race_id = '', $race_name = '', $distance = '', $race_rank = '', $race_time = '')
1181 1181
 	{
1182 1182
 		global $globalMarineImageFetch;
1183 1183
 		
@@ -1249,34 +1249,34 @@  discard block
 block discarded – undo
1249 1249
 			$date = date("Y-m-d H:i:s", time());
1250 1250
 		}
1251 1251
 
1252
-		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
1253
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
1254
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1255
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1256
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
1257
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1258
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
1259
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING);
1260
-		$type = filter_var($type,FILTER_SANITIZE_STRING);
1261
-		$status = filter_var($status,FILTER_SANITIZE_STRING);
1262
-		$type_id = filter_var($typeid,FILTER_SANITIZE_NUMBER_INT);
1263
-		$status_id = filter_var($statusid,FILTER_SANITIZE_NUMBER_INT);
1264
-		$imo = filter_var($imo,FILTER_SANITIZE_STRING);
1265
-		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
1266
-		$arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING);
1267
-		$arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING);
1268
-		$captain_id = filter_var($captain_id,FILTER_SANITIZE_STRING);
1269
-		$captain_name = filter_var($captain_name,FILTER_SANITIZE_STRING);
1270
-		$race_id = filter_var($race_id,FILTER_SANITIZE_STRING);
1271
-		$race_name = filter_var($race_name,FILTER_SANITIZE_STRING);
1272
-		$race_rank = filter_var($race_rank,FILTER_SANITIZE_NUMBER_INT);
1273
-		$race_time = filter_var($race_time,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1274
-		$distance = filter_var($distance,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1252
+		$fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING);
1253
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1254
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1255
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1256
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
1257
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1258
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
1259
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING);
1260
+		$type = filter_var($type, FILTER_SANITIZE_STRING);
1261
+		$status = filter_var($status, FILTER_SANITIZE_STRING);
1262
+		$type_id = filter_var($typeid, FILTER_SANITIZE_NUMBER_INT);
1263
+		$status_id = filter_var($statusid, FILTER_SANITIZE_NUMBER_INT);
1264
+		$imo = filter_var($imo, FILTER_SANITIZE_STRING);
1265
+		$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
1266
+		$arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING);
1267
+		$arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING);
1268
+		$captain_id = filter_var($captain_id, FILTER_SANITIZE_STRING);
1269
+		$captain_name = filter_var($captain_name, FILTER_SANITIZE_STRING);
1270
+		$race_id = filter_var($race_id, FILTER_SANITIZE_STRING);
1271
+		$race_name = filter_var($race_name, FILTER_SANITIZE_STRING);
1272
+		$race_rank = filter_var($race_rank, FILTER_SANITIZE_NUMBER_INT);
1273
+		$race_time = filter_var($race_time, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1274
+		$distance = filter_var($distance, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1275 1275
 		if (isset($globalMarineImageFetch) && $globalMarineImageFetch === TRUE) {
1276 1276
 			$Image = new Image($this->db);
1277
-			$image_array = $Image->getMarineImage($mmsi,$imo,$ident);
1277
+			$image_array = $Image->getMarineImage($mmsi, $imo, $ident);
1278 1278
 			if (!isset($image_array[0]['mmsi'])) {
1279
-				$Image->addMarineImage($mmsi,$imo,$ident);
1279
+				$Image->addMarineImage($mmsi, $imo, $ident);
1280 1280
 			}
1281 1281
 			unset($Image);
1282 1282
 		}
@@ -1292,10 +1292,10 @@  discard block
 block discarded – undo
1292 1292
 		if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
1293 1293
 		//if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
1294 1294
 		if ($arrival_date == '') $arrival_date = NULL;
1295
-		$query  = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, type_id, status,status_id,imo,arrival_port_name,arrival_port_date,captain_id,captain_name,race_id,race_name, distance, race_rank,race_time) 
1295
+		$query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, type_id, status,status_id,imo,arrival_port_name,arrival_port_date,captain_id,captain_name,race_id,race_name, distance, race_rank,race_time) 
1296 1296
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:type_id,:status,:status_id,:imo,:arrival_port_name,:arrival_port_date,:captain_id,:captain_name,:race_id,:race_name, :distance, :race_rank,:race_time)";
1297 1297
 
1298
-		$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,':type_id' => $type_id,':status' => $status,':status_id' => $status_id,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date,':captain_id' => $captain_id,':captain_name' => $captain_name,':race_id' => $race_id,':race_name' => $race_name,':distance' => $distance,':race_rank' => $race_rank,':race_time' => $race_time);
1298
+		$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, ':type_id' => $type_id, ':status' => $status, ':status_id' => $status_id, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date, ':captain_id' => $captain_id, ':captain_name' => $captain_name, ':race_id' => $race_id, ':race_name' => $race_name, ':distance' => $distance, ':race_rank' => $race_rank, ':race_time' => $race_time);
1299 1299
 		try {
1300 1300
 			$sth = $this->db->prepare($query);
1301 1301
 			$sth->execute($query_values);
@@ -1319,13 +1319,13 @@  discard block
 block discarded – undo
1319 1319
 	{
1320 1320
 		global $globalDBdriver, $globalTimezone;
1321 1321
 		if ($globalDBdriver == 'mysql') {
1322
-			$query  = "SELECT marine_output.ident FROM marine_output 
1322
+			$query = "SELECT marine_output.ident FROM marine_output 
1323 1323
 								WHERE marine_output.ident = :ident 
1324 1324
 								AND marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
1325 1325
 								AND marine_output.date < UTC_TIMESTAMP()";
1326 1326
 			$query_data = array(':ident' => $ident);
1327 1327
 		} else {
1328
-			$query  = "SELECT marine_output.ident FROM marine_output 
1328
+			$query = "SELECT marine_output.ident FROM marine_output 
1329 1329
 								WHERE marine_output.ident = :ident 
1330 1330
 								AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
1331 1331
 								AND marine_output.date < now() AT TIME ZONE 'UTC'";
@@ -1334,8 +1334,8 @@  discard block
 block discarded – undo
1334 1334
 		
1335 1335
 		$sth = $this->db->prepare($query);
1336 1336
 		$sth->execute($query_data);
1337
-    		$ident_result='';
1338
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1337
+    		$ident_result = '';
1338
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1339 1339
 		{
1340 1340
 			$ident_result = $row['ident'];
1341 1341
 		}
@@ -1361,8 +1361,8 @@  discard block
 block discarded – undo
1361 1361
 				return false;
1362 1362
 			} else {
1363 1363
 				$q_array = explode(" ", $q);
1364
-				foreach ($q_array as $q_item){
1365
-					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
1364
+				foreach ($q_array as $q_item) {
1365
+					$q_item = filter_var($q_item, FILTER_SANITIZE_STRING);
1366 1366
 					$additional_query .= " AND (";
1367 1367
 					$additional_query .= "(marine_output.ident like '%".$q_item."%')";
1368 1368
 					$additional_query .= ")";
@@ -1370,11 +1370,11 @@  discard block
 block discarded – undo
1370 1370
 			}
1371 1371
 		}
1372 1372
 		if ($globalDBdriver == 'mysql') {
1373
-			$query  = "SELECT marine_output.* FROM marine_output 
1373
+			$query = "SELECT marine_output.* FROM marine_output 
1374 1374
 				WHERE marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." 
1375 1375
 				AND marine_output.date < UTC_TIMESTAMP()";
1376 1376
 		} else {
1377
-			$query  = "SELECT marine_output.* FROM marine_output 
1377
+			$query = "SELECT marine_output.* FROM marine_output 
1378 1378
 				WHERE marine_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." 
1379 1379
 				AND marine_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
1380 1380
 		}
@@ -1394,16 +1394,16 @@  discard block
 block discarded – undo
1394 1394
      * @return array the airline country list
1395 1395
      */
1396 1396
 
1397
-	public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
1397
+	public function countAllMarineOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
1398 1398
 	{
1399 1399
 		global $globalDBdriver, $globalArchive;
1400 1400
 		//$filter_query = $this->getFilter($filters,true,true);
1401
-		$Connection= new Connection($this->db);
1401
+		$Connection = new Connection($this->db);
1402 1402
 		if (!$Connection->tableExists('countries')) return array();
1403 1403
 		require_once('class.SpotterLive.php');
1404 1404
 		if (!isset($globalArchive) || $globalArchive !== TRUE) {
1405 1405
 			$MarineLive = new MarineLive($this->db);
1406
-			$filter_query = $MarineLive->getFilter($filters,true,true);
1406
+			$filter_query = $MarineLive->getFilter($filters, true, true);
1407 1407
 			$filter_query .= " over_country IS NOT NULL AND over_country <> ''";
1408 1408
 			if ($olderthanmonths > 0) {
1409 1409
 				if ($globalDBdriver == 'mysql') {
@@ -1423,7 +1423,7 @@  discard block
 block discarded – undo
1423 1423
 		} else {
1424 1424
 			require_once(dirname(__FILE__)."/class.MarineArchive.php");
1425 1425
 			$MarineArchive = new MarineArchive($this->db);
1426
-			$filter_query = $MarineArchive->getFilter($filters,true,true);
1426
+			$filter_query = $MarineArchive->getFilter($filters, true, true);
1427 1427
 			$filter_query .= " over_country <> ''";
1428 1428
 			if ($olderthanmonths > 0) {
1429 1429
 				if ($globalDBdriver == 'mysql') {
@@ -1451,7 +1451,7 @@  discard block
 block discarded – undo
1451 1451
 		$flight_array = array();
1452 1452
 		$temp_array = array();
1453 1453
         
1454
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1454
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1455 1455
 		{
1456 1456
 			$temp_array['marine_count'] = $row['nb'];
1457 1457
 			$temp_array['marine_country'] = $row['name'];
@@ -1475,11 +1475,11 @@  discard block
 block discarded – undo
1475 1475
      * @param string $day
1476 1476
      * @return array the callsign list
1477 1477
      */
1478
-	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
1478
+	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
1479 1479
 	{
1480 1480
 		global $globalDBdriver;
1481
-		$filter_query = $this->getFilter($filters,true,true);
1482
-		$query  = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count 
1481
+		$filter_query = $this->getFilter($filters, true, true);
1482
+		$query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count 
1483 1483
                     FROM marine_output".$filter_query." marine_output.ident <> ''";
1484 1484
 		 if ($olderthanmonths > 0) {
1485 1485
 			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
@@ -1493,28 +1493,28 @@  discard block
 block discarded – undo
1493 1493
 		if ($year != '') {
1494 1494
 			if ($globalDBdriver == 'mysql') {
1495 1495
 				$query .= " AND YEAR(marine_output.date) = :year";
1496
-				$query_values = array_merge($query_values,array(':year' => $year));
1496
+				$query_values = array_merge($query_values, array(':year' => $year));
1497 1497
 			} else {
1498 1498
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
1499
-				$query_values = array_merge($query_values,array(':year' => $year));
1499
+				$query_values = array_merge($query_values, array(':year' => $year));
1500 1500
 			}
1501 1501
 		}
1502 1502
 		if ($month != '') {
1503 1503
 			if ($globalDBdriver == 'mysql') {
1504 1504
 				$query .= " AND MONTH(marine_output.date) = :month";
1505
-				$query_values = array_merge($query_values,array(':month' => $month));
1505
+				$query_values = array_merge($query_values, array(':month' => $month));
1506 1506
 			} else {
1507 1507
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
1508
-				$query_values = array_merge($query_values,array(':month' => $month));
1508
+				$query_values = array_merge($query_values, array(':month' => $month));
1509 1509
 			}
1510 1510
 		}
1511 1511
 		if ($day != '') {
1512 1512
 			if ($globalDBdriver == 'mysql') {
1513 1513
 				$query .= " AND DAY(marine_output.date) = :day";
1514
-				$query_values = array_merge($query_values,array(':day' => $day));
1514
+				$query_values = array_merge($query_values, array(':day' => $day));
1515 1515
 			} else {
1516 1516
 				$query .= " AND EXTRACT(DAY FROM marine_output.date) = :day";
1517
-				$query_values = array_merge($query_values,array(':day' => $day));
1517
+				$query_values = array_merge($query_values, array(':day' => $day));
1518 1518
 			}
1519 1519
 		}
1520 1520
 		$query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC";
@@ -1526,7 +1526,7 @@  discard block
 block discarded – undo
1526 1526
 		$callsign_array = array();
1527 1527
 		$temp_array = array();
1528 1528
         
1529
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1529
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1530 1530
 		{
1531 1531
 			$temp_array['callsign_icao'] = $row['ident'];
1532 1532
 			$temp_array['airline_name'] = $row['airline_name'];
@@ -1578,7 +1578,7 @@  discard block
 block discarded – undo
1578 1578
 		$date_array = array();
1579 1579
 		$temp_array = array();
1580 1580
         
1581
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1581
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1582 1582
 		{
1583 1583
 			$temp_array['date_name'] = $row['date_name'];
1584 1584
 			$temp_array['date_count'] = $row['date_count'];
@@ -1604,7 +1604,7 @@  discard block
 block discarded – undo
1604 1604
 			$datetime = new DateTime();
1605 1605
 			$offset = $datetime->format('P');
1606 1606
 		} else $offset = '+00:00';
1607
-		$filter_query = $this->getFilter($filters,true,true);
1607
+		$filter_query = $this->getFilter($filters, true, true);
1608 1608
 		if ($globalDBdriver == 'mysql') {
1609 1609
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
1610 1610
 								FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)";
@@ -1625,7 +1625,7 @@  discard block
 block discarded – undo
1625 1625
 		$date_array = array();
1626 1626
 		$temp_array = array();
1627 1627
         
1628
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1628
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1629 1629
 		{
1630 1630
 			$temp_array['date_name'] = $row['date_name'];
1631 1631
 			$temp_array['date_count'] = $row['date_count'];
@@ -1650,7 +1650,7 @@  discard block
 block discarded – undo
1650 1650
 			$datetime = new DateTime();
1651 1651
 			$offset = $datetime->format('P');
1652 1652
 		} else $offset = '+00:00';
1653
-		$filter_query = $this->getFilter($filters,true,true);
1653
+		$filter_query = $this->getFilter($filters, true, true);
1654 1654
 		if ($globalDBdriver == 'mysql') {
1655 1655
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
1656 1656
 								FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)";
@@ -1671,7 +1671,7 @@  discard block
 block discarded – undo
1671 1671
 		$date_array = array();
1672 1672
 		$temp_array = array();
1673 1673
         
1674
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1674
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1675 1675
 		{
1676 1676
 			$temp_array['date_name'] = $row['date_name'];
1677 1677
 			$temp_array['date_count'] = $row['date_count'];
@@ -1717,7 +1717,7 @@  discard block
 block discarded – undo
1717 1717
 		$date_array = array();
1718 1718
 		$temp_array = array();
1719 1719
         
1720
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1720
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1721 1721
 		{
1722 1722
 			$temp_array['month_name'] = $row['month_name'];
1723 1723
 			$temp_array['year_name'] = $row['year_name'];
@@ -1744,7 +1744,7 @@  discard block
 block discarded – undo
1744 1744
 			$datetime = new DateTime();
1745 1745
 			$offset = $datetime->format('P');
1746 1746
 		} else $offset = '+00:00';
1747
-		$filter_query = $this->getFilter($filters,true,true);
1747
+		$filter_query = $this->getFilter($filters, true, true);
1748 1748
 		if ($globalDBdriver == 'mysql') {
1749 1749
 			$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
1750 1750
 								FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)";
@@ -1765,7 +1765,7 @@  discard block
 block discarded – undo
1765 1765
 		$date_array = array();
1766 1766
 		$temp_array = array();
1767 1767
         
1768
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1768
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1769 1769
 		{
1770 1770
 			$temp_array['year_name'] = $row['year_name'];
1771 1771
 			$temp_array['month_name'] = $row['month_name'];
@@ -1785,7 +1785,7 @@  discard block
 block discarded – undo
1785 1785
      * @param array $filters
1786 1786
      * @return array the hour list
1787 1787
      */
1788
-	public function countAllHours($orderby,$filters = array())
1788
+	public function countAllHours($orderby, $filters = array())
1789 1789
 	{
1790 1790
 		global $globalTimezone, $globalDBdriver;
1791 1791
 		if ($globalTimezone != '') {
@@ -1833,7 +1833,7 @@  discard block
 block discarded – undo
1833 1833
 		$hour_array = array();
1834 1834
 		$temp_array = array();
1835 1835
         
1836
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1836
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1837 1837
 		{
1838 1838
 			$temp_array['hour_name'] = $row['hour_name'];
1839 1839
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1855,8 +1855,8 @@  discard block
 block discarded – undo
1855 1855
 	public function countAllHoursByDate($date, $filters = array())
1856 1856
 	{
1857 1857
 		global $globalTimezone, $globalDBdriver;
1858
-		$filter_query = $this->getFilter($filters,true,true);
1859
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
1858
+		$filter_query = $this->getFilter($filters, true, true);
1859
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
1860 1860
 		if ($globalTimezone != '') {
1861 1861
 			date_default_timezone_set($globalTimezone);
1862 1862
 			$datetime = new DateTime($date);
@@ -1864,12 +1864,12 @@  discard block
 block discarded – undo
1864 1864
 		} else $offset = '+00:00';
1865 1865
 
1866 1866
 		if ($globalDBdriver == 'mysql') {
1867
-			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1867
+			$query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1868 1868
 								FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = :date
1869 1869
 								GROUP BY hour_name 
1870 1870
 								ORDER BY hour_name ASC";
1871 1871
 		} else {
1872
-			$query  = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1872
+			$query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1873 1873
 								FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date
1874 1874
 								GROUP BY hour_name 
1875 1875
 								ORDER BY hour_name ASC";
@@ -1881,7 +1881,7 @@  discard block
 block discarded – undo
1881 1881
 		$hour_array = array();
1882 1882
 		$temp_array = array();
1883 1883
         
1884
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1884
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1885 1885
 		{
1886 1886
 			$temp_array['hour_name'] = $row['hour_name'];
1887 1887
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1903,8 +1903,8 @@  discard block
 block discarded – undo
1903 1903
 	public function countAllHoursByIdent($ident, $filters = array())
1904 1904
 	{
1905 1905
 		global $globalTimezone, $globalDBdriver;
1906
-		$filter_query = $this->getFilter($filters,true,true);
1907
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
1906
+		$filter_query = $this->getFilter($filters, true, true);
1907
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1908 1908
 		if ($globalTimezone != '') {
1909 1909
 			date_default_timezone_set($globalTimezone);
1910 1910
 			$datetime = new DateTime();
@@ -1912,12 +1912,12 @@  discard block
 block discarded – undo
1912 1912
 		} else $offset = '+00:00';
1913 1913
 
1914 1914
 		if ($globalDBdriver == 'mysql') {
1915
-			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1915
+			$query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1916 1916
 								FROM marine_output".$filter_query." marine_output.ident = :ident 
1917 1917
 								GROUP BY hour_name 
1918 1918
 								ORDER BY hour_name ASC";
1919 1919
 		} else {
1920
-			$query  = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1920
+			$query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1921 1921
 								FROM marine_output".$filter_query." marine_output.ident = :ident 
1922 1922
 								GROUP BY hour_name 
1923 1923
 								ORDER BY hour_name ASC";
@@ -1925,12 +1925,12 @@  discard block
 block discarded – undo
1925 1925
       
1926 1926
 		
1927 1927
 		$sth = $this->db->prepare($query);
1928
-		$sth->execute(array(':ident' => $ident,':offset' => $offset));
1928
+		$sth->execute(array(':ident' => $ident, ':offset' => $offset));
1929 1929
       
1930 1930
 		$hour_array = array();
1931 1931
 		$temp_array = array();
1932 1932
         
1933
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1933
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1934 1934
 		{
1935 1935
 			$temp_array['hour_name'] = $row['hour_name'];
1936 1936
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1950,11 +1950,11 @@  discard block
 block discarded – undo
1950 1950
      * @param array $filters
1951 1951
      * @return array the aircraft list
1952 1952
      */
1953
-	public function countAllCaptainsByRaces($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
1953
+	public function countAllCaptainsByRaces($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
1954 1954
 	{
1955 1955
 		global $globalDBdriver;
1956
-		$filter_query = $this->getFilter($filters,true,true);
1957
-		$query  = "SELECT DISTINCT marine_output.race_id, marine_output.race_name, COUNT(marine_output.captain_id) AS captain_count 
1956
+		$filter_query = $this->getFilter($filters, true, true);
1957
+		$query = "SELECT DISTINCT marine_output.race_id, marine_output.race_name, COUNT(marine_output.captain_id) AS captain_count 
1958 1958
 			FROM marine_output".$filter_query." race_id IS NOT NULL";
1959 1959
 		if ($olderthanmonths > 0) {
1960 1960
 			if ($globalDBdriver == 'mysql') {
@@ -1977,7 +1977,7 @@  discard block
 block discarded – undo
1977 1977
 		$marine_array = array();
1978 1978
 		$temp_array = array();
1979 1979
         
1980
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1980
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1981 1981
 		{
1982 1982
 			$temp_array['marine_race_id'] = $row['race_id'];
1983 1983
 			$temp_array['marine_race_name'] = $row['race_name'];
@@ -1995,33 +1995,33 @@  discard block
 block discarded – undo
1995 1995
      * @param string $month
1996 1996
      * @return Integer the number of vessels
1997 1997
      */
1998
-	public function countOverallMarine($filters = array(),$year = '',$month = '')
1998
+	public function countOverallMarine($filters = array(), $year = '', $month = '')
1999 1999
 	{
2000 2000
 		global $globalDBdriver;
2001 2001
 		//$queryi  = "SELECT COUNT(marine_output.marine_id) AS flight_count FROM marine_output";
2002
-		$queryi  = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output";
2002
+		$queryi = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output";
2003 2003
 		$query_values = array();
2004 2004
 		$query = '';
2005 2005
 		if ($year != '') {
2006 2006
 			if ($globalDBdriver == 'mysql') {
2007 2007
 				$query .= " AND YEAR(marine_output.date) = :year";
2008
-				$query_values = array_merge($query_values,array(':year' => $year));
2008
+				$query_values = array_merge($query_values, array(':year' => $year));
2009 2009
 			} else {
2010 2010
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
2011
-				$query_values = array_merge($query_values,array(':year' => $year));
2011
+				$query_values = array_merge($query_values, array(':year' => $year));
2012 2012
 			}
2013 2013
 		}
2014 2014
 		if ($month != '') {
2015 2015
 			if ($globalDBdriver == 'mysql') {
2016 2016
 				$query .= " AND MONTH(marine_output.date) = :month";
2017
-				$query_values = array_merge($query_values,array(':month' => $month));
2017
+				$query_values = array_merge($query_values, array(':month' => $month));
2018 2018
 			} else {
2019 2019
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
2020
-				$query_values = array_merge($query_values,array(':month' => $month));
2020
+				$query_values = array_merge($query_values, array(':month' => $month));
2021 2021
 			}
2022 2022
 		}
2023 2023
 		if (empty($query_values)) $queryi .= $this->getFilter($filters);
2024
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
2024
+		else $queryi .= $this->getFilter($filters, true, true).substr($query, 4);
2025 2025
 		
2026 2026
 		$sth = $this->db->prepare($queryi);
2027 2027
 		$sth->execute($query_values);
@@ -2036,32 +2036,32 @@  discard block
 block discarded – undo
2036 2036
      * @param string $month
2037 2037
      * @return Integer the number of vessels
2038 2038
      */
2039
-	public function countOverallMarineTypes($filters = array(),$year = '',$month = '')
2039
+	public function countOverallMarineTypes($filters = array(), $year = '', $month = '')
2040 2040
 	{
2041 2041
 		global $globalDBdriver;
2042
-		$queryi  = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output";
2042
+		$queryi = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output";
2043 2043
 		$query_values = array();
2044 2044
 		$query = '';
2045 2045
 		if ($year != '') {
2046 2046
 			if ($globalDBdriver == 'mysql') {
2047 2047
 				$query .= " AND YEAR(marine_output.date) = :year";
2048
-				$query_values = array_merge($query_values,array(':year' => $year));
2048
+				$query_values = array_merge($query_values, array(':year' => $year));
2049 2049
 			} else {
2050 2050
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
2051
-				$query_values = array_merge($query_values,array(':year' => $year));
2051
+				$query_values = array_merge($query_values, array(':year' => $year));
2052 2052
 			}
2053 2053
 		}
2054 2054
 		if ($month != '') {
2055 2055
 			if ($globalDBdriver == 'mysql') {
2056 2056
 				$query .= " AND MONTH(marine_output.date) = :month";
2057
-				$query_values = array_merge($query_values,array(':month' => $month));
2057
+				$query_values = array_merge($query_values, array(':month' => $month));
2058 2058
 			} else {
2059 2059
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
2060
-				$query_values = array_merge($query_values,array(':month' => $month));
2060
+				$query_values = array_merge($query_values, array(':month' => $month));
2061 2061
 			}
2062 2062
 		}
2063 2063
 		if (empty($query_values)) $queryi .= $this->getFilter($filters);
2064
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
2064
+		else $queryi .= $this->getFilter($filters, true, true).substr($query, 4);
2065 2065
 		
2066 2066
 		$sth = $this->db->prepare($queryi);
2067 2067
 		$sth->execute($query_values);
@@ -2076,32 +2076,32 @@  discard block
 block discarded – undo
2076 2076
      * @param string $month
2077 2077
      * @return Integer number of races
2078 2078
      */
2079
-	public function countOverallMarineRaces($filters = array(),$year = '',$month = '')
2079
+	public function countOverallMarineRaces($filters = array(), $year = '', $month = '')
2080 2080
 	{
2081 2081
 		global $globalDBdriver;
2082
-		$queryi  = "SELECT COUNT(DISTINCT marine_output.race_id) AS marine_count FROM marine_output";
2082
+		$queryi = "SELECT COUNT(DISTINCT marine_output.race_id) AS marine_count FROM marine_output";
2083 2083
 		$query_values = array();
2084 2084
 		$query = '';
2085 2085
 		if ($year != '') {
2086 2086
 			if ($globalDBdriver == 'mysql') {
2087 2087
 				$query .= " AND YEAR(marine_output.date) = :year";
2088
-				$query_values = array_merge($query_values,array(':year' => $year));
2088
+				$query_values = array_merge($query_values, array(':year' => $year));
2089 2089
 			} else {
2090 2090
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
2091
-				$query_values = array_merge($query_values,array(':year' => $year));
2091
+				$query_values = array_merge($query_values, array(':year' => $year));
2092 2092
 			}
2093 2093
 		}
2094 2094
 		if ($month != '') {
2095 2095
 			if ($globalDBdriver == 'mysql') {
2096 2096
 				$query .= " AND MONTH(marine_output.date) = :month";
2097
-				$query_values = array_merge($query_values,array(':month' => $month));
2097
+				$query_values = array_merge($query_values, array(':month' => $month));
2098 2098
 			} else {
2099 2099
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
2100
-				$query_values = array_merge($query_values,array(':month' => $month));
2100
+				$query_values = array_merge($query_values, array(':month' => $month));
2101 2101
 			}
2102 2102
 		}
2103 2103
 		if (empty($query_values)) $queryi .= $this->getFilter($filters);
2104
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
2104
+		else $queryi .= $this->getFilter($filters, true, true).substr($query, 4);
2105 2105
 		
2106 2106
 		$sth = $this->db->prepare($queryi);
2107 2107
 		$sth->execute($query_values);
@@ -2116,32 +2116,32 @@  discard block
 block discarded – undo
2116 2116
      * @param string $month
2117 2117
      * @return Integer number of captain
2118 2118
      */
2119
-	public function countOverallMarineCaptains($filters = array(),$year = '',$month = '')
2119
+	public function countOverallMarineCaptains($filters = array(), $year = '', $month = '')
2120 2120
 	{
2121 2121
 		global $globalDBdriver;
2122
-		$queryi  = "SELECT COUNT(DISTINCT marine_output.captain_id) AS marine_count FROM marine_output";
2122
+		$queryi = "SELECT COUNT(DISTINCT marine_output.captain_id) AS marine_count FROM marine_output";
2123 2123
 		$query_values = array();
2124 2124
 		$query = '';
2125 2125
 		if ($year != '') {
2126 2126
 			if ($globalDBdriver == 'mysql') {
2127 2127
 				$query .= " AND YEAR(marine_output.date) = :year";
2128
-				$query_values = array_merge($query_values,array(':year' => $year));
2128
+				$query_values = array_merge($query_values, array(':year' => $year));
2129 2129
 			} else {
2130 2130
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
2131
-				$query_values = array_merge($query_values,array(':year' => $year));
2131
+				$query_values = array_merge($query_values, array(':year' => $year));
2132 2132
 			}
2133 2133
 		}
2134 2134
 		if ($month != '') {
2135 2135
 			if ($globalDBdriver == 'mysql') {
2136 2136
 				$query .= " AND MONTH(marine_output.date) = :month";
2137
-				$query_values = array_merge($query_values,array(':month' => $month));
2137
+				$query_values = array_merge($query_values, array(':month' => $month));
2138 2138
 			} else {
2139 2139
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
2140
-				$query_values = array_merge($query_values,array(':month' => $month));
2140
+				$query_values = array_merge($query_values, array(':month' => $month));
2141 2141
 			}
2142 2142
 		}
2143 2143
 		if (empty($query_values)) $queryi .= $this->getFilter($filters);
2144
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
2144
+		else $queryi .= $this->getFilter($filters, true, true).substr($query, 4);
2145 2145
 		
2146 2146
 		$sth = $this->db->prepare($queryi);
2147 2147
 		$sth->execute($query_values);
@@ -2157,7 +2157,7 @@  discard block
 block discarded – undo
2157 2157
 	public function countAllHoursFromToday($filters = array())
2158 2158
 	{
2159 2159
 		global $globalTimezone, $globalDBdriver;
2160
-		$filter_query = $this->getFilter($filters,true,true);
2160
+		$filter_query = $this->getFilter($filters, true, true);
2161 2161
 		if ($globalTimezone != '') {
2162 2162
 			date_default_timezone_set($globalTimezone);
2163 2163
 			$datetime = new DateTime();
@@ -2165,12 +2165,12 @@  discard block
 block discarded – undo
2165 2165
 		} else $offset = '+00:00';
2166 2166
 
2167 2167
 		if ($globalDBdriver == 'mysql') {
2168
-			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
2168
+			$query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
2169 2169
 								FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = CURDATE()
2170 2170
 								GROUP BY hour_name 
2171 2171
 								ORDER BY hour_name ASC";
2172 2172
 		} else {
2173
-			$query  = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
2173
+			$query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
2174 2174
 								FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date)
2175 2175
 								GROUP BY hour_name 
2176 2176
 								ORDER BY hour_name ASC";
@@ -2182,7 +2182,7 @@  discard block
 block discarded – undo
2182 2182
 		$hour_array = array();
2183 2183
 		$temp_array = array();
2184 2184
         
2185
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2185
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2186 2186
 		{
2187 2187
 			$temp_array['hour_name'] = $row['hour_name'];
2188 2188
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -2201,9 +2201,9 @@  discard block
 block discarded – undo
2201 2201
      */
2202 2202
 	public function getMarineIDBasedOnFamMarineID($fammarine_id)
2203 2203
 	{
2204
-		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
2204
+		$fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING);
2205 2205
 
2206
-		$query  = "SELECT marine_output.marine_id
2206
+		$query = "SELECT marine_output.marine_id
2207 2207
 				FROM marine_output 
2208 2208
 				WHERE marine_output.fammarine_id = '".$fammarine_id."'";
2209 2209
         
@@ -2211,7 +2211,7 @@  discard block
 block discarded – undo
2211 2211
 		$sth = $this->db->prepare($query);
2212 2212
 		$sth->execute();
2213 2213
 
2214
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2214
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2215 2215
 		{
2216 2216
 			return $row['marine_id'];
2217 2217
 		}
@@ -2236,23 +2236,23 @@  discard block
 block discarded – undo
2236 2236
 		}
2237 2237
 		
2238 2238
 		$current_date = date("Y-m-d H:i:s");
2239
-		$date = date("Y-m-d H:i:s",strtotime($dateString." UTC"));
2239
+		$date = date("Y-m-d H:i:s", strtotime($dateString." UTC"));
2240 2240
 		
2241 2241
 		$diff = abs(strtotime($current_date) - strtotime($date));
2242 2242
 
2243
-		$time_array['years'] = floor($diff / (365*60*60*24)); 
2243
+		$time_array['years'] = floor($diff/(365*60*60*24)); 
2244 2244
 		$years = $time_array['years'];
2245 2245
 		
2246
-		$time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
2246
+		$time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24));
2247 2247
 		$months = $time_array['months'];
2248 2248
 		
2249
-		$time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
2249
+		$time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24));
2250 2250
 		$days = $time_array['days'];
2251
-		$time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60));
2251
+		$time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60));
2252 2252
 		$hours = $time_array['hours'];
2253
-		$time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60);
2253
+		$time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60);
2254 2254
 		$minutes = $time_array['minutes'];
2255
-		$time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
2255
+		$time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
2256 2256
 		
2257 2257
 		return $time_array;
2258 2258
 	}
@@ -2275,63 +2275,63 @@  discard block
 block discarded – undo
2275 2275
 			$temp_array['direction_degree'] = $direction;
2276 2276
 			$temp_array['direction_shortname'] = "N";
2277 2277
 			$temp_array['direction_fullname'] = "North";
2278
-		} elseif ($direction >= 22.5 && $direction < 45){
2278
+		} elseif ($direction >= 22.5 && $direction < 45) {
2279 2279
 			$temp_array['direction_degree'] = $direction;
2280 2280
 			$temp_array['direction_shortname'] = "NNE";
2281 2281
 			$temp_array['direction_fullname'] = "North-Northeast";
2282
-		} elseif ($direction >= 45 && $direction < 67.5){
2282
+		} elseif ($direction >= 45 && $direction < 67.5) {
2283 2283
 			$temp_array['direction_degree'] = $direction;
2284 2284
 			$temp_array['direction_shortname'] = "NE";
2285 2285
 			$temp_array['direction_fullname'] = "Northeast";
2286
-		} elseif ($direction >= 67.5 && $direction < 90){
2286
+		} elseif ($direction >= 67.5 && $direction < 90) {
2287 2287
 			$temp_array['direction_degree'] = $direction;
2288 2288
 			$temp_array['direction_shortname'] = "ENE";
2289 2289
 			$temp_array['direction_fullname'] = "East-Northeast";
2290
-		} elseif ($direction >= 90 && $direction < 112.5){
2290
+		} elseif ($direction >= 90 && $direction < 112.5) {
2291 2291
 			$temp_array['direction_degree'] = $direction;
2292 2292
 			$temp_array['direction_shortname'] = "E";
2293 2293
 			$temp_array['direction_fullname'] = "East";
2294
-		} elseif ($direction >= 112.5 && $direction < 135){
2294
+		} elseif ($direction >= 112.5 && $direction < 135) {
2295 2295
 			$temp_array['direction_degree'] = $direction;
2296 2296
 			$temp_array['direction_shortname'] = "ESE";
2297 2297
 			$temp_array['direction_fullname'] = "East-Southeast";
2298
-		} elseif ($direction >= 135 && $direction < 157.5){
2298
+		} elseif ($direction >= 135 && $direction < 157.5) {
2299 2299
 			$temp_array['direction_degree'] = $direction;
2300 2300
 			$temp_array['direction_shortname'] = "SE";
2301 2301
 			$temp_array['direction_fullname'] = "Southeast";
2302
-		} elseif ($direction >= 157.5 && $direction < 180){
2302
+		} elseif ($direction >= 157.5 && $direction < 180) {
2303 2303
 			$temp_array['direction_degree'] = $direction;
2304 2304
 			$temp_array['direction_shortname'] = "SSE";
2305 2305
 			$temp_array['direction_fullname'] = "South-Southeast";
2306
-		} elseif ($direction >= 180 && $direction < 202.5){
2306
+		} elseif ($direction >= 180 && $direction < 202.5) {
2307 2307
 			$temp_array['direction_degree'] = $direction;
2308 2308
 			$temp_array['direction_shortname'] = "S";
2309 2309
 			$temp_array['direction_fullname'] = "South";
2310
-		} elseif ($direction >= 202.5 && $direction < 225){
2310
+		} elseif ($direction >= 202.5 && $direction < 225) {
2311 2311
 			$temp_array['direction_degree'] = $direction;
2312 2312
 			$temp_array['direction_shortname'] = "SSW";
2313 2313
 			$temp_array['direction_fullname'] = "South-Southwest";
2314
-		} elseif ($direction >= 225 && $direction < 247.5){
2314
+		} elseif ($direction >= 225 && $direction < 247.5) {
2315 2315
 			$temp_array['direction_degree'] = $direction;
2316 2316
 			$temp_array['direction_shortname'] = "SW";
2317 2317
 			$temp_array['direction_fullname'] = "Southwest";
2318
-		} elseif ($direction >= 247.5 && $direction < 270){
2318
+		} elseif ($direction >= 247.5 && $direction < 270) {
2319 2319
 			$temp_array['direction_degree'] = $direction;
2320 2320
 			$temp_array['direction_shortname'] = "WSW";
2321 2321
 			$temp_array['direction_fullname'] = "West-Southwest";
2322
-		} elseif ($direction >= 270 && $direction < 292.5){
2322
+		} elseif ($direction >= 270 && $direction < 292.5) {
2323 2323
 			$temp_array['direction_degree'] = $direction;
2324 2324
 			$temp_array['direction_shortname'] = "W";
2325 2325
 			$temp_array['direction_fullname'] = "West";
2326
-		} elseif ($direction >= 292.5 && $direction < 315){
2326
+		} elseif ($direction >= 292.5 && $direction < 315) {
2327 2327
 			$temp_array['direction_degree'] = $direction;
2328 2328
 			$temp_array['direction_shortname'] = "WNW";
2329 2329
 			$temp_array['direction_fullname'] = "West-Northwest";
2330
-		} elseif ($direction >= 315 && $direction < 337.5){
2330
+		} elseif ($direction >= 315 && $direction < 337.5) {
2331 2331
 			$temp_array['direction_degree'] = $direction;
2332 2332
 			$temp_array['direction_shortname'] = "NW";
2333 2333
 			$temp_array['direction_fullname'] = "Northwest";
2334
-		} elseif ($direction >= 337.5 && $direction < 360){
2334
+		} elseif ($direction >= 337.5 && $direction < 360) {
2335 2335
 			$temp_array['direction_degree'] = $direction;
2336 2336
 			$temp_array['direction_shortname'] = "NNW";
2337 2337
 			$temp_array['direction_fullname'] = "North-Northwest";
@@ -2348,11 +2348,11 @@  discard block
 block discarded – undo
2348 2348
 	* @param Float $longitude longitute of the flight
2349 2349
 	* @return String the countries
2350 2350
 	*/
2351
-	public function getCountryFromLatitudeLongitude($latitude,$longitude)
2351
+	public function getCountryFromLatitudeLongitude($latitude, $longitude)
2352 2352
 	{
2353 2353
 		global $globalDebug;
2354
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2355
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2354
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
2355
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
2356 2356
 	
2357 2357
 		$Connection = new Connection($this->db);
2358 2358
 		if (!$Connection->tableExists('countries')) return '';
@@ -2392,7 +2392,7 @@  discard block
 block discarded – undo
2392 2392
 	public function getCountryFromISO2($iso2)
2393 2393
 	{
2394 2394
 		global $globalDebug;
2395
-		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
2395
+		$iso2 = filter_var($iso2, FILTER_SANITIZE_STRING);
2396 2396
 	
2397 2397
 		$Connection = new Connection($this->db);
2398 2398
 		if (!$Connection->tableExists('countries')) return '';
@@ -2440,7 +2440,7 @@  discard block
 block discarded – undo
2440 2440
 		
2441 2441
 		$bitly_data = json_decode($bitly_data);
2442 2442
 		$bitly_url = '';
2443
-		if ($bitly_data->status_txt = "OK"){
2443
+		if ($bitly_data->status_txt = "OK") {
2444 2444
 			$bitly_url = $bitly_data->data->url;
2445 2445
 		}
2446 2446
 
@@ -2460,11 +2460,11 @@  discard block
 block discarded – undo
2460 2460
      * @param string $day
2461 2461
      * @return array the vessel type list
2462 2462
      */
2463
-	public function countAllMarineTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
2463
+	public function countAllMarineTypes($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
2464 2464
 	{
2465 2465
 		global $globalDBdriver;
2466
-		$filter_query = $this->getFilter($filters,true,true);
2467
-		$query  = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count, marine_output.type_id AS marine_type_id 
2466
+		$filter_query = $this->getFilter($filters, true, true);
2467
+		$query = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count, marine_output.type_id AS marine_type_id 
2468 2468
 		    FROM marine_output ".$filter_query." marine_output.type <> '' AND marine_output.type_id IS NOT NULL";
2469 2469
 		if ($olderthanmonths > 0) {
2470 2470
 			if ($globalDBdriver == 'mysql') {
@@ -2484,28 +2484,28 @@  discard block
 block discarded – undo
2484 2484
 		if ($year != '') {
2485 2485
 			if ($globalDBdriver == 'mysql') {
2486 2486
 				$query .= " AND YEAR(marine_output.date) = :year";
2487
-				$query_values = array_merge($query_values,array(':year' => $year));
2487
+				$query_values = array_merge($query_values, array(':year' => $year));
2488 2488
 			} else {
2489 2489
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
2490
-				$query_values = array_merge($query_values,array(':year' => $year));
2490
+				$query_values = array_merge($query_values, array(':year' => $year));
2491 2491
 			}
2492 2492
 		}
2493 2493
 		if ($month != '') {
2494 2494
 			if ($globalDBdriver == 'mysql') {
2495 2495
 				$query .= " AND MONTH(marine_output.date) = :month";
2496
-				$query_values = array_merge($query_values,array(':month' => $month));
2496
+				$query_values = array_merge($query_values, array(':month' => $month));
2497 2497
 			} else {
2498 2498
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
2499
-				$query_values = array_merge($query_values,array(':month' => $month));
2499
+				$query_values = array_merge($query_values, array(':month' => $month));
2500 2500
 			}
2501 2501
 		}
2502 2502
 		if ($day != '') {
2503 2503
 			if ($globalDBdriver == 'mysql') {
2504 2504
 				$query .= " AND DAY(marine_output.date) = :day";
2505
-				$query_values = array_merge($query_values,array(':day' => $day));
2505
+				$query_values = array_merge($query_values, array(':day' => $day));
2506 2506
 			} else {
2507 2507
 				$query .= " AND EXTRACT(DAY FROM marine_output.date) = :day";
2508
-				$query_values = array_merge($query_values,array(':day' => $day));
2508
+				$query_values = array_merge($query_values, array(':day' => $day));
2509 2509
 			}
2510 2510
 		}
2511 2511
 		$query .= " GROUP BY marine_output.type, marine_output.type_id ORDER BY marine_type_count DESC";
@@ -2514,9 +2514,9 @@  discard block
 block discarded – undo
2514 2514
 		$sth->execute($query_values);
2515 2515
 		$marine_array = array();
2516 2516
 		$temp_array = array();
2517
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2517
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2518 2518
 		{
2519
-			$temp_array['marine_type'] = html_entity_decode($row['marine_type'],ENT_QUOTES);
2519
+			$temp_array['marine_type'] = html_entity_decode($row['marine_type'], ENT_QUOTES);
2520 2520
 			$temp_array['marine_type_id'] = $row['marine_type_id'];
2521 2521
 			$temp_array['marine_type_count'] = $row['marine_type_count'];
2522 2522
 			$marine_array[] = $temp_array;
@@ -2545,13 +2545,13 @@  discard block
 block discarded – undo
2545 2545
      * @param array $filters
2546 2546
      * @return array the tracker information
2547 2547
      */
2548
-	public function searchMarineData($q = '', $callsign = '',$mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '',$captain_id = '',$captain_name = '',$race_id = '',$race_name = '',$filters = array())
2548
+	public function searchMarineData($q = '', $callsign = '', $mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $captain_id = '', $captain_name = '', $race_id = '', $race_name = '', $filters = array())
2549 2549
 	{
2550 2550
 		global $globalTimezone, $globalDBdriver;
2551 2551
 		date_default_timezone_set('UTC');
2552 2552
 		$query_values = array();
2553 2553
 		$additional_query = '';
2554
-		$filter_query = $this->getFilter($filters,true,true);
2554
+		$filter_query = $this->getFilter($filters, true, true);
2555 2555
 		if ($q != "")
2556 2556
 		{
2557 2557
 			if (!is_string($q))
@@ -2559,8 +2559,8 @@  discard block
 block discarded – undo
2559 2559
 				return array();
2560 2560
 			} else {
2561 2561
 				$q_array = explode(" ", $q);
2562
-				foreach ($q_array as $q_item){
2563
-					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
2562
+				foreach ($q_array as $q_item) {
2563
+					$q_item = filter_var($q_item, FILTER_SANITIZE_STRING);
2564 2564
 					$additional_query .= " AND (";
2565 2565
 					if (is_int($q_item)) $additional_query .= "(marine_output.marine_id = '".$q_item."') OR ";
2566 2566
 					if (is_int($q_item)) $additional_query .= "(marine_output.mmsi = '".$q_item."') OR ";
@@ -2576,86 +2576,86 @@  discard block
 block discarded – undo
2576 2576
 		}
2577 2577
 		if ($callsign != "")
2578 2578
 		{
2579
-			$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
2579
+			$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
2580 2580
 			if (!is_string($callsign))
2581 2581
 			{
2582 2582
 				return array();
2583 2583
 			} else {
2584 2584
 				$additional_query .= " AND marine_output.ident = :callsign";
2585
-				$query_values = array_merge($query_values,array(':callsign' => $callsign));
2585
+				$query_values = array_merge($query_values, array(':callsign' => $callsign));
2586 2586
 			}
2587 2587
 		}
2588 2588
 		if ($mmsi != "")
2589 2589
 		{
2590
-			$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING);
2590
+			$mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING);
2591 2591
 			if (!is_numeric($mmsi))
2592 2592
 			{
2593 2593
 				return array();
2594 2594
 			} else {
2595 2595
 				$additional_query .= " AND marine_output.mmsi = :mmsi";
2596
-				$query_values = array_merge($query_values,array(':mmsi' => $mmsi));
2596
+				$query_values = array_merge($query_values, array(':mmsi' => $mmsi));
2597 2597
 			}
2598 2598
 		}
2599 2599
 		if ($imo != "")
2600 2600
 		{
2601
-			$imo = filter_var($imo,FILTER_SANITIZE_STRING);
2601
+			$imo = filter_var($imo, FILTER_SANITIZE_STRING);
2602 2602
 			if (!is_numeric($imo))
2603 2603
 			{
2604 2604
 				return array();
2605 2605
 			} else {
2606 2606
 				$additional_query .= " AND marine_output.imo = :imo";
2607
-				$query_values = array_merge($query_values,array(':imo' => $imo));
2607
+				$query_values = array_merge($query_values, array(':imo' => $imo));
2608 2608
 			}
2609 2609
 		}
2610 2610
 		if ($captain_id != "")
2611 2611
 		{
2612
-			$captain_id = filter_var($captain_id,FILTER_SANITIZE_STRING);
2612
+			$captain_id = filter_var($captain_id, FILTER_SANITIZE_STRING);
2613 2613
 			if (!is_numeric($captain_id))
2614 2614
 			{
2615 2615
 				return array();
2616 2616
 			} else {
2617 2617
 				$additional_query .= " AND marine_output.captain_id = :captain_id";
2618
-				$query_values = array_merge($query_values,array(':captain_id' => $captain_id));
2618
+				$query_values = array_merge($query_values, array(':captain_id' => $captain_id));
2619 2619
 			}
2620 2620
 		}
2621 2621
 		if ($race_id != "")
2622 2622
 		{
2623
-			$race_id = filter_var($race_id,FILTER_SANITIZE_STRING);
2623
+			$race_id = filter_var($race_id, FILTER_SANITIZE_STRING);
2624 2624
 			if (!is_numeric($race_id))
2625 2625
 			{
2626 2626
 				return array();
2627 2627
 			} else {
2628 2628
 				$additional_query .= " AND marine_output.race_id = :race_id";
2629
-				$query_values = array_merge($query_values,array(':race_id' => $race_id));
2629
+				$query_values = array_merge($query_values, array(':race_id' => $race_id));
2630 2630
 			}
2631 2631
 		}
2632 2632
 		if ($captain_name != "")
2633 2633
 		{
2634
-			$captain_name = filter_var($captain_name,FILTER_SANITIZE_STRING);
2634
+			$captain_name = filter_var($captain_name, FILTER_SANITIZE_STRING);
2635 2635
 			if (!is_string($captain_name))
2636 2636
 			{
2637 2637
 				return array();
2638 2638
 			} else {
2639 2639
 				$additional_query .= " AND marine_output.captain_name = :captain_name";
2640
-				$query_values = array_merge($query_values,array(':captain_name' => $captain_name));
2640
+				$query_values = array_merge($query_values, array(':captain_name' => $captain_name));
2641 2641
 			}
2642 2642
 		}
2643 2643
 		if ($race_name != "")
2644 2644
 		{
2645
-			$race_name = filter_var($race_name,FILTER_SANITIZE_STRING);
2645
+			$race_name = filter_var($race_name, FILTER_SANITIZE_STRING);
2646 2646
 			if (!is_numeric($race_name))
2647 2647
 			{
2648 2648
 				return array();
2649 2649
 			} else {
2650 2650
 				$additional_query .= " AND marine_output.race_name = :race_name";
2651
-				$query_values = array_merge($query_values,array(':race_name' => $race_name));
2651
+				$query_values = array_merge($query_values, array(':race_name' => $race_name));
2652 2652
 			}
2653 2653
 		}
2654 2654
 		if ($date_posted != "")
2655 2655
 		{
2656 2656
 			$date_array = explode(",", $date_posted);
2657
-			$date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
2658
-			$date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
2657
+			$date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING);
2658
+			$date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING);
2659 2659
 			if ($globalTimezone != '') {
2660 2660
 				date_default_timezone_set($globalTimezone);
2661 2661
 				$datetime = new DateTime();
@@ -2682,8 +2682,8 @@  discard block
 block discarded – undo
2682 2682
 		if ($limit != "")
2683 2683
 		{
2684 2684
 			$limit_array = explode(",", $limit);
2685
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
2686
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
2685
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
2686
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
2687 2687
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
2688 2688
 			{
2689 2689
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
@@ -2701,22 +2701,22 @@  discard block
 block discarded – undo
2701 2701
 			}
2702 2702
 		}
2703 2703
 		if ($origLat != "" && $origLon != "" && $dist != "") {
2704
-			$dist = number_format($dist*0.621371,2,'.',''); // convert km to mile
2704
+			$dist = number_format($dist*0.621371, 2, '.', ''); // convert km to mile
2705 2705
 			if ($globalDBdriver == 'mysql') {
2706
-				$query="SELECT marine_output.*, 1.60935*3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - marine_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(marine_archive.latitude*pi()/180)*POWER(SIN(($origLon-marine_archive.longitude)*pi()/180/2),2))) as distance 
2706
+				$query = "SELECT marine_output.*, 1.60935*3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - marine_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(marine_archive.latitude*pi()/180)*POWER(SIN(($origLon-marine_archive.longitude)*pi()/180/2),2))) as distance 
2707 2707
 				    FROM marine_archive,marine_output".$filter_query." marine_output.fammarine_id = marine_archive.fammarine_id AND marine_output.ident <> '' ".$additional_query."AND marine_archive.longitude between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat)*69)) and marine_archive.latitude between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
2708 2708
 				    AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - marine_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(marine_archive.latitude*pi()/180)*POWER(SIN(($origLon-marine_archive.longitude)*pi()/180/2),2)))) < $dist".$orderby_query;
2709 2709
 			} else {
2710
-				$query="SELECT marine_output.*, 1.60935 * 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(marine_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(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 
2710
+				$query = "SELECT marine_output.*, 1.60935 * 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(marine_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(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 
2711 2711
 				    FROM marine_archive,marine_output".$filter_query." marine_output.fammarine_id = marine_archive.fammarine_id AND marine_output.ident <> '' ".$additional_query."AND CAST(marine_archive.longitude as double precision) between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat))*69) and CAST(marine_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
2712 2712
 				    AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(marine_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(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.$orderby_query;
2713 2713
 			}
2714 2714
 		} else {
2715
-			$query  = "SELECT marine_output.* FROM marine_output".$filter_query." marine_output.ident <> '' 
2715
+			$query = "SELECT marine_output.* FROM marine_output".$filter_query." marine_output.ident <> '' 
2716 2716
 			    ".$additional_query."
2717 2717
 			    ".$orderby_query;
2718 2718
 		}
2719
-		$marine_array = $this->getDataFromDB($query, $query_values,$limit_query);
2719
+		$marine_array = $this->getDataFromDB($query, $query_values, $limit_query);
2720 2720
 		return $marine_array;
2721 2721
 	}
2722 2722
 
@@ -2728,12 +2728,12 @@  discard block
 block discarded – undo
2728 2728
      */
2729 2729
 	public function checkId($id)
2730 2730
 	{
2731
-		$query  = 'SELECT marine_output.ident, marine_output.fammarine_id FROM marine_output WHERE marine_output.fammarine_id = :id';
2731
+		$query = 'SELECT marine_output.ident, marine_output.fammarine_id FROM marine_output WHERE marine_output.fammarine_id = :id';
2732 2732
 		$query_data = array(':id' => $id);
2733 2733
 		$sth = $this->db->prepare($query);
2734 2734
 		$sth->execute($query_data);
2735
-		$ident_result='';
2736
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2735
+		$ident_result = '';
2736
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2737 2737
 		{
2738 2738
 			$ident_result = $row['fammarine_id'];
2739 2739
 		}
@@ -2748,7 +2748,7 @@  discard block
 block discarded – undo
2748 2748
      */
2749 2749
 	public function getRaceByName($race_name)
2750 2750
 	{
2751
-		$race_name = filter_var($race_name,FILTER_SANITIZE_STRING);
2751
+		$race_name = filter_var($race_name, FILTER_SANITIZE_STRING);
2752 2752
 		$query  = "SELECT * FROM marine_race WHERE race_name = :race_name LIMIT 1";
2753 2753
 		$sth = $this->db->prepare($query);
2754 2754
 		$sth->execute(array(':race_name' => $race_name));
@@ -2765,7 +2765,7 @@  discard block
 block discarded – undo
2765 2765
      */
2766 2766
 	public function getRace($race_id)
2767 2767
 	{
2768
-		$race_id = filter_var($race_id,FILTER_SANITIZE_NUMBER_INT);
2768
+		$race_id = filter_var($race_id, FILTER_SANITIZE_NUMBER_INT);
2769 2769
 		$query  = "SELECT * FROM marine_race WHERE race_id = :race_id LIMIT 1";
2770 2770
 		$sth = $this->db->prepare($query);
2771 2771
 		$sth->execute(array(':race_id' => $race_id));
@@ -2783,24 +2783,24 @@  discard block
 block discarded – undo
2783 2783
      * @param $race_startdate
2784 2784
      * @param $race_markers
2785 2785
      */
2786
-	public function addRace($race_id,$race_name,$race_creator,$race_desc,$race_startdate,$race_markers)
2786
+	public function addRace($race_id, $race_name, $race_creator, $race_desc, $race_startdate, $race_markers)
2787 2787
 	{
2788
-		$race_id = filter_var($race_id,FILTER_SANITIZE_NUMBER_INT);
2788
+		$race_id = filter_var($race_id, FILTER_SANITIZE_NUMBER_INT);
2789 2789
 		if ($race_id != '') {
2790
-			$race_name = filter_var($race_name,FILTER_SANITIZE_STRING);
2791
-			$race_creator = filter_var($race_creator,FILTER_SANITIZE_STRING);
2792
-			$race_desc = filter_var($race_desc,FILTER_SANITIZE_STRING);
2793
-			$race_startdate = filter_var($race_startdate,FILTER_SANITIZE_STRING);
2790
+			$race_name = filter_var($race_name, FILTER_SANITIZE_STRING);
2791
+			$race_creator = filter_var($race_creator, FILTER_SANITIZE_STRING);
2792
+			$race_desc = filter_var($race_desc, FILTER_SANITIZE_STRING);
2793
+			$race_startdate = filter_var($race_startdate, FILTER_SANITIZE_STRING);
2794 2794
 			//$race_markers = filter_var($race_markers,FILTER_SANITIZE_STRING);
2795 2795
 			$allrace = $this->getRace($race_id);
2796 2796
 			if (empty($allrace)) {
2797 2797
 				$query  = "INSERT INTO marine_race (race_id,race_name,race_creator,race_desc,race_startdate,race_markers) VALUES (:race_id,:race_name,:race_creator,:race_desc,:race_startdate,:race_markers)";
2798 2798
 				$sth = $this->db->prepare($query);
2799
-				$sth->execute(array(':race_id' => $race_id,':race_name' => $race_name,':race_creator' => $race_creator,':race_desc' => $race_desc,':race_startdate' => $race_startdate,':race_markers' => $race_markers));
2799
+				$sth->execute(array(':race_id' => $race_id, ':race_name' => $race_name, ':race_creator' => $race_creator, ':race_desc' => $race_desc, ':race_startdate' => $race_startdate, ':race_markers' => $race_markers));
2800 2800
 			} elseif ($race_id != '') {
2801
-				$query  = "UPDATE marine_race SET race_name = :race_name,race_desc = :race_desc,race_startdate = :race_startdate,race_markers = :race_markers WHERE race_id = :race_id";
2801
+				$query = "UPDATE marine_race SET race_name = :race_name,race_desc = :race_desc,race_startdate = :race_startdate,race_markers = :race_markers WHERE race_id = :race_id";
2802 2802
 				$sth = $this->db->prepare($query);
2803
-				$sth->execute(array(':race_id' => $race_id,':race_name' => $race_name,':race_desc' => $race_desc,':race_startdate' => $race_startdate,':race_markers' => $race_markers));
2803
+				$sth->execute(array(':race_id' => $race_id, ':race_name' => $race_name, ':race_desc' => $race_desc, ':race_startdate' => $race_startdate, ':race_markers' => $race_markers));
2804 2804
 			}
2805 2805
 		}
2806 2806
 	}
@@ -2809,7 +2809,7 @@  discard block
 block discarded – undo
2809 2809
 
2810 2810
 	public function getOrderBy()
2811 2811
 	{
2812
-		$orderby = array("type_asc" => array("key" => "type_asc", "value" => "Type - ASC", "sql" => "ORDER BY marine_output.type ASC"), "type_desc" => array("key" => "type_desc", "value" => "Type - DESC", "sql" => "ORDER BY marine_output.type 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 port - ASC", "sql" => "ORDER BY marine_output.departure_port_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"));
2812
+		$orderby = array("type_asc" => array("key" => "type_asc", "value" => "Type - ASC", "sql" => "ORDER BY marine_output.type ASC"), "type_desc" => array("key" => "type_desc", "value" => "Type - DESC", "sql" => "ORDER BY marine_output.type 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 port - ASC", "sql" => "ORDER BY marine_output.departure_port_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"));
2813 2813
 		return $orderby;
2814 2814
 	}
2815 2815
     
Please login to merge, or discard this patch.
require/class.Scheduler.php 3 patches
Indentation   +156 added lines, -156 removed lines patch added patch discarded remove patch
@@ -27,16 +27,16 @@  discard block
 block discarded – undo
27 27
 		if ($this->db === null) die('Error: No DB connection.');
28 28
 	}
29 29
 
30
-    /**
31
-     * Add schedule data to database
32
-     * @param String $ident aircraft ident
33
-     * @param String $departure_airport_icao departure airport icao
34
-     * @param String $departure_airport_time departure airport time
35
-     * @param String $arrival_airport_icao arrival airport icao
36
-     * @param String $arrival_airport_time arrival airport time
37
-     * @param String $source source of data
38
-     * @return string
39
-     */
30
+	/**
31
+	 * Add schedule data to database
32
+	 * @param String $ident aircraft ident
33
+	 * @param String $departure_airport_icao departure airport icao
34
+	 * @param String $departure_airport_time departure airport time
35
+	 * @param String $arrival_airport_icao arrival airport icao
36
+	 * @param String $arrival_airport_time arrival airport time
37
+	 * @param String $source source of data
38
+	 * @return string
39
+	 */
40 40
 	public function addSchedule($ident,$departure_airport_icao,$departure_airport_time,$arrival_airport_icao,$arrival_airport_time,$source = 'website') {
41 41
 		date_default_timezone_set('UTC');
42 42
 		$date = date("Y-m-d H:i:s",time());
@@ -52,18 +52,18 @@  discard block
 block discarded – undo
52 52
 		}
53 53
 		if ($sth->fetchColumn() > 0) {
54 54
 			if ($departure_airport_time == '' && $arrival_airport_time == '') {
55
-			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao";
56
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao);
55
+				$query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao";
56
+				$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao);
57 57
 			} elseif ($arrival_airport_time == '') {
58
-			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao";
59
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao);
58
+				$query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao";
59
+				$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao);
60 60
 			} elseif ($departure_airport_time == '') {
61
-			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time";
62
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
61
+				$query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time";
62
+				$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
63 63
 			} else {
64
-			    //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident AND departure_airport_icao = :departure_airport_icao AND departure_airport_time = :departure_airport_time AND arrival_airport_icao = :arrival_airport_icao AND arrival_airport_time = :arrival_airport_time";
65
-			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time";
66
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
64
+				//$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident AND departure_airport_icao = :departure_airport_icao AND departure_airport_time = :departure_airport_time AND arrival_airport_icao = :arrival_airport_icao AND arrival_airport_time = :arrival_airport_time";
65
+				$query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time";
66
+				$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
67 67
 			}
68 68
 			try {
69 69
 				$sth = $this->db->prepare($query);
@@ -151,15 +151,15 @@  discard block
 block discarded – undo
151 151
 	*/
152 152
 	public function checkSchedule($ident) {
153 153
 		global $globalDBdriver;
154
-	        //$query = "SELECT COUNT(*) as nb FROM schedule WHERE ident = :ident AND date_added > DATE_SUB(CURDATE(), INTERVAL 8 DAY) - 8 LIMIT 1";
155
-	        if ($globalDBdriver == 'mysql') {
154
+			//$query = "SELECT COUNT(*) as nb FROM schedule WHERE ident = :ident AND date_added > DATE_SUB(CURDATE(), INTERVAL 8 DAY) - 8 LIMIT 1";
155
+			if ($globalDBdriver == 'mysql') {
156 156
 			$query = "SELECT COUNT(*) as nb FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :ident AND ((date_added BETWEEN DATE(DATE_SUB(CURDATE(), INTERVAL 1 MONTH)) AND DATE(NOW()) and date_modified IS NULL) OR (date_modified BETWEEN DATE(DATE_SUB(CURDATE(), INTERVAL 15 DAY)) AND DATE(NOW()))) LIMIT 1";
157 157
 		} else {
158 158
 			$query = "SELECT COUNT(*) as nb FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :ident 
159 159
 			AND ((date_added::timestamp BETWEEN CURRENT_TIMESTAMP - INTERVAL '1 MONTH' AND CURRENT_TIMESTAMP) and date_modified::timestamp IS NULL)
160 160
 			     OR (date_modified::timestamp BETWEEN CURRENT_TIMESTAMP - INTERVAL '1 MONTH' AND CURRENT_TIMESTAMP) LIMIT 1";
161 161
 		}
162
-	        $query_values = array(':ident' => $ident);
162
+			$query_values = array(':ident' => $ident);
163 163
 		 try {
164 164
 			$sth = $this->db->prepare($query);
165 165
 			$sth->execute($query_values);
@@ -171,13 +171,13 @@  discard block
 block discarded – undo
171 171
 		return $row['nb'];
172 172
 	}
173 173
 
174
-    /**
175
-     * Get flight info from Air France
176
-     * @param String $callsign The callsign
177
-     * @param String $date date we want flight number info
178
-     * @param String $carrier IATA code
179
-     * @return array departure and arrival airports and time
180
-     */
174
+	/**
175
+	 * Get flight info from Air France
176
+	 * @param String $callsign The callsign
177
+	 * @param String $date date we want flight number info
178
+	 * @param String $carrier IATA code
179
+	 * @return array departure and arrival airports and time
180
+	 */
181 181
 	public function getAirFrance($callsign, $date = 'NOW',$carrier = 'AF') {
182 182
 		$Common = new Common();
183 183
 		$check_date = new Datetime($date);
@@ -212,12 +212,12 @@  discard block
 block discarded – undo
212 212
 		} else return array();
213 213
 	}
214 214
 
215
-    /**
216
-     * Get flight info from EasyJet
217
-     * @param String $callsign The callsign
218
-     * @param String $date date we want flight number info
219
-     * @return array departure and arrival airports and time
220
-     */
215
+	/**
216
+	 * Get flight info from EasyJet
217
+	 * @param String $callsign The callsign
218
+	 * @param String $date date we want flight number info
219
+	 * @return array departure and arrival airports and time
220
+	 */
221 221
 	private function getEasyJet($callsign, $date = 'NOW') {
222 222
 		global $globalTimezone;
223 223
 		$Common = new Common();
@@ -240,11 +240,11 @@  discard block
 block discarded – undo
240 240
 		} else return array();
241 241
 	}
242 242
 
243
-    /**
244
-     * Get flight info from Ryanair
245
-     * @param String $callsign The callsign
246
-     * @return array Flight departure and arrival airports and time
247
-     */
243
+	/**
244
+	 * Get flight info from Ryanair
245
+	 * @param String $callsign The callsign
246
+	 * @return array Flight departure and arrival airports and time
247
+	 */
248 248
 	private function getRyanair($callsign) {
249 249
 		$Common = new Common();
250 250
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -267,10 +267,10 @@  discard block
 block discarded – undo
267 267
 	}
268 268
 
269 269
 	/**
270
-	* Get flight info from Swiss
271
-	* @param string $callsign The callsign
272
-	* @return array Flight departure and arrival airports and time
273
-	*/
270
+	 * Get flight info from Swiss
271
+	 * @param string $callsign The callsign
272
+	 * @return array Flight departure and arrival airports and time
273
+	 */
274 274
 	private function getSwiss($callsign) {
275 275
 		$Common = new Common();
276 276
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -299,11 +299,11 @@  discard block
 block discarded – undo
299 299
 	}
300 300
 	
301 301
 	/**
302
-	* Get flight info from British Airways API
303
-	* @param String $callsign The callsign
304
-	* @param String $date date we want flight number info
305
-	* @return array Flight departure and arrival airports and time
306
-	*/
302
+	 * Get flight info from British Airways API
303
+	 * @param String $callsign The callsign
304
+	 * @param String $date date we want flight number info
305
+	 * @return array Flight departure and arrival airports and time
306
+	 */
307 307
 	public function getBritishAirways($callsign, $date = 'NOW') {
308 308
 		global $globalBritishAirwaysKey;
309 309
 		$Common = new Common();
@@ -327,11 +327,11 @@  discard block
 block discarded – undo
327 327
 	}
328 328
 
329 329
 	/**
330
-	* Get flight info from Lutfhansa API
331
-	* @param String $callsign The callsign
332
-	* @param String $date date we want flight number info
333
-	* @return array Flight departure and arrival airports and time
334
-	*/
330
+	 * Get flight info from Lutfhansa API
331
+	 * @param String $callsign The callsign
332
+	 * @param String $date date we want flight number info
333
+	 * @return array Flight departure and arrival airports and time
334
+	 */
335 335
 	public function getLufthansa($callsign, $date = 'NOW') {
336 336
 		global $globalLufthansaKey;
337 337
 		$Common = new Common();
@@ -361,11 +361,11 @@  discard block
 block discarded – undo
361 361
 	}
362 362
 
363 363
 	/**
364
-	* Get flight info from Transavia API
365
-	* @param string $callsign The callsign
366
-	* @param string $date date we want flight number info
367
-	* @return array Flight departure and arrival airports and time
368
-	*/
364
+	 * Get flight info from Transavia API
365
+	 * @param string $callsign The callsign
366
+	 * @param string $date date we want flight number info
367
+	 * @return array Flight departure and arrival airports and time
368
+	 */
369 369
 	public function getTransavia($callsign, $date = 'NOW') {
370 370
 		global $globalTransaviaKey;
371 371
 		$Common = new Common();
@@ -391,10 +391,10 @@  discard block
 block discarded – undo
391 391
 	}
392 392
 
393 393
 	/**
394
-	* Get flight info from Tunisair
395
-	* @param string $callsign The callsign
396
-	* @return array Flight departure and arrival airports and time
397
-	*/
394
+	 * Get flight info from Tunisair
395
+	 * @param string $callsign The callsign
396
+	 * @return array Flight departure and arrival airports and time
397
+	 */
398 398
 	public function getTunisair($callsign) {
399 399
 		$Common = new Common();
400 400
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -410,12 +410,12 @@  discard block
 block discarded – undo
410 410
 		return array();
411 411
 	}
412 412
 
413
-    /**
414
-     * Get flight info from Vueling
415
-     * @param String $callsign The callsign
416
-     * @param string $date
417
-     * @return array Flight departure and arrival airports and time
418
-     */
413
+	/**
414
+	 * Get flight info from Vueling
415
+	 * @param String $callsign The callsign
416
+	 * @param string $date
417
+	 * @return array Flight departure and arrival airports and time
418
+	 */
419 419
 	public function getVueling($callsign,$date = 'NOW') {
420 420
 		$Common = new Common();
421 421
 		$check_date = new Datetime($date);
@@ -437,11 +437,11 @@  discard block
 block discarded – undo
437 437
 	}
438 438
 
439 439
 	/**
440
-	* Get flight info from Iberia
441
-	* @param String $callsign The callsign
442
-	* @param String $date date we want flight number info
443
-	* @return array Flight departure and arrival airports and time
444
-	*/
440
+	 * Get flight info from Iberia
441
+	 * @param String $callsign The callsign
442
+	 * @param String $date date we want flight number info
443
+	 * @return array Flight departure and arrival airports and time
444
+	 */
445 445
 	public function getIberia($callsign, $date = 'NOW') {
446 446
 		$Common = new Common();
447 447
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -470,13 +470,13 @@  discard block
 block discarded – undo
470 470
 		return array();
471 471
 	}
472 472
 
473
-    /**
474
-     * Get flight info from Star Alliance
475
-     * @param String $callsign The callsign
476
-     * @param String $date date we want flight number info
477
-     * @param string $carrier
478
-     * @return array Flight departure and arrival airports and time
479
-     */
473
+	/**
474
+	 * Get flight info from Star Alliance
475
+	 * @param String $callsign The callsign
476
+	 * @param String $date date we want flight number info
477
+	 * @param string $carrier
478
+	 * @return array Flight departure and arrival airports and time
479
+	 */
480 480
 
481 481
 	private function getStarAlliance($callsign, $date = 'NOW',$carrier = '') {
482 482
 		$Common = new Common();
@@ -508,11 +508,11 @@  discard block
 block discarded – undo
508 508
 
509 509
 
510 510
 	/**
511
-	* Get flight info from Alitalia
512
-	* @param String $callsign The callsign
513
-	* @param String $date date we want flight number info
514
-	* @return array Flight departure and arrival airports and time
515
-	*/
511
+	 * Get flight info from Alitalia
512
+	 * @param String $callsign The callsign
513
+	 * @param String $date date we want flight number info
514
+	 * @return array Flight departure and arrival airports and time
515
+	 */
516 516
 	private function getAlitalia($callsign, $date = 'NOW') {
517 517
 		$Common = new Common();
518 518
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -532,11 +532,11 @@  discard block
 block discarded – undo
532 532
 	}
533 533
 
534 534
 	/**
535
-	* Get flight info from Brussels airlines
536
-	* @param String $callsign The callsign
537
-	* @param String $date date we want flight number info
538
-	* @return array Flight departure and arrival airports and time
539
-	*/
535
+	 * Get flight info from Brussels airlines
536
+	 * @param String $callsign The callsign
537
+	 * @param String $date date we want flight number info
538
+	 * @return array Flight departure and arrival airports and time
539
+	 */
540 540
 	private function getBrussels($callsign, $date = 'NOW') {
541 541
 		$Common = new Common();
542 542
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -546,25 +546,25 @@  discard block
 block discarded – undo
546 546
 		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
547 547
 		$data = $Common->getData($url);
548 548
 		if ($data != '') {
549
-		    //echo $data;
550
-		    $parsed_json = json_decode($data,true);
551
-		    if (isset($parsed_json[0]['FromAirportCode'])) {
549
+			//echo $data;
550
+			$parsed_json = json_decode($data,true);
551
+			if (isset($parsed_json[0]['FromAirportCode'])) {
552 552
 			$DepartureAirportIata = $parsed_json[0]['FromAirportCode'];
553 553
 			$ArrivalAirportIata = $parsed_json[0]['ToAirportCode'];
554 554
 			$departureTime = date('H:i',strtotime($parsed_json[0]['ScheduledDepatureDate']));
555 555
 			$arrivalTime = date('H:i',strtotime($parsed_json[0]['ScheduledArrivalDate']));
556 556
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_brussels');
557
-		    }
557
+			}
558 558
 		}
559 559
 		return array();
560 560
 	}
561 561
 
562 562
 	/**
563
-	* Get flight info from FlightRadar24
564
-	* @param String $callsign The callsign
565
-	* @param String $date date we want flight number info
566
-	* @return array Flight departure and arrival airports and time
567
-	*/
563
+	 * Get flight info from FlightRadar24
564
+	 * @param String $callsign The callsign
565
+	 * @param String $date date we want flight number info
566
+	 * @return array Flight departure and arrival airports and time
567
+	 */
568 568
 /*
569 569
 	public function getFlightRadar24($callsign, $date = 'NOW') {
570 570
 		$Common = new Common();
@@ -593,11 +593,11 @@  discard block
 block discarded – undo
593 593
 	}
594 594
   */
595 595
 	/**
596
-	* Get flight info from Lufthansa
597
-	* @param String $callsign The callsign
598
-	* @param String $date date we want flight number info
599
-	* @return array Flight departure and arrival airports and time
600
-	*/
596
+	 * Get flight info from Lufthansa
597
+	 * @param String $callsign The callsign
598
+	 * @param String $date date we want flight number info
599
+	 * @return array Flight departure and arrival airports and time
600
+	 */
601 601
 
602 602
 /*	private function getLufthansa($callsign, $date = 'NOW') {
603 603
 		$Common = new Common();
@@ -625,10 +625,10 @@  discard block
 block discarded – undo
625 625
 	}
626 626
   */
627 627
 	/**
628
-	* Get flight info from flytap
629
-	* @param String $callsign The callsign
630
-	* @return array Flight departure and arrival airports and time
631
-	*/
628
+	 * Get flight info from flytap
629
+	 * @param String $callsign The callsign
630
+	 * @return array Flight departure and arrival airports and time
631
+	 */
632 632
 	private function getFlyTap($callsign) {
633 633
 		$Common = new Common();
634 634
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -651,10 +651,10 @@  discard block
 block discarded – undo
651 651
 	}
652 652
 
653 653
 	/**
654
-	* Get flight info from flightmapper
655
-	* @param String $callsign The callsign
656
-	* @return array Flight departure and arrival airports and time
657
-	*/
654
+	 * Get flight info from flightmapper
655
+	 * @param String $callsign The callsign
656
+	 * @return array Flight departure and arrival airports and time
657
+	 */
658 658
 	public function getFlightMapper($callsign) {
659 659
 		$Common = new Common();
660 660
 		$airline_icao = '';
@@ -682,11 +682,11 @@  discard block
 block discarded – undo
682 682
 				$aarr = '';
683 683
 				$n = sscanf($sched,'%*s %5[0-9:] %*[^()] (%3[A-Z]) %5[0-9:] %*[^()] (%3[A-Z])',$dhour,$darr,$ahour,$aarr);
684 684
 				if ($n == 7) {
685
-				    $departureTime = $dhour;
686
-				    $arrivalTime = $ahour;
687
-				    $DepartureAirportIata = str_replace(array('(',')'),'',$darr);
688
-				    $ArrivalAirportIata = str_replace(array('(',')'),'',$aarr);
689
-				    return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightmapper');
685
+					$departureTime = $dhour;
686
+					$arrivalTime = $ahour;
687
+					$DepartureAirportIata = str_replace(array('(',')'),'',$darr);
688
+					$ArrivalAirportIata = str_replace(array('(',')'),'',$aarr);
689
+					return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightmapper');
690 690
 				}
691 691
 			}
692 692
 		}
@@ -694,10 +694,10 @@  discard block
 block discarded – undo
694 694
 	}
695 695
 
696 696
 	/**
697
-	* Get flight info from flightaware
698
-	* @param String $callsign The callsign
699
-	* @return array Flight departure and arrival airports and time
700
-	*/
697
+	 * Get flight info from flightaware
698
+	 * @param String $callsign The callsign
699
+	 * @return array Flight departure and arrival airports and time
700
+	 */
701 701
 	public function getFlightAware($callsign) {
702 702
 		global $globalFlightAwareUsername, $globalFlightAwarePassword;
703 703
 		date_default_timezone_set('UTC');
@@ -722,11 +722,11 @@  discard block
 block discarded – undo
722 722
 				$flight = $result['FlightInfoStatusResult']['flights'][0];
723 723
 				if (isset($flight['origin'])) {
724 724
 					return array(
725
-					    'DepartureAirportIATA' => $flight['origin']['alternate_ident'],
726
-					    'DepartureTime' => $flight['filed_departure_time']['time'],
727
-					    'ArrivalAirportIATA' => $flight['destination']['alternate_ident'],
728
-					    'ArrivalTime' => $flight['filed_arrival_time']['time'],
729
-					    'Source' => 'website_flightaware');
725
+						'DepartureAirportIATA' => $flight['origin']['alternate_ident'],
726
+						'DepartureTime' => $flight['filed_departure_time']['time'],
727
+						'ArrivalAirportIATA' => $flight['destination']['alternate_ident'],
728
+						'ArrivalTime' => $flight['filed_arrival_time']['time'],
729
+						'Source' => 'website_flightaware');
730 730
 				}
731 731
 			}
732 732
 		}
@@ -739,21 +739,21 @@  discard block
 block discarded – undo
739 739
 			$flight = reset($flights['flights']);
740 740
 			if (isset($flight['activityLog']['flights'][0]['origin'])) {
741 741
 				return array(
742
-				    'DepartureAirportIATA' => $flight['activityLog']['flights'][0]['origin']['iata'],
743
-				    'DepartureTime' => date('H:i',$flight['activityLog']['flights'][0]['takeoffTimes']['scheduled']),
744
-				    'ArrivalAirportIATA' => $flight['activityLog']['flights'][0]['destination']['iata'],
745
-				    'ArrivalTime' => date('H:i',$flight['activityLog']['flights'][0]['landingTimes']['scheduled']),
746
-				    'Source' => 'website_flightaware');
742
+					'DepartureAirportIATA' => $flight['activityLog']['flights'][0]['origin']['iata'],
743
+					'DepartureTime' => date('H:i',$flight['activityLog']['flights'][0]['takeoffTimes']['scheduled']),
744
+					'ArrivalAirportIATA' => $flight['activityLog']['flights'][0]['destination']['iata'],
745
+					'ArrivalTime' => date('H:i',$flight['activityLog']['flights'][0]['landingTimes']['scheduled']),
746
+					'Source' => 'website_flightaware');
747 747
 			}
748 748
 		}
749 749
 		return array();
750 750
 	}
751 751
 
752 752
 	/**
753
-	* Get flight info from CostToTravel
754
-	* @param String $callsign The callsign
755
-	* @return array Flight departure and arrival airports and time
756
-	*/
753
+	 * Get flight info from CostToTravel
754
+	 * @param String $callsign The callsign
755
+	 * @return array Flight departure and arrival airports and time
756
+	 */
757 757
 	public function getCostToTravel($callsign) {
758 758
 		$Common = new Common();
759 759
 		$url= "http://www.costtotravel.com/flight-number/".$callsign;
@@ -776,11 +776,11 @@  discard block
 block discarded – undo
776 776
 	}
777 777
 
778 778
 	/**
779
-	* Get flight info from Air Canada
780
-	* @param string $callsign The callsign
781
-	* @param string $date date we want flight number info
782
-	* @return array Flight departure and arrival airports and time
783
-	*/
779
+	 * Get flight info from Air Canada
780
+	 * @param string $callsign The callsign
781
+	 * @param string $date date we want flight number info
782
+	 * @return array Flight departure and arrival airports and time
783
+	 */
784 784
 	private function getAirCanada($callsign,$date = 'NOW') {
785 785
 		$Common = new Common();
786 786
 		if (class_exists("DomDocument") === FALSE) return array();
@@ -805,11 +805,11 @@  discard block
 block discarded – undo
805 805
 	}
806 806
 
807 807
 	/**
808
-	* Get flight info from Vietnam Airlines
809
-	* @param String $callsign The callsign
810
-	* @param String $date date we want flight number info
811
-	* @return array Flight departure and arrival airports and time
812
-	*/
808
+	 * Get flight info from Vietnam Airlines
809
+	 * @param String $callsign The callsign
810
+	 * @param String $date date we want flight number info
811
+	 * @return array Flight departure and arrival airports and time
812
+	 */
813 813
 	private function getVietnamAirlines($callsign, $date = 'NOW') {
814 814
 		$Common = new Common();
815 815
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -832,12 +832,12 @@  discard block
 block discarded – undo
832 832
 	}
833 833
 
834 834
 	/**
835
-	* Get flight info from Air Berlin
836
-	* @param String $callsign The callsign
837
-	* @param String $date date we want flight number info
838
-	* @param String $carrier airline code
839
-	* @return array Flight departure and arrival airports and time
840
-	*/
835
+	 * Get flight info from Air Berlin
836
+	 * @param String $callsign The callsign
837
+	 * @param String $date date we want flight number info
838
+	 * @param String $carrier airline code
839
+	 * @return array Flight departure and arrival airports and time
840
+	 */
841 841
 	private function getAirBerlin($callsign, $date = 'NOW',$carrier = 'AB') {
842 842
 		$Common = new Common();
843 843
 		date_default_timezone_set('UTC');
@@ -866,11 +866,11 @@  discard block
 block discarded – undo
866 866
 			$table = $Common->table2array($data);
867 867
 			$flight = $table;
868 868
 			if (isset($flight[5][4])) {
869
-			    $arrivalTime = $flight[5][4];
870
-			    $arrivalAirport = $flight[5][3];
869
+				$arrivalTime = $flight[5][4];
870
+				$arrivalAirport = $flight[5][3];
871 871
 			} else {
872
-			    $arrivalTime = '';
873
-			    $arrivalAirport = '';
872
+				$arrivalTime = '';
873
+				$arrivalAirport = '';
874 874
 			}
875 875
 		} else return array();
876 876
 		$url = 'http://www.airberlin.com/en-US/site/json/suggestAirport.php?searchfor=departures&searchflightid=0&departures%5B%5D=&suggestsource%5B0%5D=activeairports&withcountries=0&withoutroutings=0&promotion%5Bid%5D=&promotion%5Btype%5D=&routesource%5B0%5D=airberlin&routesource%5B1%5D=partner';
Please login to merge, or discard this patch.
Spacing   +166 added lines, -166 removed lines patch added patch discarded remove patch
@@ -37,9 +37,9 @@  discard block
 block discarded – undo
37 37
      * @param String $source source of data
38 38
      * @return string
39 39
      */
40
-	public function addSchedule($ident,$departure_airport_icao,$departure_airport_time,$arrival_airport_icao,$arrival_airport_time,$source = 'website') {
40
+	public function addSchedule($ident, $departure_airport_icao, $departure_airport_time, $arrival_airport_icao, $arrival_airport_time, $source = 'website') {
41 41
 		date_default_timezone_set('UTC');
42
-		$date = date("Y-m-d H:i:s",time());
42
+		$date = date("Y-m-d H:i:s", time());
43 43
 		//if ($departure_airport_time == '' && $arrival_airport_time == '') exit;
44 44
 		//$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident";
45 45
 		$query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident";
@@ -47,69 +47,69 @@  discard block
 block discarded – undo
47 47
 		 try {
48 48
 			$sth = $this->db->prepare($query);
49 49
 			$sth->execute($query_values);
50
-		} catch(PDOException $e) {
50
+		} catch (PDOException $e) {
51 51
 			return "error : ".$e->getMessage();
52 52
 		}
53 53
 		if ($sth->fetchColumn() > 0) {
54 54
 			if ($departure_airport_time == '' && $arrival_airport_time == '') {
55 55
 			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao";
56
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao);
56
+			    $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao);
57 57
 			} elseif ($arrival_airport_time == '') {
58 58
 			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao";
59
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao);
59
+			    $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao);
60 60
 			} elseif ($departure_airport_time == '') {
61 61
 			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time";
62
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
62
+			    $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time);
63 63
 			} else {
64 64
 			    //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident AND departure_airport_icao = :departure_airport_icao AND departure_airport_time = :departure_airport_time AND arrival_airport_icao = :arrival_airport_icao AND arrival_airport_time = :arrival_airport_time";
65 65
 			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time";
66
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
66
+			    $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time);
67 67
 			}
68 68
 			try {
69 69
 				$sth = $this->db->prepare($query);
70 70
 				$sth->execute($query_values);
71
-			} catch(PDOException $e) {
71
+			} catch (PDOException $e) {
72 72
 				return "error : ".$e->getMessage();
73 73
 			}
74 74
 			if ($sth->fetchColumn() == 0) {
75 75
 				//$query = 'UPDATE schedule SET departure_airport_icao = :departure_airport_icao, departure_airport_time = :departure_airport_time, arrival_airport_icao = :arrival_airport_icao, arrival_airport_time = :arrival_airport_time, date_modified = :date, source = :source WHERE ident = :ident';
76 76
 				if ($departure_airport_time == '' && $arrival_airport_time == '') {
77 77
 					$query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident';
78
-					$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source);
78
+					$query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source);
79 79
 				} elseif ($arrival_airport_time == '') {
80 80
 					$query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident';
81
-					$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source);
81
+					$query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source);
82 82
 				} elseif ($departure_airport_time == '') {
83 83
 					$query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident';
84
-					$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
84
+					$query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
85 85
 				} else {
86 86
 					$query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident';
87
-					$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
87
+					$query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
88 88
 				}
89 89
 				try {
90 90
 					$sth = $this->db->prepare($query);
91 91
 					$sth->execute($query_values);
92
-				} catch(PDOException $e) {
92
+				} catch (PDOException $e) {
93 93
 					return "error : ".$e->getMessage();
94 94
 				}
95 95
 			} else {
96 96
 				//$query = 'UPDATE schedule SET date_lastseen = :date WHERE ident = :ident';
97 97
 				$query = 'UPDATE routes SET date_lastseen = :date WHERE CallSign = :ident';
98
-				$query_values = array(':ident' => $ident,':date' => $date);
98
+				$query_values = array(':ident' => $ident, ':date' => $date);
99 99
 				try {
100 100
 					$sth = $this->db->prepare($query);
101 101
 					$sth->execute($query_values);
102
-				} catch(PDOException $e) {
102
+				} catch (PDOException $e) {
103 103
 					return "error : ".$e->getMessage();
104 104
 				}
105 105
 			}
106 106
 		} else {
107 107
 			$query = 'INSERT INTO  routes (CallSign,FromAirport_ICAO, FromAirport_Time, ToAirport_ICAO, ToAirport_Time,date_added,source)  VALUES (:ident,:departure_airport_icao,:departure_airport_time,:arrival_airport_icao,:arrival_airport_time,:date,:source)';
108
-			$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
108
+			$query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
109 109
 			 try {
110 110
 				$sth = $this->db->prepare($query);
111 111
 				$sth->execute($query_values);
112
-			} catch(PDOException $e) {
112
+			} catch (PDOException $e) {
113 113
 				return "error : ".$e->getMessage();
114 114
 			}
115 115
 		}
@@ -123,10 +123,10 @@  discard block
 block discarded – undo
123 123
 	*/
124 124
 	public function getSchedule($ident) {
125 125
 		$Translation = new Translation($this->db);
126
-		$operator = $Translation->checkTranslation($ident,false);
126
+		$operator = $Translation->checkTranslation($ident, false);
127 127
 		if ($ident != $operator) {
128 128
 			$query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :operator OR CallSign = :ident LIMIT 1";
129
-			$query_values = array(':ident' => $ident,'operator' => $operator);
129
+			$query_values = array(':ident' => $ident, 'operator' => $operator);
130 130
 		} else {
131 131
 			$query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :ident LIMIT 1";
132 132
 			$query_values = array(':ident' => $ident);
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 		 try {
135 135
 			$sth = $this->db->prepare($query);
136 136
 			$sth->execute($query_values);
137
-		} catch(PDOException $e) {
137
+		} catch (PDOException $e) {
138 138
 			return "error : ".$e->getMessage();
139 139
 		}
140 140
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 		 try {
164 164
 			$sth = $this->db->prepare($query);
165 165
 			$sth->execute($query_values);
166
-		} catch(PDOException $e) {
166
+		} catch (PDOException $e) {
167 167
 			return "error : ".$e->getMessage();
168 168
 		}
169 169
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -178,16 +178,16 @@  discard block
 block discarded – undo
178 178
      * @param String $carrier IATA code
179 179
      * @return array departure and arrival airports and time
180 180
      */
181
-	public function getAirFrance($callsign, $date = 'NOW',$carrier = 'AF') {
181
+	public function getAirFrance($callsign, $date = 'NOW', $carrier = 'AF') {
182 182
 		$Common = new Common();
183 183
 		$check_date = new Datetime($date);
184
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
185
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
184
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
185
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
186 186
 		$url = "http://www.airfrance.fr/cgi-bin/AF/FR/fr/local/resainfovol/infovols/detailsVolJson.do?codeCompagnie[0]=".$carrier."&numeroVol[0]=".$numvol."&dayFlightDate=".$check_date->format('d')."&yearMonthFlightDate=".$check_date->format('Ym');
187 187
 		$json = $Common->getData($url);
188 188
 		var_dump($json);
189 189
 		$parsed_json = json_decode($json);
190
-		if (property_exists($parsed_json,'errors') === false) {
190
+		if (property_exists($parsed_json, 'errors') === false) {
191 191
 			//$originLong = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'originLong'};
192 192
 			$originShort = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'originShort'};
193 193
 			//$departureDateMedium = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'departureDateMedium'};
@@ -197,9 +197,9 @@  discard block
 block discarded – undo
197 197
 			//$arrivalDateMedium = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'arrivalDateMedium'};
198 198
 			$arrivalTime = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'arrivalTime'};
199 199
 
200
-			preg_match('/\((.*?)\)/',$originShort,$originiata);
200
+			preg_match('/\((.*?)\)/', $originShort, $originiata);
201 201
 			$DepartureAirportIata = $originiata[1];
202
-			preg_match('/\((.*?)\)/',$destinationShort,$destinationiata);
202
+			preg_match('/\((.*?)\)/', $destinationShort, $destinationiata);
203 203
 			$ArrivalAirportIata = $destinationiata[1];
204 204
 
205 205
 			/*
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 			$arrivalTime = gmdate('H:i',strtotime($arrivalTime));
209 209
 			*/
210 210
 		
211
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airfrance');
211
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_airfrance');
212 212
 		} else return array();
213 213
 	}
214 214
 
@@ -223,8 +223,8 @@  discard block
 block discarded – undo
223 223
 		$Common = new Common();
224 224
 		date_default_timezone_set($globalTimezone);
225 225
 		$check_date = new Datetime($date);
226
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
227
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
226
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
227
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
228 228
 		$url = "http://www.easyjet.com/ft/api/flights?date=".$check_date->format('Y-m-d')."&fn=".$callsign;
229 229
 		$json = $Common->getData($url);
230 230
 		$parsed_json = json_decode($json);
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 			$departureTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fstd'};
237 237
 			$arrivalTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fsta'};
238 238
 
239
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_easyjet');
239
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_easyjet');
240 240
 		} else return array();
241 241
 	}
242 242
 
@@ -247,12 +247,12 @@  discard block
 block discarded – undo
247 247
      */
248 248
 	private function getRyanair($callsign) {
249 249
 		$Common = new Common();
250
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
251
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
250
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
251
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
252 252
 		$url = "http://www.ryanair.com/fr/api/2/flight-info/0/50/";
253 253
 		$post = '{"flight":"'.$numvol.'","minDepartureTime":"00:00","maxDepartureTime":"23:59"}';
254
-		$headers = array('Content-Type: application/json','Content-Length: ' . strlen($post));
255
-		$json = $Common->getData($url,'post',$post,$headers);
254
+		$headers = array('Content-Type: application/json', 'Content-Length: '.strlen($post));
255
+		$json = $Common->getData($url, 'post', $post, $headers);
256 256
 		$parsed_json = json_decode($json);
257 257
 		if (isset($parsed_json->{'flightInfo'})) {
258 258
 			$flights = $parsed_json->{'flightInfo'};
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 				$ArrivalAirportIata = $parsed_json->{'flightInfo'}[0]->{'arrivalAirport'}->{'iata'}; //name
262 262
 				$departureTime = $parsed_json->{'flightInfo'}[0]->{'departureTime'};
263 263
 				$arrivalTime = $parsed_json->{'flightInfo'}[0]->{'arrivalTime'};
264
-				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair');
264
+				return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair');
265 265
 			} else return array();
266 266
 		} else return array();
267 267
 	}
@@ -273,8 +273,8 @@  discard block
 block discarded – undo
273 273
 	*/
274 274
 	private function getSwiss($callsign) {
275 275
 		$Common = new Common();
276
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
277
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
276
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
277
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
278 278
 		$url = "http://www.world-of-swiss.com/fr/routenetwork.json";
279 279
 		$json = $Common->getData($url);
280 280
 		$parsed_json = json_decode($json);
@@ -288,12 +288,12 @@  discard block
 block discarded – undo
288 288
 				if ($flight->{'no'} == "Vol LX ".$numvol) {
289 289
 					$DepartureAirportIata = $flight->{'from'}->{'code'}; //city
290 290
 					$ArrivalAirportIata = $flight->{'to'}->{'code'}; //city
291
-					$departureTime = substr($flight->{'from'}->{'hour'},0,5);
292
-					$arrivalTime = substr($flight->{'to'}->{'hour'},0,5);
291
+					$departureTime = substr($flight->{'from'}->{'hour'},0, 5);
292
+					$arrivalTime = substr($flight->{'to'}->{'hour'},0, 5);
293 293
 				}
294 294
 			}
295 295
 			if (isset($DepartureAirportIata) && isset($ArrivalAirportIata)) {
296
-				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_swiss');
296
+				return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_swiss');
297 297
 			} else return array();
298 298
 		} else return array();
299 299
 	}
@@ -308,21 +308,21 @@  discard block
 block discarded – undo
308 308
 		global $globalBritishAirwaysKey;
309 309
 		$Common = new Common();
310 310
 		$check_date = new Datetime($date);
311
-		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
312
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
311
+		$numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign));
312
+		if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array();
313 313
 		if ($globalBritishAirwaysKey == '') return array();
314 314
 		$url = "https://api.ba.com/rest-v1/v1/flights;flightNumber=".$numvol.";scheduledDepartureDate=".$check_date->format('Y-m-d').".json";
315 315
 		$headers = array('Client-Key: '.$globalBritishAirwaysKey);
316
-		$json = $Common->getData($url,'get','',$headers);
316
+		$json = $Common->getData($url, 'get', '', $headers);
317 317
 		if ($json == '') return array();
318 318
 		$parsed_json = json_decode($json);
319 319
 		$flights = $parsed_json->{'FlightsResponse'};
320 320
 		if (count($flights) > 0) {
321 321
 			$DepartureAirportIata = $parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'DepartureAirport'};
322 322
 			$ArrivalAirportIata = $parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ArrivalAirport'};
323
-			$departureTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'}));
324
-			$arrivalTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'}));
325
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_britishairways');
323
+			$departureTime = date('H:i', strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'}));
324
+			$arrivalTime = date('H:i', strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'}));
325
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_britishairways');
326 326
 		} else return array();
327 327
 	}
328 328
 
@@ -336,27 +336,27 @@  discard block
 block discarded – undo
336 336
 		global $globalLufthansaKey;
337 337
 		$Common = new Common();
338 338
 		$check_date = new Datetime($date);
339
-		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
340
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
339
+		$numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign));
340
+		if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array();
341 341
 		if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') return array();
342 342
 		$url = "https://api.lufthansa.com/v1/oauth/token";
343
-		$post = array('client_id' => $globalLufthansaKey['key'],'client_secret' => $globalLufthansaKey['secret'],'grant_type' => 'client_credentials');
344
-		$data = $Common->getData($url,'post',$post);
343
+		$post = array('client_id' => $globalLufthansaKey['key'], 'client_secret' => $globalLufthansaKey['secret'], 'grant_type' => 'client_credentials');
344
+		$data = $Common->getData($url, 'post', $post);
345 345
 		$parsed_data = json_decode($data);
346 346
 		if (!isset($parsed_data->{'access_token'})) return array();
347 347
 		$token = $parsed_data->{'access_token'};
348 348
 		
349 349
 		$url = "https://api.lufthansa.com/v1/operations/flightstatus/LH".$numvol."/".$check_date->format('Y-m-d');
350
-		$headers = array('Authorization: Bearer '.$token,'Accept: application/json');
351
-		$json = $Common->getData($url,'get','',$headers);
350
+		$headers = array('Authorization: Bearer '.$token, 'Accept: application/json');
351
+		$json = $Common->getData($url, 'get', '', $headers);
352 352
 		if ($json == '') return array();
353 353
 		$parsed_json = json_decode($json);
354 354
 		if (isset($parsed_json->{'FlightStatusResource'}) && count($parsed_json->{'FlightStatusResource'}) > 0) {
355 355
 			$DepartureAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'AirportCode'};
356
-			$departureTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'ScheduledTimeLocal'}->{'DateTime'}));
356
+			$departureTime = date('H:i', strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'ScheduledTimeLocal'}->{'DateTime'}));
357 357
 			$ArrivalAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'AirportCode'};
358
-			$arrivalTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'}));
359
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_lufthansa');
358
+			$arrivalTime = date('H:i', strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'}));
359
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_lufthansa');
360 360
 		} else return array();
361 361
 	}
362 362
 
@@ -370,23 +370,23 @@  discard block
 block discarded – undo
370 370
 		global $globalTransaviaKey;
371 371
 		$Common = new Common();
372 372
 		$check_date = new Datetime($date);
373
-		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
374
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
373
+		$numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign));
374
+		if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array();
375 375
 		if ($globalTransaviaKey == '') return array();
376 376
 		$url = "https://tst.api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol;
377 377
 		//$url = "https://api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol;
378 378
 		$headers = array('apikey: '.$globalTransaviaKey);
379
-		$json = $Common->getData($url,'get','',$headers);
379
+		$json = $Common->getData($url, 'get', '', $headers);
380 380
 		//echo 'result : '.$json;
381 381
 		if ($json == '') return array();
382 382
 		$parsed_json = json_decode($json);
383 383
 		
384 384
 		if (isset($parsed_json->{'data'}[0])) {
385 385
 			$DepartureAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'departureAirport'}->{'locationCode'};
386
-			$departureTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'departureDateTime'}));
386
+			$departureTime = date('H:i', strtotime($parsed_json->{'data'}[0]->{'flight'}->{'departureDateTime'}));
387 387
 			$ArrivalAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'arrivalAirport'}->{'locationCode'};
388
-			$arrivalTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'}));
389
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_transavia');
388
+			$arrivalTime = date('H:i', strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'}));
389
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_transavia');
390 390
 		} else return array();
391 391
 	}
392 392
 
@@ -397,14 +397,14 @@  discard block
 block discarded – undo
397 397
 	*/
398 398
 	public function getTunisair($callsign) {
399 399
 		$Common = new Common();
400
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
401
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
400
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
401
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
402 402
 		$url = "http://www.tunisair.com/site/publish/module/Volj/fr/Flight_List.asp";
403 403
 		$data = $Common->getData($url);
404 404
 		$table = $Common->table2array($data);
405 405
 		foreach ($table as $flight) {
406
-			if (isset($flight[1]) && $flight[1] == "TU ".sprintf('%04d',$numvol)) {
407
-				return array('DepartureAirportIATA' => $flight[2],'DepartureTime' => str_replace('.',':',$flight[5]),'ArrivalAirportIATA' => $flight[3],'ArrivalTime' => str_replace('.',':',$flight[6]),'Source' => 'website_tunisair');
406
+			if (isset($flight[1]) && $flight[1] == "TU ".sprintf('%04d', $numvol)) {
407
+				return array('DepartureAirportIATA' => $flight[2], 'DepartureTime' => str_replace('.', ':', $flight[5]), 'ArrivalAirportIATA' => $flight[3], 'ArrivalTime' => str_replace('.', ':', $flight[6]), 'Source' => 'website_tunisair');
408 408
 			}
409 409
 		}
410 410
 		return array();
@@ -416,21 +416,21 @@  discard block
 block discarded – undo
416 416
      * @param string $date
417 417
      * @return array Flight departure and arrival airports and time
418 418
      */
419
-	public function getVueling($callsign,$date = 'NOW') {
419
+	public function getVueling($callsign, $date = 'NOW') {
420 420
 		$Common = new Common();
421 421
 		$check_date = new Datetime($date);
422
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
423
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
424
-		$final_date = str_replace('/','%2F',$check_date->format('d/m/Y'));
422
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
423
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
424
+		$final_date = str_replace('/', '%2F', $check_date->format('d/m/Y'));
425 425
 		$url = "http://www.vueling.com/Base/BaseProxy/RenderMacro/?macroalias=FlightStatusResult&searchBy=bycode&date=".$final_date."&flightNumber=".$numvol."&idioma=en-GB";
426 426
 		$data = $Common->getData($url);
427
-		$data=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$data));
427
+		$data = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $data));
428 428
 		if ($data != '') {
429
-			preg_match('/flightOri=[A-Z]{3}/',$data,$result);
430
-			$DepartureAirportIata = str_replace('flightOri=','',$result[0]);
431
-			preg_match('/flightDest=[A-Z]{3}/',$data,$result);
432
-			$ArrivalAirportIata = str_replace('flightDest=','',$result[0]);
433
-			if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling');
429
+			preg_match('/flightOri=[A-Z]{3}/', $data, $result);
430
+			$DepartureAirportIata = str_replace('flightOri=', '', $result[0]);
431
+			preg_match('/flightDest=[A-Z]{3}/', $data, $result);
432
+			$ArrivalAirportIata = str_replace('flightDest=', '', $result[0]);
433
+			if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') return array('DepartureAirportIATA' => $DepartureAirportIata, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'Source' => 'website_vueling');
434 434
 			else return array();
435 435
 		}
436 436
 		return array();
@@ -444,27 +444,27 @@  discard block
 block discarded – undo
444 444
 	*/
445 445
 	public function getIberia($callsign, $date = 'NOW') {
446 446
 		$Common = new Common();
447
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
447
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
448 448
 		$check_date = new Datetime($date);
449
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
449
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
450 450
 		$url = "https://www.iberia.com/web/flightDetail.do";
451
-		$post = array('numvuelo' => $numvol,'fecha' => $check_date->format('Ymd'),'airlineID' => 'IB');
452
-		$data = $Common->getData($url,'post',$post);
451
+		$post = array('numvuelo' => $numvol, 'fecha' => $check_date->format('Ymd'), 'airlineID' => 'IB');
452
+		$data = $Common->getData($url, 'post', $post);
453 453
 		if ($data != '') {
454 454
 			$table = $Common->table2array($data);
455 455
 			//print_r($table);
456 456
 			if (count($table) > 0) {
457 457
 				$flight = $table;
458
-				preg_match('/([A-Z]{3})/',$flight[3][0],$DepartureAirportIataMatch);
459
-				preg_match('/([A-Z]{3})/',$flight[5][0],$ArrivalAirportIataMatch);
458
+				preg_match('/([A-Z]{3})/', $flight[3][0], $DepartureAirportIataMatch);
459
+				preg_match('/([A-Z]{3})/', $flight[5][0], $ArrivalAirportIataMatch);
460 460
 				$DepartureAirportIata = $DepartureAirportIataMatch[0];
461 461
 				$ArrivalAirportIata = $ArrivalAirportIataMatch[0];
462
-				$departureTime = substr(trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[3][2]))),0,5);
463
-				$arrivalTime = trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[5][1])));
462
+				$departureTime = substr(trim(str_replace(' lunes', '', str_replace('&nbsp;', '', $flight[3][2]))), 0, 5);
463
+				$arrivalTime = trim(str_replace(' lunes', '', str_replace('&nbsp;', '', $flight[5][1])));
464 464
 				if ($arrivalTime == 'Hora estimada de llegada') {
465
-					$arrivalTime = substr(trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[5][2]))),0,5);
466
-				} else $arrivalTime = substr($arrivalTime,0,5);
467
-				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_iberia');
465
+					$arrivalTime = substr(trim(str_replace(' lunes', '', str_replace('&nbsp;', '', $flight[5][2]))), 0, 5);
466
+				} else $arrivalTime = substr($arrivalTime, 0, 5);
467
+				return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_iberia');
468 468
 			}
469 469
 		}
470 470
 		return array();
@@ -478,11 +478,11 @@  discard block
 block discarded – undo
478 478
      * @return array Flight departure and arrival airports and time
479 479
      */
480 480
 
481
-	private function getStarAlliance($callsign, $date = 'NOW',$carrier = '') {
481
+	private function getStarAlliance($callsign, $date = 'NOW', $carrier = '') {
482 482
 		$Common = new Common();
483
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
483
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
484 484
 		$check_date = new Datetime($date);
485
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
485
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
486 486
 		$url = "http://www.staralliance.com/flifoQueryAction.do?myAirline=&airlineCode=".$carrier."&flightNo=".$numvol."&day=".$check_date->format('d')."&month=".$check_date->format('m')."&year=".$check_date->format('Y')."&departuredate=".$check_date->format('d-M-Y');
487 487
 		$data = $Common->getData($url);
488 488
 		if ($data != '') {
@@ -491,13 +491,13 @@  discard block
 block discarded – undo
491 491
 				$flight = $table;
492 492
 				//print_r($table);
493 493
 				if (isset($flight[25]) && isset($flight[29])) {
494
-					preg_match('/([A-Z]{3})/',$flight[25][1],$DepartureAirportIataMatch);
495
-					preg_match('/([A-Z]{3})/',$flight[25][3],$ArrivalAirportIataMatch);
494
+					preg_match('/([A-Z]{3})/', $flight[25][1], $DepartureAirportIataMatch);
495
+					preg_match('/([A-Z]{3})/', $flight[25][3], $ArrivalAirportIataMatch);
496 496
 					$DepartureAirportIata = $DepartureAirportIataMatch[0];
497 497
 					$ArrivalAirportIata = $ArrivalAirportIataMatch[0];
498
-					$departureTime = substr(trim(str_replace('Scheduled: ','',$flight[29][0])),0,5);
499
-					$arrivalTime = substr(trim(str_replace('Scheduled: ','',$flight[29][1])),0,5);
500
-					return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_staralliance');
498
+					$departureTime = substr(trim(str_replace('Scheduled: ', '', $flight[29][0])), 0, 5);
499
+					$arrivalTime = substr(trim(str_replace('Scheduled: ', '', $flight[29][1])), 0, 5);
500
+					return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_staralliance');
501 501
 				} else return array();
502 502
 			}
503 503
 			
@@ -515,10 +515,10 @@  discard block
 block discarded – undo
515 515
 	*/
516 516
 	private function getAlitalia($callsign, $date = 'NOW') {
517 517
 		$Common = new Common();
518
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
518
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
519 519
 		$check_date = new Datetime($date);
520
-		$url= "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y');
521
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
520
+		$url = "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y');
521
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
522 522
 		$data = $Common->getData($url);
523 523
 		if ($data != '') {
524 524
 			$table = $Common->text2array($data);
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
 			$ArrivalAirportIata = '';
527 527
 			$departureTime = $table[4];
528 528
 			$arrivalTime = $table[5];
529
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_alitalia');
529
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_alitalia');
530 530
 		}
531 531
 		return array();
532 532
 	}
@@ -539,21 +539,21 @@  discard block
 block discarded – undo
539 539
 	*/
540 540
 	private function getBrussels($callsign, $date = 'NOW') {
541 541
 		$Common = new Common();
542
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
542
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
543 543
 		$check_date = new Datetime($date);
544
-		$url= "http://www.brusselsairlines.com/api/flightstatus/getresults?from=NA&to=NA&date=".$check_date->format('d/m/Y')."&hour=NA&lookup=flightnumber&flightnumber=".$numvol."&publicationID=302";
544
+		$url = "http://www.brusselsairlines.com/api/flightstatus/getresults?from=NA&to=NA&date=".$check_date->format('d/m/Y')."&hour=NA&lookup=flightnumber&flightnumber=".$numvol."&publicationID=302";
545 545
 		//http://www.brusselsairlines.com/fr-fr/informations-pratiques/statut-de-votre-vol/resultat.aspx?flightnumber=".$numvol."&date=".$check_date->format('d/m/Y')."&lookup=flightnumber";
546
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
546
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
547 547
 		$data = $Common->getData($url);
548 548
 		if ($data != '') {
549 549
 		    //echo $data;
550
-		    $parsed_json = json_decode($data,true);
550
+		    $parsed_json = json_decode($data, true);
551 551
 		    if (isset($parsed_json[0]['FromAirportCode'])) {
552 552
 			$DepartureAirportIata = $parsed_json[0]['FromAirportCode'];
553 553
 			$ArrivalAirportIata = $parsed_json[0]['ToAirportCode'];
554
-			$departureTime = date('H:i',strtotime($parsed_json[0]['ScheduledDepatureDate']));
555
-			$arrivalTime = date('H:i',strtotime($parsed_json[0]['ScheduledArrivalDate']));
556
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_brussels');
554
+			$departureTime = date('H:i', strtotime($parsed_json[0]['ScheduledDepatureDate']));
555
+			$arrivalTime = date('H:i', strtotime($parsed_json[0]['ScheduledArrivalDate']));
556
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_brussels');
557 557
 		    }
558 558
 		}
559 559
 		return array();
@@ -631,21 +631,21 @@  discard block
 block discarded – undo
631 631
 	*/
632 632
 	private function getFlyTap($callsign) {
633 633
 		$Common = new Common();
634
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
635
-		$url= "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees";
634
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
635
+		$url = "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees";
636 636
 		//$check_date = new Datetime($date);
637
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
638
-		$post = array('arrivalsdepartures_content' => 'number','arrivalsdepartures_tp' => $numvol,'arrivalsdepartures_trk' => 'ARR','arrivalsdepartures_date_trk' => '1','aptCode' => '','arrivalsdepartures' => 'DEP','arrivalsdepartures_date' => '1','aptCodeFrom' => '','aptCodeTo' => '','arrivalsdepartures2' => 'DEP','arrivalsdepartures_date2' => '1');
639
-		$data = $Common->getData($url,'post',$post);
637
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
638
+		$post = array('arrivalsdepartures_content' => 'number', 'arrivalsdepartures_tp' => $numvol, 'arrivalsdepartures_trk' => 'ARR', 'arrivalsdepartures_date_trk' => '1', 'aptCode' => '', 'arrivalsdepartures' => 'DEP', 'arrivalsdepartures_date' => '1', 'aptCodeFrom' => '', 'aptCodeTo' => '', 'arrivalsdepartures2' => 'DEP', 'arrivalsdepartures_date2' => '1');
639
+		$data = $Common->getData($url, 'post', $post);
640 640
 		if ($data != '') {
641 641
 			$table = $Common->table2array($data);
642
-			$departureTime = trim(substr($table[15][0],0,5));
643
-			$arrivalTime = trim(substr($table[35][0],0,5));
644
-			preg_match('/([A-Z]{3})/',$table[11][0],$DepartureAirportIataMatch);
645
-			preg_match('/([A-Z]{3})/',$table[31][0],$ArrivalAirportIataMatch);
642
+			$departureTime = trim(substr($table[15][0], 0, 5));
643
+			$arrivalTime = trim(substr($table[35][0], 0, 5));
644
+			preg_match('/([A-Z]{3})/', $table[11][0], $DepartureAirportIataMatch);
645
+			preg_match('/([A-Z]{3})/', $table[31][0], $ArrivalAirportIataMatch);
646 646
 			$DepartureAirportIata = $DepartureAirportIataMatch[0];
647 647
 			$ArrivalAirportIata = $ArrivalAirportIataMatch[0];
648
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flytap');
648
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_flytap');
649 649
 		}
650 650
 		return array();
651 651
 	}
@@ -667,10 +667,10 @@  discard block
 block discarded – undo
667 667
 			} 
668 668
 		}
669 669
 		if ($airline_icao == '') return array();
670
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
671
-		$url= "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol;
670
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
671
+		$url = "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol;
672 672
 		//$check_date = new Datetime($date);
673
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
673
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
674 674
 		$data = $Common->getData($url);
675 675
 		if ($data != '') {
676 676
 			$table = $Common->table2array($data);
@@ -680,13 +680,13 @@  discard block
 block discarded – undo
680 680
 				$darr = '';
681 681
 				$ahour = '';
682 682
 				$aarr = '';
683
-				$n = sscanf($sched,'%*s %5[0-9:] %*[^()] (%3[A-Z]) %5[0-9:] %*[^()] (%3[A-Z])',$dhour,$darr,$ahour,$aarr);
683
+				$n = sscanf($sched, '%*s %5[0-9:] %*[^()] (%3[A-Z]) %5[0-9:] %*[^()] (%3[A-Z])', $dhour, $darr, $ahour, $aarr);
684 684
 				if ($n == 7) {
685 685
 				    $departureTime = $dhour;
686 686
 				    $arrivalTime = $ahour;
687
-				    $DepartureAirportIata = str_replace(array('(',')'),'',$darr);
688
-				    $ArrivalAirportIata = str_replace(array('(',')'),'',$aarr);
689
-				    return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightmapper');
687
+				    $DepartureAirportIata = str_replace(array('(', ')'), '', $darr);
688
+				    $ArrivalAirportIata = str_replace(array('(', ')'), '', $aarr);
689
+				    return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_flightmapper');
690 690
 				}
691 691
 			}
692 692
 		}
@@ -718,7 +718,7 @@  discard block
 block discarded – undo
718 718
 			$url = 'http://'.$globalFlightAwareUsername.':'.$globalFlightAwarePassword.'@flightxml.flightaware.com/json/FlightXML3/FlightInfoStatus?ident='.$callsign;
719 719
 			$data = $Common->getData($url);
720 720
 			if ($data != '') {
721
-				$result = json_decode($data,true);
721
+				$result = json_decode($data, true);
722 722
 				$flight = $result['FlightInfoStatusResult']['flights'][0];
723 723
 				if (isset($flight['origin'])) {
724 724
 					return array(
@@ -731,18 +731,18 @@  discard block
 block discarded – undo
731 731
 			}
732 732
 		}
733 733
 		
734
-		$url= "http://flightaware.com/live/flight/".$callsign;
734
+		$url = "http://flightaware.com/live/flight/".$callsign;
735 735
 		$data = $Common->getData($url);
736 736
 		if ($data != '') {
737
-			preg_match(':<script>var trackpollBootstrap = (.*?);</script>:',$data,$result);
738
-			$flights = json_decode($result[1],true);
737
+			preg_match(':<script>var trackpollBootstrap = (.*?);</script>:', $data, $result);
738
+			$flights = json_decode($result[1], true);
739 739
 			$flight = reset($flights['flights']);
740 740
 			if (isset($flight['activityLog']['flights'][0]['origin'])) {
741 741
 				return array(
742 742
 				    'DepartureAirportIATA' => $flight['activityLog']['flights'][0]['origin']['iata'],
743
-				    'DepartureTime' => date('H:i',$flight['activityLog']['flights'][0]['takeoffTimes']['scheduled']),
743
+				    'DepartureTime' => date('H:i', $flight['activityLog']['flights'][0]['takeoffTimes']['scheduled']),
744 744
 				    'ArrivalAirportIATA' => $flight['activityLog']['flights'][0]['destination']['iata'],
745
-				    'ArrivalTime' => date('H:i',$flight['activityLog']['flights'][0]['landingTimes']['scheduled']),
745
+				    'ArrivalTime' => date('H:i', $flight['activityLog']['flights'][0]['landingTimes']['scheduled']),
746 746
 				    'Source' => 'website_flightaware');
747 747
 			}
748 748
 		}
@@ -756,20 +756,20 @@  discard block
 block discarded – undo
756 756
 	*/
757 757
 	public function getCostToTravel($callsign) {
758 758
 		$Common = new Common();
759
-		$url= "http://www.costtotravel.com/flight-number/".$callsign;
759
+		$url = "http://www.costtotravel.com/flight-number/".$callsign;
760 760
 		//$check_date = new Datetime($date);
761 761
 		//if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
762 762
 		$data = $Common->getData($url);
763 763
 		if ($data != '') {
764 764
 			$table = $Common->table2array($data);
765 765
 			if (isset($table[11][1])) {
766
-				if (is_numeric(substr($table[11][1],0,1))) $departureTime = substr($table[11][1],0,5);
766
+				if (is_numeric(substr($table[11][1], 0, 1))) $departureTime = substr($table[11][1], 0, 5);
767 767
 				else $departureTime = '';
768
-				if (is_numeric(substr($table[17][1],0,1))) $arrivalTime = substr($table[17][1],0,5);
768
+				if (is_numeric(substr($table[17][1], 0, 1))) $arrivalTime = substr($table[17][1], 0, 5);
769 769
 				else $arrivalTime = '';
770
-				$DepartureAirportIata = substr($table[13][1],0,3);
771
-				$ArrivalAirportIata = substr($table[15][1],0,3);
772
-				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_costtotravel');
770
+				$DepartureAirportIata = substr($table[13][1], 0, 3);
771
+				$ArrivalAirportIata = substr($table[15][1], 0, 3);
772
+				return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_costtotravel');
773 773
 			}
774 774
 		}
775 775
 		return array();
@@ -781,14 +781,14 @@  discard block
 block discarded – undo
781 781
 	* @param string $date date we want flight number info
782 782
 	* @return array Flight departure and arrival airports and time
783 783
 	*/
784
-	private function getAirCanada($callsign,$date = 'NOW') {
784
+	private function getAirCanada($callsign, $date = 'NOW') {
785 785
 		$Common = new Common();
786 786
 		if (class_exists("DomDocument") === FALSE) return array();
787 787
 		date_default_timezone_set('UTC');
788 788
 		$check_date = new Datetime($date);
789
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
790
-		$url= "http://services.aircanada.com/portal/rest/getFlightsByFlightNumber?forceTimetable=true&flightNumber=".$numvol."&carrierCode=AC&date=".$check_date->format('m-d-Y')."&app_key=AE919FDCC80311DF9BABC975DFD72085&cache=74249";
791
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
789
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
790
+		$url = "http://services.aircanada.com/portal/rest/getFlightsByFlightNumber?forceTimetable=true&flightNumber=".$numvol."&carrierCode=AC&date=".$check_date->format('m-d-Y')."&app_key=AE919FDCC80311DF9BABC975DFD72085&cache=74249";
791
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
792 792
 		$data = $Common->getData($url);
793 793
 		$dom = new DomDocument();
794 794
 		$dom->loadXML($data);
@@ -796,11 +796,11 @@  discard block
 block discarded – undo
796 796
 		$departure = $dom->getElementsByTagName('DepartureStationInfo')->item(0);
797 797
 		if (isset($departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue)) {
798 798
 			$DepartureAirportIata = $departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue;
799
-			$departureTime = date('H:i',strtotime($departure->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
799
+			$departureTime = date('H:i', strtotime($departure->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
800 800
 			$arrival = $dom->getElementsByTagName('ArrivalStationInfo')->item(0);
801 801
 			$ArrivalAirportIata = $arrival->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue;
802
-			$arrivalTime = date('H:i',strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
803
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_aircanada');
802
+			$arrivalTime = date('H:i', strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
803
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_aircanada');
804 804
 		} else return array();
805 805
 	}
806 806
 
@@ -812,21 +812,21 @@  discard block
 block discarded – undo
812 812
 	*/
813 813
 	private function getVietnamAirlines($callsign, $date = 'NOW') {
814 814
 		$Common = new Common();
815
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
815
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
816 816
 		$check_date = new Datetime($date);
817
-		$url= "https://cat.sabresonicweb.com/SSWVN/meridia?posid=VNVN&page=flifoFlightInfoDetailsMessage_learn&action=flightInfoDetails&airline=VN&language=fr&depDay=".$check_date->format('j')."&depMonth=".strtoupper($check_date->format('M'))."&=&flight=".$numvol."&";
818
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
817
+		$url = "https://cat.sabresonicweb.com/SSWVN/meridia?posid=VNVN&page=flifoFlightInfoDetailsMessage_learn&action=flightInfoDetails&airline=VN&language=fr&depDay=".$check_date->format('j')."&depMonth=".strtoupper($check_date->format('M'))."&=&flight=".$numvol."&";
818
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
819 819
 		$data = $Common->getData($url);
820 820
 		if ($data != '') {
821 821
 			$table = $Common->table2array($data);
822 822
 			$flight = $table;
823
-			preg_match('/([A-Z]{3})/',$flight[3][0],$DepartureAirportIataMatch);
824
-			preg_match('/([A-Z]{3})/',$flight[21][0],$ArrivalAirportIataMatch);
823
+			preg_match('/([A-Z]{3})/', $flight[3][0], $DepartureAirportIataMatch);
824
+			preg_match('/([A-Z]{3})/', $flight[21][0], $ArrivalAirportIataMatch);
825 825
 			$DepartureAirportIata = $DepartureAirportIataMatch[0];
826 826
 			$ArrivalAirportIata = $ArrivalAirportIataMatch[0];
827 827
 			$departureTime = $flight[5][1];
828 828
 			$arrivalTime = $flight[23][1];
829
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_vietnamairlines');
829
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_vietnamairlines');
830 830
 		}
831 831
 		return array();
832 832
 	}
@@ -838,16 +838,16 @@  discard block
 block discarded – undo
838 838
 	* @param String $carrier airline code
839 839
 	* @return array Flight departure and arrival airports and time
840 840
 	*/
841
-	private function getAirBerlin($callsign, $date = 'NOW',$carrier = 'AB') {
841
+	private function getAirBerlin($callsign, $date = 'NOW', $carrier = 'AB') {
842 842
 		$Common = new Common();
843 843
 		date_default_timezone_set('UTC');
844 844
 		//AB = airberlin, HG/NLY = NIKI, 4T/BHP = Belair 
845
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
845
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
846 846
 		$check_date = new Datetime($date);
847
-		$url= "http://www.airberlin.com/en-US/site/aims.php";
848
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
849
-		$post = array('type' => 'departure','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => $carrier);
850
-		$data = $Common->getData($url,'post',$post);
847
+		$url = "http://www.airberlin.com/en-US/site/aims.php";
848
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
849
+		$post = array('type' => 'departure', 'searchFlightNo' => '1', 'requestsent' => 'true', 'flightno' => $numvol, 'date' => $check_date->format('Y-m-d'), 'carrier' => $carrier);
850
+		$data = $Common->getData($url, 'post', $post);
851 851
 		//echo $data;
852 852
 		$DepartureAirportIata = '';
853 853
 		$ArrivalAirportIata = '';
@@ -860,8 +860,8 @@  discard block
 block discarded – undo
860 860
 			if (isset($flight[5][2])) $departureAirport = $flight[5][2];
861 861
 			else $departureAirport = '';
862 862
 		} else return array();
863
-		$post = array('type' => 'arrival','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => 'AB');
864
-		$data = $Common->getData($url,'post',$post);
863
+		$post = array('type' => 'arrival', 'searchFlightNo' => '1', 'requestsent' => 'true', 'flightno' => $numvol, 'date' => $check_date->format('Y-m-d'), 'carrier' => 'AB');
864
+		$data = $Common->getData($url, 'post', $post);
865 865
 		if ($data != '') {
866 866
 			$table = $Common->table2array($data);
867 867
 			$flight = $table;
@@ -889,7 +889,7 @@  discard block
 block discarded – undo
889 889
 			}
890 890
 		}
891 891
 		if (isset($DepartureAirportIata)) {
892
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airberlin');
892
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_airberlin');
893 893
 		} else return array();
894 894
 	}
895 895
 
@@ -899,7 +899,7 @@  discard block
 block discarded – undo
899 899
 	 * @param String $date Date
900 900
 	 * @return array Schedules info
901 901
 	*/
902
-	public function fetchSchedule($ident,$date = 'NOW') {
902
+	public function fetchSchedule($ident, $date = 'NOW') {
903 903
 		global $globalSchedulesSources, $globalSchedulesFetch, $globalOffline, $globalFlightAwareUsername;
904 904
 		//$Common = new Common();
905 905
 		if ($globalSchedulesFetch === FALSE || (isset($globalOffline) && $globalOffline === TRUE)) return array();
@@ -969,7 +969,7 @@  discard block
 block discarded – undo
969 969
 				// Brussels Airlines
970 970
 				case "BEL":
971 971
 				case "SN":
972
-					return $this->getBrussels($ident,$date);
972
+					return $this->getBrussels($ident, $date);
973 973
 /*
974 974
 				// Copa Airlines
975 975
 				case "CMP":
@@ -1068,7 +1068,7 @@  discard block
 block discarded – undo
1068 1068
 				case "DS":
1069 1069
 				case "EZY":
1070 1070
 				case "EZS":
1071
-					return $this->getEasyJet($ident,$date);
1071
+					return $this->getEasyJet($ident, $date);
1072 1072
 				// Ryanair
1073 1073
 				case "FR":
1074 1074
 				case "RYR":
@@ -1120,19 +1120,19 @@  discard block
 block discarded – undo
1120 1120
 					return $this->getIberia($ident);
1121 1121
 				// Vietnam Airlines
1122 1122
 				case "HVN":
1123
-					return $this->getVietnamAirlines($ident,$date);
1123
+					return $this->getVietnamAirlines($ident, $date);
1124 1124
 				// Air Berlin
1125 1125
 				case "AB":
1126 1126
 				case "BER":
1127
-					return $this->getAirBerlin($ident,$date,'AB');
1127
+					return $this->getAirBerlin($ident, $date, 'AB');
1128 1128
 				// NIKI
1129 1129
 				case "HG":
1130 1130
 				case "NLY":
1131
-					return $this->getAirBerlin($ident,$date,'HG');
1131
+					return $this->getAirBerlin($ident, $date, 'HG');
1132 1132
 				// BelAir
1133 1133
 				case "4T":
1134 1134
 				case "BHP":
1135
-					return $this->getAirBerlin($ident,$date,'4T');
1135
+					return $this->getAirBerlin($ident, $date, '4T');
1136 1136
 				default:
1137 1137
 					if (strlen($airline_icao) == 3) {
1138 1138
 						$Spotter = new Spotter($this->db);
@@ -1141,9 +1141,9 @@  discard block
 block discarded – undo
1141 1141
 					}
1142 1142
 					// Randomly use a generic function to get hours
1143 1143
 					if (strlen($airline_icao) == 2) {
1144
-						if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper','costtotravel','flightaware');
1144
+						if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper', 'costtotravel', 'flightaware');
1145 1145
 						if (count($globalSchedulesSources) > 0) {
1146
-							$rand = mt_rand(0,count($globalSchedulesSources)-1);
1146
+							$rand = mt_rand(0, count($globalSchedulesSources) - 1);
1147 1147
 							$source = $globalSchedulesSources[$rand];
1148 1148
 							if ($source == 'flightmapper') return $this->getFlightMapper($ident);
1149 1149
 							elseif ($source == 'costtotravel') return $this->getCostToTravel($ident);
Please login to merge, or discard this patch.
Braces   +180 added lines, -62 removed lines patch added patch discarded remove patch
@@ -24,7 +24,9 @@  discard block
 block discarded – undo
24 24
 	public function __construct($dbc = null) {
25 25
 		$Connection = new Connection($dbc);
26 26
 		$this->db = $Connection->db();
27
-		if ($this->db === null) die('Error: No DB connection.');
27
+		if ($this->db === null) {
28
+			die('Error: No DB connection.');
29
+		}
28 30
 	}
29 31
 
30 32
     /**
@@ -141,7 +143,9 @@  discard block
 block discarded – undo
141 143
 		$sth->closeCursor();
142 144
 		if (is_array($row) && count($row) > 0) {
143 145
 			return $row;
144
-		} else return array();
146
+		} else {
147
+			return array();
148
+		}
145 149
 	}
146 150
 
147 151
 	/*
@@ -182,7 +186,9 @@  discard block
 block discarded – undo
182 186
 		$Common = new Common();
183 187
 		$check_date = new Datetime($date);
184 188
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
185
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
189
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
190
+			return array();
191
+		}
186 192
 		$url = "http://www.airfrance.fr/cgi-bin/AF/FR/fr/local/resainfovol/infovols/detailsVolJson.do?codeCompagnie[0]=".$carrier."&numeroVol[0]=".$numvol."&dayFlightDate=".$check_date->format('d')."&yearMonthFlightDate=".$check_date->format('Ym');
187 193
 		$json = $Common->getData($url);
188 194
 		var_dump($json);
@@ -209,7 +215,9 @@  discard block
 block discarded – undo
209 215
 			*/
210 216
 		
211 217
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airfrance');
212
-		} else return array();
218
+		} else {
219
+			return array();
220
+		}
213 221
 	}
214 222
 
215 223
     /**
@@ -224,7 +232,9 @@  discard block
 block discarded – undo
224 232
 		date_default_timezone_set($globalTimezone);
225 233
 		$check_date = new Datetime($date);
226 234
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
227
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
235
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
236
+			return array();
237
+		}
228 238
 		$url = "http://www.easyjet.com/ft/api/flights?date=".$check_date->format('Y-m-d')."&fn=".$callsign;
229 239
 		$json = $Common->getData($url);
230 240
 		$parsed_json = json_decode($json);
@@ -237,7 +247,9 @@  discard block
 block discarded – undo
237 247
 			$arrivalTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fsta'};
238 248
 
239 249
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_easyjet');
240
-		} else return array();
250
+		} else {
251
+			return array();
252
+		}
241 253
 	}
242 254
 
243 255
     /**
@@ -248,7 +260,9 @@  discard block
 block discarded – undo
248 260
 	private function getRyanair($callsign) {
249 261
 		$Common = new Common();
250 262
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
251
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
263
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
264
+			return array();
265
+		}
252 266
 		$url = "http://www.ryanair.com/fr/api/2/flight-info/0/50/";
253 267
 		$post = '{"flight":"'.$numvol.'","minDepartureTime":"00:00","maxDepartureTime":"23:59"}';
254 268
 		$headers = array('Content-Type: application/json','Content-Length: ' . strlen($post));
@@ -262,8 +276,12 @@  discard block
 block discarded – undo
262 276
 				$departureTime = $parsed_json->{'flightInfo'}[0]->{'departureTime'};
263 277
 				$arrivalTime = $parsed_json->{'flightInfo'}[0]->{'arrivalTime'};
264 278
 				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair');
265
-			} else return array();
266
-		} else return array();
279
+			} else {
280
+				return array();
281
+			}
282
+		} else {
283
+			return array();
284
+		}
267 285
 	}
268 286
 
269 287
 	/**
@@ -274,7 +292,9 @@  discard block
 block discarded – undo
274 292
 	private function getSwiss($callsign) {
275 293
 		$Common = new Common();
276 294
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
277
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
295
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
296
+			return array();
297
+		}
278 298
 		$url = "http://www.world-of-swiss.com/fr/routenetwork.json";
279 299
 		$json = $Common->getData($url);
280 300
 		$parsed_json = json_decode($json);
@@ -294,8 +314,12 @@  discard block
 block discarded – undo
294 314
 			}
295 315
 			if (isset($DepartureAirportIata) && isset($ArrivalAirportIata)) {
296 316
 				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_swiss');
297
-			} else return array();
298
-		} else return array();
317
+			} else {
318
+				return array();
319
+			}
320
+		} else {
321
+			return array();
322
+		}
299 323
 	}
300 324
 	
301 325
 	/**
@@ -309,12 +333,18 @@  discard block
 block discarded – undo
309 333
 		$Common = new Common();
310 334
 		$check_date = new Datetime($date);
311 335
 		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
312
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
313
-		if ($globalBritishAirwaysKey == '') return array();
336
+		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) {
337
+			return array();
338
+		}
339
+		if ($globalBritishAirwaysKey == '') {
340
+			return array();
341
+		}
314 342
 		$url = "https://api.ba.com/rest-v1/v1/flights;flightNumber=".$numvol.";scheduledDepartureDate=".$check_date->format('Y-m-d').".json";
315 343
 		$headers = array('Client-Key: '.$globalBritishAirwaysKey);
316 344
 		$json = $Common->getData($url,'get','',$headers);
317
-		if ($json == '') return array();
345
+		if ($json == '') {
346
+			return array();
347
+		}
318 348
 		$parsed_json = json_decode($json);
319 349
 		$flights = $parsed_json->{'FlightsResponse'};
320 350
 		if (count($flights) > 0) {
@@ -323,7 +353,9 @@  discard block
 block discarded – undo
323 353
 			$departureTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'}));
324 354
 			$arrivalTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'}));
325 355
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_britishairways');
326
-		} else return array();
356
+		} else {
357
+			return array();
358
+		}
327 359
 	}
328 360
 
329 361
 	/**
@@ -337,19 +369,27 @@  discard block
 block discarded – undo
337 369
 		$Common = new Common();
338 370
 		$check_date = new Datetime($date);
339 371
 		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
340
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
341
-		if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') return array();
372
+		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) {
373
+			return array();
374
+		}
375
+		if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') {
376
+			return array();
377
+		}
342 378
 		$url = "https://api.lufthansa.com/v1/oauth/token";
343 379
 		$post = array('client_id' => $globalLufthansaKey['key'],'client_secret' => $globalLufthansaKey['secret'],'grant_type' => 'client_credentials');
344 380
 		$data = $Common->getData($url,'post',$post);
345 381
 		$parsed_data = json_decode($data);
346
-		if (!isset($parsed_data->{'access_token'})) return array();
382
+		if (!isset($parsed_data->{'access_token'})) {
383
+			return array();
384
+		}
347 385
 		$token = $parsed_data->{'access_token'};
348 386
 		
349 387
 		$url = "https://api.lufthansa.com/v1/operations/flightstatus/LH".$numvol."/".$check_date->format('Y-m-d');
350 388
 		$headers = array('Authorization: Bearer '.$token,'Accept: application/json');
351 389
 		$json = $Common->getData($url,'get','',$headers);
352
-		if ($json == '') return array();
390
+		if ($json == '') {
391
+			return array();
392
+		}
353 393
 		$parsed_json = json_decode($json);
354 394
 		if (isset($parsed_json->{'FlightStatusResource'}) && count($parsed_json->{'FlightStatusResource'}) > 0) {
355 395
 			$DepartureAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'AirportCode'};
@@ -357,7 +397,9 @@  discard block
 block discarded – undo
357 397
 			$ArrivalAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'AirportCode'};
358 398
 			$arrivalTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'}));
359 399
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_lufthansa');
360
-		} else return array();
400
+		} else {
401
+			return array();
402
+		}
361 403
 	}
362 404
 
363 405
 	/**
@@ -371,14 +413,20 @@  discard block
 block discarded – undo
371 413
 		$Common = new Common();
372 414
 		$check_date = new Datetime($date);
373 415
 		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
374
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
375
-		if ($globalTransaviaKey == '') return array();
416
+		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) {
417
+			return array();
418
+		}
419
+		if ($globalTransaviaKey == '') {
420
+			return array();
421
+		}
376 422
 		$url = "https://tst.api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol;
377 423
 		//$url = "https://api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol;
378 424
 		$headers = array('apikey: '.$globalTransaviaKey);
379 425
 		$json = $Common->getData($url,'get','',$headers);
380 426
 		//echo 'result : '.$json;
381
-		if ($json == '') return array();
427
+		if ($json == '') {
428
+			return array();
429
+		}
382 430
 		$parsed_json = json_decode($json);
383 431
 		
384 432
 		if (isset($parsed_json->{'data'}[0])) {
@@ -387,7 +435,9 @@  discard block
 block discarded – undo
387 435
 			$ArrivalAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'arrivalAirport'}->{'locationCode'};
388 436
 			$arrivalTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'}));
389 437
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_transavia');
390
-		} else return array();
438
+		} else {
439
+			return array();
440
+		}
391 441
 	}
392 442
 
393 443
 	/**
@@ -398,7 +448,9 @@  discard block
 block discarded – undo
398 448
 	public function getTunisair($callsign) {
399 449
 		$Common = new Common();
400 450
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
401
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
451
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
452
+			return array();
453
+		}
402 454
 		$url = "http://www.tunisair.com/site/publish/module/Volj/fr/Flight_List.asp";
403 455
 		$data = $Common->getData($url);
404 456
 		$table = $Common->table2array($data);
@@ -420,7 +472,9 @@  discard block
 block discarded – undo
420 472
 		$Common = new Common();
421 473
 		$check_date = new Datetime($date);
422 474
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
423
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
475
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
476
+			return array();
477
+		}
424 478
 		$final_date = str_replace('/','%2F',$check_date->format('d/m/Y'));
425 479
 		$url = "http://www.vueling.com/Base/BaseProxy/RenderMacro/?macroalias=FlightStatusResult&searchBy=bycode&date=".$final_date."&flightNumber=".$numvol."&idioma=en-GB";
426 480
 		$data = $Common->getData($url);
@@ -430,8 +484,11 @@  discard block
 block discarded – undo
430 484
 			$DepartureAirportIata = str_replace('flightOri=','',$result[0]);
431 485
 			preg_match('/flightDest=[A-Z]{3}/',$data,$result);
432 486
 			$ArrivalAirportIata = str_replace('flightDest=','',$result[0]);
433
-			if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling');
434
-			else return array();
487
+			if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') {
488
+				return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling');
489
+			} else {
490
+				return array();
491
+			}
435 492
 		}
436 493
 		return array();
437 494
 	}
@@ -446,7 +503,9 @@  discard block
 block discarded – undo
446 503
 		$Common = new Common();
447 504
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
448 505
 		$check_date = new Datetime($date);
449
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
506
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
507
+			return array();
508
+		}
450 509
 		$url = "https://www.iberia.com/web/flightDetail.do";
451 510
 		$post = array('numvuelo' => $numvol,'fecha' => $check_date->format('Ymd'),'airlineID' => 'IB');
452 511
 		$data = $Common->getData($url,'post',$post);
@@ -463,7 +522,9 @@  discard block
 block discarded – undo
463 522
 				$arrivalTime = trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[5][1])));
464 523
 				if ($arrivalTime == 'Hora estimada de llegada') {
465 524
 					$arrivalTime = substr(trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[5][2]))),0,5);
466
-				} else $arrivalTime = substr($arrivalTime,0,5);
525
+				} else {
526
+					$arrivalTime = substr($arrivalTime,0,5);
527
+				}
467 528
 				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_iberia');
468 529
 			}
469 530
 		}
@@ -482,7 +543,9 @@  discard block
 block discarded – undo
482 543
 		$Common = new Common();
483 544
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
484 545
 		$check_date = new Datetime($date);
485
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
546
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
547
+			return array();
548
+		}
486 549
 		$url = "http://www.staralliance.com/flifoQueryAction.do?myAirline=&airlineCode=".$carrier."&flightNo=".$numvol."&day=".$check_date->format('d')."&month=".$check_date->format('m')."&year=".$check_date->format('Y')."&departuredate=".$check_date->format('d-M-Y');
487 550
 		$data = $Common->getData($url);
488 551
 		if ($data != '') {
@@ -498,7 +561,9 @@  discard block
 block discarded – undo
498 561
 					$departureTime = substr(trim(str_replace('Scheduled: ','',$flight[29][0])),0,5);
499 562
 					$arrivalTime = substr(trim(str_replace('Scheduled: ','',$flight[29][1])),0,5);
500 563
 					return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_staralliance');
501
-				} else return array();
564
+				} else {
565
+					return array();
566
+				}
502 567
 			}
503 568
 			
504 569
 
@@ -518,7 +583,9 @@  discard block
 block discarded – undo
518 583
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
519 584
 		$check_date = new Datetime($date);
520 585
 		$url= "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y');
521
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
586
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
587
+			return array();
588
+		}
522 589
 		$data = $Common->getData($url);
523 590
 		if ($data != '') {
524 591
 			$table = $Common->text2array($data);
@@ -543,7 +610,9 @@  discard block
 block discarded – undo
543 610
 		$check_date = new Datetime($date);
544 611
 		$url= "http://www.brusselsairlines.com/api/flightstatus/getresults?from=NA&to=NA&date=".$check_date->format('d/m/Y')."&hour=NA&lookup=flightnumber&flightnumber=".$numvol."&publicationID=302";
545 612
 		//http://www.brusselsairlines.com/fr-fr/informations-pratiques/statut-de-votre-vol/resultat.aspx?flightnumber=".$numvol."&date=".$check_date->format('d/m/Y')."&lookup=flightnumber";
546
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
613
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
614
+			return array();
615
+		}
547 616
 		$data = $Common->getData($url);
548 617
 		if ($data != '') {
549 618
 		    //echo $data;
@@ -634,7 +703,9 @@  discard block
 block discarded – undo
634 703
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
635 704
 		$url= "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees";
636 705
 		//$check_date = new Datetime($date);
637
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
706
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
707
+			return array();
708
+		}
638 709
 		$post = array('arrivalsdepartures_content' => 'number','arrivalsdepartures_tp' => $numvol,'arrivalsdepartures_trk' => 'ARR','arrivalsdepartures_date_trk' => '1','aptCode' => '','arrivalsdepartures' => 'DEP','arrivalsdepartures_date' => '1','aptCodeFrom' => '','aptCodeTo' => '','arrivalsdepartures2' => 'DEP','arrivalsdepartures_date2' => '1');
639 710
 		$data = $Common->getData($url,'post',$post);
640 711
 		if ($data != '') {
@@ -666,11 +737,15 @@  discard block
 block discarded – undo
666 737
 				$airline_icao = substr($callsign, 0, 3);
667 738
 			} 
668 739
 		}
669
-		if ($airline_icao == '') return array();
740
+		if ($airline_icao == '') {
741
+			return array();
742
+		}
670 743
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
671 744
 		$url= "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol;
672 745
 		//$check_date = new Datetime($date);
673
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
746
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
747
+			return array();
748
+		}
674 749
 		$data = $Common->getData($url);
675 750
 		if ($data != '') {
676 751
 			$table = $Common->table2array($data);
@@ -763,10 +838,16 @@  discard block
 block discarded – undo
763 838
 		if ($data != '') {
764 839
 			$table = $Common->table2array($data);
765 840
 			if (isset($table[11][1])) {
766
-				if (is_numeric(substr($table[11][1],0,1))) $departureTime = substr($table[11][1],0,5);
767
-				else $departureTime = '';
768
-				if (is_numeric(substr($table[17][1],0,1))) $arrivalTime = substr($table[17][1],0,5);
769
-				else $arrivalTime = '';
841
+				if (is_numeric(substr($table[11][1],0,1))) {
842
+					$departureTime = substr($table[11][1],0,5);
843
+				} else {
844
+					$departureTime = '';
845
+				}
846
+				if (is_numeric(substr($table[17][1],0,1))) {
847
+					$arrivalTime = substr($table[17][1],0,5);
848
+				} else {
849
+					$arrivalTime = '';
850
+				}
770 851
 				$DepartureAirportIata = substr($table[13][1],0,3);
771 852
 				$ArrivalAirportIata = substr($table[15][1],0,3);
772 853
 				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_costtotravel');
@@ -783,16 +864,22 @@  discard block
 block discarded – undo
783 864
 	*/
784 865
 	private function getAirCanada($callsign,$date = 'NOW') {
785 866
 		$Common = new Common();
786
-		if (class_exists("DomDocument") === FALSE) return array();
867
+		if (class_exists("DomDocument") === FALSE) {
868
+			return array();
869
+		}
787 870
 		date_default_timezone_set('UTC');
788 871
 		$check_date = new Datetime($date);
789 872
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
790 873
 		$url= "http://services.aircanada.com/portal/rest/getFlightsByFlightNumber?forceTimetable=true&flightNumber=".$numvol."&carrierCode=AC&date=".$check_date->format('m-d-Y')."&app_key=AE919FDCC80311DF9BABC975DFD72085&cache=74249";
791
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
874
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
875
+			return array();
876
+		}
792 877
 		$data = $Common->getData($url);
793 878
 		$dom = new DomDocument();
794 879
 		$dom->loadXML($data);
795
-		if ($dom->getElementsByTagName('DepartureStationInfo')->length == 0) return array();
880
+		if ($dom->getElementsByTagName('DepartureStationInfo')->length == 0) {
881
+			return array();
882
+		}
796 883
 		$departure = $dom->getElementsByTagName('DepartureStationInfo')->item(0);
797 884
 		if (isset($departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue)) {
798 885
 			$DepartureAirportIata = $departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue;
@@ -801,7 +888,9 @@  discard block
 block discarded – undo
801 888
 			$ArrivalAirportIata = $arrival->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue;
802 889
 			$arrivalTime = date('H:i',strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
803 890
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_aircanada');
804
-		} else return array();
891
+		} else {
892
+			return array();
893
+		}
805 894
 	}
806 895
 
807 896
 	/**
@@ -815,7 +904,9 @@  discard block
 block discarded – undo
815 904
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
816 905
 		$check_date = new Datetime($date);
817 906
 		$url= "https://cat.sabresonicweb.com/SSWVN/meridia?posid=VNVN&page=flifoFlightInfoDetailsMessage_learn&action=flightInfoDetails&airline=VN&language=fr&depDay=".$check_date->format('j')."&depMonth=".strtoupper($check_date->format('M'))."&=&flight=".$numvol."&";
818
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
907
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
908
+			return array();
909
+		}
819 910
 		$data = $Common->getData($url);
820 911
 		if ($data != '') {
821 912
 			$table = $Common->table2array($data);
@@ -845,7 +936,9 @@  discard block
 block discarded – undo
845 936
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
846 937
 		$check_date = new Datetime($date);
847 938
 		$url= "http://www.airberlin.com/en-US/site/aims.php";
848
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
939
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
940
+			return array();
941
+		}
849 942
 		$post = array('type' => 'departure','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => $carrier);
850 943
 		$data = $Common->getData($url,'post',$post);
851 944
 		//echo $data;
@@ -855,11 +948,19 @@  discard block
 block discarded – undo
855 948
 		if ($data != '') {
856 949
 			$table = $Common->table2array($data);
857 950
 			$flight = $table;
858
-			if (isset($flight[5][4])) $departureTime = $flight[5][4];
859
-			else $departureTime = '';
860
-			if (isset($flight[5][2])) $departureAirport = $flight[5][2];
861
-			else $departureAirport = '';
862
-		} else return array();
951
+			if (isset($flight[5][4])) {
952
+				$departureTime = $flight[5][4];
953
+			} else {
954
+				$departureTime = '';
955
+			}
956
+			if (isset($flight[5][2])) {
957
+				$departureAirport = $flight[5][2];
958
+			} else {
959
+				$departureAirport = '';
960
+			}
961
+		} else {
962
+			return array();
963
+		}
863 964
 		$post = array('type' => 'arrival','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => 'AB');
864 965
 		$data = $Common->getData($url,'post',$post);
865 966
 		if ($data != '') {
@@ -872,10 +973,14 @@  discard block
 block discarded – undo
872 973
 			    $arrivalTime = '';
873 974
 			    $arrivalAirport = '';
874 975
 			}
875
-		} else return array();
976
+		} else {
977
+			return array();
978
+		}
876 979
 		$url = 'http://www.airberlin.com/en-US/site/json/suggestAirport.php?searchfor=departures&searchflightid=0&departures%5B%5D=&suggestsource%5B0%5D=activeairports&withcountries=0&withoutroutings=0&promotion%5Bid%5D=&promotion%5Btype%5D=&routesource%5B0%5D=airberlin&routesource%5B1%5D=partner';
877 980
 		$json = $Common->getData($url);
878
-		if ($json == '') return array();
981
+		if ($json == '') {
982
+			return array();
983
+		}
879 984
 		$parsed_json = json_decode($json);
880 985
 		$airports = $parsed_json->{'suggestList'};
881 986
 		if (count($airports) > 0) {
@@ -890,7 +995,9 @@  discard block
 block discarded – undo
890 995
 		}
891 996
 		if (isset($DepartureAirportIata)) {
892 997
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airberlin');
893
-		} else return array();
998
+		} else {
999
+			return array();
1000
+		}
894 1001
 	}
895 1002
 
896 1003
 	/*
@@ -902,7 +1009,9 @@  discard block
 block discarded – undo
902 1009
 	public function fetchSchedule($ident,$date = 'NOW') {
903 1010
 		global $globalSchedulesSources, $globalSchedulesFetch, $globalOffline, $globalFlightAwareUsername;
904 1011
 		//$Common = new Common();
905
-		if ($globalSchedulesFetch === FALSE || (isset($globalOffline) && $globalOffline === TRUE)) return array();
1012
+		if ($globalSchedulesFetch === FALSE || (isset($globalOffline) && $globalOffline === TRUE)) {
1013
+			return array();
1014
+		}
906 1015
 		$airline_icao = '';
907 1016
 		if (!is_numeric(substr($ident, 0, 3)))
908 1017
 		{
@@ -1137,18 +1246,27 @@  discard block
 block discarded – undo
1137 1246
 					if (strlen($airline_icao) == 3) {
1138 1247
 						$Spotter = new Spotter($this->db);
1139 1248
 						$airline_info = $Spotter->getAllAirlineInfo($airline_icao);
1140
-						if (isset($airline_info[0]['iata'])) $airline_icao = $airline_info[0]['iata'];
1249
+						if (isset($airline_info[0]['iata'])) {
1250
+							$airline_icao = $airline_info[0]['iata'];
1251
+						}
1141 1252
 					}
1142 1253
 					// Randomly use a generic function to get hours
1143 1254
 					if (strlen($airline_icao) == 2) {
1144
-						if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper','costtotravel','flightaware');
1255
+						if (!isset($globalSchedulesSources)) {
1256
+							$globalSchedulesSources = array('flightmapper','costtotravel','flightaware');
1257
+						}
1145 1258
 						if (count($globalSchedulesSources) > 0) {
1146 1259
 							$rand = mt_rand(0,count($globalSchedulesSources)-1);
1147 1260
 							$source = $globalSchedulesSources[$rand];
1148
-							if ($source == 'flightmapper') return $this->getFlightMapper($ident);
1149
-							elseif ($source == 'costtotravel') return $this->getCostToTravel($ident);
1261
+							if ($source == 'flightmapper') {
1262
+								return $this->getFlightMapper($ident);
1263
+							} elseif ($source == 'costtotravel') {
1264
+								return $this->getCostToTravel($ident);
1265
+							}
1150 1266
 							//elseif ($source == 'flightradar24') return $this->getFlightRadar24($ident,$date);
1151
-							elseif ($source == 'flightaware' && $globalFlightAwareUsername != '') return $this->getFlightAware($ident);
1267
+							elseif ($source == 'flightaware' && $globalFlightAwareUsername != '') {
1268
+								return $this->getFlightAware($ident);
1269
+							}
1152 1270
 						}
1153 1271
 					}
1154 1272
 			}
Please login to merge, or discard this patch.
require/class.Tracker.php 3 patches
Indentation   +268 added lines, -268 removed lines patch added patch discarded remove patch
@@ -20,13 +20,13 @@  discard block
 block discarded – undo
20 20
 		if ($this->db === null) die('Error: No DB connection. (Tracker)');
21 21
 	}
22 22
 
23
-    /**
24
-     * Get SQL query part for filter used
25
-     * @param array $filter the filter
26
-     * @param bool $where
27
-     * @param bool $and
28
-     * @return string the SQL part
29
-     */
23
+	/**
24
+	 * Get SQL query part for filter used
25
+	 * @param array $filter the filter
26
+	 * @param bool $where
27
+	 * @param bool $and
28
+	 * @return string the SQL part
29
+	 */
30 30
 	
31 31
 	public function getFilter($filter = array(),$where = false,$and = false) {
32 32
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
@@ -92,15 +92,15 @@  discard block
 block discarded – undo
92 92
 		return $filter_query;
93 93
 	}
94 94
 
95
-    /**
96
-     * Executes the SQL statements to get the tracker information
97
-     *
98
-     * @param String $query the SQL query
99
-     * @param array $params parameter of the query
100
-     * @param String $limitQuery the limit query
101
-     * @param bool $schedules
102
-     * @return array the tracker information
103
-     */
95
+	/**
96
+	 * Executes the SQL statements to get the tracker information
97
+	 *
98
+	 * @param String $query the SQL query
99
+	 * @param array $params parameter of the query
100
+	 * @param String $limitQuery the limit query
101
+	 * @param bool $schedules
102
+	 * @return array the tracker information
103
+	 */
104 104
 	public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false)
105 105
 	{
106 106
 		date_default_timezone_set('UTC');
@@ -212,14 +212,14 @@  discard block
 block discarded – undo
212 212
 	}
213 213
 
214 214
 
215
-    /**
216
-     * Gets all the tracker information based on the latest data entry
217
-     *
218
-     * @param string $limit
219
-     * @param string $sort
220
-     * @param array $filter
221
-     * @return array the tracker information
222
-     */
215
+	/**
216
+	 * Gets all the tracker information based on the latest data entry
217
+	 *
218
+	 * @param string $limit
219
+	 * @param string $sort
220
+	 * @param array $filter
221
+	 * @return array the tracker information
222
+	 */
223 223
 	public function getLatestTrackerData($limit = '', $sort = '', $filter = array())
224 224
 	{
225 225
 		global $global_tracker_query;
@@ -276,15 +276,15 @@  discard block
 block discarded – undo
276 276
 		return $tracker_array;
277 277
 	}
278 278
 
279
-    /**
280
-     * Gets all the tracker information based on the callsign
281
-     *
282
-     * @param string $ident
283
-     * @param string $limit
284
-     * @param string $sort
285
-     * @param array $filter
286
-     * @return array the tracker information
287
-     */
279
+	/**
280
+	 * Gets all the tracker information based on the callsign
281
+	 *
282
+	 * @param string $ident
283
+	 * @param string $limit
284
+	 * @param string $sort
285
+	 * @param array $filter
286
+	 * @return array the tracker information
287
+	 */
288 288
 	public function getTrackerDataByIdent($ident = '', $limit = '', $sort = '', $filter = array())
289 289
 	{
290 290
 		global $global_tracker_query;
@@ -393,13 +393,13 @@  discard block
 block discarded – undo
393 393
 	}
394 394
 
395 395
 
396
-    /**
397
-     * Gets all source name
398
-     *
399
-     * @param String type format of source
400
-     * @param array $filters
401
-     * @return array list of source name
402
-     */
396
+	/**
397
+	 * Gets all source name
398
+	 *
399
+	 * @param String type format of source
400
+	 * @param array $filters
401
+	 * @return array list of source name
402
+	 */
403 403
 	public function getAllSourceName($type = '',$filters = array())
404 404
 	{
405 405
 		$filter_query = $this->getFilter($filters,true,true);
@@ -428,12 +428,12 @@  discard block
 block discarded – undo
428 428
 	}
429 429
 
430 430
 
431
-    /**
432
-     * Gets a list of all idents/callsigns
433
-     *
434
-     * @param array $filters
435
-     * @return array list of ident/callsign names
436
-     */
431
+	/**
432
+	 * Gets a list of all idents/callsigns
433
+	 *
434
+	 * @param array $filters
435
+	 * @return array list of ident/callsign names
436
+	 */
437 437
 	public function getAllIdents($filters = array())
438 438
 	{
439 439
 		$filter_query = $this->getFilter($filters,true,true);
@@ -500,19 +500,19 @@  discard block
 block discarded – undo
500 500
 	}
501 501
 
502 502
 
503
-    /**
504
-     * Update ident tracker data
505
-     *
506
-     * @param string $famtrackid
507
-     * @param String $ident the flight ident
508
-     * @param null $fromsource
509
-     * @return String success or false
510
-     */
503
+	/**
504
+	 * Update ident tracker data
505
+	 *
506
+	 * @param string $famtrackid
507
+	 * @param String $ident the flight ident
508
+	 * @param null $fromsource
509
+	 * @return String success or false
510
+	 */
511 511
 	public function updateIdentTrackerData($famtrackid = '', $ident = '',$fromsource = NULL)
512 512
 	{
513 513
 
514 514
 		$query = 'UPDATE tracker_output SET ident = :ident WHERE famtrackid = :famtrackid';
515
-                $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident);
515
+				$query_values = array(':famtrackid' => $famtrackid,':ident' => $ident);
516 516
 
517 517
 		try {
518 518
 			$sth = $this->db->prepare($query);
@@ -525,22 +525,22 @@  discard block
 block discarded – undo
525 525
 
526 526
 	}
527 527
 
528
-    /**
529
-     * Update latest tracker data
530
-     *
531
-     * @param string $famtrackid
532
-     * @param String $ident the flight ident
533
-     * @param string $latitude
534
-     * @param string $longitude
535
-     * @param string $altitude
536
-     * @param null $groundspeed
537
-     * @param string $date
538
-     * @return String success or false
539
-     */
528
+	/**
529
+	 * Update latest tracker data
530
+	 *
531
+	 * @param string $famtrackid
532
+	 * @param String $ident the flight ident
533
+	 * @param string $latitude
534
+	 * @param string $longitude
535
+	 * @param string $altitude
536
+	 * @param null $groundspeed
537
+	 * @param string $date
538
+	 * @return String success or false
539
+	 */
540 540
 	public function updateLatestTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $groundspeed = NULL, $date = '')
541 541
 	{
542 542
 		$query = 'UPDATE tracker_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_altitude = :last_altitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE famtrackid = :famtrackid';
543
-                $query_values = array(':famtrackid' => $famtrackid,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_altitude' => $altitude,':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident);
543
+				$query_values = array(':famtrackid' => $famtrackid,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_altitude' => $altitude,':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident);
544 544
 
545 545
 		try {
546 546
 			$sth = $this->db->prepare($query);
@@ -553,23 +553,23 @@  discard block
 block discarded – undo
553 553
 
554 554
 	}
555 555
 
556
-    /**
557
-     * Adds a new tracker data
558
-     *
559
-     * @param string $famtrackid
560
-     * @param String $ident the flight ident
561
-     * @param String $latitude latitude of flight
562
-     * @param String $longitude latitude of flight
563
-     * @param String $altitude altitude of flight
564
-     * @param String $heading heading of flight
565
-     * @param String $groundspeed speed of flight
566
-     * @param String $date date of flight
567
-     * @param string $comment
568
-     * @param string $type
569
-     * @param string $format_source
570
-     * @param string $source_name
571
-     * @return String success or false
572
-     */
556
+	/**
557
+	 * Adds a new tracker data
558
+	 *
559
+	 * @param string $famtrackid
560
+	 * @param String $ident the flight ident
561
+	 * @param String $latitude latitude of flight
562
+	 * @param String $longitude latitude of flight
563
+	 * @param String $altitude altitude of flight
564
+	 * @param String $heading heading of flight
565
+	 * @param String $groundspeed speed of flight
566
+	 * @param String $date date of flight
567
+	 * @param string $comment
568
+	 * @param string $type
569
+	 * @param string $format_source
570
+	 * @param string $source_name
571
+	 * @return String success or false
572
+	 */
573 573
 	public function addTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $comment = '', $type = '',$format_source = '', $source_name = '')
574 574
 	{
575 575
 		//$Image = new Image($this->db);
@@ -652,16 +652,16 @@  discard block
 block discarded – undo
652 652
 		$comment = filter_var($comment,FILTER_SANITIZE_STRING);
653 653
 		$type = filter_var($type,FILTER_SANITIZE_STRING);
654 654
 	
655
-                if ($latitude == '' && $longitude == '') {
656
-            		$latitude = 0;
657
-            		$longitude = 0;
658
-            	}
659
-                if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
660
-                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
661
-                $query  = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) 
655
+				if ($latitude == '' && $longitude == '') {
656
+					$latitude = 0;
657
+					$longitude = 0;
658
+				}
659
+				if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
660
+				if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
661
+				$query  = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) 
662 662
                 VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:speed,:date,:format_source, :source_name,:comment,:type)";
663 663
 
664
-                $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':altitude' => $altitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':comment' => $comment,':type' => $type);
664
+				$query_values = array(':famtrackid' => $famtrackid,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':altitude' => $altitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':comment' => $comment,':type' => $type);
665 665
 
666 666
 		try {
667 667
 		        
@@ -669,7 +669,7 @@  discard block
 block discarded – undo
669 669
 			$sth->execute($query_values);
670 670
 			$this->db = null;
671 671
 		} catch (PDOException $e) {
672
-		    return "error : ".$e->getMessage();
672
+			return "error : ".$e->getMessage();
673 673
 		}
674 674
 		
675 675
 		return "success";
@@ -677,12 +677,12 @@  discard block
 block discarded – undo
677 677
 	}
678 678
 
679 679
 
680
-    /**
681
-     * Gets the aircraft ident within the last hour
682
-     *
683
-     * @param $ident
684
-     * @return String the ident
685
-     */
680
+	/**
681
+	 * Gets the aircraft ident within the last hour
682
+	 *
683
+	 * @param $ident
684
+	 * @return String the ident
685
+	 */
686 686
 	public function getIdentFromLastHour($ident)
687 687
 	{
688 688
 		global $globalDBdriver;
@@ -698,11 +698,11 @@  discard block
 block discarded – undo
698 698
 								AND tracker_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
699 699
 								AND tracker_output.date < now() AT TIME ZONE 'UTC'";
700 700
 			$query_data = array(':ident' => $ident);
701
-    		}
701
+			}
702 702
 		
703 703
 		$sth = $this->db->prepare($query);
704 704
 		$sth->execute($query_data);
705
-    		$ident_result='';
705
+			$ident_result='';
706 706
 		while($row = $sth->fetch(PDO::FETCH_ASSOC))
707 707
 		{
708 708
 			$ident_result = $row['ident'];
@@ -712,12 +712,12 @@  discard block
 block discarded – undo
712 712
 	}
713 713
 
714 714
 
715
-    /**
716
-     * Gets the aircraft data from the last 20 seconds
717
-     *
718
-     * @param string $q
719
-     * @return array the tracker data
720
-     */
715
+	/**
716
+	 * Gets the aircraft data from the last 20 seconds
717
+	 *
718
+	 * @param string $q
719
+	 * @return array the tracker data
720
+	 */
721 721
 	public function getRealTimeData($q = '')
722 722
 	{
723 723
 		global $globalDBdriver;
@@ -750,15 +750,15 @@  discard block
 block discarded – undo
750 750
 		return $tracker_array;
751 751
 	}
752 752
 
753
-    /**
754
-     * Gets all number of flight over countries
755
-     *
756
-     * @param bool $limit
757
-     * @param int $olderthanmonths
758
-     * @param string $sincedate
759
-     * @param array $filters
760
-     * @return array the airline country list
761
-     */
753
+	/**
754
+	 * Gets all number of flight over countries
755
+	 *
756
+	 * @param bool $limit
757
+	 * @param int $olderthanmonths
758
+	 * @param string $sincedate
759
+	 * @param array $filters
760
+	 * @return array the airline country list
761
+	 */
762 762
 	public function countAllTrackerOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
763 763
 	{
764 764
 		global $globalDBdriver, $globalArchive;
@@ -827,18 +827,18 @@  discard block
 block discarded – undo
827 827
 		return $flight_array;
828 828
 	}
829 829
 
830
-    /**
831
-     * Gets all callsigns that have flown over
832
-     *
833
-     * @param bool $limit
834
-     * @param int $olderthanmonths
835
-     * @param string $sincedate
836
-     * @param array $filters
837
-     * @param string $year
838
-     * @param string $month
839
-     * @param string $day
840
-     * @return array the callsign list
841
-     */
830
+	/**
831
+	 * Gets all callsigns that have flown over
832
+	 *
833
+	 * @param bool $limit
834
+	 * @param int $olderthanmonths
835
+	 * @param string $sincedate
836
+	 * @param array $filters
837
+	 * @param string $year
838
+	 * @param string $month
839
+	 * @param string $day
840
+	 * @return array the callsign list
841
+	 */
842 842
 	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
843 843
 	{
844 844
 		global $globalDBdriver;
@@ -904,12 +904,12 @@  discard block
 block discarded – undo
904 904
 	}
905 905
 
906 906
 
907
-    /**
908
-     * Counts all dates
909
-     *
910
-     * @param array $filters
911
-     * @return array the date list
912
-     */
907
+	/**
908
+	 * Counts all dates
909
+	 *
910
+	 * @param array $filters
911
+	 * @return array the date list
912
+	 */
913 913
 	public function countAllDates($filters = array())
914 914
 	{
915 915
 		global $globalTimezone, $globalDBdriver;
@@ -954,12 +954,12 @@  discard block
 block discarded – undo
954 954
 	}
955 955
 
956 956
 
957
-    /**
958
-     * Counts all dates during the last 7 days
959
-     *
960
-     * @param array $filters
961
-     * @return array the date list
962
-     */
957
+	/**
958
+	 * Counts all dates during the last 7 days
959
+	 *
960
+	 * @param array $filters
961
+	 * @return array the date list
962
+	 */
963 963
 	public function countAllDatesLast7Days($filters = array())
964 964
 	{
965 965
 		global $globalTimezone, $globalDBdriver;
@@ -981,7 +981,7 @@  discard block
 block discarded – undo
981 981
 			$query .= " GROUP BY date_name 
982 982
 								ORDER BY date_name ASC";
983 983
 			$query_data = array(':offset' => $offset);
984
-    		}
984
+			}
985 985
 		
986 986
 		$sth = $this->db->prepare($query);
987 987
 		$sth->execute($query_data);
@@ -1000,12 +1000,12 @@  discard block
 block discarded – undo
1000 1000
 		return $date_array;
1001 1001
 	}
1002 1002
 
1003
-    /**
1004
-     * Counts all dates during the last month
1005
-     *
1006
-     * @param array $filters
1007
-     * @return array the date list
1008
-     */
1003
+	/**
1004
+	 * Counts all dates during the last month
1005
+	 *
1006
+	 * @param array $filters
1007
+	 * @return array the date list
1008
+	 */
1009 1009
 	public function countAllDatesLastMonth($filters = array())
1010 1010
 	{
1011 1011
 		global $globalTimezone, $globalDBdriver;
@@ -1027,7 +1027,7 @@  discard block
 block discarded – undo
1027 1027
 			$query .= " GROUP BY date_name 
1028 1028
 								ORDER BY date_name ASC";
1029 1029
 			$query_data = array(':offset' => $offset);
1030
-    		}
1030
+			}
1031 1031
 		
1032 1032
 		$sth = $this->db->prepare($query);
1033 1033
 		$sth->execute($query_data);
@@ -1047,12 +1047,12 @@  discard block
 block discarded – undo
1047 1047
 	}
1048 1048
 
1049 1049
 
1050
-    /**
1051
-     * Counts all month
1052
-     *
1053
-     * @param array $filters
1054
-     * @return array the month list
1055
-     */
1050
+	/**
1051
+	 * Counts all month
1052
+	 *
1053
+	 * @param array $filters
1054
+	 * @return array the month list
1055
+	 */
1056 1056
 	public function countAllMonths($filters = array())
1057 1057
 	{
1058 1058
 		global $globalTimezone, $globalDBdriver;
@@ -1094,12 +1094,12 @@  discard block
 block discarded – undo
1094 1094
 	}
1095 1095
 
1096 1096
 
1097
-    /**
1098
-     * Counts all dates during the last year
1099
-     *
1100
-     * @param $filters
1101
-     * @return array the date list
1102
-     */
1097
+	/**
1098
+	 * Counts all dates during the last year
1099
+	 *
1100
+	 * @param $filters
1101
+	 * @return array the date list
1102
+	 */
1103 1103
 	public function countAllMonthsLastYear($filters)
1104 1104
 	{
1105 1105
 		global $globalTimezone, $globalDBdriver;
@@ -1121,7 +1121,7 @@  discard block
 block discarded – undo
1121 1121
 			$query .= " GROUP BY year_name, month_name
1122 1122
 								ORDER BY year_name, month_name ASC";
1123 1123
 			$query_data = array(':offset' => $offset);
1124
-    		}
1124
+			}
1125 1125
 		
1126 1126
 		$sth = $this->db->prepare($query);
1127 1127
 		$sth->execute($query_data);
@@ -1142,13 +1142,13 @@  discard block
 block discarded – undo
1142 1142
 	}
1143 1143
 
1144 1144
 
1145
-    /**
1146
-     * Counts all hours
1147
-     *
1148
-     * @param $orderby
1149
-     * @param array $filters
1150
-     * @return array the hour list
1151
-     */
1145
+	/**
1146
+	 * Counts all hours
1147
+	 *
1148
+	 * @param $orderby
1149
+	 * @param array $filters
1150
+	 * @return array the hour list
1151
+	 */
1152 1152
 	public function countAllHours($orderby,$filters = array())
1153 1153
 	{
1154 1154
 		global $globalTimezone, $globalDBdriver;
@@ -1209,13 +1209,13 @@  discard block
 block discarded – undo
1209 1209
 	}
1210 1210
 
1211 1211
 
1212
-    /**
1213
-     * Counts all hours by date
1214
-     *
1215
-     * @param $date
1216
-     * @param array $filters
1217
-     * @return array the hour list
1218
-     */
1212
+	/**
1213
+	 * Counts all hours by date
1214
+	 *
1215
+	 * @param $date
1216
+	 * @param array $filters
1217
+	 * @return array the hour list
1218
+	 */
1219 1219
 	public function countAllHoursByDate($date, $filters = array())
1220 1220
 	{
1221 1221
 		global $globalTimezone, $globalDBdriver;
@@ -1257,13 +1257,13 @@  discard block
 block discarded – undo
1257 1257
 	}
1258 1258
 
1259 1259
 
1260
-    /**
1261
-     * Counts all hours by a ident/callsign
1262
-     *
1263
-     * @param $ident
1264
-     * @param array $filters
1265
-     * @return array the hour list
1266
-     */
1260
+	/**
1261
+	 * Counts all hours by a ident/callsign
1262
+	 *
1263
+	 * @param $ident
1264
+	 * @param array $filters
1265
+	 * @return array the hour list
1266
+	 */
1267 1267
 	public function countAllHoursByIdent($ident, $filters = array())
1268 1268
 	{
1269 1269
 		global $globalTimezone, $globalDBdriver;
@@ -1306,14 +1306,14 @@  discard block
 block discarded – undo
1306 1306
 	}
1307 1307
 
1308 1308
 
1309
-    /**
1310
-     * Counts all trackers that have flown over
1311
-     *
1312
-     * @param array $filters
1313
-     * @param string $year
1314
-     * @param string $month
1315
-     * @return Integer the number of trackers
1316
-     */
1309
+	/**
1310
+	 * Counts all trackers that have flown over
1311
+	 *
1312
+	 * @param array $filters
1313
+	 * @param string $year
1314
+	 * @param string $month
1315
+	 * @return Integer the number of trackers
1316
+	 */
1317 1317
 	public function countOverallTracker($filters = array(),$year = '',$month = '')
1318 1318
 	{
1319 1319
 		global $globalDBdriver;
@@ -1347,14 +1347,14 @@  discard block
 block discarded – undo
1347 1347
 		return $sth->fetchColumn();
1348 1348
 	}
1349 1349
 
1350
-    /**
1351
-     * Counts all trackers type that have flown over
1352
-     *
1353
-     * @param array $filters
1354
-     * @param string $year
1355
-     * @param string $month
1356
-     * @return Integer the number of flights
1357
-     */
1350
+	/**
1351
+	 * Counts all trackers type that have flown over
1352
+	 *
1353
+	 * @param array $filters
1354
+	 * @param string $year
1355
+	 * @param string $month
1356
+	 * @return Integer the number of flights
1357
+	 */
1358 1358
 	public function countOverallTrackerTypes($filters = array(),$year = '',$month = '')
1359 1359
 	{
1360 1360
 		global $globalDBdriver;
@@ -1388,12 +1388,12 @@  discard block
 block discarded – undo
1388 1388
 	}
1389 1389
 
1390 1390
 
1391
-    /**
1392
-     * Counts all hours of today
1393
-     *
1394
-     * @param array $filters
1395
-     * @return array the hour list
1396
-     */
1391
+	/**
1392
+	 * Counts all hours of today
1393
+	 *
1394
+	 * @param array $filters
1395
+	 * @return array the hour list
1396
+	 */
1397 1397
 	public function countAllHoursFromToday($filters = array())
1398 1398
 	{
1399 1399
 		global $globalTimezone, $globalDBdriver;
@@ -1433,12 +1433,12 @@  discard block
 block discarded – undo
1433 1433
 	}
1434 1434
 
1435 1435
 
1436
-    /**
1437
-     * Gets the Barrie Spotter ID based on the FlightAware ID
1438
-     *
1439
-     * @param $famtrackid
1440
-     * @return Integer the Barrie Spotter ID
1441
-     */
1436
+	/**
1437
+	 * Gets the Barrie Spotter ID based on the FlightAware ID
1438
+	 *
1439
+	 * @param $famtrackid
1440
+	 * @return Integer the Barrie Spotter ID
1441
+	 */
1442 1442
 	public function getTrackerIDBasedOnFamTrackID($famtrackid)
1443 1443
 	{
1444 1444
 		$famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING);
@@ -1459,13 +1459,13 @@  discard block
 block discarded – undo
1459 1459
   
1460 1460
  
1461 1461
 	/**
1462
-	* Parses a date string
1463
-	*
1464
-	* @param String $dateString the date string
1465
-	* @param String $timezone the timezone of a user
1466
-	* @return array the time information
1467
-	*
1468
-	*/
1462
+	 * Parses a date string
1463
+	 *
1464
+	 * @param String $dateString the date string
1465
+	 * @param String $timezone the timezone of a user
1466
+	 * @return array the time information
1467
+	 *
1468
+	 */
1469 1469
 	public function parseDateString($dateString, $timezone = '')
1470 1470
 	{
1471 1471
 		$time_array = array();
@@ -1498,12 +1498,12 @@  discard block
 block discarded – undo
1498 1498
 	}
1499 1499
 	
1500 1500
 	/**
1501
-	* Parses the direction degrees to working
1502
-	*
1503
-	* @param Float $direction the direction in degrees
1504
-	* @return array the direction information
1505
-	*
1506
-	*/
1501
+	 * Parses the direction degrees to working
1502
+	 *
1503
+	 * @param Float $direction the direction in degrees
1504
+	 * @return array the direction information
1505
+	 *
1506
+	 */
1507 1507
 	public function parseDirection($direction = 0)
1508 1508
 	{
1509 1509
 		if ($direction == '') $direction = 0;
@@ -1582,12 +1582,12 @@  discard block
 block discarded – undo
1582 1582
 	
1583 1583
 	
1584 1584
 	/**
1585
-	* Gets Country from latitude/longitude
1586
-	*
1587
-	* @param Float $latitude latitute of the flight
1588
-	* @param Float $longitude longitute of the flight
1589
-	* @return String the countrie
1590
-	*/
1585
+	 * Gets Country from latitude/longitude
1586
+	 *
1587
+	 * @param Float $latitude latitute of the flight
1588
+	 * @param Float $longitude longitute of the flight
1589
+	 * @return String the countrie
1590
+	 */
1591 1591
 	public function getCountryFromLatitudeLongitude($latitude,$longitude)
1592 1592
 	{
1593 1593
 		global $globalDebug;
@@ -1615,11 +1615,11 @@  discard block
 block discarded – undo
1615 1615
 	}
1616 1616
 
1617 1617
 	/**
1618
-	* Gets Country from iso2
1619
-	*
1620
-	* @param String $iso2 ISO2 country code
1621
-	* @return String the countrie
1622
-	*/
1618
+	 * Gets Country from iso2
1619
+	 *
1620
+	 * @param String $iso2 ISO2 country code
1621
+	 * @return String the countrie
1622
+	 */
1623 1623
 	public function getCountryFromISO2($iso2)
1624 1624
 	{
1625 1625
 		global $globalDebug;
@@ -1646,18 +1646,18 @@  discard block
 block discarded – undo
1646 1646
 	
1647 1647
 	}
1648 1648
 
1649
-    /**
1650
-     * Gets all vessels types that have flown over
1651
-     *
1652
-     * @param bool $limit
1653
-     * @param int $olderthanmonths
1654
-     * @param string $sincedate
1655
-     * @param array $filters
1656
-     * @param string $year
1657
-     * @param string $month
1658
-     * @param string $day
1659
-     * @return array the vessel type list
1660
-     */
1649
+	/**
1650
+	 * Gets all vessels types that have flown over
1651
+	 *
1652
+	 * @param bool $limit
1653
+	 * @param int $olderthanmonths
1654
+	 * @param string $sincedate
1655
+	 * @param array $filters
1656
+	 * @param string $year
1657
+	 * @param string $month
1658
+	 * @param string $day
1659
+	 * @return array the vessel type list
1660
+	 */
1661 1661
 	public function countAllTrackerTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
1662 1662
 	{
1663 1663
 		global $globalDBdriver;
@@ -1721,21 +1721,21 @@  discard block
 block discarded – undo
1721 1721
 		return $tracker_array;
1722 1722
 	}
1723 1723
 
1724
-    /**
1725
-     * Gets all the tracker information
1726
-     *
1727
-     * @param string $q
1728
-     * @param string $callsign
1729
-     * @param string $date_posted
1730
-     * @param string $limit
1731
-     * @param string $sort
1732
-     * @param string $includegeodata
1733
-     * @param string $origLat
1734
-     * @param string $origLon
1735
-     * @param string $dist
1736
-     * @param array $filters
1737
-     * @return array the tracker information
1738
-     */
1724
+	/**
1725
+	 * Gets all the tracker information
1726
+	 *
1727
+	 * @param string $q
1728
+	 * @param string $callsign
1729
+	 * @param string $date_posted
1730
+	 * @param string $limit
1731
+	 * @param string $sort
1732
+	 * @param string $includegeodata
1733
+	 * @param string $origLat
1734
+	 * @param string $origLon
1735
+	 * @param string $dist
1736
+	 * @param array $filters
1737
+	 * @return array the tracker information
1738
+	 */
1739 1739
 	public function searchTrackerData($q = '', $callsign = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '',$filters = array())
1740 1740
 	{
1741 1741
 		global $globalTimezone, $globalDBdriver;
@@ -1840,12 +1840,12 @@  discard block
 block discarded – undo
1840 1840
 	}
1841 1841
 
1842 1842
 	/**
1843
-	* Gets the short url from bit.ly
1844
-	*
1845
-	* @param String $url the full url
1846
-	* @return String the bit.ly url
1847
-	*
1848
-	*/
1843
+	 * Gets the short url from bit.ly
1844
+	 *
1845
+	 * @param String $url the full url
1846
+	 * @return String the bit.ly url
1847
+	 *
1848
+	 */
1849 1849
 	public function getBitlyURL($url)
1850 1850
 	{
1851 1851
 		global $globalBitlyAccessToken;
Please login to merge, or discard this patch.
Spacing   +176 added lines, -176 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 require_once(dirname(__FILE__).'/class.Image.php');
12 12
 $global_tracker_query = "SELECT tracker_output.* FROM tracker_output";
13 13
 
14
-class Tracker{
14
+class Tracker {
15 15
 	public $db;
16 16
 	
17 17
 	public function __construct($dbc = null) {
@@ -28,33 +28,33 @@  discard block
 block discarded – undo
28 28
      * @return string the SQL part
29 29
      */
30 30
 	
31
-	public function getFilter($filter = array(),$where = false,$and = false) {
31
+	public function getFilter($filter = array(), $where = false, $and = false) {
32 32
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
33 33
 		$filters = array();
34 34
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
35 35
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
36 36
 				$filters = $globalStatsFilters[$globalFilterName];
37 37
 			} else {
38
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
38
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
39 39
 			}
40 40
 		}
41 41
 		if (isset($filter[0]['source'])) {
42
-			$filters = array_merge($filters,$filter);
42
+			$filters = array_merge($filters, $filter);
43 43
 		}
44
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
44
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
45 45
 		$filter_query_join = '';
46 46
 		$filter_query_where = '';
47
-		foreach($filters as $flt) {
47
+		foreach ($filters as $flt) {
48 48
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
49 49
 				if (isset($flt['source'])) {
50
-					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."') AND tracker_output.format_source IN ('".implode("','",$flt['source'])."')) spfi ON spfi.famtrackid = tracker_output.famtrackid";
50
+					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."') AND tracker_output.format_source IN ('".implode("','", $flt['source'])."')) spfi ON spfi.famtrackid = tracker_output.famtrackid";
51 51
 				} else {
52
-					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."')) spfi ON spfi.famtrackid = tracker_output.famtrackid";
52
+					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."')) spfi ON spfi.famtrackid = tracker_output.famtrackid";
53 53
 				}
54 54
 			}
55 55
 		}
56 56
 		if (isset($filter['source']) && !empty($filter['source'])) {
57
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
57
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
58 58
 		}
59 59
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
60 60
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
87 87
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
88 88
 		if ($filter_query_where != '') {
89
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
89
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
90 90
 		}
91 91
 		$filter_query = $filter_query_join.$filter_query_where;
92 92
 		return $filter_query;
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
      * @param bool $schedules
102 102
      * @return array the tracker information
103 103
      */
104
-	public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false)
104
+	public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false)
105 105
 	{
106 106
 		date_default_timezone_set('UTC');
107 107
 		if (!is_string($query))
@@ -121,13 +121,13 @@  discard block
 block discarded – undo
121 121
 			$sth = $this->db->prepare($query.$limitQuery);
122 122
 			$sth->execute($params);
123 123
 		} catch (PDOException $e) {
124
-			printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery);
124
+			printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery);
125 125
 			exit();
126 126
 		}
127 127
 		
128 128
 		$num_rows = 0;
129 129
 		$tracker_array = array();
130
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
130
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
131 131
 		{
132 132
 			$num_rows++;
133 133
 			$temp_array = array();
@@ -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
 				}
@@ -232,8 +232,8 @@  discard block
 block discarded – undo
232 232
 		{
233 233
 			$limit_array = explode(",", $limit);
234 234
 			
235
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
236
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
235
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
236
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
237 237
 			
238 238
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
239 239
 			{
@@ -250,9 +250,9 @@  discard block
 block discarded – undo
250 250
 			$orderby_query = " ORDER BY tracker_output.date DESC";
251 251
 		}
252 252
 
253
-		$query  = $global_tracker_query.$filter_query." ".$orderby_query;
253
+		$query = $global_tracker_query.$filter_query." ".$orderby_query;
254 254
 
255
-		$tracker_array = $this->getDataFromDB($query, array(),$limit_query,true);
255
+		$tracker_array = $this->getDataFromDB($query, array(), $limit_query, true);
256 256
 
257 257
 		return $tracker_array;
258 258
 	}
@@ -271,8 +271,8 @@  discard block
 block discarded – undo
271 271
 		if ($id == '') return array();
272 272
 		$additional_query = "tracker_output.famtrackid = :id";
273 273
 		$query_values = array(':id' => $id);
274
-		$query  = $global_tracker_query." WHERE ".$additional_query." ";
275
-		$tracker_array = $this->getDataFromDB($query,$query_values);
274
+		$query = $global_tracker_query." WHERE ".$additional_query." ";
275
+		$tracker_array = $this->getDataFromDB($query, $query_values);
276 276
 		return $tracker_array;
277 277
 	}
278 278
 
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 		$query_values = array();
295 295
 		$limit_query = '';
296 296
 		$additional_query = '';
297
-		$filter_query = $this->getFilter($filter,true,true);
297
+		$filter_query = $this->getFilter($filter, true, true);
298 298
 		if ($ident != "")
299 299
 		{
300 300
 			if (!is_string($ident))
@@ -310,8 +310,8 @@  discard block
 block discarded – undo
310 310
 		{
311 311
 			$limit_array = explode(",", $limit);
312 312
 			
313
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
314
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
313
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
314
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
315 315
 			
316 316
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
317 317
 			{
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
 		return $tracker_array;
336 336
 	}
337 337
 	
338
-	public function getTrackerDataByDate($date = '', $limit = '', $sort = '',$filter = array())
338
+	public function getTrackerDataByDate($date = '', $limit = '', $sort = '', $filter = array())
339 339
 	{
340 340
 		global $global_tracker_query, $globalTimezone, $globalDBdriver;
341 341
 		
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
 		$limit_query = '';
344 344
 		$additional_query = '';
345 345
 
346
-		$filter_query = $this->getFilter($filter,true,true);
346
+		$filter_query = $this->getFilter($filter, true, true);
347 347
 		
348 348
 		if ($date != "")
349 349
 		{
@@ -369,8 +369,8 @@  discard block
 block discarded – undo
369 369
 		{
370 370
 			$limit_array = explode(",", $limit);
371 371
 			
372
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
373
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
372
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
373
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
374 374
 			
375 375
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
376 376
 			{
@@ -400,11 +400,11 @@  discard block
 block discarded – undo
400 400
      * @param array $filters
401 401
      * @return array list of source name
402 402
      */
403
-	public function getAllSourceName($type = '',$filters = array())
403
+	public function getAllSourceName($type = '', $filters = array())
404 404
 	{
405
-		$filter_query = $this->getFilter($filters,true,true);
405
+		$filter_query = $this->getFilter($filters, true, true);
406 406
 		$query_values = array();
407
-		$query  = "SELECT DISTINCT tracker_output.source_name 
407
+		$query = "SELECT DISTINCT tracker_output.source_name 
408 408
 				FROM tracker_output".$filter_query." tracker_output.source_name <> ''";
409 409
 		if ($type != '') {
410 410
 			$query_values = array(':type' => $type);
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
 		$source_array = array();
420 420
 		$temp_array = array();
421 421
 		
422
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
422
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
423 423
 		{
424 424
 			$temp_array['source_name'] = $row['source_name'];
425 425
 			$source_array[] = $temp_array;
@@ -436,8 +436,8 @@  discard block
 block discarded – undo
436 436
      */
437 437
 	public function getAllIdents($filters = array())
438 438
 	{
439
-		$filter_query = $this->getFilter($filters,true,true);
440
-		$query  = "SELECT DISTINCT tracker_output.ident
439
+		$filter_query = $this->getFilter($filters, true, true);
440
+		$query = "SELECT DISTINCT tracker_output.ident
441 441
 								FROM tracker_output".$filter_query." tracker_output.ident <> '' 
442 442
 								ORDER BY tracker_output.date ASC LIMIT 700 OFFSET 0";
443 443
 
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
 		$ident_array = array();
448 448
 		$temp_array = array();
449 449
 		
450
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
450
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
451 451
 		{
452 452
 			$temp_array['ident'] = $row['ident'];
453 453
 			$ident_array[] = $temp_array;
@@ -472,12 +472,12 @@  discard block
 block discarded – undo
472 472
 		} else $offset = '+00:00';
473 473
 
474 474
 		if ($globalDBdriver == 'mysql') {
475
-			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) as date
475
+			$query = "SELECT DISTINCT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) as date
476 476
 								FROM tracker_output
477 477
 								WHERE tracker_output.date <> '' 
478 478
 								ORDER BY tracker_output.date ASC LIMIT 0,100";
479 479
 		} else {
480
-			$query  = "SELECT DISTINCT to_char(tracker_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
480
+			$query = "SELECT DISTINCT to_char(tracker_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
481 481
 								FROM tracker_output
482 482
 								WHERE tracker_output.date <> '' 
483 483
 								ORDER BY tracker_output.date ASC LIMIT 0,100";
@@ -489,7 +489,7 @@  discard block
 block discarded – undo
489 489
 		$date_array = array();
490 490
 		$temp_array = array();
491 491
 		
492
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
492
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
493 493
 		{
494 494
 			$temp_array['date'] = $row['date'];
495 495
 
@@ -508,11 +508,11 @@  discard block
 block discarded – undo
508 508
      * @param null $fromsource
509 509
      * @return String success or false
510 510
      */
511
-	public function updateIdentTrackerData($famtrackid = '', $ident = '',$fromsource = NULL)
511
+	public function updateIdentTrackerData($famtrackid = '', $ident = '', $fromsource = NULL)
512 512
 	{
513 513
 
514 514
 		$query = 'UPDATE tracker_output SET ident = :ident WHERE famtrackid = :famtrackid';
515
-                $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident);
515
+                $query_values = array(':famtrackid' => $famtrackid, ':ident' => $ident);
516 516
 
517 517
 		try {
518 518
 			$sth = $this->db->prepare($query);
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
 	public function updateLatestTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $groundspeed = NULL, $date = '')
541 541
 	{
542 542
 		$query = 'UPDATE tracker_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_altitude = :last_altitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE famtrackid = :famtrackid';
543
-                $query_values = array(':famtrackid' => $famtrackid,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_altitude' => $altitude,':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident);
543
+                $query_values = array(':famtrackid' => $famtrackid, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_altitude' => $altitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident);
544 544
 
545 545
 		try {
546 546
 			$sth = $this->db->prepare($query);
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
      * @param string $source_name
571 571
      * @return String success or false
572 572
      */
573
-	public function addTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $comment = '', $type = '',$format_source = '', $source_name = '')
573
+	public function addTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $comment = '', $type = '', $format_source = '', $source_name = '')
574 574
 	{
575 575
 		//$Image = new Image($this->db);
576 576
 		$Common = new Common();
@@ -636,21 +636,21 @@  discard block
 block discarded – undo
636 636
 		}
637 637
 
638 638
     
639
-		if ($date == "" || strtotime($date) < time()-20*60)
639
+		if ($date == "" || strtotime($date) < time() - 20*60)
640 640
 		{
641 641
 			$date = date("Y-m-d H:i:s", time());
642 642
 		}
643 643
 
644
-		$famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING);
645
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
646
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
647
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
648
-		$altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
649
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
650
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
651
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
652
-		$comment = filter_var($comment,FILTER_SANITIZE_STRING);
653
-		$type = filter_var($type,FILTER_SANITIZE_STRING);
644
+		$famtrackid = filter_var($famtrackid, FILTER_SANITIZE_STRING);
645
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
646
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
647
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
648
+		$altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
649
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
650
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
651
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
652
+		$comment = filter_var($comment, FILTER_SANITIZE_STRING);
653
+		$type = filter_var($type, FILTER_SANITIZE_STRING);
654 654
 	
655 655
                 if ($latitude == '' && $longitude == '') {
656 656
             		$latitude = 0;
@@ -658,10 +658,10 @@  discard block
 block discarded – undo
658 658
             	}
659 659
                 if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
660 660
                 if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
661
-                $query  = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) 
661
+                $query = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) 
662 662
                 VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:speed,:date,:format_source, :source_name,:comment,:type)";
663 663
 
664
-                $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':altitude' => $altitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':comment' => $comment,':type' => $type);
664
+                $query_values = array(':famtrackid' => $famtrackid, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':heading' => $heading, ':speed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':comment' => $comment, ':type' => $type);
665 665
 
666 666
 		try {
667 667
 		        
@@ -687,13 +687,13 @@  discard block
 block discarded – undo
687 687
 	{
688 688
 		global $globalDBdriver;
689 689
 		if ($globalDBdriver == 'mysql') {
690
-			$query  = "SELECT tracker_output.ident FROM tracker_output 
690
+			$query = "SELECT tracker_output.ident FROM tracker_output 
691 691
 								WHERE tracker_output.ident = :ident 
692 692
 								AND tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
693 693
 								AND tracker_output.date < UTC_TIMESTAMP()";
694 694
 			$query_data = array(':ident' => $ident);
695 695
 		} else {
696
-			$query  = "SELECT tracker_output.ident FROM tracker_output 
696
+			$query = "SELECT tracker_output.ident FROM tracker_output 
697 697
 								WHERE tracker_output.ident = :ident 
698 698
 								AND tracker_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
699 699
 								AND tracker_output.date < now() AT TIME ZONE 'UTC'";
@@ -702,8 +702,8 @@  discard block
 block discarded – undo
702 702
 		
703 703
 		$sth = $this->db->prepare($query);
704 704
 		$sth->execute($query_data);
705
-    		$ident_result='';
706
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
705
+    		$ident_result = '';
706
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
707 707
 		{
708 708
 			$ident_result = $row['ident'];
709 709
 		}
@@ -729,8 +729,8 @@  discard block
 block discarded – undo
729 729
 				return array();
730 730
 			} else {
731 731
 				$q_array = explode(" ", $q);
732
-				foreach ($q_array as $q_item){
733
-					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
732
+				foreach ($q_array as $q_item) {
733
+					$q_item = filter_var($q_item, FILTER_SANITIZE_STRING);
734 734
 					$additional_query .= " AND (";
735 735
 					$additional_query .= "(tracker_output.ident like '%".$q_item."%')";
736 736
 					$additional_query .= ")";
@@ -738,11 +738,11 @@  discard block
 block discarded – undo
738 738
 			}
739 739
 		}
740 740
 		if ($globalDBdriver == 'mysql') {
741
-			$query  = "SELECT tracker_output.* FROM tracker_output 
741
+			$query = "SELECT tracker_output.* FROM tracker_output 
742 742
 				WHERE tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." 
743 743
 				AND tracker_output.date < UTC_TIMESTAMP()";
744 744
 		} else {
745
-			$query  = "SELECT tracker_output.* FROM tracker_output 
745
+			$query = "SELECT tracker_output.* FROM tracker_output 
746 746
 				WHERE tracker_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." 
747 747
 				AND tracker_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
748 748
 		}
@@ -759,16 +759,16 @@  discard block
 block discarded – undo
759 759
      * @param array $filters
760 760
      * @return array the airline country list
761 761
      */
762
-	public function countAllTrackerOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
762
+	public function countAllTrackerOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
763 763
 	{
764 764
 		global $globalDBdriver, $globalArchive;
765 765
 		//$filter_query = $this->getFilter($filters,true,true);
766
-		$Connection= new Connection($this->db);
766
+		$Connection = new Connection($this->db);
767 767
 		if (!$Connection->tableExists('countries')) return array();
768 768
 		if (!isset($globalArchive) || $globalArchive !== TRUE) {
769 769
 			require_once('class.TrackerLive.php');
770 770
 			$TrackerLive = new TrackerLive($this->db);
771
-			$filter_query = $TrackerLive->getFilter($filters,true,true);
771
+			$filter_query = $TrackerLive->getFilter($filters, true, true);
772 772
 			$filter_query .= " over_country IS NOT NULL AND over_country <> ''";
773 773
 			if ($olderthanmonths > 0) {
774 774
 				if ($globalDBdriver == 'mysql') {
@@ -788,7 +788,7 @@  discard block
 block discarded – undo
788 788
 		} else {
789 789
 			require_once('class.TrackerArchive.php');
790 790
 			$TrackerArchive = new TrackerArchive($this->db);
791
-			$filter_query = $TrackerArchive->getFilter($filters,true,true);
791
+			$filter_query = $TrackerArchive->getFilter($filters, true, true);
792 792
 			$filter_query .= " over_country IS NOT NULL AND over_country <> ''";
793 793
 			if ($olderthanmonths > 0) {
794 794
 				if ($globalDBdriver == 'mysql') {
@@ -816,7 +816,7 @@  discard block
 block discarded – undo
816 816
 		$flight_array = array();
817 817
 		$temp_array = array();
818 818
         
819
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
819
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
820 820
 		{
821 821
 			$temp_array['tracker_count'] = $row['nb'];
822 822
 			$temp_array['tracker_country'] = $row['name'];
@@ -839,11 +839,11 @@  discard block
 block discarded – undo
839 839
      * @param string $day
840 840
      * @return array the callsign list
841 841
      */
842
-	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
842
+	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
843 843
 	{
844 844
 		global $globalDBdriver;
845
-		$filter_query = $this->getFilter($filters,true,true);
846
-		$query  = "SELECT DISTINCT tracker_output.ident, COUNT(tracker_output.ident) AS callsign_icao_count 
845
+		$filter_query = $this->getFilter($filters, true, true);
846
+		$query = "SELECT DISTINCT tracker_output.ident, COUNT(tracker_output.ident) AS callsign_icao_count 
847 847
                     FROM tracker_output".$filter_query." tracker_output.ident <> ''";
848 848
 		 if ($olderthanmonths > 0) {
849 849
 			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
@@ -857,28 +857,28 @@  discard block
 block discarded – undo
857 857
 		if ($year != '') {
858 858
 			if ($globalDBdriver == 'mysql') {
859 859
 				$query .= " AND YEAR(tracker_output.date) = :year";
860
-				$query_values = array_merge($query_values,array(':year' => $year));
860
+				$query_values = array_merge($query_values, array(':year' => $year));
861 861
 			} else {
862 862
 				$query .= " AND EXTRACT(YEAR FROM tracker_output.date) = :year";
863
-				$query_values = array_merge($query_values,array(':year' => $year));
863
+				$query_values = array_merge($query_values, array(':year' => $year));
864 864
 			}
865 865
 		}
866 866
 		if ($month != '') {
867 867
 			if ($globalDBdriver == 'mysql') {
868 868
 				$query .= " AND MONTH(tracker_output.date) = :month";
869
-				$query_values = array_merge($query_values,array(':month' => $month));
869
+				$query_values = array_merge($query_values, array(':month' => $month));
870 870
 			} else {
871 871
 				$query .= " AND EXTRACT(MONTH FROM tracker_output.date) = :month";
872
-				$query_values = array_merge($query_values,array(':month' => $month));
872
+				$query_values = array_merge($query_values, array(':month' => $month));
873 873
 			}
874 874
 		}
875 875
 		if ($day != '') {
876 876
 			if ($globalDBdriver == 'mysql') {
877 877
 				$query .= " AND DAY(tracker_output.date) = :day";
878
-				$query_values = array_merge($query_values,array(':day' => $day));
878
+				$query_values = array_merge($query_values, array(':day' => $day));
879 879
 			} else {
880 880
 				$query .= " AND EXTRACT(DAY FROM tracker_output.date) = :day";
881
-				$query_values = array_merge($query_values,array(':day' => $day));
881
+				$query_values = array_merge($query_values, array(':day' => $day));
882 882
 			}
883 883
 		}
884 884
 		$query .= " GROUP BY tracker_output.ident ORDER BY callsign_icao_count DESC";
@@ -890,7 +890,7 @@  discard block
 block discarded – undo
890 890
 		$callsign_array = array();
891 891
 		$temp_array = array();
892 892
         
893
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
893
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
894 894
 		{
895 895
 			$temp_array['callsign_icao'] = $row['ident'];
896 896
 			$temp_array['airline_name'] = $row['airline_name'];
@@ -942,7 +942,7 @@  discard block
 block discarded – undo
942 942
 		$date_array = array();
943 943
 		$temp_array = array();
944 944
         
945
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
945
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
946 946
 		{
947 947
 			$temp_array['date_name'] = $row['date_name'];
948 948
 			$temp_array['date_count'] = $row['date_count'];
@@ -968,7 +968,7 @@  discard block
 block discarded – undo
968 968
 			$datetime = new DateTime();
969 969
 			$offset = $datetime->format('P');
970 970
 		} else $offset = '+00:00';
971
-		$filter_query = $this->getFilter($filters,true,true);
971
+		$filter_query = $this->getFilter($filters, true, true);
972 972
 		if ($globalDBdriver == 'mysql') {
973 973
 			$query  = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
974 974
 								FROM tracker_output".$filter_query." tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)";
@@ -989,7 +989,7 @@  discard block
 block discarded – undo
989 989
 		$date_array = array();
990 990
 		$temp_array = array();
991 991
         
992
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
992
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
993 993
 		{
994 994
 			$temp_array['date_name'] = $row['date_name'];
995 995
 			$temp_array['date_count'] = $row['date_count'];
@@ -1014,7 +1014,7 @@  discard block
 block discarded – undo
1014 1014
 			$datetime = new DateTime();
1015 1015
 			$offset = $datetime->format('P');
1016 1016
 		} else $offset = '+00:00';
1017
-		$filter_query = $this->getFilter($filters,true,true);
1017
+		$filter_query = $this->getFilter($filters, true, true);
1018 1018
 		if ($globalDBdriver == 'mysql') {
1019 1019
 			$query  = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
1020 1020
 								FROM tracker_output".$filter_query." tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)";
@@ -1035,7 +1035,7 @@  discard block
 block discarded – undo
1035 1035
 		$date_array = array();
1036 1036
 		$temp_array = array();
1037 1037
         
1038
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1038
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1039 1039
 		{
1040 1040
 			$temp_array['date_name'] = $row['date_name'];
1041 1041
 			$temp_array['date_count'] = $row['date_count'];
@@ -1081,7 +1081,7 @@  discard block
 block discarded – undo
1081 1081
 		$date_array = array();
1082 1082
 		$temp_array = array();
1083 1083
         
1084
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1084
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1085 1085
 		{
1086 1086
 			$temp_array['month_name'] = $row['month_name'];
1087 1087
 			$temp_array['year_name'] = $row['year_name'];
@@ -1108,7 +1108,7 @@  discard block
 block discarded – undo
1108 1108
 			$datetime = new DateTime();
1109 1109
 			$offset = $datetime->format('P');
1110 1110
 		} else $offset = '+00:00';
1111
-		$filter_query = $this->getFilter($filters,true,true);
1111
+		$filter_query = $this->getFilter($filters, true, true);
1112 1112
 		if ($globalDBdriver == 'mysql') {
1113 1113
 			$query  = "SELECT MONTH(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count
1114 1114
 								FROM tracker_output".$filter_query." tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)";
@@ -1129,7 +1129,7 @@  discard block
 block discarded – undo
1129 1129
 		$date_array = array();
1130 1130
 		$temp_array = array();
1131 1131
         
1132
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1132
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1133 1133
 		{
1134 1134
 			$temp_array['year_name'] = $row['year_name'];
1135 1135
 			$temp_array['month_name'] = $row['month_name'];
@@ -1149,7 +1149,7 @@  discard block
 block discarded – undo
1149 1149
      * @param array $filters
1150 1150
      * @return array the hour list
1151 1151
      */
1152
-	public function countAllHours($orderby,$filters = array())
1152
+	public function countAllHours($orderby, $filters = array())
1153 1153
 	{
1154 1154
 		global $globalTimezone, $globalDBdriver;
1155 1155
 		if ($globalTimezone != '') {
@@ -1197,7 +1197,7 @@  discard block
 block discarded – undo
1197 1197
 		$hour_array = array();
1198 1198
 		$temp_array = array();
1199 1199
         
1200
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1200
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1201 1201
 		{
1202 1202
 			$temp_array['hour_name'] = $row['hour_name'];
1203 1203
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1219,8 +1219,8 @@  discard block
 block discarded – undo
1219 1219
 	public function countAllHoursByDate($date, $filters = array())
1220 1220
 	{
1221 1221
 		global $globalTimezone, $globalDBdriver;
1222
-		$filter_query = $this->getFilter($filters,true,true);
1223
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
1222
+		$filter_query = $this->getFilter($filters, true, true);
1223
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
1224 1224
 		if ($globalTimezone != '') {
1225 1225
 			date_default_timezone_set($globalTimezone);
1226 1226
 			$datetime = new DateTime($date);
@@ -1228,12 +1228,12 @@  discard block
 block discarded – undo
1228 1228
 		} else $offset = '+00:00';
1229 1229
 
1230 1230
 		if ($globalDBdriver == 'mysql') {
1231
-			$query  = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1231
+			$query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1232 1232
 								FROM tracker_output".$filter_query." DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) = :date
1233 1233
 								GROUP BY hour_name 
1234 1234
 								ORDER BY hour_name ASC";
1235 1235
 		} else {
1236
-			$query  = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1236
+			$query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1237 1237
 								FROM tracker_output".$filter_query." to_char(tracker_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date
1238 1238
 								GROUP BY hour_name 
1239 1239
 								ORDER BY hour_name ASC";
@@ -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 countAllHoursByIdent($ident, $filters = array())
1268 1268
 	{
1269 1269
 		global $globalTimezone, $globalDBdriver;
1270
-		$filter_query = $this->getFilter($filters,true,true);
1271
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
1270
+		$filter_query = $this->getFilter($filters, true, true);
1271
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1272 1272
 		if ($globalTimezone != '') {
1273 1273
 			date_default_timezone_set($globalTimezone);
1274 1274
 			$datetime = new DateTime();
@@ -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(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1279
+			$query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1280 1280
 								FROM tracker_output".$filter_query." tracker_output.ident = :ident 
1281 1281
 								GROUP BY hour_name 
1282 1282
 								ORDER BY hour_name ASC";
1283 1283
 		} else {
1284
-			$query  = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1284
+			$query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1285 1285
 								FROM tracker_output".$filter_query." tracker_output.ident = :ident 
1286 1286
 								GROUP BY hour_name 
1287 1287
 								ORDER BY hour_name ASC";
@@ -1289,12 +1289,12 @@  discard block
 block discarded – undo
1289 1289
       
1290 1290
 		
1291 1291
 		$sth = $this->db->prepare($query);
1292
-		$sth->execute(array(':ident' => $ident,':offset' => $offset));
1292
+		$sth->execute(array(':ident' => $ident, ':offset' => $offset));
1293 1293
       
1294 1294
 		$hour_array = array();
1295 1295
 		$temp_array = array();
1296 1296
         
1297
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1297
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1298 1298
 		{
1299 1299
 			$temp_array['hour_name'] = $row['hour_name'];
1300 1300
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1314,33 +1314,33 @@  discard block
 block discarded – undo
1314 1314
      * @param string $month
1315 1315
      * @return Integer the number of trackers
1316 1316
      */
1317
-	public function countOverallTracker($filters = array(),$year = '',$month = '')
1317
+	public function countOverallTracker($filters = array(), $year = '', $month = '')
1318 1318
 	{
1319 1319
 		global $globalDBdriver;
1320 1320
 		//$queryi  = "SELECT COUNT(tracker_output.tracker_id) AS flight_count FROM tracker_output";
1321
-		$queryi  = "SELECT COUNT(DISTINCT tracker_output.ident) AS tracker_count FROM tracker_output";
1321
+		$queryi = "SELECT COUNT(DISTINCT tracker_output.ident) AS tracker_count FROM tracker_output";
1322 1322
 		$query_values = array();
1323 1323
 		$query = '';
1324 1324
 		if ($year != '') {
1325 1325
 			if ($globalDBdriver == 'mysql') {
1326 1326
 				$query .= " AND YEAR(tracker_output.date) = :year";
1327
-				$query_values = array_merge($query_values,array(':year' => $year));
1327
+				$query_values = array_merge($query_values, array(':year' => $year));
1328 1328
 			} else {
1329 1329
 				$query .= " AND EXTRACT(YEAR FROM tracker_output.date) = :year";
1330
-				$query_values = array_merge($query_values,array(':year' => $year));
1330
+				$query_values = array_merge($query_values, array(':year' => $year));
1331 1331
 			}
1332 1332
 		}
1333 1333
 		if ($month != '') {
1334 1334
 			if ($globalDBdriver == 'mysql') {
1335 1335
 				$query .= " AND MONTH(tracker_output.date) = :month";
1336
-				$query_values = array_merge($query_values,array(':month' => $month));
1336
+				$query_values = array_merge($query_values, array(':month' => $month));
1337 1337
 			} else {
1338 1338
 				$query .= " AND EXTRACT(MONTH FROM tracker_output.date) = :month";
1339
-				$query_values = array_merge($query_values,array(':month' => $month));
1339
+				$query_values = array_merge($query_values, array(':month' => $month));
1340 1340
 			}
1341 1341
 		}
1342 1342
 		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1343
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1343
+		else $queryi .= $this->getFilter($filters, true, true).substr($query, 4);
1344 1344
 		
1345 1345
 		$sth = $this->db->prepare($queryi);
1346 1346
 		$sth->execute($query_values);
@@ -1355,32 +1355,32 @@  discard block
 block discarded – undo
1355 1355
      * @param string $month
1356 1356
      * @return Integer the number of flights
1357 1357
      */
1358
-	public function countOverallTrackerTypes($filters = array(),$year = '',$month = '')
1358
+	public function countOverallTrackerTypes($filters = array(), $year = '', $month = '')
1359 1359
 	{
1360 1360
 		global $globalDBdriver;
1361
-		$queryi  = "SELECT COUNT(DISTINCT tracker_output.type) AS tracker_count FROM tracker_output";
1361
+		$queryi = "SELECT COUNT(DISTINCT tracker_output.type) AS tracker_count FROM tracker_output";
1362 1362
 		$query_values = array();
1363 1363
 		$query = '';
1364 1364
 		if ($year != '') {
1365 1365
 			if ($globalDBdriver == 'mysql') {
1366 1366
 				$query .= " AND YEAR(tracker_output.date) = :year";
1367
-				$query_values = array_merge($query_values,array(':year' => $year));
1367
+				$query_values = array_merge($query_values, array(':year' => $year));
1368 1368
 			} else {
1369 1369
 				$query .= " AND EXTRACT(YEAR FROM tracker_output.date) = :year";
1370
-				$query_values = array_merge($query_values,array(':year' => $year));
1370
+				$query_values = array_merge($query_values, array(':year' => $year));
1371 1371
 			}
1372 1372
 		}
1373 1373
 		if ($month != '') {
1374 1374
 			if ($globalDBdriver == 'mysql') {
1375 1375
 				$query .= " AND MONTH(tracker_output.date) = :month";
1376
-				$query_values = array_merge($query_values,array(':month' => $month));
1376
+				$query_values = array_merge($query_values, array(':month' => $month));
1377 1377
 			} else {
1378 1378
 				$query .= " AND EXTRACT(MONTH FROM tracker_output.date) = :month";
1379
-				$query_values = array_merge($query_values,array(':month' => $month));
1379
+				$query_values = array_merge($query_values, array(':month' => $month));
1380 1380
 			}
1381 1381
 		}
1382 1382
 		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1383
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1383
+		else $queryi .= $this->getFilter($filters, true, true).substr($query, 4);
1384 1384
 		
1385 1385
 		$sth = $this->db->prepare($queryi);
1386 1386
 		$sth->execute($query_values);
@@ -1397,7 +1397,7 @@  discard block
 block discarded – undo
1397 1397
 	public function countAllHoursFromToday($filters = array())
1398 1398
 	{
1399 1399
 		global $globalTimezone, $globalDBdriver;
1400
-		$filter_query = $this->getFilter($filters,true,true);
1400
+		$filter_query = $this->getFilter($filters, true, true);
1401 1401
 		if ($globalTimezone != '') {
1402 1402
 			date_default_timezone_set($globalTimezone);
1403 1403
 			$datetime = new DateTime();
@@ -1405,12 +1405,12 @@  discard block
 block discarded – undo
1405 1405
 		} else $offset = '+00:00';
1406 1406
 
1407 1407
 		if ($globalDBdriver == 'mysql') {
1408
-			$query  = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1408
+			$query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1409 1409
 								FROM tracker_output".$filter_query." DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) = CURDATE()
1410 1410
 								GROUP BY hour_name 
1411 1411
 								ORDER BY hour_name ASC";
1412 1412
 		} else {
1413
-			$query  = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1413
+			$query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1414 1414
 								FROM tracker_output".$filter_query." to_char(tracker_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date)
1415 1415
 								GROUP BY hour_name 
1416 1416
 								ORDER BY hour_name ASC";
@@ -1422,7 +1422,7 @@  discard block
 block discarded – undo
1422 1422
 		$hour_array = array();
1423 1423
 		$temp_array = array();
1424 1424
         
1425
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1425
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1426 1426
 		{
1427 1427
 			$temp_array['hour_name'] = $row['hour_name'];
1428 1428
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1441,9 +1441,9 @@  discard block
 block discarded – undo
1441 1441
      */
1442 1442
 	public function getTrackerIDBasedOnFamTrackID($famtrackid)
1443 1443
 	{
1444
-		$famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING);
1444
+		$famtrackid = filter_var($famtrackid, FILTER_SANITIZE_STRING);
1445 1445
 
1446
-		$query  = "SELECT tracker_output.tracker_id
1446
+		$query = "SELECT tracker_output.tracker_id
1447 1447
 				FROM tracker_output 
1448 1448
 				WHERE tracker_output.famtrackid = '".$famtrackid."'";
1449 1449
         
@@ -1451,7 +1451,7 @@  discard block
 block discarded – undo
1451 1451
 		$sth = $this->db->prepare($query);
1452 1452
 		$sth->execute();
1453 1453
 
1454
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1454
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1455 1455
 		{
1456 1456
 			return $row['tracker_id'];
1457 1457
 		}
@@ -1476,23 +1476,23 @@  discard block
 block discarded – undo
1476 1476
 		}
1477 1477
 		
1478 1478
 		$current_date = date("Y-m-d H:i:s");
1479
-		$date = date("Y-m-d H:i:s",strtotime($dateString." UTC"));
1479
+		$date = date("Y-m-d H:i:s", strtotime($dateString." UTC"));
1480 1480
 		
1481 1481
 		$diff = abs(strtotime($current_date) - strtotime($date));
1482 1482
 
1483
-		$time_array['years'] = floor($diff / (365*60*60*24)); 
1483
+		$time_array['years'] = floor($diff/(365*60*60*24)); 
1484 1484
 		$years = $time_array['years'];
1485 1485
 		
1486
-		$time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
1486
+		$time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24));
1487 1487
 		$months = $time_array['months'];
1488 1488
 		
1489
-		$time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
1489
+		$time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24));
1490 1490
 		$days = $time_array['days'];
1491
-		$time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60));
1491
+		$time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60));
1492 1492
 		$hours = $time_array['hours'];
1493
-		$time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60);
1493
+		$time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60);
1494 1494
 		$minutes = $time_array['minutes'];
1495
-		$time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
1495
+		$time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
1496 1496
 		
1497 1497
 		return $time_array;
1498 1498
 	}
@@ -1515,63 +1515,63 @@  discard block
 block discarded – undo
1515 1515
 			$temp_array['direction_degree'] = $direction;
1516 1516
 			$temp_array['direction_shortname'] = "N";
1517 1517
 			$temp_array['direction_fullname'] = "North";
1518
-		} elseif ($direction >= 22.5 && $direction < 45){
1518
+		} elseif ($direction >= 22.5 && $direction < 45) {
1519 1519
 			$temp_array['direction_degree'] = $direction;
1520 1520
 			$temp_array['direction_shortname'] = "NNE";
1521 1521
 			$temp_array['direction_fullname'] = "North-Northeast";
1522
-		} elseif ($direction >= 45 && $direction < 67.5){
1522
+		} elseif ($direction >= 45 && $direction < 67.5) {
1523 1523
 			$temp_array['direction_degree'] = $direction;
1524 1524
 			$temp_array['direction_shortname'] = "NE";
1525 1525
 			$temp_array['direction_fullname'] = "Northeast";
1526
-		} elseif ($direction >= 67.5 && $direction < 90){
1526
+		} elseif ($direction >= 67.5 && $direction < 90) {
1527 1527
 			$temp_array['direction_degree'] = $direction;
1528 1528
 			$temp_array['direction_shortname'] = "ENE";
1529 1529
 			$temp_array['direction_fullname'] = "East-Northeast";
1530
-		} elseif ($direction >= 90 && $direction < 112.5){
1530
+		} elseif ($direction >= 90 && $direction < 112.5) {
1531 1531
 			$temp_array['direction_degree'] = $direction;
1532 1532
 			$temp_array['direction_shortname'] = "E";
1533 1533
 			$temp_array['direction_fullname'] = "East";
1534
-		} elseif ($direction >= 112.5 && $direction < 135){
1534
+		} elseif ($direction >= 112.5 && $direction < 135) {
1535 1535
 			$temp_array['direction_degree'] = $direction;
1536 1536
 			$temp_array['direction_shortname'] = "ESE";
1537 1537
 			$temp_array['direction_fullname'] = "East-Southeast";
1538
-		} elseif ($direction >= 135 && $direction < 157.5){
1538
+		} elseif ($direction >= 135 && $direction < 157.5) {
1539 1539
 			$temp_array['direction_degree'] = $direction;
1540 1540
 			$temp_array['direction_shortname'] = "SE";
1541 1541
 			$temp_array['direction_fullname'] = "Southeast";
1542
-		} elseif ($direction >= 157.5 && $direction < 180){
1542
+		} elseif ($direction >= 157.5 && $direction < 180) {
1543 1543
 			$temp_array['direction_degree'] = $direction;
1544 1544
 			$temp_array['direction_shortname'] = "SSE";
1545 1545
 			$temp_array['direction_fullname'] = "South-Southeast";
1546
-		} elseif ($direction >= 180 && $direction < 202.5){
1546
+		} elseif ($direction >= 180 && $direction < 202.5) {
1547 1547
 			$temp_array['direction_degree'] = $direction;
1548 1548
 			$temp_array['direction_shortname'] = "S";
1549 1549
 			$temp_array['direction_fullname'] = "South";
1550
-		} elseif ($direction >= 202.5 && $direction < 225){
1550
+		} elseif ($direction >= 202.5 && $direction < 225) {
1551 1551
 			$temp_array['direction_degree'] = $direction;
1552 1552
 			$temp_array['direction_shortname'] = "SSW";
1553 1553
 			$temp_array['direction_fullname'] = "South-Southwest";
1554
-		} elseif ($direction >= 225 && $direction < 247.5){
1554
+		} elseif ($direction >= 225 && $direction < 247.5) {
1555 1555
 			$temp_array['direction_degree'] = $direction;
1556 1556
 			$temp_array['direction_shortname'] = "SW";
1557 1557
 			$temp_array['direction_fullname'] = "Southwest";
1558
-		} elseif ($direction >= 247.5 && $direction < 270){
1558
+		} elseif ($direction >= 247.5 && $direction < 270) {
1559 1559
 			$temp_array['direction_degree'] = $direction;
1560 1560
 			$temp_array['direction_shortname'] = "WSW";
1561 1561
 			$temp_array['direction_fullname'] = "West-Southwest";
1562
-		} elseif ($direction >= 270 && $direction < 292.5){
1562
+		} elseif ($direction >= 270 && $direction < 292.5) {
1563 1563
 			$temp_array['direction_degree'] = $direction;
1564 1564
 			$temp_array['direction_shortname'] = "W";
1565 1565
 			$temp_array['direction_fullname'] = "West";
1566
-		} elseif ($direction >= 292.5 && $direction < 315){
1566
+		} elseif ($direction >= 292.5 && $direction < 315) {
1567 1567
 			$temp_array['direction_degree'] = $direction;
1568 1568
 			$temp_array['direction_shortname'] = "WNW";
1569 1569
 			$temp_array['direction_fullname'] = "West-Northwest";
1570
-		} elseif ($direction >= 315 && $direction < 337.5){
1570
+		} elseif ($direction >= 315 && $direction < 337.5) {
1571 1571
 			$temp_array['direction_degree'] = $direction;
1572 1572
 			$temp_array['direction_shortname'] = "NW";
1573 1573
 			$temp_array['direction_fullname'] = "Northwest";
1574
-		} elseif ($direction >= 337.5 && $direction < 360){
1574
+		} elseif ($direction >= 337.5 && $direction < 360) {
1575 1575
 			$temp_array['direction_degree'] = $direction;
1576 1576
 			$temp_array['direction_shortname'] = "NNW";
1577 1577
 			$temp_array['direction_fullname'] = "North-Northwest";
@@ -1588,11 +1588,11 @@  discard block
 block discarded – undo
1588 1588
 	* @param Float $longitude longitute of the flight
1589 1589
 	* @return String the countrie
1590 1590
 	*/
1591
-	public function getCountryFromLatitudeLongitude($latitude,$longitude)
1591
+	public function getCountryFromLatitudeLongitude($latitude, $longitude)
1592 1592
 	{
1593 1593
 		global $globalDebug;
1594
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1595
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1594
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1595
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1596 1596
 	
1597 1597
 		$Connection = new Connection($this->db);
1598 1598
 		if (!$Connection->tableExists('countries')) return '';
@@ -1623,7 +1623,7 @@  discard block
 block discarded – undo
1623 1623
 	public function getCountryFromISO2($iso2)
1624 1624
 	{
1625 1625
 		global $globalDebug;
1626
-		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
1626
+		$iso2 = filter_var($iso2, FILTER_SANITIZE_STRING);
1627 1627
 	
1628 1628
 		$Connection = new Connection($this->db);
1629 1629
 		if (!$Connection->tableExists('countries')) return '';
@@ -1658,11 +1658,11 @@  discard block
 block discarded – undo
1658 1658
      * @param string $day
1659 1659
      * @return array the vessel type list
1660 1660
      */
1661
-	public function countAllTrackerTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
1661
+	public function countAllTrackerTypes($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
1662 1662
 	{
1663 1663
 		global $globalDBdriver;
1664
-		$filter_query = $this->getFilter($filters,true,true);
1665
-		$query  = "SELECT tracker_output.type AS tracker_type, COUNT(tracker_output.type) AS tracker_type_count 
1664
+		$filter_query = $this->getFilter($filters, true, true);
1665
+		$query = "SELECT tracker_output.type AS tracker_type, COUNT(tracker_output.type) AS tracker_type_count 
1666 1666
 		    FROM tracker_output ".$filter_query." tracker_output.type  <> ''";
1667 1667
 		if ($olderthanmonths > 0) {
1668 1668
 			if ($globalDBdriver == 'mysql') {
@@ -1682,28 +1682,28 @@  discard block
 block discarded – undo
1682 1682
 		if ($year != '') {
1683 1683
 			if ($globalDBdriver == 'mysql') {
1684 1684
 				$query .= " AND YEAR(tracker_output.date) = :year";
1685
-				$query_values = array_merge($query_values,array(':year' => $year));
1685
+				$query_values = array_merge($query_values, array(':year' => $year));
1686 1686
 			} else {
1687 1687
 				$query .= " AND EXTRACT(YEAR FROM tracker_output.date) = :year";
1688
-				$query_values = array_merge($query_values,array(':year' => $year));
1688
+				$query_values = array_merge($query_values, array(':year' => $year));
1689 1689
 			}
1690 1690
 		}
1691 1691
 		if ($month != '') {
1692 1692
 			if ($globalDBdriver == 'mysql') {
1693 1693
 				$query .= " AND MONTH(tracker_output.date) = :month";
1694
-				$query_values = array_merge($query_values,array(':month' => $month));
1694
+				$query_values = array_merge($query_values, array(':month' => $month));
1695 1695
 			} else {
1696 1696
 				$query .= " AND EXTRACT(MONTH FROM tracker_output.date) = :month";
1697
-				$query_values = array_merge($query_values,array(':month' => $month));
1697
+				$query_values = array_merge($query_values, array(':month' => $month));
1698 1698
 			}
1699 1699
 		}
1700 1700
 		if ($day != '') {
1701 1701
 			if ($globalDBdriver == 'mysql') {
1702 1702
 				$query .= " AND DAY(tracker_output.date) = :day";
1703
-				$query_values = array_merge($query_values,array(':day' => $day));
1703
+				$query_values = array_merge($query_values, array(':day' => $day));
1704 1704
 			} else {
1705 1705
 				$query .= " AND EXTRACT(DAY FROM tracker_output.date) = :day";
1706
-				$query_values = array_merge($query_values,array(':day' => $day));
1706
+				$query_values = array_merge($query_values, array(':day' => $day));
1707 1707
 			}
1708 1708
 		}
1709 1709
 		$query .= " GROUP BY tracker_output.type ORDER BY tracker_type_count DESC";
@@ -1712,7 +1712,7 @@  discard block
 block discarded – undo
1712 1712
 		$sth->execute($query_values);
1713 1713
 		$tracker_array = array();
1714 1714
 		$temp_array = array();
1715
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1715
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1716 1716
 		{
1717 1717
 			$temp_array['tracker_type'] = $row['tracker_type'];
1718 1718
 			$temp_array['tracker_type_count'] = $row['tracker_type_count'];
@@ -1736,13 +1736,13 @@  discard block
 block discarded – undo
1736 1736
      * @param array $filters
1737 1737
      * @return array the tracker information
1738 1738
      */
1739
-	public function searchTrackerData($q = '', $callsign = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '',$filters = array())
1739
+	public function searchTrackerData($q = '', $callsign = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array())
1740 1740
 	{
1741 1741
 		global $globalTimezone, $globalDBdriver;
1742 1742
 		date_default_timezone_set('UTC');
1743 1743
 		$query_values = array();
1744 1744
 		$additional_query = '';
1745
-		$filter_query = $this->getFilter($filters,true,true);
1745
+		$filter_query = $this->getFilter($filters, true, true);
1746 1746
 		if ($q != "")
1747 1747
 		{
1748 1748
 			if (!is_string($q))
@@ -1750,8 +1750,8 @@  discard block
 block discarded – undo
1750 1750
 				return array();
1751 1751
 			} else {
1752 1752
 				$q_array = explode(" ", $q);
1753
-				foreach ($q_array as $q_item){
1754
-					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
1753
+				foreach ($q_array as $q_item) {
1754
+					$q_item = filter_var($q_item, FILTER_SANITIZE_STRING);
1755 1755
 					$additional_query .= " AND (";
1756 1756
 					if (is_int($q_item)) $additional_query .= "(tracker_output.tracker_id = '".$q_item."') OR ";
1757 1757
 					$additional_query .= "(tracker_output.ident like '%".$q_item."%') OR ";
@@ -1761,20 +1761,20 @@  discard block
 block discarded – undo
1761 1761
 		}
1762 1762
 		if ($callsign != "")
1763 1763
 		{
1764
-			$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
1764
+			$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
1765 1765
 			if (!is_string($callsign))
1766 1766
 			{
1767 1767
 				return array();
1768 1768
 			} else {
1769 1769
 				$additional_query .= " AND tracker_output.ident = :callsign";
1770
-				$query_values = array_merge($query_values,array(':callsign' => $callsign));
1770
+				$query_values = array_merge($query_values, array(':callsign' => $callsign));
1771 1771
 			}
1772 1772
 		}
1773 1773
 		if ($date_posted != "")
1774 1774
 		{
1775 1775
 			$date_array = explode(",", $date_posted);
1776
-			$date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
1777
-			$date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
1776
+			$date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING);
1777
+			$date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING);
1778 1778
 			if ($globalTimezone != '') {
1779 1779
 				date_default_timezone_set($globalTimezone);
1780 1780
 				$datetime = new DateTime();
@@ -1801,8 +1801,8 @@  discard block
 block discarded – undo
1801 1801
 		if ($limit != "")
1802 1802
 		{
1803 1803
 			$limit_array = explode(",", $limit);
1804
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1805
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1804
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1805
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1806 1806
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1807 1807
 			{
1808 1808
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
@@ -1820,22 +1820,22 @@  discard block
 block discarded – undo
1820 1820
 			}
1821 1821
 		}
1822 1822
 		if ($origLat != "" && $origLon != "" && $dist != "") {
1823
-			$dist = number_format($dist*0.621371,2,'.',''); // convert km to mile
1823
+			$dist = number_format($dist*0.621371, 2, '.', ''); // convert km to mile
1824 1824
 			if ($globalDBdriver == 'mysql') {
1825
-				$query="SELECT tracker_output.*, 1.60935*3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - tracker_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(tracker_archive.latitude*pi()/180)*POWER(SIN(($origLon-tracker_archive.longitude)*pi()/180/2),2))) as distance 
1825
+				$query = "SELECT tracker_output.*, 1.60935*3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - tracker_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(tracker_archive.latitude*pi()/180)*POWER(SIN(($origLon-tracker_archive.longitude)*pi()/180/2),2))) as distance 
1826 1826
 				    FROM tracker_archive,tracker_output".$filter_query." tracker_output.famtrackid = tracker_archive.famtrackid AND tracker_output.ident <> '' ".$additional_query."AND tracker_archive.longitude between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat)*69)) and tracker_archive.latitude between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
1827 1827
 				    AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - tracker_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(tracker_archive.latitude*pi()/180)*POWER(SIN(($origLon-tracker_archive.longitude)*pi()/180/2),2)))) < $dist".$orderby_query;
1828 1828
 			} else {
1829
-				$query="SELECT tracker_output.*, 1.60935 * 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(tracker_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(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 
1829
+				$query = "SELECT tracker_output.*, 1.60935 * 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(tracker_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(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 
1830 1830
 				    FROM tracker_archive,tracker_output".$filter_query." tracker_output.famtrackid = tracker_archive.famtrackid AND tracker_output.ident <> '' ".$additional_query."AND CAST(tracker_archive.longitude as double precision) between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat))*69) and CAST(tracker_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
1831 1831
 				    AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(tracker_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(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.$orderby_query;
1832 1832
 			}
1833 1833
 		} else {
1834
-			$query  = "SELECT tracker_output.* FROM tracker_output".$filter_query." tracker_output.ident <> '' 
1834
+			$query = "SELECT tracker_output.* FROM tracker_output".$filter_query." tracker_output.ident <> '' 
1835 1835
 			    ".$additional_query."
1836 1836
 			    ".$orderby_query;
1837 1837
 		}
1838
-		$tracker_array = $this->getDataFromDB($query, $query_values,$limit_query);
1838
+		$tracker_array = $this->getDataFromDB($query, $query_values, $limit_query);
1839 1839
 		return $tracker_array;
1840 1840
 	}
1841 1841
 
@@ -1860,7 +1860,7 @@  discard block
 block discarded – undo
1860 1860
 		curl_close($ch);
1861 1861
 		$bitly_data = json_decode($bitly_data);
1862 1862
 		$bitly_url = '';
1863
-		if ($bitly_data->status_txt = "OK"){
1863
+		if ($bitly_data->status_txt = "OK") {
1864 1864
 			$bitly_url = $bitly_data->data->url;
1865 1865
 		}
1866 1866
 		return $bitly_url;
@@ -1868,7 +1868,7 @@  discard block
 block discarded – undo
1868 1868
 
1869 1869
 	public function getOrderBy()
1870 1870
 	{
1871
-		$orderby = array("type_asc" => array("key" => "type_asc", "value" => "Type - ASC", "sql" => "ORDER BY tracker_output.type ASC"), "type_desc" => array("key" => "type_desc", "value" => "Type - DESC", "sql" => "ORDER BY tracker_output.type DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_output.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_output.date DESC"),"distance_asc" => array("key" => "distance_asc","value" => "Distance - ASC","sql" => "ORDER BY distance ASC"),"distance_desc" => array("key" => "distance_desc","value" => "Distance - DESC","sql" => "ORDER BY distance DESC"));
1871
+		$orderby = array("type_asc" => array("key" => "type_asc", "value" => "Type - ASC", "sql" => "ORDER BY tracker_output.type ASC"), "type_desc" => array("key" => "type_desc", "value" => "Type - DESC", "sql" => "ORDER BY tracker_output.type DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_output.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_output.date DESC"), "distance_asc" => array("key" => "distance_asc", "value" => "Distance - ASC", "sql" => "ORDER BY distance ASC"), "distance_desc" => array("key" => "distance_desc", "value" => "Distance - DESC", "sql" => "ORDER BY distance DESC"));
1872 1872
 		
1873 1873
 		return $orderby;
1874 1874
 		
Please login to merge, or discard this patch.
Braces   +172 added lines, -61 removed lines patch added patch discarded remove patch
@@ -17,7 +17,9 @@  discard block
 block discarded – undo
17 17
 	public function __construct($dbc = null) {
18 18
 		$Connection = new Connection($dbc);
19 19
 		$this->db = $Connection->db();
20
-		if ($this->db === null) die('Error: No DB connection. (Tracker)');
20
+		if ($this->db === null) {
21
+			die('Error: No DB connection. (Tracker)');
22
+		}
21 23
 	}
22 24
 
23 25
     /**
@@ -41,7 +43,9 @@  discard block
 block discarded – undo
41 43
 		if (isset($filter[0]['source'])) {
42 44
 			$filters = array_merge($filters,$filter);
43 45
 		}
44
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
46
+		if (is_array($globalFilter)) {
47
+			$filter = array_merge($filter,$globalFilter);
48
+		}
45 49
 		$filter_query_join = '';
46 50
 		$filter_query_where = '';
47 51
 		foreach($filters as $flt) {
@@ -83,8 +87,11 @@  discard block
 block discarded – undo
83 87
 				$filter_query_where .= " AND EXTRACT(DAY FROM tracker_output.date) = '".$filter['day']."'";
84 88
 			}
85 89
 		}
86
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
87
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
90
+		if ($filter_query_where == '' && $where) {
91
+			$filter_query_where = ' WHERE';
92
+		} elseif ($filter_query_where != '' && $and) {
93
+			$filter_query_where .= ' AND';
94
+		}
88 95
 		if ($filter_query_where != '') {
89 96
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
90 97
 		}
@@ -138,26 +145,43 @@  discard block
 block discarded – undo
138 145
 				$temp_array['tracker_id'] = $row['tracker_archive_id'];
139 146
 			} elseif (isset($row['tracker_archive_output_id'])) {
140 147
 				$temp_array['tracker_id'] = $row['tracker_archive_output_id'];
141
-			*/} 
142
-			elseif (isset($row['trackerid'])) {
148
+			*/} elseif (isset($row['trackerid'])) {
143 149
 				$temp_array['trackerid'] = $row['trackerid'];
144 150
 			} else {
145 151
 				$temp_array['trackerid'] = '';
146 152
 			}
147
-			if (isset($row['famtrackid'])) $temp_array['famtrackid'] = $row['famtrackid'];
148
-			if (isset($row['type'])) $temp_array['type'] = $row['type'];
149
-			if (isset($row['comment'])) $temp_array['comment'] = $row['comment'];
153
+			if (isset($row['famtrackid'])) {
154
+				$temp_array['famtrackid'] = $row['famtrackid'];
155
+			}
156
+			if (isset($row['type'])) {
157
+				$temp_array['type'] = $row['type'];
158
+			}
159
+			if (isset($row['comment'])) {
160
+				$temp_array['comment'] = $row['comment'];
161
+			}
150 162
 			$temp_array['ident'] = $row['ident'];
151
-			if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude'];
152
-			if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude'];
153
-			if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source'];
154
-			if (isset($row['altitude'])) $temp_array['altitude'] = $row['altitude'];
163
+			if (isset($row['latitude'])) {
164
+				$temp_array['latitude'] = $row['latitude'];
165
+			}
166
+			if (isset($row['longitude'])) {
167
+				$temp_array['longitude'] = $row['longitude'];
168
+			}
169
+			if (isset($row['format_source'])) {
170
+				$temp_array['format_source'] = $row['format_source'];
171
+			}
172
+			if (isset($row['altitude'])) {
173
+				$temp_array['altitude'] = $row['altitude'];
174
+			}
155 175
 			if (isset($row['heading'])) {
156 176
 				$temp_array['heading'] = $row['heading'];
157 177
 				$heading_direction = $this->parseDirection($row['heading']);
158
-				if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
178
+				if (isset($heading_direction[0]['direction_fullname'])) {
179
+					$temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
180
+				}
181
+			}
182
+			if (isset($row['ground_speed'])) {
183
+				$temp_array['ground_speed'] = $row['ground_speed'];
159 184
 			}
160
-			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];
161 185
 			
162 186
 			if (isset($row['date'])) {
163 187
 				$dateArray = $this->parseDateString($row['date']);
@@ -200,13 +224,21 @@  discard block
 block discarded – undo
200 224
 			}
201 225
 			
202 226
 			$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'];
227
+			if (isset($row['source_name']) && $row['source_name'] != '') {
228
+				$temp_array['source_name'] = $row['source_name'];
229
+			}
230
+			if (isset($row['over_country']) && $row['over_country'] != '') {
231
+				$temp_array['over_country'] = $row['over_country'];
232
+			}
233
+			if (isset($row['distance']) && $row['distance'] != '') {
234
+				$temp_array['distance'] = $row['distance'];
235
+			}
206 236
 			$temp_array['query_number_rows'] = $num_rows;
207 237
 			$tracker_array[] = $temp_array;
208 238
 		}
209
-		if ($num_rows == 0) return array();
239
+		if ($num_rows == 0) {
240
+			return array();
241
+		}
210 242
 		$tracker_array[0]['query_number_rows'] = $num_rows;
211 243
 		return $tracker_array;
212 244
 	}
@@ -239,8 +271,12 @@  discard block
 block discarded – undo
239 271
 			{
240 272
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
241 273
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
242
-			} else $limit_query = "";
243
-		} else $limit_query = "";
274
+			} else {
275
+				$limit_query = "";
276
+			}
277
+		} else {
278
+			$limit_query = "";
279
+		}
244 280
 		
245 281
 		if ($sort != "")
246 282
 		{
@@ -268,7 +304,9 @@  discard block
 block discarded – undo
268 304
 		global $global_tracker_query;
269 305
 		
270 306
 		date_default_timezone_set('UTC');
271
-		if ($id == '') return array();
307
+		if ($id == '') {
308
+			return array();
309
+		}
272 310
 		$additional_query = "tracker_output.famtrackid = :id";
273 311
 		$query_values = array(':id' => $id);
274 312
 		$query  = $global_tracker_query." WHERE ".$additional_query." ";
@@ -413,8 +451,11 @@  discard block
 block discarded – undo
413 451
 		$query .= " ORDER BY tracker_output.source_name ASC";
414 452
 
415 453
 		$sth = $this->db->prepare($query);
416
-		if (!empty($query_values)) $sth->execute($query_values);
417
-		else $sth->execute();
454
+		if (!empty($query_values)) {
455
+			$sth->execute($query_values);
456
+		} else {
457
+			$sth->execute();
458
+		}
418 459
 
419 460
 		$source_array = array();
420 461
 		$temp_array = array();
@@ -469,7 +510,9 @@  discard block
 block discarded – undo
469 510
 			date_default_timezone_set($globalTimezone);
470 511
 			$datetime = new DateTime();
471 512
 			$offset = $datetime->format('P');
472
-		} else $offset = '+00:00';
513
+		} else {
514
+			$offset = '+00:00';
515
+		}
473 516
 
474 517
 		if ($globalDBdriver == 'mysql') {
475 518
 			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) as date
@@ -617,7 +660,9 @@  discard block
 block discarded – undo
617 660
 			{
618 661
 				return false;
619 662
 			}
620
-		} else $altitude = 0;
663
+		} else {
664
+			$altitude = 0;
665
+		}
621 666
 		
622 667
 		if ($heading != "")
623 668
 		{
@@ -656,8 +701,12 @@  discard block
 block discarded – undo
656 701
             		$latitude = 0;
657 702
             		$longitude = 0;
658 703
             	}
659
-                if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
660
-                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
704
+                if ($heading == '' || $Common->isInteger($heading) === false) {
705
+                	$heading = 0;
706
+                }
707
+                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) {
708
+                	$groundspeed = 0;
709
+                }
661 710
                 $query  = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) 
662 711
                 VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:speed,:date,:format_source, :source_name,:comment,:type)";
663 712
 
@@ -764,7 +813,9 @@  discard block
 block discarded – undo
764 813
 		global $globalDBdriver, $globalArchive;
765 814
 		//$filter_query = $this->getFilter($filters,true,true);
766 815
 		$Connection= new Connection($this->db);
767
-		if (!$Connection->tableExists('countries')) return array();
816
+		if (!$Connection->tableExists('countries')) {
817
+			return array();
818
+		}
768 819
 		if (!isset($globalArchive) || $globalArchive !== TRUE) {
769 820
 			require_once('class.TrackerLive.php');
770 821
 			$TrackerLive = new TrackerLive($this->db);
@@ -807,7 +858,9 @@  discard block
 block discarded – undo
807 858
 			$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb FROM countries c INNER JOIN (SELECT DISTINCT famtrackid,over_country FROM tracker_archive".$filter_query.") l ON c.iso2 = l.over_country ";
808 859
 		}
809 860
 		$query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC";
810
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
861
+		if ($limit) {
862
+			$query .= " LIMIT 10 OFFSET 0";
863
+		}
811 864
       
812 865
 		
813 866
 		$sth = $this->db->prepare($query);
@@ -846,12 +899,18 @@  discard block
 block discarded – undo
846 899
 		$query  = "SELECT DISTINCT tracker_output.ident, COUNT(tracker_output.ident) AS callsign_icao_count 
847 900
                     FROM tracker_output".$filter_query." tracker_output.ident <> ''";
848 901
 		 if ($olderthanmonths > 0) {
849
-			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
850
-			else $query .= " AND tracker_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
902
+			if ($globalDBdriver == 'mysql') {
903
+				$query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
904
+			} else {
905
+				$query .= " AND tracker_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
906
+			}
851 907
 		}
852 908
 		if ($sincedate != '') {
853
-			if ($globalDBdriver == 'mysql') $query .= " AND tracker_output.date > '".$sincedate."'";
854
-			else $query .= " AND tracker_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
909
+			if ($globalDBdriver == 'mysql') {
910
+				$query .= " AND tracker_output.date > '".$sincedate."'";
911
+			} else {
912
+				$query .= " AND tracker_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
913
+			}
855 914
 		}
856 915
 		$query_values = array();
857 916
 		if ($year != '') {
@@ -882,7 +941,9 @@  discard block
 block discarded – undo
882 941
 			}
883 942
 		}
884 943
 		$query .= " GROUP BY tracker_output.ident ORDER BY callsign_icao_count DESC";
885
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
944
+		if ($limit) {
945
+			$query .= " LIMIT 10 OFFSET 0";
946
+		}
886 947
       		
887 948
 		$sth = $this->db->prepare($query);
888 949
 		$sth->execute($query_values);
@@ -917,7 +978,9 @@  discard block
 block discarded – undo
917 978
 			date_default_timezone_set($globalTimezone);
918 979
 			$datetime = new DateTime();
919 980
 			$offset = $datetime->format('P');
920
-		} else $offset = '+00:00';
981
+		} else {
982
+			$offset = '+00:00';
983
+		}
921 984
 
922 985
 		if ($globalDBdriver == 'mysql') {
923 986
 			$query  = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -967,7 +1030,9 @@  discard block
 block discarded – undo
967 1030
 			date_default_timezone_set($globalTimezone);
968 1031
 			$datetime = new DateTime();
969 1032
 			$offset = $datetime->format('P');
970
-		} else $offset = '+00:00';
1033
+		} else {
1034
+			$offset = '+00:00';
1035
+		}
971 1036
 		$filter_query = $this->getFilter($filters,true,true);
972 1037
 		if ($globalDBdriver == 'mysql') {
973 1038
 			$query  = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1013,7 +1078,9 @@  discard block
 block discarded – undo
1013 1078
 			date_default_timezone_set($globalTimezone);
1014 1079
 			$datetime = new DateTime();
1015 1080
 			$offset = $datetime->format('P');
1016
-		} else $offset = '+00:00';
1081
+		} else {
1082
+			$offset = '+00:00';
1083
+		}
1017 1084
 		$filter_query = $this->getFilter($filters,true,true);
1018 1085
 		if ($globalDBdriver == 'mysql') {
1019 1086
 			$query  = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1060,7 +1127,9 @@  discard block
 block discarded – undo
1060 1127
 			date_default_timezone_set($globalTimezone);
1061 1128
 			$datetime = new DateTime();
1062 1129
 			$offset = $datetime->format('P');
1063
-		} else $offset = '+00:00';
1130
+		} else {
1131
+			$offset = '+00:00';
1132
+		}
1064 1133
 
1065 1134
 		if ($globalDBdriver == 'mysql') {
1066 1135
 			$query  = "SELECT YEAR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
@@ -1107,7 +1176,9 @@  discard block
 block discarded – undo
1107 1176
 			date_default_timezone_set($globalTimezone);
1108 1177
 			$datetime = new DateTime();
1109 1178
 			$offset = $datetime->format('P');
1110
-		} else $offset = '+00:00';
1179
+		} else {
1180
+			$offset = '+00:00';
1181
+		}
1111 1182
 		$filter_query = $this->getFilter($filters,true,true);
1112 1183
 		if ($globalDBdriver == 'mysql') {
1113 1184
 			$query  = "SELECT MONTH(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count
@@ -1156,7 +1227,9 @@  discard block
 block discarded – undo
1156 1227
 			date_default_timezone_set($globalTimezone);
1157 1228
 			$datetime = new DateTime();
1158 1229
 			$offset = $datetime->format('P');
1159
-		} else $offset = '+00:00';
1230
+		} else {
1231
+			$offset = '+00:00';
1232
+		}
1160 1233
 
1161 1234
 		$orderby_sql = '';
1162 1235
 		if ($orderby == "hour")
@@ -1225,7 +1298,9 @@  discard block
 block discarded – undo
1225 1298
 			date_default_timezone_set($globalTimezone);
1226 1299
 			$datetime = new DateTime($date);
1227 1300
 			$offset = $datetime->format('P');
1228
-		} else $offset = '+00:00';
1301
+		} else {
1302
+			$offset = '+00:00';
1303
+		}
1229 1304
 
1230 1305
 		if ($globalDBdriver == 'mysql') {
1231 1306
 			$query  = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1273,7 +1348,9 @@  discard block
 block discarded – undo
1273 1348
 			date_default_timezone_set($globalTimezone);
1274 1349
 			$datetime = new DateTime();
1275 1350
 			$offset = $datetime->format('P');
1276
-		} else $offset = '+00:00';
1351
+		} else {
1352
+			$offset = '+00:00';
1353
+		}
1277 1354
 
1278 1355
 		if ($globalDBdriver == 'mysql') {
1279 1356
 			$query  = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1339,8 +1416,11 @@  discard block
 block discarded – undo
1339 1416
 				$query_values = array_merge($query_values,array(':month' => $month));
1340 1417
 			}
1341 1418
 		}
1342
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1343
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1419
+		if (empty($query_values)) {
1420
+			$queryi .= $this->getFilter($filters);
1421
+		} else {
1422
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
1423
+		}
1344 1424
 		
1345 1425
 		$sth = $this->db->prepare($queryi);
1346 1426
 		$sth->execute($query_values);
@@ -1379,8 +1459,11 @@  discard block
 block discarded – undo
1379 1459
 				$query_values = array_merge($query_values,array(':month' => $month));
1380 1460
 			}
1381 1461
 		}
1382
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1383
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1462
+		if (empty($query_values)) {
1463
+			$queryi .= $this->getFilter($filters);
1464
+		} else {
1465
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
1466
+		}
1384 1467
 		
1385 1468
 		$sth = $this->db->prepare($queryi);
1386 1469
 		$sth->execute($query_values);
@@ -1402,7 +1485,9 @@  discard block
 block discarded – undo
1402 1485
 			date_default_timezone_set($globalTimezone);
1403 1486
 			$datetime = new DateTime();
1404 1487
 			$offset = $datetime->format('P');
1405
-		} else $offset = '+00:00';
1488
+		} else {
1489
+			$offset = '+00:00';
1490
+		}
1406 1491
 
1407 1492
 		if ($globalDBdriver == 'mysql') {
1408 1493
 			$query  = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1506,7 +1591,9 @@  discard block
 block discarded – undo
1506 1591
 	*/
1507 1592
 	public function parseDirection($direction = 0)
1508 1593
 	{
1509
-		if ($direction == '') $direction = 0;
1594
+		if ($direction == '') {
1595
+			$direction = 0;
1596
+		}
1510 1597
 		$direction_array = array();
1511 1598
 		$temp_array = array();
1512 1599
 
@@ -1595,7 +1682,9 @@  discard block
 block discarded – undo
1595 1682
 		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1596 1683
 	
1597 1684
 		$Connection = new Connection($this->db);
1598
-		if (!$Connection->tableExists('countries')) return '';
1685
+		if (!$Connection->tableExists('countries')) {
1686
+			return '';
1687
+		}
1599 1688
 	
1600 1689
 		try {
1601 1690
 			$query = "SELECT name,iso2,iso3 FROM countries WHERE ST_Within(ST_GeomFromText('POINT(".$longitude." ".$latitude.")',4326), ogc_geom) LIMIT 1";
@@ -1606,9 +1695,13 @@  discard block
 block discarded – undo
1606 1695
 			$sth->closeCursor();
1607 1696
 			if (count($row) > 0) {
1608 1697
 				return $row;
1609
-			} else return '';
1698
+			} else {
1699
+				return '';
1700
+			}
1610 1701
 		} catch (PDOException $e) {
1611
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
1702
+			if (isset($globalDebug) && $globalDebug) {
1703
+				echo 'Error : '.$e->getMessage()."\n";
1704
+			}
1612 1705
 			return '';
1613 1706
 		}
1614 1707
 	
@@ -1626,7 +1719,9 @@  discard block
 block discarded – undo
1626 1719
 		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
1627 1720
 	
1628 1721
 		$Connection = new Connection($this->db);
1629
-		if (!$Connection->tableExists('countries')) return '';
1722
+		if (!$Connection->tableExists('countries')) {
1723
+			return '';
1724
+		}
1630 1725
 	
1631 1726
 		try {
1632 1727
 			$query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1";
@@ -1638,9 +1733,13 @@  discard block
 block discarded – undo
1638 1733
 			$sth->closeCursor();
1639 1734
 			if (count($row) > 0) {
1640 1735
 				return $row;
1641
-			} else return '';
1736
+			} else {
1737
+				return '';
1738
+			}
1642 1739
 		} catch (PDOException $e) {
1643
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
1740
+			if (isset($globalDebug) && $globalDebug) {
1741
+				echo 'Error : '.$e->getMessage()."\n";
1742
+			}
1644 1743
 			return '';
1645 1744
 		}
1646 1745
 	
@@ -1707,7 +1806,9 @@  discard block
 block discarded – undo
1707 1806
 			}
1708 1807
 		}
1709 1808
 		$query .= " GROUP BY tracker_output.type ORDER BY tracker_type_count DESC";
1710
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
1809
+		if ($limit) {
1810
+			$query .= " LIMIT 10 OFFSET 0";
1811
+		}
1711 1812
 		$sth = $this->db->prepare($query);
1712 1813
 		$sth->execute($query_values);
1713 1814
 		$tracker_array = array();
@@ -1753,7 +1854,9 @@  discard block
 block discarded – undo
1753 1854
 				foreach ($q_array as $q_item){
1754 1855
 					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
1755 1856
 					$additional_query .= " AND (";
1756
-					if (is_int($q_item)) $additional_query .= "(tracker_output.tracker_id = '".$q_item."') OR ";
1857
+					if (is_int($q_item)) {
1858
+						$additional_query .= "(tracker_output.tracker_id = '".$q_item."') OR ";
1859
+					}
1757 1860
 					$additional_query .= "(tracker_output.ident like '%".$q_item."%') OR ";
1758 1861
 					$additional_query .= ")";
1759 1862
 				}
@@ -1779,7 +1882,9 @@  discard block
 block discarded – undo
1779 1882
 				date_default_timezone_set($globalTimezone);
1780 1883
 				$datetime = new DateTime();
1781 1884
 				$offset = $datetime->format('P');
1782
-			} else $offset = '+00:00';
1885
+			} else {
1886
+				$offset = '+00:00';
1887
+			}
1783 1888
 			if ($date_array[1] != "")
1784 1889
 			{
1785 1890
 				$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
@@ -1806,8 +1911,12 @@  discard block
 block discarded – undo
1806 1911
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1807 1912
 			{
1808 1913
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1809
-			} else $limit_query = "";
1810
-		} else $limit_query = "";
1914
+			} else {
1915
+				$limit_query = "";
1916
+			}
1917
+		} else {
1918
+			$limit_query = "";
1919
+		}
1811 1920
 		if ($sort != "")
1812 1921
 		{
1813 1922
 			$search_orderby_array = $this->getOrderBy();
@@ -1850,7 +1959,9 @@  discard block
 block discarded – undo
1850 1959
 	{
1851 1960
 		global $globalBitlyAccessToken;
1852 1961
 		
1853
-		if ($globalBitlyAccessToken == '') return $url;
1962
+		if ($globalBitlyAccessToken == '') {
1963
+			return $url;
1964
+		}
1854 1965
 		$google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url;
1855 1966
 		$ch = curl_init();
1856 1967
 		curl_setopt($ch, CURLOPT_HEADER, 0);
Please login to merge, or discard this patch.
require/class.NOTAM.php 1 patch
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -988,7 +988,7 @@  discard block
 block discarded – undo
988 988
 		try {
989 989
 			$sth = $this->db->prepare($query);
990 990
 			$sth->execute($query_values);
991
-		} catch(PDOException $e) {
991
+		} catch (PDOException $e) {
992 992
 			echo "error : ".$e->getMessage();
993 993
 			return array();
994 994
 		}
@@ -1006,7 +1006,7 @@  discard block
 block discarded – undo
1006 1006
 		try {
1007 1007
 			$sth = $this->db->prepare($query);
1008 1008
 			$sth->execute($query_values);
1009
-		} catch(PDOException $e) {
1009
+		} catch (PDOException $e) {
1010 1010
 			echo "error : ".$e->getMessage();
1011 1011
 			return array();
1012 1012
 		}
@@ -1014,12 +1014,12 @@  discard block
 block discarded – undo
1014 1014
 		return $all;
1015 1015
 	}
1016 1016
 	public function getAllNOTAMtext() {
1017
-		$query  = 'SELECT full_notam FROM notam';
1017
+		$query = 'SELECT full_notam FROM notam';
1018 1018
 		$query_values = array();
1019 1019
 		try {
1020 1020
 			$sth = $this->db->prepare($query);
1021 1021
 			$sth->execute($query_values);
1022
-		} catch(PDOException $e) {
1022
+		} catch (PDOException $e) {
1023 1023
 			echo "error : ".$e->getMessage();
1024 1024
 			return array();
1025 1025
 		}
@@ -1029,12 +1029,12 @@  discard block
 block discarded – undo
1029 1029
 	public function createNOTAMtextFile($filename) {
1030 1030
 		$allnotam_result = $this->getAllNOTAMtext();
1031 1031
 		$notamtext = '';
1032
-		foreach($allnotam_result as $notam) {
1032
+		foreach ($allnotam_result as $notam) {
1033 1033
 			$notamtext .= '%%'."\n";
1034 1034
 			$notamtext .= $notam['full_notam'];
1035 1035
 			$notamtext .= "\n".'%%'."\n";
1036 1036
 		}
1037
-		file_put_contents($filename,$notamtext);
1037
+		file_put_contents($filename, $notamtext);
1038 1038
 	}
1039 1039
 	public function parseNOTAMtextFile($filename) {
1040 1040
 		$data = file_get_contents($filename);
@@ -1053,7 +1053,7 @@  discard block
 block discarded – undo
1053 1053
 		try {
1054 1054
 			$sth = $this->db->prepare($query);
1055 1055
 			$sth->execute($query_values);
1056
-		} catch(PDOException $e) {
1056
+		} catch (PDOException $e) {
1057 1057
 			echo "error : ".$e->getMessage();
1058 1058
 			return array();
1059 1059
 		}
@@ -1063,10 +1063,10 @@  discard block
 block discarded – undo
1063 1063
 	public function getAllNOTAMbyCoord($coord) {
1064 1064
 		global $globalDBdriver;
1065 1065
 		if (is_array($coord)) {
1066
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1067
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1068
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1069
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1066
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1067
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1068
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1069
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1070 1070
 			if ($minlat > $maxlat) {
1071 1071
 				$tmplat = $minlat;
1072 1072
 				$minlat = $maxlat;
@@ -1087,20 +1087,20 @@  discard block
 block discarded – undo
1087 1087
 		try {
1088 1088
 			$sth = $this->db->prepare($query);
1089 1089
 			$sth->execute($query_values);
1090
-		} catch(PDOException $e) {
1090
+		} catch (PDOException $e) {
1091 1091
 			echo "error : ".$e->getMessage();
1092 1092
 			return array();
1093 1093
 		}
1094 1094
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1095 1095
 		return $all;
1096 1096
 	}
1097
-	public function getAllNOTAMbyCoordScope($coord,$scope) {
1097
+	public function getAllNOTAMbyCoordScope($coord, $scope) {
1098 1098
 		global $globalDBdriver;
1099 1099
 		if (is_array($coord)) {
1100
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1101
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1102
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1103
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1100
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1101
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1102
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1103
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1104 1104
 		} else return array();
1105 1105
 		if ($globalDBdriver == 'mysql') {
1106 1106
 			$query  = 'SELECT * FROM notam WHERE center_latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND center_longitude BETWEEN '.$minlong.' AND '.$maxlong.' AND radius > 0 AND date_end > UTC_TIMESTAMP() AND date_begin < UTC_TIMESTAMP() AND scope = :scope';
@@ -1111,7 +1111,7 @@  discard block
 block discarded – undo
1111 1111
 		try {
1112 1112
 			$sth = $this->db->prepare($query);
1113 1113
 			$sth->execute($query_values);
1114
-		} catch(PDOException $e) {
1114
+		} catch (PDOException $e) {
1115 1115
 			echo "error : ".$e->getMessage();
1116 1116
 			return array();
1117 1117
 		}
@@ -1124,7 +1124,7 @@  discard block
 block discarded – undo
1124 1124
 		try {
1125 1125
 			$sth = $this->db->prepare($query);
1126 1126
 			$sth->execute($query_values);
1127
-		} catch(PDOException $e) {
1127
+		} catch (PDOException $e) {
1128 1128
 			return "error : ".$e->getMessage();
1129 1129
 		}
1130 1130
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1132,13 +1132,13 @@  discard block
 block discarded – undo
1132 1132
 		else return array();
1133 1133
 	}
1134 1134
 
1135
-	public function addNOTAM($ref,$title,$type,$fir,$code,$rules,$scope,$lower_limit,$upper_limit,$center_latitude,$center_longitude,$radius,$date_begin,$date_end,$permanent,$text,$full_notam) {
1135
+	public function addNOTAM($ref, $title, $type, $fir, $code, $rules, $scope, $lower_limit, $upper_limit, $center_latitude, $center_longitude, $radius, $date_begin, $date_end, $permanent, $text, $full_notam) {
1136 1136
 		$query = "INSERT INTO notam (ref,title,notam_type,fir,code,rules,scope,lower_limit,upper_limit,center_latitude,center_longitude,radius,date_begin,date_end,permanent,notam_text,full_notam) VALUES (:ref,:title,:type,:fir,:code,:rules,:scope,:lower_limit,:upper_limit,:center_latitude,:center_longitude,:radius,:date_begin,:date_end,:permanent,:text,:full_notam)";
1137
-		$query_values = array(':ref' => $ref,':title' => $title,':type' => $type,':fir' => $fir,':code' => $code,':rules' => $rules,':scope' => $scope,':lower_limit' => $lower_limit,':upper_limit' => $upper_limit,':center_latitude' => $center_latitude,':center_longitude' => $center_longitude,':radius' => $radius,':date_begin' => $date_begin,':date_end' => $date_end,':permanent' => $permanent,':text' => $text,':full_notam' => $full_notam);
1137
+		$query_values = array(':ref' => $ref, ':title' => $title, ':type' => $type, ':fir' => $fir, ':code' => $code, ':rules' => $rules, ':scope' => $scope, ':lower_limit' => $lower_limit, ':upper_limit' => $upper_limit, ':center_latitude' => $center_latitude, ':center_longitude' => $center_longitude, ':radius' => $radius, ':date_begin' => $date_begin, ':date_end' => $date_end, ':permanent' => $permanent, ':text' => $text, ':full_notam' => $full_notam);
1138 1138
 		try {
1139 1139
 			$sth = $this->db->prepare($query);
1140 1140
 			$sth->execute($query_values);
1141
-		} catch(PDOException $e) {
1141
+		} catch (PDOException $e) {
1142 1142
 			return "error : ".$e->getMessage();
1143 1143
 		}
1144 1144
 		return '';
@@ -1150,7 +1150,7 @@  discard block
 block discarded – undo
1150 1150
 		try {
1151 1151
 			$sth = $this->db->prepare($query);
1152 1152
 			$sth->execute($query_values);
1153
-		} catch(PDOException $e) {
1153
+		} catch (PDOException $e) {
1154 1154
 			return "error : ".$e->getMessage();
1155 1155
 		}
1156 1156
 		return '';
@@ -1166,7 +1166,7 @@  discard block
 block discarded – undo
1166 1166
 		try {
1167 1167
 			$sth = $this->db->prepare($query);
1168 1168
 			$sth->execute($query_values);
1169
-		} catch(PDOException $e) {
1169
+		} catch (PDOException $e) {
1170 1170
 			return "error : ".$e->getMessage();
1171 1171
 		}
1172 1172
 		return '';
@@ -1177,7 +1177,7 @@  discard block
 block discarded – undo
1177 1177
 		try {
1178 1178
 			$sth = $this->db->prepare($query);
1179 1179
 			$sth->execute($query_values);
1180
-		} catch(PDOException $e) {
1180
+		} catch (PDOException $e) {
1181 1181
 			return "error : ".$e->getMessage();
1182 1182
 		}
1183 1183
 		return '';
@@ -1187,7 +1187,7 @@  discard block
 block discarded – undo
1187 1187
 		try {
1188 1188
 			$sth = $this->db->prepare($query);
1189 1189
 			$sth->execute();
1190
-		} catch(PDOException $e) {
1190
+		} catch (PDOException $e) {
1191 1191
 			return "error : ".$e->getMessage();
1192 1192
 		}
1193 1193
 		return '';
@@ -1197,7 +1197,7 @@  discard block
 block discarded – undo
1197 1197
 		try {
1198 1198
 			$sth = $this->db->prepare($query);
1199 1199
 			$sth->execute();
1200
-		} catch(PDOException $e) {
1200
+		} catch (PDOException $e) {
1201 1201
 			return "error : ".$e->getMessage();
1202 1202
 		}
1203 1203
 		return '';
@@ -1206,14 +1206,14 @@  discard block
 block discarded – undo
1206 1206
 	public function updateNOTAM() {
1207 1207
 		global $globalNOTAMAirports;
1208 1208
 		if (isset($globalNOTAMAirports) && is_array($globalNOTAMAirports) && count($globalNOTAMAirports) > 0) {
1209
-			foreach (array_chunk($globalNOTAMAirports,10) as $airport) {
1210
-				$airport_icao = implode(',',$airport);
1209
+			foreach (array_chunk($globalNOTAMAirports, 10) as $airport) {
1210
+				$airport_icao = implode(',', $airport);
1211 1211
 				$alldata = $this->downloadNOTAM($airport_icao);
1212 1212
 				if (count($alldata) > 0) {
1213 1213
 					foreach ($alldata as $initial_data) {
1214 1214
 						$data = $this->parse($initial_data);
1215 1215
 						$notamref = $this->getNOTAMbyRef($data['ref']);
1216
-						if (count($notamref) == 0) $this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']);
1216
+						if (count($notamref) == 0) $this->addNOTAM($data['ref'], $data['title'], '', $data['fir'], $data['code'], '', $data['scope'], $data['lower_limit'], $data['upper_limit'], $data['latitude'], $data['longitude'], $data['radius'], $data['date_begin'], $data['date_end'], $data['permanent'], $data['text'], $data['full_notam']);
1217 1217
 					}
1218 1218
 				}
1219 1219
 			}
@@ -1230,8 +1230,8 @@  discard block
 block discarded – undo
1230 1230
 				$j++;
1231 1231
 				$data = $this->parse($initial_data);
1232 1232
 				$notamref = $this->getNOTAMbyRef($data['ref']);
1233
-				if (!isset($notamref['notam_id'])) $this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']);
1234
-				if ($globalTransaction && $j % 1000 == 0) {
1233
+				if (!isset($notamref['notam_id'])) $this->addNOTAM($data['ref'], $data['title'], '', $data['fir'], $data['code'], '', $data['scope'], $data['lower_limit'], $data['upper_limit'], $data['latitude'], $data['longitude'], $data['radius'], $data['date_begin'], $data['date_end'], $data['permanent'], $data['text'], $data['full_notam']);
1234
+				if ($globalTransaction && $j%1000 == 0) {
1235 1235
 					$this->db->commit();
1236 1236
 					if ($globalDebug) echo '.';
1237 1237
 					$this->db->beginTransaction();
@@ -1245,12 +1245,12 @@  discard block
 block discarded – undo
1245 1245
 		global $globalTransaction;
1246 1246
 		$Spotter = new Spotter($this->db);
1247 1247
 		$allairports = $Spotter->getAllAirportInfo();
1248
-		foreach (array_chunk($allairports,20) as $airport) {
1248
+		foreach (array_chunk($allairports, 20) as $airport) {
1249 1249
 			$airports_icao = array();
1250
-			foreach($airport as $icao) {
1250
+			foreach ($airport as $icao) {
1251 1251
 				if (isset($icao['icao'])) $airports_icao[] = $icao['icao'];
1252 1252
 			}
1253
-			$airport_icao = implode(',',$airports_icao);
1253
+			$airport_icao = implode(',', $airports_icao);
1254 1254
 			$alldata = $this->downloadNOTAM($airport_icao);
1255 1255
 			if ($globalTransaction) $this->db->beginTransaction();
1256 1256
 			if (count($alldata) > 0) {
@@ -1263,7 +1263,7 @@  discard block
 block discarded – undo
1263 1263
 						if (count($notamref) == 0) {
1264 1264
 							if (isset($data['ref_replaced'])) $this->deleteNOTAMbyRef($data['ref_replaced']);
1265 1265
 							if (isset($data['ref_cancelled'])) $this->deleteNOTAMbyRef($data['ref_cancelled']);
1266
-							elseif (isset($data['latitude']) && isset($data['scope']) && isset($data['text']) && isset($data['permanent'])) echo $this->addNOTAM($data['ref'],'','',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']);
1266
+							elseif (isset($data['latitude']) && isset($data['scope']) && isset($data['text']) && isset($data['permanent'])) echo $this->addNOTAM($data['ref'], '', '', $data['fir'], $data['code'], '', $data['scope'], $data['lower_limit'], $data['upper_limit'], $data['latitude'], $data['longitude'], $data['radius'], $data['date_begin'], $data['date_end'], $data['permanent'], $data['text'], $data['full_notam']);
1267 1267
 						}
1268 1268
 					}
1269 1269
 				}
@@ -1277,7 +1277,7 @@  discard block
 block discarded – undo
1277 1277
 		date_default_timezone_set("UTC");
1278 1278
 		$Common = new Common();
1279 1279
 		//$url = str_replace('{icao}',$icao,'https://pilotweb.nas.faa.gov/PilotWeb/notamRetrievalByICAOAction.do?method=displayByICAOs&reportType=RAW&formatType=DOMESTIC&retrieveLocId={icao}&actionType=notamRetrievalByICAOs');
1280
-		$url = str_replace('{icao}',$icao,'https://pilotweb.nas.faa.gov/PilotWeb/notamRetrievalByICAOAction.do?method=displayByICAOs&reportType=RAW&formatType=ICAO&retrieveLocId={icao}&actionType=notamRetrievalByICAOs');
1280
+		$url = str_replace('{icao}', $icao, 'https://pilotweb.nas.faa.gov/PilotWeb/notamRetrievalByICAOAction.do?method=displayByICAOs&reportType=RAW&formatType=ICAO&retrieveLocId={icao}&actionType=notamRetrievalByICAOs');
1281 1281
 		$data = $Common->getData($url);
1282 1282
 		preg_match_all("/<pre>(.+?)<\/pre>/is", $data, $matches);
1283 1283
 		//print_r($matches);
@@ -1294,8 +1294,8 @@  discard block
 block discarded – undo
1294 1294
 		$result['permanent'] = '';
1295 1295
 		$result['date_begin'] = NULL;
1296 1296
 		$result['date_end'] = NULL;
1297
-		$data = str_ireplace(array("\r","\n",'\r','\n'),' ',$data);
1298
-		$data = preg_split('#\s(?=([A-Z]\)\s))#',$data);
1297
+		$data = str_ireplace(array("\r", "\n", '\r', '\n'), ' ', $data);
1298
+		$data = preg_split('#\s(?=([A-Z]\)\s))#', $data);
1299 1299
 		$q = false;
1300 1300
 		$a = false;
1301 1301
 		$b = false;
@@ -1303,9 +1303,9 @@  discard block
 block discarded – undo
1303 1303
 		$e = false;
1304 1304
 		foreach ($data as $line) {
1305 1305
 			$line = trim($line);
1306
-			if (preg_match('#(^|\s)Q\) (.*)#',$line,$matches) && $q === false) {
1307
-				$line = str_replace(' ','',$line);
1308
-				if (preg_match('#Q\)([A-Z]{3,4})\/([A-Z]{5})\/(IV|I|V)\/([A-Z]{1,3})\/([A-Z]{1,2})\/([0-9]{3})\/([0-9]{3})\/([0-9]{4})(N|S)([0-9]{5})(E|W)([0-9]{3}|)#',$line,$matches)) {
1306
+			if (preg_match('#(^|\s)Q\) (.*)#', $line, $matches) && $q === false) {
1307
+				$line = str_replace(' ', '', $line);
1308
+				if (preg_match('#Q\)([A-Z]{3,4})\/([A-Z]{5})\/(IV|I|V)\/([A-Z]{1,3})\/([A-Z]{1,2})\/([0-9]{3})\/([0-9]{3})\/([0-9]{4})(N|S)([0-9]{5})(E|W)([0-9]{3}|)#', $line, $matches)) {
1309 1309
 				//if (preg_match('#Q\)([A-Z]{4})\/([A-Z]{5})\/(IV|I|V)\/([A-Z]{1,3})\/([A-Z]{1,2})\/([0-9]{3})\/([0-9]{3})\/([0-9]{4})(N|S)([0-9]{5})(E|W)([0-9]{3})#',$line,$matches)) {
1310 1310
 					$result['fir'] = $matches[1];
1311 1311
 					$result['code'] = $matches[2];
@@ -1350,9 +1350,9 @@  discard block
 block discarded – undo
1350 1350
 					elseif ($matches[5] == 'AW') $result['scope'] = 'Airport/Navigation warning';
1351 1351
 					$result['lower_limit'] = $matches[6];
1352 1352
 					$result['upper_limit'] = $matches[7];
1353
-					$latitude = $Common->convertDec($matches[8],'latitude');
1353
+					$latitude = $Common->convertDec($matches[8], 'latitude');
1354 1354
 					if ($matches[9] == 'S') $latitude = -$latitude;
1355
-					$longitude = $Common->convertDec($matches[10],'longitude');
1355
+					$longitude = $Common->convertDec($matches[10], 'longitude');
1356 1356
 					if ($matches[11] == 'W') $longitude = -$longitude;
1357 1357
 					$result['latitude'] = $latitude;
1358 1358
 					$result['longitude'] = $longitude;
@@ -1364,24 +1364,24 @@  discard block
 block discarded – undo
1364 1364
 					echo "Can't parse : ".$line."\n";
1365 1365
 				}
1366 1366
 			}
1367
-			elseif (preg_match('#(^|\s)A\) (.*)#',$line,$matches) && $a === false) {
1367
+			elseif (preg_match('#(^|\s)A\) (.*)#', $line, $matches) && $a === false) {
1368 1368
 				$result['icao'] = $matches[2];
1369 1369
 				$a = true;
1370 1370
 			}
1371
-			elseif (preg_match('#(^|\s)B\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})#',$line,$matches) && $b === false) {
1371
+			elseif (preg_match('#(^|\s)B\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})#', $line, $matches) && $b === false) {
1372 1372
 				if ($matches[1] > 50) $year = '19'.$matches[2];
1373 1373
 				else $year = '20'.$matches[2];
1374 1374
 				$result['date_begin'] = $year.'/'.$matches[3].'/'.$matches[4].' '.$matches[5].':'.$matches[6];
1375 1375
 				$b = true;
1376 1376
 			}
1377
-			elseif (preg_match('#(^|\s)C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#',$line,$matches) && $c === false) {
1377
+			elseif (preg_match('#(^|\s)C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#', $line, $matches) && $c === false) {
1378 1378
 				if ($matches[2] > 50) $year = '19'.$matches[2];
1379 1379
 				else $year = '20'.$matches[2];
1380 1380
 				$result['date_end'] = $year.'/'.$matches[3].'/'.$matches[4].' '.$matches[5].':'.$matches[6];
1381 1381
 				$result['permanent'] = 0;
1382 1382
 				$c = true;
1383 1383
 			}
1384
-			elseif (preg_match('#(^|\s)C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2}) (EST|PERM)$#',$line,$matches) && $c === false) {
1384
+			elseif (preg_match('#(^|\s)C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2}) (EST|PERM)$#', $line, $matches) && $c === false) {
1385 1385
 				if ($matches[2] > 50) $year = '19'.$matches[2];
1386 1386
 				else $year = '20'.$matches[2];
1387 1387
 				$result['date_end'] = $year.'/'.$matches[3].'/'.$matches[4].' '.$matches[5].':'.$matches[6];
@@ -1391,7 +1391,7 @@  discard block
 block discarded – undo
1391 1391
 				else $result['permanent'] = 0;
1392 1392
 				$c = true;
1393 1393
 			}
1394
-			elseif (preg_match('#(^|\s)C\) (EST|PERM)$#',$line,$matches) && $c === false) {
1394
+			elseif (preg_match('#(^|\s)C\) (EST|PERM)$#', $line, $matches) && $c === false) {
1395 1395
 				$result['date_end'] = '2030/12/20 12:00';
1396 1396
 				if ($matches[2] == 'EST') $result['estimated'] = 1;
1397 1397
 				else $result['estimated'] = 0;
@@ -1399,20 +1399,20 @@  discard block
 block discarded – undo
1399 1399
 				else $result['permanent'] = 0;
1400 1400
 				$c = true;
1401 1401
 			}
1402
-			elseif (preg_match('#(^|\s)E\) (.*)#',$line,$matches) && $e === false) {
1402
+			elseif (preg_match('#(^|\s)E\) (.*)#', $line, $matches) && $e === false) {
1403 1403
 				$rtext = array();
1404
-				$text = explode(' ',$matches[2]);
1404
+				$text = explode(' ', $matches[2]);
1405 1405
 				foreach ($text as $word) {
1406 1406
 					if (isset($this->abbr[$word])) $rtext[] = strtoupper($this->abbr[$word]);
1407
-					elseif (ctype_digit(strval(substr($word,3))) && isset($this->abbr[substr($word,0,3)])) $rtext[] = strtoupper($this->abbr[substr($word,0,3)]).' '.substr($word,3);
1407
+					elseif (ctype_digit(strval(substr($word, 3))) && isset($this->abbr[substr($word, 0, 3)])) $rtext[] = strtoupper($this->abbr[substr($word, 0, 3)]).' '.substr($word, 3);
1408 1408
 					else $rtext[] = $word;
1409 1409
 				}
1410
-				$result['text'] = implode(' ',$rtext);
1410
+				$result['text'] = implode(' ', $rtext);
1411 1411
 				$e = true;
1412 1412
 			//} elseif (preg_match('#F\) (.*)#',$line,$matches)) {
1413 1413
 			//} elseif (preg_match('#G\) (.*)#',$line,$matches)) {
1414
-			} elseif (preg_match('#(NOTAMN|NOTAMR|NOTAMC)#',$line,$matches)) {
1415
-				$text = explode(' ',$line);
1414
+			} elseif (preg_match('#(NOTAMN|NOTAMR|NOTAMC)#', $line, $matches)) {
1415
+				$text = explode(' ', $line);
1416 1416
 				$result['ref'] = $text[0];
1417 1417
 				if ($matches[1] == 'NOTAMN') $result['type'] = 'new';
1418 1418
 				if ($matches[1] == 'NOTAMC') {
Please login to merge, or discard this patch.
require/class.Accident.php 3 patches
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -36,12 +36,12 @@  discard block
 block discarded – undo
36 36
 	}
37 37
 
38 38
 	/**
39
-	* Get Accidents data from DB
40
-	* @param String $limit Limit
41
-	* @param String $type Set type accident or incident
42
-	* @param String $date get data for a date
43
-	* @return array Return Accidents data in array
44
-	*/
39
+	 * Get Accidents data from DB
40
+	 * @param String $limit Limit
41
+	 * @param String $type Set type accident or incident
42
+	 * @param String $date get data for a date
43
+	 * @return array Return Accidents data in array
44
+	 */
45 45
 	public function getAccidentData($limit = '',$type = '',$date = '') {
46 46
 		global $globalDBdriver;
47 47
 		$Image = new Image($this->db);
@@ -384,11 +384,11 @@  discard block
 block discarded – undo
384 384
 		return $row['nb'];
385 385
 	}
386 386
 
387
-    /**
388
-     * Check if lastest accident update date is older than 1 day
389
-     * @return bool|string
390
-     */
391
-    public static function check_last_accidents_update() {
387
+	/**
388
+	 * Check if lastest accident update date is older than 1 day
389
+	 * @return bool|string
390
+	 */
391
+	public static function check_last_accidents_update() {
392 392
 		global $globalDBdriver;
393 393
 		if ($globalDBdriver == 'mysql') {
394 394
 			$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_accident_db' AND value > DATE_SUB(NOW(), INTERVAL 1 DAY)";
@@ -407,11 +407,11 @@  discard block
 block discarded – undo
407 407
 		else return true;
408 408
 	}
409 409
 
410
-    /**
411
-     * Insert accident update date
412
-     * @return string
413
-     */
414
-    public static function insert_last_accidents_update() {
410
+	/**
411
+	 * Insert accident update date
412
+	 * @return string
413
+	 */
414
+	public static function insert_last_accidents_update() {
415 415
 		$query = "DELETE FROM config WHERE name = 'last_update_accident_db';
416 416
 		    INSERT INTO config (name,value) VALUES ('last_update_accident_db',NOW());";
417 417
 		try {
Please login to merge, or discard this patch.
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -42,20 +42,20 @@  discard block
 block discarded – undo
42 42
 	* @param String $date get data for a date
43 43
 	* @return array Return Accidents data in array
44 44
 	*/
45
-	public function getAccidentData($limit = '',$type = '',$date = '') {
45
+	public function getAccidentData($limit = '', $type = '', $date = '') {
46 46
 		global $globalDBdriver;
47 47
 		$Image = new Image($this->db);
48 48
 		$Spotter = new Spotter($this->db);
49 49
 		$Translation = new Translation($this->db);
50
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
50
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
51 51
 		date_default_timezone_set('UTC');
52 52
 		$result = array();
53 53
 		$limit_query = '';
54 54
 		if ($limit != "")
55 55
 		{
56 56
 			$limit_array = explode(",", $limit);
57
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
58
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
57
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
58
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
59 59
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
60 60
 			{
61 61
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
@@ -64,29 +64,29 @@  discard block
 block discarded – undo
64 64
 
65 65
 		if ($type != '') {
66 66
 			if ($date != '') {
67
-				if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/",$date)) {
67
+				if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $date)) {
68 68
 					$query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
69 69
 					//$query = "SELECT accidents.registration, accidents.ident, accidents.date, accidents.url, accidents.country, accidents.place, accidents.title, accidents.fatalities, accidents.type, accidents.ident, accidents.aircraft_manufacturer, accidents.aircraft_name, accidents.airline_name, accidents.airline_icao, spotter_output.flightaware_id FROM accidents LEFT OUTER JOIN spotter_output ON accidents.registration = spotter_output.registration WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
70
-					$query_values = array(':type' => $type,':date' => $date);
71
-				} elseif (preg_match("/^[0-9]{4}-[0-9]{2}$/",$date)) {
70
+					$query_values = array(':type' => $type, ':date' => $date);
71
+				} elseif (preg_match("/^[0-9]{4}-[0-9]{2}$/", $date)) {
72 72
 					$query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND date BETWEEN :dated AND :datef GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
73
-					$query_values = array(':type' => $type,':dated' => $date.'-01', ':datef' => $date.'-31');
74
-				} elseif (preg_match("/^[0-9]{4}$/",$date)) {
73
+					$query_values = array(':type' => $type, ':dated' => $date.'-01', ':datef' => $date.'-31');
74
+				} elseif (preg_match("/^[0-9]{4}$/", $date)) {
75 75
 					if ($globalDBdriver == 'mysql') {
76 76
 						$query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND YEAR(date) = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
77 77
 					} else {
78 78
 						$query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND EXTRACT(YEAR FROM date) = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
79 79
 					}
80
-					$query_values = array(':type' => $type,':date' => $date);
80
+					$query_values = array(':type' => $type, ':date' => $date);
81 81
 				} else {
82 82
 					$date = $date.'%';
83 83
 					if ($globalDBdriver == 'mysql') {
84 84
 						$query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND DATE_FORMAT(date,'%Y-%m-%d') LIKE :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
85
-						$query_values = array(':type' => $type,':date' => $date);
85
+						$query_values = array(':type' => $type, ':date' => $date);
86 86
 					} else {
87 87
 						$query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND to_char(date,'YYYY-MM-DD') LIKE :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
88 88
 						//$query = "SELECT accidents.registration, accidents.ident, accidents.date, accidents.url, accidents.country, accidents.place, accidents.title, accidents.fatalities, accidents.type, accidents.ident, accidents.aircraft_manufacturer, accidents.aircraft_name, accidents.airline_name, accidents.airline_icao, spotter_output.flightaware_id FROM accidents LEFT OUTER JOIN spotter_output ON accidents.registration = spotter_output.registration WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND to_char(date,'YYYY-MM-DD') LIKE :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
89
-						$query_values = array(':type' => $type,':date' => $date);
89
+						$query_values = array(':type' => $type, ':date' => $date);
90 90
 					}
91 91
 				}
92 92
 			} else {
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 			}
98 98
 		} else {
99 99
 			if ($date != '') {
100
-				if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/",$date)) {
100
+				if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $date)) {
101 101
 					$query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
102 102
 					//$query = "SELECT accidents.registration, accidents.ident, accidents.date, accidents.url, accidents.country, accidents.place, accidents.title, accidents.fatalities, accidents.type, accidents.ident, accidents.aircraft_manufacturer, accidents.aircraft_name, accidents.airline_name, accidents.airline_icao, spotter_output.flightaware_id FROM accidents LEFT OUTER JOIN spotter_output ON accidents.registration = spotter_output.registration WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
103 103
 				} else {
@@ -116,18 +116,18 @@  discard block
 block discarded – undo
116 116
 		try {
117 117
 			$sth = $this->db->prepare($query);
118 118
 			$sth->execute($query_values);
119
-		} catch(PDOException $e) {
119
+		} catch (PDOException $e) {
120 120
 			echo "error : ".$e->getMessage();
121 121
 			return array();
122 122
 		}
123 123
 		$i = 0;
124 124
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
125
-			if (preg_match('/^[\w\-]+$/',$row['registration'])) {
125
+			if (preg_match('/^[\w\-]+$/', $row['registration'])) {
126 126
 				$data = array();
127 127
 				if ($row['registration'] != '') {
128 128
 					$image_array = $Image->getSpotterImage($row['registration']);
129
-					if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
130
-					else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
129
+					if (count($image_array) > 0) $data = array_merge($data, array('image' => $image_array[0]['image'], 'image_thumbnail' => $image_array[0]['image_thumbnail'], 'image_copyright' => $image_array[0]['image_copyright'], 'image_source' => $image_array[0]['image_source'], 'image_source_website' => $image_array[0]['image_source_website']));
130
+					else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
131 131
 					$aircraft_type = $Spotter->getAllAircraftTypeByRegistration($row['registration']);
132 132
 					$aircraft_info = $Spotter->getAllAircraftInfo($aircraft_type);
133 133
 					if (!empty($aircraft_info)) {
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 						$data['aircraft_name'] = $aircraft_info[0]['type'];
136 136
 						$data['aircraft_manufacturer'] = $aircraft_info[0]['manufacturer'];
137 137
 					} else {
138
-						$data = array_merge($data,array('aircraft_type' => 'NA'));
138
+						$data = array_merge($data, array('aircraft_type' => 'NA'));
139 139
 					}
140 140
 					$owner_data = $Spotter->getAircraftOwnerByRegistration($row['registration']);
141 141
 					if (!empty($owner_data)) {
@@ -143,18 +143,18 @@  discard block
 block discarded – undo
143 143
 						$data['aircraft_base'] = $owner_data['base'];
144 144
 						$data['aircraft_date_first_reg'] = $owner_data['date_first_reg'];
145 145
 					}
146
-				} else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
146
+				} else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
147 147
 				if ($row['registration'] == '') $row['registration'] = 'NA';
148 148
 				if ($row['ident'] == '') $row['ident'] = 'NA';
149
-				$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,3));
149
+				$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 3));
150 150
 				if (isset($identicao[0])) {
151
-					if (substr($row['ident'],0,2) == 'AF') {
152
-						if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
153
-						else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
154
-					} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
155
-					$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
151
+					if (substr($row['ident'], 0, 2) == 'AF') {
152
+						if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
153
+						else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0');
154
+					} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0');
155
+					$data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name']));
156 156
 				} else $icao = $row['ident'];
157
-				$icao = $Translation->checkTranslation($icao,false);
157
+				$icao = $Translation->checkTranslation($icao, false);
158 158
 				//$data = array_merge($data,array('registration' => $row['registration'], 'date' => $row['date'], 'ident' => $icao,'url' => $row['url']));
159 159
 				if ($row['airline_name'] != '' && !isset($data['airline_name'])) {
160 160
 					//echo 'Check airline info... for '.$row['airline_name'].' ';
@@ -163,16 +163,16 @@  discard block
 block discarded – undo
163 163
 					if (!empty($airline_info)) {
164 164
 						//echo 'data found !'."\n";
165 165
 						//print_r($airline_info);
166
-						$data = array_merge($data,$airline_info);
166
+						$data = array_merge($data, $airline_info);
167 167
 					} 
168 168
 					//else echo 'No data...'."\n";
169 169
 				}
170
-				$data = array_merge($row,$data);
170
+				$data = array_merge($row, $data);
171 171
 				if ($data['ident'] == null) $data['ident'] = $icao;
172 172
 				if ($data['title'] == null) {
173 173
 					$data['message'] = $row['type'].' of '.$row['registration'].' at '.$row['place'].','.$row['country'];
174 174
 				} else $data['message'] = strtolower($data['title']);
175
-				$ids = $Spotter->getAllIDByRegistration($data['registration'],true);
175
+				$ids = $Spotter->getAllIDByRegistration($data['registration'], true);
176 176
 				$date = $data['date'];
177 177
 				if (isset($ids[$date])) {
178 178
 					$data['spotted'] = TRUE;
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 		try {
205 205
 			$sth = $this->db->prepare($query);
206 206
 			$sth->execute();
207
-		} catch(PDOException $e) {
207
+		} catch (PDOException $e) {
208 208
 			echo "Error : ".$e->getMessage();
209 209
 			return array();
210 210
 		}
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 		try {
226 226
 			$sth = $this->db->prepare($query);
227 227
 			$sth->execute();
228
-		} catch(PDOException $e) {
228
+		} catch (PDOException $e) {
229 229
 			echo "Error : ".$e->getMessage();
230 230
 			return array();
231 231
 		}
@@ -241,15 +241,15 @@  discard block
 block discarded – undo
241 241
 		if ($globalDebug) echo 'Import '.$file."\n";
242 242
 		$result = array();
243 243
 		if (file_exists($file)) {
244
-			if (($handle = fopen($file,'r')) !== FALSE) {
245
-				while (($data = fgetcsv($handle,2000,",")) !== FALSE) {
244
+			if (($handle = fopen($file, 'r')) !== FALSE) {
245
+				while (($data = fgetcsv($handle, 2000, ",")) !== FALSE) {
246 246
 					if (isset($data[1]) && $data[1] != '0000-00-00 00:00:00') {
247
-						$result[] = array('registration' => $data[0],'date' => strtotime($data[1]),'url' => $data[2],'country' => $data[3],'place' => $data[4],'title' => $data[5],'fatalities' => $data[6],'latitude' => $data[7],'longitude' => $data[8],'type' => $data[9],'ident' => $data[10],'aircraft_manufacturer' => $data[11],'aircraft_name' => $data[12],'operator' => $data[13],'source' => 'website_fam');
247
+						$result[] = array('registration' => $data[0], 'date' => strtotime($data[1]), 'url' => $data[2], 'country' => $data[3], 'place' => $data[4], 'title' => $data[5], 'fatalities' => $data[6], 'latitude' => $data[7], 'longitude' => $data[8], 'type' => $data[9], 'ident' => $data[10], 'aircraft_manufacturer' => $data[11], 'aircraft_name' => $data[12], 'operator' => $data[13], 'source' => 'website_fam');
248 248
 					}
249 249
 				}
250 250
 				fclose($handle);
251 251
 			}
252
-			if (!empty($result)) $this->add($result,true);
252
+			if (!empty($result)) $this->add($result, true);
253 253
 			elseif ($globalDebug) echo 'Nothing to import';
254 254
 		}
255 255
 	}
@@ -265,8 +265,8 @@  discard block
 block discarded – undo
265 265
 		$all_md5_new = array();
266 266
 		if (file_exists(dirname(__FILE__).'/../install/tmp/cr-all.md5')) {
267 267
 			if ($this->check_accidents_nb() > 0) {
268
-				if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5','r')) !== FALSE) {
269
-					while (($data = fgetcsv($handle,2000,"\t")) !== FALSE) {
268
+				if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5', 'r')) !== FALSE) {
269
+					while (($data = fgetcsv($handle, 2000, "\t")) !== FALSE) {
270 270
 						if (isset($data[1])) {
271 271
 							$year = $data[0];
272 272
 							$all_md5[$year] = $data[1];
@@ -276,10 +276,10 @@  discard block
 block discarded – undo
276 276
 				}
277 277
 			}
278 278
 		}
279
-		$Common->download('http://data.flightairmap.fr/data/cr/cr-all.md5',dirname(__FILE__).'/../install/tmp/cr-all.md5');
279
+		$Common->download('http://data.flightairmap.fr/data/cr/cr-all.md5', dirname(__FILE__).'/../install/tmp/cr-all.md5');
280 280
 		if (file_exists(dirname(__FILE__).'/../install/tmp/cr-all.md5')) {
281
-			if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5','r')) !== FALSE) {
282
-				while (($data = fgetcsv($handle,2000,"\t")) !== FALSE) {
281
+			if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5', 'r')) !== FALSE) {
282
+				while (($data = fgetcsv($handle, 2000, "\t")) !== FALSE) {
283 283
 					if (isset($data[1])) {
284 284
 						$year = $data[0];
285 285
 						$all_md5_new[$year] = $data[1];
@@ -288,10 +288,10 @@  discard block
 block discarded – undo
288 288
 				fclose($handle);
289 289
 			} elseif ($globalDebug) echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5';
290 290
 		} elseif ($globalDebug) echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.';
291
-		$result = $Common->arr_diff($all_md5_new,$all_md5);
291
+		$result = $Common->arr_diff($all_md5_new, $all_md5);
292 292
 		if (empty($result) && $globalDebug) echo 'Nothing to update';
293 293
 		foreach ($result as $file => $md5) {
294
-			$Common->download('http://data.flightairmap.fr/data/cr/'.$file,dirname(__FILE__).'/../install/tmp/'.$file);
294
+			$Common->download('http://data.flightairmap.fr/data/cr/'.$file, dirname(__FILE__).'/../install/tmp/'.$file);
295 295
 			if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) $this->import(dirname(__FILE__).'/../install/tmp/'.$file);
296 296
 			elseif ($globalDebug) echo 'Download '.$file.' failed';
297 297
 		}
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
 	* Add data to DB
302 302
 	* @param Array $crash An array with accidents/incidents data
303 303
 	*/
304
-	public function add($crash,$new = false) {
304
+	public function add($crash, $new = false) {
305 305
 		global $globalTransaction, $globalDebug, $globalAircraftImageFetch;
306 306
 		require_once('class.Connection.php');
307 307
 		require_once('class.Image.php');
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 			$sthd->execute(array(':source' => $crash[0]['source']));
318 318
 		}
319 319
 		if ($globalTransaction) $Connection->db->beginTransaction();
320
-		$initial_array = array('ident' => null,'type' => 'accident','url' => null,'registration' => null, 'date' => null, 'place' => null,'country' => null, 'latitude' => null, 'longitude' => null, 'fatalities' => null, 'title' => '','source' => '','aircraft_manufacturer' => null,'aircraft_name' => null,'operator' => null);
320
+		$initial_array = array('ident' => null, 'type' => 'accident', 'url' => null, 'registration' => null, 'date' => null, 'place' => null, 'country' => null, 'latitude' => null, 'longitude' => null, 'fatalities' => null, 'title' => '', 'source' => '', 'aircraft_manufacturer' => null, 'aircraft_name' => null, 'operator' => null);
321 321
 		$query_check = 'SELECT COUNT(*) as nb FROM accidents WHERE registration = :registration AND date = :date AND type = :type AND source = :source';
322 322
 		$sth_check = $Connection->db->prepare($query_check);
323 323
 		$query = 'INSERT INTO accidents (aircraft_manufacturer,aircraft_name,ident,registration,date,url,country,place,title,fatalities,latitude,longitude,type,airline_name,source) VALUES (:aircraft_manufacturer,:aircraft_name,:ident,:registration,:date,:url,:country,:place,:title,:fatalities,:latitude,:longitude,:type,:airline_name,:source)';
@@ -330,15 +330,15 @@  discard block
 block discarded – undo
330 330
 				$cr = array_map(function($value) {
331 331
 					return $value === "" ? NULL : $value;
332 332
 				}, $cr);
333
-				if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/',$cr['registration'])) {
334
-					if (strpos($cr['registration'],'-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']);
335
-					$query_check_values = array(':registration' => $cr['registration'],':date' => date('Y-m-d',$cr['date']),':type' => $cr['type'],':source' => $cr['source']);
333
+				if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/', $cr['registration'])) {
334
+					if (strpos($cr['registration'], '-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']);
335
+					$query_check_values = array(':registration' => $cr['registration'], ':date' => date('Y-m-d', $cr['date']), ':type' => $cr['type'], ':source' => $cr['source']);
336 336
 					$sth_check->execute($query_check_values);
337 337
 					$result_check = $sth_check->fetchAll(PDO::FETCH_ASSOC);
338 338
 					if ($result_check[0]['nb'] == 0) {
339
-						$query_values = array(':registration' => trim($cr['registration']),':date' => date('Y-m-d',$cr['date']),':url' => $cr['url'],':country' => $cr['country'],':place' => $cr['place'],':title' => $cr['title'],':fatalities' => $cr['fatalities'],':latitude' => $cr['latitude'],':longitude' => $cr['longitude'],':type' => $cr['type'],':source' => $cr['source'],':ident' => $cr['ident'],':aircraft_manufacturer' => $cr['aircraft_manufacturer'],':aircraft_name' => $cr['aircraft_name'],':airline_name' => $cr['operator']);
339
+						$query_values = array(':registration' => trim($cr['registration']), ':date' => date('Y-m-d', $cr['date']), ':url' => $cr['url'], ':country' => $cr['country'], ':place' => $cr['place'], ':title' => $cr['title'], ':fatalities' => $cr['fatalities'], ':latitude' => $cr['latitude'], ':longitude' => $cr['longitude'], ':type' => $cr['type'], ':source' => $cr['source'], ':ident' => $cr['ident'], ':aircraft_manufacturer' => $cr['aircraft_manufacturer'], ':aircraft_name' => $cr['aircraft_name'], ':airline_name' => $cr['operator']);
340 340
 						$sth->execute($query_values);
341
-						if ($cr['date'] > time()-(30*86400)) {
341
+						if ($cr['date'] > time() - (30*86400)) {
342 342
 							if ($globalAircraftImageFetch) {
343 343
 								$imgchk = $Image->getSpotterImage($cr['registration']);
344 344
 								if (empty($imgchk)) {
@@ -349,17 +349,17 @@  discard block
 block discarded – undo
349 349
 								// elseif ($globalDebug) echo 'Image already in DB'."\n";
350 350
 							}
351 351
 							if ($cr['title'] == '') $cr['title'] = $cr['registration'].' '.$cr['type'];
352
-							$Spotter->setHighlightFlightByRegistration($cr['registration'],$cr['title'],date('Y-m-d',$cr['date']));
352
+							$Spotter->setHighlightFlightByRegistration($cr['registration'], $cr['title'], date('Y-m-d', $cr['date']));
353 353
 						}
354 354
 					}
355 355
 				}
356
-				if ($globalTransaction && $j % 1000 == 0) {
356
+				if ($globalTransaction && $j%1000 == 0) {
357 357
 					$Connection->db->commit();
358 358
 					$Connection->db->beginTransaction();
359 359
 				}
360 360
 			}
361 361
 			if ($globalTransaction) $Connection->db->commit();
362
-		} catch(PDOException $e) {
362
+		} catch (PDOException $e) {
363 363
 			if ($globalTransaction) $Connection->db->rollBack();
364 364
 			echo $e->getMessage();
365 365
 		}
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
 			$Connection = new Connection();
378 378
 			$sth = $Connection->db->prepare($query);
379 379
 			$sth->execute();
380
-		} catch(PDOException $e) {
380
+		} catch (PDOException $e) {
381 381
 			return "error : ".$e->getMessage();
382 382
 		}
383 383
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
 			$Connection = new Connection();
400 400
 			$sth = $Connection->db->prepare($query);
401 401
 			$sth->execute();
402
-		} catch(PDOException $e) {
402
+		} catch (PDOException $e) {
403 403
 			return "error : ".$e->getMessage();
404 404
 		}
405 405
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
 			$Connection = new Connection();
419 419
 			$sth = $Connection->db->prepare($query);
420 420
 			$sth->execute();
421
-		} catch(PDOException $e) {
421
+		} catch (PDOException $e) {
422 422
 			return "error : ".$e->getMessage();
423 423
 		}
424 424
 		return '';
Please login to merge, or discard this patch.
Braces   +87 added lines, -31 removed lines patch added patch discarded remove patch
@@ -20,7 +20,9 @@  discard block
 block discarded – undo
20 20
 	public function __construct($dbc = null) {
21 21
 		$Connection = new Connection($dbc);
22 22
 		$this->db = $Connection->db();
23
-		if ($this->db === null) die('Error: No DB connection. (Accident)');
23
+		if ($this->db === null) {
24
+			die('Error: No DB connection. (Accident)');
25
+		}
24 26
 	}
25 27
 
26 28
 	/*
@@ -126,8 +128,11 @@  discard block
 block discarded – undo
126 128
 				$data = array();
127 129
 				if ($row['registration'] != '') {
128 130
 					$image_array = $Image->getSpotterImage($row['registration']);
129
-					if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
130
-					else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
131
+					if (count($image_array) > 0) {
132
+						$data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
133
+					} else {
134
+						$data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
135
+					}
131 136
 					$aircraft_type = $Spotter->getAllAircraftTypeByRegistration($row['registration']);
132 137
 					$aircraft_info = $Spotter->getAllAircraftInfo($aircraft_type);
133 138
 					if (!empty($aircraft_info)) {
@@ -143,17 +148,30 @@  discard block
 block discarded – undo
143 148
 						$data['aircraft_base'] = $owner_data['base'];
144 149
 						$data['aircraft_date_first_reg'] = $owner_data['date_first_reg'];
145 150
 					}
146
-				} else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
147
-				if ($row['registration'] == '') $row['registration'] = 'NA';
148
-				if ($row['ident'] == '') $row['ident'] = 'NA';
151
+				} else {
152
+					$data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
153
+				}
154
+				if ($row['registration'] == '') {
155
+					$row['registration'] = 'NA';
156
+				}
157
+				if ($row['ident'] == '') {
158
+					$row['ident'] = 'NA';
159
+				}
149 160
 				$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,3));
150 161
 				if (isset($identicao[0])) {
151 162
 					if (substr($row['ident'],0,2) == 'AF') {
152
-						if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
153
-						else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
154
-					} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
163
+						if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) {
164
+							$icao = $row['ident'];
165
+						} else {
166
+							$icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
167
+						}
168
+					} else {
169
+						$icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
170
+					}
155 171
 					$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
156
-				} else $icao = $row['ident'];
172
+				} else {
173
+					$icao = $row['ident'];
174
+				}
157 175
 				$icao = $Translation->checkTranslation($icao,false);
158 176
 				//$data = array_merge($data,array('registration' => $row['registration'], 'date' => $row['date'], 'ident' => $icao,'url' => $row['url']));
159 177
 				if ($row['airline_name'] != '' && !isset($data['airline_name'])) {
@@ -168,10 +186,14 @@  discard block
 block discarded – undo
168 186
 					//else echo 'No data...'."\n";
169 187
 				}
170 188
 				$data = array_merge($row,$data);
171
-				if ($data['ident'] == null) $data['ident'] = $icao;
189
+				if ($data['ident'] == null) {
190
+					$data['ident'] = $icao;
191
+				}
172 192
 				if ($data['title'] == null) {
173 193
 					$data['message'] = $row['type'].' of '.$row['registration'].' at '.$row['place'].','.$row['country'];
174
-				} else $data['message'] = strtolower($data['title']);
194
+				} else {
195
+					$data['message'] = strtolower($data['title']);
196
+				}
175 197
 				$ids = $Spotter->getAllIDByRegistration($data['registration'],true);
176 198
 				$date = $data['date'];
177 199
 				if (isset($ids[$date])) {
@@ -190,8 +212,9 @@  discard block
 block discarded – undo
190 212
 		if (isset($result)) {
191 213
 			$result[0]['query_number_rows'] = $i;
192 214
 			return $result;
215
+		} else {
216
+			return array();
193 217
 		}
194
-		else return array();
195 218
 	}
196 219
 
197 220
 	/*
@@ -238,7 +261,9 @@  discard block
 block discarded – undo
238 261
 	*/
239 262
 	public function import($file) {
240 263
 		global $globalDebug;
241
-		if ($globalDebug) echo 'Import '.$file."\n";
264
+		if ($globalDebug) {
265
+			echo 'Import '.$file."\n";
266
+		}
242 267
 		$result = array();
243 268
 		if (file_exists($file)) {
244 269
 			if (($handle = fopen($file,'r')) !== FALSE) {
@@ -249,8 +274,11 @@  discard block
 block discarded – undo
249 274
 				}
250 275
 				fclose($handle);
251 276
 			}
252
-			if (!empty($result)) $this->add($result,true);
253
-			elseif ($globalDebug) echo 'Nothing to import';
277
+			if (!empty($result)) {
278
+				$this->add($result,true);
279
+			} elseif ($globalDebug) {
280
+				echo 'Nothing to import';
281
+			}
254 282
 		}
255 283
 	}
256 284
 
@@ -286,14 +314,23 @@  discard block
 block discarded – undo
286 314
 					}
287 315
 				}
288 316
 				fclose($handle);
289
-			} elseif ($globalDebug) echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5';
290
-		} elseif ($globalDebug) echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.';
317
+			} elseif ($globalDebug) {
318
+				echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5';
319
+			}
320
+		} elseif ($globalDebug) {
321
+			echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.';
322
+		}
291 323
 		$result = $Common->arr_diff($all_md5_new,$all_md5);
292
-		if (empty($result) && $globalDebug) echo 'Nothing to update';
324
+		if (empty($result) && $globalDebug) {
325
+			echo 'Nothing to update';
326
+		}
293 327
 		foreach ($result as $file => $md5) {
294 328
 			$Common->download('http://data.flightairmap.fr/data/cr/'.$file,dirname(__FILE__).'/../install/tmp/'.$file);
295
-			if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) $this->import(dirname(__FILE__).'/../install/tmp/'.$file);
296
-			elseif ($globalDebug) echo 'Download '.$file.' failed';
329
+			if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) {
330
+				$this->import(dirname(__FILE__).'/../install/tmp/'.$file);
331
+			} elseif ($globalDebug) {
332
+				echo 'Download '.$file.' failed';
333
+			}
297 334
 		}
298 335
 	}
299 336
 
@@ -310,13 +347,17 @@  discard block
 block discarded – undo
310 347
 		$Image = new Image($this->db);
311 348
 		$Spotter = new Spotter($this->db);
312 349
 
313
-		if (empty($crash)) return false;
350
+		if (empty($crash)) {
351
+			return false;
352
+		}
314 353
 		if ($new === false) {
315 354
 			$query_delete = 'DELETE FROM accidents WHERE source = :source';
316 355
 			$sthd = $Connection->db->prepare($query_delete);
317 356
 			$sthd->execute(array(':source' => $crash[0]['source']));
318 357
 		}
319
-		if ($globalTransaction) $Connection->db->beginTransaction();
358
+		if ($globalTransaction) {
359
+			$Connection->db->beginTransaction();
360
+		}
320 361
 		$initial_array = array('ident' => null,'type' => 'accident','url' => null,'registration' => null, 'date' => null, 'place' => null,'country' => null, 'latitude' => null, 'longitude' => null, 'fatalities' => null, 'title' => '','source' => '','aircraft_manufacturer' => null,'aircraft_name' => null,'operator' => null);
321 362
 		$query_check = 'SELECT COUNT(*) as nb FROM accidents WHERE registration = :registration AND date = :date AND type = :type AND source = :source';
322 363
 		$sth_check = $Connection->db->prepare($query_check);
@@ -331,7 +372,9 @@  discard block
 block discarded – undo
331 372
 					return $value === "" ? NULL : $value;
332 373
 				}, $cr);
333 374
 				if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/',$cr['registration'])) {
334
-					if (strpos($cr['registration'],'-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']);
375
+					if (strpos($cr['registration'],'-') === FALSE) {
376
+						$cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']);
377
+					}
335 378
 					$query_check_values = array(':registration' => $cr['registration'],':date' => date('Y-m-d',$cr['date']),':type' => $cr['type'],':source' => $cr['source']);
336 379
 					$sth_check->execute($query_check_values);
337 380
 					$result_check = $sth_check->fetchAll(PDO::FETCH_ASSOC);
@@ -342,13 +385,19 @@  discard block
 block discarded – undo
342 385
 							if ($globalAircraftImageFetch) {
343 386
 								$imgchk = $Image->getSpotterImage($cr['registration']);
344 387
 								if (empty($imgchk)) {
345
-									if ($globalDebug) echo "\t".'Get image for '.$cr['registration'].'...';
388
+									if ($globalDebug) {
389
+										echo "\t".'Get image for '.$cr['registration'].'...';
390
+									}
346 391
 									$Image->addSpotterImage($cr['registration']);
347
-									if ($globalDebug) echo "\t".'Done'."\n";
392
+									if ($globalDebug) {
393
+										echo "\t".'Done'."\n";
394
+									}
348 395
 								}
349 396
 								// elseif ($globalDebug) echo 'Image already in DB'."\n";
350 397
 							}
351
-							if ($cr['title'] == '') $cr['title'] = $cr['registration'].' '.$cr['type'];
398
+							if ($cr['title'] == '') {
399
+								$cr['title'] = $cr['registration'].' '.$cr['type'];
400
+							}
352 401
 							$Spotter->setHighlightFlightByRegistration($cr['registration'],$cr['title'],date('Y-m-d',$cr['date']));
353 402
 						}
354 403
 					}
@@ -358,9 +407,13 @@  discard block
 block discarded – undo
358 407
 					$Connection->db->beginTransaction();
359 408
 				}
360 409
 			}
361
-			if ($globalTransaction) $Connection->db->commit();
410
+			if ($globalTransaction) {
411
+				$Connection->db->commit();
412
+			}
362 413
 		} catch(PDOException $e) {
363
-			if ($globalTransaction) $Connection->db->rollBack();
414
+			if ($globalTransaction) {
415
+				$Connection->db->rollBack();
416
+			}
364 417
 			echo $e->getMessage();
365 418
 		}
366 419
 		$sth_check->closeCursor();
@@ -403,8 +456,11 @@  discard block
 block discarded – undo
403 456
 			return "error : ".$e->getMessage();
404 457
 		}
405 458
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
406
-		if ($row['nb'] > 0) return false;
407
-		else return true;
459
+		if ($row['nb'] > 0) {
460
+			return false;
461
+		} else {
462
+			return true;
463
+		}
408 464
 	}
409 465
 
410 466
     /**
Please login to merge, or discard this patch.
require/class.SpotterLive.php 2 patches
Spacing   +150 added lines, -150 removed lines patch added patch discarded remove patch
@@ -17,62 +17,62 @@  discard block
 block discarded – undo
17 17
 	* @param array $filter the filter
18 18
 	* @return string the SQL part
19 19
 	*/
20
-	public function getFilter($filter = array(),$where = false,$and = false) {
20
+	public function getFilter($filter = array(), $where = false, $and = false) {
21 21
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
22 22
 		$filters = array();
23 23
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
24 24
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
25 25
 				$filters = $globalStatsFilters[$globalFilterName];
26 26
 			} else {
27
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
27
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
28 28
 			}
29 29
 		}
30 30
 		if (isset($filter[0]['source'])) {
31
-			$filters = array_merge($filters,$filter);
31
+			$filters = array_merge($filters, $filter);
32 32
 		}
33
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
33
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
34 34
 		$filter_query_join = '';
35 35
 		$filter_query_where = '';
36
-		foreach($filters as $flt) {
36
+		foreach ($filters as $flt) {
37 37
 			if (isset($flt['airlines']) && !empty($flt['airlines'])) {
38 38
 				if ($flt['airlines'][0] != '' && $flt['airlines'][0] != 'all') {
39 39
 					if (isset($flt['source'])) {
40
-						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id";
40
+						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id";
41 41
 					} else {
42
-						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id";
42
+						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id";
43 43
 					}
44 44
 				}
45 45
 			}
46 46
 			if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) {
47 47
 				if (isset($flt['source'])) {
48
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id";
48
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id";
49 49
 				} else {
50
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id";
50
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id";
51 51
 				}
52 52
 			}
53 53
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
54 54
 				if (isset($flt['source'])) {
55
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id";
55
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id";
56 56
 				} else {
57
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id";
57
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id";
58 58
 				}
59 59
 			}
60 60
 			if (isset($flt['registrations']) && !empty($flt['registrations'])) {
61 61
 				if (isset($flt['source'])) {
62
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id";
62
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','", $flt['registrations'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id";
63 63
 				} else {
64
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id";
64
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','", $flt['registrations'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id";
65 65
 				}
66 66
 			}
67 67
 			if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) {
68 68
 				if (isset($flt['source'])) {
69
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) ssf ON ssf.flightaware_id = spotter_live.flightaware_id";
69
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','", $flt['source'])."')) ssf ON ssf.flightaware_id = spotter_live.flightaware_id";
70 70
 				}
71 71
 			}
72 72
 		}
73 73
 		if (isset($filter['airlines']) && !empty($filter['airlines'])) {
74 74
 			if ($filter['airlines'][0] != '' && $filter['airlines'][0] != 'all') {
75
-				$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) sai ON sai.flightaware_id = spotter_live.flightaware_id";
75
+				$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) sai ON sai.flightaware_id = spotter_live.flightaware_id";
76 76
 			}
77 77
 		}
78 78
 		if (isset($filter['alliance']) && !empty($filter['alliance'])) {
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_live.flightaware_id ";
83 83
 		}
84 84
 		if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) {
85
-			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) sp ON sp.flightaware_id = spotter_live.flightaware_id";
85
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) sp ON sp.flightaware_id = spotter_live.flightaware_id";
86 86
 		}
87 87
 		if (isset($filter['blocked']) && $filter['blocked'] == true) {
88 88
 			$filter_query_join .= " INNER JOIN (SELECT callsign FROM aircraft_block) cblk ON cblk.callsign = spotter_live.ident";
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 			if (count($filter['source']) == 1) {
92 92
 				$filter_query_where .= " AND format_source = '".$filter['source'][0]."'";
93 93
 			} else {
94
-				$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
94
+				$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
95 95
 			}
96 96
 		}
97 97
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
@@ -124,15 +124,15 @@  discard block
 block discarded – undo
124 124
 					$filter_query_date .= " AND EXTRACT(DAY FROM spotter_output.date) = '".$filter['day']."'";
125 125
 				}
126 126
 			}
127
-			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_live.flightaware_id";
127
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.flightaware_id = spotter_live.flightaware_id";
128 128
 		}
129 129
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
130
-			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
130
+			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
131 131
 		}
132 132
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
133 133
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
134 134
 		if ($filter_query_where != '') {
135
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
135
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
136 136
 		}
137 137
 		$filter_query = $filter_query_join.$filter_query_where;
138 138
 		return $filter_query;
@@ -157,8 +157,8 @@  discard block
 block discarded – undo
157 157
 		if ($limit != '')
158 158
 		{
159 159
 			$limit_array = explode(',', $limit);
160
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
161
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
160
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
161
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
162 162
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
163 163
 			{
164 164
 				$limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0];
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 		} else {
183 183
 			$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate".$filter_query.$orderby_query;
184 184
 		}
185
-		$spotter_array = $Spotter->getDataFromDB($query.$limit_query,array(),'',true);
185
+		$spotter_array = $Spotter->getDataFromDB($query.$limit_query, array(), '', true);
186 186
 
187 187
 		return $spotter_array;
188 188
 	}
@@ -194,34 +194,34 @@  discard block
 block discarded – undo
194 194
      * @param array $filter
195 195
      * @return array the spotter information
196 196
      */
197
-	public function getMinLiveSpotterData($limit = 0,$filter = array())
197
+	public function getMinLiveSpotterData($limit = 0, $filter = array())
198 198
 	{
199 199
 		global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap2DAircraftsLimit;
200 200
 		date_default_timezone_set('UTC');
201
-		$filter_query = $this->getFilter($filter,true,true);
201
+		$filter_query = $this->getFilter($filter, true, true);
202 202
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
203 203
 		if ($globalDBdriver == 'mysql') {
204 204
 			if (isset($globalArchive) && $globalArchive === TRUE) {
205 205
 			//	$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
206 206
 			//	FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= spotter_live.date AND'." spotter_live.latitude <> 0 AND spotter_live.longitude <> 0 ORDER BY date DESC";
207
-				$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
207
+				$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
208 208
 				FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= spotter_live.date AND'." spotter_live.latitude <> 0 AND spotter_live.longitude <> 0";
209 209
 			} else {
210 210
 			//	$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
211 211
 			//	FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query." spotter_live.latitude <> 0 AND spotter_live.longitude <> 0 ORDER BY date DESC";
212
-				$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
212
+				$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
213 213
 				FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query." spotter_live.latitude <> 0 AND spotter_live.longitude <> 0";
214 214
 			}
215 215
 		} else {
216 216
 			if (isset($globalArchive) && $globalArchive === TRUE) {
217 217
 			//	$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
218 218
 			//	FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date AND  spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' ORDER BY date DESC";
219
-				$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
219
+				$query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
220 220
 				FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date AND  spotter_live.latitude <> '0' AND spotter_live.longitude <> '0'";
221 221
 			} else {
222 222
 			//	$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
223 223
 			//	FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate".$filter_query." spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' ORDER BY date DESC";
224
-				$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
224
+				$query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
225 225
 				FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate".$filter_query." spotter_live.latitude <> '0' AND spotter_live.longitude <> '0'";
226 226
 			}
227 227
 		}
@@ -229,14 +229,14 @@  discard block
 block discarded – undo
229 229
 		if ($limit == 0 && isset($globalMap2DAircraftsLimit) && $globalMap2DAircraftsLimit != '') {
230 230
 			$limit = $globalMap2DAircraftsLimit;
231 231
 		}
232
-		if ($limit != 0 && filter_var($limit,FILTER_VALIDATE_INT)) {
232
+		if ($limit != 0 && filter_var($limit, FILTER_VALIDATE_INT)) {
233 233
 			$query .= ' LIMIT '.$limit;
234 234
 		}
235 235
 
236 236
 		try {
237 237
 			$sth = $this->db->prepare($query);
238 238
 			$sth->execute();
239
-		} catch(PDOException $e) {
239
+		} catch (PDOException $e) {
240 240
 			echo $e->getMessage();
241 241
 			die;
242 242
 		}
@@ -253,20 +253,20 @@  discard block
 block discarded – undo
253 253
      * @param string $id
254 254
      * @return array the spotter information
255 255
      */
256
-	public function getMinLastLiveSpotterData($coord = array(),$filter = array(), $limit = 0, $id = '')
256
+	public function getMinLastLiveSpotterData($coord = array(), $filter = array(), $limit = 0, $id = '')
257 257
 	{
258 258
 		global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap3DAircraftsLimit;
259 259
 		date_default_timezone_set('UTC');
260 260
 		$usecoord = false;
261 261
 		if (is_array($coord) && !empty($coord)) {
262
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
263
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
264
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
265
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
262
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
263
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
264
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
265
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
266 266
 			if ($minlong != '' && $minlat != '' && $maxlong != '' && $maxlat != '') $usecoord = true;
267 267
 		}
268
-		$id = filter_var($id,FILTER_SANITIZE_STRING);
269
-		$filter_query = $this->getFilter($filter,true,true);
268
+		$id = filter_var($id, FILTER_SANITIZE_STRING);
269
+		$filter_query = $this->getFilter($filter, true, true);
270 270
 
271 271
 		if (!isset($globalLiveInterval) || $globalLiveInterval == '') $globalLiveInterval = '200';
272 272
 		if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') $globalMap3DAircraftsLimit = '300';
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
 				ORDER BY flightaware_id, date";
297 297
 				if ($limit > 0) $query .= " LIMIT ".$limit;
298 298
 			} else {
299
-				$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
299
+				$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
300 300
 				FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date ";
301 301
 				if ($usecoord) $query .= "AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
302 302
 				if ($id != '') $query .= "OR spotter_live.flightaware_id = :id ";
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
 		try {
347 347
 			$sth = $this->db->prepare($query);
348 348
 			$sth->execute($query_values);
349
-		} catch(PDOException $e) {
349
+		} catch (PDOException $e) {
350 350
 			echo $e->getMessage();
351 351
 			die;
352 352
 		}
@@ -362,12 +362,12 @@  discard block
 block discarded – undo
362 362
      * @param int $limit
363 363
      * @return array the spotter information
364 364
      */
365
-	public function getMinLastLiveSpotterDataByID($id = '',$filter = array(), $limit = 0)
365
+	public function getMinLastLiveSpotterDataByID($id = '', $filter = array(), $limit = 0)
366 366
 	{
367 367
 		global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap3DAircraftsLimit;
368 368
 		date_default_timezone_set('UTC');
369
-		$id = filter_var($id,FILTER_SANITIZE_STRING);
370
-		$filter_query = $this->getFilter($filter,true,true);
369
+		$id = filter_var($id, FILTER_SANITIZE_STRING);
370
+		$filter_query = $this->getFilter($filter, true, true);
371 371
 
372 372
 		if (!isset($globalLiveInterval) || $globalLiveInterval == '') $globalLiveInterval = '200';
373 373
 		if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') $globalMap3DAircraftsLimit = '300';
@@ -392,13 +392,13 @@  discard block
 block discarded – undo
392 392
 			}
393 393
 		} else {
394 394
 			if (isset($globalArchive) && $globalArchive === TRUE) {
395
-				$query  = "SELECT * FROM (
395
+				$query = "SELECT * FROM (
396 396
 				SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source, spotter_archive.registration 
397 397
 				FROM spotter_archive 
398 398
 				INNER JOIN (
399 399
 				    SELECT flightaware_id 
400 400
 				    FROM spotter_live".$filter_query." spotter_live.flightaware_id = :id";
401
-				$query.= ") l ON l.flightaware_id = spotter_archive.flightaware_id ";
401
+				$query .= ") l ON l.flightaware_id = spotter_archive.flightaware_id ";
402 402
 				$query .= "UNION
403 403
 				    SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
404 404
 				    FROM spotter_live".$filter_query." spotter_live.flightaware_id = :id";
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
 		try {
418 418
 			$sth = $this->db->prepare($query);
419 419
 			$sth->execute($query_values);
420
-		} catch(PDOException $e) {
420
+		} catch (PDOException $e) {
421 421
 			echo $e->getMessage();
422 422
 			die;
423 423
 		}
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
 	public function getLiveSpotterCount($filter = array())
435 435
 	{
436 436
 		global $globalDBdriver, $globalLiveInterval;
437
-		$filter_query = $this->getFilter($filter,true,true);
437
+		$filter_query = $this->getFilter($filter, true, true);
438 438
 
439 439
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
440 440
 		if ($globalDBdriver == 'mysql') {
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
 		try {
448 448
 			$sth = $this->db->prepare($query);
449 449
 			$sth->execute();
450
-		} catch(PDOException $e) {
450
+		} catch (PDOException $e) {
451 451
 			echo $e->getMessage();
452 452
 			die;
453 453
 		}
@@ -465,16 +465,16 @@  discard block
 block discarded – undo
465 465
      */
466 466
 	public function getLiveSpotterDatabyCoord($coord, $filter = array())
467 467
 	{
468
-		global $globalDBdriver, $globalLiveInterval,$globalMap2DAircraftsLimit;
468
+		global $globalDBdriver, $globalLiveInterval, $globalMap2DAircraftsLimit;
469 469
 		$Spotter = new Spotter($this->db);
470 470
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
471 471
 		$filter_query = $this->getFilter($filter);
472 472
 
473 473
 		if (is_array($coord)) {
474
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
475
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
476
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
477
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
474
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
475
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
476
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
477
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
478 478
 		} else return array();
479 479
 		if ($globalDBdriver == 'mysql') {
480 480
 			$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY spotter_live.flightaware_id'.$filter_query;
@@ -497,27 +497,27 @@  discard block
 block discarded – undo
497 497
      * @param array $filter
498 498
      * @return array the spotter information
499 499
      */
500
-	public function getMinLiveSpotterDatabyCoord($coord,$limit = 0, $filter = array())
500
+	public function getMinLiveSpotterDatabyCoord($coord, $limit = 0, $filter = array())
501 501
 	{
502
-		global $globalDBdriver, $globalLiveInterval, $globalArchive,$globalMap2DAircraftsLimit;
502
+		global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap2DAircraftsLimit;
503 503
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
504
-		$filter_query = $this->getFilter($filter,true,true);
504
+		$filter_query = $this->getFilter($filter, true, true);
505 505
 
506 506
 		if (is_array($coord)) {
507
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
508
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
509
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
510
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
507
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
508
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
509
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
510
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
511 511
 		} else return array();
512 512
 		if ($globalDBdriver == 'mysql') {
513 513
 			if (isset($globalArchive) && $globalArchive === TRUE) {
514
-				$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
514
+				$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
515 515
 				FROM spotter_live 
516 516
 				'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= spotter_live.date 
517 517
 				AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.'
518 518
 				AND spotter_live.latitude <> 0 AND spotter_live.longitude <> 0 ORDER BY date DESC';
519 519
 			} else {
520
-				$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
520
+				$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
521 521
 				FROM spotter_live 
522 522
 				INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate 
523 523
 				    FROM spotter_live l 
@@ -537,7 +537,7 @@  discard block
 block discarded – undo
537 537
 				AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." 
538 538
 				AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' ORDER BY date DESC";
539 539
 				*/
540
-				$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
540
+				$query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
541 541
 				FROM spotter_live 
542 542
 				".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date 
543 543
 				AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." 
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
 				) s on spotter_live.flightaware_id = s.flightaware_id 
557 557
 				AND spotter_live.date = s.maxdate".$filter_query." spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' ORDER BY date DESC";
558 558
 				*/
559
-				$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
559
+				$query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
560 560
 				FROM spotter_live 
561 561
 				INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate 
562 562
 				    FROM spotter_live l 
@@ -571,13 +571,13 @@  discard block
 block discarded – undo
571 571
 		if ($limit == 0 && isset($globalMap2DAircraftsLimit) && $globalMap2DAircraftsLimit != '') {
572 572
 			$limit = $globalMap2DAircraftsLimit;
573 573
 		}
574
-		if ($limit != 0 && filter_var($limit,FILTER_VALIDATE_INT)) {
574
+		if ($limit != 0 && filter_var($limit, FILTER_VALIDATE_INT)) {
575 575
 			$query .= ' LIMIT '.$limit;
576 576
 		}
577 577
 		try {
578 578
 			$sth = $this->db->prepare($query);
579 579
 			$sth->execute();
580
-		} catch(PDOException $e) {
580
+		} catch (PDOException $e) {
581 581
 			echo $e->getMessage();
582 582
 			die;
583 583
 		}
@@ -627,21 +627,21 @@  discard block
 block discarded – undo
627 627
                 if ($interval == '1m')
628 628
                 {
629 629
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
630
-                } else if ($interval == '15m'){
630
+                } else if ($interval == '15m') {
631 631
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date ';
632 632
                 } 
633 633
             }
634 634
         } else {
635 635
         	$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
636 636
         }
637
-	        $query  = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live 
637
+	        $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live 
638 638
                    WHERE spotter_live.latitude <> '' 
639 639
                    AND spotter_live.longitude <> '' 
640 640
                   ".$additional_query."
641 641
                    HAVING distance < :radius  
642 642
                    ORDER BY distance";
643 643
 
644
-            $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
644
+            $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius));
645 645
             return $spotter_array;
646 646
         }
647 647
 
@@ -658,9 +658,9 @@  discard block
 block discarded – undo
658 658
 		date_default_timezone_set('UTC');
659 659
 
660 660
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
661
-                $query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
661
+                $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
662 662
 
663
-		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true);
663
+		$spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident), '', true);
664 664
 
665 665
 		return $spotter_array;
666 666
 	}
@@ -672,16 +672,16 @@  discard block
 block discarded – undo
672 672
      * @param $date
673 673
      * @return array the spotter information
674 674
      */
675
-	public function getDateLiveSpotterDataByIdent($ident,$date)
675
+	public function getDateLiveSpotterDataByIdent($ident, $date)
676 676
 	{
677 677
 		$Spotter = new Spotter($this->db);
678 678
 		date_default_timezone_set('UTC');
679 679
 
680 680
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
681
-                $query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
681
+                $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
682 682
 
683
-                $date = date('c',$date);
684
-		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
683
+                $date = date('c', $date);
684
+		$spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
685 685
 
686 686
 		return $spotter_array;
687 687
 	}
@@ -697,8 +697,8 @@  discard block
 block discarded – undo
697 697
 		$Spotter = new Spotter($this->db);
698 698
 		date_default_timezone_set('UTC');
699 699
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
700
-		$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
701
-		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true);
700
+		$query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
701
+		$spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id), '', true);
702 702
 		return $spotter_array;
703 703
 	}
704 704
 
@@ -709,15 +709,15 @@  discard block
 block discarded – undo
709 709
      * @param $date
710 710
      * @return array the spotter information
711 711
      */
712
-	public function getDateLiveSpotterDataById($id,$date)
712
+	public function getDateLiveSpotterDataById($id, $date)
713 713
 	{
714 714
 		$Spotter = new Spotter($this->db);
715 715
 		date_default_timezone_set('UTC');
716 716
 
717 717
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
718
-		$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
719
-		$date = date('c',$date);
720
-		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
718
+		$query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
719
+		$date = date('c', $date);
720
+		$spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true);
721 721
 		return $spotter_array;
722 722
 	}
723 723
 
@@ -733,13 +733,13 @@  discard block
 block discarded – undo
733 733
 		date_default_timezone_set('UTC');
734 734
 
735 735
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
736
-                $query  = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
736
+                $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
737 737
 
738 738
     		try {
739 739
 			
740 740
 			$sth = $this->db->prepare($query);
741 741
 			$sth->execute(array(':ident' => $ident));
742
-		} catch(PDOException $e) {
742
+		} catch (PDOException $e) {
743 743
 			echo $e->getMessage();
744 744
 			die;
745 745
 		}
@@ -755,7 +755,7 @@  discard block
 block discarded – undo
755 755
      * @param bool $liveinterval
756 756
      * @return array the spotter information
757 757
      */
758
-	public function getAllLiveSpotterDataById($id,$liveinterval = false)
758
+	public function getAllLiveSpotterDataById($id, $liveinterval = false)
759 759
 	{
760 760
 		global $globalDBdriver, $globalLiveInterval;
761 761
 		date_default_timezone_set('UTC');
@@ -774,7 +774,7 @@  discard block
 block discarded – undo
774 774
 		try {
775 775
 			$sth = $this->db->prepare($query);
776 776
 			$sth->execute(array(':id' => $id));
777
-		} catch(PDOException $e) {
777
+		} catch (PDOException $e) {
778 778
 			echo $e->getMessage();
779 779
 			die;
780 780
 		}
@@ -792,12 +792,12 @@  discard block
 block discarded – undo
792 792
 	{
793 793
 		date_default_timezone_set('UTC');
794 794
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
795
-		$query  = self::$global_query.' WHERE spotter_live.ident = :ident';
795
+		$query = self::$global_query.' WHERE spotter_live.ident = :ident';
796 796
     		try {
797 797
 			
798 798
 			$sth = $this->db->prepare($query);
799 799
 			$sth->execute(array(':ident' => $ident));
800
-		} catch(PDOException $e) {
800
+		} catch (PDOException $e) {
801 801
 			echo $e->getMessage();
802 802
 			die;
803 803
 		}
@@ -827,7 +827,7 @@  discard block
 block discarded – undo
827 827
 			
828 828
 			$sth = $this->db->prepare($query);
829 829
 			$sth->execute();
830
-		} catch(PDOException $e) {
830
+		} catch (PDOException $e) {
831 831
 			return "error";
832 832
 		}
833 833
 
@@ -850,14 +850,14 @@  discard block
 block discarded – undo
850 850
 				
851 851
 				$sth = $this->db->prepare($query);
852 852
 				$sth->execute();
853
-			} catch(PDOException $e) {
853
+			} catch (PDOException $e) {
854 854
 				return "error";
855 855
 			}
856 856
 			$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
857 857
                         $i = 0;
858
-                        $j =0;
858
+                        $j = 0;
859 859
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
860
-			foreach($all as $row)
860
+			foreach ($all as $row)
861 861
 			{
862 862
 				$i++;
863 863
 				$j++;
@@ -865,9 +865,9 @@  discard block
 block discarded – undo
865 865
 					if ($globalDebug) echo ".";
866 866
 				    	try {
867 867
 						
868
-						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
868
+						$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
869 869
 						$sth->execute();
870
-					} catch(PDOException $e) {
870
+					} catch (PDOException $e) {
871 871
 						return "error";
872 872
 					}
873 873
                                 	$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
@@ -878,9 +878,9 @@  discard block
 block discarded – undo
878 878
 			if ($i > 0) {
879 879
     				try {
880 880
 					
881
-					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
881
+					$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
882 882
 					$sth->execute();
883
-				} catch(PDOException $e) {
883
+				} catch (PDOException $e) {
884 884
 					return "error";
885 885
 				}
886 886
 			}
@@ -893,7 +893,7 @@  discard block
 block discarded – undo
893 893
 				
894 894
 				$sth = $this->db->prepare($query);
895 895
 				$sth->execute();
896
-			} catch(PDOException $e) {
896
+			} catch (PDOException $e) {
897 897
 				return "error";
898 898
 			}
899 899
 /*			$query_delete = "DELETE FROM spotter_live WHERE flightaware_id IN (";
@@ -941,13 +941,13 @@  discard block
 block discarded – undo
941 941
 	public function deleteLiveSpotterDataByIdent($ident)
942 942
 	{
943 943
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
944
-		$query  = 'DELETE FROM spotter_live WHERE ident = :ident';
944
+		$query = 'DELETE FROM spotter_live WHERE ident = :ident';
945 945
         
946 946
     		try {
947 947
 			
948 948
 			$sth = $this->db->prepare($query);
949 949
 			$sth->execute(array(':ident' => $ident));
950
-		} catch(PDOException $e) {
950
+		} catch (PDOException $e) {
951 951
 			return "error";
952 952
 		}
953 953
 
@@ -963,13 +963,13 @@  discard block
 block discarded – undo
963 963
 	public function deleteLiveSpotterDataById($id)
964 964
 	{
965 965
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
966
-		$query  = 'DELETE FROM spotter_live WHERE flightaware_id = :id';
966
+		$query = 'DELETE FROM spotter_live WHERE flightaware_id = :id';
967 967
         
968 968
     		try {
969 969
 			
970 970
 			$sth = $this->db->prepare($query);
971 971
 			$sth->execute(array(':id' => $id));
972
-		} catch(PDOException $e) {
972
+		} catch (PDOException $e) {
973 973
 			return "error";
974 974
 		}
975 975
 
@@ -987,13 +987,13 @@  discard block
 block discarded – undo
987 987
 	{
988 988
 		global $globalDBdriver, $globalTimezone;
989 989
 		if ($globalDBdriver == 'mysql') {
990
-			$query  = 'SELECT spotter_live.ident FROM spotter_live 
990
+			$query = 'SELECT spotter_live.ident FROM spotter_live 
991 991
 				WHERE spotter_live.ident = :ident 
992 992
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
993 993
 				AND spotter_live.date < UTC_TIMESTAMP()';
994 994
 			$query_data = array(':ident' => $ident);
995 995
 		} else {
996
-			$query  = "SELECT spotter_live.ident FROM spotter_live 
996
+			$query = "SELECT spotter_live.ident FROM spotter_live 
997 997
 				WHERE spotter_live.ident = :ident 
998 998
 				AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
999 999
 				AND spotter_live.date < now() AT TIME ZONE 'UTC'";
@@ -1002,8 +1002,8 @@  discard block
 block discarded – undo
1002 1002
 		
1003 1003
 		$sth = $this->db->prepare($query);
1004 1004
 		$sth->execute($query_data);
1005
-		$ident_result='';
1006
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1005
+		$ident_result = '';
1006
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1007 1007
 		{
1008 1008
 			$ident_result = $row['ident'];
1009 1009
 		}
@@ -1020,13 +1020,13 @@  discard block
 block discarded – undo
1020 1020
 	{
1021 1021
 		global $globalDBdriver, $globalTimezone;
1022 1022
 		if ($globalDBdriver == 'mysql') {
1023
-			$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
1023
+			$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
1024 1024
 				WHERE spotter_live.ident = :ident 
1025 1025
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 MINUTE)'; 
1026 1026
 //				AND spotter_live.date < UTC_TIMESTAMP()";
1027 1027
 			$query_data = array(':ident' => $ident);
1028 1028
 		} else {
1029
-			$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
1029
+			$query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
1030 1030
 				WHERE spotter_live.ident = :ident 
1031 1031
 				AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '20 MINUTES'";
1032 1032
 //				AND spotter_live.date < now() AT TIME ZONE 'UTC'";
@@ -1035,8 +1035,8 @@  discard block
 block discarded – undo
1035 1035
 		
1036 1036
 		$sth = $this->db->prepare($query);
1037 1037
 		$sth->execute($query_data);
1038
-		$ident_result='';
1039
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1038
+		$ident_result = '';
1039
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1040 1040
 		{
1041 1041
 			$ident_result = $row['flightaware_id'];
1042 1042
 		}
@@ -1053,13 +1053,13 @@  discard block
 block discarded – undo
1053 1053
 	{
1054 1054
 		global $globalDBdriver, $globalTimezone;
1055 1055
 		if ($globalDBdriver == 'mysql') {
1056
-			$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
1056
+			$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
1057 1057
 				WHERE spotter_live.flightaware_id = :id 
1058 1058
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; 
1059 1059
 //				AND spotter_live.date < UTC_TIMESTAMP()";
1060 1060
 			$query_data = array(':id' => $id);
1061 1061
 		} else {
1062
-			$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
1062
+			$query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
1063 1063
 				WHERE spotter_live.flightaware_id = :id 
1064 1064
 				AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'";
1065 1065
 //				AND spotter_live.date < now() AT TIME ZONE 'UTC'";
@@ -1068,8 +1068,8 @@  discard block
 block discarded – undo
1068 1068
 		
1069 1069
 		$sth = $this->db->prepare($query);
1070 1070
 		$sth->execute($query_data);
1071
-		$ident_result='';
1072
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1071
+		$ident_result = '';
1072
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1073 1073
 		{
1074 1074
 			$ident_result = $row['flightaware_id'];
1075 1075
 		}
@@ -1086,13 +1086,13 @@  discard block
 block discarded – undo
1086 1086
 	{
1087 1087
 		global $globalDBdriver, $globalTimezone;
1088 1088
 		if ($globalDBdriver == 'mysql') {
1089
-			$query  = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
1089
+			$query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
1090 1090
 				WHERE spotter_live.ModeS = :modes 
1091 1091
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 MINUTE)'; 
1092 1092
 //				AND spotter_live.date < UTC_TIMESTAMP()";
1093 1093
 			$query_data = array(':modes' => $modes);
1094 1094
 		} else {
1095
-			$query  = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
1095
+			$query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
1096 1096
 				WHERE spotter_live.ModeS = :modes 
1097 1097
 				AND spotter_live.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 MINUTE'";
1098 1098
 //			//	AND spotter_live.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
@@ -1101,8 +1101,8 @@  discard block
 block discarded – undo
1101 1101
 		
1102 1102
 		$sth = $this->db->prepare($query);
1103 1103
 		$sth->execute($query_data);
1104
-		$ident_result='';
1105
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1104
+		$ident_result = '';
1105
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1106 1106
 		{
1107 1107
 			//$ident_result = $row['spotter_live_id'];
1108 1108
 			$ident_result = $row['flightaware_id'];
@@ -1127,8 +1127,8 @@  discard block
 block discarded – undo
1127 1127
 				return array();
1128 1128
 			} else {
1129 1129
 				$q_array = explode(" ", $q);
1130
-				foreach ($q_array as $q_item){
1131
-					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
1130
+				foreach ($q_array as $q_item) {
1131
+					$q_item = filter_var($q_item, FILTER_SANITIZE_STRING);
1132 1132
 					$additional_query .= " AND (";
1133 1133
 					$additional_query .= "(spotter_live.aircraft_icao like '%".$q_item."%') OR ";
1134 1134
 					$additional_query .= "(spotter_live.aircraft_name like '%".$q_item."%') OR ";
@@ -1143,11 +1143,11 @@  discard block
 block discarded – undo
1143 1143
 			}
1144 1144
 		}
1145 1145
 		if ($globalDBdriver == 'mysql') {
1146
-			$query  = "SELECT spotter_live.* FROM spotter_live 
1146
+			$query = "SELECT spotter_live.* FROM spotter_live 
1147 1147
 			    WHERE spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." 
1148 1148
 			    AND spotter_live.date < UTC_TIMESTAMP()";
1149 1149
 		} else {
1150
-			$query  = "SELECT spotter_live.* FROM spotter_live 
1150
+			$query = "SELECT spotter_live.* FROM spotter_live 
1151 1151
 			    WHERE spotter_live.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." 
1152 1152
 			    AND spotter_live.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
1153 1153
 		}
@@ -1189,7 +1189,7 @@  discard block
 block discarded – undo
1189 1189
      * @param string $over_country
1190 1190
      * @return String success or false
1191 1191
      */
1192
-	public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '',$heading = '', $groundspeed = '', $date = '',$departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false,$registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false,$format_source = '', $source_name = '', $over_country = '')
1192
+	public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '', $heading = '', $groundspeed = '', $date = '', $departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false, $registration = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false, $format_source = '', $source_name = '', $over_country = '')
1193 1193
 	{
1194 1194
 		global $globalURL, $globalArchive, $globalDebug;
1195 1195
 		$Common = new Common();
@@ -1289,27 +1289,27 @@  discard block
 block discarded – undo
1289 1289
 		if ($date == '') $date = date("Y-m-d H:i:s", time());
1290 1290
 
1291 1291
         
1292
-		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING);
1293
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
1294
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
1295
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
1296
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
1297
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1298
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1299
-		$waypoints = filter_var($waypoints,FILTER_SANITIZE_STRING);
1300
-		$altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1301
-		$altitude_real = filter_var($altitude_real,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1302
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
1303
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1304
-		$squawk = filter_var($squawk,FILTER_SANITIZE_NUMBER_INT);
1305
-		$route_stop = filter_var($route_stop,FILTER_SANITIZE_STRING);
1306
-		$ModeS = filter_var($ModeS,FILTER_SANITIZE_STRING);
1307
-		$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING);
1308
-		$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
1309
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
1310
-		$source_name = filter_var($source_name,FILTER_SANITIZE_STRING);
1311
-		$over_country = filter_var($over_country,FILTER_SANITIZE_STRING);
1312
-		$verticalrate = filter_var($verticalrate,FILTER_SANITIZE_NUMBER_INT);
1292
+		$flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING);
1293
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1294
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
1295
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
1296
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
1297
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1298
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1299
+		$waypoints = filter_var($waypoints, FILTER_SANITIZE_STRING);
1300
+		$altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1301
+		$altitude_real = filter_var($altitude_real, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1302
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
1303
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1304
+		$squawk = filter_var($squawk, FILTER_SANITIZE_NUMBER_INT);
1305
+		$route_stop = filter_var($route_stop, FILTER_SANITIZE_STRING);
1306
+		$ModeS = filter_var($ModeS, FILTER_SANITIZE_STRING);
1307
+		$pilot_id = filter_var($pilot_id, FILTER_SANITIZE_STRING);
1308
+		$pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
1309
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
1310
+		$source_name = filter_var($source_name, FILTER_SANITIZE_STRING);
1311
+		$over_country = filter_var($over_country, FILTER_SANITIZE_STRING);
1312
+		$verticalrate = filter_var($verticalrate, FILTER_SANITIZE_NUMBER_INT);
1313 1313
 
1314 1314
 		$airline_name = '';
1315 1315
 		$airline_icao = '';
@@ -1331,10 +1331,10 @@  discard block
 block discarded – undo
1331 1331
 		$arrival_airport_country = '';
1332 1332
 		
1333 1333
             	
1334
-            	if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
1335
-            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
1336
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1337
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1334
+            	if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL;
1335
+            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL;
1336
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
1337
+            	if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
1338 1338
 		
1339 1339
 		$query = '';
1340 1340
 		if ($globalArchive) {
@@ -1345,19 +1345,19 @@  discard block
 block discarded – undo
1345 1345
 		$query  .= 'INSERT INTO spotter_live (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop, ModeS, pilot_id, pilot_name, verticalrate, ground, format_source, source_name, over_country, real_altitude) 
1346 1346
 		VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_shadow,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name, :departure_airport_city, :departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date,:departure_airport_time,:arrival_airport_time,:squawk,:route_stop,:ModeS, :pilot_id, :pilot_name, :verticalrate, :ground, :format_source, :source_name, :over_country, :real_altitude)';
1347 1347
 
1348
-		$query_values = array(':flightaware_id' => $flightaware_id,':ident' => $ident, ':registration' => $registration,':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type,':aircraft_icao' => $aircraft_icao,':aircraft_shadow' => $aircraft_shadow,':aircraft_type' => $aircraft_type,':aircraft_manufacturer' => $aircraft_manufacturer,':departure_airport_icao' => $departure_airport_icao,':departure_airport_name' => $departure_airport_name,':departure_airport_city' => $departure_airport_city,':departure_airport_country' => $departure_airport_country,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_name' => $arrival_airport_name,':arrival_airport_city' => $arrival_airport_city,':arrival_airport_country' => $arrival_airport_country,':latitude' => $latitude,':longitude' => $longitude, ':waypoints' => $waypoints,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':departure_airport_time' => $departure_airport_time,':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk,':route_stop' => $route_stop,':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source,':ground' => $ground, ':source_name' => $source_name, ':over_country' => $over_country,':real_altitude' => $altitude_real);
1348
+		$query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_type' => $aircraft_type, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk, ':route_stop' => $route_stop, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':ground' => $ground, ':source_name' => $source_name, ':over_country' => $over_country, ':real_altitude' => $altitude_real);
1349 1349
 		try {
1350 1350
 			
1351 1351
 			$sth = $this->db->prepare($query);
1352 1352
 			$sth->execute($query_values);
1353 1353
 			$sth->closeCursor();
1354
-		} catch(PDOException $e) {
1354
+		} catch (PDOException $e) {
1355 1355
 			return "error : ".$e->getMessage();
1356 1356
 		}
1357 1357
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
1358 1358
 		    if ($globalDebug) echo '(Add to Spotter archive : ';
1359 1359
 		    $SpotterArchive = new SpotterArchive($this->db);
1360
-		    $result =  $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country);
1360
+		    $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time, $arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date, $latitude, $longitude, $waypoints, $altitude, $altitude_real, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name, $verticalrate, $format_source, $source_name, $over_country);
1361 1361
 		    if ($globalDebug) echo $result.')';
1362 1362
 		} elseif ($globalDebug && $putinarchive !== true) {
1363 1363
 			echo '(Not adding to archive)';
@@ -1370,7 +1370,7 @@  discard block
 block discarded – undo
1370 1370
 
1371 1371
 	public function getOrderBy()
1372 1372
 	{
1373
-		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_live.date DESC"));
1373
+		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_live.date DESC"));
1374 1374
 		return $orderby;
1375 1375
 	}
1376 1376
 
Please login to merge, or discard this patch.
Braces   +170 added lines, -57 removed lines patch added patch discarded remove patch
@@ -8,7 +8,9 @@  discard block
 block discarded – undo
8 8
 	public function __construct($dbc = null) {
9 9
 		$Connection = new Connection($dbc);
10 10
 		$this->db = $Connection->db();
11
-		if ($this->db === null) die('Error: No DB connection. (SpotterLive)');
11
+		if ($this->db === null) {
12
+			die('Error: No DB connection. (SpotterLive)');
13
+		}
12 14
 	}
13 15
 
14 16
 
@@ -30,7 +32,9 @@  discard block
 block discarded – undo
30 32
 		if (isset($filter[0]['source'])) {
31 33
 			$filters = array_merge($filters,$filter);
32 34
 		}
33
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
35
+		if (is_array($globalFilter)) {
36
+			$filter = array_merge($filter,$globalFilter);
37
+		}
34 38
 		$filter_query_join = '';
35 39
 		$filter_query_where = '';
36 40
 		foreach($filters as $flt) {
@@ -129,8 +133,11 @@  discard block
 block discarded – undo
129 133
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
130 134
 			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
131 135
 		}
132
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
133
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
136
+		if ($filter_query_where == '' && $where) {
137
+			$filter_query_where = ' WHERE';
138
+		} elseif ($filter_query_where != '' && $and) {
139
+			$filter_query_where .= ' AND';
140
+		}
134 141
 		if ($filter_query_where != '') {
135 142
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
136 143
 		}
@@ -173,9 +180,13 @@  discard block
 block discarded – undo
173 180
 				$orderby_query = ' '.$search_orderby_array[$sort]['sql'];
174 181
 			}
175 182
 		}
176
-		if ($orderby_query == '') $orderby_query = ' ORDER BY date DESC';
183
+		if ($orderby_query == '') {
184
+			$orderby_query = ' ORDER BY date DESC';
185
+		}
177 186
 
178
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
187
+		if (!isset($globalLiveInterval)) {
188
+			$globalLiveInterval = '200';
189
+		}
179 190
 		if ($globalDBdriver == 'mysql') {
180 191
 			//$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
181 192
 			$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query.$orderby_query;
@@ -199,7 +210,9 @@  discard block
 block discarded – undo
199 210
 		global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap2DAircraftsLimit;
200 211
 		date_default_timezone_set('UTC');
201 212
 		$filter_query = $this->getFilter($filter,true,true);
202
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
213
+		if (!isset($globalLiveInterval)) {
214
+			$globalLiveInterval = '200';
215
+		}
203 216
 		if ($globalDBdriver == 'mysql') {
204 217
 			if (isset($globalArchive) && $globalArchive === TRUE) {
205 218
 			//	$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
@@ -263,14 +276,22 @@  discard block
 block discarded – undo
263 276
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
264 277
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
265 278
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
266
-			if ($minlong != '' && $minlat != '' && $maxlong != '' && $maxlat != '') $usecoord = true;
279
+			if ($minlong != '' && $minlat != '' && $maxlong != '' && $maxlat != '') {
280
+				$usecoord = true;
281
+			}
267 282
 		}
268 283
 		$id = filter_var($id,FILTER_SANITIZE_STRING);
269 284
 		$filter_query = $this->getFilter($filter,true,true);
270 285
 
271
-		if (!isset($globalLiveInterval) || $globalLiveInterval == '') $globalLiveInterval = '200';
272
-		if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') $globalMap3DAircraftsLimit = '300';
273
-		if ($limit == 0 || $limit == '') $limit = $globalMap3DAircraftsLimit;
286
+		if (!isset($globalLiveInterval) || $globalLiveInterval == '') {
287
+			$globalLiveInterval = '200';
288
+		}
289
+		if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') {
290
+			$globalMap3DAircraftsLimit = '300';
291
+		}
292
+		if ($limit == 0 || $limit == '') {
293
+			$limit = $globalMap3DAircraftsLimit;
294
+		}
274 295
 		if ($globalDBdriver == 'mysql') {
275 296
 			if (isset($globalArchive) && $globalArchive === TRUE) {
276 297
 				/*
@@ -283,26 +304,42 @@  discard block
 block discarded – undo
283 304
 				FROM spotter_archive INNER JOIN (SELECT flightaware_id FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date";
284 305
 				//if ($limit > 0) $query .= " LIMIT ".$limit;
285 306
 				$query .= ") l ON l.flightaware_id = spotter_archive.flightaware_id ";
286
-				if ($usecoord) $query .= "AND (spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
287
-				if ($id != '') $query .= "OR spotter_archive.flightaware_id = :id ";
307
+				if ($usecoord) {
308
+					$query .= "AND (spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
309
+				}
310
+				if ($id != '') {
311
+					$query .= "OR spotter_archive.flightaware_id = :id ";
312
+				}
288 313
 				$query .= "UNION
289 314
 				SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
290 315
 				FROM spotter_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date";
291
-				if ($usecoord) $query .= " AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")";
292
-				if ($id != '') $query .= " OR spotter_live.flightaware_id = :id";
316
+				if ($usecoord) {
317
+					$query .= " AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")";
318
+				}
319
+				if ($id != '') {
320
+					$query .= " OR spotter_live.flightaware_id = :id";
321
+				}
293 322
 				//if ($limit > 0) $query .= " LIMIT ".$limit;
294 323
 				$query .= ") AS spotter 
295 324
 				WHERE latitude <> '0' AND longitude <> '0' 
296 325
 				ORDER BY flightaware_id, date";
297
-				if ($limit > 0) $query .= " LIMIT ".$limit;
326
+				if ($limit > 0) {
327
+					$query .= " LIMIT ".$limit;
328
+				}
298 329
 			} else {
299 330
 				$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
300 331
 				FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date ";
301
-				if ($usecoord) $query .= "AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
302
-				if ($id != '') $query .= "OR spotter_live.flightaware_id = :id ";
332
+				if ($usecoord) {
333
+					$query .= "AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
334
+				}
335
+				if ($id != '') {
336
+					$query .= "OR spotter_live.flightaware_id = :id ";
337
+				}
303 338
 				$query .= "AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' 
304 339
 				ORDER BY spotter_live.flightaware_id, spotter_live.date";
305
-				if ($limit > 0) $query .= " LIMIT ".$limit;
340
+				if ($limit > 0) {
341
+					$query .= " LIMIT ".$limit;
342
+				}
306 343
 			}
307 344
 		} else {
308 345
 			if (isset($globalArchive) && $globalArchive === TRUE) {
@@ -320,29 +357,47 @@  discard block
 block discarded – undo
320 357
 				    FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date";
321 358
 				//if ($limit > 0) $query .= " ORDER BY spotter_live.date ASC LIMIT ".$limit;
322 359
 				$query .= ") l ON l.flightaware_id = spotter_archive.flightaware_id ";
323
-				if ($usecoord) $query .= "AND (spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
324
-				if ($id != '') $query .= "OR spotter_archive.flightaware_id = :id ";
360
+				if ($usecoord) {
361
+					$query .= "AND (spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
362
+				}
363
+				if ($id != '') {
364
+					$query .= "OR spotter_archive.flightaware_id = :id ";
365
+				}
325 366
 				$query .= "UNION
326 367
 				    SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
327 368
 				    FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date";
328
-				if ($usecoord) $query .= " AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")";
329
-				if ($id != '') $query .= " OR spotter_live.flightaware_id = :id";
369
+				if ($usecoord) {
370
+					$query .= " AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")";
371
+				}
372
+				if ($id != '') {
373
+					$query .= " OR spotter_live.flightaware_id = :id";
374
+				}
330 375
 				//if ($limit > 0) $query .= " ORDER BY date ASC LIMIT ".$limit;
331 376
 				$query .= ") AS spotter WHERE latitude <> '0' AND longitude <> '0' ";
332 377
 				$query .= "ORDER BY flightaware_id, date";
333
-				if ($limit > 0) $query .= " LIMIT ".$limit;
378
+				if ($limit > 0) {
379
+					$query .= " LIMIT ".$limit;
380
+				}
334 381
 			} else {
335 382
 				$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
336 383
 				FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date ";
337
-				if ($usecoord) $query .= "AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
338
-				if ($id != '') $query .= "OR spotter_live.flightaware_id = :id ";
384
+				if ($usecoord) {
385
+					$query .= "AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
386
+				}
387
+				if ($id != '') {
388
+					$query .= "OR spotter_live.flightaware_id = :id ";
389
+				}
339 390
 				$query .= "AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' 
340 391
 				ORDER BY spotter_live.flightaware_id, spotter_live.date";
341
-				if ($limit > 0) $query .= " LIMIT ".$limit;
392
+				if ($limit > 0) {
393
+					$query .= " LIMIT ".$limit;
394
+				}
342 395
 			}
343 396
 		}
344 397
 		$query_values = array();
345
-		if ($id != '') $query_values = array(':id' => $id);
398
+		if ($id != '') {
399
+			$query_values = array(':id' => $id);
400
+		}
346 401
 		try {
347 402
 			$sth = $this->db->prepare($query);
348 403
 			$sth->execute($query_values);
@@ -369,9 +424,15 @@  discard block
 block discarded – undo
369 424
 		$id = filter_var($id,FILTER_SANITIZE_STRING);
370 425
 		$filter_query = $this->getFilter($filter,true,true);
371 426
 
372
-		if (!isset($globalLiveInterval) || $globalLiveInterval == '') $globalLiveInterval = '200';
373
-		if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') $globalMap3DAircraftsLimit = '300';
374
-		if ($limit == 0 || $limit == '') $limit = $globalMap3DAircraftsLimit;
427
+		if (!isset($globalLiveInterval) || $globalLiveInterval == '') {
428
+			$globalLiveInterval = '200';
429
+		}
430
+		if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') {
431
+			$globalMap3DAircraftsLimit = '300';
432
+		}
433
+		if ($limit == 0 || $limit == '') {
434
+			$limit = $globalMap3DAircraftsLimit;
435
+		}
375 436
 		if ($globalDBdriver == 'mysql') {
376 437
 			if (isset($globalArchive) && $globalArchive === TRUE) {
377 438
 				$query  = 'SELECT * FROM (SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source, spotter_archive.registration 
@@ -382,13 +443,17 @@  discard block
 block discarded – undo
382 443
 				$query .= ") AS spotter 
383 444
 				WHERE latitude <> '0' AND longitude <> '0' 
384 445
 				ORDER BY flightaware_id, date";
385
-				if ($limit > 0) $query .= " LIMIT ".$limit;
446
+				if ($limit > 0) {
447
+					$query .= " LIMIT ".$limit;
448
+				}
386 449
 			} else {
387 450
 				$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
388 451
 				FROM spotter_live'.$filter_query.' spotter_live.flightaware_id = :id ';
389 452
 				$query .= "AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' 
390 453
 				ORDER BY spotter_live.flightaware_id, spotter_live.date";
391
-				if ($limit > 0) $query .= " LIMIT ".$limit;
454
+				if ($limit > 0) {
455
+					$query .= " LIMIT ".$limit;
456
+				}
392 457
 			}
393 458
 		} else {
394 459
 			if (isset($globalArchive) && $globalArchive === TRUE) {
@@ -404,13 +469,17 @@  discard block
 block discarded – undo
404 469
 				    FROM spotter_live".$filter_query." spotter_live.flightaware_id = :id";
405 470
 				$query .= ") AS spotter WHERE latitude <> '0' AND longitude <> '0' ";
406 471
 				$query .= "ORDER BY flightaware_id, date";
407
-				if ($limit > 0) $query .= " LIMIT ".$limit;
472
+				if ($limit > 0) {
473
+					$query .= " LIMIT ".$limit;
474
+				}
408 475
 			} else {
409 476
 				$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
410 477
 				FROM spotter_live".$filter_query." spotter_live.flightaware_id = :id ";
411 478
 				$query .= "AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' 
412 479
 				ORDER BY spotter_live.flightaware_id, spotter_live.date";
413
-				if ($limit > 0) $query .= " LIMIT ".$limit;
480
+				if ($limit > 0) {
481
+					$query .= " LIMIT ".$limit;
482
+				}
414 483
 			}
415 484
 		}
416 485
 		$query_values = array(':id' => $id);
@@ -436,7 +505,9 @@  discard block
 block discarded – undo
436 505
 		global $globalDBdriver, $globalLiveInterval;
437 506
 		$filter_query = $this->getFilter($filter,true,true);
438 507
 
439
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
508
+		if (!isset($globalLiveInterval)) {
509
+			$globalLiveInterval = '200';
510
+		}
440 511
 		if ($globalDBdriver == 'mysql') {
441 512
 			//$query  = 'SELECT COUNT(*) as nb FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query;
442 513
 			$query = 'SELECT COUNT(DISTINCT spotter_live.flightaware_id) as nb FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
@@ -467,7 +538,9 @@  discard block
 block discarded – undo
467 538
 	{
468 539
 		global $globalDBdriver, $globalLiveInterval,$globalMap2DAircraftsLimit;
469 540
 		$Spotter = new Spotter($this->db);
470
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
541
+		if (!isset($globalLiveInterval)) {
542
+			$globalLiveInterval = '200';
543
+		}
471 544
 		$filter_query = $this->getFilter($filter);
472 545
 
473 546
 		if (is_array($coord)) {
@@ -475,7 +548,9 @@  discard block
 block discarded – undo
475 548
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
476 549
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
477 550
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
478
-		} else return array();
551
+		} else {
552
+			return array();
553
+		}
479 554
 		if ($globalDBdriver == 'mysql') {
480 555
 			$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY spotter_live.flightaware_id'.$filter_query;
481 556
 		} else {
@@ -500,7 +575,9 @@  discard block
 block discarded – undo
500 575
 	public function getMinLiveSpotterDatabyCoord($coord,$limit = 0, $filter = array())
501 576
 	{
502 577
 		global $globalDBdriver, $globalLiveInterval, $globalArchive,$globalMap2DAircraftsLimit;
503
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
578
+		if (!isset($globalLiveInterval)) {
579
+			$globalLiveInterval = '200';
580
+		}
504 581
 		$filter_query = $this->getFilter($filter,true,true);
505 582
 
506 583
 		if (is_array($coord)) {
@@ -508,7 +585,9 @@  discard block
 block discarded – undo
508 585
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
509 586
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
510 587
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
511
-		} else return array();
588
+		} else {
589
+			return array();
590
+		}
512 591
 		if ($globalDBdriver == 'mysql') {
513 592
 			if (isset($globalArchive) && $globalArchive === TRUE) {
514 593
 				$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
@@ -763,11 +842,15 @@  discard block
 block discarded – undo
763 842
 		//$query  = self::$global_query.' WHERE spotter_live.flightaware_id = :id ORDER BY date';
764 843
 		if ($globalDBdriver == 'mysql') {
765 844
 			$query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id';
766
-			if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
845
+			if ($liveinterval) {
846
+				$query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
847
+			}
767 848
 			$query .= ' ORDER BY date';
768 849
 		} else {
769 850
 			$query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id';
770
-			if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
851
+			if ($liveinterval) {
852
+				$query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
853
+			}
771 854
 			$query .= ' ORDER BY date';
772 855
 		}
773 856
 
@@ -862,7 +945,9 @@  discard block
 block discarded – undo
862 945
 				$i++;
863 946
 				$j++;
864 947
 				if ($j == 30) {
865
-					if ($globalDebug) echo ".";
948
+					if ($globalDebug) {
949
+						echo ".";
950
+					}
866 951
 				    	try {
867 952
 						
868 953
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
@@ -1237,7 +1322,9 @@  discard block
 block discarded – undo
1237 1322
 			{
1238 1323
 				return false;
1239 1324
 			}
1240
-		} else return '';
1325
+		} else {
1326
+			return '';
1327
+		}
1241 1328
 
1242 1329
 		if ($longitude != '')
1243 1330
 		{
@@ -1245,7 +1332,9 @@  discard block
 block discarded – undo
1245 1332
 			{
1246 1333
 				return false;
1247 1334
 			}
1248
-		} else return '';
1335
+		} else {
1336
+			return '';
1337
+		}
1249 1338
 
1250 1339
 		if ($waypoints != '')
1251 1340
 		{
@@ -1261,14 +1350,18 @@  discard block
 block discarded – undo
1261 1350
 			{
1262 1351
 				return false;
1263 1352
 			}
1264
-		} else $altitude = 0;
1353
+		} else {
1354
+			$altitude = 0;
1355
+		}
1265 1356
 		if ($altitude_real != '')
1266 1357
 		{
1267 1358
 			if (!is_numeric($altitude_real))
1268 1359
 			{
1269 1360
 				return false;
1270 1361
 			}
1271
-		} else $altitude_real = 0;
1362
+		} else {
1363
+			$altitude_real = 0;
1364
+		}
1272 1365
 
1273 1366
 		if ($heading != '')
1274 1367
 		{
@@ -1276,7 +1369,9 @@  discard block
 block discarded – undo
1276 1369
 			{
1277 1370
 				return false;
1278 1371
 			}
1279
-		} else $heading = 0;
1372
+		} else {
1373
+			$heading = 0;
1374
+		}
1280 1375
 
1281 1376
 		if ($groundspeed != '')
1282 1377
 		{
@@ -1284,9 +1379,13 @@  discard block
 block discarded – undo
1284 1379
 			{
1285 1380
 				return false;
1286 1381
 			}
1287
-		} else $groundspeed = 0;
1382
+		} else {
1383
+			$groundspeed = 0;
1384
+		}
1288 1385
 		date_default_timezone_set('UTC');
1289
-		if ($date == '') $date = date("Y-m-d H:i:s", time());
1386
+		if ($date == '') {
1387
+			$date = date("Y-m-d H:i:s", time());
1388
+		}
1290 1389
 
1291 1390
         
1292 1391
 		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING);
@@ -1331,14 +1430,24 @@  discard block
 block discarded – undo
1331 1430
 		$arrival_airport_country = '';
1332 1431
 		
1333 1432
             	
1334
-            	if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
1335
-            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
1336
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1337
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1433
+            	if ($squawk == '' || $Common->isInteger($squawk) === false ) {
1434
+            		$squawk = NULL;
1435
+            	}
1436
+            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) {
1437
+            		$verticalrate = NULL;
1438
+            	}
1439
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) {
1440
+            		$groundspeed = 0;
1441
+            	}
1442
+            	if ($heading == '' || $Common->isInteger($heading) === false ) {
1443
+            		$heading = 0;
1444
+            	}
1338 1445
 		
1339 1446
 		$query = '';
1340 1447
 		if ($globalArchive) {
1341
-			if ($globalDebug) echo '-- Delete previous data -- ';
1448
+			if ($globalDebug) {
1449
+				echo '-- Delete previous data -- ';
1450
+			}
1342 1451
 			$query .= 'DELETE FROM spotter_live WHERE flightaware_id = :flightaware_id;';
1343 1452
 		}
1344 1453
 
@@ -1355,10 +1464,14 @@  discard block
 block discarded – undo
1355 1464
 			return "error : ".$e->getMessage();
1356 1465
 		}
1357 1466
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
1358
-		    if ($globalDebug) echo '(Add to Spotter archive : ';
1467
+		    if ($globalDebug) {
1468
+		    	echo '(Add to Spotter archive : ';
1469
+		    }
1359 1470
 		    $SpotterArchive = new SpotterArchive($this->db);
1360 1471
 		    $result =  $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country);
1361
-		    if ($globalDebug) echo $result.')';
1472
+		    if ($globalDebug) {
1473
+		    	echo $result.')';
1474
+		    }
1362 1475
 		} elseif ($globalDebug && $putinarchive !== true) {
1363 1476
 			echo '(Not adding to archive)';
1364 1477
 		} elseif ($globalDebug && $noarchive === true) {
Please login to merge, or discard this patch.
require/class.MarineLive.php 2 patches
Indentation   +229 added lines, -229 removed lines patch added patch discarded remove patch
@@ -20,13 +20,13 @@  discard block
 block discarded – undo
20 20
 	}
21 21
 
22 22
 
23
-    /**
24
-     * Get SQL query part for filter used
25
-     * @param array $filter the filter
26
-     * @param bool $where
27
-     * @param bool $and
28
-     * @return string the SQL part
29
-     */
23
+	/**
24
+	 * Get SQL query part for filter used
25
+	 * @param array $filter the filter
26
+	 * @param bool $where
27
+	 * @param bool $and
28
+	 * @return string the SQL part
29
+	 */
30 30
 	public function getFilter($filter = array(),$where = false,$and = false) {
31 31
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
32 32
 		$filters = array();
@@ -105,14 +105,14 @@  discard block
 block discarded – undo
105 105
 		return $filter_query;
106 106
 	}
107 107
 
108
-    /**
109
-     * Gets all the spotter information based on the latest data entry
110
-     *
111
-     * @param string $limit
112
-     * @param string $sort
113
-     * @param array $filter
114
-     * @return array the spotter information
115
-     */
108
+	/**
109
+	 * Gets all the spotter information based on the latest data entry
110
+	 *
111
+	 * @param string $limit
112
+	 * @param string $sort
113
+	 * @param array $filter
114
+	 * @return array the spotter information
115
+	 */
116 116
 	public function getLiveMarineData($limit = '', $sort = '', $filter = array())
117 117
 	{
118 118
 		global $globalDBdriver, $globalLiveInterval;
@@ -154,12 +154,12 @@  discard block
 block discarded – undo
154 154
 		return $spotter_array;
155 155
 	}
156 156
 
157
-    /**
158
-     * Gets Minimal Live Spotter data
159
-     *
160
-     * @param array $filter
161
-     * @return array the spotter information
162
-     */
157
+	/**
158
+	 * Gets Minimal Live Spotter data
159
+	 *
160
+	 * @param array $filter
161
+	 * @return array the spotter information
162
+	 */
163 163
 	public function getMinLiveMarineData($filter = array())
164 164
 	{
165 165
 		global $globalDBdriver, $globalLiveInterval;
@@ -188,15 +188,15 @@  discard block
 block discarded – undo
188 188
 		return $spotter_array;
189 189
 	}
190 190
 
191
-    /**
192
-     * Gets Minimal Live Spotter data since xx seconds
193
-     *
194
-     * @param array $coord
195
-     * @param array $filter
196
-     * @param bool $limit
197
-     * @param string $id
198
-     * @return array the spotter information
199
-     */
191
+	/**
192
+	 * Gets Minimal Live Spotter data since xx seconds
193
+	 *
194
+	 * @param array $coord
195
+	 * @param array $filter
196
+	 * @param bool $limit
197
+	 * @param string $id
198
+	 * @return array the spotter information
199
+	 */
200 200
 	public function getMinLastLiveMarineData($coord = array(),$filter = array(), $limit = false, $id = '')
201 201
 	{
202 202
 		global $globalDBdriver, $globalLiveInterval, $globalMap3DMarinesLimit, $globalArchive;
@@ -275,14 +275,14 @@  discard block
 block discarded – undo
275 275
 		return $spotter_array;
276 276
 	}
277 277
 
278
-    /**
279
-     * Gets Minimal Live Spotter data since xx seconds
280
-     *
281
-     * @param string $id
282
-     * @param array $filter
283
-     * @param bool $limit
284
-     * @return array the spotter information
285
-     */
278
+	/**
279
+	 * Gets Minimal Live Spotter data since xx seconds
280
+	 *
281
+	 * @param string $id
282
+	 * @param array $filter
283
+	 * @param bool $limit
284
+	 * @return array the spotter information
285
+	 */
286 286
 	public function getMinLastLiveMarineDataByID($id = '',$filter = array(), $limit = false)
287 287
 	{
288 288
 		global $globalDBdriver, $globalLiveInterval, $globalMap3DMarinesLimit, $globalArchive;
@@ -341,12 +341,12 @@  discard block
 block discarded – undo
341 341
 		return $spotter_array;
342 342
 	}
343 343
 
344
-    /**
345
-     * Gets number of latest data entry
346
-     *
347
-     * @param array $filter
348
-     * @return String number of entry
349
-     */
344
+	/**
345
+	 * Gets number of latest data entry
346
+	 *
347
+	 * @param array $filter
348
+	 * @return String number of entry
349
+	 */
350 350
 	public function getLiveMarineCount($filter = array())
351 351
 	{
352 352
 		global $globalDBdriver, $globalLiveInterval;
@@ -370,13 +370,13 @@  discard block
 block discarded – undo
370 370
 		return $result['nb'];
371 371
 	}
372 372
 
373
-    /**
374
-     * Gets all the spotter information based on the latest data entry and coord
375
-     *
376
-     * @param $coord
377
-     * @param array $filter
378
-     * @return array the spotter information
379
-     */
373
+	/**
374
+	 * Gets all the spotter information based on the latest data entry and coord
375
+	 *
376
+	 * @param $coord
377
+	 * @param array $filter
378
+	 * @return array the spotter information
379
+	 */
380 380
 	public function getLiveMarineDatabyCoord($coord, $filter = array())
381 381
 	{
382 382
 		global $globalDBdriver, $globalLiveInterval;
@@ -399,13 +399,13 @@  discard block
 block discarded – undo
399 399
 		return $spotter_array;
400 400
 	}
401 401
 
402
-    /**
403
-     * Gets all the spotter information based on the latest data entry and coord
404
-     *
405
-     * @param $coord
406
-     * @param array $filter
407
-     * @return array the spotter information
408
-     */
402
+	/**
403
+	 * Gets all the spotter information based on the latest data entry and coord
404
+	 *
405
+	 * @param $coord
406
+	 * @param array $filter
407
+	 * @return array the spotter information
408
+	 */
409 409
 	public function getMinLiveMarineDatabyCoord($coord, $filter = array())
410 410
 	{
411 411
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
@@ -473,15 +473,15 @@  discard block
 block discarded – undo
473 473
 		return $spotter_array;
474 474
 	}
475 475
 
476
-    /**
477
-     * Gets all the spotter information based on a user's latitude and longitude
478
-     *
479
-     * @param $lat
480
-     * @param $lng
481
-     * @param $radius
482
-     * @param $interval
483
-     * @return array the spotter information
484
-     */
476
+	/**
477
+	 * Gets all the spotter information based on a user's latitude and longitude
478
+	 *
479
+	 * @param $lat
480
+	 * @param $lng
481
+	 * @param $radius
482
+	 * @param $interval
483
+	 * @return array the spotter information
484
+	 */
485 485
 	public function getLatestMarineForLayar($lat, $lng, $radius, $interval)
486 486
 	{
487 487
 		$Marine = new Marine($this->db);
@@ -538,32 +538,32 @@  discard block
 block discarded – undo
538 538
 	}
539 539
 
540 540
 
541
-    /**
542
-     * Gets all the spotter information based on a particular callsign
543
-     *
544
-     * @param $ident
545
-     * @return array the spotter information
546
-     */
541
+	/**
542
+	 * Gets all the spotter information based on a particular callsign
543
+	 *
544
+	 * @param $ident
545
+	 * @return array the spotter information
546
+	 */
547 547
 	public function getLastLiveMarineDataByIdent($ident)
548 548
 	{
549 549
 		$Marine = new Marine($this->db);
550 550
 		date_default_timezone_set('UTC');
551 551
 
552 552
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
553
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
553
+				$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
554 554
 
555 555
 		$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true);
556 556
 
557 557
 		return $spotter_array;
558 558
 	}
559 559
 
560
-    /**
561
-     * Gets all the spotter information based on a particular callsign
562
-     *
563
-     * @param $ident
564
-     * @param $date
565
-     * @return array the spotter information
566
-     */
560
+	/**
561
+	 * Gets all the spotter information based on a particular callsign
562
+	 *
563
+	 * @param $ident
564
+	 * @param $date
565
+	 * @return array the spotter information
566
+	 */
567 567
 	public function getDateLiveMarineDataByIdent($ident,$date)
568 568
 	{
569 569
 		$Marine = new Marine($this->db);
@@ -575,13 +575,13 @@  discard block
 block discarded – undo
575 575
 		return $spotter_array;
576 576
 	}
577 577
 
578
-    /**
579
-     * Gets all the spotter information based on a particular MMSI
580
-     *
581
-     * @param $mmsi
582
-     * @param $date
583
-     * @return array the spotter information
584
-     */
578
+	/**
579
+	 * Gets all the spotter information based on a particular MMSI
580
+	 *
581
+	 * @param $mmsi
582
+	 * @param $date
583
+	 * @return array the spotter information
584
+	 */
585 585
 	public function getDateLiveMarineDataByMMSI($mmsi,$date)
586 586
 	{
587 587
 		$Marine = new Marine($this->db);
@@ -593,53 +593,53 @@  discard block
 block discarded – undo
593 593
 		return $spotter_array;
594 594
 	}
595 595
 
596
-    /**
597
-     * Gets last spotter information based on a particular callsign
598
-     *
599
-     * @param $id
600
-     * @return array the spotter information
601
-     */
596
+	/**
597
+	 * Gets last spotter information based on a particular callsign
598
+	 *
599
+	 * @param $id
600
+	 * @return array the spotter information
601
+	 */
602 602
 	public function getLastLiveMarineDataById($id)
603 603
 	{
604 604
 		$Marine = new Marine($this->db);
605 605
 		date_default_timezone_set('UTC');
606 606
 
607 607
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
608
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
608
+				$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
609 609
 
610 610
 		$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true);
611 611
 
612 612
 		return $spotter_array;
613 613
 	}
614 614
 
615
-    /**
616
-     * Gets last spotter information based on a particular callsign
617
-     *
618
-     * @param $id
619
-     * @param $date
620
-     * @return array the spotter information
621
-     */
615
+	/**
616
+	 * Gets last spotter information based on a particular callsign
617
+	 *
618
+	 * @param $id
619
+	 * @param $date
620
+	 * @return array the spotter information
621
+	 */
622 622
 	public function getDateLiveMarineDataById($id,$date)
623 623
 	{
624 624
 		$Marine = new Marine($this->db);
625 625
 		date_default_timezone_set('UTC');
626 626
 
627 627
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
628
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
629
-                $date = date('c',$date);
628
+				$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
629
+				$date = date('c',$date);
630 630
 		$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
631 631
 
632 632
 		return $spotter_array;
633 633
 	}
634 634
 
635 635
 
636
-    /**
637
-     * Gets all the spotter information based on a particular id
638
-     *
639
-     * @param $id
640
-     * @param bool $liveinterval
641
-     * @return array the spotter information
642
-     */
636
+	/**
637
+	 * Gets all the spotter information based on a particular id
638
+	 *
639
+	 * @param $id
640
+	 * @param bool $liveinterval
641
+	 * @return array the spotter information
642
+	 */
643 643
 	public function getAllLiveMarineDataById($id,$liveinterval = false)
644 644
 	{
645 645
 		global $globalDBdriver, $globalLiveInterval;
@@ -667,18 +667,18 @@  discard block
 block discarded – undo
667 667
 		return $spotter_array;
668 668
 	}
669 669
 
670
-    /**
671
-     * Gets all the spotter information based on a particular ident
672
-     *
673
-     * @param $ident
674
-     * @return array the spotter information
675
-     */
670
+	/**
671
+	 * Gets all the spotter information based on a particular ident
672
+	 *
673
+	 * @param $ident
674
+	 * @return array the spotter information
675
+	 */
676 676
 	public function getAllLiveMarineDataByIdent($ident)
677 677
 	{
678 678
 		date_default_timezone_set('UTC');
679 679
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
680 680
 		$query  = self::$global_query.' WHERE marine_live.ident = :ident';
681
-    		try {
681
+			try {
682 682
 			
683 683
 			$sth = $this->db->prepare($query);
684 684
 			$sth->execute(array(':ident' => $ident));
@@ -692,23 +692,23 @@  discard block
 block discarded – undo
692 692
 
693 693
 
694 694
 	/**
695
-	* Deletes all info in the table
696
-	*
697
-	* @return String success or false
698
-	*
699
-	*/
695
+	 * Deletes all info in the table
696
+	 *
697
+	 * @return String success or false
698
+	 *
699
+	 */
700 700
 	public function deleteLiveMarineData()
701 701
 	{
702 702
 		global $globalDBdriver;
703 703
 		if ($globalDBdriver == 'mysql') {
704 704
 			//$query  = "DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= marine_live.date";
705 705
 			$query  = 'DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= marine_live.date';
706
-            		//$query  = "DELETE FROM marine_live WHERE marine_live.id IN (SELECT marine_live.id FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= marine_live.date)";
706
+					//$query  = "DELETE FROM marine_live WHERE marine_live.id IN (SELECT marine_live.id FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= marine_live.date)";
707 707
 		} else {
708 708
 			$query  = "DELETE FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= marine_live.date";
709 709
 		}
710 710
         
711
-    		try {
711
+			try {
712 712
 			
713 713
 			$sth = $this->db->prepare($query);
714 714
 			$sth->execute();
@@ -720,18 +720,18 @@  discard block
 block discarded – undo
720 720
 	}
721 721
 
722 722
 	/**
723
-	* Deletes all info in the table for aircraft not seen since 2 HOUR
724
-	*
725
-	* @return String success or false
726
-	*
727
-	*/
723
+	 * Deletes all info in the table for aircraft not seen since 2 HOUR
724
+	 *
725
+	 * @return String success or false
726
+	 *
727
+	 */
728 728
 	public function deleteLiveMarineDataNotUpdated()
729 729
 	{
730 730
 		global $globalDBdriver, $globalDebug;
731 731
 		if ($globalDBdriver == 'mysql') {
732 732
 			//$query = 'SELECT fammarine_id FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= marine_live.date AND marine_live.fammarine_id NOT IN (SELECT fammarine_id FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < marine_live.date) LIMIT 800 OFFSET 0';
733
-    			$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0";
734
-    			try {
733
+				$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0";
734
+				try {
735 735
 				
736 736
 				$sth = $this->db->prepare($query);
737 737
 				$sth->execute();
@@ -739,8 +739,8 @@  discard block
 block discarded – undo
739 739
 				return "error";
740 740
 			}
741 741
 			$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN (';
742
-                        $i = 0;
743
-                        $j =0;
742
+						$i = 0;
743
+						$j =0;
744 744
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
745 745
 			foreach($all as $row)
746 746
 			{
@@ -748,20 +748,20 @@  discard block
 block discarded – undo
748 748
 				$j++;
749 749
 				if ($j == 30) {
750 750
 					if ($globalDebug) echo ".";
751
-				    	try {
751
+						try {
752 752
 						
753 753
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
754 754
 						$sth->execute();
755 755
 					} catch(PDOException $e) {
756 756
 						return "error";
757 757
 					}
758
-                                	$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN (';
759
-                                	$j = 0;
758
+									$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN (';
759
+									$j = 0;
760 760
 				}
761 761
 				$query_delete .= "'".$row['fammarine_id']."',";
762 762
 			}
763 763
 			if ($i > 0) {
764
-    				try {
764
+					try {
765 765
 					
766 766
 					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
767 767
 					$sth->execute();
@@ -772,9 +772,9 @@  discard block
 block discarded – undo
772 772
 			return "success";
773 773
 		} elseif ($globalDBdriver == 'pgsql') {
774 774
 			//$query = "SELECT fammarine_id FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= marine_live.date AND marine_live.fammarine_id NOT IN (SELECT fammarine_id FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < marine_live.date) LIMIT 800 OFFSET 0";
775
-    			//$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0";
776
-    			$query = "DELETE FROM marine_live WHERE fammarine_id IN (SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)";
777
-    			try {
775
+				//$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0";
776
+				$query = "DELETE FROM marine_live WHERE fammarine_id IN (SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)";
777
+				try {
778 778
 				
779 779
 				$sth = $this->db->prepare($query);
780 780
 				$sth->execute();
@@ -818,18 +818,18 @@  discard block
 block discarded – undo
818 818
 		return 'error';
819 819
 	}
820 820
 
821
-    /**
822
-     * Deletes all info in the table for an ident
823
-     *
824
-     * @param $ident
825
-     * @return String success or false
826
-     */
821
+	/**
822
+	 * Deletes all info in the table for an ident
823
+	 *
824
+	 * @param $ident
825
+	 * @return String success or false
826
+	 */
827 827
 	public function deleteLiveMarineDataByIdent($ident)
828 828
 	{
829 829
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
830 830
 		$query  = 'DELETE FROM marine_live WHERE ident = :ident';
831 831
         
832
-    		try {
832
+			try {
833 833
 			
834 834
 			$sth = $this->db->prepare($query);
835 835
 			$sth->execute(array(':ident' => $ident));
@@ -840,18 +840,18 @@  discard block
 block discarded – undo
840 840
 		return "success";
841 841
 	}
842 842
 
843
-    /**
844
-     * Deletes all info in the table for an id
845
-     *
846
-     * @param $id
847
-     * @return String success or false
848
-     */
843
+	/**
844
+	 * Deletes all info in the table for an id
845
+	 *
846
+	 * @param $id
847
+	 * @return String success or false
848
+	 */
849 849
 	public function deleteLiveMarineDataById($id)
850 850
 	{
851 851
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
852 852
 		$query  = 'DELETE FROM marine_live WHERE fammarine_id = :id';
853 853
         
854
-    		try {
854
+			try {
855 855
 			
856 856
 			$sth = $this->db->prepare($query);
857 857
 			$sth->execute(array(':id' => $id));
@@ -864,11 +864,11 @@  discard block
 block discarded – undo
864 864
 
865 865
 
866 866
 	/**
867
-	* Gets the marine races
868
-	*
869
-	* @return array all races
870
-	*
871
-	*/
867
+	 * Gets the marine races
868
+	 *
869
+	 * @return array all races
870
+	 *
871
+	 */
872 872
 	public function getAllRaces()
873 873
 	{
874 874
 		$query  = 'SELECT DISTINCT marine_live.race_id, marine_live.race_name FROM marine_live ORDER BY marine_live.race_name';
@@ -877,12 +877,12 @@  discard block
 block discarded – undo
877 877
 		return $sth->fetchAll(PDO::FETCH_ASSOC);
878 878
 	}
879 879
 
880
-    /**
881
-     * Gets the aircraft ident within the last hour
882
-     *
883
-     * @param $ident
884
-     * @return String the ident
885
-     */
880
+	/**
881
+	 * Gets the aircraft ident within the last hour
882
+	 *
883
+	 * @param $ident
884
+	 * @return String the ident
885
+	 */
886 886
 	public function getIdentFromLastHour($ident)
887 887
 	{
888 888
 		global $globalDBdriver;
@@ -908,14 +908,14 @@  discard block
 block discarded – undo
908 908
 			$ident_result = $row['ident'];
909 909
 		}
910 910
 		return $ident_result;
911
-        }
912
-
913
-    /**
914
-     * Check recent aircraft
915
-     *
916
-     * @param $ident
917
-     * @return String the ident
918
-     */
911
+		}
912
+
913
+	/**
914
+	 * Check recent aircraft
915
+	 *
916
+	 * @param $ident
917
+	 * @return String the ident
918
+	 */
919 919
 	public function checkIdentRecent($ident)
920 920
 	{
921 921
 		global $globalDBdriver;
@@ -941,14 +941,14 @@  discard block
 block discarded – undo
941 941
 			$ident_result = $row['fammarine_id'];
942 942
 		}
943 943
 		return $ident_result;
944
-        }
945
-
946
-    /**
947
-     * Check recent aircraft by id
948
-     *
949
-     * @param $id
950
-     * @return String the ident
951
-     */
944
+		}
945
+
946
+	/**
947
+	 * Check recent aircraft by id
948
+	 *
949
+	 * @param $id
950
+	 * @return String the ident
951
+	 */
952 952
 	public function checkIdRecent($id)
953 953
 	{
954 954
 		global $globalDBdriver;
@@ -974,14 +974,14 @@  discard block
 block discarded – undo
974 974
 			$ident_result = $row['fammarine_id'];
975 975
 		}
976 976
 		return $ident_result;
977
-        }
978
-
979
-    /**
980
-     * Check recent aircraft by mmsi
981
-     *
982
-     * @param $mmsi
983
-     * @return String the ident
984
-     */
977
+		}
978
+
979
+	/**
980
+	 * Check recent aircraft by mmsi
981
+	 *
982
+	 * @param $mmsi
983
+	 * @return String the ident
984
+	 */
985 985
 	public function checkMMSIRecent($mmsi)
986 986
 	{
987 987
 		global $globalDBdriver;
@@ -1007,41 +1007,41 @@  discard block
 block discarded – undo
1007 1007
 			$ident_result = $row['fammarine_id'];
1008 1008
 		}
1009 1009
 		return $ident_result;
1010
-        }
1011
-
1012
-    /**
1013
-     * Adds a new spotter data
1014
-     *
1015
-     * @param String $fammarine_id the ID from flightaware
1016
-     * @param String $ident the flight ident
1017
-     * @param string $latitude
1018
-     * @param string $longitude
1019
-     * @param string $heading
1020
-     * @param string $groundspeed
1021
-     * @param string $date
1022
-     * @param bool $putinarchive
1023
-     * @param string $mmsi
1024
-     * @param string $type
1025
-     * @param string $typeid
1026
-     * @param string $imo
1027
-     * @param string $callsign
1028
-     * @param string $arrival_code
1029
-     * @param string $arrival_date
1030
-     * @param string $status
1031
-     * @param string $statusid
1032
-     * @param bool $noarchive
1033
-     * @param string $format_source
1034
-     * @param string $source_name
1035
-     * @param string $over_country
1036
-     * @param string $captain_id
1037
-     * @param string $captain_name
1038
-     * @param string $race_id
1039
-     * @param string $race_name
1040
-     * @param string $distance
1041
-     * @param string $race_rank
1042
-     * @param string $race_time
1043
-     * @return String success or false
1044
-     */
1010
+		}
1011
+
1012
+	/**
1013
+	 * Adds a new spotter data
1014
+	 *
1015
+	 * @param String $fammarine_id the ID from flightaware
1016
+	 * @param String $ident the flight ident
1017
+	 * @param string $latitude
1018
+	 * @param string $longitude
1019
+	 * @param string $heading
1020
+	 * @param string $groundspeed
1021
+	 * @param string $date
1022
+	 * @param bool $putinarchive
1023
+	 * @param string $mmsi
1024
+	 * @param string $type
1025
+	 * @param string $typeid
1026
+	 * @param string $imo
1027
+	 * @param string $callsign
1028
+	 * @param string $arrival_code
1029
+	 * @param string $arrival_date
1030
+	 * @param string $status
1031
+	 * @param string $statusid
1032
+	 * @param bool $noarchive
1033
+	 * @param string $format_source
1034
+	 * @param string $source_name
1035
+	 * @param string $over_country
1036
+	 * @param string $captain_id
1037
+	 * @param string $captain_name
1038
+	 * @param string $race_id
1039
+	 * @param string $race_name
1040
+	 * @param string $distance
1041
+	 * @param string $race_rank
1042
+	 * @param string $race_time
1043
+	 * @return String success or false
1044
+	 */
1045 1045
 	public function addLiveMarineData($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 = '',$captain_id = '',$captain_name = '',$race_id = '', $race_name = '', $distance = '', $race_rank = '', $race_time = '')
1046 1046
 	{
1047 1047
 		global $globalArchive, $globalDebug;
@@ -1123,10 +1123,10 @@  discard block
 block discarded – undo
1123 1123
 		if ($statusid == '') $statusid = NULL;
1124 1124
 		if ($distance == '') $distance = NULL;
1125 1125
 
1126
-            	//if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1127
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1128
-            	if ($arrival_date == '') $arrival_date = NULL;
1129
-            	$query = '';
1126
+				//if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1127
+				if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1128
+				if ($arrival_date == '') $arrival_date = NULL;
1129
+				$query = '';
1130 1130
 		if ($globalArchive) {
1131 1131
 			if ($globalDebug) echo '-- Delete previous data -- ';
1132 1132
 			$query .= 'DELETE FROM marine_live WHERE fammarine_id = :fammarine_id;';
Please login to merge, or discard this patch.
Spacing   +129 added lines, -129 removed lines patch added patch discarded remove patch
@@ -27,33 +27,33 @@  discard block
 block discarded – undo
27 27
      * @param bool $and
28 28
      * @return string the SQL part
29 29
      */
30
-	public function getFilter($filter = array(),$where = false,$and = false) {
30
+	public function getFilter($filter = array(), $where = false, $and = false) {
31 31
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
32 32
 		$filters = array();
33 33
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
34 34
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
35 35
 				$filters = $globalStatsFilters[$globalFilterName];
36 36
 			} else {
37
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
37
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
38 38
 			}
39 39
 		}
40 40
 		if (isset($filter[0]['source'])) {
41
-			$filters = array_merge($filters,$filter);
41
+			$filters = array_merge($filters, $filter);
42 42
 		}
43
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
43
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
44 44
 		$filter_query_join = '';
45 45
 		$filter_query_where = '';
46
-		foreach($filters as $flt) {
46
+		foreach ($filters as $flt) {
47 47
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
48 48
 				if (isset($flt['source'])) {
49
-					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."') AND marine_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id";
49
+					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND marine_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id";
50 50
 				} else {
51
-					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id";
51
+					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id";
52 52
 				}
53 53
 			}
54 54
 		}
55 55
 		if (isset($filter['source']) && !empty($filter['source'])) {
56
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
56
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
57 57
 		}
58 58
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
59 59
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
@@ -91,15 +91,15 @@  discard block
 block discarded – undo
91 91
 					$filter_query_date .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'";
92 92
 				}
93 93
 			}
94
-			$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.fammarine_id = marine_live.fammarine_id";
94
+			$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.fammarine_id = marine_live.fammarine_id";
95 95
 		}
96 96
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
97
-			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
97
+			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
98 98
 		}
99 99
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
100 100
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
101 101
 		if ($filter_query_where != '') {
102
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
102
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
103 103
 		}
104 104
 		$filter_query = $filter_query_join.$filter_query_where;
105 105
 		return $filter_query;
@@ -124,8 +124,8 @@  discard block
 block discarded – undo
124 124
 		if ($limit != '')
125 125
 		{
126 126
 			$limit_array = explode(',', $limit);
127
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
128
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
127
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
128
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
129 129
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
130 130
 			{
131 131
 				$limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0];
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 				$orderby_query = ' '.$search_orderby_array[$sort]['sql'];
141 141
 			}
142 142
 		}
143
-		if ($orderby_query == '') $orderby_query= ' ORDER BY date DESC';
143
+		if ($orderby_query == '') $orderby_query = ' ORDER BY date DESC';
144 144
 
145 145
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
146 146
 		if ($globalDBdriver == 'mysql') {
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 		} else {
150 150
 			$query  = "SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate".$filter_query.$orderby_query;
151 151
 		}
152
-		$spotter_array = $Marine->getDataFromDB($query.$limit_query,array(),'',true);
152
+		$spotter_array = $Marine->getDataFromDB($query.$limit_query, array(), '', true);
153 153
 
154 154
 		return $spotter_array;
155 155
 	}
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 		global $globalDBdriver, $globalLiveInterval;
166 166
 		date_default_timezone_set('UTC');
167 167
 
168
-		$filter_query = $this->getFilter($filter,true,true);
168
+		$filter_query = $this->getFilter($filter, true, true);
169 169
 
170 170
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
171 171
 		if ($globalDBdriver == 'mysql') {
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 		try {
180 180
 			$sth = $this->db->prepare($query);
181 181
 			$sth->execute();
182
-		} catch(PDOException $e) {
182
+		} catch (PDOException $e) {
183 183
 			echo $e->getMessage();
184 184
 			die;
185 185
 		}
@@ -197,26 +197,26 @@  discard block
 block discarded – undo
197 197
      * @param string $id
198 198
      * @return array the spotter information
199 199
      */
200
-	public function getMinLastLiveMarineData($coord = array(),$filter = array(), $limit = false, $id = '')
200
+	public function getMinLastLiveMarineData($coord = array(), $filter = array(), $limit = false, $id = '')
201 201
 	{
202 202
 		global $globalDBdriver, $globalLiveInterval, $globalMap3DMarinesLimit, $globalArchive;
203 203
 		date_default_timezone_set('UTC');
204 204
 		$usecoord = false;
205 205
 		if (is_array($coord) && !empty($coord)) {
206
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
207
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
208
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
209
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
206
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
207
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
208
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
209
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
210 210
 			$usecoord = true;
211 211
 		}
212
-		$id = filter_var($id,FILTER_SANITIZE_STRING);
213
-		$filter_query = $this->getFilter($filter,true,true);
212
+		$id = filter_var($id, FILTER_SANITIZE_STRING);
213
+		$filter_query = $this->getFilter($filter, true, true);
214 214
 
215 215
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
216 216
 		if (!isset($globalMap3DMarinesLimit) || $globalMap3DMarinesLimit == '') $globalMap3DMarinesLimit = '300';
217 217
 		if ($globalDBdriver == 'mysql') {
218 218
 			if (isset($globalArchive) && $globalArchive === TRUE) {
219
-				$query  = 'SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id,marine_archive.type_id,marine_archive.type, marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source, marine_archive.captain_name, marine_archive.race_id, marine_archive.race_rank, marine_archive.race_name 
219
+				$query = 'SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id,marine_archive.type_id,marine_archive.type, marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source, marine_archive.captain_name, marine_archive.race_id, marine_archive.race_rank, marine_archive.race_name 
220 220
 				    FROM marine_archive INNER JOIN (SELECT fammarine_id FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date) l ON l.fammarine_id = marine_archive.fammarine_id ";
221 221
 				if ($usecoord) $query .= "AND marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
222 222
 				if ($id != '') $query .= "OR marine_archive.fammarine_id = :id ";
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 				    ORDER BY fammarine_id, date";
231 231
 				if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit;
232 232
 			} else {
233
-				$query  = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id, marine_live.race_rank, marine_live.race_name 
233
+				$query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id, marine_live.race_rank, marine_live.race_name 
234 234
 				    FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date ";
235 235
 				if ($usecoord) $query .= "AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
236 236
 				if ($id != '') $query .= "OR marine_live.fammarine_id = :id ";
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 			}
241 241
 		} else {
242 242
 			if (isset($globalArchive) && $globalArchive === TRUE) {
243
-				$query  = "SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.type_id, marine_archive.type,marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source, marine_archive.captain_name, marine_archive.race_id, marine_archive.race_rank, marine_archive.race_name 
243
+				$query = "SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.type_id, marine_archive.type,marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source, marine_archive.captain_name, marine_archive.race_id, marine_archive.race_rank, marine_archive.race_name 
244 244
 				    FROM marine_archive INNER JOIN (SELECT fammarine_id FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date) l ON l.fammarine_id = marine_archive.fammarine_id ";
245 245
 				if ($usecoord) $query .= "AND (marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
246 246
 				if ($id != '') $query .= "OR marine_archive.fammarine_id = :id ";
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
 		try {
268 268
 			$sth = $this->db->prepare($query);
269 269
 			$sth->execute($query_values);
270
-		} catch(PDOException $e) {
270
+		} catch (PDOException $e) {
271 271
 			echo $e->getMessage();
272 272
 			die;
273 273
 		}
@@ -283,12 +283,12 @@  discard block
 block discarded – undo
283 283
      * @param bool $limit
284 284
      * @return array the spotter information
285 285
      */
286
-	public function getMinLastLiveMarineDataByID($id = '',$filter = array(), $limit = false)
286
+	public function getMinLastLiveMarineDataByID($id = '', $filter = array(), $limit = false)
287 287
 	{
288 288
 		global $globalDBdriver, $globalLiveInterval, $globalMap3DMarinesLimit, $globalArchive;
289 289
 		date_default_timezone_set('UTC');
290
-		$id = filter_var($id,FILTER_SANITIZE_STRING);
291
-		$filter_query = $this->getFilter($filter,true,true);
290
+		$id = filter_var($id, FILTER_SANITIZE_STRING);
291
+		$filter_query = $this->getFilter($filter, true, true);
292 292
 
293 293
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
294 294
 		if (!isset($globalMap3DMarinesLimit) || $globalMap3DMarinesLimit == '') $globalMap3DMarinesLimit = '300';
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
 		try {
334 334
 			$sth = $this->db->prepare($query);
335 335
 			$sth->execute($query_values);
336
-		} catch(PDOException $e) {
336
+		} catch (PDOException $e) {
337 337
 			echo $e->getMessage();
338 338
 			die;
339 339
 		}
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
 	public function getLiveMarineCount($filter = array())
351 351
 	{
352 352
 		global $globalDBdriver, $globalLiveInterval;
353
-		$filter_query = $this->getFilter($filter,true,true);
353
+		$filter_query = $this->getFilter($filter, true, true);
354 354
 
355 355
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
356 356
 		if ($globalDBdriver == 'mysql') {
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
 		try {
362 362
 			$sth = $this->db->prepare($query);
363 363
 			$sth->execute();
364
-		} catch(PDOException $e) {
364
+		} catch (PDOException $e) {
365 365
 			echo $e->getMessage();
366 366
 			die;
367 367
 		}
@@ -385,10 +385,10 @@  discard block
 block discarded – undo
385 385
 		$filter_query = $this->getFilter($filter);
386 386
 
387 387
 		if (is_array($coord)) {
388
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
389
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
390
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
391
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
388
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
389
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
390
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
391
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
392 392
 		} else return array();
393 393
 		if ($globalDBdriver == 'mysql') {
394 394
 			$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY marine_live.fammarine_id ORDER BY date DESC'.$filter_query;
@@ -411,13 +411,13 @@  discard block
 block discarded – undo
411 411
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
412 412
 		$Marine = new Marine($this->db);
413 413
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
414
-		$filter_query = $this->getFilter($filter,true,true);
414
+		$filter_query = $this->getFilter($filter, true, true);
415 415
 
416 416
 		if (is_array($coord)) {
417
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
418
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
419
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
420
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
417
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
418
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
419
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
420
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
421 421
 		} else return array();
422 422
 		/*
423 423
 		if ($globalDBdriver == 'mysql') {
@@ -432,13 +432,13 @@  discard block
 block discarded – undo
432 432
 		*/
433 433
 		if ($globalDBdriver == 'mysql') {
434 434
 			if (isset($globalArchive) && $globalArchive === TRUE) {
435
-				$query  = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id, marine_live.race_rank, marine_live.race_name 
435
+				$query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id, marine_live.race_rank, marine_live.race_name 
436 436
 				    FROM marine_live 
437 437
 				    '.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= marine_live.date 
438 438
 				    AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.'
439 439
 				    AND marine_live.latitude <> 0 AND marine_live.longitude <> 0 ORDER BY race_rank,date DESC';
440 440
 			} else {
441
-				$query  = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id, marine_live.race_rank, marine_live.race_name 
441
+				$query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id, marine_live.race_rank, marine_live.race_name 
442 442
 				    FROM marine_live 
443 443
 				    INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate 
444 444
 				    FROM marine_live l 
@@ -450,14 +450,14 @@  discard block
 block discarded – undo
450 450
 			}
451 451
 		} else {
452 452
 			if (isset($globalArchive) && $globalArchive === TRUE) {
453
-				$query  = "SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id, marine_live.race_rank, marine_live.race_name 
453
+				$query = "SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id, marine_live.race_rank, marine_live.race_name 
454 454
 				    FROM marine_live 
455 455
 				    ".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date 
456 456
 				    AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." 
457 457
 				    AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." 
458 458
 				    AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' ORDER BY race_rank, date DESC";
459 459
 			} else {
460
-				$query  = "SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id, marine_live.race_rank, marine_live.race_name 
460
+				$query = "SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id, marine_live.race_rank, marine_live.race_name 
461 461
 				    FROM marine_live 
462 462
 				    INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate 
463 463
 				    FROM marine_live l 
@@ -517,7 +517,7 @@  discard block
 block discarded – undo
517 517
 				if ($interval == '1m')
518 518
 				{
519 519
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';
520
-				} else if ($interval == '15m'){
520
+				} else if ($interval == '15m') {
521 521
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date ';
522 522
 				}
523 523
 			}
@@ -525,14 +525,14 @@  discard block
 block discarded – undo
525 525
 			$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';
526 526
 		}
527 527
 
528
-		$query  = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live 
528
+		$query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live 
529 529
                    WHERE marine_live.latitude <> '' 
530 530
                                    AND marine_live.longitude <> '' 
531 531
                    ".$additional_query."
532 532
                    HAVING distance < :radius  
533 533
                                    ORDER BY distance";
534 534
 
535
-		$spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
535
+		$spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius));
536 536
 
537 537
 		return $spotter_array;
538 538
 	}
@@ -550,9 +550,9 @@  discard block
 block discarded – undo
550 550
 		date_default_timezone_set('UTC');
551 551
 
552 552
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
553
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
553
+                $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
554 554
 
555
-		$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true);
555
+		$spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident), '', true);
556 556
 
557 557
 		return $spotter_array;
558 558
 	}
@@ -564,14 +564,14 @@  discard block
 block discarded – undo
564 564
      * @param $date
565 565
      * @return array the spotter information
566 566
      */
567
-	public function getDateLiveMarineDataByIdent($ident,$date)
567
+	public function getDateLiveMarineDataByIdent($ident, $date)
568 568
 	{
569 569
 		$Marine = new Marine($this->db);
570 570
 		date_default_timezone_set('UTC');
571 571
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
572 572
 		$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
573
-		$date = date('c',$date);
574
-		$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
573
+		$date = date('c', $date);
574
+		$spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
575 575
 		return $spotter_array;
576 576
 	}
577 577
 
@@ -582,14 +582,14 @@  discard block
 block discarded – undo
582 582
      * @param $date
583 583
      * @return array the spotter information
584 584
      */
585
-	public function getDateLiveMarineDataByMMSI($mmsi,$date)
585
+	public function getDateLiveMarineDataByMMSI($mmsi, $date)
586 586
 	{
587 587
 		$Marine = new Marine($this->db);
588 588
 		date_default_timezone_set('UTC');
589 589
 		$mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT);
590 590
 		$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.mmsi = :mmsi AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
591
-		$date = date('c',$date);
592
-		$spotter_array = $Marine->getDataFromDB($query,array(':mmsi' => $mmsi,':date' => $date));
591
+		$date = date('c', $date);
592
+		$spotter_array = $Marine->getDataFromDB($query, array(':mmsi' => $mmsi, ':date' => $date));
593 593
 		return $spotter_array;
594 594
 	}
595 595
 
@@ -605,9 +605,9 @@  discard block
 block discarded – undo
605 605
 		date_default_timezone_set('UTC');
606 606
 
607 607
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
608
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
608
+                $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
609 609
 
610
-		$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true);
610
+		$spotter_array = $Marine->getDataFromDB($query, array(':id' => $id), '', true);
611 611
 
612 612
 		return $spotter_array;
613 613
 	}
@@ -619,15 +619,15 @@  discard block
 block discarded – undo
619 619
      * @param $date
620 620
      * @return array the spotter information
621 621
      */
622
-	public function getDateLiveMarineDataById($id,$date)
622
+	public function getDateLiveMarineDataById($id, $date)
623 623
 	{
624 624
 		$Marine = new Marine($this->db);
625 625
 		date_default_timezone_set('UTC');
626 626
 
627 627
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
628
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
629
-                $date = date('c',$date);
630
-		$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
628
+                $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
629
+                $date = date('c', $date);
630
+		$spotter_array = $Marine->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true);
631 631
 
632 632
 		return $spotter_array;
633 633
 	}
@@ -640,7 +640,7 @@  discard block
 block discarded – undo
640 640
      * @param bool $liveinterval
641 641
      * @return array the spotter information
642 642
      */
643
-	public function getAllLiveMarineDataById($id,$liveinterval = false)
643
+	public function getAllLiveMarineDataById($id, $liveinterval = false)
644 644
 	{
645 645
 		global $globalDBdriver, $globalLiveInterval;
646 646
 		date_default_timezone_set('UTC');
@@ -659,7 +659,7 @@  discard block
 block discarded – undo
659 659
 		try {
660 660
 			$sth = $this->db->prepare($query);
661 661
 			$sth->execute(array(':id' => $id));
662
-		} catch(PDOException $e) {
662
+		} catch (PDOException $e) {
663 663
 			echo $e->getMessage();
664 664
 			die;
665 665
 		}
@@ -677,12 +677,12 @@  discard block
 block discarded – undo
677 677
 	{
678 678
 		date_default_timezone_set('UTC');
679 679
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
680
-		$query  = self::$global_query.' WHERE marine_live.ident = :ident';
680
+		$query = self::$global_query.' WHERE marine_live.ident = :ident';
681 681
     		try {
682 682
 			
683 683
 			$sth = $this->db->prepare($query);
684 684
 			$sth->execute(array(':ident' => $ident));
685
-		} catch(PDOException $e) {
685
+		} catch (PDOException $e) {
686 686
 			echo $e->getMessage();
687 687
 			die;
688 688
 		}
@@ -712,7 +712,7 @@  discard block
 block discarded – undo
712 712
 			
713 713
 			$sth = $this->db->prepare($query);
714 714
 			$sth->execute();
715
-		} catch(PDOException $e) {
715
+		} catch (PDOException $e) {
716 716
 			return "error";
717 717
 		}
718 718
 
@@ -735,14 +735,14 @@  discard block
 block discarded – undo
735 735
 				
736 736
 				$sth = $this->db->prepare($query);
737 737
 				$sth->execute();
738
-			} catch(PDOException $e) {
738
+			} catch (PDOException $e) {
739 739
 				return "error";
740 740
 			}
741 741
 			$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN (';
742 742
                         $i = 0;
743
-                        $j =0;
743
+                        $j = 0;
744 744
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
745
-			foreach($all as $row)
745
+			foreach ($all as $row)
746 746
 			{
747 747
 				$i++;
748 748
 				$j++;
@@ -750,9 +750,9 @@  discard block
 block discarded – undo
750 750
 					if ($globalDebug) echo ".";
751 751
 				    	try {
752 752
 						
753
-						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
753
+						$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
754 754
 						$sth->execute();
755
-					} catch(PDOException $e) {
755
+					} catch (PDOException $e) {
756 756
 						return "error";
757 757
 					}
758 758
                                 	$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN (';
@@ -763,9 +763,9 @@  discard block
 block discarded – undo
763 763
 			if ($i > 0) {
764 764
     				try {
765 765
 					
766
-					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
766
+					$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
767 767
 					$sth->execute();
768
-				} catch(PDOException $e) {
768
+				} catch (PDOException $e) {
769 769
 					return "error";
770 770
 				}
771 771
 			}
@@ -778,7 +778,7 @@  discard block
 block discarded – undo
778 778
 				
779 779
 				$sth = $this->db->prepare($query);
780 780
 				$sth->execute();
781
-			} catch(PDOException $e) {
781
+			} catch (PDOException $e) {
782 782
 				return "error";
783 783
 			}
784 784
 /*			$query_delete = "DELETE FROM marine_live WHERE fammarine_id IN (";
@@ -827,13 +827,13 @@  discard block
 block discarded – undo
827 827
 	public function deleteLiveMarineDataByIdent($ident)
828 828
 	{
829 829
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
830
-		$query  = 'DELETE FROM marine_live WHERE ident = :ident';
830
+		$query = 'DELETE FROM marine_live WHERE ident = :ident';
831 831
         
832 832
     		try {
833 833
 			
834 834
 			$sth = $this->db->prepare($query);
835 835
 			$sth->execute(array(':ident' => $ident));
836
-		} catch(PDOException $e) {
836
+		} catch (PDOException $e) {
837 837
 			return "error";
838 838
 		}
839 839
 
@@ -849,13 +849,13 @@  discard block
 block discarded – undo
849 849
 	public function deleteLiveMarineDataById($id)
850 850
 	{
851 851
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
852
-		$query  = 'DELETE FROM marine_live WHERE fammarine_id = :id';
852
+		$query = 'DELETE FROM marine_live WHERE fammarine_id = :id';
853 853
         
854 854
     		try {
855 855
 			
856 856
 			$sth = $this->db->prepare($query);
857 857
 			$sth->execute(array(':id' => $id));
858
-		} catch(PDOException $e) {
858
+		} catch (PDOException $e) {
859 859
 			return "error";
860 860
 		}
861 861
 
@@ -871,7 +871,7 @@  discard block
 block discarded – undo
871 871
 	*/
872 872
 	public function getAllRaces()
873 873
 	{
874
-		$query  = 'SELECT DISTINCT marine_live.race_id, marine_live.race_name FROM marine_live ORDER BY marine_live.race_name';
874
+		$query = 'SELECT DISTINCT marine_live.race_id, marine_live.race_name FROM marine_live ORDER BY marine_live.race_name';
875 875
 		$sth = $this->db->prepare($query);
876 876
 		$sth->execute();
877 877
 		return $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -887,13 +887,13 @@  discard block
 block discarded – undo
887 887
 	{
888 888
 		global $globalDBdriver;
889 889
 		if ($globalDBdriver == 'mysql') {
890
-			$query  = 'SELECT marine_live.ident FROM marine_live 
890
+			$query = 'SELECT marine_live.ident FROM marine_live 
891 891
 				WHERE marine_live.ident = :ident 
892 892
 				AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
893 893
 				AND marine_live.date < UTC_TIMESTAMP()';
894 894
 			$query_data = array(':ident' => $ident);
895 895
 		} else {
896
-			$query  = "SELECT marine_live.ident FROM marine_live 
896
+			$query = "SELECT marine_live.ident FROM marine_live 
897 897
 				WHERE marine_live.ident = :ident 
898 898
 				AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
899 899
 				AND marine_live.date < now() AT TIME ZONE 'UTC'";
@@ -902,8 +902,8 @@  discard block
 block discarded – undo
902 902
 		
903 903
 		$sth = $this->db->prepare($query);
904 904
 		$sth->execute($query_data);
905
-		$ident_result='';
906
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
905
+		$ident_result = '';
906
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
907 907
 		{
908 908
 			$ident_result = $row['ident'];
909 909
 		}
@@ -920,13 +920,13 @@  discard block
 block discarded – undo
920 920
 	{
921 921
 		global $globalDBdriver;
922 922
 		if ($globalDBdriver == 'mysql') {
923
-			$query  = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
923
+			$query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
924 924
 				WHERE marine_live.ident = :ident 
925 925
 				AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; 
926 926
 //				AND marine_live.date < UTC_TIMESTAMP()";
927 927
 			$query_data = array(':ident' => $ident);
928 928
 		} else {
929
-			$query  = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
929
+			$query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
930 930
 				WHERE marine_live.ident = :ident 
931 931
 				AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'";
932 932
 //				AND marine_live.date < now() AT TIME ZONE 'UTC'";
@@ -935,8 +935,8 @@  discard block
 block discarded – undo
935 935
 		
936 936
 		$sth = $this->db->prepare($query);
937 937
 		$sth->execute($query_data);
938
-		$ident_result='';
939
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
938
+		$ident_result = '';
939
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
940 940
 		{
941 941
 			$ident_result = $row['fammarine_id'];
942 942
 		}
@@ -953,13 +953,13 @@  discard block
 block discarded – undo
953 953
 	{
954 954
 		global $globalDBdriver;
955 955
 		if ($globalDBdriver == 'mysql') {
956
-			$query  = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
956
+			$query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
957 957
 				WHERE marine_live.fammarine_id = :id 
958 958
 				AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; 
959 959
 //				AND marine_live.date < UTC_TIMESTAMP()";
960 960
 			$query_data = array(':id' => $id);
961 961
 		} else {
962
-			$query  = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
962
+			$query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
963 963
 				WHERE marine_live.fammarine_id = :id 
964 964
 				AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'";
965 965
 //				AND marine_live.date < now() AT TIME ZONE 'UTC'";
@@ -968,8 +968,8 @@  discard block
 block discarded – undo
968 968
 		
969 969
 		$sth = $this->db->prepare($query);
970 970
 		$sth->execute($query_data);
971
-		$ident_result='';
972
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
971
+		$ident_result = '';
972
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
973 973
 		{
974 974
 			$ident_result = $row['fammarine_id'];
975 975
 		}
@@ -986,13 +986,13 @@  discard block
 block discarded – undo
986 986
 	{
987 987
 		global $globalDBdriver;
988 988
 		if ($globalDBdriver == 'mysql') {
989
-			$query  = 'SELECT marine_live.fammarine_id FROM marine_live 
989
+			$query = 'SELECT marine_live.fammarine_id FROM marine_live 
990 990
 				WHERE marine_live.mmsi = :mmsi 
991 991
 				AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; 
992 992
 //				AND marine_live.date < UTC_TIMESTAMP()";
993 993
 			$query_data = array(':mmsi' => $mmsi);
994 994
 		} else {
995
-			$query  = "SELECT marine_live.fammarine_id FROM marine_live 
995
+			$query = "SELECT marine_live.fammarine_id FROM marine_live 
996 996
 				WHERE marine_live.mmsi = :mmsi 
997 997
 				AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'";
998 998
 //				AND marine_live.date < now() AT TIME ZONE 'UTC'";
@@ -1001,8 +1001,8 @@  discard block
 block discarded – undo
1001 1001
 		
1002 1002
 		$sth = $this->db->prepare($query);
1003 1003
 		$sth->execute($query_data);
1004
-		$ident_result='';
1005
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1004
+		$ident_result = '';
1005
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1006 1006
 		{
1007 1007
 			$ident_result = $row['fammarine_id'];
1008 1008
 		}
@@ -1042,7 +1042,7 @@  discard block
 block discarded – undo
1042 1042
      * @param string $race_time
1043 1043
      * @return String success or false
1044 1044
      */
1045
-	public function addLiveMarineData($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 = '',$captain_id = '',$captain_name = '',$race_id = '', $race_name = '', $distance = '', $race_rank = '', $race_time = '')
1045
+	public function addLiveMarineData($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 = '', $captain_id = '', $captain_name = '', $race_id = '', $race_name = '', $distance = '', $race_rank = '', $race_time = '')
1046 1046
 	{
1047 1047
 		global $globalArchive, $globalDebug;
1048 1048
 		$Common = new Common();
@@ -1094,37 +1094,37 @@  discard block
 block discarded – undo
1094 1094
 		if ($date == '') $date = date("Y-m-d H:i:s", time());
1095 1095
 
1096 1096
         
1097
-		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
1098
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
1099
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1100
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1101
-		$distance = filter_var($distance,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1102
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
1103
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1104
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
1105
-		$source_name = filter_var($source_name,FILTER_SANITIZE_STRING);
1106
-		$over_country = filter_var($over_country,FILTER_SANITIZE_STRING);
1107
-		$type = filter_var($type,FILTER_SANITIZE_STRING);
1108
-		$typeid = filter_var($typeid,FILTER_SANITIZE_NUMBER_INT);
1109
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
1110
-		$status = filter_var($status,FILTER_SANITIZE_STRING);
1111
-		$statusid = filter_var($statusid,FILTER_SANITIZE_NUMBER_INT);
1112
-		$imo = filter_var($imo,FILTER_SANITIZE_STRING);
1113
-		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
1114
-		$arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING);
1115
-		$arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING);
1116
-		$captain_id = filter_var($captain_id,FILTER_SANITIZE_STRING);
1117
-		$captain_name = filter_var($captain_name,FILTER_SANITIZE_STRING);
1118
-		$race_id = filter_var($race_id,FILTER_SANITIZE_STRING);
1119
-		$race_name = filter_var($race_name,FILTER_SANITIZE_STRING);
1120
-		$race_rank = filter_var($race_rank,FILTER_SANITIZE_NUMBER_INT);
1121
-		$race_time = filter_var($race_time,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1097
+		$fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING);
1098
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1099
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1100
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1101
+		$distance = filter_var($distance, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1102
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
1103
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1104
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
1105
+		$source_name = filter_var($source_name, FILTER_SANITIZE_STRING);
1106
+		$over_country = filter_var($over_country, FILTER_SANITIZE_STRING);
1107
+		$type = filter_var($type, FILTER_SANITIZE_STRING);
1108
+		$typeid = filter_var($typeid, FILTER_SANITIZE_NUMBER_INT);
1109
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT);
1110
+		$status = filter_var($status, FILTER_SANITIZE_STRING);
1111
+		$statusid = filter_var($statusid, FILTER_SANITIZE_NUMBER_INT);
1112
+		$imo = filter_var($imo, FILTER_SANITIZE_STRING);
1113
+		$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
1114
+		$arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING);
1115
+		$arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING);
1116
+		$captain_id = filter_var($captain_id, FILTER_SANITIZE_STRING);
1117
+		$captain_name = filter_var($captain_name, FILTER_SANITIZE_STRING);
1118
+		$race_id = filter_var($race_id, FILTER_SANITIZE_STRING);
1119
+		$race_name = filter_var($race_name, FILTER_SANITIZE_STRING);
1120
+		$race_rank = filter_var($race_rank, FILTER_SANITIZE_NUMBER_INT);
1121
+		$race_time = filter_var($race_time, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1122 1122
 		if ($typeid == '') $typeid = NULL;
1123 1123
 		if ($statusid == '') $statusid = NULL;
1124 1124
 		if ($distance == '') $distance = NULL;
1125 1125
 
1126 1126
             	//if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1127
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1127
+            	if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
1128 1128
             	if ($arrival_date == '') $arrival_date = NULL;
1129 1129
             	$query = '';
1130 1130
 		if ($globalArchive) {
@@ -1133,19 +1133,19 @@  discard block
 block discarded – undo
1133 1133
 		}
1134 1134
 		$query .= 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,type_id,status,status_id,imo,arrival_port_name,arrival_port_date,captain_id,captain_name,race_id,race_name,distance,race_rank,race_time) 
1135 1135
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:mmsi,:type,:typeid,:status,:statusid,:imo,:arrival_port_name,:arrival_port_date,:captain_id,:captain_name,:race_id,:race_name,:distance,:race_rank,:race_time)';
1136
-		$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,':typeid' => $typeid,':status' => $status,':statusid' => $statusid,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date,':captain_id' => $captain_id,':captain_name' => $captain_name,':race_id' => $race_id,':race_name' => $race_name,':distance' => $distance,':race_time' => $race_time,':race_rank' => $race_rank);
1136
+		$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, ':typeid' => $typeid, ':status' => $status, ':statusid' => $statusid, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date, ':captain_id' => $captain_id, ':captain_name' => $captain_name, ':race_id' => $race_id, ':race_name' => $race_name, ':distance' => $distance, ':race_time' => $race_time, ':race_rank' => $race_rank);
1137 1137
 		try {
1138 1138
 			$sth = $this->db->prepare($query);
1139 1139
 			$sth->execute($query_values);
1140 1140
 			$sth->closeCursor();
1141
-		} catch(PDOException $e) {
1141
+		} catch (PDOException $e) {
1142 1142
 			return "error : ".$e->getMessage();
1143 1143
 		}
1144 1144
 		
1145 1145
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
1146 1146
 			if ($globalDebug) echo '(Add to Marine archive : ';
1147 1147
 			$MarineArchive = new MarineArchive($this->db);
1148
-			$result =  $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi,$type,$typeid,$imo, $callsign,$arrival_code,$arrival_date,$status,$statusid,$noarchive,$format_source, $source_name, $over_country,$captain_id,$captain_name,$race_id,$race_name,$distance,$race_rank,$race_time);
1148
+			$result = $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi, $type, $typeid, $imo, $callsign, $arrival_code, $arrival_date, $status, $statusid, $noarchive, $format_source, $source_name, $over_country, $captain_id, $captain_name, $race_id, $race_name, $distance, $race_rank, $race_time);
1149 1149
 			if ($globalDebug) echo $result.')';
1150 1150
 		}
1151 1151
 		return "success";
@@ -1153,7 +1153,7 @@  discard block
 block discarded – undo
1153 1153
 
1154 1154
 	public function getOrderBy()
1155 1155
 	{
1156
-		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_live.date DESC"));
1156
+		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_live.date DESC"));
1157 1157
 		return $orderby;
1158 1158
 	}
1159 1159
 
Please login to merge, or discard this patch.
require/class.METAR.php 1 patch
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 			$Connection = new Connection();
69 69
 			$sth = $Connection->db->prepare($query);
70 70
 			$sth->execute();
71
-		} catch(PDOException $e) {
71
+		} catch (PDOException $e) {
72 72
 			return "error : ".$e->getMessage();
73 73
 		}
74 74
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 			$Connection = new Connection();
88 88
 			$sth = $Connection->db->prepare($query);
89 89
 			$sth->execute();
90
-		} catch(PDOException $e) {
90
+		} catch (PDOException $e) {
91 91
 			return "error : ".$e->getMessage();
92 92
 		}
93 93
 		return '';
@@ -101,9 +101,9 @@  discard block
 block discarded – undo
101 101
 	public function parse($data) {
102 102
 		//$data = str_replace(array('\n','\r','\r','\n'),'',$data);
103 103
 		$codes = implode('|', array_keys($this->texts));
104
-		$regWeather = '#^(\+|\-|VC)?(' . $codes . ')(' . $codes . ')?$#';
104
+		$regWeather = '#^(\+|\-|VC)?('.$codes.')('.$codes.')?$#';
105 105
 		//$pieces = explode(' ',$data);
106
-		$pieces = preg_split('/\s/',$data);
106
+		$pieces = preg_split('/\s/', $data);
107 107
 		$pos = 0;
108 108
 		if ($pieces[0] == 'METAR') $pos++;
109 109
 		elseif ($pieces[0] == 'SPECI') $pos++;
@@ -113,25 +113,25 @@  discard block
 block discarded – undo
113 113
 		$result['location'] = $pieces[$pos];
114 114
 		$pos++;
115 115
 		if (!isset($pieces[$pos])) return $result;
116
-		$result['dayofmonth'] = substr($pieces[$pos],0,2);
117
-		$result['time'] = substr($pieces[$pos],2,4);
116
+		$result['dayofmonth'] = substr($pieces[$pos], 0, 2);
117
+		$result['time'] = substr($pieces[$pos], 2, 4);
118 118
 		$c = count($pieces);
119
-		for($pos++; $pos < $c; $pos++) {
119
+		for ($pos++; $pos < $c; $pos++) {
120 120
 			$piece = $pieces[$pos];
121 121
 			if ($piece == 'RMK') break;
122 122
 			if ($piece == 'AUTO') $result['auto'] = true;
123 123
 			if ($piece == 'COR') $result['correction'] = true;
124 124
 			// Wind Speed
125 125
 			if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) {
126
-				$result['wind']['direction'] = (float)$matches[1];
126
+				$result['wind']['direction'] = (float) $matches[1];
127 127
 				$result['wind']['unit'] = $matches[4];
128
-				if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2);
129
-				elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2);
130
-				elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2);
131
-				$result['wind']['gust'] = (float)$matches[3];
128
+				if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float) $matches[2])*0.51444444444, 2);
129
+				elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float) $matches[2])*1000, 2);
130
+				elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float) $matches[2]), 2);
131
+				$result['wind']['gust'] = (float) $matches[3];
132 132
 				$result['wind']['unit'] = $matches[4];
133
-				$result['wind']['min_variation'] = array_key_exists(5,$matches) ? $matches[5] : 0;
134
-				$result['wind']['max_variation'] = array_key_exists(6,$matches) ? $matches[6] : 0;
133
+				$result['wind']['min_variation'] = array_key_exists(5, $matches) ? $matches[5] : 0;
134
+				$result['wind']['max_variation'] = array_key_exists(6, $matches) ? $matches[6] : 0;
135 135
 			}
136 136
 
137 137
 /*    			if (preg_match('#^([0-9]{3})([0-9]{2})(G([0-9]{2}))?(KT|MPS)$#', $piece, $matches)) {
@@ -152,17 +152,17 @@  discard block
 block discarded – undo
152 152
 
153 153
 			// Temperature
154 154
 			if (preg_match('#^(M?[0-9]{2,})/(M?[0-9]{2,})$#', $piece, $matches)) {
155
-				$temp = (float)$matches[1];
155
+				$temp = (float) $matches[1];
156 156
 				if ($matches[1]{0} == 'M') {
157
-					$temp = ((float)substr($matches[1], 1)) * -1;
157
+					$temp = ((float) substr($matches[1], 1))*-1;
158 158
 				}
159 159
 				$result['temperature'] = $temp;
160
-				$dew = (float)$matches[2];
160
+				$dew = (float) $matches[2];
161 161
 				if ($matches[2]{0} == 'M') {
162
-					$dew = ((float)substr($matches[2], 1)) * -1;
162
+					$dew = ((float) substr($matches[2], 1))*-1;
163 163
 				}
164 164
 				$result['dew'] = $dew;
165
-				$result['rh'] = round(100*(exp((17.625*$dew)/(243.04+$dew))/exp((17.625*$temp)/(243.04+$temp))));
165
+				$result['rh'] = round(100*(exp((17.625*$dew)/(243.04 + $dew))/exp((17.625*$temp)/(243.04 + $temp))));
166 166
 			}
167 167
 			// QNH
168 168
 			if (preg_match('#^(A|Q)([0-9]{4})$#', $piece, $matches)) {
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 					$result['QNH'] = $matches[2];
173 173
 				} else {
174 174
 					// inHg
175
-					$result['QNH'] = round(($matches[2] / 100)*33.86389,2);
175
+					$result['QNH'] = round(($matches[2]/100)*33.86389, 2);
176 176
 				}
177 177
 				/*
178 178
     				$result['QNH'] = $matches[1] == 'Q' ? $matches[2] : ($matches[2] / 100);
@@ -193,12 +193,12 @@  discard block
 block discarded – undo
193 193
     			// Visibility
194 194
 			if (preg_match('#^([0-9]{4})|(([0-9]{1,4})SM)$#', $piece, $matches)) {
195 195
 				if (isset($matches[3]) && strlen($matches[3]) > 0) {
196
-					$result['visibility'] = (float)$matches[3] * 1609.34;
196
+					$result['visibility'] = (float) $matches[3]*1609.34;
197 197
 				} else {
198 198
 					if ($matches[1] == '9999') {
199 199
 						$result['visibility'] = '> 10000';
200 200
 					} else {
201
-						$result['visibility'] = (float)$matches[1];
201
+						$result['visibility'] = (float) $matches[1];
202 202
 					}
203 203
 				}
204 204
 			}
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 				elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage';
222 222
 				elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility';
223 223
 				$cloud['type_code'] = $type;
224
-				$cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048);
224
+				$cloud['level'] = round(((float) $matches[2])*100*0.3048);
225 225
 				if (isset($matches[3])) $significant = $matches[3];
226 226
 				else $significant = '';
227 227
 				if ($significant == 'CB') $cloud['significant'] = 'Cumulonimbus';
@@ -242,8 +242,8 @@  discard block
 block discarded – undo
242 242
 				$rvr['runway'] = $matches[1];
243 243
 				$rvr['assessment'] = $matches[2];
244 244
 				$rvr['rvr'] = $matches[3];
245
-				$rvr['rvr_max'] = array_key_exists(4,$matches) ? $matches[4] : 0;
246
-				$rvr['unit'] = array_key_exists(5,$matches) ? $matches[5] : '';
245
+				$rvr['rvr_max'] = array_key_exists(4, $matches) ? $matches[4] : 0;
246
+				$rvr['unit'] = array_key_exists(5, $matches) ? $matches[5] : '';
247 247
 				$result['RVR'] = $rvr;
248 248
 			}
249 249
 			//if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
@@ -256,12 +256,12 @@  discard block
 block discarded – undo
256 256
 				$result['RVR']['friction'] = $matches[5];
257 257
 			}
258 258
 			if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
259
-				if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
260
-				else $range = array('exact' => (float)$matches[2], 'unit' => 'M');
259
+				if (isset($matches[5])) $range = array('exact' => (float) $matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
260
+				else $range = array('exact' => (float) $matches[2], 'unit' => 'M');
261 261
 				if (isset($matches[3])) {
262 262
 					$range = Array(
263
-					    'from' => (float)$matches[2],
264
-					    'to'   => (float)$matches[4],
263
+					    'from' => (float) $matches[2],
264
+					    'to'   => (float) $matches[4],
265 265
 					    'unit' => $matches[5] ? 'FT' : 'M'
266 266
 					);
267 267
 				}
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 		try {
315 315
 			$sth = $this->db->prepare($query);
316 316
 			$sth->execute($query_values);
317
-		} catch(PDOException $e) {
317
+		} catch (PDOException $e) {
318 318
 			return "error : ".$e->getMessage();
319 319
 		}
320 320
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -330,19 +330,19 @@  discard block
 block discarded – undo
330 330
 	 * @param String $metar METAR text
331 331
 	 * @param String $date date of the METAR
332 332
 	*/
333
-	public function addMETAR($location,$metar,$date) {
333
+	public function addMETAR($location, $metar, $date) {
334 334
 		global $globalDBdriver;
335
-		$date = date('Y-m-d H:i:s',strtotime($date));
335
+		$date = date('Y-m-d H:i:s', strtotime($date));
336 336
 		if ($globalDBdriver == 'mysql') {
337 337
 			$query = "INSERT INTO metar (metar_location,metar_date,metar) VALUES (:location,:date,:metar) ON DUPLICATE KEY UPDATE metar_date = :date, metar = :metar";
338 338
 		} else {
339 339
 			$query = "UPDATE metar SET metar_date = :date, metar = :metar WHERE metar_location = :location;INSERT INTO metar (metar_location,metar_date,metar) SELECT :location,:date,:metar WHERE NOT EXISTS (SELECT 1 FROM metar WHERE metar_location = :location);";
340 340
 		}
341
-		$query_values = array(':location' => $location,':date' => $date,':metar' => utf8_encode($metar));
341
+		$query_values = array(':location' => $location, ':date' => $date, ':metar' => utf8_encode($metar));
342 342
 		try {
343 343
 			$sth = $this->db->prepare($query);
344 344
 			$sth->execute($query_values);
345
-		} catch(PDOException $e) {
345
+		} catch (PDOException $e) {
346 346
 			return "error : ".$e->getMessage();
347 347
 		}
348 348
 		return '';
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
 		try {
359 359
 			$sth = $this->db->prepare($query);
360 360
 			$sth->execute($query_values);
361
-		} catch(PDOException $e) {
361
+		} catch (PDOException $e) {
362 362
 			return "error : ".$e->getMessage();
363 363
 		}
364 364
 		return '';
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
 		try {
373 373
 			$sth = $this->db->prepare($query);
374 374
 			$sth->execute();
375
-		} catch(PDOException $e) {
375
+		} catch (PDOException $e) {
376 376
 			return "error : ".$e->getMessage();
377 377
 		}
378 378
 		return '';
@@ -387,29 +387,29 @@  discard block
 block discarded – undo
387 387
 		date_default_timezone_set("UTC");
388 388
 		$Common = new Common();
389 389
 		if (isset($globalIVAO) && $globalIVAO) {
390
-			$Common->download('http://wx.ivao.aero/metar.php',dirname(__FILE__).'/../install/tmp/ivaometar.txt');
391
-			$handle = fopen(dirname(__FILE__).'/../install/tmp/ivaometar.txt',"r");
390
+			$Common->download('http://wx.ivao.aero/metar.php', dirname(__FILE__).'/../install/tmp/ivaometar.txt');
391
+			$handle = fopen(dirname(__FILE__).'/../install/tmp/ivaometar.txt', "r");
392 392
 		} else {
393
-			$Common->download('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT',dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT');
394
-			$handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT',"r");
393
+			$Common->download('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT', dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT');
394
+			$handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT', "r");
395 395
 		}
396 396
 		if ($handle) {
397 397
 			if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB...";
398 398
 			$date = '';
399 399
 			if ($globalTransaction) $this->db->beginTransaction();
400
-			while(($line = fgets($handle,4096)) !== false) {
401
-				$line = str_replace(array("\r\n","\r", "\n"), '', $line);
402
-				if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
400
+			while (($line = fgets($handle, 4096)) !== false) {
401
+				$line = str_replace(array("\r\n", "\r", "\n"), '', $line);
402
+				if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#', $line)) {
403 403
 					$date = $line;
404 404
 				} elseif (trim($line) != '') {
405 405
 					if ($date == '') $date = date('Y/m/d H:m');
406 406
 					$pos = 0;
407
-					$pieces = preg_split('/\s/',$line);
407
+					$pieces = preg_split('/\s/', $line);
408 408
 					if ($pieces[0] == 'METAR') $pos++;
409 409
 					if (strlen($pieces[$pos]) != 4) $pos++;
410 410
 					$location = $pieces[$pos];
411 411
 					//if ($location == 'LFLL') echo 'location: '.$location.' - date: '.$date.' - data: '.$line."\n";
412
-					echo $this->addMETAR($location,$line,$date);
412
+					echo $this->addMETAR($location, $line, $date);
413 413
 				}
414 414
 			}
415 415
 			fclose($handle);
@@ -428,23 +428,23 @@  discard block
 block discarded – undo
428 428
 		if ($globalMETARurl == '') return array();
429 429
 		date_default_timezone_set("UTC");
430 430
 		$Common = new Common();
431
-		$url = str_replace('{icao}',$icao,$globalMETARurl);
431
+		$url = str_replace('{icao}', $icao, $globalMETARurl);
432 432
 		$cycle = $Common->getData($url);
433 433
 		$date = '';
434
-		foreach(explode("\n",$cycle) as $line) {
435
-			$line = str_replace(array("\r\n","\r", "\n"), '', $line);
436
-			if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
434
+		foreach (explode("\n", $cycle) as $line) {
435
+			$line = str_replace(array("\r\n", "\r", "\n"), '', $line);
436
+			if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#', $line)) {
437 437
 				$date = $line;
438 438
 			} 
439 439
 			if (trim($line) != '') {
440 440
 				if ($date == '') $date = date('Y/m/d H:m');
441 441
 				$pos = 0;
442
-				$pieces = preg_split('/\s/',$line);
442
+				$pieces = preg_split('/\s/', $line);
443 443
 				if ($pieces[0] == 'METAR') $pos++;
444 444
 				if (strlen($pieces[$pos]) != 4) $pos++;
445 445
 				$location = $pieces[$pos];
446 446
 				if (strlen($location == 4)) {
447
-					$this->addMETAR($location,$line,$date);
447
+					$this->addMETAR($location, $line, $date);
448 448
 					return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line));
449 449
 				} else return array();
450 450
 			}
Please login to merge, or discard this patch.