Completed
Push — master ( 4c9919...b817a3 )
by Yannick
121:29 queued 94:05
created
require/class.Marine.php 1 patch
Spacing   +172 added lines, -172 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 AND over_country <> ''";
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 <> ''";
842 842
 			if ($olderthanmonths > 0) {
843 843
 				if ($globalDBdriver == 'mysql') {
@@ -865,7 +865,7 @@  discard block
 block discarded – undo
865 865
 		$flight_array = array();
866 866
 		$temp_array = array();
867 867
         
868
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
868
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
869 869
 		{
870 870
 			$temp_array['marine_count'] = $row['nb'];
871 871
 			$temp_array['marine_country'] = $row['name'];
@@ -884,11 +884,11 @@  discard block
 block discarded – undo
884 884
 	* @return Array the callsign list
885 885
 	*
886 886
 	*/
887
-	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
887
+	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
888 888
 	{
889 889
 		global $globalDBdriver;
890
-		$filter_query = $this->getFilter($filters,true,true);
891
-		$query  = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count 
890
+		$filter_query = $this->getFilter($filters, true, true);
891
+		$query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count 
892 892
                     FROM marine_output".$filter_query." marine_output.ident <> ''";
893 893
 		 if ($olderthanmonths > 0) {
894 894
 			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
@@ -902,28 +902,28 @@  discard block
 block discarded – undo
902 902
 		if ($year != '') {
903 903
 			if ($globalDBdriver == 'mysql') {
904 904
 				$query .= " AND YEAR(marine_output.date) = :year";
905
-				$query_values = array_merge($query_values,array(':year' => $year));
905
+				$query_values = array_merge($query_values, array(':year' => $year));
906 906
 			} else {
907 907
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
908
-				$query_values = array_merge($query_values,array(':year' => $year));
908
+				$query_values = array_merge($query_values, array(':year' => $year));
909 909
 			}
910 910
 		}
911 911
 		if ($month != '') {
912 912
 			if ($globalDBdriver == 'mysql') {
913 913
 				$query .= " AND MONTH(marine_output.date) = :month";
914
-				$query_values = array_merge($query_values,array(':month' => $month));
914
+				$query_values = array_merge($query_values, array(':month' => $month));
915 915
 			} else {
916 916
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
917
-				$query_values = array_merge($query_values,array(':month' => $month));
917
+				$query_values = array_merge($query_values, array(':month' => $month));
918 918
 			}
919 919
 		}
920 920
 		if ($day != '') {
921 921
 			if ($globalDBdriver == 'mysql') {
922 922
 				$query .= " AND DAY(marine_output.date) = :day";
923
-				$query_values = array_merge($query_values,array(':day' => $day));
923
+				$query_values = array_merge($query_values, array(':day' => $day));
924 924
 			} else {
925 925
 				$query .= " AND EXTRACT(DAY FROM marine_output.date) = :day";
926
-				$query_values = array_merge($query_values,array(':day' => $day));
926
+				$query_values = array_merge($query_values, array(':day' => $day));
927 927
 			}
928 928
 		}
929 929
 		$query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC";
@@ -935,7 +935,7 @@  discard block
 block discarded – undo
935 935
 		$callsign_array = array();
936 936
 		$temp_array = array();
937 937
         
938
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
938
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
939 939
 		{
940 940
 			$temp_array['callsign_icao'] = $row['ident'];
941 941
 			$temp_array['airline_name'] = $row['airline_name'];
@@ -987,7 +987,7 @@  discard block
 block discarded – undo
987 987
 		$date_array = array();
988 988
 		$temp_array = array();
989 989
         
990
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
990
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
991 991
 		{
992 992
 			$temp_array['date_name'] = $row['date_name'];
993 993
 			$temp_array['date_count'] = $row['date_count'];
@@ -1013,7 +1013,7 @@  discard block
 block discarded – undo
1013 1013
 			$datetime = new DateTime();
1014 1014
 			$offset = $datetime->format('P');
1015 1015
 		} else $offset = '+00:00';
1016
-		$filter_query = $this->getFilter($filters,true,true);
1016
+		$filter_query = $this->getFilter($filters, true, true);
1017 1017
 		if ($globalDBdriver == 'mysql') {
1018 1018
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
1019 1019
 								FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)";
@@ -1034,7 +1034,7 @@  discard block
 block discarded – undo
1034 1034
 		$date_array = array();
1035 1035
 		$temp_array = array();
1036 1036
         
1037
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1037
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1038 1038
 		{
1039 1039
 			$temp_array['date_name'] = $row['date_name'];
1040 1040
 			$temp_array['date_count'] = $row['date_count'];
@@ -1059,7 +1059,7 @@  discard block
 block discarded – undo
1059 1059
 			$datetime = new DateTime();
1060 1060
 			$offset = $datetime->format('P');
1061 1061
 		} else $offset = '+00:00';
1062
-		$filter_query = $this->getFilter($filters,true,true);
1062
+		$filter_query = $this->getFilter($filters, true, true);
1063 1063
 		if ($globalDBdriver == 'mysql') {
1064 1064
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
1065 1065
 								FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)";
@@ -1080,7 +1080,7 @@  discard block
 block discarded – undo
1080 1080
 		$date_array = array();
1081 1081
 		$temp_array = array();
1082 1082
         
1083
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1083
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1084 1084
 		{
1085 1085
 			$temp_array['date_name'] = $row['date_name'];
1086 1086
 			$temp_array['date_count'] = $row['date_count'];
@@ -1127,7 +1127,7 @@  discard block
 block discarded – undo
1127 1127
 		$date_array = array();
1128 1128
 		$temp_array = array();
1129 1129
         
1130
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1130
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1131 1131
 		{
1132 1132
 			$temp_array['month_name'] = $row['month_name'];
1133 1133
 			$temp_array['year_name'] = $row['year_name'];
@@ -1156,7 +1156,7 @@  discard block
 block discarded – undo
1156 1156
 			$datetime = new DateTime();
1157 1157
 			$offset = $datetime->format('P');
1158 1158
 		} else $offset = '+00:00';
1159
-		$filter_query = $this->getFilter($filters,true,true);
1159
+		$filter_query = $this->getFilter($filters, true, true);
1160 1160
 		if ($globalDBdriver == 'mysql') {
1161 1161
 			$query  = "SELECT MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count
1162 1162
 								FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)";
@@ -1177,7 +1177,7 @@  discard block
 block discarded – undo
1177 1177
 		$date_array = array();
1178 1178
 		$temp_array = array();
1179 1179
         
1180
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1180
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1181 1181
 		{
1182 1182
 			$temp_array['year_name'] = $row['year_name'];
1183 1183
 			$temp_array['month_name'] = $row['month_name'];
@@ -1197,7 +1197,7 @@  discard block
 block discarded – undo
1197 1197
 	* @return Array the hour list
1198 1198
 	*
1199 1199
 	*/
1200
-	public function countAllHours($orderby,$filters = array())
1200
+	public function countAllHours($orderby, $filters = array())
1201 1201
 	{
1202 1202
 		global $globalTimezone, $globalDBdriver;
1203 1203
 		if ($globalTimezone != '') {
@@ -1245,7 +1245,7 @@  discard block
 block discarded – undo
1245 1245
 		$hour_array = array();
1246 1246
 		$temp_array = array();
1247 1247
         
1248
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1248
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1249 1249
 		{
1250 1250
 			$temp_array['hour_name'] = $row['hour_name'];
1251 1251
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1267,8 +1267,8 @@  discard block
 block discarded – undo
1267 1267
 	public function countAllHoursByDate($date, $filters = array())
1268 1268
 	{
1269 1269
 		global $globalTimezone, $globalDBdriver;
1270
-		$filter_query = $this->getFilter($filters,true,true);
1271
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
1270
+		$filter_query = $this->getFilter($filters, true, true);
1271
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
1272 1272
 		if ($globalTimezone != '') {
1273 1273
 			date_default_timezone_set($globalTimezone);
1274 1274
 			$datetime = new DateTime($date);
@@ -1276,12 +1276,12 @@  discard block
 block discarded – undo
1276 1276
 		} else $offset = '+00:00';
1277 1277
 
1278 1278
 		if ($globalDBdriver == 'mysql') {
1279
-			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1279
+			$query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1280 1280
 								FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = :date
1281 1281
 								GROUP BY hour_name 
1282 1282
 								ORDER BY hour_name ASC";
1283 1283
 		} else {
1284
-			$query  = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1284
+			$query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1285 1285
 								FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date
1286 1286
 								GROUP BY hour_name 
1287 1287
 								ORDER BY hour_name ASC";
@@ -1293,7 +1293,7 @@  discard block
 block discarded – undo
1293 1293
 		$hour_array = array();
1294 1294
 		$temp_array = array();
1295 1295
         
1296
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1296
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1297 1297
 		{
1298 1298
 			$temp_array['hour_name'] = $row['hour_name'];
1299 1299
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1315,8 +1315,8 @@  discard block
 block discarded – undo
1315 1315
 	public function countAllHoursByIdent($ident, $filters = array())
1316 1316
 	{
1317 1317
 		global $globalTimezone, $globalDBdriver;
1318
-		$filter_query = $this->getFilter($filters,true,true);
1319
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
1318
+		$filter_query = $this->getFilter($filters, true, true);
1319
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1320 1320
 		if ($globalTimezone != '') {
1321 1321
 			date_default_timezone_set($globalTimezone);
1322 1322
 			$datetime = new DateTime();
@@ -1324,12 +1324,12 @@  discard block
 block discarded – undo
1324 1324
 		} else $offset = '+00:00';
1325 1325
 
1326 1326
 		if ($globalDBdriver == 'mysql') {
1327
-			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1327
+			$query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1328 1328
 								FROM marine_output".$filter_query." marine_output.ident = :ident 
1329 1329
 								GROUP BY hour_name 
1330 1330
 								ORDER BY hour_name ASC";
1331 1331
 		} else {
1332
-			$query  = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1332
+			$query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1333 1333
 								FROM marine_output".$filter_query." marine_output.ident = :ident 
1334 1334
 								GROUP BY hour_name 
1335 1335
 								ORDER BY hour_name ASC";
@@ -1337,12 +1337,12 @@  discard block
 block discarded – undo
1337 1337
       
1338 1338
 		
1339 1339
 		$sth = $this->db->prepare($query);
1340
-		$sth->execute(array(':ident' => $ident,':offset' => $offset));
1340
+		$sth->execute(array(':ident' => $ident, ':offset' => $offset));
1341 1341
       
1342 1342
 		$hour_array = array();
1343 1343
 		$temp_array = array();
1344 1344
         
1345
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1345
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1346 1346
 		{
1347 1347
 			$temp_array['hour_name'] = $row['hour_name'];
1348 1348
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1361,33 +1361,33 @@  discard block
 block discarded – undo
1361 1361
 	* @return Integer the number of vessels
1362 1362
 	*
1363 1363
 	*/
1364
-	public function countOverallMarine($filters = array(),$year = '',$month = '')
1364
+	public function countOverallMarine($filters = array(), $year = '', $month = '')
1365 1365
 	{
1366 1366
 		global $globalDBdriver;
1367 1367
 		//$queryi  = "SELECT COUNT(marine_output.marine_id) AS flight_count FROM marine_output";
1368
-		$queryi  = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output";
1368
+		$queryi = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output";
1369 1369
 		$query_values = array();
1370 1370
 		$query = '';
1371 1371
 		if ($year != '') {
1372 1372
 			if ($globalDBdriver == 'mysql') {
1373 1373
 				$query .= " AND YEAR(marine_output.date) = :year";
1374
-				$query_values = array_merge($query_values,array(':year' => $year));
1374
+				$query_values = array_merge($query_values, array(':year' => $year));
1375 1375
 			} else {
1376 1376
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
1377
-				$query_values = array_merge($query_values,array(':year' => $year));
1377
+				$query_values = array_merge($query_values, array(':year' => $year));
1378 1378
 			}
1379 1379
 		}
1380 1380
 		if ($month != '') {
1381 1381
 			if ($globalDBdriver == 'mysql') {
1382 1382
 				$query .= " AND MONTH(marine_output.date) = :month";
1383
-				$query_values = array_merge($query_values,array(':month' => $month));
1383
+				$query_values = array_merge($query_values, array(':month' => $month));
1384 1384
 			} else {
1385 1385
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
1386
-				$query_values = array_merge($query_values,array(':month' => $month));
1386
+				$query_values = array_merge($query_values, array(':month' => $month));
1387 1387
 			}
1388 1388
 		}
1389 1389
 		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1390
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1390
+		else $queryi .= $this->getFilter($filters, true, true).substr($query, 4);
1391 1391
 		
1392 1392
 		$sth = $this->db->prepare($queryi);
1393 1393
 		$sth->execute($query_values);
@@ -1400,32 +1400,32 @@  discard block
 block discarded – undo
1400 1400
 	* @return Integer the number of vessels
1401 1401
 	*
1402 1402
 	*/
1403
-	public function countOverallMarineTypes($filters = array(),$year = '',$month = '')
1403
+	public function countOverallMarineTypes($filters = array(), $year = '', $month = '')
1404 1404
 	{
1405 1405
 		global $globalDBdriver;
1406
-		$queryi  = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output";
1406
+		$queryi = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output";
1407 1407
 		$query_values = array();
1408 1408
 		$query = '';
1409 1409
 		if ($year != '') {
1410 1410
 			if ($globalDBdriver == 'mysql') {
1411 1411
 				$query .= " AND YEAR(marine_output.date) = :year";
1412
-				$query_values = array_merge($query_values,array(':year' => $year));
1412
+				$query_values = array_merge($query_values, array(':year' => $year));
1413 1413
 			} else {
1414 1414
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
1415
-				$query_values = array_merge($query_values,array(':year' => $year));
1415
+				$query_values = array_merge($query_values, array(':year' => $year));
1416 1416
 			}
1417 1417
 		}
1418 1418
 		if ($month != '') {
1419 1419
 			if ($globalDBdriver == 'mysql') {
1420 1420
 				$query .= " AND MONTH(marine_output.date) = :month";
1421
-				$query_values = array_merge($query_values,array(':month' => $month));
1421
+				$query_values = array_merge($query_values, array(':month' => $month));
1422 1422
 			} else {
1423 1423
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
1424
-				$query_values = array_merge($query_values,array(':month' => $month));
1424
+				$query_values = array_merge($query_values, array(':month' => $month));
1425 1425
 			}
1426 1426
 		}
1427 1427
 		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1428
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1428
+		else $queryi .= $this->getFilter($filters, true, true).substr($query, 4);
1429 1429
 		
1430 1430
 		$sth = $this->db->prepare($queryi);
1431 1431
 		$sth->execute($query_values);
@@ -1442,7 +1442,7 @@  discard block
 block discarded – undo
1442 1442
 	public function countAllHoursFromToday($filters = array())
1443 1443
 	{
1444 1444
 		global $globalTimezone, $globalDBdriver;
1445
-		$filter_query = $this->getFilter($filters,true,true);
1445
+		$filter_query = $this->getFilter($filters, true, true);
1446 1446
 		if ($globalTimezone != '') {
1447 1447
 			date_default_timezone_set($globalTimezone);
1448 1448
 			$datetime = new DateTime();
@@ -1450,12 +1450,12 @@  discard block
 block discarded – undo
1450 1450
 		} else $offset = '+00:00';
1451 1451
 
1452 1452
 		if ($globalDBdriver == 'mysql') {
1453
-			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1453
+			$query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1454 1454
 								FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = CURDATE()
1455 1455
 								GROUP BY hour_name 
1456 1456
 								ORDER BY hour_name ASC";
1457 1457
 		} else {
1458
-			$query  = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1458
+			$query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1459 1459
 								FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date)
1460 1460
 								GROUP BY hour_name 
1461 1461
 								ORDER BY hour_name ASC";
@@ -1467,7 +1467,7 @@  discard block
 block discarded – undo
1467 1467
 		$hour_array = array();
1468 1468
 		$temp_array = array();
1469 1469
         
1470
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1470
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1471 1471
 		{
1472 1472
 			$temp_array['hour_name'] = $row['hour_name'];
1473 1473
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1486,9 +1486,9 @@  discard block
 block discarded – undo
1486 1486
 	*/
1487 1487
 	public function getMarineIDBasedOnFamMarineID($fammarine_id)
1488 1488
 	{
1489
-		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
1489
+		$fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING);
1490 1490
 
1491
-		$query  = "SELECT marine_output.marine_id
1491
+		$query = "SELECT marine_output.marine_id
1492 1492
 				FROM marine_output 
1493 1493
 				WHERE marine_output.fammarine_id = '".$fammarine_id."'";
1494 1494
         
@@ -1496,7 +1496,7 @@  discard block
 block discarded – undo
1496 1496
 		$sth = $this->db->prepare($query);
1497 1497
 		$sth->execute();
1498 1498
 
1499
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1499
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1500 1500
 		{
1501 1501
 			return $row['marine_id'];
1502 1502
 		}
@@ -1521,23 +1521,23 @@  discard block
 block discarded – undo
1521 1521
 		}
1522 1522
 		
1523 1523
 		$current_date = date("Y-m-d H:i:s");
1524
-		$date = date("Y-m-d H:i:s",strtotime($dateString." UTC"));
1524
+		$date = date("Y-m-d H:i:s", strtotime($dateString." UTC"));
1525 1525
 		
1526 1526
 		$diff = abs(strtotime($current_date) - strtotime($date));
1527 1527
 
1528
-		$time_array['years'] = floor($diff / (365*60*60*24)); 
1528
+		$time_array['years'] = floor($diff/(365*60*60*24)); 
1529 1529
 		$years = $time_array['years'];
1530 1530
 		
1531
-		$time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
1531
+		$time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24));
1532 1532
 		$months = $time_array['months'];
1533 1533
 		
1534
-		$time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
1534
+		$time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24));
1535 1535
 		$days = $time_array['days'];
1536
-		$time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60));
1536
+		$time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60));
1537 1537
 		$hours = $time_array['hours'];
1538
-		$time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60);
1538
+		$time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60);
1539 1539
 		$minutes = $time_array['minutes'];
1540
-		$time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
1540
+		$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 1541
 		
1542 1542
 		return $time_array;
1543 1543
 	}
@@ -1560,63 +1560,63 @@  discard block
 block discarded – undo
1560 1560
 			$temp_array['direction_degree'] = $direction;
1561 1561
 			$temp_array['direction_shortname'] = "N";
1562 1562
 			$temp_array['direction_fullname'] = "North";
1563
-		} elseif ($direction >= 22.5 && $direction < 45){
1563
+		} elseif ($direction >= 22.5 && $direction < 45) {
1564 1564
 			$temp_array['direction_degree'] = $direction;
1565 1565
 			$temp_array['direction_shortname'] = "NNE";
1566 1566
 			$temp_array['direction_fullname'] = "North-Northeast";
1567
-		} elseif ($direction >= 45 && $direction < 67.5){
1567
+		} elseif ($direction >= 45 && $direction < 67.5) {
1568 1568
 			$temp_array['direction_degree'] = $direction;
1569 1569
 			$temp_array['direction_shortname'] = "NE";
1570 1570
 			$temp_array['direction_fullname'] = "Northeast";
1571
-		} elseif ($direction >= 67.5 && $direction < 90){
1571
+		} elseif ($direction >= 67.5 && $direction < 90) {
1572 1572
 			$temp_array['direction_degree'] = $direction;
1573 1573
 			$temp_array['direction_shortname'] = "ENE";
1574 1574
 			$temp_array['direction_fullname'] = "East-Northeast";
1575
-		} elseif ($direction >= 90 && $direction < 112.5){
1575
+		} elseif ($direction >= 90 && $direction < 112.5) {
1576 1576
 			$temp_array['direction_degree'] = $direction;
1577 1577
 			$temp_array['direction_shortname'] = "E";
1578 1578
 			$temp_array['direction_fullname'] = "East";
1579
-		} elseif ($direction >= 112.5 && $direction < 135){
1579
+		} elseif ($direction >= 112.5 && $direction < 135) {
1580 1580
 			$temp_array['direction_degree'] = $direction;
1581 1581
 			$temp_array['direction_shortname'] = "ESE";
1582 1582
 			$temp_array['direction_fullname'] = "East-Southeast";
1583
-		} elseif ($direction >= 135 && $direction < 157.5){
1583
+		} elseif ($direction >= 135 && $direction < 157.5) {
1584 1584
 			$temp_array['direction_degree'] = $direction;
1585 1585
 			$temp_array['direction_shortname'] = "SE";
1586 1586
 			$temp_array['direction_fullname'] = "Southeast";
1587
-		} elseif ($direction >= 157.5 && $direction < 180){
1587
+		} elseif ($direction >= 157.5 && $direction < 180) {
1588 1588
 			$temp_array['direction_degree'] = $direction;
1589 1589
 			$temp_array['direction_shortname'] = "SSE";
1590 1590
 			$temp_array['direction_fullname'] = "South-Southeast";
1591
-		} elseif ($direction >= 180 && $direction < 202.5){
1591
+		} elseif ($direction >= 180 && $direction < 202.5) {
1592 1592
 			$temp_array['direction_degree'] = $direction;
1593 1593
 			$temp_array['direction_shortname'] = "S";
1594 1594
 			$temp_array['direction_fullname'] = "South";
1595
-		} elseif ($direction >= 202.5 && $direction < 225){
1595
+		} elseif ($direction >= 202.5 && $direction < 225) {
1596 1596
 			$temp_array['direction_degree'] = $direction;
1597 1597
 			$temp_array['direction_shortname'] = "SSW";
1598 1598
 			$temp_array['direction_fullname'] = "South-Southwest";
1599
-		} elseif ($direction >= 225 && $direction < 247.5){
1599
+		} elseif ($direction >= 225 && $direction < 247.5) {
1600 1600
 			$temp_array['direction_degree'] = $direction;
1601 1601
 			$temp_array['direction_shortname'] = "SW";
1602 1602
 			$temp_array['direction_fullname'] = "Southwest";
1603
-		} elseif ($direction >= 247.5 && $direction < 270){
1603
+		} elseif ($direction >= 247.5 && $direction < 270) {
1604 1604
 			$temp_array['direction_degree'] = $direction;
1605 1605
 			$temp_array['direction_shortname'] = "WSW";
1606 1606
 			$temp_array['direction_fullname'] = "West-Southwest";
1607
-		} elseif ($direction >= 270 && $direction < 292.5){
1607
+		} elseif ($direction >= 270 && $direction < 292.5) {
1608 1608
 			$temp_array['direction_degree'] = $direction;
1609 1609
 			$temp_array['direction_shortname'] = "W";
1610 1610
 			$temp_array['direction_fullname'] = "West";
1611
-		} elseif ($direction >= 292.5 && $direction < 315){
1611
+		} elseif ($direction >= 292.5 && $direction < 315) {
1612 1612
 			$temp_array['direction_degree'] = $direction;
1613 1613
 			$temp_array['direction_shortname'] = "WNW";
1614 1614
 			$temp_array['direction_fullname'] = "West-Northwest";
1615
-		} elseif ($direction >= 315 && $direction < 337.5){
1615
+		} elseif ($direction >= 315 && $direction < 337.5) {
1616 1616
 			$temp_array['direction_degree'] = $direction;
1617 1617
 			$temp_array['direction_shortname'] = "NW";
1618 1618
 			$temp_array['direction_fullname'] = "Northwest";
1619
-		} elseif ($direction >= 337.5 && $direction < 360){
1619
+		} elseif ($direction >= 337.5 && $direction < 360) {
1620 1620
 			$temp_array['direction_degree'] = $direction;
1621 1621
 			$temp_array['direction_shortname'] = "NNW";
1622 1622
 			$temp_array['direction_fullname'] = "North-Northwest";
@@ -1633,11 +1633,11 @@  discard block
 block discarded – undo
1633 1633
 	* @param Float $longitude longitute of the flight
1634 1634
 	* @return String the countrie
1635 1635
 	*/
1636
-	public function getCountryFromLatitudeLongitude($latitude,$longitude)
1636
+	public function getCountryFromLatitudeLongitude($latitude, $longitude)
1637 1637
 	{
1638 1638
 		global $globalDBdriver, $globalDebug;
1639
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1640
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1639
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1640
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1641 1641
 	
1642 1642
 		$Connection = new Connection($this->db);
1643 1643
 		if (!$Connection->tableExists('countries')) return '';
@@ -1677,7 +1677,7 @@  discard block
 block discarded – undo
1677 1677
 	public function getCountryFromISO2($iso2)
1678 1678
 	{
1679 1679
 		global $globalDBdriver, $globalDebug;
1680
-		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
1680
+		$iso2 = filter_var($iso2, FILTER_SANITIZE_STRING);
1681 1681
 	
1682 1682
 		$Connection = new Connection($this->db);
1683 1683
 		if (!$Connection->tableExists('countries')) return '';
@@ -1725,7 +1725,7 @@  discard block
 block discarded – undo
1725 1725
 		
1726 1726
 		$bitly_data = json_decode($bitly_data);
1727 1727
 		$bitly_url = '';
1728
-		if ($bitly_data->status_txt = "OK"){
1728
+		if ($bitly_data->status_txt = "OK") {
1729 1729
 			$bitly_url = $bitly_data->data->url;
1730 1730
 		}
1731 1731
 
@@ -1739,11 +1739,11 @@  discard block
 block discarded – undo
1739 1739
 	* @return Array the vessel type list
1740 1740
 	*
1741 1741
 	*/
1742
-	public function countAllMarineTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
1742
+	public function countAllMarineTypes($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
1743 1743
 	{
1744 1744
 		global $globalDBdriver;
1745
-		$filter_query = $this->getFilter($filters,true,true);
1746
-		$query  = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count 
1745
+		$filter_query = $this->getFilter($filters, true, true);
1746
+		$query = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count 
1747 1747
 		    FROM marine_output ".$filter_query." marine_output.type  <> ''";
1748 1748
 		if ($olderthanmonths > 0) {
1749 1749
 			if ($globalDBdriver == 'mysql') {
@@ -1763,28 +1763,28 @@  discard block
 block discarded – undo
1763 1763
 		if ($year != '') {
1764 1764
 			if ($globalDBdriver == 'mysql') {
1765 1765
 				$query .= " AND YEAR(marine_output.date) = :year";
1766
-				$query_values = array_merge($query_values,array(':year' => $year));
1766
+				$query_values = array_merge($query_values, array(':year' => $year));
1767 1767
 			} else {
1768 1768
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
1769
-				$query_values = array_merge($query_values,array(':year' => $year));
1769
+				$query_values = array_merge($query_values, array(':year' => $year));
1770 1770
 			}
1771 1771
 		}
1772 1772
 		if ($month != '') {
1773 1773
 			if ($globalDBdriver == 'mysql') {
1774 1774
 				$query .= " AND MONTH(marine_output.date) = :month";
1775
-				$query_values = array_merge($query_values,array(':month' => $month));
1775
+				$query_values = array_merge($query_values, array(':month' => $month));
1776 1776
 			} else {
1777 1777
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
1778
-				$query_values = array_merge($query_values,array(':month' => $month));
1778
+				$query_values = array_merge($query_values, array(':month' => $month));
1779 1779
 			}
1780 1780
 		}
1781 1781
 		if ($day != '') {
1782 1782
 			if ($globalDBdriver == 'mysql') {
1783 1783
 				$query .= " AND DAY(marine_output.date) = :day";
1784
-				$query_values = array_merge($query_values,array(':day' => $day));
1784
+				$query_values = array_merge($query_values, array(':day' => $day));
1785 1785
 			} else {
1786 1786
 				$query .= " AND EXTRACT(DAY FROM marine_output.date) = :day";
1787
-				$query_values = array_merge($query_values,array(':day' => $day));
1787
+				$query_values = array_merge($query_values, array(':day' => $day));
1788 1788
 			}
1789 1789
 		}
1790 1790
 		$query .= " GROUP BY marine_output.type ORDER BY marine_type_count DESC";
@@ -1793,7 +1793,7 @@  discard block
 block discarded – undo
1793 1793
 		$sth->execute($query_values);
1794 1794
 		$marine_array = array();
1795 1795
 		$temp_array = array();
1796
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1796
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1797 1797
 		{
1798 1798
 			$temp_array['marine_type'] = $row['marine_type'];
1799 1799
 			$temp_array['marine_type_count'] = $row['marine_type_count'];
@@ -1804,7 +1804,7 @@  discard block
 block discarded – undo
1804 1804
 
1805 1805
 	public function getOrderBy()
1806 1806
 	{
1807
-		$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"));
1807
+		$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"));
1808 1808
 		
1809 1809
 		return $orderby;
1810 1810
 		
Please login to merge, or discard this patch.
require/class.MarineImport.php 1 patch
Spacing   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	    if (isset($this->all_tracked[$key]['id'])) {
59 59
 		//echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
60 60
     		$Marine = new Marine($this->db);
61
-        	$Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
61
+        	$Marine->updateLatestMarineData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['speed'], $this->all_tracked[$key]['datetime']);
62 62
             }
63 63
 	}
64 64
     }
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
70 70
 	foreach ($this->all_tracked as $key => $flight) {
71 71
     	    if (isset($flight['lastupdate'])) {
72
-        	if ($flight['lastupdate'] < (time()-3000)) {
72
+        	if ($flight['lastupdate'] < (time() - 3000)) {
73 73
             	    if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
74 74
             		if (isset($this->all_tracked[$key]['id'])) {
75 75
             		    if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
             		    //$real_arrival = $this->arrival($key);
82 82
             		    $Marine = new Marine($this->db);
83 83
             		    if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
84
-				$result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
84
+				$result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['speed'], $this->all_tracked[$key]['datetime']);
85 85
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
86 86
 			    }
87 87
 			    // Put in archive
@@ -95,14 +95,14 @@  discard block
 block discarded – undo
95 95
     }
96 96
 
97 97
     public function add($line) {
98
-	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine;
98
+	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS, $APRSMarine;
99 99
 	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
100 100
 	date_default_timezone_set('UTC');
101 101
 	$dataFound = false;
102 102
 	$send = false;
103 103
 	
104 104
 	// SBS format is CSV format
105
-	if(is_array($line) && isset($line['mmsi'])) {
105
+	if (is_array($line) && isset($line['mmsi'])) {
106 106
 	    //print_r($line);
107 107
   	    if (isset($line['mmsi'])) {
108 108
 
@@ -126,18 +126,18 @@  discard block
 block discarded – undo
126 126
 		
127 127
 		if (!isset($this->all_tracked[$id])) {
128 128
 		    $this->all_tracked[$id] = array();
129
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0));
130
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => ''));
131
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
129
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('addedMarine' => 0));
130
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => '', 'latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '', 'source_name' => '', 'comment'=> '', 'type' => '', 'typeid' => '', 'noarchive' => false, 'putinarchive' => true, 'over_country' => '', 'mmsi' => '', 'status' => '', 'status_id' => '', 'imo' => '', 'callsign' => '', 'arrival_code' => '', 'arrival_date' => '', 'mmsi_type' => ''));
131
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('lastupdate' => time()));
132 132
 		    if (!isset($line['id'])) {
133 133
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
134
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
135
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
134
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $id.'-'.date('YmdHi')));
135
+		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $line['id']));
136 136
 		    if ($globalAllTracked !== FALSE) $dataFound = true;
137 137
 		}
138 138
 		
139 139
 		if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) {
140
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi']));
140
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('mmsi' => $line['mmsi']));
141 141
 		    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
142 142
 			$Marine = new Marine($this->db);
143 143
 			$identity = $Marine->getIdentity($line['mmsi']);
@@ -151,64 +151,64 @@  discard block
 block discarded – undo
151 151
 		    }
152 152
 		}
153 153
 		if (isset($line['type_id'])) {
154
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id'])));
154
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $AIS->getShipType($line['type_id'])));
155 155
 		}
156 156
 		if (isset($line['type']) && $line['type'] != '') {
157
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
157
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $line['type']));
158 158
 		}
159 159
 		if (isset($line['mmsi_type']) && $line['mmsi_type'] != '') {
160
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type']));
160
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('mmsi_type' => $line['mmsi_type']));
161 161
 		}
162 162
 		if (isset($line['imo']) && $line['imo'] != '') {
163
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo']));
163
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('imo' => $line['imo']));
164 164
 		}
165 165
 		if (isset($line['callsign']) && $line['callsign'] != '') {
166
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign']));
166
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('callsign' => $line['callsign']));
167 167
 		}
168 168
 		if (isset($line['arrival_code']) && $line['arrival_code'] != '') {
169
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code']));
169
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('arrival_code' => $line['arrival_code']));
170 170
 		}
171 171
 		if (isset($line['arrival_date']) && $line['arrival_date'] != '') {
172
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date']));
172
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('arrival_date' => $line['arrival_date']));
173 173
 		}
