Completed
Push — master ( e2bc06...df777b )
by Yannick
29:51
created
require/class.Weather.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -4,12 +4,12 @@  discard block
 block discarded – undo
4 4
 	public function buildcloudlayer($metar) {
5 5
 		//print_r($metar);
6 6
 		$result = array();
7
-		foreach($metar['cloud'] as $key => $data) {
7
+		foreach ($metar['cloud'] as $key => $data) {
8 8
 			$alt_m = $metar['cloud'][$key]['level'];
9 9
 			$alt_ft = $alt_m*3.28084;
10 10
 			$pressure = $metar['QNH'];
11
-			$cumulus_base = 122.0 * ($metar['temperature'] - $metar['dew']);
12
-			$stratus_base = 100.0 * (100.0 * $metar['rh'])*0.3048;
11
+			$cumulus_base = 122.0*($metar['temperature'] - $metar['dew']);
12
+			$stratus_base = 100.0*(100.0*$metar['rh'])*0.3048;
13 13
 			$coverage_norm = 0.0;
14 14
 			if ($metar['cloud'][$key]['type'] == 'Few') {
15 15
 				$coverage_norm = 2.0/8.0;
@@ -31,9 +31,9 @@  discard block
 block discarded – undo
31 31
 					$layer_type = 'ns';
32 32
 				}
33 33
 			} else {
34
-				if ($cumulus_base * 0.80 < $alt_m && $cumulus_base * 1.20 > $alt_m) {
34
+				if ($cumulus_base*0.80 < $alt_m && $cumulus_base*1.20 > $alt_m) {
35 35
 					$layer_type = 'cu';
36
-				} elseif ($stratus_base * 0.80 < $alt_m && $stratus_base * 1.40 > $alt_m) {
36
+				} elseif ($stratus_base*0.80 < $alt_m && $stratus_base*1.40 > $alt_m) {
37 37
 					$layer_type = 'st';
38 38
 				} else {
39 39
 					if ($alt_ft < 2000) {
@@ -46,10 +46,10 @@  discard block
 block discarded – undo
46 46
 				}
47 47
 			}
48 48
 			//echo 'coverage norm : '.$coverage_norm.' - layer_type: '.$layer_type."\n";
49
-			$result[] = array('cov' => $coverage_norm, 'type' => $layer_type,'alt' => $alt_m,'rh' => $metar['rh']);
49
+			$result[] = array('cov' => $coverage_norm, 'type' => $layer_type, 'alt' => $alt_m, 'rh' => $metar['rh']);
50 50
 		}
51 51
 		if (count($result) < 2 && $metar['rh'] > 60) {
52
-			$result[] = array('cov' => 0.75, 'type' => 'ci','alt' => 4000,'rh' => $metar['rh']);
52
+			$result[] = array('cov' => 0.75, 'type' => 'ci', 'alt' => 4000, 'rh' => $metar['rh']);
53 53
 		}
54 54
 		return $result;
55 55
 	}
@@ -68,8 +68,8 @@  discard block
 block discarded – undo
68 68
 		
69 69
 		// http://nomads.ncep.noaa.gov/cgi-bin/filter_gfs_0p50.pl?file=gfs.t05z.pgrb2full.0p50.f000&lev_10_m_above_ground=on&lev_surface=on&var_TMP=on&var_UGRD=on&var_VGRD=on&leftlon=0&rightlon=360&toplat=90&bottomlat=-90&dir=/gfs.2017111717
70 70
 		$resolution = '0.5';
71
-		$baseurl = 'http://nomads.ncep.noaa.gov/cgi-bin/filter_gfs_'.($resolution === '1' ? '1p00':'0p50').'.pl';
72
-		$get = array('file' => 'gfs.t'.sprintf('%02d',(6*floor(date('G')/6))).($resolution === '1' ? 'z.pgrb2.1p00.f000' : 'z.pgrb2full.0p50.f000'),
71
+		$baseurl = 'http://nomads.ncep.noaa.gov/cgi-bin/filter_gfs_'.($resolution === '1' ? '1p00' : '0p50').'.pl';
72
+		$get = array('file' => 'gfs.t'.sprintf('%02d', (6*floor(date('G')/6))).($resolution === '1' ? 'z.pgrb2.1p00.f000' : 'z.pgrb2full.0p50.f000'),
73 73
 			'lev_10_m_above_ground' => 'on',
74 74
 			'lev_surface' => 'on',
75 75
 			'var_TMP' => 'on',
@@ -79,12 +79,12 @@  discard block
 block discarded – undo
79 79
 			'rightlon' => 360,
80 80
 			'toplat' => 90,
81 81
 			'bottomlat' => -90,
82
-			'dir' => '/gfs.'.date('Ymd').sprintf('%02d',(6*floor(date('G')/6)))
82
+			'dir' => '/gfs.'.date('Ymd').sprintf('%02d', (6*floor(date('G')/6)))
83 83
 		);
84 84
 		$url = $baseurl.'?'.http_build_query($get);
85 85
 		echo $url;
86 86
 		$Common = new Common();
87
-		$Common->download($url,$windpathsrc);
87
+		$Common->download($url, $windpathsrc);
88 88
 		system($grib2json.' --data --output '.$windpathdest.' --names --compact '.$windpathsrc);
89 89
 	}
90 90
 }
Please login to merge, or discard this patch.
require/class.Tracker.php 1 patch
Spacing   +176 added lines, -176 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 require_once(dirname(__FILE__).'/class.Image.php');
5 5
 $global_tracker_query = "SELECT tracker_output.* FROM tracker_output";
6 6
 
7
-class Tracker{
7
+class Tracker {
8 8
 	public $db;
9 9
 	
10 10
 	public function __construct($dbc = null) {
@@ -19,33 +19,33 @@  discard block
 block discarded – undo
19 19
 	* @return Array the SQL part
20 20
 	*/
21 21
 	
22
-	public function getFilter($filter = array(),$where = false,$and = false) {
22
+	public function getFilter($filter = array(), $where = false, $and = false) {
23 23
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
24 24
 		$filters = array();
25 25
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
26 26
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
27 27
 				$filters = $globalStatsFilters[$globalFilterName];
28 28
 			} else {
29
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
29
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
30 30
 			}
31 31
 		}
32 32
 		if (isset($filter[0]['source'])) {
33
-			$filters = array_merge($filters,$filter);
33
+			$filters = array_merge($filters, $filter);
34 34
 		}
35
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
35
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
36 36
 		$filter_query_join = '';
37 37
 		$filter_query_where = '';
38
-		foreach($filters as $flt) {
38
+		foreach ($filters as $flt) {
39 39
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
40 40
 				if (isset($flt['source'])) {
41
-					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."') AND tracker_output.format_source IN ('".implode("','",$flt['source'])."')) spfi ON spfi.famtrackid = tracker_output.famtrackid";
41
+					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."') AND tracker_output.format_source IN ('".implode("','", $flt['source'])."')) spfi ON spfi.famtrackid = tracker_output.famtrackid";
42 42
 				} else {
43
-					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."')) spfi ON spfi.famtrackid = tracker_output.famtrackid";
43
+					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."')) spfi ON spfi.famtrackid = tracker_output.famtrackid";
44 44
 				}
45 45
 			}
46 46
 		}
47 47
 		if (isset($filter['source']) && !empty($filter['source'])) {
48
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
48
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
49 49
 		}
50 50
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
51 51
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
78 78
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
79 79
 		if ($filter_query_where != '') {
80
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
80
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
81 81
 		}
82 82
 		$filter_query = $filter_query_join.$filter_query_where;
83 83
 		return $filter_query;
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 	* @return Array the tracker information
93 93
 	*
94 94
 	*/
95
-	public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false)
95
+	public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false)
96 96
 	{
97 97
 		date_default_timezone_set('UTC');
98 98
 		if (!is_string($query))
@@ -112,13 +112,13 @@  discard block
 block discarded – undo
112 112
 			$sth = $this->db->prepare($query.$limitQuery);
113 113
 			$sth->execute($params);
114 114
 		} catch (PDOException $e) {
115
-			printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery);
115
+			printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery);
116 116
 			exit();
117 117
 		}
118 118
 		
119 119
 		$num_rows = 0;
120 120
 		$tracker_array = array();
121
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
121
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
122 122
 		{
123 123
 			$num_rows++;
124 124
 			$temp_array = array();
@@ -174,17 +174,17 @@  discard block
 block discarded – undo
174 174
 				{
175 175
 					$temp_array['date'] = "about ".$dateArray['hours']." hours ago";
176 176
 				} else {
177
-					$temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC"));
177
+					$temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC"));
178 178
 				}
179 179
 				$temp_array['date_minutes_past'] = $dateArray['minutes'];
180
-				$temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC"));
181
-				$temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC"));
180
+				$temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC"));
181
+				$temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC"));
182 182
 				$temp_array['date_unix'] = strtotime($row['date']." UTC");
183 183
 				if (isset($row['last_seen']) && $row['last_seen'] != '') {
184 184
 					if (strtotime($row['last_seen']) > strtotime($row['date'])) {
185 185
 						$temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']);
186
-						$temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC"));
187
-						$temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC"));
186
+						$temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC"));
187
+						$temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC"));
188 188
 						$temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC");
189 189
 					}
190 190
 				}
@@ -221,8 +221,8 @@  discard block
 block discarded – undo
221 221
 		{
222 222
 			$limit_array = explode(",", $limit);
223 223
 			
224
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
225
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
224
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
225
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
226 226
 			
227 227
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
228 228
 			{
@@ -239,9 +239,9 @@  discard block
 block discarded – undo
239 239
 			$orderby_query = " ORDER BY tracker_output.date DESC";
240 240
 		}
241 241
 
242
-		$query  = $global_tracker_query.$filter_query." ".$orderby_query;
242
+		$query = $global_tracker_query.$filter_query." ".$orderby_query;
243 243
 
244
-		$tracker_array = $this->getDataFromDB($query, array(),$limit_query,true);
244
+		$tracker_array = $this->getDataFromDB($query, array(), $limit_query, true);
245 245
 
246 246
 		return $tracker_array;
247 247
 	}
@@ -260,8 +260,8 @@  discard block
 block discarded – undo
260 260
 		if ($id == '') return array();
261 261
 		$additional_query = "tracker_output.famtrackid = :id";
262 262
 		$query_values = array(':id' => $id);
263
-		$query  = $global_tracker_query." WHERE ".$additional_query." ";
264
-		$tracker_array = $this->getDataFromDB($query,$query_values);
263
+		$query = $global_tracker_query." WHERE ".$additional_query." ";
264
+		$tracker_array = $this->getDataFromDB($query, $query_values);
265 265
 		return $tracker_array;
266 266
 	}
267 267
 
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 		$query_values = array();
281 281
 		$limit_query = '';
282 282
 		$additional_query = '';
283
-		$filter_query = $this->getFilter($filter,true,true);
283
+		$filter_query = $this->getFilter($filter, true, true);
284 284
 		if ($ident != "")
