Completed
Push — master ( de1208...af97e6 )
by Yannick
126:18 queued 98:30
created
require/class.Marine.php 1 patch
Spacing   +191 added lines, -191 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 require_once(dirname(__FILE__).'/class.Image.php');
3 3
 $global_query = "SELECT marine_output.* FROM marine_output";
4 4
 
5
-class Marine{
5
+class Marine {
6 6
 	public $db;
7 7
 	
8 8
 	public function __construct($dbc = null) {
@@ -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']."'";
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
73 73
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
74 74
 		if ($filter_query_where != '') {
75
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
75
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
76 76
 		}
77 77
 		$filter_query = $filter_query_join.$filter_query_where;
78 78
 		return $filter_query;
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 	* @return Array the spotter information
88 88
 	*
89 89
 	*/
90
-	public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false)
90
+	public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false)
91 91
 	{
92 92
 		date_default_timezone_set('UTC');
93 93
 		if (!is_string($query))
@@ -107,13 +107,13 @@  discard block
 block discarded – undo
107 107
 			$sth = $this->db->prepare($query.$limitQuery);
108 108
 			$sth->execute($params);
109 109
 		} catch (PDOException $e) {
110
-			printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery);
110
+			printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery);
111 111
 			exit();
112 112
 		}
113 113
 		
114 114
 		$num_rows = 0;
115 115
 		$spotter_array = array();
116
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
116
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
117 117
 		{
118 118
 			$num_rows++;
119 119
 			$temp_array = array();
@@ -145,10 +145,10 @@  discard block
 block discarded – undo
145 145
 			}
146 146
 			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];
147 147
 