174 174
 
175 175
 
176 176
 		//if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) {
177 177
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) {
178
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
178
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => trim($line['ident'])));
179 179
 		    if ($this->all_tracked[$id]['addedMarine'] == 1) {
180 180
 			if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
181 181
 			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
182 182
 				$timeelapsed = microtime(true);
183 183
 				$Marine = new Marine($this->db);
184 184
 				$fromsource = NULL;
185
-				$result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
185
+				$result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $fromsource);
186 186
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
187 187
 				$Marine->db = null;
188
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
188
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
189 189
 			    }
190 190
 			}
191 191
 		    }
192
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
192
+		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident']));
193 193
 		}
194 194
 
195
-		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
195
+		if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60 && strtotime($line['datetime']) < time() + 20*60) {
196 196
 		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) {
197
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
197
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => $line['datetime']));
198 198
 		    } else {
199 199
 				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n";
200 200
 				elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n";
201 201
 				return '';
202 202
 		    }
203
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
203
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time() - 20*60) {
204 204
 			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!";
205 205
 			return '';
206
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) {
206
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time() + 20*60) {
207 207
 			if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!";
208 208
 			return '';
209 209
 		} elseif (!isset($line['datetime'])) {
210 210
 			date_default_timezone_set('UTC');
211
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s')));
211
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => date('Y-m-d H:i:s')));
212 212
 		} else {
213 213
 			if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!";
214 214
 			return '';
@@ -216,24 +216,24 @@  discard block
 block discarded – undo
216 216
 
217 217
 
218 218
 		if (isset($line['speed'])) {
219
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
220
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
219
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($line['speed'])));
220
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed_fromsrc' => true));
221 221
 		} else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
