Completed
Push — master ( 04cf69...7bb360 )
by Yannick
26:49
created
require/class.Marine.php 2 patches
Spacing   +155 added lines, -155 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 require_once(dirname(__FILE__).'/class.Image.php');
3 3
 $global_query = "SELECT marine_output.* FROM marine_output";
4 4
 
5
-class Marine{
5
+class Marine {
6 6
 	public $db;
7 7
 	
8 8
 	public function __construct($dbc = null) {
@@ -16,33 +16,33 @@  discard block
 block discarded – undo
16 16
 	* @return Array the SQL part
17 17
 	*/
18 18
 	
19
-	public function getFilter($filter = array(),$where = false,$and = false) {
19
+	public function getFilter($filter = array(), $where = false, $and = false) {
20 20
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
21 21
 		$filters = array();
22 22
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
23 23
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
24 24
 				$filters = $globalStatsFilters[$globalFilterName];
25 25
 			} else {
26
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
26
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
27 27
 			}
28 28
 		}
29 29
 		if (isset($filter[0]['source'])) {
30
-			$filters = array_merge($filters,$filter);
30
+			$filters = array_merge($filters, $filter);
31 31
 		}
32
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
32
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
33 33
 		$filter_query_join = '';
34 34
 		$filter_query_where = '';
35
-		foreach($filters as $flt) {
35
+		foreach ($filters as $flt) {
36 36
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
37 37
 				if (isset($flt['source'])) {
38
-					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id";
38
+					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id";
39 39
 				} else {
40
-					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id";
40
+					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id";
41 41
 				}
42 42
 			}
43 43
 		}
44 44
 		if (isset($filter['source']) && !empty($filter['source'])) {
45
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
45
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
46 46
 		}
47 47
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
48 48
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
72 72
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
73 73
 		if ($filter_query_where != '') {
74
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
74
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
75 75
 		}
76 76
 		$filter_query = $filter_query_join.$filter_query_where;
77 77
 		return $filter_query;
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 	* @return Array the spotter information
87 87
 	*
88 88
 	*/
89
-	public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false)
89
+	public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false)
90 90
 	{
91 91
 		date_default_timezone_set('UTC');
92 92
 		if (!is_string($query))
@@ -106,13 +106,13 @@  discard block
 block discarded – undo
106 106
 			$sth = $this->db->prepare($query.$limitQuery);
107 107
 			$sth->execute($params);
108 108
 		} catch (PDOException $e) {
109
-			printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery);
109
+			printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery);
110 110
 			exit();
111 111
 		}
112 112
 		
113 113
 		$num_rows = 0;
114 114
 		$spotter_array = array();
115
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
115
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
116 116
 		{
117 117
 			$num_rows++;
118 118
 			$temp_array = array();
@@ -144,10 +144,10 @@  discard block
 block discarded – undo
144 144
 			}
145 145
 			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];
146 146
 