285 285
 		{
286 286
 			if (!is_string($ident))
@@ -296,8 +296,8 @@  discard block
 block discarded – undo
296 296
 		{
297 297
 			$limit_array = explode(",", $limit);
298 298
 			
299
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
300
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
299
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
300
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
301 301
 			
302 302
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
303 303
 			{
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
 		return $tracker_array;
322 322
 	}
323 323
 	
324
-	public function getTrackerDataByDate($date = '', $limit = '', $sort = '',$filter = array())
324
+	public function getTrackerDataByDate($date = '', $limit = '', $sort = '', $filter = array())
325 325
 	{
326 326
 		global $global_tracker_query, $globalTimezone, $globalDBdriver;
327 327
 		
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
 		$limit_query = '';
330 330
 		$additional_query = '';
331 331
 
332
-		$filter_query = $this->getFilter($filter,true,true);
332
+		$filter_query = $this->getFilter($filter, true, true);
333 333
 		
334 334
 		if ($date != "")
335 335
 		{
@@ -355,8 +355,8 @@  discard block
 block discarded – undo
355 355
 		{
356 356
 			$limit_array = explode(",", $limit);
357 357
 			
358
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
359
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
358
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
359
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
360 360
 			
361 361
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
362 362
 			{
@@ -387,11 +387,11 @@  discard block
 block discarded – undo
387 387
 	* @return Array list of source name
388 388
 	*
389 389
 	*/
390
-	public function getAllSourceName($type = '',$filters = array())
390
+	public function getAllSourceName($type = '', $filters = array())
391 391
 	{
392
-		$filter_query = $this->getFilter($filters,true,true);
392
+		$filter_query = $this->getFilter($filters, true, true);
393 393
 		$query_values = array();
394
-		$query  = "SELECT DISTINCT tracker_output.source_name 
394
+		$query = "SELECT DISTINCT tracker_output.source_name 
395 395
 				FROM tracker_output".$filter_query." tracker_output.source_name <> ''";
396 396
 		if ($type != '') {
397 397
 			$query_values = array(':type' => $type);
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
 		$source_array = array();
407 407
 		$temp_array = array();
408 408
 		
409
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
409
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
410 410
 		{
411 411
 			$temp_array['source_name'] = $row['source_name'];
412 412
 			$source_array[] = $temp_array;
@@ -423,8 +423,8 @@  discard block
 block discarded – undo
423 423
 	*/
424 424
 	public function getAllIdents($filters = array())
425 425
 	{
426
-		$filter_query = $this->getFilter($filters,true,true);
427
-		$query  = "SELECT DISTINCT tracker_output.ident
426
+		$filter_query = $this->getFilter($filters, true, true);
427
+		$query = "SELECT DISTINCT tracker_output.ident
428 428
 								FROM tracker_output".$filter_query." tracker_output.ident <> '' 
429 429
 								ORDER BY tracker_output.date ASC LIMIT 700 OFFSET 0";
430 430
 
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
 		$ident_array = array();
435 435
 		$temp_array = array();
436 436
 		
437
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
437
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
438 438
 		{
439 439
 			$temp_array['ident'] = $row['ident'];
440 440
 			$ident_array[] = $temp_array;
@@ -459,12 +459,12 @@  discard block
 block discarded – undo
459 459
 		} else $offset = '+00:00';
460 460
 
461 461
 		if ($globalDBdriver == 'mysql') {
462
-			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) as date
462
+			$query = "SELECT DISTINCT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) as date
463 463
 								FROM tracker_output
464 464
 								WHERE tracker_output.date <> '' 
465 465
 								ORDER BY tracker_output.date ASC LIMIT 0,100";
466 466
 		} else {
467
-			$query  = "SELECT DISTINCT to_char(tracker_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
467
+			$query = "SELECT DISTINCT to_char(tracker_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
468 468
 								FROM tracker_output
469 469
 								WHERE tracker_output.date <> '' 
470 470
 								ORDER BY tracker_output.date ASC LIMIT 0,100";
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
 		$date_array = array();
477 477
 		$temp_array = array();
478 478
 		
479
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
479
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
480 480
 		{
481 481
 			$temp_array['date'] = $row['date'];
482 482
 
@@ -495,11 +495,11 @@  discard block
 block discarded – undo
495 495
 	* @return String success or false
496 496
 	*
497 497
 	*/	
498
-	public function updateIdentTrackerData($famtrackid = '', $ident = '',$fromsource = NULL)
498
+	public function updateIdentTrackerData($famtrackid = '', $ident = '', $fromsource = NULL)
499 499
 	{
500 500
 
501 501
 		$query = 'UPDATE tracker_output SET ident = :ident WHERE famtrackid = :famtrackid';
502
-                $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident);
502
+                $query_values = array(':famtrackid' => $famtrackid, ':ident' => $ident);
503 503
 
504 504
 		try {
505 505
 			$sth = $this->db->prepare($query);
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
 	public function updateLatestTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $groundspeed = NULL, $date = '')
524 524
 	{
525 525
 		$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';
526
-                $query_values = array(':famtrackid' => $famtrackid,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_altitude' => $altitude,':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident);
526
+                $query_values = array(':famtrackid' => $famtrackid, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_altitude' => $altitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident);
527 527
 
528 528
 		try {
529 529
 			$sth = $this->db->prepare($query);
@@ -563,7 +563,7 @@  discard block
 block discarded – undo
563 563
 	* @param String $verticalrate vertival rate of flight
564 564
 	* @return String success or false
565 565
 	*/
566
-	public function addTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $comment = '', $type = '',$format_source = '', $source_name = '')
566
+	public function addTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $comment = '', $type = '', $format_source = '', $source_name = '')
567 567
 	{
568 568
 		global $globalURL;
569 569
 		
@@ -631,21 +631,21 @@  discard block
 block discarded – undo
631 631
 		}
632 632
 
633 633
     
634
-		if ($date == "" || strtotime($date) < time()-20*60)
634
+		if ($date == "" || strtotime($date) < time() - 20*60)
635 635
 		{
636 636
 			$date = date("Y-m-d H:i:s", time());
637 637
 		}
638 638
 
639
-		$famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING);
640
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
641
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
642
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
643
-		$altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
644
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
645
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
646
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
647
-		$comment = filter_var($comment,FILTER_SANITIZE_STRING);
648
-		$type = filter_var($type,FILTER_SANITIZE_STRING);
639
+		$famtrackid = filter_var($famtrackid, FILTER_SANITIZE_STRING);
640
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
641
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
642
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
643
+		$altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
644
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
645
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
646
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
647
+		$comment = filter_var($comment, FILTER_SANITIZE_STRING);
648
+		$type = filter_var($type, FILTER_SANITIZE_STRING);
649 649
 	
650 650
                 if ($latitude == '' && $longitude == '') {
651 651
             		$latitude = 0;
@@ -653,10 +653,10 @@  discard block
 block discarded – undo
653 653
             	}
654 654
                 if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
655 655
                 if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
656
-                $query  = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) 
656
+                $query = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) 
657 657
                 VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:speed,:date,:format_source, :source_name,:comment,:type)";
658 658
 
659
-                $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);
659
+                $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);
660 660
 
661 661
 		try {
662 662
 		        
@@ -682,13 +682,13 @@  discard block
 block discarded – undo
682 682
 	{
683 683
 		global $globalDBdriver, $globalTimezone;
684 684
 		if ($globalDBdriver == 'mysql') {
685
-			$query  = "SELECT tracker_output.ident FROM tracker_output 
685
+			$query = "SELECT tracker_output.ident FROM tracker_output 
686 686
 								WHERE tracker_output.ident = :ident 
687 687
 								AND tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
688 688
 								AND tracker_output.date < UTC_TIMESTAMP()";
689 689
 			$query_data = array(':ident' => $ident);
690 690
 		} else {
691
-			$query  = "SELECT tracker_output.ident FROM tracker_output 
691
+			$query = "SELECT tracker_output.ident FROM tracker_output 
692 692
 								WHERE tracker_output.ident = :ident 
693 693
 								AND tracker_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
694 694
 								AND tracker_output.date < now() AT TIME ZONE 'UTC'";
@@ -697,8 +697,8 @@  discard block
 block discarded – undo
697 697
 		
698 698
 		$sth = $this->db->prepare($query);
699 699
 		$sth->execute($query_data);
700
-    		$ident_result='';
701
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
700
+    		$ident_result = '';
701
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
702 702
 		{
703 703
 			$ident_result = $row['ident'];
704 704
 		}
@@ -724,8 +724,8 @@  discard block
 block discarded – undo
724 724
 				return false;
725 725
 			} else {
726 726
 				$q_array = explode(" ", $q);
727
-				foreach ($q_array as $q_item){
728
-					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
727
+				foreach ($q_array as $q_item) {
728
+					$q_item = filter_var($q_item, FILTER_SANITIZE_STRING);
729 729
 					$additional_query .= " AND (";
730 730
 					$additional_query .= "(tracker_output.ident like '%".$q_item."%')";
731 731
 					$additional_query .= ")";
@@ -733,11 +733,11 @@  discard block
 block discarded – undo
733 733
 			}
734 734
 		}
735 735
 		if ($globalDBdriver == 'mysql') {
736
-			$query  = "SELECT tracker_output.* FROM tracker_output 
736
+			$query = "SELECT tracker_output.* FROM tracker_output 
737 737
 				WHERE tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." 
738 738
 				AND tracker_output.date < UTC_TIMESTAMP()";
739 739
 		} else {
740
-			$query  = "SELECT tracker_output.* FROM tracker_output 
740
+			$query = "SELECT tracker_output.* FROM tracker_output 
741 741
 				WHERE tracker_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." 
742 742
 				AND tracker_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
743 743
 		}
@@ -751,16 +751,16 @@  discard block
 block discarded – undo
751 751
 	* @return Array the airline country list
752 752
 	*
753 753
 	*/
754
-	public function countAllTrackerOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
754
+	public function countAllTrackerOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
755 755
 	{
756 756
 		global $globalDBdriver, $globalArchive;
757 757
 		//$filter_query = $this->getFilter($filters,true,true);
758
-		$Connection= new Connection($this->db);
758
+		$Connection = new Connection($this->db);
759 759
 		if (!$Connection->tableExists('countries')) return array();
760 760
 		if (!isset($globalArchive) || $globalArchive !== TRUE) {
761 761
 			require_once('class.TrackerLive.php');
762 762
 			$TrackerLive = new TrackerLive($this->db);
763
-			$filter_query = $TrackerLive->getFilter($filters,true,true);
763
+			$filter_query = $TrackerLive->getFilter($filters, true, true);
764 764
 			$filter_query .= " over_country IS NOT NULL AND over_country <> ''";
765 765
 			if ($olderthanmonths > 0) {
766 766
 				if ($globalDBdriver == 'mysql') {
@@ -780,7 +780,7 @@  discard block
 block discarded – undo
780 780
 		} else {
781 781
 			require_once('class.TrackerArchive.php');
782 782
 			$TrackerArchive = new TrackerArchive($this->db);
783
-			$filter_query = $TrackerArchive->getFilter($filters,true,true);
783
+			$filter_query = $TrackerArchive->getFilter($filters, true, true);
784 784
 			$filter_query .= " over_country IS NOT NULL AND over_country <> ''";
785 785
 			if ($olderthanmonths > 0) {
786 786
 				if ($globalDBdriver == 'mysql') {
@@ -808,7 +808,7 @@  discard block
 block discarded – undo
808 808
 		$flight_array = array();
809 809
 		$temp_array = array();
810 810
         
811
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
811
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
812 812
 		{
813 813
 			$temp_array['tracker_count'] = $row['nb'];
814 814
 			$temp_array['tracker_country'] = $row['name'];
@@ -825,11 +825,11 @@  discard block
 block discarded – undo
825 825
 	* @return Array the callsign list
826 826
 	*
827 827
 	*/
828
-	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
828
+	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
829 829
 	{
830 830
 		global $globalDBdriver;
831
-		$filter_query = $this->getFilter($filters,true,true);
832
-		$query  = "SELECT DISTINCT tracker_output.ident, COUNT(tracker_output.ident) AS callsign_icao_count 
831
+		$filter_query = $this->getFilter($filters, true, true);
832
+		$query = "SELECT DISTINCT tracker_output.ident, COUNT(tracker_output.ident) AS callsign_icao_count 
833 833
                     FROM tracker_output".$filter_query." tracker_output.ident <> ''";
834 834
 		 if ($olderthanmonths > 0) {
835 835
 			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
@@ -843,28 +843,28 @@  discard block
 block discarded – undo
843 843
 		if ($year != '') {
844 844
 			if ($globalDBdriver == 'mysql') {
845 845
 				$query .= " AND YEAR(tracker_output.date) = :year";
846
-				$query_values = array_merge($query_values,array(':year' => $year));
846
+				$query_values = array_merge($query_values, array(':year' => $year));
847 847
 			} else {
848 848
 				$query .= " AND EXTRACT(YEAR FROM tracker_output.date) = :year";
849
-				$query_values = array_merge($query_values,array(':year' => $year));
849
+				$query_values = array_merge($query_values, array(':year' => $year));
850 850
 			}
851 851
 		}
852 852
 		if ($month != '') {
853 853
 			if ($globalDBdriver == 'mysql') {
854 854
 				$query .= " AND MONTH(tracker_output.date) = :month";
855
-				$query_values = array_merge($query_values,array(':month' => $month));
855
+				$query_values = array_merge($query_values, array(':month' => $month));
856 856
 			} else {
857 857
 				$query .= " AND EXTRACT(MONTH FROM tracker_output.date) = :month";
858
-				$query_values = array_merge($query_values,array(':month' => $month));
858
+				$query_values = array_merge($query_values, array(':month' => $month));
859 859
 			}
860 860
 		}
861 861
 		if ($day != '') {
862 862
 			if ($globalDBdriver == 'mysql') {
863 863
 				$query .= " AND DAY(tracker_output.date) = :day";
864
-				$query_values = array_merge($query_values,array(':day' => $day));
864
+				$query_values = array_merge($query_values, array(':day' => $day));
865 865
 			} else {
866 866
 				$query .= " AND EXTRACT(DAY FROM tracker_output.date) = :day";
867
-				$query_values = array_merge($query_values,array(':day' => $day));
867
+				$query_values = array_merge($query_values, array(':day' => $day));
868 868
 			}
869 869
 		}
870 870
 		$query .= " GROUP BY tracker_output.ident ORDER BY callsign_icao_count DESC";
@@ -876,7 +876,7 @@  discard block
 block discarded – undo
876 876
 		$callsign_array = array();
877 877
 		$temp_array = array();
878 878
         
879
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
879
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
880 880
 		{
881 881
 			$temp_array['callsign_icao'] = $row['ident'];
882 882
 			$temp_array['airline_name'] = $row['airline_name'];
@@ -928,7 +928,7 @@  discard block
 block discarded – undo
928 928
 		$date_array = array();
929 929
 		$temp_array = array();
930 930
         
931
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
931
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
932 932
 		{
933 933
 			$temp_array['date_name'] = $row['date_name'];
934 934
 			$temp_array['date_count'] = $row['date_count'];
@@ -954,7 +954,7 @@  discard block
 block discarded – undo
954 954
 			$datetime = new DateTime();
955 955
 			$offset = $datetime->format('P');
956 956
 		} else $offset = '+00:00';
957
-		$filter_query = $this->getFilter($filters,true,true);
957
+		$filter_query = $this->getFilter($filters, true, true);
958 958
 		if ($globalDBdriver == 'mysql') {
959 959
 			$query  = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
960 960
 								FROM tracker_output".$filter_query." tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)";
@@ -975,7 +975,7 @@  discard block
 block discarded – undo
975 975
 		$date_array = array();
976 976
 		$temp_array = array();
977 977
         
978
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
978
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
979 979
 		{
980 980
 			$temp_array['date_name'] = $row['date_name'];
981 981
 			$temp_array['date_count'] = $row['date_count'];
@@ -1000,7 +1000,7 @@  discard block
 block discarded – undo
1000 1000
 			$datetime = new DateTime();
1001 1001
 			$offset = $datetime->format('P');
1002 1002
 		} else $offset = '+00:00';
1003
-		$filter_query = $this->getFilter($filters,true,true);
1003
+		$filter_query = $this->getFilter($filters, true, true);
1004 1004
 		if ($globalDBdriver == 'mysql') {
1005 1005
 			$query  = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
1006 1006
 								FROM tracker_output".$filter_query." tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)";
@@ -1021,7 +1021,7 @@  discard block
 block discarded – undo
1021 1021
 		$date_array = array();
1022 1022
 		$temp_array = array();
1023 1023
         
1024
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1024
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1025 1025
 		{
1026 1026
 			$temp_array['date_name'] = $row['date_name'];
1027 1027
 			$temp_array['date_count'] = $row['date_count'];
@@ -1068,7 +1068,7 @@  discard block
 block discarded – undo
1068 1068
 		$date_array = array();
1069 1069
 		$temp_array = array();
1070 1070
         
1071
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1071
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1072 1072
 		{
1073 1073
 			$temp_array['month_name'] = $row['month_name'];
1074 1074
 			$temp_array['year_name'] = $row['year_name'];
@@ -1097,7 +1097,7 @@  discard block
 block discarded – undo
1097 1097
 			$datetime = new DateTime();
1098 1098
 			$offset = $datetime->format('P');
1099 1099
 		} else $offset = '+00:00';
1100
-		$filter_query = $this->getFilter($filters,true,true);
1100
+		$filter_query = $this->getFilter($filters, true, true);
1101 1101
 		if ($globalDBdriver == 'mysql') {
1102 1102
 			$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
1103 1103
 								FROM tracker_output".$filter_query." tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)";
@@ -1118,7 +1118,7 @@  discard block
 block discarded – undo
1118 1118
 		$date_array = array();
1119 1119
 		$temp_array = array();
1120 1120
         
1121
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1121
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1122 1122
 		{
1123 1123
 			$temp_array['year_name'] = $row['year_name'];
1124 1124
 			$temp_array['month_name'] = $row['month_name'];
@@ -1138,7 +1138,7 @@  discard block
 block discarded – undo
1138 1138
 	* @return Array the hour list
1139 1139
 	*
1140 1140
 	*/
1141
-	public function countAllHours($orderby,$filters = array())
1141
+	public function countAllHours($orderby, $filters = array())
1142 1142
 	{
1143 1143
 		global $globalTimezone, $globalDBdriver;
1144 1144
 		if ($globalTimezone != '') {
@@ -1186,7 +1186,7 @@  discard block
 block discarded – undo
1186 1186
 		$hour_array = array();
1187 1187
 		$temp_array = array();
1188 1188
         
1189
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1189
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1190 1190
 		{
1191 1191
 			$temp_array['hour_name'] = $row['hour_name'];
1192 1192
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1208,8 +1208,8 @@  discard block
 block discarded – undo
1208 1208
 	public function countAllHoursByDate($date, $filters = array())
1209 1209
 	{
1210 1210
 		global $globalTimezone, $globalDBdriver;
1211
-		$filter_query = $this->getFilter($filters,true,true);
1212
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
1211
+		$filter_query = $this->getFilter($filters, true, true);
1212
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
1213 1213
 		if ($globalTimezone != '') {
1214 1214
 			date_default_timezone_set($globalTimezone);
1215 1215
 			$datetime = new DateTime($date);
@@ -1217,12 +1217,12 @@  discard block
 block discarded – undo
1217 1217
 		} else $offset = '+00:00';
1218 1218
 
1219 1219
 		if ($globalDBdriver == 'mysql') {
1220
-			$query  = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1220
+			$query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1221 1221
 								FROM tracker_output".$filter_query." DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) = :date
1222 1222
 								GROUP BY hour_name 
1223 1223
 								ORDER BY hour_name ASC";
1224 1224
 		} else {
1225
-			$query  = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1225
+			$query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1226 1226
 								FROM tracker_output".$filter_query." to_char(tracker_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date
1227 1227
 								GROUP BY hour_name 
1228 1228
 								ORDER BY hour_name ASC";
@@ -1234,7 +1234,7 @@  discard block
 block discarded – undo
1234 1234
 		$hour_array = array();
1235 1235
 		$temp_array = array();
1236 1236
         
1237
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1237
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1238 1238
 		{
1239 1239
 			$temp_array['hour_name'] = $row['hour_name'];
1240 1240
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1256,8 +1256,8 @@  discard block
 block discarded – undo
1256 1256
 	public function countAllHoursByIdent($ident, $filters = array())
1257 1257
 	{
1258 1258
 		global $globalTimezone, $globalDBdriver;
1259
-		$filter_query = $this->getFilter($filters,true,true);
1260
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
1259
+		$filter_query = $this->getFilter($filters, true, true);
1260
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1261 1261
 		if ($globalTimezone != '') {
1262 1262
 			date_default_timezone_set($globalTimezone);
1263 1263
 			$datetime = new DateTime();
@@ -1265,12 +1265,12 @@  discard block
 block discarded – undo
1265 1265
 		} else $offset = '+00:00';
1266 1266
 
1267 1267
 		if ($globalDBdriver == 'mysql') {
1268
-			$query  = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1268
+			$query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1269 1269
 								FROM tracker_output".$filter_query." tracker_output.ident = :ident 
1270 1270
 								GROUP BY hour_name 
1271 1271
 								ORDER BY hour_name ASC";
1272 1272
 		} else {
1273
-			$query  = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1273
+			$query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1274 1274
 								FROM tracker_output".$filter_query." tracker_output.ident = :ident 
1275 1275
 								GROUP BY hour_name 
1276 1276
 								ORDER BY hour_name ASC";
@@ -1278,12 +1278,12 @@  discard block
 block discarded – undo
1278 1278
       
1279 1279
 		
1280 1280
 		$sth = $this->db->prepare($query);
1281
-		$sth->execute(array(':ident' => $ident,':offset' => $offset));
1281
+		$sth->execute(array(':ident' => $ident, ':offset' => $offset));
1282 1282
       
1283 1283
 		$hour_array = array();
1284 1284
 		$temp_array = array();
1285 1285
         
1286
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1286
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1287 1287
 		{
1288 1288
 			$temp_array['hour_name'] = $row['hour_name'];
1289 1289
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1302,33 +1302,33 @@  discard block
 block discarded – undo
1302 1302
 	* @return Integer the number of trackers
1303 1303
 	*
1304 1304
 	*/
1305
-	public function countOverallTracker($filters = array(),$year = '',$month = '')
1305
+	public function countOverallTracker($filters = array(), $year = '', $month = '')
1306 1306
 	{
1307 1307
 		global $globalDBdriver;
1308 1308
 		//$queryi  = "SELECT COUNT(tracker_output.tracker_id) AS flight_count FROM tracker_output";
1309
-		$queryi  = "SELECT COUNT(DISTINCT tracker_output.ident) AS tracker_count FROM tracker_output";
1309
+		$queryi = "SELECT COUNT(DISTINCT tracker_output.ident) AS tracker_count FROM tracker_output";
1310 1310
 		$query_values = array();
1311 1311
 		$query = '';
1312 1312
 		if ($year != '') {
1313 1313
 			if ($globalDBdriver == 'mysql') {
1314 1314
 				$query .= " AND YEAR(tracker_output.date) = :year";
1315
-				$query_values = array_merge($query_values,array(':year' => $year));
1315
+				$query_values = array_merge($query_values, array(':year' => $year));
1316 1316
 			} else {
1317 1317
 				$query .= " AND EXTRACT(YEAR FROM tracker_output.date) = :year";
1318
-				$query_values = array_merge($query_values,array(':year' => $year));
1318
+				$query_values = array_merge($query_values, array(':year' => $year));
1319 1319
 			}
1320 1320
 		}
1321 1321
 		if ($month != '') {
1322 1322
 			if ($globalDBdriver == 'mysql') {
1323 1323
 				$query .= " AND MONTH(tracker_output.date) = :month";
1324
-				$query_values = array_merge($query_values,array(':month' => $month));
1324
+				$query_values = array_merge($query_values, array(':month' => $month));
1325 1325
 			} else {
1326 1326
 				$query .= " AND EXTRACT(MONTH FROM tracker_output.date) = :month";
1327
-				$query_values = array_merge($query_values,array(':month' => $month));
1327
+				$query_values = array_merge($query_values, array(':month' => $month));
1328 1328
 			}
1329 1329
 		}
1330 1330
 		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1331
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1331
+		else $queryi .= $this->getFilter($filters, true, true).substr($query, 4);
1332 1332
 		
1333 1333
 		$sth = $this->db->prepare($queryi);
1334 1334
 		$sth->execute($query_values);
@@ -1341,32 +1341,32 @@  discard block
 block discarded – undo
1341 1341
 	* @return Integer the number of flights
1342 1342
 	*
1343 1343
 	*/
1344
-	public function countOverallTrackerTypes($filters = array(),$year = '',$month = '')
1344
+	public function countOverallTrackerTypes($filters = array(), $year = '', $month = '')
1345 1345
 	{
1346 1346
 		global $globalDBdriver;
1347
-		$queryi  = "SELECT COUNT(DISTINCT tracker_output.type) AS tracker_count FROM tracker_output";
1347
+		$queryi = "SELECT COUNT(DISTINCT tracker_output.type) AS tracker_count FROM tracker_output";
1348 1348
 		$query_values = array();
1349 1349
 		$query = '';
1350 1350
 		if ($year != '') {
1351 1351
 			if ($globalDBdriver == 'mysql') {
1352 1352
 				$query .= " AND YEAR(tracker_output.date) = :year";
1353
-				$query_values = array_merge($query_values,array(':year' => $year));
1353
+				$query_values = array_merge($query_values, array(':year' => $year));
1354 1354
 			} else {
1355 1355
 				$query .= " AND EXTRACT(YEAR FROM tracker_output.date) = :year";
1356
-				$query_values = array_merge($query_values,array(':year' => $year));
1356
+				$query_values = array_merge($query_values, array(':year' => $year));
1357 1357
 			}
1358 1358
 		}
1359 1359
 		if ($month != '') {
1360 1360
 			if ($globalDBdriver == 'mysql') {
1361 1361
 				$query .= " AND MONTH(tracker_output.date) = :month";
1362
-				$query_values = array_merge($query_values,array(':month' => $month));
1362
+				$query_values = array_merge($query_values, array(':month' => $month));
1363 1363
 			} else {
1364 1364
 				$query .= " AND EXTRACT(MONTH FROM tracker_output.date) = :month";
1365
-				$query_values = array_merge($query_values,array(':month' => $month));
1365
+				$query_values = array_merge($query_values, array(':month' => $month));
1366 1366
 			}
1367 1367
 		}
1368 1368
 		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1369
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1369
+		else $queryi .= $this->getFilter($filters, true, true).substr($query, 4);
1370 1370
 		
1371 1371
 		$sth = $this->db->prepare($queryi);
1372 1372
 		$sth->execute($query_values);
@@ -1383,7 +1383,7 @@  discard block
 block discarded – undo
1383 1383
 	public function countAllHoursFromToday($filters = array())
1384 1384
 	{
1385 1385
 		global $globalTimezone, $globalDBdriver;
1386
-		$filter_query = $this->getFilter($filters,true,true);
1386
+		$filter_query = $this->getFilter($filters, true, true);
1387 1387
 		if ($globalTimezone != '') {
1388 1388
 			date_default_timezone_set($globalTimezone);
1389 1389
 			$datetime = new DateTime();
@@ -1391,12 +1391,12 @@  discard block
 block discarded – undo
1391 1391
 		} else $offset = '+00:00';
1392 1392
 
1393 1393
 		if ($globalDBdriver == 'mysql') {
1394
-			$query  = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1394
+			$query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1395 1395
 								FROM tracker_output".$filter_query." DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) = CURDATE()
1396 1396
 								GROUP BY hour_name 
1397 1397
 								ORDER BY hour_name ASC";
1398 1398
 		} else {
1399
-			$query  = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1399
+			$query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1400 1400
 								FROM tracker_output".$filter_query." to_char(tracker_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date)
1401 1401
 								GROUP BY hour_name 
1402 1402
 								ORDER BY hour_name ASC";
@@ -1408,7 +1408,7 @@  discard block
 block discarded – undo
1408 1408
 		$hour_array = array();
1409 1409
 		$temp_array = array();
1410 1410
         
1411
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1411
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1412 1412
 		{
1413 1413
 			$temp_array['hour_name'] = $row['hour_name'];
1414 1414
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1427,9 +1427,9 @@  discard block
 block discarded – undo
1427 1427
 	*/
1428 1428
 	public function getTrackerIDBasedOnFamTrackID($famtrackid)
1429 1429
 	{
1430
-		$famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING);
1430
+		$famtrackid = filter_var($famtrackid, FILTER_SANITIZE_STRING);
1431 1431
 
1432
-		$query  = "SELECT tracker_output.tracker_id
1432
+		$query = "SELECT tracker_output.tracker_id
1433 1433
 				FROM tracker_output 
1434 1434
 				WHERE tracker_output.famtrackid = '".$famtrackid."'";
1435 1435
         
@@ -1437,7 +1437,7 @@  discard block
 block discarded – undo
1437 1437
 		$sth = $this->db->prepare($query);
1438 1438
 		$sth->execute();
1439 1439
 
1440
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1440
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1441 1441
 		{
1442 1442
 			return $row['tracker_id'];
1443 1443
 		}
@@ -1462,23 +1462,23 @@  discard block
 block discarded – undo
1462 1462
 		}
1463 1463
 		
1464 1464
 		$current_date = date("Y-m-d H:i:s");
1465
-		$date = date("Y-m-d H:i:s",strtotime($dateString." UTC"));
1465
+		$date = date("Y-m-d H:i:s", strtotime($dateString." UTC"));
1466 1466
 		
1467 1467
 		$diff = abs(strtotime($current_date) - strtotime($date));
1468 1468
 
1469
-		$time_array['years'] = floor($diff / (365*60*60*24)); 
1469
+		$time_array['years'] = floor($diff/(365*60*60*24)); 
1470 1470
 		$years = $time_array['years'];
1471 1471
 		
1472
-		$time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
1472
+		$time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24));
1473 1473
 		$months = $time_array['months'];
1474 1474
 		
1475
-		$time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
1475
+		$time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24));
1476 1476
 		$days = $time_array['days'];
1477
-		$time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60));
1477
+		$time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60));
1478 1478
 		$hours = $time_array['hours'];
1479
-		$time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60);
1479
+		$time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60);
1480 1480
 		$minutes = $time_array['minutes'];
1481
-		$time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
1481
+		$time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
1482 1482
 		
1483 1483
 		return $time_array;
1484 1484
 	}
@@ -1501,63 +1501,63 @@  discard block
 block discarded – undo
1501 1501
 			$temp_array['direction_degree'] = $direction;
1502 1502
 			$temp_array['direction_shortname'] = "N";
1503 1503
 			$temp_array['direction_fullname'] = "North";
1504
-		} elseif ($direction >= 22.5 && $direction < 45){
1504
+		} elseif ($direction >= 22.5 && $direction < 45) {
1505 1505
 			$temp_array['direction_degree'] = $direction;
1506 1506
 			$temp_array['direction_shortname'] = "NNE";
1507 1507
 			$temp_array['direction_fullname'] = "North-Northeast";
1508
-		} elseif ($direction >= 45 && $direction < 67.5){
1508
+		} elseif ($direction >= 45 && $direction < 67.5) {
1509 1509
 			$temp_array['direction_degree'] = $direction;
1510 1510
 			$temp_array['direction_shortname'] = "NE";
1511 1511
 			$temp_array['direction_fullname'] = "Northeast";
1512
-		} elseif ($direction >= 67.5 && $direction < 90){
1512
+		} elseif ($direction >= 67.5 && $direction < 90) {
1513 1513
 			$temp_array['direction_degree'] = $direction;
1514 1514
 			$temp_array['direction_shortname'] = "ENE";
1515 1515
 			$temp_array['direction_fullname'] = "East-Northeast";
1516
-		} elseif ($direction >= 90 && $direction < 112.5){
1516
+		} elseif ($direction >= 90 && $direction < 112.5) {
1517 1517
 			$temp_array['direction_degree'] = $direction;
1518 1518
 			$temp_array['direction_shortname'] = "E";
1519 1519
 			$temp_array['direction_fullname'] = "East";
1520
-		} elseif ($direction >= 112.5 && $direction < 135){
1520
+		} elseif ($direction >= 112.5 && $direction < 135) {
1521 1521
 			$temp_array['direction_degree'] = $direction;
1522 1522
 			$temp_array['direction_shortname'] = "ESE";
1523 1523
 			$temp_array['direction_fullname'] = "East-Southeast";
1524
-		} elseif ($direction >= 135 && $direction < 157.5){
1524
+		} elseif ($direction >= 135 && $direction < 157.5) {
1525 1525
 			$temp_array['direction_degree'] = $direction;
1526 1526
 			$temp_array['direction_shortname'] = "SE";
1527 1527
 			$temp_array['direction_fullname'] = "Southeast";
1528
-		} elseif ($direction >= 157.5 && $direction < 180){
1528
+		} elseif ($direction >= 157.5 && $direction < 180) {
1529 1529
 			$temp_array['direction_degree'] = $direction;
1530 1530
 			$temp_array['direction_shortname'] = "SSE";
1531 1531
 			$temp_array['direction_fullname'] = "South-Southeast";
1532
-		} elseif ($direction >= 180 && $direction < 202.5){
1532
+		} elseif ($direction >= 180 && $direction < 202.5) {
1533 1533
 			$temp_array['direction_degree'] = $direction;
1534 1534
 			$temp_array['direction_shortname'] = "S";
1535 1535
 			$temp_array['direction_fullname'] = "South";
1536
-		} elseif ($direction >= 202.5 && $direction < 225){
1536
+		} elseif ($direction >= 202.5 && $direction < 225) {
1537 1537
 			$temp_array['direction_degree'] = $direction;
1538 1538
 			$temp_array['direction_shortname'] = "SSW";
1539 1539
 			$temp_array['direction_fullname'] = "South-Southwest";
1540
-		} elseif ($direction >= 225 && $direction < 247.5){
1540
+		} elseif ($direction >= 225 && $direction < 247.5) {
1541 1541
 			$temp_array['direction_degree'] = $direction;
1542 1542
 			$temp_array['direction_shortname'] = "SW";
1543 1543
 			$temp_array['direction_fullname'] = "Southwest";
1544
-		} elseif ($direction >= 247.5 && $direction < 270){
1544
+		} elseif ($direction >= 247.5 && $direction < 270) {
1545 1545
 			$temp_array['direction_degree'] = $direction;
1546 1546
 			$temp_array['direction_shortname'] = "WSW";
1547 1547
 			$temp_array['direction_fullname'] = "West-Southwest";
1548
-		} elseif ($direction >= 270 && $direction < 292.5){
1548
+		} elseif ($direction >= 270 && $direction < 292.5) {
1549 1549
 			$temp_array['direction_degree'] = $direction;
1550 1550
 			$temp_array['direction_shortname'] = "W";
1551 1551
 			$temp_array['direction_fullname'] = "West";
1552
-		} elseif ($direction >= 292.5 && $direction < 315){
1552
+		} elseif ($direction >= 292.5 && $direction < 315) {
1553 1553
 			$temp_array['direction_degree'] = $direction;
1554 1554
 			$temp_array['direction_shortname'] = "WNW";
1555 1555
 			$temp_array['direction_fullname'] = "West-Northwest";
1556
-		} elseif ($direction >= 315 && $direction < 337.5){
1556
+		} elseif ($direction >= 315 && $direction < 337.5) {
1557 1557
 			$temp_array['direction_degree'] = $direction;
1558 1558
 			$temp_array['direction_shortname'] = "NW";
1559 1559
 			$temp_array['direction_fullname'] = "Northwest";
1560
-		} elseif ($direction >= 337.5 && $direction < 360){
1560
+		} elseif ($direction >= 337.5 && $direction < 360) {
1561 1561
 			$temp_array['direction_degree'] = $direction;
1562 1562
 			$temp_array['direction_shortname'] = "NNW";
1563 1563
 			$temp_array['direction_fullname'] = "North-Northwest";
@@ -1574,11 +1574,11 @@  discard block
 block discarded – undo
1574 1574
 	* @param Float $longitude longitute of the flight
1575 1575
 	* @return String the countrie
1576 1576
 	*/
1577
-	public function getCountryFromLatitudeLongitude($latitude,$longitude)
1577
+	public function getCountryFromLatitudeLongitude($latitude, $longitude)
1578 1578
 	{
1579 1579
 		global $globalDBdriver, $globalDebug;
1580
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1581
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1580
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1581
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1582 1582
 	
1583 1583
 		$Connection = new Connection($this->db);
1584 1584
 		if (!$Connection->tableExists('countries')) return '';
@@ -1618,7 +1618,7 @@  discard block
 block discarded – undo
1618 1618
 	public function getCountryFromISO2($iso2)
1619 1619
 	{
1620 1620
 		global $globalDBdriver, $globalDebug;
1621
-		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
1621
+		$iso2 = filter_var($iso2, FILTER_SANITIZE_STRING);
1622 1622
 	
1623 1623
 		$Connection = new Connection($this->db);
1624 1624
 		if (!$Connection->tableExists('countries')) return '';
@@ -1647,11 +1647,11 @@  discard block
 block discarded – undo
1647 1647
 	* @return Array the vessel type list
1648 1648
 	*
1649 1649
 	*/
1650
-	public function countAllTrackerTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
1650
+	public function countAllTrackerTypes($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
1651 1651
 	{
1652 1652
 		global $globalDBdriver;
1653
-		$filter_query = $this->getFilter($filters,true,true);
1654
-		$query  = "SELECT tracker_output.type AS tracker_type, COUNT(tracker_output.type) AS tracker_type_count 
1653
+		$filter_query = $this->getFilter($filters, true, true);
1654
+		$query = "SELECT tracker_output.type AS tracker_type, COUNT(tracker_output.type) AS tracker_type_count 
1655 1655
 		    FROM tracker_output ".$filter_query." tracker_output.type  <> ''";
1656 1656
 		if ($olderthanmonths > 0) {
1657 1657
 			if ($globalDBdriver == 'mysql') {
@@ -1671,28 +1671,28 @@  discard block
 block discarded – undo
1671 1671
 		if ($year != '') {
1672 1672
 			if ($globalDBdriver == 'mysql') {
1673 1673
 				$query .= " AND YEAR(tracker_output.date) = :year";
1674
-				$query_values = array_merge($query_values,array(':year' => $year));
1674
+				$query_values = array_merge($query_values, array(':year' => $year));
1675 1675
 			} else {
1676 1676
 				$query .= " AND EXTRACT(YEAR FROM tracker_output.date) = :year";
1677
-				$query_values = array_merge($query_values,array(':year' => $year));
1677
+				$query_values = array_merge($query_values, array(':year' => $year));
1678 1678
 			}
1679 1679
 		}
1680 1680
 		if ($month != '') {
1681 1681
 			if ($globalDBdriver == 'mysql') {
1682 1682
 				$query .= " AND MONTH(tracker_output.date) = :month";
1683
-				$query_values = array_merge($query_values,array(':month' => $month));
1683
+				$query_values = array_merge($query_values, array(':month' => $month));
1684 1684
 			} else {
1685 1685
 				$query .= " AND EXTRACT(MONTH FROM tracker_output.date) = :month";
1686
-				$query_values = array_merge($query_values,array(':month' => $month));
1686
+				$query_values = array_merge($query_values, array(':month' => $month));
1687 1687
 			}
1688 1688
 		}
1689 1689
 		if ($day != '') {
1690 1690
 			if ($globalDBdriver == 'mysql') {
1691 1691
 				$query .= " AND DAY(tracker_output.date) = :day";
1692
-				$query_values = array_merge($query_values,array(':day' => $day));
1692
+				$query_values = array_merge($query_values, array(':day' => $day));
1693 1693
 			} else {
1694 1694
 				$query .= " AND EXTRACT(DAY FROM tracker_output.date) = :day";
1695
-				$query_values = array_merge($query_values,array(':day' => $day));
1695
+				$query_values = array_merge($query_values, array(':day' => $day));
1696 1696
 			}
1697 1697
 		}
1698 1698
 		$query .= " GROUP BY tracker_output.type ORDER BY tracker_type_count DESC";
@@ -1701,7 +1701,7 @@  discard block
 block discarded – undo
1701 1701
 		$sth->execute($query_values);
1702 1702
 		$tracker_array = array();
1703 1703
 		$temp_array = array();
1704
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1704
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1705 1705
 		{
1706 1706
 			$temp_array['tracker_type'] = $row['tracker_type'];
1707 1707
 			$temp_array['tracker_type_count'] = $row['tracker_type_count'];
@@ -1716,13 +1716,13 @@  discard block
 block discarded – undo
1716 1716
 	* @return Array the tracker information
1717 1717
 	*
1718 1718
 	*/
1719
-	public function searchTrackerData($q = '', $callsign = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '',$filters = array())
1719
+	public function searchTrackerData($q = '', $callsign = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array())
1720 1720
 	{
1721 1721
 		global $globalTimezone, $globalDBdriver;
1722 1722
 		date_default_timezone_set('UTC');
1723 1723
 		$query_values = array();
1724 1724
 		$additional_query = '';
1725
-		$filter_query = $this->getFilter($filters,true,true);
1725
+		$filter_query = $this->getFilter($filters, true, true);
1726 1726
 		if ($q != "")
1727 1727
 		{
1728 1728
 			if (!is_string($q))
@@ -1730,8 +1730,8 @@  discard block
 block discarded – undo
1730 1730
 				return false;
1731 1731
 			} else {
1732 1732
 				$q_array = explode(" ", $q);
1733
-				foreach ($q_array as $q_item){
1734
-					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
1733
+				foreach ($q_array as $q_item) {
1734
+					$q_item = filter_var($q_item, FILTER_SANITIZE_STRING);
1735 1735
 					$additional_query .= " AND (";
1736 1736
 					if (is_int($q_item)) $additional_query .= "(tracker_output.tracker_id = '".$q_item."') OR ";
1737 1737
 					$additional_query .= "(tracker_output.ident like '%".$q_item."%') OR ";
@@ -1741,20 +1741,20 @@  discard block
 block discarded – undo
1741 1741
 		}
1742 1742
 		if ($callsign != "")
1743 1743
 		{
1744
-			$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
1744
+			$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
1745 1745
 			if (!is_string($callsign))
1746 1746
 			{
1747 1747
 				return false;
1748 1748
 			} else {
1749 1749
 				$additional_query .= " AND tracker_output.ident = :callsign";
1750
-				$query_values = array_merge($query_values,array(':callsign' => $callsign));
1750
+				$query_values = array_merge($query_values, array(':callsign' => $callsign));
1751 1751
 			}
1752 1752
 		}
1753 1753
 		if ($date_posted != "")
1754 1754
 		{
1755 1755
 			$date_array = explode(",", $date_posted);
1756
-			$date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
1757
-			$date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
1756
+			$date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING);
1757
+			$date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING);
1758 1758
 			if ($globalTimezone != '') {
1759 1759
 				date_default_timezone_set($globalTimezone);
1760 1760
 				$datetime = new DateTime();
@@ -1781,8 +1781,8 @@  discard block
 block discarded – undo
1781 1781
 		if ($limit != "")
1782 1782
 		{
1783 1783
 			$limit_array = explode(",", $limit);
1784
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1785
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1784
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1785
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1786 1786
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1787 1787
 			{
1788 1788
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
@@ -1800,22 +1800,22 @@  discard block
 block discarded – undo
1800 1800
 			}
1801 1801
 		}
1802 1802
 		if ($origLat != "" && $origLon != "" && $dist != "") {
1803
-			$dist = number_format($dist*0.621371,2,'.',''); // convert km to mile
1803
+			$dist = number_format($dist*0.621371, 2, '.', ''); // convert km to mile
1804 1804
 			if ($globalDBdriver == 'mysql') {
1805
-				$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 
1805
+				$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 
1806 1806
 				    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)) 
1807 1807
 				    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;
1808 1808
 			} else {
1809
-				$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 
1809
+				$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 
1810 1810
 				    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)) 
1811 1811
 				    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;
1812 1812
 			}
1813 1813
 		} else {
1814
-			$query  = "SELECT tracker_output.* FROM tracker_output".$filter_query." tracker_output.ident <> '' 
1814
+			$query = "SELECT tracker_output.* FROM tracker_output".$filter_query." tracker_output.ident <> '' 
1815 1815
 			    ".$additional_query."
1816 1816
 			    ".$orderby_query;
1817 1817
 		}
1818
-		$tracker_array = $this->getDataFromDB($query, $query_values,$limit_query);
1818
+		$tracker_array = $this->getDataFromDB($query, $query_values, $limit_query);
1819 1819
 		return $tracker_array;
1820 1820
 	}
1821 1821
 
@@ -1840,7 +1840,7 @@  discard block
 block discarded – undo
1840 1840
 		curl_close($ch);
1841 1841
 		$bitly_data = json_decode($bitly_data);
1842 1842
 		$bitly_url = '';
1843
-		if ($bitly_data->status_txt = "OK"){
1843
+		if ($bitly_data->status_txt = "OK") {
1844 1844
 			$bitly_url = $bitly_data->data->url;
1845 1845
 		}
1846 1846
 		return $bitly_url;
@@ -1848,7 +1848,7 @@  discard block
 block discarded – undo
1848 1848
 
1849 1849
 	public function getOrderBy()
1850 1850
 	{
1851
-		$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"));
1851
+		$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"));
1852 1852
 		
1853 1853
 		return $orderby;
1854 1854
 		
Please login to merge, or discard this patch.
require/class.Marine.php 1 patch
Spacing   +215 added lines, -215 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 require_once(dirname(__FILE__).'/class.Image.php');
3 3
 $global_marine_query = "SELECT marine_output.* FROM marine_output";
4 4
 
5
-class Marine{
5
+class Marine {
6 6
 	public $db;
7 7
 	
8 8
 	public function __construct($dbc = null) {
@@ -17,33 +17,33 @@  discard block
 block discarded – undo
17 17
 	* @return Array the SQL part
18 18
 	*/
19 19
 	
20
-	public function getFilter($filter = array(),$where = false,$and = false) {
20
+	public function getFilter($filter = array(), $where = false, $and = false) {
21 21
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
22 22
 		$filters = array();
23 23
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
24 24
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
25 25
 				$filters = $globalStatsFilters[$globalFilterName];
26 26
 			} else {
27
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
27
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
28 28
 			}
29 29
 		}
30 30
 		if (isset($filter[0]['source'])) {
31
-			$filters = array_merge($filters,$filter);
31
+			$filters = array_merge($filters, $filter);
32 32
 		}
33
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
33
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
34 34
 		$filter_query_join = '';
35 35
 		$filter_query_where = '';
36
-		foreach($filters as $flt) {
36
+		foreach ($filters as $flt) {
37 37
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
38 38
 				if (isset($flt['source'])) {
39
-					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id";
39
+					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id";
40 40
 				} else {
41
-					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id";
41
+					$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";
42 42
 				}
43 43
 			}
44 44
 		}
45 45
 		if (isset($filter['source']) && !empty($filter['source'])) {
46
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
46
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
47 47
 		}
48 48
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
49 49
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
82 82
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
83 83
 		if ($filter_query_where != '') {
84
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
84
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
85 85
 		}
86 86
 		$filter_query = $filter_query_join.$filter_query_where;
87 87
 		return $filter_query;
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 	* @return Array the spotter information
97 97
 	*
98 98
 	*/
99
-	public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false)
99
+	public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false)
100 100
 	{
101 101
 		date_default_timezone_set('UTC');
102 102
 		if (!is_string($query))
@@ -116,13 +116,13 @@  discard block
 block discarded – undo
116 116
 			$sth = $this->db->prepare($query.$limitQuery);
117 117
 			$sth->execute($params);
118 118
 		} catch (PDOException $e) {
119
-			printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery);
119
+			printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery);
120 120
 			exit();
121 121
 		}
122 122
 		
123 123
 		$num_rows = 0;
124 124
 		$spotter_array = array();
125
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
125
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
126 126
 		{
127 127
 			$num_rows++;
128 128
 			$temp_array = array();
@@ -161,10 +161,10 @@  discard block
 block discarded – undo
161 161
 			}
162 162
 			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];
163 163
 
164
-			if(isset($temp_array['mmsi']) && $temp_array['mmsi'] != "")
164
+			if (isset($temp_array['mmsi']) && $temp_array['mmsi'] != "")
165 165
 			{
166 166
 				$Image = new Image($this->db);
167
-				if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']);
167
+				if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'], '', $temp_array['ident']);
168 168
 				else $image_array = $Image->getMarineImage($temp_array['mmsi']);
169 169
 				unset($Image);
170 170
 				if (count($image_array) > 0) {
@@ -200,17 +200,17 @@  discard block
 block discarded – undo
200 200
 				{
201 201
 					$temp_array['date'] = "about ".$dateArray['hours']." hours ago";
202 202
 				} else {
203
-					$temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC"));
203
+					$temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC"));
204 204
 				}
205 205
 				$temp_array['date_minutes_past'] = $dateArray['minutes'];
206
-				$temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC"));
207
-				$temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC"));
206
+				$temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC"));
207
+				$temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC"));
208 208
 				$temp_array['date_unix'] = strtotime($row['date']." UTC");
209 209
 				if (isset($row['last_seen']) && $row['last_seen'] != '') {
210 210
 					if (strtotime($row['last_seen']) > strtotime($row['date'])) {
211 211
 						$temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']);
212
-						$temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC"));
213
-						$temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC"));
212
+						$temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC"));
213
+						$temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC"));
214 214
 						$temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC");
215 215
 					}
216 216
 				}
@@ -243,8 +243,8 @@  discard block
 block discarded – undo
243 243
 		if ($limit != "")
244 244
 		{
245 245
 			$limit_array = explode(",", $limit);
246
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
247
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
246
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
247
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
248 248
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
249 249
 			{
250 250
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
@@ -258,8 +258,8 @@  discard block
 block discarded – undo
258 258
 		} else {
259 259
 			$orderby_query = " ORDER BY marine_output.date DESC";
260 260
 		}
261
-		$query  = $global_marine_query.$filter_query." ".$orderby_query;
262
-		$spotter_array = $this->getDataFromDB($query, array(),$limit_query,true);
261
+		$query = $global_marine_query.$filter_query." ".$orderby_query;
262
+		$spotter_array = $this->getDataFromDB($query, array(), $limit_query, true);
263 263
 		return $spotter_array;
264 264
 	}
265 265
     
@@ -277,8 +277,8 @@  discard block
 block discarded – undo
277 277
 		if ($id == '') return array();
278 278
 		$additional_query = "marine_output.fammarine_id = :id";
279 279
 		$query_values = array(':id' => $id);
280
-		$query  = $global_marine_query." WHERE ".$additional_query." ";
281
-		$spotter_array = $this->getDataFromDB($query,$query_values);
280
+		$query = $global_marine_query." WHERE ".$additional_query." ";
281
+		$spotter_array = $this->getDataFromDB($query, $query_values);
282 282
 		return $spotter_array;
283 283
 	}
284 284
 
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 		$query_values = array();
298 298
 		$limit_query = '';
299 299
 		$additional_query = '';
300
-		$filter_query = $this->getFilter($filter,true,true);
300
+		$filter_query = $this->getFilter($filter, true, true);
301 301
 		if ($ident != "")
302 302
 		{
303 303
 			if (!is_string($ident))
@@ -313,8 +313,8 @@  discard block
 block discarded – undo
313 313
 		{
314 314
 			$limit_array = explode(",", $limit);
315 315
 			
316
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
317
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
316
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
317
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
318 318
 			
319 319
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
320 320
 			{
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 		$query_values = array();
354 354
 		$limit_query = '';
355 355
 		$additional_query = '';
356
-		$filter_query = $this->getFilter($filter,true,true);
356
+		$filter_query = $this->getFilter($filter, true, true);
357 357
 		if (!is_string($type))
358 358
 		{
359 359
 			return false;
@@ -366,8 +366,8 @@  discard block
 block discarded – undo
366 366
 		{
367 367
 			$limit_array = explode(",", $limit);
368 368
 			
369
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
370
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
369
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
370
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
371 371
 			
372 372
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
373 373
 			{
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
 		return $spotter_array;
392 392
 	}
393 393
 	
394
-	public function getMarineDataByDate($date = '', $limit = '', $sort = '',$filter = array())
394
+	public function getMarineDataByDate($date = '', $limit = '', $sort = '', $filter = array())
395 395
 	{
396 396
 		global $global_marine_query, $globalTimezone, $globalDBdriver;
397 397
 		
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
 		$limit_query = '';
400 400
 		$additional_query = '';
401 401
 
402
-		$filter_query = $this->getFilter($filter,true,true);
402
+		$filter_query = $this->getFilter($filter, true, true);
403 403
 		
404 404
 		if ($date != "")
405 405
 		{
@@ -425,8 +425,8 @@  discard block
 block discarded – undo
425 425
 		{
426 426
 			$limit_array = explode(",", $limit);
427 427
 			
428
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
429
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
428
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
429
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
430 430
 			
431 431
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
432 432
 			{
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
 		$query_values = array();
462 462
 		$limit_query = '';
463 463
 		$additional_query = '';
464
-		$filter_query = $this->getFilter($filter,true,true);
464
+		$filter_query = $this->getFilter($filter, true, true);
465 465
 		if ($captain != "")
466 466
 		{
467 467
 			$additional_query = " AND (marine_output.captain_name = :captain OR marine_output.captain_id = :captain)";
@@ -470,8 +470,8 @@  discard block
 block discarded – undo
470 470
 		if ($limit != "")
471 471
 		{
472 472
 			$limit_array = explode(",", $limit);
473
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
474
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
473
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
474
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
475 475
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
476 476
 			{
477 477
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
@@ -497,11 +497,11 @@  discard block
 block discarded – undo
497 497
 	* @return Array list of source name
498 498
 	*
499 499
 	*/
500
-	public function getAllSourceName($type = '',$filters = array())
500
+	public function getAllSourceName($type = '', $filters = array())
501 501
 	{
502
-		$filter_query = $this->getFilter($filters,true,true);
502
+		$filter_query = $this->getFilter($filters, true, true);
503 503
 		$query_values = array();
504
-		$query  = "SELECT DISTINCT marine_output.source_name 
504
+		$query = "SELECT DISTINCT marine_output.source_name 
505 505
 				FROM marine_output".$filter_query." marine_output.source_name <> ''";
506 506
 		if ($type != '') {
507 507
 			$query_values = array(':type' => $type);
@@ -516,7 +516,7 @@  discard block
 block discarded – undo
516 516
 		$source_array = array();
517 517
 		$temp_array = array();
518 518
 		
519
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
519
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
520 520
 		{
521 521
 			$temp_array['source_name'] = $row['source_name'];
522 522
 			$source_array[] = $temp_array;
@@ -533,8 +533,8 @@  discard block
 block discarded – undo
533 533
 	*/
534 534
 	public function getAllIdents($filters = array())
535 535
 	{
536
-		$filter_query = $this->getFilter($filters,true,true);
537
-		$query  = "SELECT DISTINCT marine_output.ident
536
+		$filter_query = $this->getFilter($filters, true, true);
537
+		$query = "SELECT DISTINCT marine_output.ident
538 538
 								FROM marine_output".$filter_query." marine_output.ident <> '' 
539 539
 								ORDER BY marine_output.date ASC LIMIT 700 OFFSET 0";
540 540
 
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
 		$ident_array = array();
545 545
 		$temp_array = array();
546 546
 		
547
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
547
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
548 548
 		{
549 549
 			$temp_array['ident'] = $row['ident'];
550 550
 			$ident_array[] = $temp_array;
@@ -561,7 +561,7 @@  discard block
 block discarded – undo
561 561
 	*/
562 562
 	public function getIdentity($mmsi)
563 563
 	{
564
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
564
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT);
565 565
 		$query  = "SELECT * FROM marine_identity WHERE mmsi = :mmsi LIMIT 1";
566 566
 		$sth = $this->db->prepare($query);
567 567
 		$sth->execute(array(':mmsi' => $mmsi));
@@ -574,23 +574,23 @@  discard block
 block discarded – undo
574 574
 	* Add identity
575 575
 	*
576 576
 	*/
577
-	public function addIdentity($mmsi,$imo,$ident,$callsign,$type)
577
+	public function addIdentity($mmsi, $imo, $ident, $callsign, $type)
578 578
 	{
579
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
579
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT);
580 580
 		if ($mmsi != '') {
581
-			$imo = filter_var($imo,FILTER_SANITIZE_NUMBER_INT);
582
-			$ident = filter_var($ident,FILTER_SANITIZE_STRING);
583
-			$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
584
-			$type = filter_var($type,FILTER_SANITIZE_STRING);
581
+			$imo = filter_var($imo, FILTER_SANITIZE_NUMBER_INT);
582
+			$ident = filter_var($ident, FILTER_SANITIZE_STRING);
583
+			$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
584
+			$type = filter_var($type, FILTER_SANITIZE_STRING);
585 585
 			$identinfo = $this->getIdentity($mmsi);
586 586
 			if (empty($identinfo)) {
587
-				$query  = "INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:type)";
587
+				$query = "INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:type)";
588 588
 				$sth = $this->db->prepare($query);
589
-				$sth->execute(array(':mmsi' => $mmsi,':imo' => $imo,':call_sign' => $callsign,':ship_name' => $ident,':type' => $type));
589
+				$sth->execute(array(':mmsi' => $mmsi, ':imo' => $imo, ':call_sign' => $callsign, ':ship_name' => $ident, ':type' => $type));
590 590
 			} elseif ($ident != '' && $identinfo['ship_name'] != $ident) {
591
-				$query  = "UPDATE marine_identity SET ship_name = :ship_name,type = :type WHERE mmsi = :mmsi";
591
+				$query = "UPDATE marine_identity SET ship_name = :ship_name,type = :type WHERE mmsi = :mmsi";
592 592
 				$sth = $this->db->prepare($query);
593
-				$sth->execute(array(':mmsi' => $mmsi,':ship_name' => $ident,':type' => $type));
593
+				$sth->execute(array(':mmsi' => $mmsi, ':ship_name' => $ident, ':type' => $type));
594 594
 			}
595 595
 		}
596 596
 	}
@@ -611,12 +611,12 @@  discard block
 block discarded – undo
611 611
 		} else $offset = '+00:00';
612 612
 
613 613
 		if ($globalDBdriver == 'mysql') {
614
-			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date
614
+			$query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date
615 615
 								FROM marine_output
616 616
 								WHERE marine_output.date <> '' 
617 617
 								ORDER BY marine_output.date ASC LIMIT 0,100";
618 618
 		} else {
619
-			$query  = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
619
+			$query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
620 620
 								FROM marine_output
621 621
 								WHERE marine_output.date <> '' 
622 622
 								ORDER BY marine_output.date ASC LIMIT 0,100";
@@ -628,7 +628,7 @@  discard block
 block discarded – undo
628 628
 		$date_array = array();
629 629
 		$temp_array = array();
630 630
 		
631
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
631
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
632 632
 		{
633 633
 			$temp_array['date'] = $row['date'];
634 634
 
@@ -646,10 +646,10 @@  discard block
 block discarded – undo
646 646
 	* @return String success or false
647 647
 	*
648 648
 	*/
649
-	public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL)
649
+	public function updateIdentMarineData($fammarine_id = '', $ident = '', $fromsource = NULL)
650 650
 	{
651 651
 		$query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id';
652
-		$query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident);
652
+		$query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident);
653 653
 		try {
654 654
 			$sth = $this->db->prepare($query);
655 655
 			$sth->execute($query_values);
@@ -667,10 +667,10 @@  discard block
 block discarded – undo
667 667
 	* @return String success or false
668 668
 	*
669 669
 	*/
670
-	public function updateArrivalPortNameMarineData($fammarine_id = '', $arrival_code = '',$fromsource = NULL)
670
+	public function updateArrivalPortNameMarineData($fammarine_id = '', $arrival_code = '', $fromsource = NULL)
671 671
 	{
672 672
 		$query = 'UPDATE marine_output SET arrival_port_name = :arrival_code WHERE fammarine_id = :fammarine_id';
673
-		$query_values = array(':fammarine_id' => $fammarine_id,':arrival_code' => $arrival_code);
673
+		$query_values = array(':fammarine_id' => $fammarine_id, ':arrival_code' => $arrival_code);
674 674
 		try {
675 675
 			$sth = $this->db->prepare($query);
676 676
 			$sth->execute($query_values);
@@ -689,11 +689,11 @@  discard block
 block discarded – undo
689 689
 	* @return String success or false
690 690
 	*
691 691
 	*/
692
-	public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '')
692
+	public function updateStatusMarineData($fammarine_id = '', $status_id = '', $status = '')
693 693
 	{
694 694
 
695 695
 		$query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id';
696
-                $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id);
696
+                $query_values = array(':fammarine_id' => $fammarine_id, ':status' => $status, ':status_id' => $status_id);
697 697
 
698 698
 		try {
699 699
 			$sth = $this->db->prepare($query);
@@ -716,7 +716,7 @@  discard block
 block discarded – undo
716 716
 	public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '')
717 717
 	{
718 718
 		$query = 'UPDATE marine_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE fammarine_id = :fammarine_id';
719
-                $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident);
719
+                $query_values = array(':fammarine_id' => $fammarine_id, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident);
720 720
 
721 721
 		try {
722 722
 			$sth = $this->db->prepare($query);
@@ -754,7 +754,7 @@  discard block
 block discarded – undo
754 754
 	* @param String $verticalrate vertival rate of flight
755 755
 	* @return String success or false
756 756
 	*/
757
-	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 = '')
757
+	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 = '')
758 758
 	{
759 759
 		global $globalURL, $globalMarineImageFetch;
760 760
 		
@@ -821,36 +821,36 @@  discard block
 block discarded – undo
821 821
 		}
822 822
 
823 823
     
824
-		if ($date == "" || strtotime($date) < time()-20*60)
824
+		if ($date == "" || strtotime($date) < time() - 20*60)
825 825
 		{
826 826
 			$date = date("Y-m-d H:i:s", time());
827 827
 		}
828 828
 
829
-		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
830
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
831
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
832
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
833
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
834
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
835
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
836
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING);
837
-		$type = filter_var($type,FILTER_SANITIZE_STRING);
838
-		$status = filter_var($status,FILTER_SANITIZE_STRING);
839
-		$type_id = filter_var($typeid,FILTER_SANITIZE_NUMBER_INT);
840
-		$status_id = filter_var($statusid,FILTER_SANITIZE_NUMBER_INT);
841
-		$imo = filter_var($imo,FILTER_SANITIZE_STRING);
842
-		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
843
-		$arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING);
844
-		$arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING);
845
-		$captain_id = filter_var($captain_id,FILTER_SANITIZE_STRING);
846
-		$captain_name = filter_var($captain_name,FILTER_SANITIZE_STRING);
847
-		$race_id = filter_var($race_id,FILTER_SANITIZE_STRING);
848
-		$race_name = filter_var($race_name,FILTER_SANITIZE_STRING);
829
+		$fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING);
830
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
831
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
832
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
833
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
834
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
835
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
836
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING);
837
+		$type = filter_var($type, FILTER_SANITIZE_STRING);
838
+		$status = filter_var($status, FILTER_SANITIZE_STRING);
839
+		$type_id = filter_var($typeid, FILTER_SANITIZE_NUMBER_INT);
840
+		$status_id = filter_var($statusid, FILTER_SANITIZE_NUMBER_INT);
841
+		$imo = filter_var($imo, FILTER_SANITIZE_STRING);
842
+		$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
843
+		$arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING);
844
+		$arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING);
845
+		$captain_id = filter_var($captain_id, FILTER_SANITIZE_STRING);
846
+		$captain_name = filter_var($captain_name, FILTER_SANITIZE_STRING);
847
+		$race_id = filter_var($race_id, FILTER_SANITIZE_STRING);
848
+		$race_name = filter_var($race_name, FILTER_SANITIZE_STRING);
849 849
 		if (isset($globalMarineImageFetch) && $globalMarineImageFetch === TRUE) {
850 850
 			$Image = new Image($this->db);
851
-			$image_array = $Image->getMarineImage($mmsi,$imo,$ident);
851
+			$image_array = $Image->getMarineImage($mmsi, $imo, $ident);
852 852
 			if (!isset($image_array[0]['mmsi'])) {
853
-				$Image->addMarineImage($mmsi,$imo,$ident);
853
+				$Image->addMarineImage($mmsi, $imo, $ident);
854 854
 			}
855 855
 			unset($Image);
856 856
 		}
@@ -863,10 +863,10 @@  discard block
 block discarded – undo
863 863
 		if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
864 864
 		//if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
865 865
 		if ($arrival_date == '') $arrival_date = NULL;
866
-		$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) 
866
+		$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) 
867 867
 		    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)";
868 868
 
869
-		$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);
869
+		$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);
870 870
 		try {
871 871
 			$sth = $this->db->prepare($query);
872 872
 			$sth->execute($query_values);
@@ -890,13 +890,13 @@  discard block
 block discarded – undo
890 890
 	{
891 891
 		global $globalDBdriver, $globalTimezone;
892 892
 		if ($globalDBdriver == 'mysql') {
893
-			$query  = "SELECT marine_output.ident FROM marine_output 
893
+			$query = "SELECT marine_output.ident FROM marine_output 
894 894
 								WHERE marine_output.ident = :ident 
895 895
 								AND marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
896 896
 								AND marine_output.date < UTC_TIMESTAMP()";
897 897
 			$query_data = array(':ident' => $ident);
898 898
 		} else {
899
-			$query  = "SELECT marine_output.ident FROM marine_output 
899
+			$query = "SELECT marine_output.ident FROM marine_output 
900 900
 								WHERE marine_output.ident = :ident 
901 901
 								AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
902 902
 								AND marine_output.date < now() AT TIME ZONE 'UTC'";
@@ -905,8 +905,8 @@  discard block
 block discarded – undo
905 905
 		
906 906
 		$sth = $this->db->prepare($query);
907 907
 		$sth->execute($query_data);
908
-    		$ident_result='';
909
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
908
+    		$ident_result = '';
909
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
910 910
 		{
911 911
 			$ident_result = $row['ident'];
912 912
 		}
@@ -932,8 +932,8 @@  discard block
 block discarded – undo
932 932
 				return false;
933 933
 			} else {
934 934
 				$q_array = explode(" ", $q);
935
-				foreach ($q_array as $q_item){
936
-					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
935
+				foreach ($q_array as $q_item) {
936
+					$q_item = filter_var($q_item, FILTER_SANITIZE_STRING);
937 937
 					$additional_query .= " AND (";
938 938
 					$additional_query .= "(marine_output.ident like '%".$q_item."%')";
939 939
 					$additional_query .= ")";
@@ -941,11 +941,11 @@  discard block
 block discarded – undo
941 941
 			}
942 942
 		}
943 943
 		if ($globalDBdriver == 'mysql') {
944
-			$query  = "SELECT marine_output.* FROM marine_output 
944
+			$query = "SELECT marine_output.* FROM marine_output 
945 945
 				WHERE marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." 
946 946
 				AND marine_output.date < UTC_TIMESTAMP()";
947 947
 		} else {
948
-			$query  = "SELECT marine_output.* FROM marine_output 
948
+			$query = "SELECT marine_output.* FROM marine_output 
949 949
 				WHERE marine_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." 
950 950
 				AND marine_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
951 951
 		}
@@ -964,16 +964,16 @@  discard block
 block discarded – undo
964 964
 	*
965 965
 	*/
966 966
 
967
-	public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
967
+	public function countAllMarineOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
968 968
 	{
969 969
 		global $globalDBdriver, $globalArchive;
970 970
 		//$filter_query = $this->getFilter($filters,true,true);
971
-		$Connection= new Connection($this->db);
971
+		$Connection = new Connection($this->db);
972 972
 		if (!$Connection->tableExists('countries')) return array();
973 973
 		require_once('class.SpotterLive.php');
974 974
 		if (!isset($globalArchive) || $globalArchive !== TRUE) {
975 975
 			$MarineLive = new MarineLive($this->db);
976
-			$filter_query = $MarineLive->getFilter($filters,true,true);
976
+			$filter_query = $MarineLive->getFilter($filters, true, true);
977 977
 			$filter_query .= " over_country IS NOT NULL AND over_country <> ''";
978 978
 			if ($olderthanmonths > 0) {
979 979
 				if ($globalDBdriver == 'mysql') {
@@ -993,7 +993,7 @@  discard block
 block discarded – undo
993 993
 		} else {
994 994
 			require_once(dirname(__FILE__)."/class.MarineArchive.php");
995 995
 			$MarineArchive = new MarineArchive($this->db);
996
-			$filter_query = $MarineArchive->getFilter($filters,true,true);
996
+			$filter_query = $MarineArchive->getFilter($filters, true, true);
997 997
 			$filter_query .= " over_country <> ''";
998 998
 			if ($olderthanmonths > 0) {
999 999
 				if ($globalDBdriver == 'mysql') {
@@ -1021,7 +1021,7 @@  discard block
 block discarded – undo
1021 1021
 		$flight_array = array();
1022 1022
 		$temp_array = array();
1023 1023
         
1024
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1024
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1025 1025
 		{
1026 1026
 			$temp_array['marine_count'] = $row['nb'];
1027 1027
 			$temp_array['marine_country'] = $row['name'];
@@ -1040,11 +1040,11 @@  discard block
 block discarded – undo
1040 1040
 	* @return Array the callsign list
1041 1041
 	*
1042 1042
 	*/
1043
-	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
1043
+	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
1044 1044
 	{
1045 1045
 		global $globalDBdriver;
1046
-		$filter_query = $this->getFilter($filters,true,true);
1047
-		$query  = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count 
1046
+		$filter_query = $this->getFilter($filters, true, true);
1047
+		$query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count 
1048 1048
                     FROM marine_output".$filter_query." marine_output.ident <> ''";
1049 1049
 		 if ($olderthanmonths > 0) {
1050 1050
 			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
@@ -1058,28 +1058,28 @@  discard block
 block discarded – undo
1058 1058
 		if ($year != '') {
1059 1059
 			if ($globalDBdriver == 'mysql') {
1060 1060
 				$query .= " AND YEAR(marine_output.date) = :year";
1061
-				$query_values = array_merge($query_values,array(':year' => $year));
1061
+				$query_values = array_merge($query_values, array(':year' => $year));
1062 1062
 			} else {
1063 1063
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
1064
-				$query_values = array_merge($query_values,array(':year' => $year));
1064
+				$query_values = array_merge($query_values, array(':year' => $year));
1065 1065
 			}
1066 1066
 		}
1067 1067
 		if ($month != '') {
1068 1068
 			if ($globalDBdriver == 'mysql') {
1069 1069
 				$query .= " AND MONTH(marine_output.date) = :month";
1070
-				$query_values = array_merge($query_values,array(':month' => $month));
1070
+				$query_values = array_merge($query_values, array(':month' => $month));
1071 1071
 			} else {
1072 1072
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
1073
-				$query_values = array_merge($query_values,array(':month' => $month));
1073
+				$query_values = array_merge($query_values, array(':month' => $month));
1074 1074
 			}
1075 1075
 		}
1076 1076
 		if ($day != '') {
1077 1077
 			if ($globalDBdriver == 'mysql') {
1078 1078
 				$query .= " AND DAY(marine_output.date) = :day";
1079
-				$query_values = array_merge($query_values,array(':day' => $day));
1079
+				$query_values = array_merge($query_values, array(':day' => $day));
1080 1080
 			} else {
1081 1081
 				$query .= " AND EXTRACT(DAY FROM marine_output.date) = :day";
1082
-				$query_values = array_merge($query_values,array(':day' => $day));
1082
+				$query_values = array_merge($query_values, array(':day' => $day));
1083 1083
 			}
1084 1084
 		}
1085 1085
 		$query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC";
@@ -1091,7 +1091,7 @@  discard block
 block discarded – undo
1091 1091
 		$callsign_array = array();
1092 1092
 		$temp_array = array();
1093 1093
         
1094
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1094
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1095 1095
 		{
1096 1096
 			$temp_array['callsign_icao'] = $row['ident'];
1097 1097
 			$temp_array['airline_name'] = $row['airline_name'];
@@ -1143,7 +1143,7 @@  discard block
 block discarded – undo
1143 1143
 		$date_array = array();
1144 1144
 		$temp_array = array();
1145 1145
         
1146
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1146
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1147 1147
 		{
1148 1148
 			$temp_array['date_name'] = $row['date_name'];
1149 1149
 			$temp_array['date_count'] = $row['date_count'];
@@ -1169,7 +1169,7 @@  discard block
 block discarded – undo
1169 1169
 			$datetime = new DateTime();
1170 1170
 			$offset = $datetime->format('P');
1171 1171
 		} else $offset = '+00:00';
1172
-		$filter_query = $this->getFilter($filters,true,true);
1172
+		$filter_query = $this->getFilter($filters, true, true);
1173 1173
 		if ($globalDBdriver == 'mysql') {
1174 1174
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
1175 1175
 								FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)";
@@ -1190,7 +1190,7 @@  discard block
 block discarded – undo
1190 1190
 		$date_array = array();
1191 1191
 		$temp_array = array();
1192 1192
         
1193
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1193
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1194 1194
 		{
1195 1195
 			$temp_array['date_name'] = $row['date_name'];
1196 1196
 			$temp_array['date_count'] = $row['date_count'];
@@ -1215,7 +1215,7 @@  discard block
 block discarded – undo
1215 1215
 			$datetime = new DateTime();
1216 1216
 			$offset = $datetime->format('P');
1217 1217
 		} else $offset = '+00:00';
1218
-		$filter_query = $this->getFilter($filters,true,true);
1218
+		$filter_query = $this->getFilter($filters, true, true);
1219 1219
 		if ($globalDBdriver == 'mysql') {
1220 1220
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
1221 1221
 								FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)";
@@ -1236,7 +1236,7 @@  discard block
 block discarded – undo
1236 1236
 		$date_array = array();
1237 1237
 		$temp_array = array();
1238 1238
         
1239
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1239
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1240 1240
 		{
1241 1241
 			$temp_array['date_name'] = $row['date_name'];
1242 1242
 			$temp_array['date_count'] = $row['date_count'];
@@ -1283,7 +1283,7 @@  discard block
 block discarded – undo
1283 1283
 		$date_array = array();
1284 1284
 		$temp_array = array();
1285 1285
         
1286
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1286
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1287 1287
 		{
1288 1288
 			$temp_array['month_name'] = $row['month_name'];
1289 1289
 			$temp_array['year_name'] = $row['year_name'];
@@ -1312,7 +1312,7 @@  discard block
 block discarded – undo
1312 1312
 			$datetime = new DateTime();
1313 1313
 			$offset = $datetime->format('P');
1314 1314
 		} else $offset = '+00:00';
1315
-		$filter_query = $this->getFilter($filters,true,true);
1315
+		$filter_query = $this->getFilter($filters, true, true);
1316 1316
 		if ($globalDBdriver == 'mysql') {
1317 1317
 			$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
1318 1318
 								FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)";
@@ -1333,7 +1333,7 @@  discard block
 block discarded – undo
1333 1333
 		$date_array = array();
1334 1334
 		$temp_array = array();
1335 1335
         
1336
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1336
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1337 1337
 		{
1338 1338
 			$temp_array['year_name'] = $row['year_name'];
1339 1339
 			$temp_array['month_name'] = $row['month_name'];
@@ -1353,7 +1353,7 @@  discard block
 block discarded – undo
1353 1353
 	* @return Array the hour list
1354 1354
 	*
1355 1355
 	*/
1356
-	public function countAllHours($orderby,$filters = array())
1356
+	public function countAllHours($orderby, $filters = array())
1357 1357
 	{
1358 1358
 		global $globalTimezone, $globalDBdriver;
1359 1359
 		if ($globalTimezone != '') {
@@ -1401,7 +1401,7 @@  discard block
 block discarded – undo
1401 1401
 		$hour_array = array();
1402 1402
 		$temp_array = array();
1403 1403
         
1404
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1404
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1405 1405
 		{
1406 1406
 			$temp_array['hour_name'] = $row['hour_name'];
1407 1407
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1423,8 +1423,8 @@  discard block
 block discarded – undo
1423 1423
 	public function countAllHoursByDate($date, $filters = array())
1424 1424
 	{
1425 1425
 		global $globalTimezone, $globalDBdriver;
1426
-		$filter_query = $this->getFilter($filters,true,true);
1427
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
1426
+		$filter_query = $this->getFilter($filters, true, true);
1427
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
1428 1428
 		if ($globalTimezone != '') {
1429 1429
 			date_default_timezone_set($globalTimezone);
1430 1430
 			$datetime = new DateTime($date);
@@ -1432,12 +1432,12 @@  discard block
 block discarded – undo
1432 1432
 		} else $offset = '+00:00';
1433 1433
 
1434 1434
 		if ($globalDBdriver == 'mysql') {
1435
-			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1435
+			$query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1436 1436
 								FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = :date
1437 1437
 								GROUP BY hour_name 
1438 1438
 								ORDER BY hour_name ASC";
1439 1439
 		} else {
1440
-			$query  = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1440
+			$query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1441 1441
 								FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date
1442 1442
 								GROUP BY hour_name 
1443 1443
 								ORDER BY hour_name ASC";
@@ -1449,7 +1449,7 @@  discard block
 block discarded – undo
1449 1449
 		$hour_array = array();
1450 1450
 		$temp_array = array();
1451 1451
         
1452
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1452
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1453 1453
 		{
1454 1454
 			$temp_array['hour_name'] = $row['hour_name'];
1455 1455
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1471,8 +1471,8 @@  discard block
 block discarded – undo
1471 1471
 	public function countAllHoursByIdent($ident, $filters = array())
1472 1472
 	{
1473 1473
 		global $globalTimezone, $globalDBdriver;
1474
-		$filter_query = $this->getFilter($filters,true,true);
1475
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
1474
+		$filter_query = $this->getFilter($filters, true, true);
1475
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1476 1476
 		if ($globalTimezone != '') {
1477 1477
 			date_default_timezone_set($globalTimezone);
1478 1478
 			$datetime = new DateTime();
@@ -1480,12 +1480,12 @@  discard block
 block discarded – undo
1480 1480
 		} else $offset = '+00:00';
1481 1481
 
1482 1482
 		if ($globalDBdriver == 'mysql') {
1483
-			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1483
+			$query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1484 1484
 								FROM marine_output".$filter_query." marine_output.ident = :ident 
1485 1485
 								GROUP BY hour_name 
1486 1486
 								ORDER BY hour_name ASC";
1487 1487
 		} else {
1488
-			$query  = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1488
+			$query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1489 1489
 								FROM marine_output".$filter_query." marine_output.ident = :ident 
1490 1490
 								GROUP BY hour_name 
1491 1491
 								ORDER BY hour_name ASC";
@@ -1493,12 +1493,12 @@  discard block
 block discarded – undo
1493 1493
       
1494 1494
 		
1495 1495
 		$sth = $this->db->prepare($query);
1496
-		$sth->execute(array(':ident' => $ident,':offset' => $offset));
1496
+		$sth->execute(array(':ident' => $ident, ':offset' => $offset));
1497 1497
       
1498 1498
 		$hour_array = array();
1499 1499
 		$temp_array = array();
1500 1500
         
1501
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1501
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1502 1502
 		{
1503 1503
 			$temp_array['hour_name'] = $row['hour_name'];
1504 1504
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1517,33 +1517,33 @@  discard block
 block discarded – undo
1517 1517
 	* @return Integer the number of vessels
1518 1518
 	*
1519 1519
 	*/
1520
-	public function countOverallMarine($filters = array(),$year = '',$month = '')
1520
+	public function countOverallMarine($filters = array(), $year = '', $month = '')
1521 1521
 	{
1522 1522
 		global $globalDBdriver;
1523 1523
 		//$queryi  = "SELECT COUNT(marine_output.marine_id) AS flight_count FROM marine_output";
1524
-		$queryi  = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output";
1524
+		$queryi = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output";
1525 1525
 		$query_values = array();
1526 1526
 		$query = '';
1527 1527
 		if ($year != '') {
1528 1528
 			if ($globalDBdriver == 'mysql') {
1529 1529
 				$query .= " AND YEAR(marine_output.date) = :year";
1530
-				$query_values = array_merge($query_values,array(':year' => $year));
1530
+				$query_values = array_merge($query_values, array(':year' => $year));
1531 1531
 			} else {
1532 1532
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
1533
-				$query_values = array_merge($query_values,array(':year' => $year));
1533
+				$query_values = array_merge($query_values, array(':year' => $year));
1534 1534
 			}
1535 1535
 		}
1536 1536
 		if ($month != '') {
1537 1537
 			if ($globalDBdriver == 'mysql') {
1538 1538
 				$query .= " AND MONTH(marine_output.date) = :month";
1539
-				$query_values = array_merge($query_values,array(':month' => $month));
1539
+				$query_values = array_merge($query_values, array(':month' => $month));
1540 1540
 			} else {
1541 1541
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
1542
-				$query_values = array_merge($query_values,array(':month' => $month));
1542
+				$query_values = array_merge($query_values, array(':month' => $month));
1543 1543
 			}
1544 1544
 		}
1545 1545
 		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1546
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1546
+		else $queryi .= $this->getFilter($filters, true, true).substr($query, 4);
1547 1547
 		
1548 1548
 		$sth = $this->db->prepare($queryi);
1549 1549
 		$sth->execute($query_values);
@@ -1556,32 +1556,32 @@  discard block
 block discarded – undo
1556 1556
 	* @return Integer the number of vessels
1557 1557
 	*
1558 1558
 	*/
1559
-	public function countOverallMarineTypes($filters = array(),$year = '',$month = '')
1559
+	public function countOverallMarineTypes($filters = array(), $year = '', $month = '')
1560 1560
 	{
1561 1561
 		global $globalDBdriver;
1562
-		$queryi  = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output";
1562
+		$queryi = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output";
1563 1563
 		$query_values = array();
1564 1564
 		$query = '';
1565 1565
 		if ($year != '') {
1566 1566
 			if ($globalDBdriver == 'mysql') {
1567 1567
 				$query .= " AND YEAR(marine_output.date) = :year";
1568
-				$query_values = array_merge($query_values,array(':year' => $year));
1568
+				$query_values = array_merge($query_values, array(':year' => $year));
1569 1569
 			} else {
1570 1570
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
1571
-				$query_values = array_merge($query_values,array(':year' => $year));
1571
+				$query_values = array_merge($query_values, array(':year' => $year));
1572 1572
 			}
1573 1573
 		}
1574 1574
 		if ($month != '') {
1575 1575
 			if ($globalDBdriver == 'mysql') {
1576 1576
 				$query .= " AND MONTH(marine_output.date) = :month";
1577
-				$query_values = array_merge($query_values,array(':month' => $month));
1577
+				$query_values = array_merge($query_values, array(':month' => $month));
1578 1578
 			} else {
1579 1579
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
1580
-				$query_values = array_merge($query_values,array(':month' => $month));
1580
+				$query_values = array_merge($query_values, array(':month' => $month));
1581 1581
 			}
1582 1582
 		}
1583 1583
 		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1584
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1584
+		else $queryi .= $this->getFilter($filters, true, true).substr($query, 4);
1585 1585
 		
1586 1586
 		$sth = $this->db->prepare($queryi);
1587 1587
 		$sth->execute($query_values);
@@ -1598,7 +1598,7 @@  discard block
 block discarded – undo
1598 1598
 	public function countAllHoursFromToday($filters = array())
1599 1599
 	{
1600 1600
 		global $globalTimezone, $globalDBdriver;
1601
-		$filter_query = $this->getFilter($filters,true,true);
1601
+		$filter_query = $this->getFilter($filters, true, true);
1602 1602
 		if ($globalTimezone != '') {
1603 1603
 			date_default_timezone_set($globalTimezone);
1604 1604
 			$datetime = new DateTime();
@@ -1606,12 +1606,12 @@  discard block
 block discarded – undo
1606 1606
 		} else $offset = '+00:00';
1607 1607
 
1608 1608
 		if ($globalDBdriver == 'mysql') {
1609
-			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1609
+			$query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1610 1610
 								FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = CURDATE()
1611 1611
 								GROUP BY hour_name 
1612 1612
 								ORDER BY hour_name ASC";
1613 1613
 		} else {
1614
-			$query  = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1614
+			$query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1615 1615
 								FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date)
1616 1616
 								GROUP BY hour_name 
1617 1617
 								ORDER BY hour_name ASC";
@@ -1623,7 +1623,7 @@  discard block
 block discarded – undo
1623 1623
 		$hour_array = array();
1624 1624
 		$temp_array = array();
1625 1625
         
1626
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1626
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1627 1627
 		{
1628 1628
 			$temp_array['hour_name'] = $row['hour_name'];
1629 1629
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1642,9 +1642,9 @@  discard block
 block discarded – undo
1642 1642
 	*/
1643 1643
 	public function getMarineIDBasedOnFamMarineID($fammarine_id)
1644 1644
 	{
1645
-		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
1645
+		$fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING);
1646 1646
 
1647
-		$query  = "SELECT marine_output.marine_id
1647
+		$query = "SELECT marine_output.marine_id
1648 1648
 				FROM marine_output 
1649 1649
 				WHERE marine_output.fammarine_id = '".$fammarine_id."'";
1650 1650
         
@@ -1652,7 +1652,7 @@  discard block
 block discarded – undo
1652 1652
 		$sth = $this->db->prepare($query);
1653 1653
 		$sth->execute();
1654 1654
 
1655
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1655
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1656 1656
 		{
1657 1657
 			return $row['marine_id'];
1658 1658
 		}
@@ -1677,23 +1677,23 @@  discard block
 block discarded – undo
1677 1677
 		}
1678 1678
 		
1679 1679
 		$current_date = date("Y-m-d H:i:s");
1680
-		$date = date("Y-m-d H:i:s",strtotime($dateString." UTC"));
1680
+		$date = date("Y-m-d H:i:s", strtotime($dateString." UTC"));
1681 1681
 		
1682 1682
 		$diff = abs(strtotime($current_date) - strtotime($date));
1683 1683
 
1684
-		$time_array['years'] = floor($diff / (365*60*60*24)); 
1684
+		$time_array['years'] = floor($diff/(365*60*60*24)); 
1685 1685
 		$years = $time_array['years'];
1686 1686
 		
1687
-		$time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
1687
+		$time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24));
1688 1688
 		$months = $time_array['months'];
1689 1689
 		
1690
-		$time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
1690
+		$time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24));
1691 1691
 		$days = $time_array['days'];
1692
-		$time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60));
1692
+		$time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60));
1693 1693
 		$hours = $time_array['hours'];
1694
-		$time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60);
1694
+		$time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60);
1695 1695
 		$minutes = $time_array['minutes'];
1696
-		$time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
1696
+		$time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
1697 1697
 		
1698 1698
 		return $time_array;
1699 1699
 	}
@@ -1716,63 +1716,63 @@  discard block
 block discarded – undo
1716 1716
 			$temp_array['direction_degree'] = $direction;
1717 1717
 			$temp_array['direction_shortname'] = "N";
1718 1718
 			$temp_array['direction_fullname'] = "North";
1719
-		} elseif ($direction >= 22.5 && $direction < 45){
1719
+		} elseif ($direction >= 22.5 && $direction < 45) {
1720 1720
 			$temp_array['direction_degree'] = $direction;
1721 1721
 			$temp_array['direction_shortname'] = "NNE";
1722 1722
 			$temp_array['direction_fullname'] = "North-Northeast";
1723
-		} elseif ($direction >= 45 && $direction < 67.5){
1723
+		} elseif ($direction >= 45 && $direction < 67.5) {
1724 1724
 			$temp_array['direction_degree'] = $direction;
1725 1725
 			$temp_array['direction_shortname'] = "NE";
1726 1726
 			$temp_array['direction_fullname'] = "Northeast";
1727
-		} elseif ($direction >= 67.5 && $direction < 90){
1727
+		} elseif ($direction >= 67.5 && $direction < 90) {
1728 1728
 			$temp_array['direction_degree'] = $direction;
1729 1729
 			$temp_array['direction_shortname'] = "ENE";
1730 1730
 			$temp_array['direction_fullname'] = "East-Northeast";
1731
-		} elseif ($direction >= 90 && $direction < 112.5){
1731
+		} elseif ($direction >= 90 && $direction < 112.5) {
1732 1732
 			$temp_array['direction_degree'] = $direction;
1733 1733
 			$temp_array['direction_shortname'] = "E";
1734 1734
 			$temp_array['direction_fullname'] = "East";
1735
-		} elseif ($direction >= 112.5 && $direction < 135){
1735
+		} elseif ($direction >= 112.5 && $direction < 135) {
1736 1736
 			$temp_array['direction_degree'] = $direction;
1737 1737
 			$temp_array['direction_shortname'] = "ESE";
1738 1738
 			$temp_array['direction_fullname'] = "East-Southeast";
1739
-		} elseif ($direction >= 135 && $direction < 157.5){
1739
+		} elseif ($direction >= 135 && $direction < 157.5) {
1740 1740
 			$temp_array['direction_degree'] = $direction;
1741 1741
 			$temp_array['direction_shortname'] = "SE";
1742 1742
 			$temp_array['direction_fullname'] = "Southeast";
1743
-		} elseif ($direction >= 157.5 && $direction < 180){
1743
+		} elseif ($direction >= 157.5 && $direction < 180) {
1744 1744
 			$temp_array['direction_degree'] = $direction;
1745 1745
 			$temp_array['direction_shortname'] = "SSE";
1746 1746
 			$temp_array['direction_fullname'] = "South-Southeast";
1747
-		} elseif ($direction >= 180 && $direction < 202.5){
1747
+		} elseif ($direction >= 180 && $direction < 202.5) {
1748 1748
 			$temp_array['direction_degree'] = $direction;
1749 1749
 			$temp_array['direction_shortname'] = "S";
1750 1750
 			$temp_array['direction_fullname'] = "South";
1751
-		} elseif ($direction >= 202.5 && $direction < 225){
1751
+		} elseif ($direction >= 202.5 && $direction < 225) {
1752 1752
 			$temp_array['direction_degree'] = $direction;
1753 1753
 			$temp_array['direction_shortname'] = "SSW";
1754 1754
 			$temp_array['direction_fullname'] = "South-Southwest";
1755
-		} elseif ($direction >= 225 && $direction < 247.5){
1755
+		} elseif ($direction >= 225 && $direction < 247.5) {
1756 1756
 			$temp_array['direction_degree'] = $direction;
1757 1757
 			$temp_array['direction_shortname'] = "SW";
1758 1758
 			$temp_array['direction_fullname'] = "Southwest";
1759
-		} elseif ($direction >= 247.5 && $direction < 270){
1759
+		} elseif ($direction >= 247.5 && $direction < 270) {
1760 1760
 			$temp_array['direction_degree'] = $direction;
1761 1761
 			$temp_array['direction_shortname'] = "WSW";
1762 1762
 			$temp_array['direction_fullname'] = "West-Southwest";
1763
-		} elseif ($direction >= 270 && $direction < 292.5){
1763
+		} elseif ($direction >= 270 && $direction < 292.5) {
1764 1764
 			$temp_array['direction_degree'] = $direction;
1765 1765
 			$temp_array['direction_shortname'] = "W";
1766 1766
 			$temp_array['direction_fullname'] = "West";
1767
-		} elseif ($direction >= 292.5 && $direction < 315){
1767
+		} elseif ($direction >= 292.5 && $direction < 315) {
1768 1768
 			$temp_array['direction_degree'] = $direction;
1769 1769
 			$temp_array['direction_shortname'] = "WNW";
1770 1770
 			$temp_array['direction_fullname'] = "West-Northwest";
1771
-		} elseif ($direction >= 315 && $direction < 337.5){
1771
+		} elseif ($direction >= 315 && $direction < 337.5) {
1772 1772
 			$temp_array['direction_degree'] = $direction;
1773 1773
 			$temp_array['direction_shortname'] = "NW";
1774 1774
 			$temp_array['direction_fullname'] = "Northwest";
1775
-		} elseif ($direction >= 337.5 && $direction < 360){
1775
+		} elseif ($direction >= 337.5 && $direction < 360) {
1776 1776
 			$temp_array['direction_degree'] = $direction;
1777 1777
 			$temp_array['direction_shortname'] = "NNW";
1778 1778
 			$temp_array['direction_fullname'] = "North-Northwest";
@@ -1789,11 +1789,11 @@  discard block
 block discarded – undo
1789 1789
 	* @param Float $longitude longitute of the flight
1790 1790
 	* @return String the countrie
1791 1791
 	*/
1792
-	public function getCountryFromLatitudeLongitude($latitude,$longitude)
1792
+	public function getCountryFromLatitudeLongitude($latitude, $longitude)
1793 1793
 	{
1794 1794
 		global $globalDBdriver, $globalDebug;
1795
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1796
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1795
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1796
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1797 1797
 	
1798 1798
 		$Connection = new Connection($this->db);
1799 1799
 		if (!$Connection->tableExists('countries')) return '';
@@ -1833,7 +1833,7 @@  discard block
 block discarded – undo
1833 1833
 	public function getCountryFromISO2($iso2)
1834 1834
 	{
1835 1835
 		global $globalDBdriver, $globalDebug;
1836
-		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
1836
+		$iso2 = filter_var($iso2, FILTER_SANITIZE_STRING);
1837 1837
 	
1838 1838
 		$Connection = new Connection($this->db);
1839 1839
 		if (!$Connection->tableExists('countries')) return '';
@@ -1881,7 +1881,7 @@  discard block
 block discarded – undo
1881 1881
 		
1882 1882
 		$bitly_data = json_decode($bitly_data);
1883 1883
 		$bitly_url = '';
1884
-		if ($bitly_data->status_txt = "OK"){
1884
+		if ($bitly_data->status_txt = "OK") {
1885 1885
 			$bitly_url = $bitly_data->data->url;
1886 1886
 		}
1887 1887
 
@@ -1895,11 +1895,11 @@  discard block
 block discarded – undo
1895 1895
 	* @return Array the vessel type list
1896 1896
 	*
1897 1897
 	*/
1898
-	public function countAllMarineTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
1898
+	public function countAllMarineTypes($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
1899 1899
 	{
1900 1900
 		global $globalDBdriver;
1901
-		$filter_query = $this->getFilter($filters,true,true);
1902
-		$query  = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count, marine_output.type_id AS marine_type_id 
1901
+		$filter_query = $this->getFilter($filters, true, true);
1902
+		$query = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count, marine_output.type_id AS marine_type_id 
1903 1903
 		    FROM marine_output ".$filter_query." marine_output.type <> '' AND marine_output.type_id IS NOT NULL";
1904 1904
 		if ($olderthanmonths > 0) {
1905 1905
 			if ($globalDBdriver == 'mysql') {
@@ -1919,28 +1919,28 @@  discard block
 block discarded – undo
1919 1919
 		if ($year != '') {
1920 1920
 			if ($globalDBdriver == 'mysql') {
1921 1921
 				$query .= " AND YEAR(marine_output.date) = :year";
1922
-				$query_values = array_merge($query_values,array(':year' => $year));
1922
+				$query_values = array_merge($query_values, array(':year' => $year));
1923 1923
 			} else {
1924 1924
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
1925
-				$query_values = array_merge($query_values,array(':year' => $year));
1925
+				$query_values = array_merge($query_values, array(':year' => $year));
1926 1926
 			}
1927 1927
 		}
1928 1928
 		if ($month != '') {
1929 1929
 			if ($globalDBdriver == 'mysql') {
1930 1930
 				$query .= " AND MONTH(marine_output.date) = :month";
1931
-				$query_values = array_merge($query_values,array(':month' => $month));
1931
+				$query_values = array_merge($query_values, array(':month' => $month));
1932 1932
 			} else {
1933 1933
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
1934
-				$query_values = array_merge($query_values,array(':month' => $month));
1934
+				$query_values = array_merge($query_values, array(':month' => $month));
1935 1935
 			}
1936 1936
 		}
1937 1937
 		if ($day != '') {
1938 1938
 			if ($globalDBdriver == 'mysql') {
1939 1939
 				$query .= " AND DAY(marine_output.date) = :day";
1940
-				$query_values = array_merge($query_values,array(':day' => $day));
1940
+				$query_values = array_merge($query_values, array(':day' => $day));
1941 1941
 			} else {
1942 1942
 				$query .= " AND EXTRACT(DAY FROM marine_output.date) = :day";
1943
-				$query_values = array_merge($query_values,array(':day' => $day));
1943
+				$query_values = array_merge($query_values, array(':day' => $day));
1944 1944
 			}
1945 1945
 		}
1946 1946
 		$query .= " GROUP BY marine_output.type, marine_output.type_id ORDER BY marine_type_count DESC";
@@ -1949,7 +1949,7 @@  discard block
 block discarded – undo
1949 1949
 		$sth->execute($query_values);
1950 1950
 		$marine_array = array();
1951 1951
 		$temp_array = array();
1952
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1952
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1953 1953
 		{
1954 1954
 			$temp_array['marine_type'] = $row['marine_type'];
1955 1955
 			$temp_array['marine_type_id'] = $row['marine_type_id'];
@@ -1965,13 +1965,13 @@  discard block
 block discarded – undo
1965 1965
 	* @return Array the tracker information
1966 1966
 	*
1967 1967
 	*/
1968
-	public function searchMarineData($q = '', $callsign = '',$mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '',$filters = array())
1968
+	public function searchMarineData($q = '', $callsign = '', $mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array())
1969 1969
 	{
1970 1970
 		global $globalTimezone, $globalDBdriver;
1971 1971
 		date_default_timezone_set('UTC');
1972 1972
 		$query_values = array();
1973 1973
 		$additional_query = '';
1974
-		$filter_query = $this->getFilter($filters,true,true);
1974
+		$filter_query = $this->getFilter($filters, true, true);
1975 1975
 		if ($q != "")
1976 1976
 		{
1977 1977
 			if (!is_string($q))
@@ -1979,8 +1979,8 @@  discard block
 block discarded – undo
1979 1979
 				return false;
1980 1980
 			} else {
1981 1981
 				$q_array = explode(" ", $q);
1982
-				foreach ($q_array as $q_item){
1983
-					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
1982
+				foreach ($q_array as $q_item) {
1983
+					$q_item = filter_var($q_item, FILTER_SANITIZE_STRING);
1984 1984
 					$additional_query .= " AND (";
1985 1985
 					if (is_int($q_item)) $additional_query .= "(marine_output.marine_id = '".$q_item."') OR ";
1986 1986
 					if (is_int($q_item)) $additional_query .= "(marine_output.mmsi = '".$q_item."') OR ";
@@ -1992,42 +1992,42 @@  discard block
 block discarded – undo
1992 1992
 		}
1993 1993
 		if ($callsign != "")
1994 1994
 		{
1995
-			$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
1995
+			$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
1996 1996
 			if (!is_string($callsign))
1997 1997
 			{
1998 1998
 				return false;
1999 1999
 			} else {
2000 2000
 				$additional_query .= " AND marine_output.ident = :callsign";
2001
-				$query_values = array_merge($query_values,array(':callsign' => $callsign));
2001
+				$query_values = array_merge($query_values, array(':callsign' => $callsign));
2002 2002
 			}
2003 2003
 		}
2004 2004
 		if ($mmsi != "")
2005 2005
 		{
2006
-			$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING);
2006
+			$mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING);
2007 2007
 			if (!is_numeric($mmsi))
2008 2008
 			{
2009 2009
 				return false;
2010 2010
 			} else {
2011 2011
 				$additional_query .= " AND marine_output.mmsi = :mmsi";
2012
-				$query_values = array_merge($query_values,array(':mmsi' => $mmsi));
2012
+				$query_values = array_merge($query_values, array(':mmsi' => $mmsi));
2013 2013
 			}
2014 2014
 		}
2015 2015
 		if ($imo != "")
2016 2016
 		{
2017
-			$imo = filter_var($imo,FILTER_SANITIZE_STRING);
2017
+			$imo = filter_var($imo, FILTER_SANITIZE_STRING);
2018 2018
 			if (!is_numeric($imo))
2019 2019
 			{
2020 2020
 				return false;
2021 2021
 			} else {
2022 2022
 				$additional_query .= " AND marine_output.imo = :imo";
2023
-				$query_values = array_merge($query_values,array(':imo' => $imo));
2023
+				$query_values = array_merge($query_values, array(':imo' => $imo));
2024 2024
 			}
2025 2025
 		}
2026 2026
 		if ($date_posted != "")
2027 2027
 		{
2028 2028
 			$date_array = explode(",", $date_posted);
2029
-			$date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
2030
-			$date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
2029
+			$date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING);
2030
+			$date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING);
2031 2031
 			if ($globalTimezone != '') {
2032 2032
 				date_default_timezone_set($globalTimezone);
2033 2033
 				$datetime = new DateTime();
@@ -2054,8 +2054,8 @@  discard block
 block discarded – undo
2054 2054
 		if ($limit != "")
2055 2055
 		{
2056 2056
 			$limit_array = explode(",", $limit);
2057
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
2058
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
2057
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
2058
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
2059 2059
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
2060 2060
 			{
2061 2061
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
@@ -2073,28 +2073,28 @@  discard block
 block discarded – undo
2073 2073
 			}
2074 2074
 		}
2075 2075
 		if ($origLat != "" && $origLon != "" && $dist != "") {
2076
-			$dist = number_format($dist*0.621371,2,'.',''); // convert km to mile
2076
+			$dist = number_format($dist*0.621371, 2, '.', ''); // convert km to mile
2077 2077
 			if ($globalDBdriver == 'mysql') {
2078
-				$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 
2078
+				$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 
2079 2079
 				    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)) 
2080 2080
 				    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;
2081 2081
 			} else {
2082
-				$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 
2082
+				$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 
2083 2083
 				    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)) 
2084 2084
 				    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;
2085 2085
 			}
2086 2086
 		} else {
2087
-			$query  = "SELECT marine_output.* FROM marine_output".$filter_query." marine_output.ident <> '' 
2087
+			$query = "SELECT marine_output.* FROM marine_output".$filter_query." marine_output.ident <> '' 
2088 2088
 			    ".$additional_query."
2089 2089
 			    ".$orderby_query;
2090 2090
 		}
2091
-		$marine_array = $this->getDataFromDB($query, $query_values,$limit_query);
2091
+		$marine_array = $this->getDataFromDB($query, $query_values, $limit_query);
2092 2092
 		return $marine_array;
2093 2093
 	}
2094 2094
 
2095 2095
 	public function getOrderBy()
2096 2096
 	{
2097
-		$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 Airport - ASC", "sql" => "ORDER BY marine_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_output.date DESC"),"distance_asc" => array("key" => "distance_asc","value" => "Distance - ASC","sql" => "ORDER BY distance ASC"),"distance_desc" => array("key" => "distance_desc","value" => "Distance - DESC","sql" => "ORDER BY distance DESC"));
2097
+		$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 Airport - ASC", "sql" => "ORDER BY marine_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_output.date DESC"), "distance_asc" => array("key" => "distance_asc", "value" => "Distance - ASC", "sql" => "ORDER BY distance ASC"), "distance_desc" => array("key" => "distance_desc", "value" => "Distance - DESC", "sql" => "ORDER BY distance DESC"));
2098 2098
 		
2099 2099
 		return $orderby;
2100 2100
 		
Please login to merge, or discard this patch.