222
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
222
+		    $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm');
223 223
 		    if ($distance > 1000 && $distance < 10000) {
224 224
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
225 225
 			$speed = $speed*3.6;
226
-			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
226
+			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($speed)));
227 227
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
228 228
 		    }
229 229
 		}
230 230
 
231 231
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
232
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
232
+	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time() - $this->all_tracked[$id]['time_last_coord']);
233 233
 	    	    else unset($timediff);
234
-	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
234
+	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')))) {
235 235
 			if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) {
236
-			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
236
+			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'], $this->all_tracked[$id]['archive_longitude'], $this->all_tracked[$id]['livedb_latitude'], $this->all_tracked[$id]['livedb_longitude'], $line['latitude'], $line['longitude'])) {
237 237
 				$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
238 238
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
239 239
 				$this->all_tracked[$id]['putinarchive'] = true;
@@ -242,10 +242,10 @@  discard block
 block discarded – undo
242 242
 				$timeelapsed = microtime(true);
243 243
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
244 244
 				    $Marine = new Marine($this->db);
245
-				    $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
245
+				    $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']);
246 246
 				    if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
247 247
 				    $Marine->db = null;
248
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
248
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
249 249
 				}
250 250
 				$this->tmd = 0;
251 251
 				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
@@ -254,52 +254,52 @@  discard block
 block discarded – undo
254 254
 
255 255
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
256 256
 				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
257
-				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
257
+				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
258 258
 				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
259 259
 				    $dataFound = true;
260 260
 				    $this->all_tracked[$id]['time_last_coord'] = time();
261 261
 				}
262
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
262
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('latitude' => $line['latitude']));
263 263
 			}
264 264
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
265 265
 			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
266 266
 				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
267
-				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
267
+				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
268 268
 				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
269 269
 				    $dataFound = true;
270 270
 				    $this->all_tracked[$id]['time_last_coord'] = time();
271 271
 				}
272
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude']));
272
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('longitude' => $line['longitude']));
273 273
 			}
274 274
 
275 275
 		    } else if ($globalDebug && $timediff > 20) {
276 276
 			$this->tmd = $this->tmd + 1;
277 277
 			echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n";
278
-			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -";
279
-			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
278
+			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')."m -";
279
+			echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - ";
280 280
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n";
281 281
 		    }
282 282
 		}
283 283
 		if (isset($line['last_update']) && $line['last_update'] != '') {
284 284
 		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
285
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
285
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('last_update' => $line['last_update']));
286 286
 		}
287 287
 		if (isset($line['format_source']) && $line['format_source'] != '') {
288
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
288
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('format_source' => $line['format_source']));
289 289
 		}
290 290
 		if (isset($line['source_name']) && $line['source_name'] != '') {
291
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
291
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('source_name' => $line['source_name']));
292 292
 		}
293 293
 		if (isset($line['status']) && $line['status'] != '') {
294
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status']));
294
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('status' => $line['status']));
295 295
 		}
296 296
 		if (isset($line['status_id']) && (!isset($this->all_tracked[$id]['status_id']) || $this->all_tracked[$id]['status_id'] != $line['status_id'])) {
297
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id']));
297
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('status_id' => $line['status_id']));
298 298
 		    if ($this->all_tracked[$id]['addedMarine'] == 1) {
299 299
 			if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
300 300
 			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
301 301
 				$Marine = new Marine($this->db);
302
-				$Marine->updateStatusMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['status']);
302
+				$Marine->updateStatusMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['status_id'], $this->all_tracked[$id]['status']);
303 303
 				unset($Marine);
304 304
 			    }
305 305
 			}
@@ -307,18 +307,18 @@  discard block
 block discarded – undo
307 307
 		}
308 308
 
309 309
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
310
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
310
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('noarchive' => true));
311 311
 		}
312 312
 		
313 313
 		if (isset($line['heading']) && $line['heading'] != '') {
314
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
315
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
316
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
314
+		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading'] - round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
315
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($line['heading'])));
316
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading_fromsrc' => true));
317 317
 		    //$dataFound = true;
318 318
   		} elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) {
319
-  		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
320
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
321
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
319
+  		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'], $this->all_tracked[$id]['archive_longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']);
320
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($heading)));
321
+		    if (abs($this->all_tracked[$id]['heading'] - round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
322 322
   		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
323 323
   		}
324 324
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 		if ($dataFound === true && isset($this->all_tracked[$id]['mmsi'])) {
329 329
 		    $this->all_tracked[$id]['lastupdate'] = time();
330 330
 		    if ($this->all_tracked[$id]['addedMarine'] == 0) {
331
-		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
331
+		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
332 332
 			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
333 333
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
334 334
 				    if ($globalDebug) echo "Check if aircraft is already in DB...";
@@ -336,37 +336,37 @@  discard block
 block discarded – undo
336 336
 				    $MarineLive = new MarineLive($this->db);
337 337
 				    if (isset($line['id'])) {
338 338
 					$recent_ident = $MarineLive->checkIdRecent($line['id']);
339
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
339
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
340 340
 				    } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') {
341 341
 					$recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']);
342
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
342
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
343 343
 				    } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
344 344
 					$recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']);
345
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
345
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
346 346
 				    } else $recent_ident = '';
347
-				    $MarineLive->db=null;
347
+				    $MarineLive->db = null;
348 348
 				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
349 349
 				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
350 350
 				} else $recent_ident = '';
351 351
 			    } else {
352 352
 				$recent_ident = '';
353
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
353
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('forcenew' => 0));
354 354
 			    }
355 355
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
356
-			    if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '')
356
+			    if ($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '')
357 357
 			    {
358 358
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : ";
359 359
 				//adds the spotter data for the archive
360 360
 				    $highlight = '';
361
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
361
+				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
362 362
 				    if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
363 363
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
364 364
 					    $timeelapsed = microtime(true);
365 365
 					    $Marine = new Marine($this->db);
366
-					    $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
366
+					    $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['typeid'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['arrival_code'], $this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name']);
367 367
 					    $Marine->db = null;
368 368
 					    if ($globalDebug && isset($result)) echo $result."\n";
369
-					    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
369
+					    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
370 370
 					}
371 371
 				    }
372 372
 				    if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') {
@@ -374,15 +374,15 @@  discard block
 block discarded – undo
374 374
 					$Stats = new Stats($this->db);
375 375
 					if (!empty($this->stats)) {
376 376
 					    if ($globalDebug) echo 'Add source stats : ';
377
-				    	    foreach($this->stats as $date => $data) {
378
-						foreach($data as $source => $sourced) {
377
+				    	    foreach ($this->stats as $date => $data) {
378
+						foreach ($data as $source => $sourced) {
379 379
 					    	    //print_r($sourced);
380
-				    	    	    if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date);
381
-				    	    	    if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date);
380
+				    	    	    if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar_marine', $date);
381
+				    	    	    if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist_marine', $date);
382 382
 				    		    if (isset($sourced['msg'])) {
383 383
 				    			if (time() - $sourced['msg']['date'] > 10) {
384 384
 				    		    	    $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
385
-				    		    	    echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date);
385
+				    		    	    echo $Stats->addStatSource($nbmsg, $source, 'msg_marine', $date);
386 386
 			    			    	    unset($this->stats[$date][$source]['msg']);
387 387
 			    				}
388 388
 			    			    }
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
407 407
 					$MarineLive = new MarineLive($this->db);
408 408
 					$MarineLive->deleteLiveMarineData();
409
-					$MarineLive->db=null;
409
+					$MarineLive->db = null;
410 410
 					if ($globalDebug) echo " Done\n";
411 411
 				    }
412 412
 				    $this->last_delete = time();
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
418 418
 				    if (isset($globalDaemon) && !$globalDaemon) {
419 419
 					$Marine = new Marine($this->db);
420
-					$Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime']);
420
+					$Marine->updateLatestMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime']);
421 421
 					$Marine->db = null;
422 422
 				    }
423 423
 				}
@@ -432,20 +432,20 @@  discard block
 block discarded – undo