147
-			if($temp_array['mmsi'] != "")
147
+			if ($temp_array['mmsi'] != "")
148 148
 			{
149 149
 				$Image = new Image($this->db);
150
-				if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']);
150
+				if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'], '', $temp_array['ident']);
151 151
 				else $image_array = $Image->getMarineImage($temp_array['mmsi']);
152 152
 				unset($Image);
153 153
 				if (count($image_array) > 0) {
@@ -183,17 +183,17 @@  discard block
 block discarded – undo
183 183
 				{
184 184
 					$temp_array['date'] = "about ".$dateArray['hours']." hours ago";
185 185
 				} else {
186
-					$temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC"));
186
+					$temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC"));
187 187
 				}
188 188
 				$temp_array['date_minutes_past'] = $dateArray['minutes'];
189
-				$temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC"));
190
-				$temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC"));
189
+				$temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC"));
190
+				$temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC"));
191 191
 				$temp_array['date_unix'] = strtotime($row['date']." UTC");
192 192
 				if (isset($row['last_seen']) && $row['last_seen'] != '') {
193 193
 					if (strtotime($row['last_seen']) > strtotime($row['date'])) {
194 194
 						$temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']);
195
-						$temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC"));
196
-						$temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC"));
195
+						$temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC"));
196
+						$temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC"));
197 197
 						$temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC");
198 198
 					}
199 199
 				}
@@ -226,8 +226,8 @@  discard block
 block discarded – undo
226 226
 		if ($limit != "")
227 227
 		{
228 228
 			$limit_array = explode(",", $limit);
229
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
230
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
229
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
230
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
231 231
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
232 232
 			{
233 233
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
@@ -241,8 +241,8 @@  discard block
 block discarded – undo
241 241
 		} else {
242 242
 			$orderby_query = " ORDER BY marine_output.date DESC";
243 243
 		}
244
-		$query  = $global_query.$filter_query." ".$orderby_query;
245
-		$spotter_array = $this->getDataFromDB($query, array(),$limit_query,true);
244
+		$query = $global_query.$filter_query." ".$orderby_query;
245
+		$spotter_array = $this->getDataFromDB($query, array(), $limit_query, true);
246 246
 		return $spotter_array;
247 247
 	}
248 248
     
@@ -260,8 +260,8 @@  discard block
 block discarded – undo
260 260
 		if ($id == '') return array();
261 261
 		$additional_query = "marine_output.fammarine_id = :id";
262 262
 		$query_values = array(':id' => $id);
263
-		$query  = $global_query." WHERE ".$additional_query." ";
264
-		$spotter_array = $this->getDataFromDB($query,$query_values);
263
+		$query = $global_query." WHERE ".$additional_query." ";
264
+		$spotter_array = $this->getDataFromDB($query, $query_values);
265 265
 		return $spotter_array;
266 266
 	}
267 267
 
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 		$query_values = array();
281 281
 		$limit_query = '';
282 282
 		$additional_query = '';
283
-		$filter_query = $this->getFilter($filter,true,true);
283
+		$filter_query = $this->getFilter($filter, true, true);
284 284
 		if ($ident != "")
285 285
 		{
286 286
 			if (!is_string($ident))
@@ -296,8 +296,8 @@  discard block
 block discarded – undo
296 296
 		{
297 297
 			$limit_array = explode(",", $limit);
298 298
 			
299
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
300
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
299
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
300
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
301 301
 			
302 302
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
303 303
 			{
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
 		return $spotter_array;
322 322
 	}
323 323
 	
324
-	public function getMarineDataByDate($date = '', $limit = '', $sort = '',$filter = array())
324
+	public function getMarineDataByDate($date = '', $limit = '', $sort = '', $filter = array())
325 325
 	{
326 326
 		global $global_query, $globalTimezone, $globalDBdriver;
327 327
 		
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
 		$limit_query = '';
330 330
 		$additional_query = '';
331 331
 
332
-		$filter_query = $this->getFilter($filter,true,true);
332
+		$filter_query = $this->getFilter($filter, true, true);
333 333
 		
334 334
 		if ($date != "")
335 335
 		{
@@ -355,8 +355,8 @@  discard block
 block discarded – undo
355 355
 		{
356 356
 			$limit_array = explode(",", $limit);
357 357
 			
358
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
359
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
358
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
359
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
360 360
 			
361 361
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
362 362
 			{
@@ -387,11 +387,11 @@  discard block
 block discarded – undo
387 387
 	* @return Array list of source name
388 388
 	*
389 389
 	*/
390
-	public function getAllSourceName($type = '',$filters = array())
390
+	public function getAllSourceName($type = '', $filters = array())
391 391
 	{
392
-		$filter_query = $this->getFilter($filters,true,true);
392
+		$filter_query = $this->getFilter($filters, true, true);
393 393
 		$query_values = array();
394
-		$query  = "SELECT DISTINCT marine_output.source_name 
394
+		$query = "SELECT DISTINCT marine_output.source_name 
395 395
 				FROM marine_output".$filter_query." marine_output.source_name <> ''";
396 396
 		if ($type != '') {
397 397
 			$query_values = array(':type' => $type);
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
 		$source_array = array();
407 407
 		$temp_array = array();
408 408
 		
409
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
409
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
410 410
 		{
411 411
 			$temp_array['source_name'] = $row['source_name'];
412 412
 			$source_array[] = $temp_array;
@@ -423,8 +423,8 @@  discard block
 block discarded – undo
423 423
 	*/
424 424
 	public function getAllIdents($filters = array())
425 425
 	{
426
-		$filter_query = $this->getFilter($filters,true,true);
427
-		$query  = "SELECT DISTINCT marine_output.ident
426
+		$filter_query = $this->getFilter($filters, true, true);
427
+		$query = "SELECT DISTINCT marine_output.ident
428 428
 								FROM marine_output".$filter_query." marine_output.ident <> '' 
429 429
 								ORDER BY marine_output.date ASC LIMIT 700 OFFSET 0";
430 430
 
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
 		$ident_array = array();
435 435
 		$temp_array = array();
436 436
 		
437
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
437
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
438 438
 		{
439 439
 			$temp_array['ident'] = $row['ident'];
440 440
 			$ident_array[] = $temp_array;
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
 	*/
452 452
 	public function getIdentity($mmsi)
453 453
 	{
454
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
454
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT);
455 455
 		$query  = "SELECT * FROM marine_identity WHERE mmsi = :mmsi LIMIT 1";
456 456
 		$sth = $this->db->prepare($query);
457 457
 		$sth->execute(array(':mmsi' => $mmsi));
@@ -476,12 +476,12 @@  discard block
 block discarded – undo
476 476
 		} else $offset = '+00:00';
477 477
 
478 478
 		if ($globalDBdriver == 'mysql') {
479
-			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date
479
+			$query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date
480 480
 								FROM marine_output
481 481
 								WHERE marine_output.date <> '' 
482 482
 								ORDER BY marine_output.date ASC LIMIT 0,200";
483 483
 		} else {
484
-			$query  = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
484
+			$query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
485 485
 								FROM marine_output
486 486
 								WHERE marine_output.date <> '' 
487 487
 								ORDER BY marine_output.date ASC LIMIT 0,200";
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
 		$date_array = array();
494 494
 		$temp_array = array();
495 495
 		
496
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
496
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
497 497
 		{
498 498
 			$temp_array['date'] = $row['date'];
499 499
 
@@ -512,11 +512,11 @@  discard block
 block discarded – undo
512 512
 	* @return String success or false
513 513
 	*
514 514
 	*/	
515
-	public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL)
515
+	public function updateIdentMarineData($fammarine_id = '', $ident = '', $fromsource = NULL)
516 516
 	{
517 517
 
518 518
 		$query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id';
519
-                $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident);
519
+                $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident);
520 520
 
521 521
 		try {
522 522
 			$sth = $this->db->prepare($query);
@@ -538,11 +538,11 @@  discard block
 block discarded – undo
538 538
 	* @return String success or false
539 539
 	*
540 540
 	*/	
541
-	public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '')
541
+	public function updateStatusMarineData($fammarine_id = '', $status_id = '', $status = '')
542 542
 	{
543 543
 
544 544
 		$query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id';
545
-                $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id);
545
+                $query_values = array(':fammarine_id' => $fammarine_id, ':status' => $status, ':status_id' => $status_id);
546 546
 
547 547
 		try {
548 548
 			$sth = $this->db->prepare($query);
@@ -565,7 +565,7 @@  discard block
 block discarded – undo
565 565
 	public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '')
566 566
 	{
567 567
 		$query = 'UPDATE marine_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE fammarine_id = :fammarine_id';
568
-                $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident);
568
+                $query_values = array(':fammarine_id' => $fammarine_id, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident);
569 569
 
570 570
 		try {
571 571
 			$sth = $this->db->prepare($query);
@@ -603,7 +603,7 @@  discard block
 block discarded – undo
603 603
 	* @param String $verticalrate vertival rate of flight
604 604
 	* @return String success or false
605 605
 	*/
606
-	public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$format_source = '', $source_name = '')
606
+	public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $format_source = '', $source_name = '')
607 607
 	{
608 608
 		global $globalURL, $globalMarineImageFetch;
609 609
 		
@@ -670,31 +670,31 @@  discard block
 block discarded – undo
670 670
 		}
671 671
 
672 672
     
673
-		if ($date == "" || strtotime($date) < time()-20*60)
673
+		if ($date == "" || strtotime($date) < time() - 20*60)
674 674
 		{
675 675
 			$date = date("Y-m-d H:i:s", time());
676 676
 		}
677 677
 
678
-		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
679
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
680
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
681
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
682
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
683
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
684
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
685
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING);
686
-		$type = filter_var($type,FILTER_SANITIZE_STRING);
687
-		$status = filter_var($status,FILTER_SANITIZE_STRING);
688
-		$imo = filter_var($imo,FILTER_SANITIZE_STRING);
689
-		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
690
-		$arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING);
691
-		$arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING);
678
+		$fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING);
679
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
680
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
681
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
682
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
683
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
684
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
685
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING);
686
+		$type = filter_var($type, FILTER_SANITIZE_STRING);
687
+		$status = filter_var($status, FILTER_SANITIZE_STRING);
688
+		$imo = filter_var($imo, FILTER_SANITIZE_STRING);
689
+		$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
690
+		$arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING);
691
+		$arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING);
692 692
 	
693 693
 		if (isset($globalMarineImageFetch) && $globalMarineImageFetch === TRUE) {
694 694
 			$Image = new Image($this->db);
695
-			$image_array = $Image->getMarineImage($mmsi,$imo,$ident);
695
+			$image_array = $Image->getMarineImage($mmsi, $imo, $ident);
696 696
 			if (!isset($image_array[0]['mmsi'])) {
697
-				$Image->addMarineImage($mmsi,$imo,$ident);
697
+				$Image->addMarineImage($mmsi, $imo, $ident);
698 698
 			}
699 699
 			unset($Image);
700 700
 		}
@@ -706,10 +706,10 @@  discard block
 block discarded – undo
706 706
                 if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
707 707
                 if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
708 708
                 if ($arrival_date == '') $arrival_date = NULL;
709
-		$query  = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) 
709
+		$query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) 
710 710
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)";
711 711
 