148
-			if($temp_array['mmsi'] != "")
148
+			if ($temp_array['mmsi'] != "")
149 149
 			{
150 150
 				$Image = new Image($this->db);
151
-				if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']);
151
+				if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'], '', $temp_array['ident']);
152 152
 				else $image_array = $Image->getMarineImage($temp_array['mmsi']);
153 153
 				unset($Image);
154 154
 				if (count($image_array) > 0) {
@@ -184,17 +184,17 @@  discard block
 block discarded – undo
184 184
 				{
185 185
 					$temp_array['date'] = "about ".$dateArray['hours']." hours ago";
186 186
 				} else {
187
-					$temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC"));
187
+					$temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC"));
188 188
 				}
189 189
 				$temp_array['date_minutes_past'] = $dateArray['minutes'];
190
-				$temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC"));
191
-				$temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC"));
190
+				$temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC"));
191
+				$temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC"));
192 192
 				$temp_array['date_unix'] = strtotime($row['date']." UTC");
193 193
 				if (isset($row['last_seen']) && $row['last_seen'] != '') {
194 194
 					if (strtotime($row['last_seen']) > strtotime($row['date'])) {
195 195
 						$temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']);
196
-						$temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC"));
197
-						$temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC"));
196
+						$temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC"));
197
+						$temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC"));
198 198
 						$temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC");
199 199
 					}
200 200
 				}
@@ -227,8 +227,8 @@  discard block
 block discarded – undo
227 227
 		if ($limit != "")
228 228
 		{
229 229
 			$limit_array = explode(",", $limit);
230
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
231
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
230
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
231
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
232 232
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
233 233
 			{
234 234
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
@@ -242,8 +242,8 @@  discard block
 block discarded – undo
242 242
 		} else {
243 243
 			$orderby_query = " ORDER BY marine_output.date DESC";
244 244
 		}
245
-		$query  = $global_query.$filter_query." ".$orderby_query;
246
-		$spotter_array = $this->getDataFromDB($query, array(),$limit_query,true);
245
+		$query = $global_query.$filter_query." ".$orderby_query;
246
+		$spotter_array = $this->getDataFromDB($query, array(), $limit_query, true);
247 247
 		return $spotter_array;
248 248
 	}
249 249
     
@@ -261,8 +261,8 @@  discard block
 block discarded – undo
261 261
 		if ($id == '') return array();
262 262
 		$additional_query = "marine_output.fammarine_id = :id";
263 263
 		$query_values = array(':id' => $id);
264
-		$query  = $global_query." WHERE ".$additional_query." ";
265
-		$spotter_array = $this->getDataFromDB($query,$query_values);
264
+		$query = $global_query." WHERE ".$additional_query." ";
265
+		$spotter_array = $this->getDataFromDB($query, $query_values);
266 266
 		return $spotter_array;
267 267
 	}
268 268
 
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
 		$query_values = array();
282 282
 		$limit_query = '';
283 283
 		$additional_query = '';
284
-		$filter_query = $this->getFilter($filter,true,true);
284
+		$filter_query = $this->getFilter($filter, true, true);
285 285
 		if ($ident != "")
286 286
 		{
287 287
 			if (!is_string($ident))
@@ -297,8 +297,8 @@  discard block
 block discarded – undo
297 297
 		{
298 298
 			$limit_array = explode(",", $limit);
299 299
 			
300
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
301
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
300
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
301
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
302 302
 			
303 303
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
304 304
 			{
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 		return $spotter_array;
323 323
 	}
324 324
 	
325
-	public function getMarineDataByDate($date = '', $limit = '', $sort = '',$filter = array())
325
+	public function getMarineDataByDate($date = '', $limit = '', $sort = '', $filter = array())
326 326
 	{
327 327
 		global $global_query, $globalTimezone, $globalDBdriver;
328 328
 		
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 		$limit_query = '';
331 331
 		$additional_query = '';
332 332
 
333
-		$filter_query = $this->getFilter($filter,true,true);
333
+		$filter_query = $this->getFilter($filter, true, true);
334 334
 		
335 335
 		if ($date != "")
336 336
 		{
@@ -356,8 +356,8 @@  discard block
 block discarded – undo
356 356
 		{
357 357
 			$limit_array = explode(",", $limit);
358 358
 			
359
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
360
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
359
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
360
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
361 361
 			
362 362
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
363 363
 			{
@@ -388,11 +388,11 @@  discard block
 block discarded – undo
388 388
 	* @return Array list of source name
389 389
 	*
390 390
 	*/
391
-	public function getAllSourceName($type = '',$filters = array())
391
+	public function getAllSourceName($type = '', $filters = array())
392 392
 	{
393
-		$filter_query = $this->getFilter($filters,true,true);
393
+		$filter_query = $this->getFilter($filters, true, true);
394 394
 		$query_values = array();
395
-		$query  = "SELECT DISTINCT marine_output.source_name 
395
+		$query = "SELECT DISTINCT marine_output.source_name 
396 396
 				FROM marine_output".$filter_query." marine_output.source_name <> ''";
397 397
 		if ($type != '') {
398 398
 			$query_values = array(':type' => $type);
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
 		$source_array = array();
408 408
 		$temp_array = array();
409 409
 		
410
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
410
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
411 411
 		{
412 412
 			$temp_array['source_name'] = $row['source_name'];
413 413
 			$source_array[] = $temp_array;
@@ -424,8 +424,8 @@  discard block
 block discarded – undo
424 424
 	*/
425 425
 	public function getAllIdents($filters = array())
426 426
 	{
427
-		$filter_query = $this->getFilter($filters,true,true);
428
-		$query  = "SELECT DISTINCT marine_output.ident
427
+		$filter_query = $this->getFilter($filters, true, true);
428
+		$query = "SELECT DISTINCT marine_output.ident
429 429
 								FROM marine_output".$filter_query." marine_output.ident <> '' 
430 430
 								ORDER BY marine_output.date ASC LIMIT 700 OFFSET 0";
431 431
 
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
 		$ident_array = array();
436 436
 		$temp_array = array();
437 437
 		
438
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
438
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
439 439
 		{
440 440
 			$temp_array['ident'] = $row['ident'];
441 441
 			$ident_array[] = $temp_array;
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
 	*/
453 453
 	public function getIdentity($mmsi)
454 454
 	{
455
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
455
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT);
456 456
 		$query  = "SELECT * FROM marine_identity WHERE mmsi = :mmsi LIMIT 1";
457 457
 		$sth = $this->db->prepare($query);
458 458
 		$sth->execute(array(':mmsi' => $mmsi));
@@ -477,12 +477,12 @@  discard block
 block discarded – undo
477 477
 		} else $offset = '+00:00';
478 478
 
479 479
 		if ($globalDBdriver == 'mysql') {
480
-			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date
480
+			$query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date
481 481
 								FROM marine_output
482 482
 								WHERE marine_output.date <> '' 
483 483
 								ORDER BY marine_output.date ASC LIMIT 0,100";
484 484
 		} else {
485
-			$query  = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
485
+			$query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
486 486
 								FROM marine_output
487 487
 								WHERE marine_output.date <> '' 
488 488
 								ORDER BY marine_output.date ASC LIMIT 0,100";
@@ -494,7 +494,7 @@  discard block
 block discarded – undo
494 494
 		$date_array = array();
495 495
 		$temp_array = array();
496 496
 		
497
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
497
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
498 498
 		{
499 499
 			$temp_array['date'] = $row['date'];
500 500
 
@@ -513,11 +513,11 @@  discard block
 block discarded – undo
513 513
 	* @return String success or false
514 514
 	*
515 515
 	*/	
516
-	public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL)
516
+	public function updateIdentMarineData($fammarine_id = '', $ident = '', $fromsource = NULL)
517 517
 	{
518 518
 
519 519
 		$query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id';
520
-                $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident);
520
+                $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident);
521 521
 
522 522
 		try {
523 523
 			$sth = $this->db->prepare($query);
@@ -539,11 +539,11 @@  discard block
 block discarded – undo
539 539
 	* @return String success or false
540 540
 	*
541 541
 	*/	
542
-	public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '')
542
+	public function updateStatusMarineData($fammarine_id = '', $status_id = '', $status = '')
543 543
 	{
544 544
 
545 545
 		$query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id';
546
-                $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id);
546
+                $query_values = array(':fammarine_id' => $fammarine_id, ':status' => $status, ':status_id' => $status_id);
547 547
 
548 548
 		try {
549 549
 			$sth = $this->db->prepare($query);
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
 	public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '')
567 567
 	{
568 568
 		$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';
569
-                $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident);
569
+                $query_values = array(':fammarine_id' => $fammarine_id, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident);
570 570
 
571 571
 		try {
572 572
 			$sth = $this->db->prepare($query);
@@ -604,7 +604,7 @@  discard block
 block discarded – undo
604 604
 	* @param String $verticalrate vertival rate of flight
605 605
 	* @return String success or false
606 606
 	*/
607
-	public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$format_source = '', $source_name = '')
607
+	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 = '')
608 608
 	{
609 609
 		global $globalURL, $globalMarineImageFetch;
610 610
 		
@@ -671,31 +671,31 @@  discard block
 block discarded – undo
671 671
 		}
672 672
 
673 673
     
674
-		if ($date == "" || strtotime($date) < time()-20*60)
674
+		if ($date == "" || strtotime($date) < time() - 20*60)
675 675
 		{
676 676
 			$date = date("Y-m-d H:i:s", time());
677 677
 		}
678 678
 
679
-		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
680
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
681
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
682
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
683
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
684
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
685
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
686
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING);
687
-		$type = filter_var($type,FILTER_SANITIZE_STRING);
688
-		$status = filter_var($status,FILTER_SANITIZE_STRING);
689
-		$imo = filter_var($imo,FILTER_SANITIZE_STRING);
690
-		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
691
-		$arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING);
692
-		$arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING);
679
+		$fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING);
680
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
681
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
682
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
683
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
684
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
685
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
686
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING);
687
+		$type = filter_var($type, FILTER_SANITIZE_STRING);
688
+		$status = filter_var($status, FILTER_SANITIZE_STRING);
689
+		$imo = filter_var($imo, FILTER_SANITIZE_STRING);
690
+		$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
691
+		$arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING);
692
+		$arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING);
693 693
 	
694 694
 		if (isset($globalMarineImageFetch) && $globalMarineImageFetch === TRUE) {
695 695
 			$Image = new Image($this->db);
696
-			$image_array = $Image->getMarineImage($mmsi,$imo,$ident);
696
+			$image_array = $Image->getMarineImage($mmsi, $imo, $ident);
697 697
 			if (!isset($image_array[0]['mmsi'])) {
698
-				$Image->addMarineImage($mmsi,$imo,$ident);
698
+				$Image->addMarineImage($mmsi, $imo, $ident);
699 699
 			}
700 700
 			unset($Image);
701 701
 		}
@@ -707,10 +707,10 @@  discard block
 block discarded – undo
707 707
                 if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
708 708
                 if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
709 709
                 if ($arrival_date == '') $arrival_date = NULL;
710
-		$query  = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) 
710
+		$query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) 
711 711
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)";
712 712
 