432 432
 		    $ignoreImport = false;
433 433
 
434 434
 		    if (!$ignoreImport) {
435
-			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
435
+			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
436 436
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
437 437
 				if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
438 438
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
439 439
 					$timeelapsed = microtime(true);
440 440
 					$MarineLive = new MarineLive($this->db);
441
-					$result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
441
+					$result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['typeid'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['arrival_code'], $this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'], $this->all_tracked[$id]['noarchive'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['over_country']);
442 442
 					$MarineLive->db = null;
443 443
 					if ($globalDebug) echo $result."\n";
444
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
444
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
445 445
 				    }
446 446
 				}
447 447
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) {
448
-				    $APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
448
+				    $APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['typeid'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['arrival_code'], $this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'], $this->all_tracked[$id]['noarchive'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['over_country']);
449 449
 				}
450 450
 				$this->all_tracked[$id]['putinarchive'] = false;
451 451
 
@@ -464,19 +464,19 @@  discard block
 block discarded – undo
464 464
 							$latitude = $globalCenterLatitude;
465 465
 							$longitude = $globalCenterLongitude;
466 466
 						}
467
-						$this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude);
467
+						$this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude);
468 468
 					} else {
469 469
 						$latitude = $this->source_location[$source]['latitude'];
470 470
 						$longitude = $this->source_location[$source]['longitude'];
471 471
 					}