712
-		$query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':mmsi' => $mmsi,':type' => $type,':status' => $status,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date);
712
+		$query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':speed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':mmsi' => $mmsi, ':type' => $type, ':status' => $status, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date);
713 713
 		try {
714 714
 		        
715 715
 			$sth = $this->db->prepare($query);
@@ -734,13 +734,13 @@  discard block
 block discarded – undo
734 734
 	{
735 735
 		global $globalDBdriver, $globalTimezone;
736 736
 		if ($globalDBdriver == 'mysql') {
737
-			$query  = "SELECT marine_output.ident FROM marine_output 
737
+			$query = "SELECT marine_output.ident FROM marine_output 
738 738
 								WHERE marine_output.ident = :ident 
739 739
 								AND marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
740 740
 								AND marine_output.date < UTC_TIMESTAMP()";
741 741
 			$query_data = array(':ident' => $ident);
742 742
 		} else {
743
-			$query  = "SELECT marine_output.ident FROM marine_output 
743
+			$query = "SELECT marine_output.ident FROM marine_output 
744 744
 								WHERE marine_output.ident = :ident 
745 745
 								AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
746 746
 								AND marine_output.date < now() AT TIME ZONE 'UTC'";
@@ -749,8 +749,8 @@  discard block
 block discarded – undo
749 749
 		
750 750
 		$sth = $this->db->prepare($query);
751 751
 		$sth->execute($query_data);
752
-    		$ident_result='';
753
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
752
+    		$ident_result = '';
753
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
754 754
 		{
755 755
 			$ident_result = $row['ident'];
756 756
 		}
@@ -776,8 +776,8 @@  discard block
 block discarded – undo
776 776
 				return false;
777 777
 			} else {
778 778
 				$q_array = explode(" ", $q);
779
-				foreach ($q_array as $q_item){
780
-					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
779
+				foreach ($q_array as $q_item) {
780
+					$q_item = filter_var($q_item, FILTER_SANITIZE_STRING);
781 781
 					$additional_query .= " AND (";
782 782
 					$additional_query .= "(marine_output.ident like '%".$q_item."%')";
783 783
 					$additional_query .= ")";
@@ -785,11 +785,11 @@  discard block
 block discarded – undo
785 785
 			}
786 786
 		}
787 787
 		if ($globalDBdriver == 'mysql') {
788
-			$query  = "SELECT marine_output.* FROM marine_output 
788
+			$query = "SELECT marine_output.* FROM marine_output 
789 789
 				WHERE marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." 
790 790
 				AND marine_output.date < UTC_TIMESTAMP()";
791 791
 		} else {
792
-			$query  = "SELECT marine_output.* FROM marine_output 
792
+			$query = "SELECT marine_output.* FROM marine_output 
793 793
 				WHERE marine_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." 
794 794
 				AND marine_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
795 795
 		}
@@ -808,16 +808,16 @@  discard block
 block discarded – undo
808 808
 	*
809 809
 	*/
810 810
 
811
-	public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
811
+	public function countAllMarineOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
812 812
 	{
813 813
 		global $globalDBdriver, $globalArchive;
814 814
 		//$filter_query = $this->getFilter($filters,true,true);
815
-		$Connection= new Connection($this->db);
815
+		$Connection = new Connection($this->db);
816 816
 		if (!$Connection->tableExists('countries')) return array();
817 817
 		require_once('class.SpotterLive.php');
818 818
 		if (!isset($globalArchive) || $globalArchive !== TRUE) {
819 819
 			$MarineLive = new MarineLive();
820
-			$filter_query = $MarineLive->getFilter($filters,true,true);
820
+			$filter_query = $MarineLive->getFilter($filters, true, true);
821 821
 			$filter_query .= ' over_country IS NOT NULL';
822 822
 			if ($olderthanmonths > 0) {
823 823
 				if ($globalDBdriver == 'mysql') {
@@ -837,7 +837,7 @@  discard block
 block discarded – undo
837 837
 		} else {
838 838
 			require_once(dirname(__FILE__)."/class.MarineArchive.php");
839 839
 			$MarineArchive = new MarineArchive();
840
-			$filter_query = $MarineArchive->getFilter($filters,true,true);
840
+			$filter_query = $MarineArchive->getFilter($filters, true, true);
841 841
 			$filter_query .= ' over_country IS NOT NULL';
842 842
 			if ($olderthanmonths > 0) {
843 843
 				if ($globalDBdriver == 'mysql') {
@@ -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['flight_count'] = $row['nb'];
872 872
 			$temp_array['flight_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 flights
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);
@@ -1405,7 +1405,7 @@  discard block
 block discarded – undo
1405 1405
 	public function countAllHoursFromToday($filters = array())
1406 1406
 	{
1407 1407
 		global $globalTimezone, $globalDBdriver;
1408
-		$filter_query = $this->getFilter($filters,true,true);
1408
+		$filter_query = $this->getFilter($filters, true, true);
1409 1409
 		if ($globalTimezone != '') {
1410 1410
 			date_default_timezone_set($globalTimezone);
1411 1411
 			$datetime = new DateTime();
@@ -1413,12 +1413,12 @@  discard block
 block discarded – undo
1413 1413
 		} else $offset = '+00:00';
1414 1414
 
1415 1415
 		if ($globalDBdriver == 'mysql') {
1416
-			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1416
+			$query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1417 1417
 								FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = CURDATE()
1418 1418
 								GROUP BY hour_name 
1419 1419
 								ORDER BY hour_name ASC";
1420 1420
 		} else {
1421
-			$query  = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1421
+			$query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1422 1422
 								FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date)
1423 1423
 								GROUP BY hour_name 
1424 1424
 								ORDER BY hour_name ASC";
@@ -1430,7 +1430,7 @@  discard block
 block discarded – undo
1430 1430
 		$hour_array = array();
1431 1431
 		$temp_array = array();
1432 1432
         
1433
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1433
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1434 1434
 		{
1435 1435
 			$temp_array['hour_name'] = $row['hour_name'];
1436 1436
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1449,9 +1449,9 @@  discard block
 block discarded – undo
1449 1449
 	*/
1450 1450
 	public function getMarineIDBasedOnFamMarineID($fammarine_id)
1451 1451
 	{
1452
-		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
1452
+		$fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING);
1453 1453
 
1454
-		$query  = "SELECT marine_output.marine_id
1454
+		$query = "SELECT marine_output.marine_id
1455 1455
 				FROM marine_output 
1456 1456
 				WHERE marine_output.fammarine_id = '".$fammarine_id."'";
1457 1457
         
@@ -1459,7 +1459,7 @@  discard block
 block discarded – undo
1459 1459
 		$sth = $this->db->prepare($query);
1460 1460
 		$sth->execute();
1461 1461
 
1462
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1462
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1463 1463
 		{
1464 1464
 			return $row['marine_id'];
1465 1465
 		}
@@ -1484,23 +1484,23 @@  discard block
 block discarded – undo
1484 1484
 		}
1485 1485
 		
1486 1486
 		$current_date = date("Y-m-d H:i:s");
1487
-		$date = date("Y-m-d H:i:s",strtotime($dateString." UTC"));
1487
+		$date = date("Y-m-d H:i:s", strtotime($dateString." UTC"));
1488 1488
 		
1489 1489
 		$diff = abs(strtotime($current_date) - strtotime($date));
1490 1490
 
1491
-		$time_array['years'] = floor($diff / (365*60*60*24)); 
1491
+		$time_array['years'] = floor($diff/(365*60*60*24)); 
1492 1492
 		$years = $time_array['years'];
1493 1493
 		
1494
-		$time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
1494
+		$time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24));
1495 1495
 		$months = $time_array['months'];
1496 1496
 		
1497
-		$time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
1497
+		$time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24));
1498 1498
 		$days = $time_array['days'];
1499
-		$time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60));
1499
+		$time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60));
1500 1500
 		$hours = $time_array['hours'];
1501
-		$time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60);
1501
+		$time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60);
1502 1502
 		$minutes = $time_array['minutes'];