713
-		$query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':mmsi' => $mmsi,':type' => $type,':status' => $status,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date);
713
+		$query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':speed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':mmsi' => $mmsi, ':type' => $type, ':status' => $status, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date);
714 714
 		try {
715 715
 		        
716 716
 			$sth = $this->db->prepare($query);
@@ -735,13 +735,13 @@  discard block
 block discarded – undo
735 735
 	{
736 736
 		global $globalDBdriver, $globalTimezone;
737 737
 		if ($globalDBdriver == 'mysql') {
738
-			$query  = "SELECT marine_output.ident FROM marine_output 
738
+			$query = "SELECT marine_output.ident FROM marine_output 
739 739
 								WHERE marine_output.ident = :ident 
740 740
 								AND marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
741 741
 								AND marine_output.date < UTC_TIMESTAMP()";
742 742
 			$query_data = array(':ident' => $ident);
743 743
 		} else {
744
-			$query  = "SELECT marine_output.ident FROM marine_output 
744
+			$query = "SELECT marine_output.ident FROM marine_output 
745 745
 								WHERE marine_output.ident = :ident 
746 746
 								AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
747 747
 								AND marine_output.date < now() AT TIME ZONE 'UTC'";
@@ -750,8 +750,8 @@  discard block
 block discarded – undo
750 750
 		
751 751
 		$sth = $this->db->prepare($query);
752 752
 		$sth->execute($query_data);
753
-    		$ident_result='';
754
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
753
+    		$ident_result = '';
754
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
755 755
 		{
756 756
 			$ident_result = $row['ident'];
757 757
 		}
@@ -777,8 +777,8 @@  discard block
 block discarded – undo
777 777
 				return false;
778 778
 			} else {
779 779
 				$q_array = explode(" ", $q);
780
-				foreach ($q_array as $q_item){
781
-					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
780
+				foreach ($q_array as $q_item) {
781
+					$q_item = filter_var($q_item, FILTER_SANITIZE_STRING);
782 782
 					$additional_query .= " AND (";
783 783
 					$additional_query .= "(marine_output.ident like '%".$q_item."%')";
784 784
 					$additional_query .= ")";
@@ -786,11 +786,11 @@  discard block
 block discarded – undo
786 786
 			}
787 787
 		}
788 788
 		if ($globalDBdriver == 'mysql') {
789
-			$query  = "SELECT marine_output.* FROM marine_output 
789
+			$query = "SELECT marine_output.* FROM marine_output 
790 790
 				WHERE marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." 
791 791
 				AND marine_output.date < UTC_TIMESTAMP()";
792 792
 		} else {
793
-			$query  = "SELECT marine_output.* FROM marine_output 
793
+			$query = "SELECT marine_output.* FROM marine_output 
794 794
 				WHERE marine_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." 
795 795
 				AND marine_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
796 796
 		}
@@ -809,16 +809,16 @@  discard block
 block discarded – undo
809 809
 	*
810 810
 	*/
811 811
 
812
-	public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
812
+	public function countAllMarineOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
813 813
 	{
814 814
 		global $globalDBdriver, $globalArchive;
815 815
 		//$filter_query = $this->getFilter($filters,true,true);
816
-		$Connection= new Connection($this->db);
816
+		$Connection = new Connection($this->db);
817 817
 		if (!$Connection->tableExists('countries')) return array();
818 818
 		require_once('class.SpotterLive.php');
819 819
 		if (!isset($globalArchive) || $globalArchive !== TRUE) {
820 820
 			$MarineLive = new MarineLive($this->db);
821
-			$filter_query = $MarineLive->getFilter($filters,true,true);
821
+			$filter_query = $MarineLive->getFilter($filters, true, true);
822 822
 			$filter_query .= " over_country IS NOT NULL AND over_country <> ''";
823 823
 			if ($olderthanmonths > 0) {
824 824
 				if ($globalDBdriver == 'mysql') {
@@ -838,7 +838,7 @@  discard block
 block discarded – undo
838 838
 		} else {
839 839
 			require_once(dirname(__FILE__)."/class.MarineArchive.php");
840 840
 			$MarineArchive = new MarineArchive($this->db);
841
-			$filter_query = $MarineArchive->getFilter($filters,true,true);
841
+			$filter_query = $MarineArchive->getFilter($filters, true, true);
842 842
 			$filter_query .= " over_country <> ''";
843 843
 			if ($olderthanmonths > 0) {
844 844
 				if ($globalDBdriver == 'mysql') {
@@ -866,7 +866,7 @@  discard block
 block discarded – undo
866 866
 		$flight_array = array();
867 867
 		$temp_array = array();
868 868
         
869
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
869
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
870 870
 		{
871 871
 			$temp_array['marine_count'] = $row['nb'];
872 872
 			$temp_array['marine_country'] = $row['name'];
@@ -885,11 +885,11 @@  discard block
 block discarded – undo
885 885
 	* @return Array the callsign list
886 886
 	*
887 887
 	*/
888
-	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
888
+	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
889 889
 	{
890 890
 		global $globalDBdriver;
891
-		$filter_query = $this->getFilter($filters,true,true);
892
-		$query  = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count 
891
+		$filter_query = $this->getFilter($filters, true, true);
892
+		$query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count 
893 893
                     FROM marine_output".$filter_query." marine_output.ident <> ''";
894 894
 		 if ($olderthanmonths > 0) {
895 895
 			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
@@ -903,28 +903,28 @@  discard block
 block discarded – undo
903 903
 		if ($year != '') {
904 904
 			if ($globalDBdriver == 'mysql') {
905 905
 				$query .= " AND YEAR(marine_output.date) = :year";
906
-				$query_values = array_merge($query_values,array(':year' => $year));
906
+				$query_values = array_merge($query_values, array(':year' => $year));
907 907
 			} else {
908 908
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
909
-				$query_values = array_merge($query_values,array(':year' => $year));
909
+				$query_values = array_merge($query_values, array(':year' => $year));
910 910
 			}
911 911
 		}
912 912
 		if ($month != '') {
913 913
 			if ($globalDBdriver == 'mysql') {
914 914
 				$query .= " AND MONTH(marine_output.date) = :month";
915
-				$query_values = array_merge($query_values,array(':month' => $month));
915
+				$query_values = array_merge($query_values, array(':month' => $month));
916 916
 			} else {
917 917
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
918
-				$query_values = array_merge($query_values,array(':month' => $month));
918
+				$query_values = array_merge($query_values, array(':month' => $month));
919 919
 			}
920 920
 		}
921 921
 		if ($day != '') {
922 922
 			if ($globalDBdriver == 'mysql') {
923 923
 				$query .= " AND DAY(marine_output.date) = :day";
924
-				$query_values = array_merge($query_values,array(':day' => $day));
924
+				$query_values = array_merge($query_values, array(':day' => $day));
925 925
 			} else {
926 926
 				$query .= " AND EXTRACT(DAY FROM marine_output.date) = :day";
927
-				$query_values = array_merge($query_values,array(':day' => $day));
927
+				$query_values = array_merge($query_values, array(':day' => $day));
928 928
 			}
929 929
 		}
930 930
 		$query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC";
@@ -936,7 +936,7 @@  discard block
 block discarded – undo
936 936
 		$callsign_array = array();
937 937
 		$temp_array = array();
938 938
         
939
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
939
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
940 940
 		{
941 941
 			$temp_array['callsign_icao'] = $row['ident'];
942 942
 			$temp_array['airline_name'] = $row['airline_name'];
@@ -988,7 +988,7 @@  discard block
 block discarded – undo
988 988
 		$date_array = array();
989 989
 		$temp_array = array();
990 990
         
991
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
991
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
992 992
 		{
993 993
 			$temp_array['date_name'] = $row['date_name'];
994 994
 			$temp_array['date_count'] = $row['date_count'];
@@ -1014,7 +1014,7 @@  discard block
 block discarded – undo
1014 1014
 			$datetime = new DateTime();
1015 1015
 			$offset = $datetime->format('P');
1016 1016
 		} else $offset = '+00:00';
1017
-		$filter_query = $this->getFilter($filters,true,true);
1017
+		$filter_query = $this->getFilter($filters, true, true);
1018 1018
 		if ($globalDBdriver == 'mysql') {
1019 1019
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
1020 1020
 								FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)";
@@ -1035,7 +1035,7 @@  discard block
 block discarded – undo
1035 1035
 		$date_array = array();
1036 1036
 		$temp_array = array();
1037 1037
         
1038
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1038
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1039 1039
 		{
1040 1040
 			$temp_array['date_name'] = $row['date_name'];
1041 1041
 			$temp_array['date_count'] = $row['date_count'];
@@ -1060,7 +1060,7 @@  discard block
 block discarded – undo
1060 1060
 			$datetime = new DateTime();
1061 1061
 			$offset = $datetime->format('P');
1062 1062
 		} else $offset = '+00:00';
1063
-		$filter_query = $this->getFilter($filters,true,true);
1063
+		$filter_query = $this->getFilter($filters, true, true);
1064 1064
 		if ($globalDBdriver == 'mysql') {
1065 1065
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
1066 1066
 								FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)";
@@ -1081,7 +1081,7 @@  discard block
 block discarded – undo
1081 1081
 		$date_array = array();
1082 1082
 		$temp_array = array();
1083 1083
         
1084
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1084
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1085 1085
 		{
1086 1086
 			$temp_array['date_name'] = $row['date_name'];
1087 1087
 			$temp_array['date_count'] = $row['date_count'];
@@ -1128,7 +1128,7 @@  discard block
 block discarded – undo
1128 1128
 		$date_array = array();
1129 1129
 		$temp_array = array();
1130 1130
         
1131
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1131
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1132 1132
 		{
1133 1133
 			$temp_array['month_name'] = $row['month_name'];
1134 1134
 			$temp_array['year_name'] = $row['year_name'];
@@ -1157,7 +1157,7 @@  discard block
 block discarded – undo
1157 1157
 			$datetime = new DateTime();
1158 1158
 			$offset = $datetime->format('P');
1159 1159
 		} else $offset = '+00:00';
1160
-		$filter_query = $this->getFilter($filters,true,true);
1160
+		$filter_query = $this->getFilter($filters, true, true);
1161 1161
 		if ($globalDBdriver == 'mysql') {
1162 1162
 			$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
1163 1163
 								FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)";
@@ -1178,7 +1178,7 @@  discard block
 block discarded – undo
1178 1178
 		$date_array = array();
1179 1179
 		$temp_array = array();
1180 1180
         
1181
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1181
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1182 1182
 		{
1183 1183
 			$temp_array['year_name'] = $row['year_name'];
1184 1184
 			$temp_array['month_name'] = $row['month_name'];
@@ -1198,7 +1198,7 @@  discard block
 block discarded – undo
1198 1198
 	* @return Array the hour list
1199 1199
 	*
1200 1200
 	*/
1201
-	public function countAllHours($orderby,$filters = array())
1201
+	public function countAllHours($orderby, $filters = array())
1202 1202
 	{
1203 1203
 		global $globalTimezone, $globalDBdriver;
1204 1204
 		if ($globalTimezone != '') {
@@ -1246,7 +1246,7 @@  discard block
 block discarded – undo
1246 1246
 		$hour_array = array();
1247 1247
 		$temp_array = array();
1248 1248
         
1249
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1249
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1250 1250
 		{
1251 1251
 			$temp_array['hour_name'] = $row['hour_name'];
1252 1252
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1268,8 +1268,8 @@  discard block
 block discarded – undo
1268 1268
 	public function countAllHoursByDate($date, $filters = array())
1269 1269
 	{
1270 1270
 		global $globalTimezone, $globalDBdriver;
1271
-		$filter_query = $this->getFilter($filters,true,true);
1272
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
1271
+		$filter_query = $this->getFilter($filters, true, true);
1272
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
1273 1273
 		if ($globalTimezone != '') {
1274 1274
 			date_default_timezone_set($globalTimezone);
1275 1275
 			$datetime = new DateTime($date);
@@ -1277,12 +1277,12 @@  discard block
 block discarded – undo
1277 1277
 		} else $offset = '+00:00';
1278 1278
 
1279 1279
 		if ($globalDBdriver == 'mysql') {
1280
-			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1280
+			$query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1281 1281
 								FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = :date
1282 1282
 								GROUP BY hour_name 
1283 1283
 								ORDER BY hour_name ASC";
1284 1284
 		} else {
1285
-			$query  = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1285
+			$query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1286 1286
 								FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date
1287 1287
 								GROUP BY hour_name 
1288 1288
 								ORDER BY hour_name ASC";
@@ -1294,7 +1294,7 @@  discard block
 block discarded – undo
1294 1294
 		$hour_array = array();
1295 1295
 		$temp_array = array();
1296 1296
         
1297
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1297
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1298 1298
 		{
1299 1299
 			$temp_array['hour_name'] = $row['hour_name'];
1300 1300
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1316,8 +1316,8 @@  discard block
 block discarded – undo
1316 1316
 	public function countAllHoursByIdent($ident, $filters = array())
1317 1317
 	{
1318 1318
 		global $globalTimezone, $globalDBdriver;
1319
-		$filter_query = $this->getFilter($filters,true,true);
1320
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
1319
+		$filter_query = $this->getFilter($filters, true, true);
1320
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1321 1321
 		if ($globalTimezone != '') {
1322 1322
 			date_default_timezone_set($globalTimezone);
1323 1323
 			$datetime = new DateTime();
@@ -1325,12 +1325,12 @@  discard block
 block discarded – undo
1325 1325
 		} else $offset = '+00:00';
1326 1326
 
1327 1327
 		if ($globalDBdriver == 'mysql') {
1328
-			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1328
+			$query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1329 1329
 								FROM marine_output".$filter_query." marine_output.ident = :ident 
1330 1330
 								GROUP BY hour_name 
1331 1331
 								ORDER BY hour_name ASC";
1332 1332
 		} else {
1333
-			$query  = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1333
+			$query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1334 1334
 								FROM marine_output".$filter_query." marine_output.ident = :ident 
1335 1335
 								GROUP BY hour_name 
1336 1336
 								ORDER BY hour_name ASC";
@@ -1338,12 +1338,12 @@  discard block
 block discarded – undo
1338 1338
       
1339 1339
 		
1340 1340
 		$sth = $this->db->prepare($query);
1341
-		$sth->execute(array(':ident' => $ident,':offset' => $offset));
1341
+		$sth->execute(array(':ident' => $ident, ':offset' => $offset));
1342 1342
       
1343 1343
 		$hour_array = array();
1344 1344
 		$temp_array = array();
1345 1345
         
1346
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1346
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1347 1347
 		{
1348 1348
 			$temp_array['hour_name'] = $row['hour_name'];
1349 1349
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1362,33 +1362,33 @@  discard block
 block discarded – undo
1362 1362
 	* @return Integer the number of vessels
1363 1363
 	*
1364 1364
 	*/
1365
-	public function countOverallMarine($filters = array(),$year = '',$month = '')
1365
+	public function countOverallMarine($filters = array(), $year = '', $month = '')
1366 1366
 	{
1367 1367
 		global $globalDBdriver;
1368 1368
 		//$queryi  = "SELECT COUNT(marine_output.marine_id) AS flight_count FROM marine_output";
1369
-		$queryi  = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output";
1369
+		$queryi = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output";
1370 1370
 		$query_values = array();
1371 1371
 		$query = '';
1372 1372
 		if ($year != '') {
1373 1373
 			if ($globalDBdriver == 'mysql') {
1374 1374
 				$query .= " AND YEAR(marine_output.date) = :year";
1375
-				$query_values = array_merge($query_values,array(':year' => $year));
1375
+				$query_values = array_merge($query_values, array(':year' => $year));
1376 1376
 			} else {
1377 1377
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
1378
-				$query_values = array_merge($query_values,array(':year' => $year));
1378
+				$query_values = array_merge($query_values, array(':year' => $year));
1379 1379
 			}
1380 1380
 		}
1381 1381
 		if ($month != '') {
1382 1382
 			if ($globalDBdriver == 'mysql') {
1383 1383
 				$query .= " AND MONTH(marine_output.date) = :month";
1384
-				$query_values = array_merge($query_values,array(':month' => $month));
1384
+				$query_values = array_merge($query_values, array(':month' => $month));
1385 1385
 			} else {
1386 1386
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
1387
-				$query_values = array_merge($query_values,array(':month' => $month));
1387
+				$query_values = array_merge($query_values, array(':month' => $month));
1388 1388
 			}
1389 1389
 		}
1390 1390
 		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1391
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1391
+		else $queryi .= $this->getFilter($filters, true, true).substr($query, 4);
1392 1392
 		
1393 1393
 		$sth = $this->db->prepare($queryi);
1394 1394
 		$sth->execute($query_values);
@@ -1401,32 +1401,32 @@  discard block
 block discarded – undo
1401 1401
 	* @return Integer the number of vessels
1402 1402
 	*
1403 1403
 	*/
1404
-	public function countOverallMarineTypes($filters = array(),$year = '',$month = '')
1404
+	public function countOverallMarineTypes($filters = array(), $year = '', $month = '')
1405 1405
 	{
1406 1406
 		global $globalDBdriver;
1407
-		$queryi  = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output";
1407
+		$queryi = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output";
1408 1408
 		$query_values = array();
1409 1409
 		$query = '';
1410 1410
 		if ($year != '') {
1411 1411
 			if ($globalDBdriver == 'mysql') {
1412 1412
 				$query .= " AND YEAR(marine_output.date) = :year";
1413
-				$query_values = array_merge($query_values,array(':year' => $year));
1413
+				$query_values = array_merge($query_values, array(':year' => $year));
1414 1414
 			} else {
1415 1415
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
1416
-				$query_values = array_merge($query_values,array(':year' => $year));
1416
+				$query_values = array_merge($query_values, array(':year' => $year));
1417 1417
 			}
1418 1418
 		}
1419 1419
 		if ($month != '') {
1420 1420
 			if ($globalDBdriver == 'mysql') {
1421 1421
 				$query .= " AND MONTH(marine_output.date) = :month";
1422
-				$query_values = array_merge($query_values,array(':month' => $month));
1422
+				$query_values = array_merge($query_values, array(':month' => $month));
1423 1423
 			} else {
1424 1424
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
1425
-				$query_values = array_merge($query_values,array(':month' => $month));
1425
+				$query_values = array_merge($query_values, array(':month' => $month));
1426 1426
 			}
1427 1427
 		}
1428 1428
 		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1429
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1429
+		else $queryi .= $this->getFilter($filters, true, true).substr($query, 4);
1430 1430
 		
1431 1431
 		$sth = $this->db->prepare($queryi);
1432 1432
 		$sth->execute($query_values);
@@ -1443,7 +1443,7 @@  discard block
 block discarded – undo
1443 1443
 	public function countAllHoursFromToday($filters = array())
1444 1444
 	{
1445 1445
 		global $globalTimezone, $globalDBdriver;
1446
-		$filter_query = $this->getFilter($filters,true,true);
1446
+		$filter_query = $this->getFilter($filters, true, true);
1447 1447
 		if ($globalTimezone != '') {
1448 1448
 			date_default_timezone_set($globalTimezone);
1449 1449
 			$datetime = new DateTime();
@@ -1451,12 +1451,12 @@  discard block
 block discarded – undo
1451 1451
 		} else $offset = '+00:00';
1452 1452
 
1453 1453
 		if ($globalDBdriver == 'mysql') {
1454
-			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1454
+			$query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1455 1455
 								FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = CURDATE()
1456 1456
 								GROUP BY hour_name 
1457 1457
 								ORDER BY hour_name ASC";
1458 1458
 		} else {
1459
-			$query  = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1459
+			$query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1460 1460
 								FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date)
1461 1461
 								GROUP BY hour_name 
1462 1462
 								ORDER BY hour_name ASC";
@@ -1468,7 +1468,7 @@  discard block
 block discarded – undo
1468 1468
 		$hour_array = array();
1469 1469
 		$temp_array = array();
1470 1470
         
1471
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1471
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1472 1472
 		{
1473 1473
 			$temp_array['hour_name'] = $row['hour_name'];
1474 1474
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1487,9 +1487,9 @@  discard block
 block discarded – undo
1487 1487
 	*/
1488 1488
 	public function getMarineIDBasedOnFamMarineID($fammarine_id)
1489 1489
 	{
1490
-		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
1490
+		$fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING);
1491 1491
 
1492
-		$query  = "SELECT marine_output.marine_id
1492
+		$query = "SELECT marine_output.marine_id
1493 1493
 				FROM marine_output 
1494 1494
 				WHERE marine_output.fammarine_id = '".$fammarine_id."'";
1495 1495
         
@@ -1497,7 +1497,7 @@  discard block
 block discarded – undo
1497 1497
 		$sth = $this->db->prepare($query);
1498 1498
 		$sth->execute();
1499 1499
 
1500
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1500
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1501 1501
 		{
1502 1502
 			return $row['marine_id'];
1503 1503
 		}
@@ -1522,23 +1522,23 @@  discard block
 block discarded – undo
1522 1522
 		}
1523 1523
 		
1524 1524
 		$current_date = date("Y-m-d H:i:s");
1525
-		$date = date("Y-m-d H:i:s",strtotime($dateString." UTC"));
1525
+		$date = date("Y-m-d H:i:s", strtotime($dateString." UTC"));
1526 1526
 		
1527 1527
 		$diff = abs(strtotime($current_date) - strtotime($date));
1528 1528
 
1529
-		$time_array['years'] = floor($diff / (365*60*60*24)); 
1529
+		$time_array['years'] = floor($diff/(365*60*60*24)); 
1530 1530
 		$years = $time_array['years'];
1531 1531
 		
1532
-		$time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
1532
+		$time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24));
1533 1533
 		$months = $time_array['months'];
1534 1534
 		
1535
-		$time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
1535
+		$time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24));
1536 1536
 		$days = $time_array['days'];
1537
-		$time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60));
1537
+		$time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60));
1538 1538
 		$hours = $time_array['hours'];
1539
-		$time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60);
1539
+		$time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60);
1540 1540
 		$minutes = $time_array['minutes'];
1541
-		$time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
1541
+		$time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
1542 1542
 		
1543 1543
 		return $time_array;
1544 1544
 	}
@@ -1561,63 +1561,63 @@  discard block
 block discarded – undo
1561 1561
 			$temp_array['direction_degree'] = $direction;
1562 1562
 			$temp_array['direction_shortname'] = "N";
1563 1563
 			$temp_array['direction_fullname'] = "North";
1564
-		} elseif ($direction >= 22.5 && $direction < 45){
1564
+		} elseif ($direction >= 22.5 && $direction < 45) {
1565 1565
 			$temp_array['direction_degree'] = $direction;
1566 1566
 			$temp_array['direction_shortname'] = "NNE";
1567 1567
 			$temp_array['direction_fullname'] = "North-Northeast";
1568
-		} elseif ($direction >= 45 && $direction < 67.5){
1568
+		} elseif ($direction >= 45 && $direction < 67.5) {
1569 1569
 			$temp_array['direction_degree'] = $direction;
1570 1570
 			$temp_array['direction_shortname'] = "NE";
1571 1571
 			$temp_array['direction_fullname'] = "Northeast";
1572
-		} elseif ($direction >= 67.5 && $direction < 90){
1572
+		} elseif ($direction >= 67.5 && $direction < 90) {
1573 1573
 			$temp_array['direction_degree'] = $direction;
1574 1574
 			$temp_array['direction_shortname'] = "ENE";
1575 1575
 			$temp_array['direction_fullname'] = "East-Northeast";
1576
-		} elseif ($direction >= 90 && $direction < 112.5){
1576
+		} elseif ($direction >= 90 && $direction < 112.5) {
1577 1577
 			$temp_array['direction_degree'] = $direction;
1578 1578
 			$temp_array['direction_shortname'] = "E";
1579 1579
 			$temp_array['direction_fullname'] = "East";
1580
-		} elseif ($direction >= 112.5 && $direction < 135){
1580
+		} elseif ($direction >= 112.5 && $direction < 135) {
1581 1581
 			$temp_array['direction_degree'] = $direction;
1582 1582
 			$temp_array['direction_shortname'] = "ESE";
1583 1583
 			$temp_array['direction_fullname'] = "East-Southeast";
1584
-		} elseif ($direction >= 135 && $direction < 157.5){
1584
+		} elseif ($direction >= 135 && $direction < 157.5) {
1585 1585
 			$temp_array['direction_degree'] = $direction;
1586 1586
 			$temp_array['direction_shortname'] = "SE";
1587 1587
 			$temp_array['direction_fullname'] = "Southeast";
1588
-		} elseif ($direction >= 157.5 && $direction < 180){
1588
+		} elseif ($direction >= 157.5 && $direction < 180) {
1589 1589
 			$temp_array['direction_degree'] = $direction;
1590 1590
 			$temp_array['direction_shortname'] = "SSE";
1591 1591
 			$temp_array['direction_fullname'] = "South-Southeast";
1592
-		} elseif ($direction >= 180 && $direction < 202.5){
1592
+		} elseif ($direction >= 180 && $direction < 202.5) {
1593 1593
 			$temp_array['direction_degree'] = $direction;
1594 1594
 			$temp_array['direction_shortname'] = "S";
1595 1595
 			$temp_array['direction_fullname'] = "South";
1596
-		} elseif ($direction >= 202.5 && $direction < 225){
1596
+		} elseif ($direction >= 202.5 && $direction < 225) {
1597 1597
 			$temp_array['direction_degree'] = $direction;
1598 1598
 			$temp_array['direction_shortname'] = "SSW";
1599 1599
 			$temp_array['direction_fullname'] = "South-Southwest";
1600
-		} elseif ($direction >= 225 && $direction < 247.5){
1600
+		} elseif ($direction >= 225 && $direction < 247.5) {
1601 1601
 			$temp_array['direction_degree'] = $direction;
1602 1602
 			$temp_array['direction_shortname'] = "SW";
1603 1603
 			$temp_array['direction_fullname'] = "Southwest";
1604
-		} elseif ($direction >= 247.5 && $direction < 270){
1604
+		} elseif ($direction >= 247.5 && $direction < 270) {
1605 1605
 			$temp_array['direction_degree'] = $direction;
1606 1606
 			$temp_array['direction_shortname'] = "WSW";
1607 1607
 			$temp_array['direction_fullname'] = "West-Southwest";
1608
-		} elseif ($direction >= 270 && $direction < 292.5){
1608
+		} elseif ($direction >= 270 && $direction < 292.5) {
1609 1609
 			$temp_array['direction_degree'] = $direction;
1610 1610
 			$temp_array['direction_shortname'] = "W";
1611 1611
 			$temp_array['direction_fullname'] = "West";
1612
-		} elseif ($direction >= 292.5 && $direction < 315){
1612
+		} elseif ($direction >= 292.5 && $direction < 315) {
1613 1613
 			$temp_array['direction_degree'] = $direction;
1614 1614
 			$temp_array['direction_shortname'] = "WNW";
1615 1615
 			$temp_array['direction_fullname'] = "West-Northwest";
1616
-		} elseif ($direction >= 315 && $direction < 337.5){
1616
+		} elseif ($direction >= 315 && $direction < 337.5) {
1617 1617
 			$temp_array['direction_degree'] = $direction;
1618 1618
 			$temp_array['direction_shortname'] = "NW";
1619 1619
 			$temp_array['direction_fullname'] = "Northwest";
1620
-		} elseif ($direction >= 337.5 && $direction < 360){
1620
+		} elseif ($direction >= 337.5 && $direction < 360) {
1621 1621
 			$temp_array['direction_degree'] = $direction;
1622 1622
 			$temp_array['direction_shortname'] = "NNW";
1623 1623
 			$temp_array['direction_fullname'] = "North-Northwest";
@@ -1634,11 +1634,11 @@  discard block
 block discarded – undo
1634 1634
 	* @param Float $longitude longitute of the flight
1635 1635
 	* @return String the countrie
1636 1636
 	*/
1637
-	public function getCountryFromLatitudeLongitude($latitude,$longitude)
1637
+	public function getCountryFromLatitudeLongitude($latitude, $longitude)
1638 1638
 	{
1639 1639
 		global $globalDBdriver, $globalDebug;
1640
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1641
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1640
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1641
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1642 1642
 	
1643 1643
 		$Connection = new Connection($this->db);
1644 1644
 		if (!$Connection->tableExists('countries')) return '';
@@ -1678,7 +1678,7 @@  discard block
 block discarded – undo
1678 1678
 	public function getCountryFromISO2($iso2)
1679 1679
 	{
1680 1680
 		global $globalDBdriver, $globalDebug;
1681
-		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
1681
+		$iso2 = filter_var($iso2, FILTER_SANITIZE_STRING);
1682 1682
 	
1683 1683
 		$Connection = new Connection($this->db);
1684 1684
 		if (!$Connection->tableExists('countries')) return '';
@@ -1726,7 +1726,7 @@  discard block
 block discarded – undo
1726 1726
 		
1727 1727
 		$bitly_data = json_decode($bitly_data);
1728 1728
 		$bitly_url = '';
1729
-		if ($bitly_data->status_txt = "OK"){
1729
+		if ($bitly_data->status_txt = "OK") {
1730 1730
 			$bitly_url = $bitly_data->data->url;
1731 1731
 		}
1732 1732
 
@@ -1740,11 +1740,11 @@  discard block
 block discarded – undo
1740 1740
 	* @return Array the vessel type list
1741 1741
 	*
1742 1742
 	*/
1743
-	public function countAllMarineTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
1743
+	public function countAllMarineTypes($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
1744 1744
 	{
1745 1745
 		global $globalDBdriver;
1746
-		$filter_query = $this->getFilter($filters,true,true);
1747
-		$query  = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count 
1746
+		$filter_query = $this->getFilter($filters, true, true);
1747
+		$query = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count 
1748 1748
 		    FROM marine_output ".$filter_query." marine_output.type  <> ''";
1749 1749
 		if ($olderthanmonths > 0) {
1750 1750
 			if ($globalDBdriver == 'mysql') {
@@ -1764,28 +1764,28 @@  discard block
 block discarded – undo
1764 1764
 		if ($year != '') {
1765 1765
 			if ($globalDBdriver == 'mysql') {
1766 1766
 				$query .= " AND YEAR(marine_output.date) = :year";
1767
-				$query_values = array_merge($query_values,array(':year' => $year));
1767
+				$query_values = array_merge($query_values, array(':year' => $year));
1768 1768
 			} else {
1769 1769
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
1770
-				$query_values = array_merge($query_values,array(':year' => $year));
1770
+				$query_values = array_merge($query_values, array(':year' => $year));
1771 1771
 			}
1772 1772
 		}
1773 1773
 		if ($month != '') {
1774 1774
 			if ($globalDBdriver == 'mysql') {
1775 1775
 				$query .= " AND MONTH(marine_output.date) = :month";
1776
-				$query_values = array_merge($query_values,array(':month' => $month));
1776
+				$query_values = array_merge($query_values, array(':month' => $month));
1777 1777
 			} else {
1778 1778
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
1779
-				$query_values = array_merge($query_values,array(':month' => $month));
1779
+				$query_values = array_merge($query_values, array(':month' => $month));
1780 1780
 			}
1781 1781
 		}
1782 1782
 		if ($day != '') {
1783 1783
 			if ($globalDBdriver == 'mysql') {
1784 1784
 				$query .= " AND DAY(marine_output.date) = :day";
1785
-				$query_values = array_merge($query_values,array(':day' => $day));
1785
+				$query_values = array_merge($query_values, array(':day' => $day));
1786 1786
 			} else {
1787 1787
 				$query .= " AND EXTRACT(DAY FROM marine_output.date) = :day";
1788
-				$query_values = array_merge($query_values,array(':day' => $day));
1788
+				$query_values = array_merge($query_values, array(':day' => $day));
1789 1789
 			}
1790 1790
 		}
1791 1791
 		$query .= " GROUP BY marine_output.type ORDER BY marine_type_count DESC";
@@ -1794,7 +1794,7 @@  discard block
 block discarded – undo
1794 1794
 		$sth->execute($query_values);
1795 1795
 		$marine_array = array();
1796 1796
 		$temp_array = array();
1797
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1797
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1798 1798
 		{
1799 1799
 			$temp_array['marine_type'] = $row['marine_type'];
1800 1800
 			$temp_array['marine_type_count'] = $row['marine_type_count'];
@@ -1809,13 +1809,13 @@  discard block
 block discarded – undo
1809 1809
 	* @return Array the tracker information
1810 1810
 	*
1811 1811
 	*/
1812
-	public function searchMarineData($q = '', $callsign = '',$mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '',$filters = array())
1812
+	public function searchMarineData($q = '', $callsign = '', $mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array())
1813 1813
 	{
1814 1814
 		global $globalTimezone, $globalDBdriver;
1815 1815
 		date_default_timezone_set('UTC');
1816 1816
 		$query_values = array();
1817 1817
 		$additional_query = '';
1818
-		$filter_query = $this->getFilter($filters,true,true);
1818
+		$filter_query = $this->getFilter($filters, true, true);
1819 1819
 		if ($q != "")
1820 1820
 		{
1821 1821
 			if (!is_string($q))
@@ -1823,8 +1823,8 @@  discard block
 block discarded – undo
1823 1823
 				return false;
1824 1824
 			} else {
1825 1825
 				$q_array = explode(" ", $q);
1826
-				foreach ($q_array as $q_item){
1827
-					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
1826
+				foreach ($q_array as $q_item) {
1827
+					$q_item = filter_var($q_item, FILTER_SANITIZE_STRING);
1828 1828
 					$additional_query .= " AND (";
1829 1829
 					if (is_int($q_item)) $additional_query .= "(marine_output.marine_id = '".$q_item."') OR ";
1830 1830
 					if (is_int($q_item)) $additional_query .= "(marine_output.mmsi = '".$q_item."') OR ";
@@ -1836,42 +1836,42 @@  discard block
 block discarded – undo
1836 1836
 		}
1837 1837
 		if ($callsign != "")
1838 1838
 		{
1839
-			$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
1839
+			$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
1840 1840
 			if (!is_string($callsign))
1841 1841
 			{
1842 1842
 				return false;
1843 1843
 			} else {
1844 1844
 				$additional_query .= " AND marine_output.ident = :callsign";
1845
-				$query_values = array_merge($query_values,array(':callsign' => $callsign));
1845
+				$query_values = array_merge($query_values, array(':callsign' => $callsign));
1846 1846
 			}
1847 1847
 		}
1848 1848
 		if ($mmsi != "")
1849 1849
 		{
1850
-			$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING);
1850
+			$mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING);
1851 1851
 			if (!is_numeric($mmsi))
1852 1852
 			{
1853 1853
 				return false;
1854 1854
 			} else {
1855 1855
 				$additional_query .= " AND marine_output.mmsi = :mmsi";
1856
-				$query_values = array_merge($query_values,array(':mmsi' => $mmsi));
1856
+				$query_values = array_merge($query_values, array(':mmsi' => $mmsi));
1857 1857
 			}
1858 1858
 		}
1859 1859
 		if ($imo != "")
1860 1860
 		{
1861
-			$imo = filter_var($imo,FILTER_SANITIZE_STRING);
1861
+			$imo = filter_var($imo, FILTER_SANITIZE_STRING);
1862 1862
 			if (!is_numeric($imo))
1863 1863
 			{
1864 1864
 				return false;
1865 1865
 			} else {
1866 1866
 				$additional_query .= " AND marine_output.imo = :imo";
1867
-				$query_values = array_merge($query_values,array(':imo' => $imo));
1867
+				$query_values = array_merge($query_values, array(':imo' => $imo));
1868 1868
 			}
1869 1869
 		}
1870 1870
 		if ($date_posted != "")
1871 1871
 		{
1872 1872
 			$date_array = explode(",", $date_posted);
1873
-			$date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
1874
-			$date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
1873
+			$date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING);
1874
+			$date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING);
1875 1875
 			if ($globalTimezone != '') {
1876 1876
 				date_default_timezone_set($globalTimezone);
1877 1877
 				$datetime = new DateTime();
@@ -1898,8 +1898,8 @@  discard block
 block discarded – undo
1898 1898
 		if ($limit != "")
1899 1899
 		{
1900 1900
 			$limit_array = explode(",", $limit);
1901
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1902
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1901
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1902
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1903 1903
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1904 1904
 			{
1905 1905
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
@@ -1917,28 +1917,28 @@  discard block
 block discarded – undo
1917 1917
 			}
1918 1918
 		}
1919 1919
 		if ($origLat != "" && $origLon != "" && $dist != "") {
1920
-			$dist = number_format($dist*0.621371,2,'.',''); // convert km to mile
1920
+			$dist = number_format($dist*0.621371, 2, '.', ''); // convert km to mile
1921 1921
 			if ($globalDBdriver == 'mysql') {
1922
-				$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 
1922
+				$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 
1923 1923
 				    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)) 
1924 1924
 				    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;
1925 1925
 			} else {
1926
-				$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 
1926
+				$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 
1927 1927
 				    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)) 
1928 1928
 				    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;
1929 1929
 			}
1930 1930
 		} else {
1931
-			$query  = "SELECT marine_output.* FROM marine_output".$filter_query." marine_output.ident <> '' 
1931
+			$query = "SELECT marine_output.* FROM marine_output".$filter_query." marine_output.ident <> '' 
1932 1932
 			    ".$additional_query."
1933 1933
 			    ".$orderby_query;
1934 1934
 		}
1935
-		$marine_array = $this->getDataFromDB($query, $query_values,$limit_query);
1935
+		$marine_array = $this->getDataFromDB($query, $query_values, $limit_query);
1936 1936
 		return $marine_array;
1937 1937
 	}
1938 1938
 
1939 1939
 	public function getOrderBy()
1940 1940
 	{
1941
-		$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"));
1941
+		$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"));
1942 1942
 		
1943 1943
 		return $orderby;
1944 1944
 		
Please login to merge, or discard this patch.