472
-					$stats_heading = $Common->getHeading($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
472
+					$stats_heading = $Common->getHeading($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']);
473 473
 					//$stats_heading = $stats_heading%22.5;
474 474
 					$stats_heading = round($stats_heading/22.5);
475
-					$stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
475
+					$stats_distance = $Common->distance($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']);
476 476
 					$current_date = date('Y-m-d');
477 477
 					if ($stats_heading == 16) $stats_heading = 0;
478 478
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
479
-						for ($i=0;$i<=15;$i++) {
479
+						for ($i = 0; $i <= 15; $i++) {
480 480
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
481 481
 						}
482 482
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
@@ -491,9 +491,9 @@  discard block
 block discarded – undo
491 491
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
492 492
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
493 493
 						    end($this->stats[$current_date][$source]['hist']);
494
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
494
+						    $mini = key($this->stats[$current_date][$source]['hist']) + 10;
495 495
 						} else $mini = 0;
496
-						for ($i=$mini;$i<=$distance;$i+=10) {
496
+						for ($i = $mini; $i <= $distance; $i += 10) {
497 497
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
498 498
 						}
499 499
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
 
506 506
 				$this->all_tracked[$id]['lastupdate'] = time();
507 507
 				if ($this->all_tracked[$id]['putinarchive']) $send = true;
508
-			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
508
+			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n";
509 509
 			//$this->del();
510 510
 			
511 511
 			
Please login to merge, or discard this patch.
statistics-aircraft.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -6,12 +6,12 @@  discard block
 block discarded – undo
6 6
 $title = _("Statistics").' - '._("Most common Aircraft");
7 7
 
8 8
 if (!isset($filter_name)) $filter_name = '';
9
-$airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
9
+$airline_icao = (string) filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING);
10 10
 if ($airline_icao == '' && isset($globalFilter)) {
11 11
     if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
12 12
 }
13
-$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
14
-$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
13
+$year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_NUMBER_INT);
14
+$month = filter_input(INPUT_GET, 'month', FILTER_SANITIZE_NUMBER_INT);
15 15
 
16 16
 require_once('header.php');
17 17
 
@@ -23,10 +23,10 @@  discard block
 block discarded – undo
23 23
 	</div>
24 24
 	<p>'._("Below are the <strong>Top 10</strong> most common aircraft types.").'</p>';
25 25
 	  
26
-$aircraft_array = $Stats->countAllAircraftTypes(true,$airline_icao,$filter_name,$year,$month);
26
+$aircraft_array = $Stats->countAllAircraftTypes(true, $airline_icao, $filter_name, $year, $month);
27 27
 print '<div id="chart" class="chart" width="100%"></div><script>';
28 28
 $aircraft_data = '';
29
-foreach($aircraft_array as $aircraft_item)
29
+foreach ($aircraft_array as $aircraft_item)
30 30
 {
31 31
 	if ($aircraft_item['aircraft_manufacturer'] == 'Not Available') $aircraft_data .= '[" ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
32 32
 	else $aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 	print '</thead>';
53 53
 	print '<tbody>';
54 54
 	$i = 1;
55
-	foreach($aircraft_array as $aircraft_item)
55
+	foreach ($aircraft_array as $aircraft_item)
56 56
 	{
57 57
 		print '<tr>';
58 58
 		print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
atc-data.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -5,8 +5,8 @@  discard block
 block discarded – undo
5 5
 $ATC = new ATC();
6 6
 
7 7
 if (isset($_GET['atcid'])) {
8
-	$atcid = filter_input(INPUT_GET,'atcid',FILTER_SANITIZE_NUMBER_INT);
9
-	$atcident = filter_input(INPUT_GET,'atcident',FILTER_SANITIZE_STRING);
8
+	$atcid = filter_input(INPUT_GET, 'atcid', FILTER_SANITIZE_NUMBER_INT);
9
+	$atcident = filter_input(INPUT_GET, 'atcident', FILTER_SANITIZE_STRING);
10 10
 	$atc_data = $ATC->getById($atcid);
11 11
 	if (!isset($atc_data[0])) $atc_data = $ATC->getByIdent($atcident);
12 12
  ?>
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 print '</div>';
39 39
 
40 40
 //print '<div><span>'._("Country").'</span>'.$spotter_item['country'].'</div>';
41
-print '<div><span>'._("Coordinates").'</span>'.round($spotter_item['latitude'],3).', '.round($spotter_item['longitude'],3).'</div>';
41
+print '<div><span>'._("Coordinates").'</span>'.round($spotter_item['latitude'], 3).', '.round($spotter_item['longitude'], 3).'</div>';
42 42
 if ($spotter_item['atc_range'] > 0) {
43 43
     print '<div><span>'._("Range").'</span>';
44 44
     print $spotter_item['atc_range'];
Please login to merge, or discard this patch.
table-output.php 1 patch
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -4,8 +4,8 @@  discard block
 block discarded – undo
4 4
 
5 5
 require_once(dirname(__FILE__).'/require/class.Common.php');
6 6
 $Common = new Common();
7
-$showRouteStop = $Common->multiKeyExists($spotter_array,'route_stop');
8
-$showDuration = $Common->multiKeyExists($spotter_array,'duration');
7
+$showRouteStop = $Common->multiKeyExists($spotter_array, 'route_stop');
8
+$showDuration = $Common->multiKeyExists($spotter_array, 'duration');
9 9
 
10 10
 if (!isset($type)) $type = 'aircraft';
11 11
 
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 	}
107 107
 	print '<th class="more"></th>';
108 108
 	print '</thead>';
109
-} else if (strtolower($current_page) == "upcoming"){
109
+} else if (strtolower($current_page) == "upcoming") {
110 110
 	print '<thead>';
111 111
 	if (!isset($globalNoAirlines) || $globalNoAirlines === FALSE) {
112 112
 		if ($_GET['sort'] == "airline_name_asc")
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 	}
161 161
 	*/
162 162
 	print '</thead>';
163
-} else if (strtolower($current_page) == "acars-latest" || strtolower($current_page) == "acars-archive"){
163
+} else if (strtolower($current_page) == "acars-latest" || strtolower($current_page) == "acars-archive") {
164 164
 	print '<thead>';
165 165
 	print '<th class="aircraft_thumbnail"></th>';
166 166
 	print '<th class="logo">'._("Airline").'</th>';
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 	print '</thead>';
198 198
 } else {
199 199
 
200
-	if ($hide_th_links === true){
200
+	if ($hide_th_links === true) {
201 201
 		print '<thead>';
202 202
 		print '<th class="aircraft_thumbnail"></th>';
203 203
 		if ($type == 'aircraft') {
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
 }
455 455
 
456 456
 print '<tbody>'."\n";
457
-foreach($spotter_array as $spotter_item)
457
+foreach ($spotter_array as $spotter_item)
458 458
 {
459 459
 	if (isset($globalTimezone))
460 460
 	{
@@ -489,13 +489,13 @@  discard block
 block discarded – undo
489 489
 						$image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id;
490 490
 					}
491 491
 					if (isset($spotter_item['airline_name'])) {
492
-						print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '.$spotter_item['airline_name'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
492
+						print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '.$spotter_item['airline_name'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
493 493
 					} else {
494
-						print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '._("Not available").'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
494
+						print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '._("Not available").'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
495 495
 					}
496 496
 				} else {
497 497
 					if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
498
-						$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
498
+						$image_thumbnail = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']);
499 499
 					} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
500 500
 					if (isset($spotter_item['airline_name'])) {
501 501
 						print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '.$spotter_item['airline_name'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
 			{
515 515
 				print '<td class="aircraft_thumbnail">'."\n";
516 516
 				if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
517
-					$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
517
+					$image_thumbnail = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']);
518 518
 				} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
519 519
 				if (isset($spotter_item['airline_name'])) {
520 520
 					print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['mmsi'].'" alt="'.$spotter_item['mmsi'].'" data-content="'._("MMSI:").' '.$spotter_item['mmsi'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
@@ -532,7 +532,7 @@  discard block
 block discarded – undo
532 532
 			{
533 533
 				print '<td class="aircraft_thumbnail">'."\n";
534 534
 				if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
535
-					$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
535
+					$image_thumbnail = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']);
536 536
 				} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
537 537
 				print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['ident'].'" alt="'.$spotter_item['type'].'" data-content="'._("Type:").' '.$spotter_item['type'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
538 538
 				print '</td>'."\n";
@@ -576,7 +576,7 @@  discard block
 block discarded – undo
576 576
 				print '</td>'."\n";
577 577
 			}
578 578
 		}
579
-	} elseif(strtolower($current_page) != "currently" && strtolower($current_page) != "upcoming" && strtolower($current_page) != "acars-latest" && strtolower($current_page) != "acars-archive" && strtolower($current_page) != "accident-latest" && strtolower($current_page) != "incident-latest" && strtolower($current_page) != "accident-detailed" && strtolower($current_page) != "incident-detailed"){
579
+	} elseif (strtolower($current_page) != "currently" && strtolower($current_page) != "upcoming" && strtolower($current_page) != "acars-latest" && strtolower($current_page) != "acars-archive" && strtolower($current_page) != "accident-latest" && strtolower($current_page) != "incident-latest" && strtolower($current_page) != "accident-detailed" && strtolower($current_page) != "incident-detailed") {
580 580
 		if ($type == 'aircraft') {
581 581
 			if (!isset($spotter_item['squawk']) || $spotter_item['squawk'] == 0) {
582 582
 			    $spotter_item['squawk'] = '-';
@@ -593,17 +593,17 @@  discard block
 block discarded – undo
593 593
 						$image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id;
594 594
 					}
595 595
 					if (!isset($spotter_item['airline_name']) && isset($spotter_item['aircraft_name'])) {
596
-						print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
596
+						print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
597 597
 					} elseif (!isset($spotter_item['aircraft_name']) && isset($spotter_item['airline_name'])) {
598
-						print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '.$spotter_item['airline_name'].'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
598
+						print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '.$spotter_item['airline_name'].'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
599 599
 					} elseif (!isset($spotter_item['aircraft_name']) && !isset($spotter_item['airline_name'])) {
600
-						print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
600
+						print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
601 601
 					} else {
602
-						print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '.$spotter_item['airline_name'].'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
602
+						print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '.$spotter_item['airline_name'].'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
603 603
 					}
604 604
 				} else {
605 605
 					if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
606
-						$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
606
+						$image_thumbnail = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']);
607 607
 					} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
608 608
 					if (!isset($spotter_item['airline_name']) && isset($spotter_item['aircraft_name'])) {
609 609
 						print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
@@ -636,7 +636,7 @@  discard block
 block discarded – undo
636 636
 			{
637 637
 				print '<td class="aircraft_thumbnail">'."\n";
638 638
 				if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
639
-					$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
639
+					$image_thumbnail = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']);
640 640
 				} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
641 641
 				print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['mmsi'].'" alt="'.$spotter_item['mmsi'].'" data-content="'._("MMSI:").' '.$spotter_item['mmsi'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
642 642
 				print '</td>'."\n";
@@ -650,7 +650,7 @@  discard block
 block discarded – undo
650 650
 			{
651 651
 				print '<td class="aircraft_thumbnail">'."\n";
652 652
 				if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
653
-					$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
653
+					$image_thumbnail = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']);
654 654
 				} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
655 655
 				print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['ident'].'" alt="'.$spotter_item['type'].'" data-content="'._("Type:").' '.$spotter_item['type'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
656 656
 				print '</td>'."\n";
@@ -759,7 +759,7 @@  discard block
 block discarded – undo
759 759
 		print '</td>'."\n";
760 760
 	}
761 761
 	// Aircraft type
762
-	if(strtolower($current_page) != "upcoming" && strtolower($current_page) != "acars-latest" && strtolower($current_page) != "acars-archive"){
762
+	if (strtolower($current_page) != "upcoming" && strtolower($current_page) != "acars-latest" && strtolower($current_page) != "acars-archive") {
763 763
 		print '<td class="type">'."\n";
764 764
 		if ($type == 'aircraft') {
765 765
 			if (!isset($spotter_item['aircraft_type']) && isset($spotter_item['aircraft_name'])) {
@@ -810,22 +810,22 @@  discard block
 block discarded – undo
810 810
 			}
811 811
 			if (isset($spotter_item['departure_airport_time']) && isset($spotter_item['real_departure_airport_time'])) {
812 812
 				if ($spotter_item['departure_airport_time'] > 2460) {
813
-					$departure_airport_time = date('H:m',$spotter_item['departure_airport_time']);
814
-				} else $departure_airport_time = substr($spotter_item['departure_airport_time'],0,-2).':'.substr($spotter_item['departure_airport_time'],-2);
813
+					$departure_airport_time = date('H:m', $spotter_item['departure_airport_time']);
814
+				} else $departure_airport_time = substr($spotter_item['departure_airport_time'], 0, -2).':'.substr($spotter_item['departure_airport_time'], -2);
815 815
 				if ($spotter_item['real_departure_airport_time'] > 2460) {
816
-					$real_departure_airport_time = date('H:m',$spotter_item['real_departure_airport_time']);
816
+					$real_departure_airport_time = date('H:m', $spotter_item['real_departure_airport_time']);
817 817
 				} else $real_departure_airport_time = $spotter_item['real_departure_airport_time'];
818 818
 				print '<br /><span class="airport_time">'.$departure_airport_time.' ('.$real_departure_airport_time.')</span>'."\n";
819 819
 			} elseif (isset($spotter_item['real_departure_airport_time']) && $spotter_item['real_departure_airport_time'] != 'NULL') {
820 820
 				if ($spotter_item['real_departure_airport_time'] > 2460) {
821
-					$real_departure_airport_time = date('H:m',$spotter_item['real_departure_airport_time']);
821
+					$real_departure_airport_time = date('H:m', $spotter_item['real_departure_airport_time']);
822 822
 				} else $real_departure_airport_time = $spotter_item['real_departure_airport_time'];
823 823
 				print '<br /><span class="airport_time">'.$real_departure_airport_time.'</span>'."\n";
824 824
 			} elseif (isset($spotter_item['departure_airport_time']) && $spotter_item['departure_airport_time'] != 'NULL') {
825 825
 				if ($spotter_item['departure_airport_time'] > 2460) {
826
-					$departure_airport_time = date('H:m',$spotter_item['departure_airport_time']);
826
+					$departure_airport_time = date('H:m', $spotter_item['departure_airport_time']);
827 827
 				} else {
828
-					$departure_airport_time = substr($spotter_item['departure_airport_time'],0,-2).':'.substr($spotter_item['departure_airport_time'],-2);
828
+					$departure_airport_time = substr($spotter_item['departure_airport_time'], 0, -2).':'.substr($spotter_item['departure_airport_time'], -2);
829 829
 				}
830 830
 				print '<br /><span class="airport_time">'.$departure_airport_time.'</span>'."\n";
831 831
 			}
@@ -840,7 +840,7 @@  discard block
 block discarded – undo
840 840
 						$latitude = $spotter_item['latitude'];
841 841
 						$longitude = $spotter_item['longitude'];
842 842
 					}
843
-					$distance = $Spotter->getAirportDistance($spotter_item['departure_airport'],$latitude,$longitude);
843
+					$distance = $Spotter->getAirportDistance($spotter_item['departure_airport'], $latitude, $longitude);
844 844
 				} else $distance = '';
845 845
 				if ($distance != '') {
846 846
 					if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
@@ -883,20 +883,20 @@  discard block
 block discarded – undo
883 883
 			}
884 884
 			if (isset($spotter_item['arrival_airport_time']) && isset($spotter_item['real_arrival_airport_time'])) {
885 885
 				if ($spotter_item['arrival_airport_time'] > 2460) {
886
-					$arrival_airport_time = date('H:m',$spotter_item['arrival_airport_time']);
886
+					$arrival_airport_time = date('H:m', $spotter_item['arrival_airport_time']);
887 887
 				} else $arrival_airport_time = $spotter_item['arrival_airport_time'];
888 888
 				if ($spotter_item['real_arrival_airport_time'] > 2460) {
889
-					$real_arrival_airport_time = date('H:m',$spotter_item['real_arrival_airport_time']);
889
+					$real_arrival_airport_time = date('H:m', $spotter_item['real_arrival_airport_time']);
890 890
 				} else $real_arrival_airport_time = $spotter_item['real_arrival_airport_time'];
891 891
 				print '<br /><span class="airport_time">'.$spotter_item['arrival_airport_time'].' ('.$spotter_item['real_arrival_airport_time'].')</span>'."\n";
892 892
 			} elseif (isset($spotter_item['real_arrival_airport_time'])) {
893 893
 				if ($spotter_item['real_arrival_airport_time'] > 2460) {
894
-					$real_arrival_airport_time = date('H:m',$spotter_item['real_arrival_airport_time']);
894
+					$real_arrival_airport_time = date('H:m', $spotter_item['real_arrival_airport_time']);
895 895
 				} else $real_arrival_airport_time = $spotter_item['real_arrival_airport_time'];
896 896
 				print '<br /><span class="airport_time">'.$real_arrival_airport_time.'</span>'."\n";
897 897
 			} elseif (isset($spotter_item['arrival_airport_time']) && $spotter_item['arrival_airport_time'] != 'NULL') {
898 898
 				if ($spotter_item['arrival_airport_time'] > 2460) {
899
-					$arrival_airport_time = date('H:m',$spotter_item['arrival_airport_time']);
899
+					$arrival_airport_time = date('H:m', $spotter_item['arrival_airport_time']);
900 900
 				} else $arrival_airport_time = $spotter_item['arrival_airport_time'];
901 901
 				print '<br /><span class="airport_time">'.$arrival_airport_time.'</span>'."\n";
902 902
 			}
@@ -909,7 +909,7 @@  discard block
 block discarded – undo
909 909
 						$latitude = $spotter_item['latitude'];
910 910
 						$longitude = $spotter_item['longitude'];
911 911
 					}
912
-					$distance = $Spotter->getAirportDistance($spotter_item['arrival_airport'],$latitude,$longitude);
912
+					$distance = $Spotter->getAirportDistance($spotter_item['arrival_airport'], $latitude, $longitude);
913 913
 				} else $distance = '';
914 914
 				if ($distance != '') {
915 915
 					if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
@@ -952,19 +952,19 @@  discard block
 block discarded – undo
952 952
 				print '<span class="mobile">-</span>'."\n";
953 953
 			} else {
954 954
 				if ((!isset($_COOKIE['unitdistance']) && ((isset($globalUnitDistance) && $globalUnitDistance == 'km') || !isset($globalUnitDistance))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) {
955
-					print '<span class="nomobile">'.round($spotter_item['distance'],2).' km</span>'."\n";
956
-					print '<span class="mobile">'.round($spotter_item['distance'],2).' km</span><br />'."\n";
955
+					print '<span class="nomobile">'.round($spotter_item['distance'], 2).' km</span>'."\n";
956
+					print '<span class="mobile">'.round($spotter_item['distance'], 2).' km</span><br />'."\n";
957 957
 				} elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) {
958
-					print '<span class="nomobile">'.round($spotter_item['distance']*0.621371,2).' mi</span>'."\n";
959
-					print '<span class="mobile">'.round($spotter_item['distance']*0.621371,2).' mi</span><br />'."\n";
958
+					print '<span class="nomobile">'.round($spotter_item['distance']*0.621371, 2).' mi</span>'."\n";
959
+					print '<span class="mobile">'.round($spotter_item['distance']*0.621371, 2).' mi</span><br />'."\n";
960 960
 				} elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
961
-					print '<span class="nomobile">'.round($spotter_item['distance']*0.539957,2).' nm</span>'."\n";
962
-					print '<span class="mobile">'.round($spotter_item['distance']*0.539957,2).' nm</span><br />'."\n";
961
+					print '<span class="nomobile">'.round($spotter_item['distance']*0.539957, 2).' nm</span>'."\n";
962
+					print '<span class="mobile">'.round($spotter_item['distance']*0.539957, 2).' nm</span><br />'."\n";
963 963
 				}
964 964
 			}
965 965
 			print '</td>'."\n";
966 966
 		}
967
-		if(strtolower($current_page) != "upcoming"){
967
+		if (strtolower($current_page) != "upcoming") {
968 968
 			if ($type == 'aircraft') {
969 969
 				//if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
970 970
 				if ((isset($globalUsePilot) && $globalUsePilot) || !isset($globalUsePilot) && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM))) {
@@ -1007,7 +1007,7 @@  discard block
 block discarded – undo
1007 1007
 		
1008 1008
 		if ($showRouteStop) {
1009 1009
 		// Route stop
1010
-			if(strtolower($current_page) != "upcoming"){
1010
+			if (strtolower($current_page) != "upcoming") {
1011 1011
 				print '<td class="route_stop">'."\n";
1012 1012
 				if (!isset($spotter_item['route_stop']) || $spotter_item['route_stop'] == '' || $spotter_item['route_stop'] == 'NULL') {
1013 1013
 					print '<span class="nomobile">-</span>'."\n";
@@ -1026,11 +1026,11 @@  discard block
 block discarded – undo
1026 1026
 		}
1027 1027
 		if ($showDuration) {
1028 1028
 		// Duration
1029
-			if(strtolower($current_page) != "upcoming"){
1029
+			if (strtolower($current_page) != "upcoming") {
1030 1030
 				print '<td class="duration">'."\n";
1031 1031
 				if (isset($spotter_item['duration'])) {
1032
-					print '<span class="nomobile">'.gmdate('H:i:s',$spotter_item['duration']).'</span>'."\n";
1033
-					print '<span class="mobile">'.gmdate('H:i:s',$spotter_item['duration']).'</span>'."\n";
1032
+					print '<span class="nomobile">'.gmdate('H:i:s', $spotter_item['duration']).'</span>'."\n";
1033
+					print '<span class="mobile">'.gmdate('H:i:s', $spotter_item['duration']).'</span>'."\n";
1034 1034
 				} else {
1035 1035
 					print '<span class="nomobile">-</span>'."\n";
1036 1036
 					print '<span class="mobile">-</span>'."\n";
@@ -1043,7 +1043,7 @@  discard block
 block discarded – undo
1043 1043
 	if (strtolower($current_page) == "acars-latest" || strtolower($current_page) == "acars-archive") {
1044 1044
 		if (isset($spotter_item['decode']) && $spotter_item['decode'] != '') {
1045 1045
 			print '<td class="message"><p>'."\n";
1046
-			print str_replace(array("\r\n", "\n", "\r"),'<br />',$spotter_item['message']);
1046
+			print str_replace(array("\r\n", "\n", "\r"), '<br />', $spotter_item['message']);
1047 1047
 			print '</p><p class="decode">';
1048 1048
 			$decode_array = json_decode($spotter_item['decode']);
1049 1049
 			foreach ($decode_array as $key => $value) {
@@ -1053,7 +1053,7 @@  discard block
 block discarded – undo
1053 1053
 			print '</td>'."\n";
1054 1054
 		} else {
1055 1055
 			print '<td class="message">'."\n";
1056
-			print str_replace(array("\r\n", "\n", "\r"),'<br />',$spotter_item['message']);
1056
+			print str_replace(array("\r\n", "\n", "\r"), '<br />', $spotter_item['message']);
1057 1057
 			print '</td>'."\n";
1058 1058
 		}
1059 1059
 	}
@@ -1078,7 +1078,7 @@  discard block
 block discarded – undo
1078 1078
 		}
1079 1079
 		print '</td>'."\n";
1080 1080
 		print '<td class="message">'."\n";
1081
-		print str_replace(array("\r\n", "\n", "\r"),'<br />',$spotter_item['message']);
1081
+		print str_replace(array("\r\n", "\n", "\r"), '<br />', $spotter_item['message']);
1082 1082
 		print '</td>'."\n";
1083 1083
 	}
1084 1084
 	if (strtolower($current_page) == "incident-latest" || strtolower($current_page) == "incident-detailed") {
@@ -1104,7 +1104,7 @@  discard block
 block discarded – undo
1104 1104
 		print '</td>'."\n";
1105 1105
 		*/
1106 1106
 		print '<td class="message">'."\n";
1107
-		print str_replace(array("\r\n", "\n", "\r"),'<br />',$spotter_item['message']);
1107
+		print str_replace(array("\r\n", "\n", "\r"), '<br />', $spotter_item['message']);
1108 1108
 		print '</td>'."\n";
1109 1109
 	}
1110 1110
 
Please login to merge, or discard this patch.
js/map.2d.js.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 require_once('../require/settings.php');
3 3
 require_once('../require/class.Language.php'); 
4 4
 
5
-setcookie("MapFormat",'2d');
5
+setcookie("MapFormat", '2d');
6 6
 
7 7
 if (!isset($globalOpenWeatherMapKey)) $globalOpenWeatherMapKey = '';
8 8
 // Compressed GeoJson is used if true
@@ -20,10 +20,10 @@  discard block
 block discarded – undo
20 20
 	$lastupd = $_GET['archivespeed']*$archiveupdatetime;
21 21
 	if (isset($_GET['enddate']) && $_GET['enddate'] != '') $enddate = $_GET['enddate'];
22 22
 	else $enddate = time();
23
-	setcookie("archive_begin",$begindate);
24
-	setcookie("archive_end",$enddate);
25
-	setcookie("archive_update",$lastupd);
26
-	setcookie("archive_speed",$archivespeed);
23
+	setcookie("archive_begin", $begindate);
24
+	setcookie("archive_end", $enddate);
25
+	setcookie("archive_update", $lastupd);
26
+	setcookie("archive_speed", $archivespeed);
27 27
 ?>
28 28
 document.cookie =  'archive_begin=<?php print $begindate; ?>; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/';
29 29
 document.cookie =  'archive_end=<?php print $enddate; ?>; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/';
@@ -74,16 +74,16 @@  discard block
 block discarded – undo
74 74
 <?php
75 75
 	}
76 76
 	if (isset($_GET['ident'])) {
77
-		$ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING);
77
+		$ident = filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING);
78 78
 	}
79 79
 	if (isset($_GET['flightaware_id'])) {
80
-		$flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING);
80
+		$flightaware_id = filter_input(INPUT_GET, 'flightaware_id', FILTER_SANITIZE_STRING);
81 81
 	}
82 82
 	if (isset($_GET['latitude'])) {
83
-		$latitude = filter_input(INPUT_GET,'latitude',FILTER_SANITIZE_STRING);
83
+		$latitude = filter_input(INPUT_GET, 'latitude', FILTER_SANITIZE_STRING);
84 84
 	}
85 85
 	if (isset($_GET['longitude'])) {
86
-		$longitude = filter_input(INPUT_GET,'longitude',FILTER_SANITIZE_STRING);
86
+		$longitude = filter_input(INPUT_GET, 'longitude', FILTER_SANITIZE_STRING);
87 87
 	}
88 88
 ?>
89 89
 
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 	     || navigator.userAgent.match(/BlackBerry/i)
120 120
 	     || navigator.userAgent.match(/Windows Phone/i))
121 121
 	{
122
-		var zoom = <?php if (isset($globalLiveZoom)) print $globalLiveZoom-1; else print '8'; ?>;
122
+		var zoom = <?php if (isset($globalLiveZoom)) print $globalLiveZoom - 1; else print '8'; ?>;
123 123
 	} else {
124 124
 		var zoom = <?php if (isset($globalLiveZoom)) print $globalLiveZoom; else print '9'; ?>;
125 125
 	}
@@ -213,19 +213,19 @@  discard block
 block discarded – undo
213 213
 	map.addLayer(yandexLayer);
214 214
 <?php
215 215
 	} elseif ($MapType == 'Bing-Aerial') {
216
-		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap');
216
+		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType', 'OpenStreetMap');
217 217
 ?>
218 218
 	var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'Aerial'});
219 219
 	map.addLayer(bingLayer);
220 220
 <?php
221 221
 	} elseif ($MapType == 'Bing-Hybrid') {
222
-		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap');
222
+		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType', 'OpenStreetMap');
223 223
 ?>
224 224
 	var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'AerialWithLabels'});
225 225
 	map.addLayer(bingLayer);
226 226
 <?php
227 227
 	} elseif ($MapType == 'Bing-Road') {
228
-		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap');
228
+		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType', 'OpenStreetMap');
229 229
 ?>
230 230
 	var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'Road'});
231 231
 	map.addLayer(bingLayer);
Please login to merge, or discard this patch.
require/class.SpotterLive.php 1 patch
Spacing   +127 added lines, -127 removed lines patch added patch discarded remove patch
@@ -16,62 +16,62 @@  discard block
 block discarded – undo
16 16
 	* @param Array $filter the filter
17 17
 	* @return Array the SQL part
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['airlines']) && !empty($flt['airlines'])) {
37 37
 				if ($flt['airlines'][0] != '') {
38 38
 					if (isset($flt['source'])) {
39
-						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id";
39
+						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id";
40 40
 					} else {
41
-						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id";
41
+						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id";
42 42
 					}
43 43
 				}
44 44
 			}
45 45
 			if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) {
46 46
 				if (isset($flt['source'])) {
47
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id";
47
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id";
48 48
 				} else {
49
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id";
49
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id";
50 50
 				}
51 51
 			}
52 52
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
53 53
 				if (isset($flt['source'])) {
54
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id";
54
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id";
55 55
 				} else {
56
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id";
56
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id";
57 57
 				}
58 58
 			}