1503
-		$time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
1503
+		$time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
1504 1504
 		
1505 1505
 		return $time_array;
1506 1506
 	}
@@ -1523,63 +1523,63 @@  discard block
 block discarded – undo
1523 1523
 			$temp_array['direction_degree'] = $direction;
1524 1524
 			$temp_array['direction_shortname'] = "N";
1525 1525
 			$temp_array['direction_fullname'] = "North";
1526
-		} elseif ($direction >= 22.5 && $direction < 45){
1526
+		} elseif ($direction >= 22.5 && $direction < 45) {
1527 1527
 			$temp_array['direction_degree'] = $direction;
1528 1528
 			$temp_array['direction_shortname'] = "NNE";
1529 1529
 			$temp_array['direction_fullname'] = "North-Northeast";
1530
-		} elseif ($direction >= 45 && $direction < 67.5){
1530
+		} elseif ($direction >= 45 && $direction < 67.5) {
1531 1531
 			$temp_array['direction_degree'] = $direction;
1532 1532
 			$temp_array['direction_shortname'] = "NE";
1533 1533
 			$temp_array['direction_fullname'] = "Northeast";
1534
-		} elseif ($direction >= 67.5 && $direction < 90){
1534
+		} elseif ($direction >= 67.5 && $direction < 90) {
1535 1535
 			$temp_array['direction_degree'] = $direction;
1536 1536
 			$temp_array['direction_shortname'] = "ENE";
1537 1537
 			$temp_array['direction_fullname'] = "East-Northeast";
1538
-		} elseif ($direction >= 90 && $direction < 112.5){
1538
+		} elseif ($direction >= 90 && $direction < 112.5) {
1539 1539
 			$temp_array['direction_degree'] = $direction;
1540 1540
 			$temp_array['direction_shortname'] = "E";
1541 1541
 			$temp_array['direction_fullname'] = "East";
1542
-		} elseif ($direction >= 112.5 && $direction < 135){
1542
+		} elseif ($direction >= 112.5 && $direction < 135) {
1543 1543
 			$temp_array['direction_degree'] = $direction;
1544 1544
 			$temp_array['direction_shortname'] = "ESE";
1545 1545
 			$temp_array['direction_fullname'] = "East-Southeast";
1546
-		} elseif ($direction >= 135 && $direction < 157.5){
1546
+		} elseif ($direction >= 135 && $direction < 157.5) {
1547 1547
 			$temp_array['direction_degree'] = $direction;
1548 1548
 			$temp_array['direction_shortname'] = "SE";
1549 1549
 			$temp_array['direction_fullname'] = "Southeast";
1550
-		} elseif ($direction >= 157.5 && $direction < 180){
1550
+		} elseif ($direction >= 157.5 && $direction < 180) {
1551 1551
 			$temp_array['direction_degree'] = $direction;
1552 1552
 			$temp_array['direction_shortname'] = "SSE";
1553 1553
 			$temp_array['direction_fullname'] = "South-Southeast";
1554
-		} elseif ($direction >= 180 && $direction < 202.5){
1554
+		} elseif ($direction >= 180 && $direction < 202.5) {
1555 1555
 			$temp_array['direction_degree'] = $direction;
1556 1556
 			$temp_array['direction_shortname'] = "S";
1557 1557
 			$temp_array['direction_fullname'] = "South";
1558
-		} elseif ($direction >= 202.5 && $direction < 225){
1558
+		} elseif ($direction >= 202.5 && $direction < 225) {
1559 1559
 			$temp_array['direction_degree'] = $direction;
1560 1560
 			$temp_array['direction_shortname'] = "SSW";
1561 1561
 			$temp_array['direction_fullname'] = "South-Southwest";
1562
-		} elseif ($direction >= 225 && $direction < 247.5){
1562
+		} elseif ($direction >= 225 && $direction < 247.5) {
1563 1563
 			$temp_array['direction_degree'] = $direction;
1564 1564
 			$temp_array['direction_shortname'] = "SW";
1565 1565
 			$temp_array['direction_fullname'] = "Southwest";
1566
-		} elseif ($direction >= 247.5 && $direction < 270){
1566
+		} elseif ($direction >= 247.5 && $direction < 270) {
1567 1567
 			$temp_array['direction_degree'] = $direction;
1568 1568
 			$temp_array['direction_shortname'] = "WSW";
1569 1569
 			$temp_array['direction_fullname'] = "West-Southwest";
1570
-		} elseif ($direction >= 270 && $direction < 292.5){
1570
+		} elseif ($direction >= 270 && $direction < 292.5) {
1571 1571
 			$temp_array['direction_degree'] = $direction;
1572 1572
 			$temp_array['direction_shortname'] = "W";
1573 1573
 			$temp_array['direction_fullname'] = "West";
1574
-		} elseif ($direction >= 292.5 && $direction < 315){
1574
+		} elseif ($direction >= 292.5 && $direction < 315) {
1575 1575
 			$temp_array['direction_degree'] = $direction;
1576 1576
 			$temp_array['direction_shortname'] = "WNW";
1577 1577
 			$temp_array['direction_fullname'] = "West-Northwest";
1578
-		} elseif ($direction >= 315 && $direction < 337.5){
1578
+		} elseif ($direction >= 315 && $direction < 337.5) {
1579 1579
 			$temp_array['direction_degree'] = $direction;
1580 1580
 			$temp_array['direction_shortname'] = "NW";
1581 1581
 			$temp_array['direction_fullname'] = "Northwest";
1582
-		} elseif ($direction >= 337.5 && $direction < 360){
1582
+		} elseif ($direction >= 337.5 && $direction < 360) {
1583 1583
 			$temp_array['direction_degree'] = $direction;
1584 1584
 			$temp_array['direction_shortname'] = "NNW";
1585 1585
 			$temp_array['direction_fullname'] = "North-Northwest";
@@ -1596,11 +1596,11 @@  discard block
 block discarded – undo
1596 1596
 	* @param Float $longitude longitute of the flight
1597 1597
 	* @return String the countrie
1598 1598
 	*/
1599
-	public function getCountryFromLatitudeLongitude($latitude,$longitude)
1599
+	public function getCountryFromLatitudeLongitude($latitude, $longitude)
1600 1600
 	{
1601 1601
 		global $globalDBdriver, $globalDebug;
1602
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1603
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1602
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1603
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1604 1604
 	
1605 1605
 		$Connection = new Connection($this->db);
1606 1606
 		if (!$Connection->tableExists('countries')) return '';
@@ -1640,7 +1640,7 @@  discard block
 block discarded – undo
1640 1640
 	public function getCountryFromISO2($iso2)
1641 1641
 	{
1642 1642
 		global $globalDBdriver, $globalDebug;
1643
-		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
1643
+		$iso2 = filter_var($iso2, FILTER_SANITIZE_STRING);
1644 1644
 	
1645 1645
 		$Connection = new Connection($this->db);
1646 1646
 		if (!$Connection->tableExists('countries')) return '';
@@ -1688,7 +1688,7 @@  discard block
 block discarded – undo
1688 1688
 		
1689 1689
 		$bitly_data = json_decode($bitly_data);
1690 1690
 		$bitly_url = '';
1691
-		if ($bitly_data->status_txt = "OK"){
1691
+		if ($bitly_data->status_txt = "OK") {
1692 1692
 			$bitly_url = $bitly_data->data->url;
1693 1693
 		}
1694 1694
 
@@ -1698,7 +1698,7 @@  discard block
 block discarded – undo
1698 1698
 
1699 1699
 	public function getOrderBy()
1700 1700
 	{
1701
-		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_output.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_output.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_output.date DESC"),"distance_asc" => array("key" => "distance_asc","value" => "Distance - ASC","sql" => "ORDER BY distance ASC"),"distance_desc" => array("key" => "distance_desc","value" => "Distance - DESC","sql" => "ORDER BY distance DESC"));
1701
+		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_output.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_output.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_output.date DESC"), "distance_asc" => array("key" => "distance_asc", "value" => "Distance - ASC", "sql" => "ORDER BY distance ASC"), "distance_desc" => array("key" => "distance_desc", "value" => "Distance - DESC", "sql" => "ORDER BY distance DESC"));
1702 1702
 		
1703 1703
 		return $orderby;
1704 1704
 		
Please login to merge, or discard this patch.
Braces   +162 added lines, -58 removed lines patch added patch discarded remove patch
@@ -29,7 +29,9 @@  discard block
 block discarded – undo
29 29
 		if (isset($filter[0]['source'])) {
30 30
 			$filters = array_merge($filters,$filter);
31 31
 		}
32
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
32
+		if (is_array($globalFilter)) {
33
+			$filter = array_merge($filter,$globalFilter);
34
+		}
33 35
 		$filter_query_join = '';
34 36
 		$filter_query_where = '';
35 37
 		foreach($filters as $flt) {
@@ -68,8 +70,11 @@  discard block
 block discarded – undo
68 70
 				$filter_query_where .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'";
69 71
 			}
70 72
 		}
71
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
72
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
73
+		if ($filter_query_where == '' && $where) {
74
+			$filter_query_where = ' WHERE';
75
+		} elseif ($filter_query_where != '' && $and) {
76
+			$filter_query_where .= ' AND';
77
+		}
73 78
 		if ($filter_query_where != '') {
74 79
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
75 80
 		}
@@ -123,32 +128,54 @@  discard block
 block discarded – undo
123 128
 				$temp_array['spotter_id'] = $row['spotter_archive_id'];
124 129
 			} elseif (isset($row['spotter_archive_output_id'])) {
125 130
 				$temp_array['spotter_id'] = $row['spotter_archive_output_id'];
126
-			*/} 
127
-			elseif (isset($row['marineid'])) {
131
+			*/} elseif (isset($row['marineid'])) {
128 132
 				$temp_array['marine_id'] = $row['marineid'];
129 133
 			} else {
130 134
 				$temp_array['marine_id'] = '';
131 135
 			}
132
-			if (isset($row['fammarine_id'])) $temp_array['fammarine_id'] = $row['fammarine_id'];
133
-			if (isset($row['mmsi'])) $temp_array['mmsi'] = $row['mmsi'];
134
-			if (isset($row['type'])) $temp_array['type'] = $row['type'];
135
-			if (isset($row['type_id'])) $temp_array['type_id'] = $row['type_id'];
136
-			if (isset($row['ident'])) $temp_array['ident'] = $row['ident'];
137
-			if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude'];
138
-			if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude'];
139
-			if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source'];
136
+			if (isset($row['fammarine_id'])) {
137
+				$temp_array['fammarine_id'] = $row['fammarine_id'];
138
+			}
139
+			if (isset($row['mmsi'])) {
140
+				$temp_array['mmsi'] = $row['mmsi'];
141
+			}
142
+			if (isset($row['type'])) {
143
+				$temp_array['type'] = $row['type'];
144
+			}
145
+			if (isset($row['type_id'])) {
146
+				$temp_array['type_id'] = $row['type_id'];
147
+			}
148
+			if (isset($row['ident'])) {
149
+				$temp_array['ident'] = $row['ident'];
150
+			}
151
+			if (isset($row['latitude'])) {
152
+				$temp_array['latitude'] = $row['latitude'];
153
+			}
154
+			if (isset($row['longitude'])) {
155
+				$temp_array['longitude'] = $row['longitude'];
156
+			}
157
+			if (isset($row['format_source'])) {
158
+				$temp_array['format_source'] = $row['format_source'];
159
+			}
140 160
 			if (isset($row['heading'])) {
141 161
 				$temp_array['heading'] = $row['heading'];
142 162
 				$heading_direction = $this->parseDirection($row['heading']);
143
-				if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
163
+				if (isset($heading_direction[0]['direction_fullname'])) {
164
+					$temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
165
+				}
166
+			}
167
+			if (isset($row['ground_speed'])) {
168
+				$temp_array['ground_speed'] = $row['ground_speed'];
144 169
 			}
145
-			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];
146 170
 
147 171
 			if($temp_array['mmsi'] != "")
148 172
 			{
149 173
 				$Image = new Image($this->db);
150
-				if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']);
151
-				else $image_array = $Image->getMarineImage($temp_array['mmsi']);
174
+				if (isset($temp_array['ident']) && $temp_array['ident'] != '') {
175
+					$image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']);
176
+				} else {
177
+					$image_array = $Image->getMarineImage($temp_array['mmsi']);
178
+				}
152 179
 				unset($Image);
153 180
 				if (count($image_array) > 0) {
154 181
 					$temp_array['image'] = $image_array[0]['image'];
@@ -200,13 +227,21 @@  discard block
 block discarded – undo
200 227
 			}
201 228
 			
202 229
 			$fromsource = NULL;
203
-			if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name'];
204
-			if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country'];
205
-			if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance'];
230
+			if (isset($row['source_name']) && $row['source_name'] != '') {
231
+				$temp_array['source_name'] = $row['source_name'];
232
+			}
233
+			if (isset($row['over_country']) && $row['over_country'] != '') {
234
+				$temp_array['over_country'] = $row['over_country'];
235
+			}
236
+			if (isset($row['distance']) && $row['distance'] != '') {
237
+				$temp_array['distance'] = $row['distance'];
238
+			}
206 239
 			$temp_array['query_number_rows'] = $num_rows;
207 240
 			$spotter_array[] = $temp_array;
208 241
 		}
209
-		if ($num_rows == 0) return array();
242
+		if ($num_rows == 0) {
243
+			return array();
244
+		}
210 245
 		$spotter_array[0]['query_number_rows'] = $num_rows;
211 246
 		return $spotter_array;
212 247
 	}	
@@ -232,8 +267,12 @@  discard block
 block discarded – undo
232 267
 			{
233 268
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
234 269
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
235
-			} else $limit_query = "";
236
-		} else $limit_query = "";
270
+			} else {
271
+				$limit_query = "";
272
+			}
273
+		} else {
274
+			$limit_query = "";
275
+		}
237 276
 		if ($sort != "")
238 277
 		{
239 278
 			$search_orderby_array = $this->getOrderBy();
@@ -257,7 +296,9 @@  discard block
 block discarded – undo
257 296
 		global $global_query;
258 297
 		
259 298
 		date_default_timezone_set('UTC');
260
-		if ($id == '') return array();
299
+		if ($id == '') {
300
+			return array();
301
+		}
261 302
 		$additional_query = "marine_output.fammarine_id = :id";
262 303
 		$query_values = array(':id' => $id);
263 304
 		$query  = $global_query." WHERE ".$additional_query." ";
@@ -400,8 +441,11 @@  discard block
 block discarded – undo
400 441
 		$query .= " ORDER BY marine_output.source_name ASC";
401 442
 
402 443
 		$sth = $this->db->prepare($query);
403
-		if (!empty($query_values)) $sth->execute($query_values);
404
-		else $sth->execute();
444
+		if (!empty($query_values)) {
445
+			$sth->execute($query_values);
446
+		} else {
447
+			$sth->execute();
448
+		}
405 449
 
406 450
 		$source_array = array();
407 451
 		$temp_array = array();
@@ -456,8 +500,11 @@  discard block
 block discarded – undo
456 500
 		$sth = $this->db->prepare($query);
457 501
 		$sth->execute(array(':mmsi' => $mmsi));
458 502
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
459
-		if (isset($result[0])) return $result[0];
460
-		else return array();
503
+		if (isset($result[0])) {
504
+			return $result[0];
505
+		} else {
506
+			return array();
507
+		}
461 508
 	}