59 59
 			if (isset($flt['registrations']) && !empty($flt['registrations'])) {
60 60
 				if (isset($flt['source'])) {
61
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id";
61
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','", $flt['registrations'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id";
62 62
 				} else {
63
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id";
63
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','", $flt['registrations'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id";
64 64
 				}
65 65
 			}
66 66
 			if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) {
67 67
 				if (isset($flt['source'])) {
68
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) ssf ON ssf.flightaware_id = spotter_live.flightaware_id";
68
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','", $flt['source'])."')) ssf ON ssf.flightaware_id = spotter_live.flightaware_id";
69 69
 				}
70 70
 			}
71 71
 		}
72 72
 		if (isset($filter['airlines']) && !empty($filter['airlines'])) {
73 73
 			if ($filter['airlines'][0] != '') {
74
-				$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) sai ON sai.flightaware_id = spotter_live.flightaware_id";
74
+				$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) sai ON sai.flightaware_id = spotter_live.flightaware_id";
75 75
 			}
76 76
 		}
77 77
 		if (isset($filter['alliance']) && !empty($filter['alliance'])) {
@@ -81,10 +81,10 @@  discard block
 block discarded – undo
81 81
 			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_live.flightaware_id ";
82 82
 		}
83 83
 		if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) {
84
-			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) sp ON sp.flightaware_id = spotter_live.flightaware_id";
84
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) sp ON sp.flightaware_id = spotter_live.flightaware_id";
85 85
 		}
86 86
 		if (isset($filter['source']) && !empty($filter['source'])) {
87
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
87
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
88 88
 		}
89 89
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
90 90
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
@@ -113,15 +113,15 @@  discard block
 block discarded – undo
113 113
 					$filter_query_date .= " AND EXTRACT(DAY FROM spotter_output.date) = '".$filter['day']."'";
114 114
 				}
115 115
 			}
116
-			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_live.flightaware_id";
116
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.flightaware_id = spotter_live.flightaware_id";
117 117
 		}
118 118
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
119
-			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
119
+			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
120 120
 		}
121 121
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
122 122
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
123 123
 		if ($filter_query_where != '') {
124
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
124
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
125 125
 		}
126 126
 		$filter_query = $filter_query_join.$filter_query_where;
127 127
 		return $filter_query;
@@ -144,8 +144,8 @@  discard block
 block discarded – undo
144 144
 		if ($limit != '')
145 145
 		{
146 146
 			$limit_array = explode(',', $limit);
147
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
148
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
147
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
148
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
149 149
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
150 150
 			{
151 151
 				$limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0];
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 		} else {
170 170
 			$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate".$filter_query.$orderby_query;
171 171
 		}
172
-		$spotter_array = $Spotter->getDataFromDB($query.$limit_query,array(),'',true);
172
+		$spotter_array = $Spotter->getDataFromDB($query.$limit_query, array(), '', true);
173 173
 
174 174
 		return $spotter_array;
175 175
 	}
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 	{
185 185
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
186 186
 		date_default_timezone_set('UTC');
187
-		$filter_query = $this->getFilter($filter,true,true);
187
+		$filter_query = $this->getFilter($filter, true, true);
188 188
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
189 189
 		if ($globalDBdriver == 'mysql') {
190 190
 			if (isset($globalArchive) && $globalArchive === TRUE) {
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 		try {
208 208
 			$sth = $this->db->prepare($query);
209 209
 			$sth->execute();
210
-		} catch(PDOException $e) {
210
+		} catch (PDOException $e) {
211 211
 			echo $e->getMessage();
212 212
 			die;
213 213
 		}
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
227 227
 		date_default_timezone_set('UTC');
228 228
 
229
-		$filter_query = $this->getFilter($filter,true,true);
229
+		$filter_query = $this->getFilter($filter, true, true);
230 230
 
231 231
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
232 232
 		if ($globalDBdriver == 'mysql') {
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 				WHERE spotter_archive.latitude <> '0' AND spotter_archive.longitude <> '0' 
238 238
 				ORDER BY spotter_archive.flightaware_id, spotter_archive.date";
239 239
 				*/
240
-				$query  = 'SELECT * FROM (SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source 
240
+				$query = 'SELECT * FROM (SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source 
241 241
 				FROM spotter_archive INNER JOIN (SELECT flightaware_id FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date) l ON l.flightaware_id = spotter_archive.flightaware_id 
242 242
 				UNION
243 243
 				SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
 				WHERE latitude <> '0' AND longitude <> '0' 
246 246
 				ORDER BY flightaware_id, date";
247 247
 			} else {
248
-				$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
248
+				$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
249 249
 				FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date 
250 250
 				AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' 
251 251
 				ORDER BY spotter_live.flightaware_id, spotter_live.date";
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 				WHERE spotter_archive.latitude <> '0' AND spotter_archive.longitude <> '0' 
259 259
 				ORDER BY spotter_archive.flightaware_id, spotter_archive.date";
260 260
                                */
261
-				$query  = "SELECT * FROM (SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source 
261
+				$query = "SELECT * FROM (SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source 
262 262
 				FROM spotter_archive INNER JOIN (SELECT flightaware_id FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date) l ON l.flightaware_id = spotter_archive.flightaware_id 
263 263
 				UNION
264 264
 				SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 				ORDER BY flightaware_id, date";
269 269
 				//AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".round($globalLiveInterval*1000)." SECONDS' <= spotter_archive.date
270 270
 			} else {
271
-				$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
271
+				$query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
272 272
 				FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date
273 273
 				AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' 
274 274
 				ORDER BY spotter_live.flightaware_id, spotter_live.date";
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
     		try {
278 278
 			$sth = $this->db->prepare($query);
279 279
 			$sth->execute();
280
-		} catch(PDOException $e) {
280
+		} catch (PDOException $e) {
281 281
 			echo $e->getMessage();
282 282
 			die;
283 283
 		}
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 	public function getLiveSpotterCount($filter = array())
295 295
 	{
296 296
 		global $globalDBdriver, $globalLiveInterval;
297
-		$filter_query = $this->getFilter($filter,true,true);
297
+		$filter_query = $this->getFilter($filter, true, true);
298 298
 
299 299
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
300 300
 		if ($globalDBdriver == 'mysql') {
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
 		try {
308 308
 			$sth = $this->db->prepare($query);
309 309
 			$sth->execute();
310
-		} catch(PDOException $e) {
310
+		} catch (PDOException $e) {
311 311
 			echo $e->getMessage();
312 312
 			die;
313 313
 		}
@@ -330,10 +330,10 @@  discard block
 block discarded – undo
330 330
 		$filter_query = $this->getFilter($filter);
331 331
 
332 332
 		if (is_array($coord)) {
333
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
334
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
335
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
336
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
333
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
334
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
335
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
336
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
337 337
 		} else return array();
338 338
 		if ($globalDBdriver == 'mysql') {
339 339
 			$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY spotter_live.flightaware_id'.$filter_query;
@@ -356,23 +356,23 @@  discard block
 block discarded – undo
356 356
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
357 357
 		$Spotter = new Spotter($this->db);
358 358
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
359
-		$filter_query = $this->getFilter($filter,true,true);
359
+		$filter_query = $this->getFilter($filter, true, true);
360 360
 
361 361
 		if (is_array($coord)) {
362
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
363
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
364
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
365
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
362
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
363
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
364
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
365
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
366 366
 		} else return array();
367 367
 		if ($globalDBdriver == 'mysql') {
368 368
 			if (isset($globalArchive) && $globalArchive === TRUE) {
369
-				$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
369
+				$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
370 370
 				FROM spotter_live 
371 371
 				'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= spotter_live.date 
372 372
 				AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.'
373 373
 				AND spotter_live.latitude <> 0 AND spotter_live.longitude <> 0';
374 374
 			} else {
375
-				$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
375
+				$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
376 376
 				FROM spotter_live 
377 377
 				INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate 
378 378
 				    FROM spotter_live l 
@@ -384,14 +384,14 @@  discard block
 block discarded – undo
384 384
 			}
385 385
 		} else {
386 386
 			if (isset($globalArchive) && $globalArchive === TRUE) {
387
-				$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
387
+				$query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
388 388
 				FROM spotter_live 
389 389
 				".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date 
390 390
 				AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." 
391 391
 				AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." 
392 392
 				AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0'";
393 393
 			} else {
394
-				$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
394
+				$query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
395 395
 				FROM spotter_live 
396 396
 				INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate 
397 397
 				    FROM spotter_live l 
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
 		try {
407 407
 			$sth = $this->db->prepare($query);
408 408
 			$sth->execute();
409
-		} catch(PDOException $e) {
409
+		} catch (PDOException $e) {
410 410
 			echo $e->getMessage();
411 411
 			die;
412 412
 		}
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
                 if ($interval == '1m')
456 456
                 {
457 457
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
458
-                } else if ($interval == '15m'){
458
+                } else if ($interval == '15m') {
459 459
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date ';
460 460
                 } 
461 461
             }
@@ -463,14 +463,14 @@  discard block
 block discarded – undo
463 463
          $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';   
464 464
         }
465 465
 
466
-                $query  = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live 
466
+                $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live 
467 467
                    WHERE spotter_live.latitude <> '' 
468 468
                                    AND spotter_live.longitude <> '' 
469 469
                    ".$additional_query."
470 470
                    HAVING distance < :radius  
471 471
                                    ORDER BY distance";
472 472
 
473
-                $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
473
+                $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius));
474 474
 
475 475
                 return $spotter_array;
476 476
         }
@@ -488,9 +488,9 @@  discard block
 block discarded – undo
488 488
 		date_default_timezone_set('UTC');
489 489
 
490 490
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
491
-                $query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
491
+                $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
492 492
 
493
-		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true);
493
+		$spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident), '', true);
494 494
 
495 495
 		return $spotter_array;
496 496
 	}
@@ -501,16 +501,16 @@  discard block
 block discarded – undo
501 501
 	* @return Array the spotter information
502 502
 	*
503 503
 	*/
504
-	public function getDateLiveSpotterDataByIdent($ident,$date)
504
+	public function getDateLiveSpotterDataByIdent($ident, $date)
505 505
 	{
506 506
 		$Spotter = new Spotter($this->db);
507 507
 		date_default_timezone_set('UTC');
508 508
 
509 509
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
510
-                $query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
510
+                $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
511 511
 
512
-                $date = date('c',$date);
513
-		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
512
+                $date = date('c', $date);
513
+		$spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
514 514
 
515 515
 		return $spotter_array;
516 516
 	}
@@ -526,8 +526,8 @@  discard block
 block discarded – undo
526 526
 		$Spotter = new Spotter($this->db);
527 527
 		date_default_timezone_set('UTC');
528 528
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
529
-		$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
530
-		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true);
529
+		$query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
530
+		$spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id), '', true);
531 531
 		return $spotter_array;
532 532
 	}
533 533
 
@@ -537,15 +537,15 @@  discard block
 block discarded – undo
537 537
 	* @return Array the spotter information
538 538
 	*
539 539
 	*/
540
-	public function getDateLiveSpotterDataById($id,$date)
540
+	public function getDateLiveSpotterDataById($id, $date)
541 541
 	{
542 542
 		$Spotter = new Spotter($this->db);
543 543
 		date_default_timezone_set('UTC');
544 544
 
545 545
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
546
-		$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
547
-		$date = date('c',$date);
548
-		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
546
+		$query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
547
+		$date = date('c', $date);
548
+		$spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true);
549 549
 		return $spotter_array;
550 550
 	}
551 551
 
@@ -561,13 +561,13 @@  discard block
 block discarded – undo
561 561
 		date_default_timezone_set('UTC');
562 562
 
563 563
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
564
-                $query  = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
564
+                $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
565 565
 