462 509
 
463 510
 	/*
@@ -473,7 +520,9 @@  discard block
 block discarded – undo
473 520
 			date_default_timezone_set($globalTimezone);
474 521
 			$datetime = new DateTime();
475 522
 			$offset = $datetime->format('P');
476
-		} else $offset = '+00:00';
523
+		} else {
524
+			$offset = '+00:00';
525
+		}
477 526
 
478 527
 		if ($globalDBdriver == 'mysql') {
479 528
 			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date
@@ -703,9 +752,15 @@  discard block
 block discarded – undo
703 752
             		$latitude = 0;
704 753
             		$longitude = 0;
705 754
             	}
706
-                if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
707
-                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
708
-                if ($arrival_date == '') $arrival_date = NULL;
755
+                if ($heading == '' || $Common->isInteger($heading) === false) {
756
+                	$heading = 0;
757
+                }
758
+                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) {
759
+                	$groundspeed = 0;
760
+                }
761
+                if ($arrival_date == '') {
762
+                	$arrival_date = NULL;
763
+                }
709 764
 		$query  = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) 
710 765
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)";
711 766
 
@@ -813,7 +868,9 @@  discard block
 block discarded – undo
813 868
 		global $globalDBdriver, $globalArchive;
814 869
 		//$filter_query = $this->getFilter($filters,true,true);
815 870
 		$Connection= new Connection($this->db);
816
-		if (!$Connection->tableExists('countries')) return array();
871
+		if (!$Connection->tableExists('countries')) {
872
+			return array();
873
+		}
817 874
 		require_once('class.SpotterLive.php');
818 875
 		if (!isset($globalArchive) || $globalArchive !== TRUE) {
819 876
 			$MarineLive = new MarineLive();
@@ -857,7 +914,9 @@  discard block
 block discarded – undo
857 914
 			$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb FROM countries c INNER JOIN (SELECT DISTINCT fammarine_id,over_country FROM marine_archive".$filter_query.") l ON c.iso2 = l.over_country ";
858 915
 		}
859 916
 		$query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC";
860
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
917
+		if ($limit) {
918
+			$query .= " LIMIT 10 OFFSET 0";
919
+		}
861 920
       
862 921
 		
863 922
 		$sth = $this->db->prepare($query);
@@ -892,12 +951,18 @@  discard block
 block discarded – undo
892 951
 		$query  = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count 
893 952
                     FROM marine_output".$filter_query." marine_output.ident <> ''";
894 953
 		 if ($olderthanmonths > 0) {
895
-			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
896
-			else $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
954
+			if ($globalDBdriver == 'mysql') {
955
+				$query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
956
+			} else {
957
+				$query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
958
+			}
897 959
 		}
898 960
 		if ($sincedate != '') {
899
-			if ($globalDBdriver == 'mysql') $query .= " AND marine_output.date > '".$sincedate."'";
900
-			else $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
961
+			if ($globalDBdriver == 'mysql') {
962
+				$query .= " AND marine_output.date > '".$sincedate."'";
963
+			} else {
964
+				$query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
965
+			}
901 966
 		}
902 967
 		$query_values = array();
903 968
 		if ($year != '') {
@@ -928,7 +993,9 @@  discard block
 block discarded – undo
928 993
 			}
929 994
 		}
930 995
 		$query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC";
931
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
996
+		if ($limit) {
997
+			$query .= " LIMIT 10 OFFSET 0";
998
+		}
932 999
       		
933 1000
 		$sth = $this->db->prepare($query);
934 1001
 		$sth->execute($query_values);
@@ -963,7 +1030,9 @@  discard block
 block discarded – undo
963 1030
 			date_default_timezone_set($globalTimezone);
964 1031
 			$datetime = new DateTime();
965 1032
 			$offset = $datetime->format('P');
966
-		} else $offset = '+00:00';
1033
+		} else {
1034
+			$offset = '+00:00';
1035
+		}
967 1036
 
968 1037
 		if ($globalDBdriver == 'mysql') {
969 1038
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1013,7 +1082,9 @@  discard block
 block discarded – undo
1013 1082
 			date_default_timezone_set($globalTimezone);
1014 1083
 			$datetime = new DateTime();
1015 1084
 			$offset = $datetime->format('P');
1016
-		} else $offset = '+00:00';
1085
+		} else {
1086
+			$offset = '+00:00';
1087
+		}
1017 1088
 		$filter_query = $this->getFilter($filters,true,true);
1018 1089
 		if ($globalDBdriver == 'mysql') {
1019 1090
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1059,7 +1130,9 @@  discard block
 block discarded – undo
1059 1130
 			date_default_timezone_set($globalTimezone);
1060 1131
 			$datetime = new DateTime();
1061 1132
 			$offset = $datetime->format('P');
1062
-		} else $offset = '+00:00';
1133
+		} else {
1134
+			$offset = '+00:00';
1135
+		}
1063 1136
 		$filter_query = $this->getFilter($filters,true,true);
1064 1137
 		if ($globalDBdriver == 'mysql') {
1065 1138
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1107,7 +1180,9 @@  discard block
 block discarded – undo
1107 1180
 			date_default_timezone_set($globalTimezone);
1108 1181
 			$datetime = new DateTime();
1109 1182
 			$offset = $datetime->format('P');
1110
-		} else $offset = '+00:00';
1183
+		} else {
1184
+			$offset = '+00:00';
1185
+		}
1111 1186
 
1112 1187
 		if ($globalDBdriver == 'mysql') {
1113 1188
 			$query  = "SELECT YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
@@ -1156,7 +1231,9 @@  discard block
 block discarded – undo
1156 1231
 			date_default_timezone_set($globalTimezone);
1157 1232
 			$datetime = new DateTime();
1158 1233
 			$offset = $datetime->format('P');
1159
-		} else $offset = '+00:00';
1234
+		} else {
1235
+			$offset = '+00:00';
1236
+		}
1160 1237
 		$filter_query = $this->getFilter($filters,true,true);
1161 1238
 		if ($globalDBdriver == 'mysql') {
1162 1239
 			$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
@@ -1205,7 +1282,9 @@  discard block
 block discarded – undo
1205 1282
 			date_default_timezone_set($globalTimezone);
1206 1283
 			$datetime = new DateTime();
1207 1284
 			$offset = $datetime->format('P');
1208
-		} else $offset = '+00:00';
1285
+		} else {
1286
+			$offset = '+00:00';
1287
+		}
1209 1288
 
1210 1289
 		$orderby_sql = '';
1211 1290
 		if ($orderby == "hour")
@@ -1274,7 +1353,9 @@  discard block
 block discarded – undo
1274 1353
 			date_default_timezone_set($globalTimezone);
1275 1354
 			$datetime = new DateTime($date);
1276 1355
 			$offset = $datetime->format('P');
1277
-		} else $offset = '+00:00';
1356
+		} else {
1357
+			$offset = '+00:00';
1358
+		}
1278 1359
 
1279 1360
 		if ($globalDBdriver == 'mysql') {
1280 1361
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1322,7 +1403,9 @@  discard block
 block discarded – undo
1322 1403
 			date_default_timezone_set($globalTimezone);
1323 1404
 			$datetime = new DateTime();
1324 1405
 			$offset = $datetime->format('P');
1325
-		} else $offset = '+00:00';
1406
+		} else {
1407
+			$offset = '+00:00';
1408
+		}
1326 1409
 
1327 1410
 		if ($globalDBdriver == 'mysql') {
1328 1411
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1387,8 +1470,11 @@  discard block
 block discarded – undo
1387 1470
 				$query_values = array_merge($query_values,array(':month' => $month));
1388 1471
 			}
1389 1472
 		}
1390
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1391
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1473
+		if (empty($query_values)) {
1474
+			$queryi .= $this->getFilter($filters);
1475
+		} else {
1476
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
1477
+		}
1392 1478
 		
1393 1479
 		$sth = $this->db->prepare($queryi);
1394 1480
 		$sth->execute($query_values);
@@ -1410,7 +1496,9 @@  discard block
 block discarded – undo
1410 1496
 			date_default_timezone_set($globalTimezone);
1411 1497
 			$datetime = new DateTime();
1412 1498
 			$offset = $datetime->format('P');
1413
-		} else $offset = '+00:00';
1499
+		} else {
1500
+			$offset = '+00:00';
1501
+		}
1414 1502
 
1415 1503
 		if ($globalDBdriver == 'mysql') {
1416 1504
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1514,7 +1602,9 @@  discard block
 block discarded – undo
1514 1602
 	*/