566 566
     		try {
567 567
 			
568 568
 			$sth = $this->db->prepare($query);
569 569
 			$sth->execute(array(':ident' => $ident));
570
-		} catch(PDOException $e) {
570
+		} catch (PDOException $e) {
571 571
 			echo $e->getMessage();
572 572
 			die;
573 573
 		}
@@ -582,7 +582,7 @@  discard block
 block discarded – undo
582 582
 	* @return Array the spotter information
583 583
 	*
584 584
 	*/
585
-	public function getAllLiveSpotterDataById($id,$liveinterval = false)
585
+	public function getAllLiveSpotterDataById($id, $liveinterval = false)
586 586
 	{
587 587
 		global $globalDBdriver, $globalLiveInterval;
588 588
 		date_default_timezone_set('UTC');
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
 		try {
602 602
 			$sth = $this->db->prepare($query);
603 603
 			$sth->execute(array(':id' => $id));
604
-		} catch(PDOException $e) {
604
+		} catch (PDOException $e) {
605 605
 			echo $e->getMessage();
606 606
 			die;
607 607
 		}
@@ -619,12 +619,12 @@  discard block
 block discarded – undo
619 619
 	{
620 620
 		date_default_timezone_set('UTC');
621 621
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
622
-		$query  = self::$global_query.' WHERE spotter_live.ident = :ident';
622
+		$query = self::$global_query.' WHERE spotter_live.ident = :ident';
623 623
     		try {
624 624
 			
625 625
 			$sth = $this->db->prepare($query);
626 626
 			$sth->execute(array(':ident' => $ident));
627
-		} catch(PDOException $e) {
627
+		} catch (PDOException $e) {
628 628
 			echo $e->getMessage();
629 629
 			die;
630 630
 		}
@@ -654,7 +654,7 @@  discard block
 block discarded – undo
654 654
 			
655 655
 			$sth = $this->db->prepare($query);
656 656
 			$sth->execute();
657
-		} catch(PDOException $e) {
657
+		} catch (PDOException $e) {
658 658
 			return "error";
659 659
 		}
660 660
 
@@ -677,14 +677,14 @@  discard block
 block discarded – undo
677 677
 				
678 678
 				$sth = $this->db->prepare($query);
679 679
 				$sth->execute();
680
-			} catch(PDOException $e) {
680
+			} catch (PDOException $e) {
681 681
 				return "error";
682 682
 			}
683 683
 			$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
684 684
                         $i = 0;
685
-                        $j =0;
685
+                        $j = 0;
686 686
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
687
-			foreach($all as $row)
687
+			foreach ($all as $row)
688 688
 			{
689 689
 				$i++;
690 690
 				$j++;
@@ -692,9 +692,9 @@  discard block
 block discarded – undo
692 692
 					if ($globalDebug) echo ".";
693 693
 				    	try {
694 694
 						
695
-						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
695
+						$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
696 696
 						$sth->execute();
697
-					} catch(PDOException $e) {
697
+					} catch (PDOException $e) {
698 698
 						return "error";
699 699
 					}
700 700
                                 	$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
@@ -705,9 +705,9 @@  discard block
 block discarded – undo
705 705
 			if ($i > 0) {
706 706
     				try {
707 707
 					
708
-					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
708
+					$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
709 709
 					$sth->execute();
710
-				} catch(PDOException $e) {
710
+				} catch (PDOException $e) {
711 711
 					return "error";
712 712
 				}
713 713
 			}
@@ -720,7 +720,7 @@  discard block
 block discarded – undo
720 720
 				
721 721
 				$sth = $this->db->prepare($query);
722 722
 				$sth->execute();
723
-			} catch(PDOException $e) {
723
+			} catch (PDOException $e) {
724 724
 				return "error";
725 725
 			}
726 726
 /*			$query_delete = "DELETE FROM spotter_live WHERE flightaware_id IN (";
@@ -768,13 +768,13 @@  discard block
 block discarded – undo
768 768
 	public function deleteLiveSpotterDataByIdent($ident)
769 769
 	{
770 770
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
771
-		$query  = 'DELETE FROM spotter_live WHERE ident = :ident';
771
+		$query = 'DELETE FROM spotter_live WHERE ident = :ident';
772 772
         
773 773
     		try {
774 774
 			
775 775
 			$sth = $this->db->prepare($query);
776 776
 			$sth->execute(array(':ident' => $ident));
777
-		} catch(PDOException $e) {
777
+		} catch (PDOException $e) {
778 778
 			return "error";
779 779
 		}
780 780
 
@@ -790,13 +790,13 @@  discard block
 block discarded – undo
790 790
 	public function deleteLiveSpotterDataById($id)
791 791
 	{
792 792
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
793
-		$query  = 'DELETE FROM spotter_live WHERE flightaware_id = :id';
793
+		$query = 'DELETE FROM spotter_live WHERE flightaware_id = :id';
794 794
         
795 795
     		try {
796 796
 			
797 797
 			$sth = $this->db->prepare($query);
798 798
 			$sth->execute(array(':id' => $id));
799
-		} catch(PDOException $e) {
799
+		} catch (PDOException $e) {
800 800
 			return "error";
801 801
 		}
802 802
 
@@ -814,13 +814,13 @@  discard block
 block discarded – undo
814 814
 	{
815 815
 		global $globalDBdriver, $globalTimezone;
816 816
 		if ($globalDBdriver == 'mysql') {
817
-			$query  = 'SELECT spotter_live.ident FROM spotter_live 
817
+			$query = 'SELECT spotter_live.ident FROM spotter_live 
818 818
 				WHERE spotter_live.ident = :ident 
819 819
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
820 820
 				AND spotter_live.date < UTC_TIMESTAMP()';
821 821
 			$query_data = array(':ident' => $ident);
822 822
 		} else {
823
-			$query  = "SELECT spotter_live.ident FROM spotter_live 
823
+			$query = "SELECT spotter_live.ident FROM spotter_live 
824 824
 				WHERE spotter_live.ident = :ident 
825 825
 				AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
826 826
 				AND spotter_live.date < now() AT TIME ZONE 'UTC'";
@@ -829,8 +829,8 @@  discard block
 block discarded – undo
829 829
 		
830 830
 		$sth = $this->db->prepare($query);
831 831
 		$sth->execute($query_data);
832
-		$ident_result='';
833
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
832
+		$ident_result = '';
833
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
834 834
 		{
835 835
 			$ident_result = $row['ident'];
836 836
 		}
@@ -847,13 +847,13 @@  discard block
 block discarded – undo
847 847
 	{
848 848
 		global $globalDBdriver, $globalTimezone;
849 849
 		if ($globalDBdriver == 'mysql') {
850
-			$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
850
+			$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
851 851
 				WHERE spotter_live.ident = :ident 
852 852
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; 
853 853
 //				AND spotter_live.date < UTC_TIMESTAMP()";
854 854
 			$query_data = array(':ident' => $ident);
855 855
 		} else {
856
-			$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
856
+			$query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
857 857
 				WHERE spotter_live.ident = :ident 
858 858
 				AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'";
859 859
 //				AND spotter_live.date < now() AT TIME ZONE 'UTC'";
@@ -862,8 +862,8 @@  discard block
 block discarded – undo
862 862
 		
863 863
 		$sth = $this->db->prepare($query);
864 864
 		$sth->execute($query_data);
865
-		$ident_result='';
866
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
865
+		$ident_result = '';
866
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
867 867
 		{
868 868
 			$ident_result = $row['flightaware_id'];
869 869
 		}
@@ -880,13 +880,13 @@  discard block
 block discarded – undo
880 880
 	{
881 881
 		global $globalDBdriver, $globalTimezone;
882 882
 		if ($globalDBdriver == 'mysql') {
883
-			$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
883
+			$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
884 884
 				WHERE spotter_live.flightaware_id = :id 
885 885
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; 
886 886
 //				AND spotter_live.date < UTC_TIMESTAMP()";
887 887
 			$query_data = array(':id' => $id);
888 888
 		} else {
889
-			$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
889
+			$query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
890 890
 				WHERE spotter_live.flightaware_id = :id 
891 891
 				AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'";
892 892
 //				AND spotter_live.date < now() AT TIME ZONE 'UTC'";
@@ -895,8 +895,8 @@  discard block
 block discarded – undo
895 895
 		
896 896
 		$sth = $this->db->prepare($query);
897 897
 		$sth->execute($query_data);
898
-		$ident_result='';
899
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
898
+		$ident_result = '';
899
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
900 900
 		{
901 901
 			$ident_result = $row['flightaware_id'];
902 902
 		}
@@ -913,13 +913,13 @@  discard block
 block discarded – undo
913 913
 	{
914 914
 		global $globalDBdriver, $globalTimezone;
915 915
 		if ($globalDBdriver == 'mysql') {
916
-			$query  = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
916
+			$query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
917 917
 				WHERE spotter_live.ModeS = :modes 
918 918
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; 
919 919
 //				AND spotter_live.date < UTC_TIMESTAMP()";
920 920
 			$query_data = array(':modes' => $modes);
921 921
 		} else {
922
-			$query  = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
922
+			$query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
923 923
 				WHERE spotter_live.ModeS = :modes 
924 924
 				AND spotter_live.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '30 MINUTE'";
925 925
 //			//	AND spotter_live.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
@@ -928,8 +928,8 @@  discard block
 block discarded – undo
928 928
 		
929 929
 		$sth = $this->db->prepare($query);
930 930
 		$sth->execute($query_data);
931
-		$ident_result='';
932
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
931
+		$ident_result = '';
932
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
933 933
 		{
934 934
 			//$ident_result = $row['spotter_live_id'];
935 935
 			$ident_result = $row['flightaware_id'];
@@ -948,7 +948,7 @@  discard block
 block discarded – undo
948 948
 	* @return String success or false
949 949
 	*
950 950
 	*/
951
-	public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '',$heading = '', $groundspeed = '', $date = '',$departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false,$registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false,$format_source = '', $source_name = '', $over_country = '')
951
+	public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '', $heading = '', $groundspeed = '', $date = '', $departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false, $registration = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false, $format_source = '', $source_name = '', $over_country = '')
952 952
 	{
953 953
 		global $globalURL, $globalArchive, $globalDebug;
954 954
 		$Common = new Common();
@@ -1048,27 +1048,27 @@  discard block
 block discarded – undo
1048 1048
 		if ($date == '') $date = date("Y-m-d H:i:s", time());
1049 1049
 
1050 1050
         
1051
-		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING);
1052
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
1053
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
1054
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
1055
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
1056
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1057
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1058
-		$waypoints = filter_var($waypoints,FILTER_SANITIZE_STRING);
1059
-		$altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1060
-		$altitude_real = filter_var($altitude_real,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1061
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
1062
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1063
-		$squawk = filter_var($squawk,FILTER_SANITIZE_NUMBER_INT);
1064
-		$route_stop = filter_var($route_stop,FILTER_SANITIZE_STRING);
1065
-		$ModeS = filter_var($ModeS,FILTER_SANITIZE_STRING);
1066
-		$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING);
1067
-		$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
1068
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
1069
-		$source_name = filter_var($source_name,FILTER_SANITIZE_STRING);
1070
-		$over_country = filter_var($over_country,FILTER_SANITIZE_STRING);
1071
-		$verticalrate = filter_var($verticalrate,FILTER_SANITIZE_NUMBER_INT);
1051
+		$flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING);
1052
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1053
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
1054
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
1055
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
1056
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1057
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1058
+		$waypoints = filter_var($waypoints, FILTER_SANITIZE_STRING);
1059
+		$altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1060
+		$altitude_real = filter_var($altitude_real, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1061
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
1062
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1063
+		$squawk = filter_var($squawk, FILTER_SANITIZE_NUMBER_INT);
1064
+		$route_stop = filter_var($route_stop, FILTER_SANITIZE_STRING);
1065
+		$ModeS = filter_var($ModeS, FILTER_SANITIZE_STRING);
1066
+		$pilot_id = filter_var($pilot_id, FILTER_SANITIZE_STRING);
1067
+		$pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
1068
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
1069
+		$source_name = filter_var($source_name, FILTER_SANITIZE_STRING);
1070
+		$over_country = filter_var($over_country, FILTER_SANITIZE_STRING);
1071
+		$verticalrate = filter_var($verticalrate, FILTER_SANITIZE_NUMBER_INT);
1072 1072
 
1073 1073
 		$airline_name = '';
1074 1074
 		$airline_icao = '';
@@ -1090,10 +1090,10 @@  discard block
 block discarded – undo
1090 1090
 		$arrival_airport_country = '';
1091 1091
 		
1092 1092
             	
1093
-            	if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
1094
-            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
1095
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1096
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1093
+            	if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL;
1094
+            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL;
1095
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
1096
+            	if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
1097 1097
 		
1098 1098
 		$query = '';
1099 1099
 		if ($globalArchive) {
@@ -1104,19 +1104,19 @@  discard block
 block discarded – undo
1104 1104
 		$query  .= 'INSERT INTO spotter_live (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop, ModeS, pilot_id, pilot_name, verticalrate, ground, format_source, source_name, over_country, real_altitude) 
1105 1105
 		VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_shadow,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name, :departure_airport_city, :departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date,:departure_airport_time,:arrival_airport_time,:squawk,:route_stop,:ModeS, :pilot_id, :pilot_name, :verticalrate, :ground, :format_source, :source_name, :over_country, :real_altitude)';
1106 1106
 
1107
-		$query_values = array(':flightaware_id' => $flightaware_id,':ident' => $ident, ':registration' => $registration,':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type,':aircraft_icao' => $aircraft_icao,':aircraft_shadow' => $aircraft_shadow,':aircraft_type' => $aircraft_type,':aircraft_manufacturer' => $aircraft_manufacturer,':departure_airport_icao' => $departure_airport_icao,':departure_airport_name' => $departure_airport_name,':departure_airport_city' => $departure_airport_city,':departure_airport_country' => $departure_airport_country,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_name' => $arrival_airport_name,':arrival_airport_city' => $arrival_airport_city,':arrival_airport_country' => $arrival_airport_country,':latitude' => $latitude,':longitude' => $longitude, ':waypoints' => $waypoints,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':departure_airport_time' => $departure_airport_time,':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk,':route_stop' => $route_stop,':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source,':ground' => $ground, ':source_name' => $source_name, ':over_country' => $over_country,':real_altitude' => $altitude_real);
1107
+		$query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_type' => $aircraft_type, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk, ':route_stop' => $route_stop, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':ground' => $ground, ':source_name' => $source_name, ':over_country' => $over_country, ':real_altitude' => $altitude_real);
1108 1108
 		try {
1109 1109
 			
1110 1110
 			$sth = $this->db->prepare($query);
1111 1111
 			$sth->execute($query_values);
1112 1112
 			$sth->closeCursor();
1113
-		} catch(PDOException $e) {
1113
+		} catch (PDOException $e) {
1114 1114
 			return "error : ".$e->getMessage();
1115 1115
 		}
1116 1116
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
1117 1117
 		    if ($globalDebug) echo '(Add to SBS archive : ';
1118 1118
 		    $SpotterArchive = new SpotterArchive($this->db);
1119
-		    $result =  $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country);
1119
+		    $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time, $arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date, $latitude, $longitude, $waypoints, $altitude, $altitude_real, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name, $verticalrate, $format_source, $source_name, $over_country);
1120 1120
 		    if ($globalDebug) echo $result.')';
1121 1121
 		} elseif ($globalDebug && $putinarchive !== true) {
1122 1122
 			echo '(Not adding to archive)';
@@ -1129,7 +1129,7 @@  discard block
 block discarded – undo
1129 1129
 
1130 1130
 	public function getOrderBy()
1131 1131
 	{
1132
-		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_live.date DESC"));
1132
+		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_live.date DESC"));
1133 1133
 		return $orderby;
1134 1134
 	}
1135 1135
 
Please login to merge, or discard this patch.
manufacturer-detailed.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -4,16 +4,16 @@  discard block
 block discarded – undo
4 4
 require_once('require/class.Stats.php');
5 5
 require_once('require/class.Language.php');
6 6
 $Spotter = new Spotter();
7
-if (!isset($_GET['aircraft_manufacturer'])){
7
+if (!isset($_GET['aircraft_manufacturer'])) {
8 8
 	header('Location: '.$globalURL.'');
9 9
 } else {
10 10
 	//calculuation for the pagination
11
-	if(!isset($_GET['limit']))
11
+	if (!isset($_GET['limit']))
12 12
 	{
13 13
 		$limit_start = 0;
14 14
 		$limit_end = 25;
15 15
 		$absolute_difference = 25;
16
-	}  else {
16
+	} else {
17 17
 		$limit_explode = explode(",", $_GET['limit']);
18 18
 		$limit_start = $limit_explode[0];
19 19
 		$limit_end = $limit_explode[1];
@@ -27,19 +27,19 @@  discard block
 block discarded – undo
27 27
 	$limit_previous_1 = $limit_start - $absolute_difference;
28 28
 	$limit_previous_2 = $limit_end - $absolute_difference;
29 29
 	
30
-	$manufacturer = ucwords(str_replace("-", " ", filter_input(INPUT_GET,'aircraft_manufacturer',FILTER_SANITIZE_STRING)));
31
-	$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
30
+	$manufacturer = ucwords(str_replace("-", " ", filter_input(INPUT_GET, 'aircraft_manufacturer', FILTER_SANITIZE_STRING)));
31
+	$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
32 32
 	$page_url = $globalURL.'/manufacturer/'.$manufacturer;
33 33
 	
34 34
 	if ($sort != '') {
35
-		$spotter_array = $Spotter->getSpotterDataByManufacturer($manufacturer,$limit_start.",".$absolute_difference, $sort);
35
+		$spotter_array = $Spotter->getSpotterDataByManufacturer($manufacturer, $limit_start.",".$absolute_difference, $sort);
36 36
 	} else {
37
-		$spotter_array = $Spotter->getSpotterDataByManufacturer($manufacturer,$limit_start.",".$absolute_difference, '');
37
+		$spotter_array = $Spotter->getSpotterDataByManufacturer($manufacturer, $limit_start.",".$absolute_difference, '');
38 38
 	}
39 39
 	
40 40
 	if (!empty($spotter_array))
41 41
 	{
42
-		$title = sprintf(_("Detailed View for %s"),$manufacturer);
42
+		$title = sprintf(_("Detailed View for %s"), $manufacturer);
43 43
 
44 44
 		require_once('header.php');
45 45
 		print '<div class="select-item">';
@@ -48,9 +48,9 @@  discard block
 block discarded – undo
48 48
 		$Stats = new Stats();
49 49
 		$all_manufacturers = $Stats->getAllManufacturers();
50 50
 		if (empty($all_manufacturers)) $all_manufacturers = $Spotter->getAllManufacturers();
51
-		foreach($all_manufacturers as $all_manufacturer)
51
+		foreach ($all_manufacturers as $all_manufacturer)
52 52
 		{
53
-			if($_GET['aircraft_manufacturer'] == strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer'])))
53
+			if ($_GET['aircraft_manufacturer'] == strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer'])))
54 54
 			{
55 55
 				print '<option value="'.strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer'])).'" selected="selected">'.$all_manufacturer['aircraft_manufacturer'].'</option>';
56 56
 			} else {
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 		print '</div>';
68 68
 
69 69
 		print '<div class="table column">';
70
-		print '<p>'.sprintf(_("The table below shows the detailed information of all flights from <strong>%s</strong>."),$manufacturer).'</p>';
70
+		print '<p>'.sprintf(_("The table below shows the detailed information of all flights from <strong>%s</strong>."), $manufacturer).'</p>';
71 71
 
72 72
 		include('manufacturer-sub-menu.php');
73 73
 		include('table-output.php'); 
Please login to merge, or discard this patch.
require/class.Elevation.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 			default:
42 42
 				throw new \Exception("bad resolution can be only one of 1,3");
43 43
 		}
44
-		register_shutdown_function(function () {
44
+		register_shutdown_function(function() {
45 45
 			$this->closeAllFiles();
46 46
 		});
47 47
 	}
@@ -55,10 +55,10 @@  discard block
 block discarded – undo
55 55
 
56 56
 	private function getElevationAtPosition($fileName, $row, $column) {
57 57
 		if (!array_key_exists($fileName, $this->openedFiles)) {
58
-			if (!file_exists($this->htgFilesDestination . DIRECTORY_SEPARATOR . $fileName)) {
58
+			if (!file_exists($this->htgFilesDestination.DIRECTORY_SEPARATOR.$fileName)) {
59 59
 				throw new \Exception("File '{$fileName}' not exists.");
60 60
 			}
61
-			$file = fopen($this->htgFilesDestination . DIRECTORY_SEPARATOR . $fileName, "r");
61
+			$file = fopen($this->htgFilesDestination.DIRECTORY_SEPARATOR.$fileName, "r");
62 62
 			if ($file === false) {
63 63
 				throw new \Exception("Cant open file '{$fileName}' for reading.");
64 64
 			}
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 			throw new \Exception("Not implemented yet");
73 73
 		}
74 74
 		$aRow     = $this->measPerDeg - $row;
75
-		$position = ($this->measPerDeg * ($aRow - 1)) + $column;
75
+		$position = ($this->measPerDeg*($aRow - 1)) + $column;
76 76
 		$position *= 2;
77 77
 		fseek($file, $position);
78 78
 		$short  = fread($file, 2);
@@ -100,8 +100,8 @@  discard block
 block discarded – undo
100 100
 		$latSec = $this->getSec($lat);
101 101
 		$lonSec = $this->getSec($lon);
102 102
 
103
-		$Xn = round($latSec / $this->resolution, 3);
104
-		$Yn = round($lonSec / $this->resolution, 3);
103
+		$Xn = round($latSec/$this->resolution, 3);
104
+		$Yn = round($lonSec/$this->resolution, 3);
105 105
 
106 106
 		$a1 = round($Xn);
107 107
 		$a2 = round($Yn);
@@ -133,55 +133,55 @@  discard block
 block discarded – undo
133 133
 		$b3 = $this->getElevationAtPosition($fName, $b1, $b2);
134 134
 		$c3 = $this->getElevationAtPosition($fName, $c1, $c2);
135 135
 
136
-		$n1 = ($c2 - $a2) * ($b3 - $a3) - ($c3 - $a3) * ($b2 - $a2);
137
-		$n2 = ($c3 - $a3) * ($b1 - $a1) - ($c1 - $a1) * ($b3 - $a3);
138
-		$n3 = ($c1 - $a1) * ($b2 - $a2) - ($c2 - $a2) * ($b1 - $a1);
136
+		$n1 = ($c2 - $a2)*($b3 - $a3) - ($c3 - $a3)*($b2 - $a2);
137
+		$n2 = ($c3 - $a3)*($b1 - $a1) - ($c1 - $a1)*($b3 - $a3);
138
+		$n3 = ($c1 - $a1)*($b2 - $a2) - ($c2 - $a2)*($b1 - $a1);
139 139
 
140
-		$d  = -$n1 * $a1 - $n2 * $a2 - $n3 * $a3;
141
-		$zN = (-$n1 * $Xn - $n2 * $Yn - $d) / $n3;
140
+		$d  = -$n1*$a1 - $n2*$a2 - $n3*$a3;
141
+		$zN = (-$n1*$Xn - $n2*$Yn - $d)/$n3;
142 142
 
143 143
 		return $zN;
144 144
 	}
145 145
 
146 146
 	private function getDeg($deg, $numPrefix) {
147 147
 		$deg = abs($deg);
148
-		$d   = floor($deg);     // round degrees
148
+		$d   = floor($deg); // round degrees
149 149
 		if ($numPrefix >= 3) {
150 150
 			if ($d < 100) {
151
-				$d = '0' . $d;
151
+				$d = '0'.$d;
152 152
 			}
153 153
 		} // pad with leading zeros
154 154
 		if ($d < 10) {
155
-			$d = '0' . $d;
155
+			$d = '0'.$d;
156 156
 		}
157 157
 		return $d;
158 158
 	}
159 159
 
160 160
 	private function getSec($deg) {
161 161
 		$deg = abs($deg);
162
-		$sec = round($deg * 3600, 4);
163
-		$m   = fmod(floor($sec / 60), 60);
162
+		$sec = round($deg*3600, 4);
163
+		$m   = fmod(floor($sec/60), 60);
164 164
 		$s   = round(fmod($sec, 60), 4);
165
-		return ($m * 60) + $s;
165
+		return ($m*60) + $s;
166 166
 	}
167 167
 
168
-	public function download($lat,$lon, $debug = false) {
168
+	public function download($lat, $lon, $debug = false) {
169 169
 		$N      = $this->getDeg($lat, 2);
170 170
 		$E      = $this->getDeg($lon, 3);
171
-		$fileName  = "N{$N}E{$E}.hgt";
172
-		if (!file_exists($this->htgFilesDestination . DIRECTORY_SEPARATOR . $fileName)) {
171
+		$fileName = "N{$N}E{$E}.hgt";
172
+		if (!file_exists($this->htgFilesDestination.DIRECTORY_SEPARATOR.$fileName)) {
173 173
 			$Common = new Common();
174 174
 			if ($debug) echo 'Downloading '.$fileName.'.gz ...';
175
-			$Common->download('https://s3.amazonaws.com/elevation-tiles-prod/skadi/N'.$N.'/'.$fileName.'.gz',$this->htgFilesDestination . DIRECTORY_SEPARATOR . $fileName . '.gz');
176
-			if (!file_exists($this->htgFilesDestination . DIRECTORY_SEPARATOR . $fileName . '.gz')) {
175
+			$Common->download('https://s3.amazonaws.com/elevation-tiles-prod/skadi/N'.$N.'/'.$fileName.'.gz', $this->htgFilesDestination.DIRECTORY_SEPARATOR.$fileName.'.gz');
176
+			if (!file_exists($this->htgFilesDestination.DIRECTORY_SEPARATOR.$fileName.'.gz')) {
177 177
 				if ($debug) echo "File '{$fileName}.gz' not exists.";
178 178
 				return false;
179 179
 			}
180 180
 			if ($debug) echo 'Done'."\n";
181 181
 			if ($debug) echo 'Decompress '.$fileName.' ....';
182
-			$Common->gunzip($this->htgFilesDestination . DIRECTORY_SEPARATOR . $fileName . '.gz',$this->htgFilesDestination . DIRECTORY_SEPARATOR . $fileName);
182
+			$Common->gunzip($this->htgFilesDestination.DIRECTORY_SEPARATOR.$fileName.'.gz', $this->htgFilesDestination.DIRECTORY_SEPARATOR.$fileName);
183 183
 			if ($debug) echo 'Done'."\n";
184
-			unlink($this->htgFilesDestination . DIRECTORY_SEPARATOR . $fileName . '.gz');
184
+			unlink($this->htgFilesDestination.DIRECTORY_SEPARATOR.$fileName.'.gz');
185 185
 		}
186 186
 		return true;
187 187
 	}
@@ -194,11 +194,11 @@  discard block
 block discarded – undo
194 194
 		try {
195 195
 			$sth = $db->prepare($query);
196 196
 			$sth->execute($query_values);
197
-		} catch(PDOException $e) {
197
+		} catch (PDOException $e) {
198 198
 			return "error : ".$e->getMessage();
199 199
 		}
200 200
 		while ($data = $sth->fetch(PDO::FETCH_ASSOC)) {
201
-			$this->download($data['latitude'],$data['longitude'],true);
201
+			$this->download($data['latitude'], $data['longitude'], true);
202 202
 		}
203 203
 		$db = $Connection->db;
204 204
 		$query = 'SELECT latitude, longitude FROM tracker_output WHERE latitude <> 0 AND longitude <> 0 ORDER BY date DESC LIMIT 100';
@@ -206,11 +206,11 @@  discard block
 block discarded – undo
206 206
 		try {
207 207
 			$sth = $db->prepare($query);
208 208
 			$sth->execute($query_values);
209
-		} catch(PDOException $e) {
209
+		} catch (PDOException $e) {
210 210
 			return "error : ".$e->getMessage();
211 211
 		}
212 212
 		while ($data = $sth->fetch(PDO::FETCH_ASSOC)) {
213
-			$this->download($data['latitude'],$data['longitude'],true);
213
+			$this->download($data['latitude'], $data['longitude'], true);
214 214
 		}
215 215
 	}
216 216
 }
Please login to merge, or discard this patch.