1515 1603
 	public function parseDirection($direction = 0)
1516 1604
 	{
1517
-		if ($direction == '') $direction = 0;
1605
+		if ($direction == '') {
1606
+			$direction = 0;
1607
+		}
1518 1608
 		$direction_array = array();
1519 1609
 		$temp_array = array();
1520 1610
 
@@ -1603,7 +1693,9 @@  discard block
 block discarded – undo
1603 1693
 		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1604 1694
 	
1605 1695
 		$Connection = new Connection($this->db);
1606
-		if (!$Connection->tableExists('countries')) return '';
1696
+		if (!$Connection->tableExists('countries')) {
1697
+			return '';
1698
+		}
1607 1699
 	
1608 1700
 		try {
1609 1701
 			/*
@@ -1623,9 +1715,13 @@  discard block
 block discarded – undo
1623 1715
 			$sth->closeCursor();
1624 1716
 			if (count($row) > 0) {
1625 1717
 				return $row;
1626
-			} else return '';
1718
+			} else {
1719
+				return '';
1720
+			}
1627 1721
 		} catch (PDOException $e) {
1628
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
1722
+			if (isset($globalDebug) && $globalDebug) {
1723
+				echo 'Error : '.$e->getMessage()."\n";
1724
+			}
1629 1725
 			return '';
1630 1726
 		}
1631 1727
 	
@@ -1643,7 +1739,9 @@  discard block
 block discarded – undo
1643 1739
 		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
1644 1740
 	
1645 1741
 		$Connection = new Connection($this->db);
1646
-		if (!$Connection->tableExists('countries')) return '';
1742
+		if (!$Connection->tableExists('countries')) {
1743
+			return '';
1744
+		}
1647 1745
 	
1648 1746
 		try {
1649 1747
 			$query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1";
@@ -1655,9 +1753,13 @@  discard block
 block discarded – undo
1655 1753
 			$sth->closeCursor();
1656 1754
 			if (count($row) > 0) {
1657 1755
 				return $row;
1658
-			} else return '';
1756
+			} else {
1757
+				return '';
1758
+			}
1659 1759
 		} catch (PDOException $e) {
1660
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
1760
+			if (isset($globalDebug) && $globalDebug) {
1761
+				echo 'Error : '.$e->getMessage()."\n";
1762
+			}
1661 1763
 			return '';
1662 1764
 		}
1663 1765
 	
@@ -1675,7 +1777,9 @@  discard block
 block discarded – undo
1675 1777
 	{
1676 1778
 		global $globalBitlyAccessToken;
1677 1779
 		
1678
-		if ($globalBitlyAccessToken == '') return $url;
1780
+		if ($globalBitlyAccessToken == '') {
1781
+			return $url;
1782
+		}
1679 1783
         
1680 1784
 		$google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url;
1681 1785
 		
Please login to merge, or discard this patch.