Completed
Push — master ( 118bb3...d652ce )
by Yannick
29:38
created
require/class.Tracker.php 1 patch
Spacing   +144 added lines, -144 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 require_once(dirname(__FILE__).'/class.Image.php');
5 5
 $global_query = "SELECT tracker_output.* FROM tracker_output";
6 6
 
7
-class Tracker{
7
+class Tracker {
8 8
 	public $db;
9 9
 	
10 10
 	public function __construct($dbc = null) {
@@ -18,33 +18,33 @@  discard block
 block discarded – undo
18 18
 	* @return Array the SQL part
19 19
 	*/
20 20
 	
21
-	public function getFilter($filter = array(),$where = false,$and = false) {
21
+	public function getFilter($filter = array(), $where = false, $and = false) {
22 22
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
23 23
 		$filters = array();
24 24
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
25 25
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
26 26
 				$filters = $globalStatsFilters[$globalFilterName];
27 27
 			} else {
28
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
28
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
29 29
 			}
30 30
 		}
31 31
 		if (isset($filter[0]['source'])) {
32
-			$filters = array_merge($filters,$filter);
32
+			$filters = array_merge($filters, $filter);
33 33
 		}
34
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
34
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
35 35
 		$filter_query_join = '';
36 36
 		$filter_query_where = '';
37
-		foreach($filters as $flt) {
37
+		foreach ($filters as $flt) {
38 38
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
39 39
 				if (isset($flt['source'])) {
40
-					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spfi ON spfi.famtrackid = tracker_output.famtrackid";
40
+					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spfi ON spfi.famtrackid = tracker_output.famtrackid";
41 41
 				} else {
42
-					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."')) spfi ON spfi.famtrackid = tracker_output.famtrackid";
42
+					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."')) spfi ON spfi.famtrackid = tracker_output.famtrackid";
43 43
 				}
44 44
 			}
45 45
 		}
46 46
 		if (isset($filter['source']) && !empty($filter['source'])) {
47
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
47
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
48 48
 		}
49 49
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
50 50
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
74 74
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
75 75
 		if ($filter_query_where != '') {
76
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
76
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
77 77
 		}
78 78
 		$filter_query = $filter_query_join.$filter_query_where;
79 79
 		return $filter_query;
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 	* @return Array the spotter information
89 89
 	*
90 90
 	*/
91
-	public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false)
91
+	public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false)
92 92
 	{
93 93
 		date_default_timezone_set('UTC');
94 94
 		if (!is_string($query))
@@ -108,13 +108,13 @@  discard block
 block discarded – undo
108 108
 			$sth = $this->db->prepare($query.$limitQuery);
109 109
 			$sth->execute($params);
110 110
 		} catch (PDOException $e) {
111
-			printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery);
111
+			printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery);
112 112
 			exit();
113 113
 		}
114 114
 		
115 115
 		$num_rows = 0;
116 116
 		$spotter_array = array();
117
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
117
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
118 118
 		{
119 119
 			$num_rows++;
120 120
 			$temp_array = array();
@@ -170,17 +170,17 @@  discard block
 block discarded – undo
170 170
 				{
171 171
 					$temp_array['date'] = "about ".$dateArray['hours']." hours ago";
172 172
 				} else {
173
-					$temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC"));
173
+					$temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC"));
174 174
 				}
175 175
 				$temp_array['date_minutes_past'] = $dateArray['minutes'];
176
-				$temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC"));
177
-				$temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC"));
176
+				$temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC"));
177
+				$temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC"));
178 178
 				$temp_array['date_unix'] = strtotime($row['date']." UTC");
179 179
 				if (isset($row['last_seen']) && $row['last_seen'] != '') {
180 180
 					if (strtotime($row['last_seen']) > strtotime($row['date'])) {
181 181
 						$temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']);
182
-						$temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC"));
183
-						$temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC"));
182
+						$temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC"));
183
+						$temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC"));
184 184
 						$temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC");
185 185
 					}
186 186
 				}
@@ -217,8 +217,8 @@  discard block
 block discarded – undo
217 217
 		{
218 218
 			$limit_array = explode(",", $limit);
219 219
 			
220
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
221
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
220
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
221
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
222 222
 			
223 223
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
224 224
 			{
@@ -235,9 +235,9 @@  discard block
 block discarded – undo
235 235
 			$orderby_query = " ORDER BY tracker_output.date DESC";
236 236
 		}
237 237
 
238
-		$query  = $global_query.$filter_query." ".$orderby_query;
238
+		$query = $global_query.$filter_query." ".$orderby_query;
239 239
 
240
-		$spotter_array = $this->getDataFromDB($query, array(),$limit_query,true);
240
+		$spotter_array = $this->getDataFromDB($query, array(), $limit_query, true);
241 241
 
242 242
 		return $spotter_array;
243 243
 	}
@@ -256,8 +256,8 @@  discard block
 block discarded – undo
256 256
 		if ($id == '') return array();
257 257
 		$additional_query = "tracker_output.famtrackid = :id";
258 258
 		$query_values = array(':id' => $id);
259
-		$query  = $global_query." WHERE ".$additional_query." ";
260
-		$spotter_array = $this->getDataFromDB($query,$query_values);
259
+		$query = $global_query." WHERE ".$additional_query." ";
260
+		$spotter_array = $this->getDataFromDB($query, $query_values);
261 261
 		return $spotter_array;
262 262
 	}
263 263
 
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 		$query_values = array();
277 277
 		$limit_query = '';
278 278
 		$additional_query = '';
279
-		$filter_query = $this->getFilter($filter,true,true);
279
+		$filter_query = $this->getFilter($filter, true, true);
280 280
 		if ($ident != "")
281 281
 		{
282 282
 			if (!is_string($ident))
@@ -292,8 +292,8 @@  discard block
 block discarded – undo
292 292
 		{
293 293
 			$limit_array = explode(",", $limit);
294 294
 			
295
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
296
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
295
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
296
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
297 297
 			
298 298
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
299 299
 			{
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 		return $spotter_array;
318 318
 	}
319 319
 	
320
-	public function getTrackerDataByDate($date = '', $limit = '', $sort = '',$filter = array())
320
+	public function getTrackerDataByDate($date = '', $limit = '', $sort = '', $filter = array())
321 321
 	{
322 322
 		global $global_query, $globalTimezone, $globalDBdriver;
323 323
 		
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
 		$limit_query = '';
326 326
 		$additional_query = '';
327 327
 
328
-		$filter_query = $this->getFilter($filter,true,true);
328
+		$filter_query = $this->getFilter($filter, true, true);
329 329
 		
330 330
 		if ($date != "")
331 331
 		{
@@ -351,8 +351,8 @@  discard block
 block discarded – undo
351 351
 		{
352 352
 			$limit_array = explode(",", $limit);
353 353
 			
354
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
355
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
354
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
355
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
356 356
 			
357 357
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
358 358
 			{
@@ -383,11 +383,11 @@  discard block
 block discarded – undo
383 383
 	* @return Array list of source name
384 384
 	*
385 385
 	*/
386
-	public function getAllSourceName($type = '',$filters = array())
386
+	public function getAllSourceName($type = '', $filters = array())
387 387
 	{
388
-		$filter_query = $this->getFilter($filters,true,true);
388
+		$filter_query = $this->getFilter($filters, true, true);
389 389
 		$query_values = array();
390
-		$query  = "SELECT DISTINCT tracker_output.source_name 
390
+		$query = "SELECT DISTINCT tracker_output.source_name 
391 391
 				FROM tracker_output".$filter_query." tracker_output.source_name <> ''";
392 392
 		if ($type != '') {
393 393
 			$query_values = array(':type' => $type);
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
 		$source_array = array();
403 403
 		$temp_array = array();
404 404
 		
405
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
405
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
406 406
 		{
407 407
 			$temp_array['source_name'] = $row['source_name'];
408 408
 			$source_array[] = $temp_array;
@@ -419,8 +419,8 @@  discard block
 block discarded – undo
419 419
 	*/
420 420
 	public function getAllIdents($filters = array())
421 421
 	{
422
-		$filter_query = $this->getFilter($filters,true,true);
423
-		$query  = "SELECT DISTINCT tracker_output.ident
422
+		$filter_query = $this->getFilter($filters, true, true);
423
+		$query = "SELECT DISTINCT tracker_output.ident
424 424
 								FROM tracker_output".$filter_query." tracker_output.ident <> '' 
425 425
 								ORDER BY tracker_output.date ASC LIMIT 700 OFFSET 0";
426 426
 
@@ -430,7 +430,7 @@  discard block
 block discarded – undo
430 430
 		$ident_array = array();
431 431
 		$temp_array = array();
432 432
 		
433
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
433
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
434 434
 		{
435 435
 			$temp_array['ident'] = $row['ident'];
436 436
 			$ident_array[] = $temp_array;
@@ -455,12 +455,12 @@  discard block
 block discarded – undo
455 455
 		} else $offset = '+00:00';
456 456
 
457 457
 		if ($globalDBdriver == 'mysql') {
458
-			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) as date
458
+			$query = "SELECT DISTINCT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) as date
459 459
 								FROM tracker_output
460 460
 								WHERE tracker_output.date <> '' 
461 461
 								ORDER BY tracker_output.date ASC LIMIT 0,200";
462 462
 		} else {
463
-			$query  = "SELECT DISTINCT to_char(tracker_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
463
+			$query = "SELECT DISTINCT to_char(tracker_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
464 464
 								FROM tracker_output
465 465
 								WHERE tracker_output.date <> '' 
466 466
 								ORDER BY tracker_output.date ASC LIMIT 0,200";
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
 		$date_array = array();
473 473
 		$temp_array = array();
474 474
 		
475
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
475
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
476 476
 		{
477 477
 			$temp_array['date'] = $row['date'];
478 478
 
@@ -491,11 +491,11 @@  discard block
 block discarded – undo
491 491
 	* @return String success or false
492 492
 	*
493 493
 	*/	
494
-	public function updateIdentTrackerData($famtrackid = '', $ident = '',$fromsource = NULL)
494
+	public function updateIdentTrackerData($famtrackid = '', $ident = '', $fromsource = NULL)
495 495
 	{
496 496
 
497 497
 		$query = 'UPDATE tracker_output SET ident = :ident WHERE famtrackid = :famtrackid';
498
-                $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident);
498
+                $query_values = array(':famtrackid' => $famtrackid, ':ident' => $ident);
499 499
 
500 500
 		try {
501 501
 			$sth = $this->db->prepare($query);
@@ -519,7 +519,7 @@  discard block
 block discarded – undo
519 519
 	public function updateLatestTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $groundspeed = NULL, $date = '')
520 520
 	{
521 521
 		$query = 'UPDATE tracker_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_altitude = :last_altitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE famtrackid = :famtrackid';
522
-                $query_values = array(':famtrackid' => $famtrackid,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_altitude' => $altitude,':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident);
522
+                $query_values = array(':famtrackid' => $famtrackid, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_altitude' => $altitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident);
523 523
 
524 524
 		try {
525 525
 			$sth = $this->db->prepare($query);
@@ -559,7 +559,7 @@  discard block
 block discarded – undo
559 559
 	* @param String $verticalrate vertival rate of flight
560 560
 	* @return String success or false
561 561
 	*/
562
-	public function addTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $comment = '', $type = '',$format_source = '', $source_name = '')
562
+	public function addTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $comment = '', $type = '', $format_source = '', $source_name = '')
563 563
 	{
564 564
 		global $globalURL;
565 565
 		
@@ -627,21 +627,21 @@  discard block
 block discarded – undo
627 627
 		}
628 628
 
629 629
     
630
-		if ($date == "" || strtotime($date) < time()-20*60)
630
+		if ($date == "" || strtotime($date) < time() - 20*60)
631 631
 		{
632 632
 			$date = date("Y-m-d H:i:s", time());
633 633
 		}
634 634
 
635
-		$famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING);
636
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
637
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
638
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
639
-		$altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
640
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
641
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
642
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
643
-		$comment = filter_var($comment,FILTER_SANITIZE_STRING);
644
-		$type = filter_var($type,FILTER_SANITIZE_STRING);
635
+		$famtrackid = filter_var($famtrackid, FILTER_SANITIZE_STRING);
636
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
637
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
638
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
639
+		$altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
640
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
641
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
642
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
643
+		$comment = filter_var($comment, FILTER_SANITIZE_STRING);
644
+		$type = filter_var($type, FILTER_SANITIZE_STRING);
645 645
 	
646 646
                 if ($latitude == '' && $longitude == '') {
647 647
             		$latitude = 0;
@@ -649,10 +649,10 @@  discard block
 block discarded – undo
649 649
             	}
650 650
                 if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
651 651
                 if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
652
-                $query  = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) 
652
+                $query = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) 
653 653
                 VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:speed,:date,:format_source, :source_name,:comment,:type)";
654 654
 
655
-                $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':altitude' => $altitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':comment' => $comment,':type' => $type);
655
+                $query_values = array(':famtrackid' => $famtrackid, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':heading' => $heading, ':speed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':comment' => $comment, ':type' => $type);
656 656
 
657 657
 		try {
658 658
 		        
@@ -678,13 +678,13 @@  discard block
 block discarded – undo
678 678
 	{
679 679
 		global $globalDBdriver, $globalTimezone;
680 680
 		if ($globalDBdriver == 'mysql') {
681
-			$query  = "SELECT tracker_output.ident FROM tracker_output 
681
+			$query = "SELECT tracker_output.ident FROM tracker_output 
682 682
 								WHERE tracker_output.ident = :ident 
683 683
 								AND tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
684 684
 								AND tracker_output.date < UTC_TIMESTAMP()";
685 685
 			$query_data = array(':ident' => $ident);
686 686
 		} else {
687
-			$query  = "SELECT tracker_output.ident FROM tracker_output 
687
+			$query = "SELECT tracker_output.ident FROM tracker_output 
688 688
 								WHERE tracker_output.ident = :ident 
689 689
 								AND tracker_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
690 690
 								AND tracker_output.date < now() AT TIME ZONE 'UTC'";
@@ -693,8 +693,8 @@  discard block
 block discarded – undo
693 693
 		
694 694
 		$sth = $this->db->prepare($query);
695 695
 		$sth->execute($query_data);
696
-    		$ident_result='';
697
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
696
+    		$ident_result = '';
697
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
698 698
 		{
699 699
 			$ident_result = $row['ident'];
700 700
 		}
@@ -720,8 +720,8 @@  discard block
 block discarded – undo
720 720
 				return false;
721 721
 			} else {
722 722
 				$q_array = explode(" ", $q);
723
-				foreach ($q_array as $q_item){
724
-					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
723
+				foreach ($q_array as $q_item) {
724
+					$q_item = filter_var($q_item, FILTER_SANITIZE_STRING);
725 725
 					$additional_query .= " AND (";
726 726
 					$additional_query .= "(tracker_output.ident like '%".$q_item."%')";
727 727
 					$additional_query .= ")";
@@ -729,11 +729,11 @@  discard block
 block discarded – undo
729 729
 			}
730 730
 		}
731 731
 		if ($globalDBdriver == 'mysql') {
732
-			$query  = "SELECT tracker_output.* FROM tracker_output 
732
+			$query = "SELECT tracker_output.* FROM tracker_output 
733 733
 				WHERE tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." 
734 734
 				AND tracker_output.date < UTC_TIMESTAMP()";
735 735
 		} else {
736
-			$query  = "SELECT tracker_output.* FROM tracker_output 
736
+			$query = "SELECT tracker_output.* FROM tracker_output 
737 737
 				WHERE tracker_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." 
738 738
 				AND tracker_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
739 739
 		}
@@ -752,16 +752,16 @@  discard block
 block discarded – undo
752 752
 	*
753 753
 	*/
754 754
 
755
-	public function countAllTrackerOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
755
+	public function countAllTrackerOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
756 756
 	{
757 757
 		global $globalDBdriver, $globalArchive;
758 758
 		//$filter_query = $this->getFilter($filters,true,true);
759
-		$Connection= new Connection($this->db);
759
+		$Connection = new Connection($this->db);
760 760
 		if (!$Connection->tableExists('countries')) return array();
761 761
 		if (!isset($globalArchive) || $globalArchive !== TRUE) {
762 762
 			require_once('class.TrackerLive.php');
763 763
 			$TrackerLive = new TrackerLive();
764
-			$filter_query = $TrackerLive->getFilter($filters,true,true);
764
+			$filter_query = $TrackerLive->getFilter($filters, true, true);
765 765
 			$filter_query .= ' over_country IS NOT NULL';
766 766
 			if ($olderthanmonths > 0) {
767 767
 				if ($globalDBdriver == 'mysql') {
@@ -781,7 +781,7 @@  discard block
 block discarded – undo
781 781
 		} else {
782 782
 			require_once('class.TrackerArchive.php');
783 783
 			$TrackerArchive = new TrackerArchive();
784
-			$filter_query = $TrackerArchive->getFilter($filters,true,true);
784
+			$filter_query = $TrackerArchive->getFilter($filters, true, true);
785 785
 			$filter_query .= ' over_country IS NOT NULL';
786 786
 			if ($olderthanmonths > 0) {
787 787
 				if ($globalDBdriver == 'mysql') {
@@ -809,7 +809,7 @@  discard block
 block discarded – undo
809 809
 		$flight_array = array();
810 810
 		$temp_array = array();
811 811
         
812
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
812
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
813 813
 		{
814 814
 			$temp_array['flight_count'] = $row['nb'];
815 815
 			$temp_array['flight_country'] = $row['name'];
@@ -826,11 +826,11 @@  discard block
 block discarded – undo
826 826
 	* @return Array the callsign list
827 827
 	*
828 828
 	*/
829
-	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
829
+	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
830 830
 	{
831 831
 		global $globalDBdriver;
832
-		$filter_query = $this->getFilter($filters,true,true);
833
-		$query  = "SELECT DISTINCT tracker_output.ident, COUNT(tracker_output.ident) AS callsign_icao_count 
832
+		$filter_query = $this->getFilter($filters, true, true);
833
+		$query = "SELECT DISTINCT tracker_output.ident, COUNT(tracker_output.ident) AS callsign_icao_count 
834 834
                     FROM tracker_output".$filter_query." tracker_output.ident <> ''";
835 835
 		 if ($olderthanmonths > 0) {
836 836
 			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
@@ -844,28 +844,28 @@  discard block
 block discarded – undo
844 844
 		if ($year != '') {
845 845
 			if ($globalDBdriver == 'mysql') {
846 846
 				$query .= " AND YEAR(tracker_output.date) = :year";
847
-				$query_values = array_merge($query_values,array(':year' => $year));
847
+				$query_values = array_merge($query_values, array(':year' => $year));
848 848
 			} else {
849 849
 				$query .= " AND EXTRACT(YEAR FROM tracker_output.date) = :year";
850
-				$query_values = array_merge($query_values,array(':year' => $year));
850
+				$query_values = array_merge($query_values, array(':year' => $year));
851 851
 			}
852 852
 		}
853 853
 		if ($month != '') {
854 854
 			if ($globalDBdriver == 'mysql') {
855 855
 				$query .= " AND MONTH(tracker_output.date) = :month";
856
-				$query_values = array_merge($query_values,array(':month' => $month));
856
+				$query_values = array_merge($query_values, array(':month' => $month));
857 857
 			} else {
858 858
 				$query .= " AND EXTRACT(MONTH FROM tracker_output.date) = :month";
859
-				$query_values = array_merge($query_values,array(':month' => $month));
859
+				$query_values = array_merge($query_values, array(':month' => $month));
860 860
 			}
861 861
 		}
862 862
 		if ($day != '') {
863 863
 			if ($globalDBdriver == 'mysql') {
864 864
 				$query .= " AND DAY(tracker_output.date) = :day";
865
-				$query_values = array_merge($query_values,array(':day' => $day));
865
+				$query_values = array_merge($query_values, array(':day' => $day));
866 866
 			} else {
867 867
 				$query .= " AND EXTRACT(DAY FROM tracker_output.date) = :day";
868
-				$query_values = array_merge($query_values,array(':day' => $day));
868
+				$query_values = array_merge($query_values, array(':day' => $day));
869 869
 			}
870 870
 		}
871 871
 		$query .= " GROUP BY tracker_output.ident ORDER BY callsign_icao_count DESC";
@@ -877,7 +877,7 @@  discard block
 block discarded – undo
877 877
 		$callsign_array = array();
878 878
 		$temp_array = array();
879 879
         
880
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
880
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
881 881
 		{
882 882
 			$temp_array['callsign_icao'] = $row['ident'];
883 883
 			$temp_array['airline_name'] = $row['airline_name'];
@@ -929,7 +929,7 @@  discard block
 block discarded – undo
929 929
 		$date_array = array();
930 930
 		$temp_array = array();
931 931
         
932
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
932
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
933 933
 		{
934 934
 			$temp_array['date_name'] = $row['date_name'];
935 935
 			$temp_array['date_count'] = $row['date_count'];
@@ -955,7 +955,7 @@  discard block
 block discarded – undo
955 955
 			$datetime = new DateTime();
956 956
 			$offset = $datetime->format('P');
957 957
 		} else $offset = '+00:00';
958
-		$filter_query = $this->getFilter($filters,true,true);
958
+		$filter_query = $this->getFilter($filters, true, true);
959 959
 		if ($globalDBdriver == 'mysql') {
960 960
 			$query  = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
961 961
 								FROM tracker_output".$filter_query." tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)";
@@ -976,7 +976,7 @@  discard block
 block discarded – undo
976 976
 		$date_array = array();
977 977
 		$temp_array = array();
978 978
         
979
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
979
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
980 980
 		{
981 981
 			$temp_array['date_name'] = $row['date_name'];
982 982
 			$temp_array['date_count'] = $row['date_count'];
@@ -1001,7 +1001,7 @@  discard block
 block discarded – undo
1001 1001
 			$datetime = new DateTime();
1002 1002
 			$offset = $datetime->format('P');
1003 1003
 		} else $offset = '+00:00';
1004
-		$filter_query = $this->getFilter($filters,true,true);
1004
+		$filter_query = $this->getFilter($filters, true, true);
1005 1005
 		if ($globalDBdriver == 'mysql') {
1006 1006
 			$query  = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
1007 1007
 								FROM tracker_output".$filter_query." tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)";
@@ -1022,7 +1022,7 @@  discard block
 block discarded – undo
1022 1022
 		$date_array = array();
1023 1023
 		$temp_array = array();
1024 1024
         
1025
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1025
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1026 1026
 		{
1027 1027
 			$temp_array['date_name'] = $row['date_name'];
1028 1028
 			$temp_array['date_count'] = $row['date_count'];
@@ -1069,7 +1069,7 @@  discard block
 block discarded – undo
1069 1069
 		$date_array = array();
1070 1070
 		$temp_array = array();
1071 1071
         
1072
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1072
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1073 1073
 		{
1074 1074
 			$temp_array['month_name'] = $row['month_name'];
1075 1075
 			$temp_array['year_name'] = $row['year_name'];
@@ -1098,7 +1098,7 @@  discard block
 block discarded – undo
1098 1098
 			$datetime = new DateTime();
1099 1099
 			$offset = $datetime->format('P');
1100 1100
 		} else $offset = '+00:00';
1101
-		$filter_query = $this->getFilter($filters,true,true);
1101
+		$filter_query = $this->getFilter($filters, true, true);
1102 1102
 		if ($globalDBdriver == 'mysql') {
1103 1103
 			$query  = "SELECT MONTH(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count
1104 1104
 								FROM tracker_output".$filter_query." tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)";
@@ -1119,7 +1119,7 @@  discard block
 block discarded – undo
1119 1119
 		$date_array = array();
1120 1120
 		$temp_array = array();
1121 1121
         
1122
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1122
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1123 1123
 		{
1124 1124
 			$temp_array['year_name'] = $row['year_name'];
1125 1125
 			$temp_array['month_name'] = $row['month_name'];
@@ -1139,7 +1139,7 @@  discard block
 block discarded – undo
1139 1139
 	* @return Array the hour list
1140 1140
 	*
1141 1141
 	*/
1142
-	public function countAllHours($orderby,$filters = array())
1142
+	public function countAllHours($orderby, $filters = array())
1143 1143
 	{
1144 1144
 		global $globalTimezone, $globalDBdriver;
1145 1145
 		if ($globalTimezone != '') {
@@ -1187,7 +1187,7 @@  discard block
 block discarded – undo
1187 1187
 		$hour_array = array();
1188 1188
 		$temp_array = array();
1189 1189
         
1190
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1190
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1191 1191
 		{
1192 1192
 			$temp_array['hour_name'] = $row['hour_name'];
1193 1193
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1209,8 +1209,8 @@  discard block
 block discarded – undo
1209 1209
 	public function countAllHoursByDate($date, $filters = array())
1210 1210
 	{
1211 1211
 		global $globalTimezone, $globalDBdriver;
1212
-		$filter_query = $this->getFilter($filters,true,true);
1213
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
1212
+		$filter_query = $this->getFilter($filters, true, true);
1213
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
1214 1214
 		if ($globalTimezone != '') {
1215 1215
 			date_default_timezone_set($globalTimezone);
1216 1216
 			$datetime = new DateTime($date);
@@ -1218,12 +1218,12 @@  discard block
 block discarded – undo
1218 1218
 		} else $offset = '+00:00';
1219 1219
 
1220 1220
 		if ($globalDBdriver == 'mysql') {
1221
-			$query  = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1221
+			$query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1222 1222
 								FROM tracker_output".$filter_query." DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) = :date
1223 1223
 								GROUP BY hour_name 
1224 1224
 								ORDER BY hour_name ASC";
1225 1225
 		} else {
1226
-			$query  = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1226
+			$query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1227 1227
 								FROM tracker_output".$filter_query." to_char(tracker_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date
1228 1228
 								GROUP BY hour_name 
1229 1229
 								ORDER BY hour_name ASC";
@@ -1235,7 +1235,7 @@  discard block
 block discarded – undo
1235 1235
 		$hour_array = array();
1236 1236
 		$temp_array = array();
1237 1237
         
1238
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1238
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1239 1239
 		{
1240 1240
 			$temp_array['hour_name'] = $row['hour_name'];
1241 1241
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1257,8 +1257,8 @@  discard block
 block discarded – undo
1257 1257
 	public function countAllHoursByIdent($ident, $filters = array())
1258 1258
 	{
1259 1259
 		global $globalTimezone, $globalDBdriver;
1260
-		$filter_query = $this->getFilter($filters,true,true);
1261
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
1260
+		$filter_query = $this->getFilter($filters, true, true);
1261
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1262 1262
 		if ($globalTimezone != '') {
1263 1263
 			date_default_timezone_set($globalTimezone);
1264 1264
 			$datetime = new DateTime();
@@ -1266,12 +1266,12 @@  discard block
 block discarded – undo
1266 1266
 		} else $offset = '+00:00';
1267 1267
 
1268 1268
 		if ($globalDBdriver == 'mysql') {
1269
-			$query  = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1269
+			$query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1270 1270
 								FROM tracker_output".$filter_query." tracker_output.ident = :ident 
1271 1271
 								GROUP BY hour_name 
1272 1272
 								ORDER BY hour_name ASC";
1273 1273
 		} else {
1274
-			$query  = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1274
+			$query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1275 1275
 								FROM tracker_output".$filter_query." tracker_output.ident = :ident 
1276 1276
 								GROUP BY hour_name 
1277 1277
 								ORDER BY hour_name ASC";
@@ -1279,12 +1279,12 @@  discard block
 block discarded – undo
1279 1279
       
1280 1280
 		
1281 1281
 		$sth = $this->db->prepare($query);
1282
-		$sth->execute(array(':ident' => $ident,':offset' => $offset));
1282
+		$sth->execute(array(':ident' => $ident, ':offset' => $offset));
1283 1283
       
1284 1284
 		$hour_array = array();
1285 1285
 		$temp_array = array();
1286 1286
         
1287
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1287
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1288 1288
 		{
1289 1289
 			$temp_array['hour_name'] = $row['hour_name'];
1290 1290
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1303,33 +1303,33 @@  discard block
 block discarded – undo
1303 1303
 	* @return Integer the number of flights
1304 1304
 	*
1305 1305
 	*/
1306
-	public function countOverallTracker($filters = array(),$year = '',$month = '')
1306
+	public function countOverallTracker($filters = array(), $year = '', $month = '')
1307 1307
 	{
1308 1308
 		global $globalDBdriver;
1309 1309
 		//$queryi  = "SELECT COUNT(tracker_output.tracker_id) AS flight_count FROM tracker_output";
1310
-		$queryi  = "SELECT COUNT(DISTINCT tracker_output.ident) AS flight_count FROM tracker_output";
1310
+		$queryi = "SELECT COUNT(DISTINCT tracker_output.ident) AS flight_count FROM tracker_output";
1311 1311
 		$query_values = array();
1312 1312
 		$query = '';
1313 1313
 		if ($year != '') {
1314 1314
 			if ($globalDBdriver == 'mysql') {
1315 1315
 				$query .= " AND YEAR(tracker_output.date) = :year";
1316
-				$query_values = array_merge($query_values,array(':year' => $year));
1316
+				$query_values = array_merge($query_values, array(':year' => $year));
1317 1317
 			} else {
1318 1318
 				$query .= " AND EXTRACT(YEAR FROM tracker_output.date) = :year";
1319
-				$query_values = array_merge($query_values,array(':year' => $year));
1319
+				$query_values = array_merge($query_values, array(':year' => $year));
1320 1320
 			}
1321 1321
 		}
1322 1322
 		if ($month != '') {
1323 1323
 			if ($globalDBdriver == 'mysql') {
1324 1324
 				$query .= " AND MONTH(tracker_output.date) = :month";
1325
-				$query_values = array_merge($query_values,array(':month' => $month));
1325
+				$query_values = array_merge($query_values, array(':month' => $month));
1326 1326
 			} else {
1327 1327
 				$query .= " AND EXTRACT(MONTH FROM tracker_output.date) = :month";
1328
-				$query_values = array_merge($query_values,array(':month' => $month));
1328
+				$query_values = array_merge($query_values, array(':month' => $month));
1329 1329
 			}
1330 1330
 		}
1331 1331
 		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1332
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1332
+		else $queryi .= $this->getFilter($filters, true, true).substr($query, 4);
1333 1333
 		
1334 1334
 		$sth = $this->db->prepare($queryi);
1335 1335
 		$sth->execute($query_values);
@@ -1346,7 +1346,7 @@  discard block
 block discarded – undo
1346 1346
 	public function countAllHoursFromToday($filters = array())
1347 1347
 	{
1348 1348
 		global $globalTimezone, $globalDBdriver;
1349
-		$filter_query = $this->getFilter($filters,true,true);
1349
+		$filter_query = $this->getFilter($filters, true, true);
1350 1350
 		if ($globalTimezone != '') {
1351 1351
 			date_default_timezone_set($globalTimezone);
1352 1352
 			$datetime = new DateTime();
@@ -1354,12 +1354,12 @@  discard block
 block discarded – undo
1354 1354
 		} else $offset = '+00:00';
1355 1355
 
1356 1356
 		if ($globalDBdriver == 'mysql') {
1357
-			$query  = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1357
+			$query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1358 1358
 								FROM tracker_output".$filter_query." DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) = CURDATE()
1359 1359
 								GROUP BY hour_name 
1360 1360
 								ORDER BY hour_name ASC";
1361 1361
 		} else {
1362
-			$query  = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1362
+			$query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1363 1363
 								FROM tracker_output".$filter_query." to_char(tracker_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date)
1364 1364
 								GROUP BY hour_name 
1365 1365
 								ORDER BY hour_name ASC";
@@ -1371,7 +1371,7 @@  discard block
 block discarded – undo
1371 1371
 		$hour_array = array();
1372 1372
 		$temp_array = array();
1373 1373
         
1374
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1374
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1375 1375
 		{
1376 1376
 			$temp_array['hour_name'] = $row['hour_name'];
1377 1377
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1390,9 +1390,9 @@  discard block
 block discarded – undo
1390 1390
 	*/
1391 1391
 	public function getTrackerIDBasedOnFamTrackID($famtrackid)
1392 1392
 	{
1393
-		$famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING);
1393
+		$famtrackid = filter_var($famtrackid, FILTER_SANITIZE_STRING);
1394 1394
 
1395
-		$query  = "SELECT tracker_output.tracker_id
1395
+		$query = "SELECT tracker_output.tracker_id
1396 1396
 				FROM tracker_output 
1397 1397
 				WHERE tracker_output.famtrackid = '".$famtrackid."'";
1398 1398
         
@@ -1400,7 +1400,7 @@  discard block
 block discarded – undo
1400 1400
 		$sth = $this->db->prepare($query);
1401 1401
 		$sth->execute();
1402 1402
 
1403
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1403
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1404 1404
 		{
1405 1405
 			return $row['tracker_id'];
1406 1406
 		}
@@ -1425,23 +1425,23 @@  discard block
 block discarded – undo
1425 1425
 		}
1426 1426
 		
1427 1427
 		$current_date = date("Y-m-d H:i:s");
1428
-		$date = date("Y-m-d H:i:s",strtotime($dateString." UTC"));
1428
+		$date = date("Y-m-d H:i:s", strtotime($dateString." UTC"));
1429 1429
 		
1430 1430
 		$diff = abs(strtotime($current_date) - strtotime($date));
1431 1431
 
1432
-		$time_array['years'] = floor($diff / (365*60*60*24)); 
1432
+		$time_array['years'] = floor($diff/(365*60*60*24)); 
1433 1433
 		$years = $time_array['years'];
1434 1434
 		
1435
-		$time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
1435
+		$time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24));
1436 1436
 		$months = $time_array['months'];
1437 1437
 		
1438
-		$time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
1438
+		$time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24));
1439 1439
 		$days = $time_array['days'];
1440
-		$time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60));
1440
+		$time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60));
1441 1441
 		$hours = $time_array['hours'];
1442
-		$time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60);
1442
+		$time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60);
1443 1443
 		$minutes = $time_array['minutes'];
1444
-		$time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
1444
+		$time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
1445 1445
 		
1446 1446
 		return $time_array;
1447 1447
 	}
@@ -1464,63 +1464,63 @@  discard block
 block discarded – undo
1464 1464
 			$temp_array['direction_degree'] = $direction;
1465 1465
 			$temp_array['direction_shortname'] = "N";
1466 1466
 			$temp_array['direction_fullname'] = "North";
1467
-		} elseif ($direction >= 22.5 && $direction < 45){
1467
+		} elseif ($direction >= 22.5 && $direction < 45) {
1468 1468
 			$temp_array['direction_degree'] = $direction;
1469 1469
 			$temp_array['direction_shortname'] = "NNE";
1470 1470
 			$temp_array['direction_fullname'] = "North-Northeast";
1471
-		} elseif ($direction >= 45 && $direction < 67.5){
1471
+		} elseif ($direction >= 45 && $direction < 67.5) {
1472 1472
 			$temp_array['direction_degree'] = $direction;
1473 1473
 			$temp_array['direction_shortname'] = "NE";
1474 1474
 			$temp_array['direction_fullname'] = "Northeast";
1475
-		} elseif ($direction >= 67.5 && $direction < 90){
1475
+		} elseif ($direction >= 67.5 && $direction < 90) {
1476 1476
 			$temp_array['direction_degree'] = $direction;
1477 1477
 			$temp_array['direction_shortname'] = "ENE";
1478 1478
 			$temp_array['direction_fullname'] = "East-Northeast";
1479
-		} elseif ($direction >= 90 && $direction < 112.5){
1479
+		} elseif ($direction >= 90 && $direction < 112.5) {
1480 1480
 			$temp_array['direction_degree'] = $direction;
1481 1481
 			$temp_array['direction_shortname'] = "E";
1482 1482
 			$temp_array['direction_fullname'] = "East";
1483
-		} elseif ($direction >= 112.5 && $direction < 135){
1483
+		} elseif ($direction >= 112.5 && $direction < 135) {
1484 1484
 			$temp_array['direction_degree'] = $direction;
1485 1485
 			$temp_array['direction_shortname'] = "ESE";
1486 1486
 			$temp_array['direction_fullname'] = "East-Southeast";
1487
-		} elseif ($direction >= 135 && $direction < 157.5){
1487
+		} elseif ($direction >= 135 && $direction < 157.5) {
1488 1488
 			$temp_array['direction_degree'] = $direction;
1489 1489
 			$temp_array['direction_shortname'] = "SE";
1490 1490
 			$temp_array['direction_fullname'] = "Southeast";
1491
-		} elseif ($direction >= 157.5 && $direction < 180){
1491
+		} elseif ($direction >= 157.5 && $direction < 180) {
1492 1492
 			$temp_array['direction_degree'] = $direction;
1493 1493
 			$temp_array['direction_shortname'] = "SSE";
1494 1494
 			$temp_array['direction_fullname'] = "South-Southeast";
1495
-		} elseif ($direction >= 180 && $direction < 202.5){
1495
+		} elseif ($direction >= 180 && $direction < 202.5) {
1496 1496
 			$temp_array['direction_degree'] = $direction;
1497 1497
 			$temp_array['direction_shortname'] = "S";
1498 1498
 			$temp_array['direction_fullname'] = "South";
1499
-		} elseif ($direction >= 202.5 && $direction < 225){
1499
+		} elseif ($direction >= 202.5 && $direction < 225) {
1500 1500
 			$temp_array['direction_degree'] = $direction;
1501 1501
 			$temp_array['direction_shortname'] = "SSW";
1502 1502
 			$temp_array['direction_fullname'] = "South-Southwest";
1503
-		} elseif ($direction >= 225 && $direction < 247.5){
1503
+		} elseif ($direction >= 225 && $direction < 247.5) {
1504 1504
 			$temp_array['direction_degree'] = $direction;
1505 1505
 			$temp_array['direction_shortname'] = "SW";
1506 1506
 			$temp_array['direction_fullname'] = "Southwest";
1507
-		} elseif ($direction >= 247.5 && $direction < 270){
1507
+		} elseif ($direction >= 247.5 && $direction < 270) {
1508 1508
 			$temp_array['direction_degree'] = $direction;
1509 1509
 			$temp_array['direction_shortname'] = "WSW";
1510 1510
 			$temp_array['direction_fullname'] = "West-Southwest";
1511
-		} elseif ($direction >= 270 && $direction < 292.5){
1511
+		} elseif ($direction >= 270 && $direction < 292.5) {
1512 1512
 			$temp_array['direction_degree'] = $direction;
1513 1513
 			$temp_array['direction_shortname'] = "W";
1514 1514
 			$temp_array['direction_fullname'] = "West";
1515
-		} elseif ($direction >= 292.5 && $direction < 315){
1515
+		} elseif ($direction >= 292.5 && $direction < 315) {
1516 1516
 			$temp_array['direction_degree'] = $direction;
1517 1517
 			$temp_array['direction_shortname'] = "WNW";
1518 1518
 			$temp_array['direction_fullname'] = "West-Northwest";
1519
-		} elseif ($direction >= 315 && $direction < 337.5){
1519
+		} elseif ($direction >= 315 && $direction < 337.5) {
1520 1520
 			$temp_array['direction_degree'] = $direction;
1521 1521
 			$temp_array['direction_shortname'] = "NW";
1522 1522
 			$temp_array['direction_fullname'] = "Northwest";
1523
-		} elseif ($direction >= 337.5 && $direction < 360){
1523
+		} elseif ($direction >= 337.5 && $direction < 360) {
1524 1524
 			$temp_array['direction_degree'] = $direction;
1525 1525
 			$temp_array['direction_shortname'] = "NNW";
1526 1526
 			$temp_array['direction_fullname'] = "North-Northwest";
@@ -1537,11 +1537,11 @@  discard block
 block discarded – undo
1537 1537
 	* @param Float $longitude longitute of the flight
1538 1538
 	* @return String the countrie
1539 1539
 	*/
1540
-	public function getCountryFromLatitudeLongitude($latitude,$longitude)
1540
+	public function getCountryFromLatitudeLongitude($latitude, $longitude)
1541 1541
 	{
1542 1542
 		global $globalDBdriver, $globalDebug;
1543
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1544
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1543
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1544
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1545 1545
 	
1546 1546
 		$Connection = new Connection($this->db);
1547 1547
 		if (!$Connection->tableExists('countries')) return '';
@@ -1581,7 +1581,7 @@  discard block
 block discarded – undo
1581 1581
 	public function getCountryFromISO2($iso2)
1582 1582
 	{
1583 1583
 		global $globalDBdriver, $globalDebug;
1584
-		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
1584
+		$iso2 = filter_var($iso2, FILTER_SANITIZE_STRING);
1585 1585
 	
1586 1586
 		$Connection = new Connection($this->db);
1587 1587
 		if (!$Connection->tableExists('countries')) return '';
@@ -1629,7 +1629,7 @@  discard block
 block discarded – undo
1629 1629
 		
1630 1630
 		$bitly_data = json_decode($bitly_data);
1631 1631
 		$bitly_url = '';
1632
-		if ($bitly_data->status_txt = "OK"){
1632
+		if ($bitly_data->status_txt = "OK") {
1633 1633
 			$bitly_url = $bitly_data->data->url;
1634 1634
 		}
1635 1635
 
@@ -1639,7 +1639,7 @@  discard block
 block discarded – undo
1639 1639
 
1640 1640
 	public function getOrderBy()
1641 1641
 	{
1642
-		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY tracker_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY tracker_output.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_output.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_output.date DESC"),"distance_asc" => array("key" => "distance_asc","value" => "Distance - ASC","sql" => "ORDER BY distance ASC"),"distance_desc" => array("key" => "distance_desc","value" => "Distance - DESC","sql" => "ORDER BY distance DESC"));
1642
+		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY tracker_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY tracker_output.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_output.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_output.date DESC"), "distance_asc" => array("key" => "distance_asc", "value" => "Distance - ASC", "sql" => "ORDER BY distance ASC"), "distance_desc" => array("key" => "distance_desc", "value" => "Distance - DESC", "sql" => "ORDER BY distance DESC"));
1643 1643
 		
1644 1644
 		return $orderby;
1645 1645
 		
Please login to merge, or discard this patch.
require/class.TrackerImport.php 1 patch
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	    if (isset($this->all_tracked[$key]['id'])) {
48 48
 		//echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
49 49
     		$Tracker = new Tracker($this->db);
50
-        	$Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
50
+        	$Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['altitude'], $this->all_tracked[$key]['speed'], $this->all_tracked[$key]['datetime']);
51 51
             }
52 52
 	}
53 53
     }
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
59 59
 	foreach ($this->all_tracked as $key => $flight) {
60 60
     	    if (isset($flight['lastupdate'])) {
61
-        	if ($flight['lastupdate'] < (time()-3000)) {
61
+        	if ($flight['lastupdate'] < (time() - 3000)) {
62 62
             	    if (isset($this->all_tracked[$key]['id'])) {
63 63
             		if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
64 64
 			/*
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
             		//$real_arrival = $this->arrival($key);
70 70
             		$Tracker = new Tracker($this->db);
71 71
             		if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
72
-				$result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed']);
72
+				$result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['altitude'], $this->all_tracked[$key]['speed']);
73 73
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
74 74
 			}
75 75
 			// Put in archive
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	$send = false;
90 90
 	
91 91
 	// SBS format is CSV format
92
-	if(is_array($line) && isset($line['ident'])) {
92
+	if (is_array($line) && isset($line['ident'])) {
93 93
 	    //print_r($line);
94 94
   	    if (isset($line['ident'])) {
95 95
 
@@ -112,33 +112,33 @@  discard block
 block discarded – undo
112 112
 		
113 113
 		if (!isset($this->all_tracked[$id])) {
114 114
 		    $this->all_tracked[$id] = array();
115
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedTracker' => 0));
116
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => ''));
117
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
115
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('addedTracker' => 0));
116
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '', 'source_name' => '', 'comment'=> '', 'type' => '', 'noarchive' => false, 'putinarchive' => true, 'over_country' => ''));
117
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('lastupdate' => time()));
118 118
 		    if (!isset($line['id'])) {
119 119
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
120
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
121
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
120
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $id.'-'.date('YmdHi')));
121
+		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $line['id']));
122 122
 		    if ($globalAllTracked !== FALSE) $dataFound = true;
123 123
 		}
124 124
 		
125
-		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
125
+		if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60 && strtotime($line['datetime']) < time() + 20*60) {
126 126
 		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) {
127
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
127
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => $line['datetime']));
128 128
 		    } else {
129 129
 				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
130 130
 				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]['ident']." - format : ".$line['format_source']."\n";
131 131
 				return '';
132 132
 		    }
133
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
133
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time() - 20*60) {
134 134
 			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!";
135 135
 			return '';
136
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) {
136
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time() + 20*60) {
137 137
 			if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!";
138 138
 			return '';
139 139
 		} elseif (!isset($line['datetime'])) {
140 140
 			date_default_timezone_set('UTC');
141
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s')));
141
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => date('Y-m-d H:i:s')));
142 142
 		} else {
143 143
 			if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!";
144 144
 			return '';
@@ -146,38 +146,38 @@  discard block
 block discarded – undo
146 146
 		
147 147
 		//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'])) {
148 148
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) {
149
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
149
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => trim($line['ident'])));
150 150
 		    if ($this->all_tracked[$id]['addedTracker'] == 1) {
151 151
 			$timeelapsed = microtime(true);
152 152
             		$Tracker = new Tracker($this->db);
153 153
             		$fromsource = NULL;
154
-            		$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
154
+            		$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $fromsource);
155 155
 			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
156 156
 			$Tracker->db = null;
157
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
157
+			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
158 158
 		    }
159
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
159
+		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident']));
160 160
 		}
161 161
 
162 162
 		if (isset($line['speed']) && $line['speed'] != '') {
163
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
164
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
163
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($line['speed'])));
164
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed_fromsrc' => true));
165 165
 		} 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'])) {
166
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
166
+		    $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm');
167 167
 		    if ($distance > 100 && $distance < 10000) {
168 168
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
169 169
 			$speed = $speed*3.6;
170
-			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
170
+			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($speed)));
171 171
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n";
172 172
 		    }
173 173
 		}
174 174
 
175 175
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
176
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
176
+	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time() - $this->all_tracked[$id]['time_last_coord']);
177 177
 	    	    else unset($timediff);
178
-	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 100 || ($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')))) {
178
+	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 100 || ($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')))) {
179 179
 			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'])) {
180
-			    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'])) {
180
+			    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'])) {
181 181
 				$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
182 182
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
183 183
 				$this->all_tracked[$id]['putinarchive'] = true;
@@ -185,10 +185,10 @@  discard block
 block discarded – undo
185 185
 				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
186 186
 				$timeelapsed = microtime(true);
187 187
 				$Tracker = new Tracker($this->db);
188
-				$all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
188
+				$all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']);
189 189
 				if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
190 190
 				$Tracker->db = null;
191
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
191
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
192 192
 				$this->tmd = 0;
193 193
 				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
194 194
 			    }
@@ -196,73 +196,73 @@  discard block
 block discarded – undo
196 196
 
197 197
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
198 198
 				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
199
-				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') {
199
+				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') {
200 200
 				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
201 201
 				    $dataFound = true;
202 202
 				    $this->all_tracked[$id]['time_last_coord'] = time();
203 203
 				}
204
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
204
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('latitude' => $line['latitude']));
205 205
 			}
206 206
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
207 207
 			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
208 208
 				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
209
-				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') {
209
+				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') {
210 210
 				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
211 211
 				    $dataFound = true;
212 212
 				    $this->all_tracked[$id]['time_last_coord'] = time();
213 213
 				}
214
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude']));
214
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('longitude' => $line['longitude']));
215 215
 			}
216 216
 
217 217
 		    } else if ($globalDebug && $timediff > 20) {
218 218
 			$this->tmd = $this->tmd + 1;
219 219
 			echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n";
220
-			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -";
221
-			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
220
+			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')."m -";
221
+			echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - ";
222 222
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n";
223 223
 		    }
224 224
 		}
225 225
 		if (isset($line['last_update']) && $line['last_update'] != '') {
226 226
 		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
227
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
227
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('last_update' => $line['last_update']));
228 228
 		}
229 229
 		if (isset($line['format_source']) && $line['format_source'] != '') {
230
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
230
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('format_source' => $line['format_source']));
231 231
 		}
232 232
 		if (isset($line['source_name']) && $line['source_name'] != '') {
233
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
233
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('source_name' => $line['source_name']));
234 234
 		}
235 235
 		if (isset($line['comment']) && $line['comment'] != '') {
236
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment']));
236
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('comment' => $line['comment']));
237 237
 		    //$dataFound = true;
238 238
 		}
239 239
 		if (isset($line['type']) && $line['type'] != '') {
240
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
240
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $line['type']));
241 241
 		    //$dataFound = true;
242 242
 		}
243 243
 
244 244
 		if (isset($line['altitude']) && $line['altitude'] != '') {
245 245
 		    //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
246
-			if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true;
247
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => round($line['altitude']/100)));
248
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude']));
246
+			if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100) - $this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true;
247
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('altitude' => round($line['altitude']/100)));
248
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('altitude_real' => $line['altitude']));
249 249
 			//$dataFound = true;
250 250
 		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
251 251
   		}
252 252
 
253 253
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
254
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
254
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('noarchive' => true));
255 255
 		}
256 256
 		
257 257
 		if (isset($line['heading']) && $line['heading'] != '') {
258
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
259
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
260
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
258
+		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading'] - round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
259
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($line['heading'])));
260
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading_fromsrc' => true));
261 261
 		    //$dataFound = true;
262 262
   		} 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']) {
263
-  		    $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']);
264
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
265
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
263
+  		    $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']);
264
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($heading)));
265
+		    if (abs($this->all_tracked[$id]['heading'] - round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
266 266
   		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
267 267
   		}
268 268
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
@@ -270,39 +270,39 @@  discard block
 block discarded – undo
270 270
 		if ($dataFound === true && isset($this->all_tracked[$id]['ident'])) {
271 271
 		    $this->all_tracked[$id]['lastupdate'] = time();
272 272
 		    if ($this->all_tracked[$id]['addedTracker'] == 0) {
273
-		        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'])) {
273
+		        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'])) {
274 274
 			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
275 275
 				if ($globalDebug) echo "Check if aircraft is already in DB...";
276 276
 				$timeelapsed = microtime(true);
277 277
 				$TrackerLive = new TrackerLive($this->db);
278 278
 				if (isset($line['id'])) {
279 279
 				    $recent_ident = $TrackerLive->checkIdRecent($line['id']);
280
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
280
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
281 281
 				} elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
282 282
 				    $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']);
283
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
283
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
284 284
 				} else $recent_ident = '';
285
-				$TrackerLive->db=null;
285
+				$TrackerLive->db = null;
286 286
 
287 287
 				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
288 288
 				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
289 289
 			    } else {
290 290
 				$recent_ident = '';
291
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
291
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('forcenew' => 0));
292 292
 			    }
293 293
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
294
-			    if($recent_ident == "")
294
+			    if ($recent_ident == "")
295 295
 			    {
296 296
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
297 297
 				//adds the spotter data for the archive
298 298
 				    $highlight = '';
299
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
299
+				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
300 300
 				    $timeelapsed = microtime(true);
301 301
 				    $Tracker = new Tracker($this->db);
302
-				    $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
302
+				    $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name']);
303 303
 				    $Tracker->db = null;
304 304
 				    if ($globalDebug && isset($result)) echo $result."\n";
305
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
305
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
306 306
 				    
307 307
 				    /*
308 308
 				    // Add source stat in DB
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
 				    //TrackerLive->deleteLiveTrackerDataNotUpdated();
341 341
 				    $TrackerLive = new TrackerLive($this->db);
342 342
 				    $TrackerLive->deleteLiveTrackerData();
343
-				    $TrackerLive->db=null;
343
+				    $TrackerLive->db = null;
344 344
 				    if ($globalDebug) echo " Done\n";
345 345
 				    $this->last_delete = time();
346 346
 				}
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
 				$this->all_tracked[$id]['addedTracker'] = 1;
350 350
 				if (isset($globalDaemon) && !$globalDaemon) {
351 351
 					$Tracker = new Tracker($this->db);
352
-					$Tracker->updateLatestTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['altitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime']);
352
+					$Tracker->updateLatestTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime']);
353 353
 					$Tracker->db = null;
354 354
 				}
355 355
 				
@@ -363,14 +363,14 @@  discard block
 block discarded – undo
363 363
 		    $ignoreImport = false;
364 364
 
365 365
 		    if (!$ignoreImport) {
366
-			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'])) {
366
+			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'])) {
367 367
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
368 368
 				$timeelapsed = microtime(true);
369 369
 				$TrackerLive = new TrackerLive($this->db);
370
-				$result = $TrackerLive->addLiveTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
370
+				$result = $TrackerLive->addLiveTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'], $this->all_tracked[$id]['comment'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['noarchive'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['over_country']);
371 371
 				$TrackerLive->db = null;
372 372
 				$this->all_tracked[$id]['putinarchive'] = false;
373
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
373
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
374 374
 
375 375
 				// Put statistics in $this->stats variable
376 376
 				/*
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
 				$this->all_tracked[$id]['lastupdate'] = time();
430 430
 				if ($this->all_tracked[$id]['putinarchive']) $send = true;
431 431
 				if ($globalDebug) echo $result."\n";
432
-			} 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";
432
+			} 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";
433 433
 			//$this->del();
434 434
 			
435 435
 			
Please login to merge, or discard this patch.
require/class.APRS.php 1 patch
Spacing   +103 added lines, -104 removed lines patch added patch discarded remove patch
@@ -90,8 +90,7 @@  discard block
 block discarded – undo
90 90
 	
91 91
 
92 92
     private function urshift($n, $s) {
93
-	return ($n >= 0) ? ($n >> $s) :
94
-	    (($n & 0x7fffffff) >> $s) | 
93
+	return ($n >= 0) ? ($n >> $s) : (($n&0x7fffffff) >> $s)| 
95 94
 		(0x40000000 >> ($s - 1));
96 95
     }
97 96
 
@@ -103,7 +102,7 @@  discard block
 block discarded – undo
103 102
 	//$split_input = str_split($input);
104 103
 
105 104
 	/* Find the end of header checking for NULL bytes while doing it. */
106
-	$splitpos = strpos($input,':');
105
+	$splitpos = strpos($input, ':');
107 106
 	
108 107
 	/* Check that end was found and body has at least one byte. */
109 108
 	if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) {
@@ -113,15 +112,15 @@  discard block
 block discarded – undo
113 112
 	
114 113
 	if ($debug) echo 'input : '.$input."\n";
115 114
 	/* Save header and body. */
116
-	$body = substr($input,$splitpos+1,$input_len);
115
+	$body = substr($input, $splitpos + 1, $input_len);
117 116
 	$body_len = strlen($body);
118
-	$header = substr($input,0,$splitpos);
117
+	$header = substr($input, 0, $splitpos);
119 118
 	//$header_len = strlen($header);
120 119
 	if ($debug) echo 'header : '.$header."\n";
121 120
 	
122 121
 	/* Parse source, target and path. */
123 122
 	//FLRDF0A52>APRS,qAS,LSTB
124
-	if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) {
123
+	if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/', $header, $matches)) {
125 124
 	    $ident = $matches[1];
126 125
 	    $all_elements = $matches[2];
127 126
 	    if ($ident == 'AIRCRAFT') {
@@ -135,14 +134,14 @@  discard block
 block discarded – undo
135 134
 		$result['ident'] = $ident;
136 135
 	    }
137 136
 	} else return false;
138
-	$elements = explode(',',$all_elements);
137
+	$elements = explode(',', $all_elements);
139 138
 	$source = end($elements);
140 139
 	$result['source'] = $source;
141 140
 	foreach ($elements as $element) {
142
-	    if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) {
141
+	    if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/', $element)) {
143 142
 	        //echo "ok";
144 143
 	        //if ($element == 'TCPIP*') return false;
145
-	    } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) {
144
+	    } elseif (!preg_match('/^([0-9A-F]{32})$/', $element)) {
146 145
 		if ($debug) echo 'element : '.$element."\n";
147 146
 		return false;
148 147
 	    }
@@ -155,14 +154,14 @@  discard block
 block discarded – undo
155 154
 	    */
156 155
 	}
157 156
 	
158
-	$type = substr($body,0,1);
157
+	$type = substr($body, 0, 1);
159 158
 	if ($debug) echo 'type : '.$type."\n";
160 159
 	if ($type == ';') {
161 160
 		if (isset($result['source_type']) && $result['source_type'] == 'modes') {
162
-			$result['address'] = trim(substr($body,1,9));
161
+			$result['address'] = trim(substr($body, 1, 9));
163 162
 		} elseif (isset($result['source_type']) && $result['source_type'] == 'ais') {
164
-			$result['mmsi'] = trim(substr($body,1,9));
165
-		} else $result['ident'] = trim(substr($body,1,9));
163
+			$result['mmsi'] = trim(substr($body, 1, 9));
164
+		} else $result['ident'] = trim(substr($body, 1, 9));
166 165
 	} elseif ($type == ',') {
167 166
 		// Invalid data or test data
168 167
 		return false;
@@ -170,24 +169,24 @@  discard block
 block discarded – undo
170 169
 	
171 170
 	// Check for Timestamp
172 171
 	$find = false;
173
-	$body_parse = substr($body,1);
172
+	$body_parse = substr($body, 1);
174 173
 	//echo 'Body : '.$body."\n";
175
-	if (preg_match('/^;(.){9}\*/',$body,$matches)) {
176
-	    $body_parse = substr($body_parse,10);
174
+	if (preg_match('/^;(.){9}\*/', $body, $matches)) {
175
+	    $body_parse = substr($body_parse, 10);
177 176
 	    $find = true;
178 177
 	    //echo $body_parse."\n";
179 178
 	}
180
-	if (preg_match('/^`(.*)\//',$body,$matches)) {
181
-	    $body_parse = substr($body_parse,strlen($matches[1])-1);
179
+	if (preg_match('/^`(.*)\//', $body, $matches)) {
180
+	    $body_parse = substr($body_parse, strlen($matches[1]) - 1);
182 181
 	    $find = true;
183 182
 	    //echo $body_parse."\n";
184 183
 	}
185
-	if (preg_match("/^'(.*)\//",$body,$matches)) {
186
-	    $body_parse = substr($body_parse,strlen($matches[1])-1);
184
+	if (preg_match("/^'(.*)\//", $body, $matches)) {
185
+	    $body_parse = substr($body_parse, strlen($matches[1]) - 1);
187 186
 	    $find = true;
188 187
 	    //echo $body_parse."\n";
189 188
 	}
190
-	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/',$body_parse,$matches)) {
189
+	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/', $body_parse, $matches)) {
191 190
 	    $find = true;
192 191
 	    //print_r($matches);
193 192
 	    $timestamp = $matches[0];
@@ -202,19 +201,19 @@  discard block
 block discarded – undo
202 201
 		// This work or not ?
203 202
 		$timestamp = strtotime(date('Ym').$matches[1].' '.$matches[2].':'.$matches[3]);
204 203
 	    }
205
-	    $body_parse = substr($body_parse,7);
204
+	    $body_parse = substr($body_parse, 7);
206 205
 	    $result['timestamp'] = $timestamp;
207 206
 	    //echo date('Ymd H:i:s',$timestamp);
208 207
 	}
209
-	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/',$body_parse,$matches)) {
208
+	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/', $body_parse, $matches)) {
210 209
 	    $find = true;
211 210
 	    $timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]);
212
-	    $body_parse = substr($body_parse,8);
211
+	    $body_parse = substr($body_parse, 8);
213 212
 	    $result['timestamp'] = $timestamp;
214 213
 	    //echo date('Ymd H:i:s',$timestamp);
215 214
 	}
216 215
 	//if (strlen($body_parse) > 19) {
217
-	    if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) {
216
+	    if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/', $body_parse, $matches)) {
218 217
 	    $find = true;
219 218
 		// 4658.70N/00707.78Ez
220 219
 		//print_r(str_split($body_parse));
@@ -240,11 +239,11 @@  discard block
 block discarded – undo
240 239
 	    */
241 240
 		$latitude = $lat + floatval($lat_min)/60;
242 241
 		$longitude = $lon + floatval($lon_min)/60;
243
-		if ($sind == 'S') $latitude = 0-$latitude;
244
-		if ($wind == 'W') $longitude = 0-$longitude;
242
+		if ($sind == 'S') $latitude = 0 - $latitude;
243
+		if ($wind == 'W') $longitude = 0 - $longitude;
245 244
 		$result['latitude'] = $latitude;
246 245
 		$result['longitude'] = $longitude;
247
-		$body_parse = substr($body_parse,18);
246
+		$body_parse = substr($body_parse, 18);
248 247
 		$body_parse_len = strlen($body_parse);
249 248
 	    }
250 249
 	    $body_parse_len = strlen($body_parse);
@@ -272,7 +271,7 @@  discard block
 block discarded – undo
272 271
 		//echo $body_parse;
273 272
 			//if ($type != ';' && $type != '>') {
274 273
 			if ($type != '') {
275
-			$body_parse = substr($body_parse,1);
274
+			$body_parse = substr($body_parse, 1);
276 275
 			$body_parse_len = strlen($body_parse);
277 276
 			$result['symbol_code'] = $symbol_code;
278 277
 			if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code];
@@ -283,16 +282,16 @@  discard block
 block discarded – undo
283 282
 		    //$body_parse_len = strlen($body_parse);
284 283
 		    if ($body_parse_len >= 7) {
285 284
 			
286
-		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
287
-		    	    $course = substr($body_parse,0,3);
285
+		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/', $body_parse)) {
286
+		    	    $course = substr($body_parse, 0, 3);
288 287
 		    	    $tmp_s = intval($course);
289 288
 		    	    if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course);
290
-		    	    $speed = substr($body_parse,4,3);
289
+		    	    $speed = substr($body_parse, 4, 3);
291 290
 		    	    if ($speed != '...') {
292 291
 		    		//$result['speed'] = round($speed*1.852);
293 292
 		    		$result['speed'] = intval($speed);
294 293
 		    	    }
295
-		    	    $body_parse = substr($body_parse,7);
294
+		    	    $body_parse = substr($body_parse, 7);
296 295
 		        }
297 296
 		        // Check PHGR, PHG, RNG
298 297
 		    } 
@@ -302,12 +301,12 @@  discard block
 block discarded – undo
302 301
 		    }
303 302
 		    */
304 303
 		    if (strlen($body_parse) > 0) {
305
-		        if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) {
304
+		        if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/', $body_parse, $matches)) {
306 305
 		            $altitude = intval($matches[1]);
307 306
 		            //$result['altitude'] = round($altitude*0.3048);
308 307
 		            $result['altitude'] = $altitude;
309 308
 		            //$body_parse = trim(substr($body_parse,strlen($matches[0])));
310
-		            $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse));
309
+		            $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/', '', $body_parse));
311 310
 		        }
312 311
 		    }
313 312
 		    
@@ -319,13 +318,13 @@  discard block
 block discarded – undo
319 318
 		    */
320 319
 		    // DAO
321 320
 		    
322
-		    if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) {
321
+		    if (preg_match('/^!([0-9A-Z]{3})/', $body_parse, $matches)) {
323 322
 			    
324 323
 			    $dao = $matches[1];
325
-			    if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) {
324
+			    if (preg_match('/^([A-Z])([0-9]{2})/', $dao)) {
326 325
 				$dao_split = str_split($dao);
327
-			        $lat_off = (($dao_split[1])-48.0)*0.001/60.0;
328
-			        $lon_off = (($dao_split[2])-48.0)*0.001/60.0;
326
+			        $lat_off = (($dao_split[1]) - 48.0)*0.001/60.0;
327
+			        $lon_off = (($dao_split[2]) - 48.0)*0.001/60.0;
329 328
 			    
330 329
 				if ($result['latitude'] < 0) $result['latitude'] -= $lat_off;
331 330
 				else $result['latitude'] += $lat_off;
@@ -333,50 +332,50 @@  discard block
 block discarded – undo
333 332
 				else $result['longitude'] += $lon_off;
334 333
 			    }
335 334
 			    
336
-		            $body_parse = substr($body_parse,6);
335
+		            $body_parse = substr($body_parse, 6);
337 336
 		    }
338 337
 		    
339
-		    if (preg_match('/CS=([0-9A-Z_]*)/',$body_parse,$matches)) {
340
-			$result['ident'] = str_replace('_',' ',$matches[1]);
338
+		    if (preg_match('/CS=([0-9A-Z_]*)/', $body_parse, $matches)) {
339
+			$result['ident'] = str_replace('_', ' ', $matches[1]);
341 340
 		    }
342
-		    if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) {
341
+		    if (preg_match('/SQ=([0-9]{4})/', $body_parse, $matches)) {
343 342
 			$result['squawk'] = $matches[1];
344 343
 		    }
345
-		    if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) {
344
+		    if (preg_match('/AI=([0-9A-Z]{4})/', $body_parse, $matches)) {
346 345
 			$result['aircraft_icao'] = $matches[1];
347 346
 		    }
348
-		    if (preg_match('/VR=([0-9]*)/',$body_parse,$matches)) {
347
+		    if (preg_match('/VR=([0-9]*)/', $body_parse, $matches)) {
349 348
 			$result['verticalrate'] = $matches[1];
350 349
 		    }
351
-		    if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) {
350
+		    if (preg_match('/TI=([0-9]*)/', $body_parse, $matches)) {
352 351
 			$result['typeid'] = $matches[1];
353 352
 		    }
354
-		    if (preg_match('/SI=([0-9]*)/',$body_parse,$matches)) {
353
+		    if (preg_match('/SI=([0-9]*)/', $body_parse, $matches)) {
355 354
 			$result['statusid'] = $matches[1];
356 355
 		    }
357
-		    if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) {
356
+		    if (preg_match('/IMO=([0-9]{7})/', $body_parse, $matches)) {
358 357
 			$result['imo'] = $matches[1];
359 358
 		    }
360
-		    if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) {
359
+		    if (preg_match('/AD=([0-9]*)/', $body_parse, $matches)) {
361 360
 			$result['arrival_date'] = $matches[1];
362 361
 		    }
363
-		    if (preg_match('/AC=([0-9A-Z_]*)/',$body_parse,$matches)) {
364
-			$result['arrival_code'] = str_replace('_',' ',$matches[1]);
362
+		    if (preg_match('/AC=([0-9A-Z_]*)/', $body_parse, $matches)) {
363
+			$result['arrival_code'] = str_replace('_', ' ', $matches[1]);
365 364
 		    }
366 365
 		    // OGN comment
367 366
 		   // echo "Before OGN : ".$body_parse."\n";
368 367
 		    //if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) {
369
-		    if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) {
368
+		    if (preg_match('/^id([0-9A-F]{8})/', $body_parse, $matches)) {
370 369
 			$id = $matches[1];
371 370
 			//$mode = substr($id,0,2);
372
-			$address = substr($id,2);
371
+			$address = substr($id, 2);
373 372
 			//print_r($matches);
374
-			$addressType = (intval(substr($id,0,2),16))&3;
373
+			$addressType = (intval(substr($id, 0, 2), 16))&3;
375 374
 			if ($addressType == 0) $result['addresstype'] = "RANDOM";
376 375
 			elseif ($addressType == 1) $result['addresstype'] = "ICAO";
377 376
 			elseif ($addressType == 2) $result['addresstype'] = "FLARM";
378 377
 			elseif ($addressType == 3) $result['addresstype'] = "OGN";
379
-			$aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2);
378
+			$aircraftType = $this->urshift(((intval(substr($id, 0, 2), 16))&0b1111100), 2);
380 379
 			$result['aircrafttype_code'] = $aircraftType;
381 380
 			if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN";
382 381
 			elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER";
@@ -393,7 +392,7 @@  discard block
 block discarded – undo
393 392
 			elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP";
394 393
 			elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV";
395 394
 			elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT";
396
-			$stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0;
395
+			$stealth = (intval(substr($id, 0, 2), 16)&0b10000000) != 0;
397 396
 			$result['stealth'] = $stealth;
398 397
 			$result['address'] = $address;
399 398
 		    }
@@ -405,77 +404,77 @@  discard block
 block discarded – undo
405 404
 		    //$body_parse = substr($body_parse,1);
406 405
 		    //$body_parse_len = strlen($body_parse);
407 406
 
408
-		    if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
407
+		    if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) {
409 408
 			    $result['wind_dir'] = intval($matches[1]);
410
-			    $result['wind_speed'] = round(intval($matches[2])*1.60934,1);
411
-			    $result['wind_gust'] = round(intval($matches[3])*1.60934,1);
412
-			    $result['temp'] = round(5/9*((intval($matches[4]))-32),1);
413
-		    	    $body_parse = substr($body_parse,strlen($matches[0])+1);
414
-		    } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
409
+			    $result['wind_speed'] = round(intval($matches[2])*1.60934, 1);
410
+			    $result['wind_gust'] = round(intval($matches[3])*1.60934, 1);
411
+			    $result['temp'] = round(5/9*((intval($matches[4])) - 32), 1);
412
+		    	    $body_parse = substr($body_parse, strlen($matches[0]) + 1);
413
+		    } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) {
415 414
 			$result['wind_dir'] = intval($matches[1]);
416
-			$result['wind_speed'] = round($matches[2]*1.60934,1);
417
-			$result['wind_gust'] = round($matches[3]*1.60934,1);
418
-			$result['temp'] = round(5/9*(($matches[4])-32),1);
419
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
420
-		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
415
+			$result['wind_speed'] = round($matches[2]*1.60934, 1);
416
+			$result['wind_gust'] = round($matches[3]*1.60934, 1);
417
+			$result['temp'] = round(5/9*(($matches[4]) - 32), 1);
418
+		        $body_parse = substr($body_parse, strlen($matches[0]) + 1);
419
+		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) {
421 420
 			$result['wind_dir'] = intval($matches[1]);
422
-			$result['wind_speed'] = round($matches[2]*1.60934,1);
423
-			$result['wind_gust'] = round($matches[3]*1.60934,1);
424
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
425
-		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) {
421
+			$result['wind_speed'] = round($matches[2]*1.60934, 1);
422
+			$result['wind_gust'] = round($matches[3]*1.60934, 1);
423
+		        $body_parse = substr($body_parse, strlen($matches[0]) + 1);
424
+		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/', $body_parse, $matches)) {
426 425
 			$result['wind_dir'] = intval($matches[1]);
427
-			$result['wind_speed'] = round($matches[2]*1.60934,1);
428
-			$result['wind_gust'] = round($matches[3]*1.60934,1);
429
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
426
+			$result['wind_speed'] = round($matches[2]*1.60934, 1);
427
+			$result['wind_gust'] = round($matches[3]*1.60934, 1);
428
+		        $body_parse = substr($body_parse, strlen($matches[0]) + 1);
430 429
 		    }
431
-		    if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) {
432
-			$result['temp'] = round(5/9*(($matches[1])-32),1);
430
+		    if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/', $body_parse, $matches)) {
431
+			$result['temp'] = round(5/9*(($matches[1]) - 32), 1);
433 432
 		    }
434 433
 		}
435 434
 		} else $result['comment'] = trim($body_parse);
436 435
 
437 436
 	    }
438 437
 	//}
439
-	if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4);
440
-	if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4);
438
+	if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'], 4);
439
+	if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'], 4);
441 440
 	if ($debug) print_r($result);
442 441
 	return $result;
443 442
     }
444 443
     
445 444
     public function connect() {
446
-	global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass,$globalName, $globalServerAPRShost, $globalServerAPRSport;
445
+	global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass, $globalName, $globalServerAPRShost, $globalServerAPRSport;
447 446
 	$aprs_connect = 0;
448 447
 	$aprs_keep = 120;
449 448
 	$aprs_last_tx = time();
450 449
 	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
451
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
450
+	else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName);
452 451
 	if (isset($globalServerAPRSssid)) $aprs_ssid = $globalServerAPRSssid;
453
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
452
+	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8);
454 453
 	if (isset($globalServerAPRSpass)) $aprs_pass = $globalServerAPRSpass;
455 454
 	else $aprs_pass = '-1';
456 455
 	
457
-	$aprs_filter  = '';
456
+	$aprs_filter = '';
458 457
 	$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
459 458
 	$Common = new Common();
460
-	$s = $Common->create_socket($globalServerAPRShost,$globalServerAPRSport,$errno,$errstr);
459
+	$s = $Common->create_socket($globalServerAPRShost, $globalServerAPRSport, $errno, $errstr);
461 460
 	if ($s !== false) {
462 461
 		echo 'Connected to APRS server! '."\n";
463 462
 		$authstart = time();
464 463
 		$this->socket = $s;
465
-		$send = socket_send( $this->socket  , $aprs_login , strlen($aprs_login) , 0 );
466
-		while ($msgin = socket_read($this->socket, 1000,PHP_NORMAL_READ)) {
464
+		$send = socket_send($this->socket, $aprs_login, strlen($aprs_login), 0);
465
+		while ($msgin = socket_read($this->socket, 1000, PHP_NORMAL_READ)) {
467 466
 			if (strpos($msgin, "$aprs_ssid verified") !== FALSE) {
468 467
 			    echo 'APRS user verified !'."\n";
469 468
 			    $this->connected = true;
470 469
 			    return true;
471 470
 			    break;
472 471
 			}
473
-			if (time()-$authstart > 5) {
472
+			if (time() - $authstart > 5) {
474 473
 			    echo 'APRS timeout'."\n";
475 474
 			    break;
476 475
 			}
477 476
 		}
478
-		socket_set_option($this->socket,SOL_SOCKET,SO_KEEPALIVE);
477
+		socket_set_option($this->socket, SOL_SOCKET, SO_KEEPALIVE);
479 478
 	}
480 479
     }
481 480
 
@@ -485,7 +484,7 @@  discard block
 block discarded – undo
485 484
     
486 485
     public function send($data) {
487 486
 	if ($this->connected === false) $this->connect();
488
-	$send = socket_send( $this->socket  , $data , strlen($data),0);
487
+	$send = socket_send($this->socket, $data, strlen($data), 0);
489 488
 	if ($send === FALSE) {
490 489
 		socket_close($this->socket);
491 490
 		$this->connect();
@@ -494,14 +493,14 @@  discard block
 block discarded – undo
494 493
 }
495 494
 
496 495
 class APRSSpotter extends APRS {
497
-	public function addLiveSpotterData($id,$ident,$aircraft_icao,$departure_airport,$arrival_airport,$latitude,$longitude,$waypoints,$altitude,$altitude_real,$heading,$speed,$datetime,$departure_airport_time,$arrival_airport_time,$squawk,$route_stop,$hex,$putinarchive,$registration,$pilot_id,$pilot_name, $verticalrate, $noarchive, $ground,$format_source,$source_name,$over_country) {
496
+	public function addLiveSpotterData($id, $ident, $aircraft_icao, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $altitude_real, $heading, $speed, $datetime, $departure_airport_time, $arrival_airport_time, $squawk, $route_stop, $hex, $putinarchive, $registration, $pilot_id, $pilot_name, $verticalrate, $noarchive, $ground, $format_source, $source_name, $over_country) {
498 497
 		$Common = new Common();
499 498
 		if ($latitude != '' && $longitude != '') {
500
-			$latitude = $Common->convertDM($latitude,'latitude');
501
-			$longitude = $Common->convertDM($longitude,'longitude');
502
-			$coordinate = sprintf("%02d",$latitude['deg']).str_pad(number_format($latitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d",$longitude['deg']).str_pad(number_format($longitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$longitude['NSEW'];
503
-			$w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'],2,'.',''))*1000));
504
-			$w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'],2,'.',''))*1000));
499
+			$latitude = $Common->convertDM($latitude, 'latitude');
500
+			$longitude = $Common->convertDM($longitude, 'longitude');
501
+			$coordinate = sprintf("%02d", $latitude['deg']).str_pad(number_format($latitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d", $longitude['deg']).str_pad(number_format($longitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$longitude['NSEW'];
502
+			$w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'], 2, '.', ''))*1000));
503
+			$w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'], 2, '.', ''))*1000));
505 504
 			$w = $w1.$w2;
506 505
 			//$w = '00';
507 506
 			$custom = '';
@@ -522,25 +521,25 @@  discard block
 block discarded – undo
522 521
 				$custom .= 'AI='.$aircraft_icao;
523 522
 			}
524 523
 			if ($custom != '') $custom = ' '.$custom;
525
-			$this->send('AIRCRAFT>APRS,TCPIP*:;'.$hex.'   *'.date('His',strtotime($datetime)).'h'.$coordinate.'^'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude_real,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n");
524
+			$this->send('AIRCRAFT>APRS,TCPIP*:;'.$hex.'   *'.date('His', strtotime($datetime)).'h'.$coordinate.'^'.str_pad($heading, 3, '0', STR_PAD_LEFT).'/'.str_pad($speed, 3, '0', STR_PAD_LEFT).'/A='.str_pad($altitude_real, 6, '0', STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n");
526 525
 		}
527 526
 	}
528 527
 }
529 528
 class APRSMarine extends APRS {
530
-	public function addLiveMarineData($id, $ident, $latitude, $longitude, $heading, $speed,$datetime, $putinarchive,$mmsi,$type,$typeid,$imo,$callsign,$arrival_code,$arrival_date,$status,$statusid,$noarchive,$format_source,$source_name,$over_country) {
529
+	public function addLiveMarineData($id, $ident, $latitude, $longitude, $heading, $speed, $datetime, $putinarchive, $mmsi, $type, $typeid, $imo, $callsign, $arrival_code, $arrival_date, $status, $statusid, $noarchive, $format_source, $source_name, $over_country) {
531 530
 		$Common = new Common();
532 531
 		if ($latitude != '' && $longitude != '') {
533
-			$latitude = $Common->convertDM($latitude,'latitude');
534
-			$longitude = $Common->convertDM($longitude,'longitude');
535
-			$coordinate = sprintf("%02d",$latitude['deg']).str_pad(number_format($latitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d",$longitude['deg']).str_pad(number_format($longitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$longitude['NSEW'];
536
-			$w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'],2,'.',''))*1000));
537
-			$w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'],2,'.',''))*1000));
532
+			$latitude = $Common->convertDM($latitude, 'latitude');
533
+			$longitude = $Common->convertDM($longitude, 'longitude');
534
+			$coordinate = sprintf("%02d", $latitude['deg']).str_pad(number_format($latitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d", $longitude['deg']).str_pad(number_format($longitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$longitude['NSEW'];
535
+			$w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'], 2, '.', ''))*1000));
536
+			$w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'], 2, '.', ''))*1000));
538 537
 			$w = $w1.$w2;
539 538
 			//$w = '00';
540 539
 			$custom = '';
541 540
 			if ($ident != '') {
542 541
 				if ($custom != '') $custom .= '/';
543
-				$custom .= 'CS='.str_replace(' ','_',$ident);
542
+				$custom .= 'CS='.str_replace(' ', '_', $ident);
544 543
 			}
545 544
 			if ($typeid != '') {
546 545
 				if ($custom != '') $custom .= '/';
@@ -560,11 +559,11 @@  discard block
 block discarded – undo
560 559
 			}
561 560
 			if ($arrival_code != '') {
562 561
 				if ($custom != '') $custom .= '/';
563
-				$custom .= 'AC='.str_replace(' ','_',$arrival_code);
562
+				$custom .= 'AC='.str_replace(' ', '_', $arrival_code);
564 563
 			}
565 564
 			if ($custom != '') $custom = ' '.$custom;
566 565
 			$altitude = 0;
567
-			$this->send('MARINE>APRS,TCPIP*:;'.$mmsi.'*'.date('His',strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n");
566
+			$this->send('MARINE>APRS,TCPIP*:;'.$mmsi.'*'.date('His', strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading, 3, '0', STR_PAD_LEFT).'/'.str_pad($speed, 3, '0', STR_PAD_LEFT).'/A='.str_pad($altitude, 6, '0', STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n");
568 567
 		}
569 568
 	}
570 569
 }
Please login to merge, or discard this patch.
require/class.SBS.php 1 patch
Spacing   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -6,83 +6,83 @@  discard block
 block discarded – undo
6 6
 	// Not yet finished, no CRC checks
7 7
 	//echo $buffer."\n";
8 8
 	$data = array();
9
-	$typehex = substr($buffer,0,1);
10
-	if ($typehex == '*' || $typehex == ':') $hex = substr($buffer,1,-1);
11
-	elseif ($typehex == '@' || $typehex == '%') $hex = substr($buffer,13,-13);
12
-	else $hex = substr($buffer,1,-1);
13
-	$bin = gmp_strval( gmp_init($hex,16), 2);
9
+	$typehex = substr($buffer, 0, 1);
10
+	if ($typehex == '*' || $typehex == ':') $hex = substr($buffer, 1, -1);
11
+	elseif ($typehex == '@' || $typehex == '%') $hex = substr($buffer, 13, -13);
12
+	else $hex = substr($buffer, 1, -1);
13
+	$bin = gmp_strval(gmp_init($hex, 16), 2);
14 14
 	//if (strlen($hex) == 28 && $this->parityCheck($hex,$bin)) {
15 15
 	if (strlen($hex) == 28) {
16
-	    $df = intval(substr($bin,0,5),2);
16
+	    $df = intval(substr($bin, 0, 5), 2);
17 17
 	    //$ca = intval(substr($bin,5,3),2);
18 18
 	    // Only support DF17 for now
19 19
 	    //if ($df == 17 || ($df == 18 && ($ca == 0 || $ca == 1 || $ca == 6))) {
20
-	    if (($df == 17 || $df == 18) && ($this->parityCheck($hex,$bin) || $typehex == '@')) {
21
-		$icao = substr($hex,2,6);
20
+	    if (($df == 17 || $df == 18) && ($this->parityCheck($hex, $bin) || $typehex == '@')) {
21
+		$icao = substr($hex, 2, 6);
22 22
 		$data['hex'] = $icao;
23
-		$tc = intval(substr($bin,32,5),2);
23
+		$tc = intval(substr($bin, 32, 5), 2);
24 24
 		if ($tc >= 1 && $tc <= 4) {
25 25
 		    //callsign
26
-		    $csbin = substr($bin,40,56);
26
+		    $csbin = substr($bin, 40, 56);
27 27
 		    $charset = str_split('#ABCDEFGHIJKLMNOPQRSTUVWXYZ#####_###############0123456789######');
28 28
 		    $cs = '';
29
-		    $cs .= $charset[intval(substr($csbin,0,6),2)];
30
-		    $cs .= $charset[intval(substr($csbin,6,6),2)];
31
-		    $cs .= $charset[intval(substr($csbin,12,6),2)];
32
-		    $cs .= $charset[intval(substr($csbin,18,6),2)];
33
-		    $cs .= $charset[intval(substr($csbin,24,6),2)];
34
-		    $cs .= $charset[intval(substr($csbin,30,6),2)];
35
-		    $cs .= $charset[intval(substr($csbin,36,6),2)];
36
-		    $cs .= $charset[intval(substr($csbin,42,6),2)];
37
-		    $cs = str_replace('_','',$cs);
38
-		    $cs = str_replace('#','',$cs);
29
+		    $cs .= $charset[intval(substr($csbin, 0, 6), 2)];
30
+		    $cs .= $charset[intval(substr($csbin, 6, 6), 2)];
31
+		    $cs .= $charset[intval(substr($csbin, 12, 6), 2)];
32
+		    $cs .= $charset[intval(substr($csbin, 18, 6), 2)];
33
+		    $cs .= $charset[intval(substr($csbin, 24, 6), 2)];
34
+		    $cs .= $charset[intval(substr($csbin, 30, 6), 2)];
35
+		    $cs .= $charset[intval(substr($csbin, 36, 6), 2)];
36
+		    $cs .= $charset[intval(substr($csbin, 42, 6), 2)];
37
+		    $cs = str_replace('_', '', $cs);
38
+		    $cs = str_replace('#', '', $cs);
39 39
 		    $callsign = $cs;
40 40
 		    $data['ident'] = $callsign;
41 41
 		} elseif ($tc >= 9 && $tc <= 18) {
42 42
 		    // Check Q-bit
43
-		    $q = substr($bin,47,1);
43
+		    $q = substr($bin, 47, 1);
44 44
 		    if ($q) {
45
-			$n = intval(substr($bin,40,7).substr($bin,48,4),2);
46
-			$alt = $n*25-1000;
45
+			$n = intval(substr($bin, 40, 7).substr($bin, 48, 4), 2);
46
+			$alt = $n*25 - 1000;
47 47
 			$data['altitude'] = $alt;
48 48
 		    }
49 49
 		    // Check odd/even flag
50
-		    $oe = substr($bin,53,1);
50
+		    $oe = substr($bin, 53, 1);
51 51
 		    //if ($oe) => odd else even
52 52
 		    //  131072 is 2^17 since CPR latitude and longitude are encoded in 17 bits.
53
-		    $cprlat = intval(substr($bin,54,17),2)/131072.0;
54
-		    $cprlon = intval(substr($bin,71,17),2)/131072.0;
55
-		    if ($oe == 0) $this::$latlon[$icao] = array('latitude' => $cprlat,'longitude' => $cprlon,'created' => time());
53
+		    $cprlat = intval(substr($bin, 54, 17), 2)/131072.0;
54
+		    $cprlon = intval(substr($bin, 71, 17), 2)/131072.0;
55
+		    if ($oe == 0) $this::$latlon[$icao] = array('latitude' => $cprlat, 'longitude' => $cprlon, 'created' => time());
56 56
 		    elseif (isset($this::$latlon[$icao]) && (time() - $this::$latlon[$icao]['created']) < 10) {
57 57
 			$cprlat_odd = $cprlat;
58 58
 			$cprlon_odd = $cprlon;
59 59
 			$cprlat_even = $this::$latlon[$icao]['latitude'];
60 60
 			$cprlon_even = $this::$latlon[$icao]['longitude'];
61 61
 		    
62
-			$j = 59*$cprlat_even-60*$cprlat_odd+0.5;
63
-			$lat_even = (360.0/60)*($j%60+$cprlat_even);
64
-			$lat_odd = (360.0/59)*($j%59+$cprlat_odd);
62
+			$j = 59*$cprlat_even - 60*$cprlat_odd + 0.5;
63
+			$lat_even = (360.0/60)*($j%60 + $cprlat_even);
64
+			$lat_odd = (360.0/59)*($j%59 + $cprlat_odd);
65 65
 			if ($lat_even >= 270) $lat_even = $lat_even - 360;
66 66
 			if ($lat_odd >= 270) $lat_odd = $lat_odd - 360;
67 67
 			// check latitude zone
68 68
 			if ($this->cprNL($lat_even) == $this->cprNL($lat_odd)) {
69 69
 			    if ($this::$latlon[$icao]['created'] > time()) {
70
-				$ni = $this->cprN($lat_even,0);
71
-				$m = floor($cprlon_even*($this->cprNL($lat_even)-1) - $cprlon_odd * $this->cprNL($lat_even)+0.5);
72
-				$lon = (360.0/$ni)*($m%$ni+$cprlon_even);
70
+				$ni = $this->cprN($lat_even, 0);
71
+				$m = floor($cprlon_even*($this->cprNL($lat_even) - 1) - $cprlon_odd*$this->cprNL($lat_even) + 0.5);
72
+				$lon = (360.0/$ni)*($m%$ni + $cprlon_even);
73 73
 				$lat = $lat_even;
74
-				if ($lon > 180) $lon = $lon -360;
74
+				if ($lon > 180) $lon = $lon - 360;
75 75
 				if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) {
76 76
 				    //if ($globalDebug) echo 'cs : '.$cs.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon;
77 77
 				    $data['latitude'] = $lat;
78 78
 				    $data['longitude'] = $lon;
79 79
 				}
80 80
 			    } else {
81
-				$ni = $this->cprN($lat_odd,1);
82
-				$m = floor($cprlon_even*($this->cprNL($lat_odd)-1) - $cprlon_odd * $this->cprNL($lat_odd)+0.5);
83
-				$lon = (360.0/$ni)*($m%$ni+$cprlon_odd);
81
+				$ni = $this->cprN($lat_odd, 1);
82
+				$m = floor($cprlon_even*($this->cprNL($lat_odd) - 1) - $cprlon_odd*$this->cprNL($lat_odd) + 0.5);
83
+				$lon = (360.0/$ni)*($m%$ni + $cprlon_odd);
84 84
 				$lat = $lat_odd;
85
-				if ($lon > 180) $lon = $lon -360;
85
+				if ($lon > 180) $lon = $lon - 360;
86 86
 				if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) {
87 87
 				    //if ($globalDebug) echo 'icao : '.$icao.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon.' second'."\n";
88 88
 				    $data['latitude'] = $lat;
@@ -94,15 +94,15 @@  discard block
 block discarded – undo
94 94
 		    }
95 95
 		} elseif ($tc == 19) {
96 96
 		    // speed & heading
97
-		    $v_ew_dir = intval(substr($bin,45,1));
98
-		    $v_ew = intval(substr($bin,46,10),2);
99
-		    $v_ns_dir = intval(substr($bin,56,1));
100
-		    $v_ns = intval(substr($bin,57,10),2);
97
+		    $v_ew_dir = intval(substr($bin, 45, 1));
98
+		    $v_ew = intval(substr($bin, 46, 10), 2);
99
+		    $v_ns_dir = intval(substr($bin, 56, 1));
100
+		    $v_ns = intval(substr($bin, 57, 10), 2);
101 101
 		    if ($v_ew_dir) $v_ew = -1*$v_ew;
102 102
 		    if ($v_ns_dir) $v_ns = -1*$v_ns;
103
-		    $speed = sqrt($v_ns*$v_ns+$v_ew*$v_ew);
104
-		    $heading = atan2($v_ew,$v_ns)*360.0/(2*pi());
105
-		    if ($heading <0) $heading = $heading+360;
103
+		    $speed = sqrt($v_ns*$v_ns + $v_ew*$v_ew);
104
+		    $heading = atan2($v_ew, $v_ns)*360.0/(2*pi());
105
+		    if ($heading < 0) $heading = $heading + 360;
106 106
 		    $data['speed'] = $speed;
107 107
 		    $data['heading'] = $heading;
108 108
 		}
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 
118 118
 	public function cprNL($lat) {
119 119
 	//Lookup table to convert the latitude to index.
120
-	if ($lat < 0) $lat = -$lat;             // Table is simmetric about the equator.
120
+	if ($lat < 0) $lat = -$lat; // Table is simmetric about the equator.
121 121
 	if ($lat < 10.47047130) return 59;
122 122
 	if ($lat < 14.82817437) return 58;
123 123
 	if ($lat < 18.18626357) return 57;
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 	return 1;
180 180
     }
181 181
     
182
-    public function cprN($lat,$isodd) {
182
+    public function cprN($lat, $isodd) {
183 183
 	$nl = $this->cprNL($lat) - $isodd;
184 184
 	if ($nl > 1) return $nl;
185 185
 	else return 1;
@@ -205,10 +205,10 @@  discard block
 block discarded – undo
205 205
 );
206 206
 
207 207
 	$crc = 0;
208
-	$checksum = intval(substr($msg,22,6),16);
208
+	$checksum = intval(substr($msg, 22, 6), 16);
209 209
 
210 210
 	for ($j = 0; $j < strlen($bin); $j++) {
211
-	    if ($bin[$j]) $crc = $crc^intval($modes_checksum_table[$j],0);
211
+	    if ($bin[$j]) $crc = $crc^intval($modes_checksum_table[$j], 0);
212 212
 	}
213 213
 	if ($crc == $checksum) return true;
214 214
 	else {
@@ -227,10 +227,10 @@  discard block
 block discarded – undo
227 227
 	    $msg['aircraftid'] = hexdec($data['address']);
228 228
 	    $msg['hex'] = $data['address'];
229 229
 	    $msg['flightid'] = hexdec($data['address']);
230
-	    $msg['date_gen'] = date('Y/m/d',$data['timestamp']);
231
-	    $msg['time_gen'] = date('H:i:s',$data['timestamp']).'.180';
232
-	    $msg['date_log'] = date('Y/m/d',$data['timestamp']);
233
-	    $msg['time_log'] = date('H:i:s',$data['timestamp']).'.180';
230
+	    $msg['date_gen'] = date('Y/m/d', $data['timestamp']);
231
+	    $msg['time_gen'] = date('H:i:s', $data['timestamp']).'.180';
232
+	    $msg['date_log'] = date('Y/m/d', $data['timestamp']);
233
+	    $msg['time_log'] = date('H:i:s', $data['timestamp']).'.180';
234 234
 	    $msg['callsign'] = $data['ident'];
235 235
 	    $msg['altitude'] = '';
236 236
 	    $msg['speed'] = '';
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 	    $msg['emergency'] = '';
244 244
 	    $msg['SPI'] = '';
245 245
 	    $msg['ground'] = '';
246
-    	    $result[] = implode(',',$msg);
246
+    	    $result[] = implode(',', $msg);
247 247
     	}
248 248
     	if (isset($data['latitude']) && $data['latitude'] != 0) {
249 249
 	    $msg = array();
@@ -253,10 +253,10 @@  discard block
 block discarded – undo
253 253
 	    $msg['aircraftid'] = hexdec($data['address']);
254 254
 	    $msg['hex'] = $data['address'];
255 255
 	    $msg['flightid'] = hexdec($data['address']);
256
-	    $msg['date_gen'] = date('Y/m/d',$data['timestamp']);
257
-	    $msg['time_gen'] = date('H:i:s',$data['timestamp']).'.180';
258
-	    $msg['date_log'] = date('Y/m/d',$data['timestamp']);
259
-	    $msg['time_log'] = date('H:i:s',$data['timestamp']).'.180';
256
+	    $msg['date_gen'] = date('Y/m/d', $data['timestamp']);
257
+	    $msg['time_gen'] = date('H:i:s', $data['timestamp']).'.180';
258
+	    $msg['date_log'] = date('Y/m/d', $data['timestamp']);
259
+	    $msg['time_log'] = date('H:i:s', $data['timestamp']).'.180';
260 260
 	    $msg['callsign'] = '';
261 261
 	    if (isset($data['altitude'])) $msg['altitude'] = $data['altitude'];
262 262
 	    else $msg['altitude'] = '';
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
 	    $msg['SPI'] = 0;
275 275
 	    if (isset($data['ground'])) $msg['ground'] = 1;
276 276
 	    else $msg['ground'] = 0;
277
-    	    $result[] = implode(',',$msg);
277
+    	    $result[] = implode(',', $msg);
278 278
         }
279 279
         return $result;
280 280
     }
Please login to merge, or discard this patch.
require/class.Marine.php 1 patch
Spacing   +155 added lines, -155 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 require_once(dirname(__FILE__).'/class.Image.php');
3 3
 $global_query = "SELECT marine_output.* FROM marine_output";
4 4
 
5
-class Marine{
5
+class Marine {
6 6
 	public $db;
7 7
 	
8 8
 	public function __construct($dbc = null) {
@@ -16,33 +16,33 @@  discard block
 block discarded – undo
16 16
 	* @return Array the SQL part
17 17
 	*/
18 18
 	
19
-	public function getFilter($filter = array(),$where = false,$and = false) {
19
+	public function getFilter($filter = array(), $where = false, $and = false) {
20 20
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
21 21
 		$filters = array();
22 22
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
23 23
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
24 24
 				$filters = $globalStatsFilters[$globalFilterName];
25 25
 			} else {
26
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
26
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
27 27
 			}
28 28
 		}
29 29
 		if (isset($filter[0]['source'])) {
30
-			$filters = array_merge($filters,$filter);
30
+			$filters = array_merge($filters, $filter);
31 31
 		}
32
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
32
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
33 33
 		$filter_query_join = '';
34 34
 		$filter_query_where = '';
35
-		foreach($filters as $flt) {
35
+		foreach ($filters as $flt) {
36 36
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
37 37
 				if (isset($flt['source'])) {
38
-					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id";
38
+					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id";
39 39
 				} else {
40
-					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id";
40
+					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id";
41 41
 				}
42 42
 			}
43 43
 		}
44 44
 		if (isset($filter['source']) && !empty($filter['source'])) {
45
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
45
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
46 46
 		}
47 47
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
48 48
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
72 72
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
73 73
 		if ($filter_query_where != '') {
74
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
74
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
75 75
 		}
76 76
 		$filter_query = $filter_query_join.$filter_query_where;
77 77
 		return $filter_query;
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 	* @return Array the spotter information
87 87
 	*
88 88
 	*/
89
-	public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false)
89
+	public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false)
90 90
 	{
91 91
 		date_default_timezone_set('UTC');
92 92
 		if (!is_string($query))
@@ -106,13 +106,13 @@  discard block
 block discarded – undo
106 106
 			$sth = $this->db->prepare($query.$limitQuery);
107 107
 			$sth->execute($params);
108 108
 		} catch (PDOException $e) {
109
-			printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery);
109
+			printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery);
110 110
 			exit();
111 111
 		}
112 112
 		
113 113
 		$num_rows = 0;
114 114
 		$spotter_array = array();
115
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
115
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
116 116
 		{
117 117
 			$num_rows++;
118 118
 			$temp_array = array();
@@ -144,10 +144,10 @@  discard block
 block discarded – undo
144 144
 			}
145 145
 			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];
146 146
 
147
-			if($temp_array['mmsi'] != "")
147
+			if ($temp_array['mmsi'] != "")
148 148
 			{
149 149
 				$Image = new Image($this->db);
150
-				if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']);
150
+				if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'], '', $temp_array['ident']);
151 151
 				else $image_array = $Image->getMarineImage($temp_array['mmsi']);
152 152
 				unset($Image);
153 153
 				if (count($image_array) > 0) {
@@ -183,17 +183,17 @@  discard block
 block discarded – undo
183 183
 				{
184 184
 					$temp_array['date'] = "about ".$dateArray['hours']." hours ago";
185 185
 				} else {
186
-					$temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC"));
186
+					$temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC"));
187 187
 				}
188 188
 				$temp_array['date_minutes_past'] = $dateArray['minutes'];
189
-				$temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC"));
190
-				$temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC"));
189
+				$temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC"));
190
+				$temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC"));
191 191
 				$temp_array['date_unix'] = strtotime($row['date']." UTC");
192 192
 				if (isset($row['last_seen']) && $row['last_seen'] != '') {
193 193
 					if (strtotime($row['last_seen']) > strtotime($row['date'])) {
194 194
 						$temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']);
195
-						$temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC"));
196
-						$temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC"));
195
+						$temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC"));
196
+						$temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC"));
197 197
 						$temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC");
198 198
 					}
199 199
 				}
@@ -226,8 +226,8 @@  discard block
 block discarded – undo
226 226
 		if ($limit != "")
227 227
 		{
228 228
 			$limit_array = explode(",", $limit);
229
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
230
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
229
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
230
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
231 231
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
232 232
 			{
233 233
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
@@ -241,8 +241,8 @@  discard block
 block discarded – undo
241 241
 		} else {
242 242
 			$orderby_query = " ORDER BY marine_output.date DESC";
243 243
 		}
244
-		$query  = $global_query.$filter_query." ".$orderby_query;
245
-		$spotter_array = $this->getDataFromDB($query, array(),$limit_query,true);
244
+		$query = $global_query.$filter_query." ".$orderby_query;
245
+		$spotter_array = $this->getDataFromDB($query, array(), $limit_query, true);
246 246
 		return $spotter_array;
247 247
 	}
248 248
     
@@ -260,8 +260,8 @@  discard block
 block discarded – undo
260 260
 		if ($id == '') return array();
261 261
 		$additional_query = "marine_output.fammarine_id = :id";
262 262
 		$query_values = array(':id' => $id);
263
-		$query  = $global_query." WHERE ".$additional_query." ";
264
-		$spotter_array = $this->getDataFromDB($query,$query_values);
263
+		$query = $global_query." WHERE ".$additional_query." ";
264
+		$spotter_array = $this->getDataFromDB($query, $query_values);
265 265
 		return $spotter_array;
266 266
 	}
267 267
 
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 		$query_values = array();
281 281
 		$limit_query = '';
282 282
 		$additional_query = '';
283
-		$filter_query = $this->getFilter($filter,true,true);
283
+		$filter_query = $this->getFilter($filter, true, true);
284 284
 		if ($ident != "")
285 285
 		{
286 286
 			if (!is_string($ident))
@@ -296,8 +296,8 @@  discard block
 block discarded – undo
296 296
 		{
297 297
 			$limit_array = explode(",", $limit);
298 298
 			
299
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
300
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
299
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
300
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
301 301
 			
302 302
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
303 303
 			{
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
 		return $spotter_array;
322 322
 	}
323 323
 	
324
-	public function getMarineDataByDate($date = '', $limit = '', $sort = '',$filter = array())
324
+	public function getMarineDataByDate($date = '', $limit = '', $sort = '', $filter = array())
325 325
 	{
326 326
 		global $global_query, $globalTimezone, $globalDBdriver;
327 327
 		
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
 		$limit_query = '';
330 330
 		$additional_query = '';
331 331
 
332
-		$filter_query = $this->getFilter($filter,true,true);
332
+		$filter_query = $this->getFilter($filter, true, true);
333 333
 		
334 334
 		if ($date != "")
335 335
 		{
@@ -355,8 +355,8 @@  discard block
 block discarded – undo
355 355
 		{
356 356
 			$limit_array = explode(",", $limit);
357 357
 			
358
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
359
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
358
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
359
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
360 360
 			
361 361
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
362 362
 			{
@@ -387,11 +387,11 @@  discard block
 block discarded – undo
387 387
 	* @return Array list of source name
388 388
 	*
389 389
 	*/
390
-	public function getAllSourceName($type = '',$filters = array())
390
+	public function getAllSourceName($type = '', $filters = array())
391 391
 	{
392
-		$filter_query = $this->getFilter($filters,true,true);
392
+		$filter_query = $this->getFilter($filters, true, true);
393 393
 		$query_values = array();
394
-		$query  = "SELECT DISTINCT marine_output.source_name 
394
+		$query = "SELECT DISTINCT marine_output.source_name 
395 395
 				FROM marine_output".$filter_query." marine_output.source_name <> ''";
396 396
 		if ($type != '') {
397 397
 			$query_values = array(':type' => $type);
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
 		$source_array = array();
407 407
 		$temp_array = array();
408 408
 		
409
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
409
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
410 410
 		{
411 411
 			$temp_array['source_name'] = $row['source_name'];
412 412
 			$source_array[] = $temp_array;
@@ -423,8 +423,8 @@  discard block
 block discarded – undo
423 423
 	*/
424 424
 	public function getAllIdents($filters = array())
425 425
 	{
426
-		$filter_query = $this->getFilter($filters,true,true);
427
-		$query  = "SELECT DISTINCT marine_output.ident
426
+		$filter_query = $this->getFilter($filters, true, true);
427
+		$query = "SELECT DISTINCT marine_output.ident
428 428
 								FROM marine_output".$filter_query." marine_output.ident <> '' 
429 429
 								ORDER BY marine_output.date ASC LIMIT 700 OFFSET 0";
430 430
 
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
 		$ident_array = array();
435 435
 		$temp_array = array();
436 436
 		
437
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
437
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
438 438
 		{
439 439
 			$temp_array['ident'] = $row['ident'];
440 440
 			$ident_array[] = $temp_array;
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
 	*/
452 452
 	public function getIdentity($mmsi)
453 453
 	{
454
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
454
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT);
455 455
 		$query  = "SELECT * FROM marine_identity WHERE mmsi = :mmsi LIMIT 1";
456 456
 		$sth = $this->db->prepare($query);
457 457
 		$sth->execute(array(':mmsi' => $mmsi));
@@ -476,12 +476,12 @@  discard block
 block discarded – undo
476 476
 		} else $offset = '+00:00';
477 477
 
478 478
 		if ($globalDBdriver == 'mysql') {
479
-			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date
479
+			$query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date
480 480
 								FROM marine_output
481 481
 								WHERE marine_output.date <> '' 
482 482
 								ORDER BY marine_output.date ASC LIMIT 0,200";
483 483
 		} else {
484
-			$query  = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
484
+			$query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
485 485
 								FROM marine_output
486 486
 								WHERE marine_output.date <> '' 
487 487
 								ORDER BY marine_output.date ASC LIMIT 0,200";
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
 		$date_array = array();
494 494
 		$temp_array = array();
495 495
 		
496
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
496
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
497 497
 		{
498 498
 			$temp_array['date'] = $row['date'];
499 499
 
@@ -512,11 +512,11 @@  discard block
 block discarded – undo
512 512
 	* @return String success or false
513 513
 	*
514 514
 	*/	
515
-	public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL)
515
+	public function updateIdentMarineData($fammarine_id = '', $ident = '', $fromsource = NULL)
516 516
 	{
517 517
 
518 518
 		$query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id';
519
-                $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident);
519
+                $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident);
520 520
 
521 521
 		try {
522 522
 			$sth = $this->db->prepare($query);
@@ -538,11 +538,11 @@  discard block
 block discarded – undo
538 538
 	* @return String success or false
539 539
 	*
540 540
 	*/	
541
-	public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '')
541
+	public function updateStatusMarineData($fammarine_id = '', $status_id = '', $status = '')
542 542
 	{
543 543
 
544 544
 		$query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id';
545
-                $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id);
545
+                $query_values = array(':fammarine_id' => $fammarine_id, ':status' => $status, ':status_id' => $status_id);
546 546
 
547 547
 		try {
548 548
 			$sth = $this->db->prepare($query);
@@ -565,7 +565,7 @@  discard block
 block discarded – undo
565 565
 	public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '')
566 566
 	{
567 567
 		$query = 'UPDATE marine_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE fammarine_id = :fammarine_id';
568
-                $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident);
568
+                $query_values = array(':fammarine_id' => $fammarine_id, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident);
569 569
 
570 570
 		try {
571 571
 			$sth = $this->db->prepare($query);
@@ -603,7 +603,7 @@  discard block
 block discarded – undo
603 603
 	* @param String $verticalrate vertival rate of flight
604 604
 	* @return String success or false
605 605
 	*/
606
-	public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$format_source = '', $source_name = '')
606
+	public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $format_source = '', $source_name = '')
607 607
 	{
608 608
 		global $globalURL, $globalMarineImageFetch;
609 609
 		
@@ -670,31 +670,31 @@  discard block
 block discarded – undo
670 670
 		}
671 671
 
672 672
     
673
-		if ($date == "" || strtotime($date) < time()-20*60)
673
+		if ($date == "" || strtotime($date) < time() - 20*60)
674 674
 		{
675 675
 			$date = date("Y-m-d H:i:s", time());
676 676
 		}
677 677
 
678
-		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
679
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
680
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
681
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
682
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
683
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
684
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
685
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING);
686
-		$type = filter_var($type,FILTER_SANITIZE_STRING);
687
-		$status = filter_var($status,FILTER_SANITIZE_STRING);
688
-		$imo = filter_var($imo,FILTER_SANITIZE_STRING);
689
-		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
690
-		$arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING);
691
-		$arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING);
678
+		$fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING);
679
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
680
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
681
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
682
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
683
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
684
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
685
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING);
686
+		$type = filter_var($type, FILTER_SANITIZE_STRING);
687
+		$status = filter_var($status, FILTER_SANITIZE_STRING);
688
+		$imo = filter_var($imo, FILTER_SANITIZE_STRING);
689
+		$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
690
+		$arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING);
691
+		$arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING);
692 692
 	
693 693
 		if (isset($globalMarineImageFetch) && $globalMarineImageFetch === TRUE) {
694 694
 			$Image = new Image($this->db);
695
-			$image_array = $Image->getMarineImage($mmsi,$imo,$ident);
695
+			$image_array = $Image->getMarineImage($mmsi, $imo, $ident);
696 696
 			if (!isset($image_array[0]['mmsi'])) {
697
-				$Image->addMarineImage($mmsi,$imo,$ident);
697
+				$Image->addMarineImage($mmsi, $imo, $ident);
698 698
 			}
699 699
 			unset($Image);
700 700
 		}
@@ -706,10 +706,10 @@  discard block
 block discarded – undo
706 706
                 if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
707 707
                 if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
708 708
                 if ($arrival_date == '') $arrival_date = NULL;
709
-		$query  = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) 
709
+		$query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) 
710 710
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)";
711 711
 
712
-		$query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':mmsi' => $mmsi,':type' => $type,':status' => $status,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date);
712
+		$query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':speed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':mmsi' => $mmsi, ':type' => $type, ':status' => $status, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date);
713 713
 		try {
714 714
 		        
715 715
 			$sth = $this->db->prepare($query);
@@ -734,13 +734,13 @@  discard block
 block discarded – undo
734 734
 	{
735 735
 		global $globalDBdriver, $globalTimezone;
736 736
 		if ($globalDBdriver == 'mysql') {
737
-			$query  = "SELECT marine_output.ident FROM marine_output 
737
+			$query = "SELECT marine_output.ident FROM marine_output 
738 738
 								WHERE marine_output.ident = :ident 
739 739
 								AND marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
740 740
 								AND marine_output.date < UTC_TIMESTAMP()";
741 741
 			$query_data = array(':ident' => $ident);
742 742
 		} else {
743
-			$query  = "SELECT marine_output.ident FROM marine_output 
743
+			$query = "SELECT marine_output.ident FROM marine_output 
744 744
 								WHERE marine_output.ident = :ident 
745 745
 								AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
746 746
 								AND marine_output.date < now() AT TIME ZONE 'UTC'";
@@ -749,8 +749,8 @@  discard block
 block discarded – undo
749 749
 		
750 750
 		$sth = $this->db->prepare($query);
751 751
 		$sth->execute($query_data);
752
-    		$ident_result='';
753
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
752
+    		$ident_result = '';
753
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
754 754
 		{
755 755
 			$ident_result = $row['ident'];
756 756
 		}
@@ -776,8 +776,8 @@  discard block
 block discarded – undo
776 776
 				return false;
777 777
 			} else {
778 778
 				$q_array = explode(" ", $q);
779
-				foreach ($q_array as $q_item){
780
-					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
779
+				foreach ($q_array as $q_item) {
780
+					$q_item = filter_var($q_item, FILTER_SANITIZE_STRING);
781 781
 					$additional_query .= " AND (";
782 782
 					$additional_query .= "(marine_output.ident like '%".$q_item."%')";
783 783
 					$additional_query .= ")";
@@ -785,11 +785,11 @@  discard block
 block discarded – undo
785 785
 			}
786 786
 		}
787 787
 		if ($globalDBdriver == 'mysql') {
788
-			$query  = "SELECT marine_output.* FROM marine_output 
788
+			$query = "SELECT marine_output.* FROM marine_output 
789 789
 				WHERE marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." 
790 790
 				AND marine_output.date < UTC_TIMESTAMP()";
791 791
 		} else {
792
-			$query  = "SELECT marine_output.* FROM marine_output 
792
+			$query = "SELECT marine_output.* FROM marine_output 
793 793
 				WHERE marine_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." 
794 794
 				AND marine_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
795 795
 		}
@@ -808,16 +808,16 @@  discard block
 block discarded – undo
808 808
 	*
809 809
 	*/
810 810
 
811
-	public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
811
+	public function countAllMarineOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
812 812
 	{
813 813
 		global $globalDBdriver, $globalArchive;
814 814
 		//$filter_query = $this->getFilter($filters,true,true);
815
-		$Connection= new Connection($this->db);
815
+		$Connection = new Connection($this->db);
816 816
 		if (!$Connection->tableExists('countries')) return array();
817 817
 		require_once('class.SpotterLive.php');
818 818
 		if (!isset($globalArchive) || $globalArchive !== TRUE) {
819 819
 			$MarineLive = new MarineLive();
820
-			$filter_query = $MarineLive->getFilter($filters,true,true);
820
+			$filter_query = $MarineLive->getFilter($filters, true, true);
821 821
 			$filter_query .= ' over_country IS NOT NULL';
822 822
 			if ($olderthanmonths > 0) {
823 823
 				if ($globalDBdriver == 'mysql') {
@@ -836,7 +836,7 @@  discard block
 block discarded – undo
836 836
 			$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb FROM countries c INNER JOIN (SELECT DISTINCT flightaware_id,over_country FROM marine_live".$filter_query.") l ON c.iso2 = l.over_country ";
837 837
 		} else {
838 838
 			$MarineArchive = new MarineArchive();
839
-			$filter_query = $MarineLive->getFilter($filters,true,true);
839
+			$filter_query = $MarineLive->getFilter($filters, true, true);
840 840
 			$filter_query .= ' over_country IS NOT NULL';
841 841
 			if ($olderthanmonths > 0) {
842 842
 				if ($globalDBdriver == 'mysql') {
@@ -864,7 +864,7 @@  discard block
 block discarded – undo
864 864
 		$flight_array = array();
865 865
 		$temp_array = array();
866 866
         
867
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
867
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
868 868
 		{
869 869
 			$temp_array['flight_count'] = $row['nb'];
870 870
 			$temp_array['flight_country'] = $row['name'];
@@ -883,11 +883,11 @@  discard block
 block discarded – undo
883 883
 	* @return Array the callsign list
884 884
 	*
885 885
 	*/
886
-	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
886
+	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
887 887
 	{
888 888
 		global $globalDBdriver;
889
-		$filter_query = $this->getFilter($filters,true,true);
890
-		$query  = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count 
889
+		$filter_query = $this->getFilter($filters, true, true);
890
+		$query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count 
891 891
                     FROM marine_output".$filter_query." marine_output.ident <> ''";
892 892
 		 if ($olderthanmonths > 0) {
893 893
 			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
@@ -901,28 +901,28 @@  discard block
 block discarded – undo
901 901
 		if ($year != '') {
902 902
 			if ($globalDBdriver == 'mysql') {
903 903
 				$query .= " AND YEAR(marine_output.date) = :year";
904
-				$query_values = array_merge($query_values,array(':year' => $year));
904
+				$query_values = array_merge($query_values, array(':year' => $year));
905 905
 			} else {
906 906
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
907
-				$query_values = array_merge($query_values,array(':year' => $year));
907
+				$query_values = array_merge($query_values, array(':year' => $year));
908 908
 			}
909 909
 		}
910 910
 		if ($month != '') {
911 911
 			if ($globalDBdriver == 'mysql') {
912 912
 				$query .= " AND MONTH(marine_output.date) = :month";
913
-				$query_values = array_merge($query_values,array(':month' => $month));
913
+				$query_values = array_merge($query_values, array(':month' => $month));
914 914
 			} else {
915 915
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
916
-				$query_values = array_merge($query_values,array(':month' => $month));
916
+				$query_values = array_merge($query_values, array(':month' => $month));
917 917
 			}
918 918
 		}
919 919
 		if ($day != '') {
920 920
 			if ($globalDBdriver == 'mysql') {
921 921
 				$query .= " AND DAY(marine_output.date) = :day";
922
-				$query_values = array_merge($query_values,array(':day' => $day));
922
+				$query_values = array_merge($query_values, array(':day' => $day));
923 923
 			} else {
924 924
 				$query .= " AND EXTRACT(DAY FROM marine_output.date) = :day";
925
-				$query_values = array_merge($query_values,array(':day' => $day));
925
+				$query_values = array_merge($query_values, array(':day' => $day));
926 926
 			}
927 927
 		}
928 928
 		$query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC";
@@ -934,7 +934,7 @@  discard block
 block discarded – undo
934 934
 		$callsign_array = array();
935 935
 		$temp_array = array();
936 936
         
937
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
937
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
938 938
 		{
939 939
 			$temp_array['callsign_icao'] = $row['ident'];
940 940
 			$temp_array['airline_name'] = $row['airline_name'];
@@ -986,7 +986,7 @@  discard block
 block discarded – undo
986 986
 		$date_array = array();
987 987
 		$temp_array = array();
988 988
         
989
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
989
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
990 990
 		{
991 991
 			$temp_array['date_name'] = $row['date_name'];
992 992
 			$temp_array['date_count'] = $row['date_count'];
@@ -1012,7 +1012,7 @@  discard block
 block discarded – undo
1012 1012
 			$datetime = new DateTime();
1013 1013
 			$offset = $datetime->format('P');
1014 1014
 		} else $offset = '+00:00';
1015
-		$filter_query = $this->getFilter($filters,true,true);
1015
+		$filter_query = $this->getFilter($filters, true, true);
1016 1016
 		if ($globalDBdriver == 'mysql') {
1017 1017
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
1018 1018
 								FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)";
@@ -1033,7 +1033,7 @@  discard block
 block discarded – undo
1033 1033
 		$date_array = array();
1034 1034
 		$temp_array = array();
1035 1035
         
1036
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1036
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1037 1037
 		{
1038 1038
 			$temp_array['date_name'] = $row['date_name'];
1039 1039
 			$temp_array['date_count'] = $row['date_count'];
@@ -1058,7 +1058,7 @@  discard block
 block discarded – undo
1058 1058
 			$datetime = new DateTime();
1059 1059
 			$offset = $datetime->format('P');
1060 1060
 		} else $offset = '+00:00';
1061
-		$filter_query = $this->getFilter($filters,true,true);
1061
+		$filter_query = $this->getFilter($filters, true, true);
1062 1062
 		if ($globalDBdriver == 'mysql') {
1063 1063
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
1064 1064
 								FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)";
@@ -1079,7 +1079,7 @@  discard block
 block discarded – undo
1079 1079
 		$date_array = array();
1080 1080
 		$temp_array = array();
1081 1081
         
1082
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1082
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1083 1083
 		{
1084 1084
 			$temp_array['date_name'] = $row['date_name'];
1085 1085
 			$temp_array['date_count'] = $row['date_count'];
@@ -1126,7 +1126,7 @@  discard block
 block discarded – undo
1126 1126
 		$date_array = array();
1127 1127
 		$temp_array = array();
1128 1128
         
1129
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1129
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1130 1130
 		{
1131 1131
 			$temp_array['month_name'] = $row['month_name'];
1132 1132
 			$temp_array['year_name'] = $row['year_name'];
@@ -1155,7 +1155,7 @@  discard block
 block discarded – undo
1155 1155
 			$datetime = new DateTime();
1156 1156
 			$offset = $datetime->format('P');
1157 1157
 		} else $offset = '+00:00';
1158
-		$filter_query = $this->getFilter($filters,true,true);
1158
+		$filter_query = $this->getFilter($filters, true, true);
1159 1159
 		if ($globalDBdriver == 'mysql') {
1160 1160
 			$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
1161 1161
 								FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)";
@@ -1176,7 +1176,7 @@  discard block
 block discarded – undo
1176 1176
 		$date_array = array();
1177 1177
 		$temp_array = array();
1178 1178
         
1179
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1179
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1180 1180
 		{
1181 1181
 			$temp_array['year_name'] = $row['year_name'];
1182 1182
 			$temp_array['month_name'] = $row['month_name'];
@@ -1196,7 +1196,7 @@  discard block
 block discarded – undo
1196 1196
 	* @return Array the hour list
1197 1197
 	*
1198 1198
 	*/
1199
-	public function countAllHours($orderby,$filters = array())
1199
+	public function countAllHours($orderby, $filters = array())
1200 1200
 	{
1201 1201
 		global $globalTimezone, $globalDBdriver;
1202 1202
 		if ($globalTimezone != '') {
@@ -1244,7 +1244,7 @@  discard block
 block discarded – undo
1244 1244
 		$hour_array = array();
1245 1245
 		$temp_array = array();
1246 1246
         
1247
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1247
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1248 1248
 		{
1249 1249
 			$temp_array['hour_name'] = $row['hour_name'];
1250 1250
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1266,8 +1266,8 @@  discard block
 block discarded – undo
1266 1266
 	public function countAllHoursByDate($date, $filters = array())
1267 1267
 	{
1268 1268
 		global $globalTimezone, $globalDBdriver;
1269
-		$filter_query = $this->getFilter($filters,true,true);
1270
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
1269
+		$filter_query = $this->getFilter($filters, true, true);
1270
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
1271 1271
 		if ($globalTimezone != '') {
1272 1272
 			date_default_timezone_set($globalTimezone);
1273 1273
 			$datetime = new DateTime($date);
@@ -1275,12 +1275,12 @@  discard block
 block discarded – undo
1275 1275
 		} else $offset = '+00:00';
1276 1276
 
1277 1277
 		if ($globalDBdriver == 'mysql') {
1278
-			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1278
+			$query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1279 1279
 								FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = :date
1280 1280
 								GROUP BY hour_name 
1281 1281
 								ORDER BY hour_name ASC";
1282 1282
 		} else {
1283
-			$query  = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1283
+			$query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1284 1284
 								FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date
1285 1285
 								GROUP BY hour_name 
1286 1286
 								ORDER BY hour_name ASC";
@@ -1292,7 +1292,7 @@  discard block
 block discarded – undo
1292 1292
 		$hour_array = array();
1293 1293
 		$temp_array = array();
1294 1294
         
1295
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1295
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1296 1296
 		{
1297 1297
 			$temp_array['hour_name'] = $row['hour_name'];
1298 1298
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1314,8 +1314,8 @@  discard block
 block discarded – undo
1314 1314
 	public function countAllHoursByIdent($ident, $filters = array())
1315 1315
 	{
1316 1316
 		global $globalTimezone, $globalDBdriver;
1317
-		$filter_query = $this->getFilter($filters,true,true);
1318
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
1317
+		$filter_query = $this->getFilter($filters, true, true);
1318
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1319 1319
 		if ($globalTimezone != '') {
1320 1320
 			date_default_timezone_set($globalTimezone);
1321 1321
 			$datetime = new DateTime();
@@ -1323,12 +1323,12 @@  discard block
 block discarded – undo
1323 1323
 		} else $offset = '+00:00';
1324 1324
 
1325 1325
 		if ($globalDBdriver == 'mysql') {
1326
-			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1326
+			$query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1327 1327
 								FROM marine_output".$filter_query." marine_output.ident = :ident 
1328 1328
 								GROUP BY hour_name 
1329 1329
 								ORDER BY hour_name ASC";
1330 1330
 		} else {
1331
-			$query  = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1331
+			$query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1332 1332
 								FROM marine_output".$filter_query." marine_output.ident = :ident 
1333 1333
 								GROUP BY hour_name 
1334 1334
 								ORDER BY hour_name ASC";
@@ -1336,12 +1336,12 @@  discard block
 block discarded – undo
1336 1336
       
1337 1337
 		
1338 1338
 		$sth = $this->db->prepare($query);
1339
-		$sth->execute(array(':ident' => $ident,':offset' => $offset));
1339
+		$sth->execute(array(':ident' => $ident, ':offset' => $offset));
1340 1340
       
1341 1341
 		$hour_array = array();
1342 1342
 		$temp_array = array();
1343 1343
         
1344
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1344
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1345 1345
 		{
1346 1346
 			$temp_array['hour_name'] = $row['hour_name'];
1347 1347
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1360,33 +1360,33 @@  discard block
 block discarded – undo
1360 1360
 	* @return Integer the number of flights
1361 1361
 	*
1362 1362
 	*/
1363
-	public function countOverallMarine($filters = array(),$year = '',$month = '')
1363
+	public function countOverallMarine($filters = array(), $year = '', $month = '')
1364 1364
 	{
1365 1365
 		global $globalDBdriver;
1366 1366
 		//$queryi  = "SELECT COUNT(marine_output.marine_id) AS flight_count FROM marine_output";
1367
-		$queryi  = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output";
1367
+		$queryi = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output";
1368 1368
 		$query_values = array();
1369 1369
 		$query = '';
1370 1370
 		if ($year != '') {
1371 1371
 			if ($globalDBdriver == 'mysql') {
1372 1372
 				$query .= " AND YEAR(marine_output.date) = :year";
1373
-				$query_values = array_merge($query_values,array(':year' => $year));
1373
+				$query_values = array_merge($query_values, array(':year' => $year));
1374 1374
 			} else {
1375 1375
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
1376
-				$query_values = array_merge($query_values,array(':year' => $year));
1376
+				$query_values = array_merge($query_values, array(':year' => $year));
1377 1377
 			}
1378 1378
 		}
1379 1379
 		if ($month != '') {
1380 1380
 			if ($globalDBdriver == 'mysql') {
1381 1381
 				$query .= " AND MONTH(marine_output.date) = :month";
1382
-				$query_values = array_merge($query_values,array(':month' => $month));
1382
+				$query_values = array_merge($query_values, array(':month' => $month));
1383 1383
 			} else {
1384 1384
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
1385
-				$query_values = array_merge($query_values,array(':month' => $month));
1385
+				$query_values = array_merge($query_values, array(':month' => $month));
1386 1386
 			}
1387 1387
 		}
1388 1388
 		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1389
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1389
+		else $queryi .= $this->getFilter($filters, true, true).substr($query, 4);
1390 1390
 		
1391 1391
 		$sth = $this->db->prepare($queryi);
1392 1392
 		$sth->execute($query_values);
@@ -1403,7 +1403,7 @@  discard block
 block discarded – undo
1403 1403
 	public function countAllHoursFromToday($filters = array())
1404 1404
 	{
1405 1405
 		global $globalTimezone, $globalDBdriver;
1406
-		$filter_query = $this->getFilter($filters,true,true);
1406
+		$filter_query = $this->getFilter($filters, true, true);
1407 1407
 		if ($globalTimezone != '') {
1408 1408
 			date_default_timezone_set($globalTimezone);
1409 1409
 			$datetime = new DateTime();
@@ -1411,12 +1411,12 @@  discard block
 block discarded – undo
1411 1411
 		} else $offset = '+00:00';
1412 1412
 
1413 1413
 		if ($globalDBdriver == 'mysql') {
1414
-			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1414
+			$query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1415 1415
 								FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = CURDATE()
1416 1416
 								GROUP BY hour_name 
1417 1417
 								ORDER BY hour_name ASC";
1418 1418
 		} else {
1419
-			$query  = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1419
+			$query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1420 1420
 								FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date)
1421 1421
 								GROUP BY hour_name 
1422 1422
 								ORDER BY hour_name ASC";
@@ -1428,7 +1428,7 @@  discard block
 block discarded – undo
1428 1428
 		$hour_array = array();
1429 1429
 		$temp_array = array();
1430 1430
         
1431
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1431
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1432 1432
 		{
1433 1433
 			$temp_array['hour_name'] = $row['hour_name'];
1434 1434
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1447,9 +1447,9 @@  discard block
 block discarded – undo
1447 1447
 	*/
1448 1448
 	public function getMarineIDBasedOnFamMarineID($fammarine_id)
1449 1449
 	{
1450
-		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
1450
+		$fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING);
1451 1451
 
1452
-		$query  = "SELECT marine_output.marine_id
1452
+		$query = "SELECT marine_output.marine_id
1453 1453
 				FROM marine_output 
1454 1454
 				WHERE marine_output.fammarine_id = '".$fammarine_id."'";
1455 1455
         
@@ -1457,7 +1457,7 @@  discard block
 block discarded – undo
1457 1457
 		$sth = $this->db->prepare($query);
1458 1458
 		$sth->execute();
1459 1459
 
1460
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1460
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1461 1461
 		{
1462 1462
 			return $row['marine_id'];
1463 1463
 		}
@@ -1482,23 +1482,23 @@  discard block
 block discarded – undo
1482 1482
 		}
1483 1483
 		
1484 1484
 		$current_date = date("Y-m-d H:i:s");
1485
-		$date = date("Y-m-d H:i:s",strtotime($dateString." UTC"));
1485
+		$date = date("Y-m-d H:i:s", strtotime($dateString." UTC"));
1486 1486
 		
1487 1487
 		$diff = abs(strtotime($current_date) - strtotime($date));
1488 1488
 
1489
-		$time_array['years'] = floor($diff / (365*60*60*24)); 
1489
+		$time_array['years'] = floor($diff/(365*60*60*24)); 
1490 1490
 		$years = $time_array['years'];
1491 1491
 		
1492
-		$time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
1492
+		$time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24));
1493 1493
 		$months = $time_array['months'];
1494 1494
 		
1495
-		$time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
1495
+		$time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24));
1496 1496
 		$days = $time_array['days'];
1497
-		$time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60));
1497
+		$time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60));
1498 1498
 		$hours = $time_array['hours'];
1499
-		$time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60);
1499
+		$time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60);
1500 1500
 		$minutes = $time_array['minutes'];
1501
-		$time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
1501
+		$time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
1502 1502
 		
1503 1503
 		return $time_array;
1504 1504
 	}
@@ -1521,63 +1521,63 @@  discard block
 block discarded – undo
1521 1521
 			$temp_array['direction_degree'] = $direction;
1522 1522
 			$temp_array['direction_shortname'] = "N";
1523 1523
 			$temp_array['direction_fullname'] = "North";
1524
-		} elseif ($direction >= 22.5 && $direction < 45){
1524
+		} elseif ($direction >= 22.5 && $direction < 45) {
1525 1525
 			$temp_array['direction_degree'] = $direction;
1526 1526
 			$temp_array['direction_shortname'] = "NNE";
1527 1527
 			$temp_array['direction_fullname'] = "North-Northeast";
1528
-		} elseif ($direction >= 45 && $direction < 67.5){
1528
+		} elseif ($direction >= 45 && $direction < 67.5) {
1529 1529
 			$temp_array['direction_degree'] = $direction;
1530 1530
 			$temp_array['direction_shortname'] = "NE";
1531 1531
 			$temp_array['direction_fullname'] = "Northeast";
1532
-		} elseif ($direction >= 67.5 && $direction < 90){
1532
+		} elseif ($direction >= 67.5 && $direction < 90) {
1533 1533
 			$temp_array['direction_degree'] = $direction;
1534 1534
 			$temp_array['direction_shortname'] = "ENE";
1535 1535
 			$temp_array['direction_fullname'] = "East-Northeast";
1536
-		} elseif ($direction >= 90 && $direction < 112.5){
1536
+		} elseif ($direction >= 90 && $direction < 112.5) {
1537 1537
 			$temp_array['direction_degree'] = $direction;
1538 1538
 			$temp_array['direction_shortname'] = "E";
1539 1539
 			$temp_array['direction_fullname'] = "East";
1540
-		} elseif ($direction >= 112.5 && $direction < 135){
1540
+		} elseif ($direction >= 112.5 && $direction < 135) {
1541 1541
 			$temp_array['direction_degree'] = $direction;
1542 1542
 			$temp_array['direction_shortname'] = "ESE";
1543 1543
 			$temp_array['direction_fullname'] = "East-Southeast";
1544
-		} elseif ($direction >= 135 && $direction < 157.5){
1544
+		} elseif ($direction >= 135 && $direction < 157.5) {
1545 1545
 			$temp_array['direction_degree'] = $direction;
1546 1546
 			$temp_array['direction_shortname'] = "SE";
1547 1547
 			$temp_array['direction_fullname'] = "Southeast";
1548
-		} elseif ($direction >= 157.5 && $direction < 180){
1548
+		} elseif ($direction >= 157.5 && $direction < 180) {
1549 1549
 			$temp_array['direction_degree'] = $direction;
1550 1550
 			$temp_array['direction_shortname'] = "SSE";
1551 1551
 			$temp_array['direction_fullname'] = "South-Southeast";
1552
-		} elseif ($direction >= 180 && $direction < 202.5){
1552
+		} elseif ($direction >= 180 && $direction < 202.5) {
1553 1553
 			$temp_array['direction_degree'] = $direction;
1554 1554
 			$temp_array['direction_shortname'] = "S";
1555 1555
 			$temp_array['direction_fullname'] = "South";
1556
-		} elseif ($direction >= 202.5 && $direction < 225){
1556
+		} elseif ($direction >= 202.5 && $direction < 225) {
1557 1557
 			$temp_array['direction_degree'] = $direction;
1558 1558
 			$temp_array['direction_shortname'] = "SSW";
1559 1559
 			$temp_array['direction_fullname'] = "South-Southwest";
1560
-		} elseif ($direction >= 225 && $direction < 247.5){
1560
+		} elseif ($direction >= 225 && $direction < 247.5) {
1561 1561
 			$temp_array['direction_degree'] = $direction;
1562 1562
 			$temp_array['direction_shortname'] = "SW";
1563 1563
 			$temp_array['direction_fullname'] = "Southwest";
1564
-		} elseif ($direction >= 247.5 && $direction < 270){
1564
+		} elseif ($direction >= 247.5 && $direction < 270) {
1565 1565
 			$temp_array['direction_degree'] = $direction;
1566 1566
 			$temp_array['direction_shortname'] = "WSW";
1567 1567
 			$temp_array['direction_fullname'] = "West-Southwest";
1568
-		} elseif ($direction >= 270 && $direction < 292.5){
1568
+		} elseif ($direction >= 270 && $direction < 292.5) {
1569 1569
 			$temp_array['direction_degree'] = $direction;
1570 1570
 			$temp_array['direction_shortname'] = "W";
1571 1571
 			$temp_array['direction_fullname'] = "West";
1572
-		} elseif ($direction >= 292.5 && $direction < 315){
1572
+		} elseif ($direction >= 292.5 && $direction < 315) {
1573 1573
 			$temp_array['direction_degree'] = $direction;
1574 1574
 			$temp_array['direction_shortname'] = "WNW";
1575 1575
 			$temp_array['direction_fullname'] = "West-Northwest";
1576
-		} elseif ($direction >= 315 && $direction < 337.5){
1576
+		} elseif ($direction >= 315 && $direction < 337.5) {
1577 1577
 			$temp_array['direction_degree'] = $direction;
1578 1578
 			$temp_array['direction_shortname'] = "NW";
1579 1579
 			$temp_array['direction_fullname'] = "Northwest";
1580
-		} elseif ($direction >= 337.5 && $direction < 360){
1580
+		} elseif ($direction >= 337.5 && $direction < 360) {
1581 1581
 			$temp_array['direction_degree'] = $direction;
1582 1582
 			$temp_array['direction_shortname'] = "NNW";
1583 1583
 			$temp_array['direction_fullname'] = "North-Northwest";
@@ -1594,11 +1594,11 @@  discard block
 block discarded – undo
1594 1594
 	* @param Float $longitude longitute of the flight
1595 1595
 	* @return String the countrie
1596 1596
 	*/
1597
-	public function getCountryFromLatitudeLongitude($latitude,$longitude)
1597
+	public function getCountryFromLatitudeLongitude($latitude, $longitude)
1598 1598
 	{
1599 1599
 		global $globalDBdriver, $globalDebug;
1600
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1601
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1600
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1601
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1602 1602
 	
1603 1603
 		$Connection = new Connection($this->db);
1604 1604
 		if (!$Connection->tableExists('countries')) return '';
@@ -1638,7 +1638,7 @@  discard block
 block discarded – undo
1638 1638
 	public function getCountryFromISO2($iso2)
1639 1639
 	{
1640 1640
 		global $globalDBdriver, $globalDebug;
1641
-		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
1641
+		$iso2 = filter_var($iso2, FILTER_SANITIZE_STRING);
1642 1642
 	
1643 1643
 		$Connection = new Connection($this->db);
1644 1644
 		if (!$Connection->tableExists('countries')) return '';
@@ -1686,7 +1686,7 @@  discard block
 block discarded – undo
1686 1686
 		
1687 1687
 		$bitly_data = json_decode($bitly_data);
1688 1688
 		$bitly_url = '';
1689
-		if ($bitly_data->status_txt = "OK"){
1689
+		if ($bitly_data->status_txt = "OK") {
1690 1690
 			$bitly_url = $bitly_data->data->url;
1691 1691
 		}
1692 1692
 
@@ -1696,7 +1696,7 @@  discard block
 block discarded – undo
1696 1696
 
1697 1697
 	public function getOrderBy()
1698 1698
 	{
1699
-		$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"));
1699
+		$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"));
1700 1700
 		
1701 1701
 		return $orderby;
1702 1702
 		
Please login to merge, or discard this patch.
statistics.php 1 patch
Spacing   +85 added lines, -85 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 }
20 20
 
21 21
 if (!isset($filter_name)) $filter_name = '';
22
-$airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
22
+$airline_icao = (string) filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING);
23 23
 if ($airline_icao == '' && isset($globalFilter)) {
24 24
 	if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
25 25
 }
@@ -34,8 +34,8 @@  discard block
 block discarded – undo
34 34
 	$title = _("Statistics");
35 35
 }
36 36
 
37
-$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
38
-$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
37
+$year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_NUMBER_INT);
38
+$month = filter_input(INPUT_GET, 'month', FILTER_SANITIZE_NUMBER_INT);
39 39
 
40 40
 require_once('header.php');
41 41
 
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 		date_default_timezone_set('UTC');
62 62
 		$lastupdate = strtotime($last_update[0]['value']);
63 63
 		if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone);
64
-		print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>';
64
+		print '<i>Last update: '.date('Y-m-d G:i:s', $lastupdate).'</i>';
65 65
 	}
66 66
     ?>
67 67
     </div>
@@ -70,30 +70,30 @@  discard block
 block discarded – undo
70 70
 <?php
71 71
     if ($type == 'aircraft') {
72 72
 ?>
73
-        <span><span class="badge"><?php print number_format($Stats->countOverallFlights($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Flights"); ?></span>
74
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
75
-        <span><span class="badge"><?php print number_format($Stats->countOverallArrival($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Arrivals seen"); ?></span>
76
-        <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
73
+        <span><span class="badge"><?php print number_format($Stats->countOverallFlights($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Flights"); ?></span>
74
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
75
+        <span><span class="badge"><?php print number_format($Stats->countOverallArrival($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Arrivals seen"); ?></span>
76
+        <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
77 77
 	<?php
78
-	    if ((isset($globalVA) && $globalVA) ||(isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
78
+	    if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
79 79
 	?>
80
-    	    <span><span class="badge"><?php print number_format($Stats->countOverallPilots($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Pilots"); ?></span>
81
-	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
80
+    	    <span><span class="badge"><?php print number_format($Stats->countOverallPilots($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Pilots"); ?></span>
81
+	    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
82 82
         <?php
83 83
     	    } else {
84 84
     	?>
85
-    	    <span><span class="badge"><?php print number_format($Stats->countOverallOwners($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Owners"); ?></span>
86
-	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
85
+    	    <span><span class="badge"><?php print number_format($Stats->countOverallOwners($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Owners"); ?></span>
86
+	    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
87 87
     	<?php
88 88
     	    }
89 89
     	?>
90
-        <span><span class="badge"><?php print number_format($Stats->countOverallAircrafts($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Aircrafts types"); ?></span>
91
-        <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
90
+        <span><span class="badge"><?php print number_format($Stats->countOverallAircrafts($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Aircrafts types"); ?></span>
91
+        <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
92 92
         <?php
93 93
     		if ($airline_icao == '') {
94 94
     	?>
95
-        <span><span class="badge"><?php print number_format($Stats->countOverallAirlines($filter_name,$year,$month)); ?></span> <?php echo _("Airlines"); ?></span>
96
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
95
+        <span><span class="badge"><?php print number_format($Stats->countOverallAirlines($filter_name, $year, $month)); ?></span> <?php echo _("Airlines"); ?></span>
96
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
97 97
 	<?php
98 98
 		}
99 99
 	?>
@@ -101,8 +101,8 @@  discard block
 block discarded – undo
101 101
 		if (!(isset($globalIVAO) && $globalIVAO) && !(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalphpVMS) && $globalphpVMS)) {
102 102
 			if ($airline_icao == '' || $airline_icao == 'all') {
103 103
 	?>
104
-        <span><span class="badge"><?php print number_format($Stats->countOverallMilitaryFlights($filter_name,$year,$month)); ?></span> <?php echo _("Military"); ?></span>
105
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
104
+        <span><span class="badge"><?php print number_format($Stats->countOverallMilitaryFlights($filter_name, $year, $month)); ?></span> <?php echo _("Military"); ?></span>
105
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
106 106
 	<?php
107 107
 			}
108 108
 		}
@@ -110,29 +110,29 @@  discard block
 block discarded – undo
110 110
 <?php
111 111
     } elseif ($type == 'marine') {
112 112
 ?>
113
-	<span><span class="badge"><?php print number_format($Marine->countOverallMarine($filter_name,$year,$month)); ?></span> <?php echo _("Vessels"); ?></span>
114
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
113
+	<span><span class="badge"><?php print number_format($Marine->countOverallMarine($filter_name, $year, $month)); ?></span> <?php echo _("Vessels"); ?></span>
114
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
115 115
 <?php
116 116
     } elseif ($type == 'tracker') {
117 117
 ?>
118
-	<span><span class="badge"><?php print number_format($Tracker->countOverallTracker($filter_name,$year,$month)); ?></span> <?php echo _("Trackers"); ?></span>
119
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
118
+	<span><span class="badge"><?php print number_format($Tracker->countOverallTracker($filter_name, $year, $month)); ?></span> <?php echo _("Trackers"); ?></span>
119
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
120 120
 <?php
121 121
     }
122 122
 ?>
123 123
     </p>
124
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
124
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
125 125
     <div class="specific-stats">
126 126
         <div class="row column">
127 127
             <div class="col-md-6">
128 128
                 <h2><?php echo _("Top 10 Most Common Aircraft Type"); ?></h2>
129 129
                  <?php
130
-                  $aircraft_array = $Stats->countAllAircraftTypes(true,$airline_icao,$filter_name,$year,$month);
130
+                  $aircraft_array = $Stats->countAllAircraftTypes(true, $airline_icao, $filter_name, $year, $month);
131 131
 		    if (count($aircraft_array) == 0) print _("No data available");
132 132
 		    else {
133 133
                     print '<div id="chart1" class="chart" width="100%"></div><script>';
134 134
                     $aircraft_data = '';
135
-                    foreach($aircraft_array as $aircraft_item)
135
+                    foreach ($aircraft_array as $aircraft_item)
136 136
                     {
137 137
                         $aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
138 138
                     }
@@ -161,17 +161,17 @@  discard block
 block discarded – undo
161 161
             	    ?>
162 162
                 </div>
163 163
             </div>
164
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
164
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
165 165
 <?php
166 166
 //    echo $airline_icao;
167 167
     if ($airline_icao == '' || $airline_icao == 'all') {
168
-	$airline_array = $Stats->countAllAirlines(true,$filter_name,$year,$month);
168
+	$airline_array = $Stats->countAllAirlines(true, $filter_name, $year, $month);
169 169
 	if (count($airline_array) > 0) {
170 170
             print '<div class="col-md-6">';
171 171
 	    print '<h2>'._("Top 10 Most Common Airline").'</h2>';
172 172
 	    print '<div id="chart2" class="chart" width="100%"></div><script>';
173 173
 	    $airline_data = '';
174
-	    foreach($airline_array as $airline_item)
174
+	    foreach ($airline_array as $airline_item)
175 175
 	    {
176 176
 		$airline_data .= '["'.$airline_item['airline_name'].' ('.$airline_item['airline_icao'].')",'.$airline_item['airline_count'].'],';
177 177
 	    }
@@ -197,14 +197,14 @@  discard block
 block discarded – undo
197 197
 	}
198 198
 ?>
199 199
         </div>
200
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
200
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
201 201
 <?php
202 202
     }
203 203
 ?>
204 204
         <div class="row column">
205 205
 <?php
206
-    $flightover_array = $Stats->countAllFlightOverCountries(false,$airline_icao,$filter_name,$year,$month);
207
-    if ((isset($globalVA) && $globalVA) ||(isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
206
+    $flightover_array = $Stats->countAllFlightOverCountries(false, $airline_icao, $filter_name, $year, $month);
207
+    if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
208 208
 	if (empty($flightover_array)) {
209 209
 	    print '<div class="col-md-12">';
210 210
 	} else {
@@ -213,12 +213,12 @@  discard block
 block discarded – undo
213 213
 ?>
214 214
                 <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2>
215 215
 <?php
216
-	$pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month);
216
+	$pilot_array = $Stats->countAllPilots(true, $airline_icao, $filter_name, $year, $month);
217 217
 	if (count($pilot_array) == 0) print _("No data available");
218 218
 	else {
219 219
 	    print '<div id="chart7" class="chart" width="100%"></div><script>';
220 220
 	    $pilot_data = '';
221
-	    foreach($pilot_array as $pilot_item)
221
+	    foreach ($pilot_array as $pilot_item)
222 222
 	    {
223 223
 		$pilot_data .= '["'.$pilot_item['pilot_name'].' ('.$pilot_item['pilot_id'].')",'.$pilot_item['pilot_count'].'],';
224 224
 	    }
@@ -240,19 +240,19 @@  discard block
 block discarded – undo
240 240
 ?>
241 241
             </div>
242 242
         
243
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
243
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
244 244
 <?php
245 245
     } else {
246 246
 ?>
247 247
             <div class="col-md-6">
248 248
                 <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
249 249
 <?php
250
-	$owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name,$year,$month);
250
+	$owner_array = $Stats->countAllOwners(true, $airline_icao, $filter_name, $year, $month);
251 251
 	if (count($owner_array) == 0) print _("No data available");
252 252
 	else {
253 253
 	    print '<div id="chart7" class="chart" width="100%"></div><script>';
254 254
 	    $owner_data = '';
255
-	    foreach($owner_array as $owner_item)
255
+	    foreach ($owner_array as $owner_item)
256 256
 	    {
257 257
 		$owner_data .= '["'.$owner_item['owner_name'].'",'.$owner_item['owner_count'].'],';
258 258
 	    }
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
                 </div>
273 273
             </div>
274 274
         
275
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
275
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
276 276
 <?php
277 277
     }
278 278
     if (!empty($flightover_array)) {
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 	    print '<div id="chart10" class="chart" width="100%"></div><script>';
287 287
 	    print 'var series = [';
288 288
             $flightover_data = '';
289
-	    foreach($flightover_array as $flightover_item)
289
+	    foreach ($flightover_array as $flightover_item)
290 290
 	    {
291 291
 		$flightover_data .= '[ "'.$flightover_item['flight_country_iso3'].'",'.$flightover_item['flight_count'].'],';
292 292
 	    }
@@ -332,21 +332,21 @@  discard block
 block discarded – undo
332 332
     }
333 333
 ?>
334 334
         </div>
335
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
335
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
336 336
 
337 337
     	
338 338
         </div>
339 339
         <div class="row column">
340 340
             <div class="col-md-6">
341 341
 <?php
342
-    $airport_airport_array = $Stats->countAllDepartureAirports(true,$airline_icao,$filter_name,$year,$month);
342
+    $airport_airport_array = $Stats->countAllDepartureAirports(true, $airline_icao, $filter_name, $year, $month);
343 343
     if (count($airport_airport_array) > 0) {
344 344
 	print '<h2>'._("Top 10 Most Common Departure Airports").'</h2>';
345 345
 	print '<div id="chart3" class="chart" width="100%"></div><script>';
346 346
         print "\n";
347 347
         print 'var series = [';
348 348
         $airport_data = '';
349
-	foreach($airport_airport_array as $airport_item)
349
+	foreach ($airport_airport_array as $airport_item)
350 350
 	{
351 351
 		$airport_data .= '[ "'.$airport_item['airport_departure_icao_count'].'", "'.$airport_item['airport_departure_icao'].'",'.$airport_item['airport_departure_latitude'].','.$airport_item['airport_departure_longitude'].'],';
352 352
 	}
@@ -397,18 +397,18 @@  discard block
 block discarded – undo
397 397
     }
398 398
 ?>
399 399
             </div>
400
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
400
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
401 401
 
402 402
             <div class="col-md-6">
403 403
 <?php
404
-    $airport_airport_array2 = $Stats->countAllArrivalAirports(true,$airline_icao,$filter_name,$year,$month);
404
+    $airport_airport_array2 = $Stats->countAllArrivalAirports(true, $airline_icao, $filter_name, $year, $month);
405 405
     if (count($airport_airport_array2) > 0) {
406 406
 	print '<h2>'._("Top 10 Most Common Arrival Airports").'</h2>';
407 407
 	print '<div id="chart4" class="chart" width="100%"></div><script>';
408 408
         print "\n";
409 409
         print 'var series = [';
410 410
         $airport_data = '';
411
-	foreach($airport_airport_array2 as $airport_item)
411
+	foreach ($airport_airport_array2 as $airport_item)
412 412
 	{
413 413
 		$airport_data .= '[ "'.$airport_item['airport_arrival_icao_count'].'", "'.$airport_item['airport_arrival_icao'].'",'.$airport_item['airport_arrival_latitude'].','.$airport_item['airport_arrival_longitude'].'],';
414 414
 	}
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
 ?>
462 462
             </div>
463 463
         </div>
464
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
464
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
465 465
 <?php
466 466
     if ($year == '' && $month == '') {
467 467
 ?>
@@ -469,19 +469,19 @@  discard block
 block discarded – undo
469 469
             <div class="col-md-6">
470 470
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
471 471
                 <?php
472
-                  $year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
472
+                  $year_array = $Stats->countAllMonthsLastYear(true, $airline_icao, $filter_name);
473 473
 		    if (count($year_array) == 0) print _("No data available");
474 474
 		    else {
475 475
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
476 476
 			$year_data = '';
477 477
 			$year_cnt = '';
478
-			foreach($year_array as $year_item)
478
+			foreach ($year_array as $year_item)
479 479
 			{
480 480
 			    $year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",';
481 481
 			    $year_cnt .= $year_item['date_count'].',';
482 482
 			}
483 483
 			$year_data = "['x',".substr($year_data, 0, -1)."]";
484
-			$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
484
+			$year_cnt = "['flights',".substr($year_cnt, 0, -1)."]";
485 485
 			print 'c3.generate({
486 486
                 	    bindto: "#chart8",
487 487
                 	    data: { x: "x",
@@ -494,23 +494,23 @@  discard block
 block discarded – undo
494 494
                     <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
495 495
                 </div>
496 496
             </div>
497
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
497
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
498 498
             <div class="col-md-6">
499 499
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
500 500
                 <?php
501
-                  $month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
501
+                  $month_array = $Stats->countAllDatesLastMonth($airline_icao, $filter_name);
502 502
 		    if (count($month_array) == 0) print _("No data available");
503 503
 		    else {
504 504
                 	print '<div id="chart9" class="chart" width="100%"></div><script>';
505 505
                         $month_data = '';
506 506
 			$month_cnt = '';
507
-			foreach($month_array as $month_item)
507
+			foreach ($month_array as $month_item)
508 508
 			{
509 509
 			    $month_data .= '"'.$month_item['date_name'].'",';
510 510
 			    $month_cnt .= $month_item['date_count'].',';
511 511
 			}
512 512
 			$month_data = "['x',".substr($month_data, 0, -1)."]";
513
-			$month_cnt = "['flights',".substr($month_cnt,0,-1)."]";
513
+			$month_cnt = "['flights',".substr($month_cnt, 0, -1)."]";
514 514
 			print 'c3.generate({
515 515
                 	    bindto: "#chart9",
516 516
                 	    data: { x: "x",
@@ -524,24 +524,24 @@  discard block
 block discarded – undo
524 524
                     <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
525 525
                 </div>
526 526
             </div>
527
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
527
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
528 528
 
529 529
             <div class="col-md-6">
530 530
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
531 531
                 <?php
532
-                    $date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
532
+                    $date_array = $Stats->countAllDatesLast7Days($airline_icao, $filter_name);
533 533
 		    if (empty($date_array)) print _("No data available");
534 534
 		    else {
535 535
                 	print '<div id="chart5" class="chart" width="100%"></div><script>';
536 536
                         $date_data = '';
537 537
 			$date_cnt = '';
538
-			foreach($date_array as $date_item)
538
+			foreach ($date_array as $date_item)
539 539
 			{
540 540
 			    $date_data .= '"'.$date_item['date_name'].'",';
541 541
 			    $date_cnt .= $date_item['date_count'].',';
542 542
 			}
543 543
 			$date_data = "['x',".substr($date_data, 0, -1)."]";
544
-			$date_cnt = "['flights',".substr($date_cnt,0,-1)."]";
544
+			$date_cnt = "['flights',".substr($date_cnt, 0, -1)."]";
545 545
 			print 'c3.generate({
546 546
                 	    bindto: "#chart5",
547 547
                 	    data: { x: "x",
@@ -555,23 +555,23 @@  discard block
 block discarded – undo
555 555
                     <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
556 556
                 </div>
557 557
             </div>
558
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
558
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
559 559
             <div class="col-md-6">
560 560
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
561 561
                 <?php
562
-                  $hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
562
+                  $hour_array = $Stats->countAllHours('hour', true, $airline_icao, $filter_name);
563 563
 		    if (empty($hour_array)) print _("No data available");
564 564
 		    else {
565 565
                 	print '<div id="chart6" class="chart" width="100%"></div><script>';
566 566
                         $hour_data = '';
567 567
 			$hour_cnt = '';
568
-			foreach($hour_array as $hour_item)
568
+			foreach ($hour_array as $hour_item)
569 569
 			{
570 570
 			    $hour_data .= '"'.$hour_item['hour_name'].':00",';
571 571
 			    $hour_cnt .= $hour_item['hour_count'].',';
572 572
 			}
573 573
 			$hour_data = "[".substr($hour_data, 0, -1)."]";
574
-			$hour_cnt = "['flights',".substr($hour_cnt,0,-1)."]";
574
+			$hour_cnt = "['flights',".substr($hour_cnt, 0, -1)."]";
575 575
 			print 'c3.generate({
576 576
                 	    bindto: "#chart6",
577 577
                 	    data: {
@@ -585,7 +585,7 @@  discard block
 block discarded – undo
585 585
                     <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
586 586
                 </div>
587 587
             </div>
588
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
588
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
589 589
         </div>
590 590
 <?php
591 591
     }
@@ -604,13 +604,13 @@  discard block
 block discarded – undo
604 604
 			print '<div id="chart32" class="chart" width="100%"></div><script>';
605 605
                         $year_data = '';
606 606
 			$year_cnt = '';
607
-			foreach($year_array as $year_item)
607
+			foreach ($year_array as $year_item)
608 608
 			{
609 609
 			    $year_data .= '"'.$year_item['year'].'-01-01",';
610 610
 			    $year_cnt .= $year_item['count'].',';
611 611
 			}
612 612
 			$year_data = "['x',".substr($year_data, 0, -1)."]";
613
-			$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
613
+			$year_cnt = "['flights',".substr($year_cnt, 0, -1)."]";
614 614
 			print 'c3.generate({
615 615
                 	    bindto: "#chart32",
616 616
                 	    data: { x: "x",
@@ -624,7 +624,7 @@  discard block
 block discarded – undo
624 624
                     <a href="<?php print $globalURL; ?>/statistics/fatalities/year" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
625 625
                 </div>
626 626
             </div>
627
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
627
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
628 628
 
629 629
         <div class="row column">
630 630
             <div class="col-md-6">
@@ -636,13 +636,13 @@  discard block
 block discarded – undo
636 636
 			print '<div id="chart33" class="chart" width="100%"></div><script>';
637 637
                         $year_data = '';
638 638
 			$year_cnt = '';
639
-			foreach($year_array as $year_item)
639
+			foreach ($year_array as $year_item)
640 640
 			{
641 641
 			    $year_data .= '"'.$year_item['year'].'-'.$year_item['month'].'-01",';
642 642
 			    $year_cnt .= $year_item['count'].',';
643 643
 			}
644 644
 			$year_data = "['x',".substr($year_data, 0, -1)."]";
645
-			$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
645
+			$year_cnt = "['flights',".substr($year_cnt, 0, -1)."]";
646 646
 			print 'c3.generate({
647 647
                 	    bindto: "#chart33",
648 648
                 	    data: { x: "x",
@@ -655,7 +655,7 @@  discard block
 block discarded – undo
655 655
                     <a href="<?php print $globalURL; ?>/statistics/fatalities/month" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
656 656
                 </div>
657 657
             </div>
658
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
658
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
659 659
 <br/>
660 660
 <?php
661 661
     }
@@ -668,9 +668,9 @@  discard block
 block discarded – undo
668 668
         	<?php
669 669
         	    //$polar = $Stats->getStatsSource(date('Y-m-d'),'polar');
670 670
         	    if ($year == '' && $month == '') {
671
-		        $polar = $Stats->getStatsSource('polar',date('Y'),date('m'),date('d'));
671
+		        $polar = $Stats->getStatsSource('polar', date('Y'), date('m'), date('d'));
672 672
 		    } else {
673
-        		$polar = $Stats->getStatsSource('polar',$year,$month);
673
+        		$polar = $Stats->getStatsSource('polar', $year, $month);
674 674
         	    }
675 675
         	    if (!empty($polar)) {
676 676
             		print '<h2>'._("Coverage pattern").'</h2>';
@@ -678,7 +678,7 @@  discard block
 block discarded – undo
678 678
         		    unset($polar_data);
679 679
 	        	    $Spotter = new Spotter();
680 680
         		    $data = json_decode($eachpolar['source_data']);
681
-        		    foreach($data as $value => $key) {
681
+        		    foreach ($data as $value => $key) {
682 682
         			$direction = $Spotter->parseDirection(($value*22.5));
683 683
         			$distance = $key;
684 684
         			$unit = 'km';
@@ -698,7 +698,7 @@  discard block
 block discarded – undo
698 698
         	?>
699 699
             <div class="col-md-6">
700 700
                 <h4><?php print $eachpolar['source_name']; ?></h4>
701
-        	<div id="polar-<?php print str_replace(' ','_',strtolower($eachpolar['source_name'])); ?>" class="chart" width="100%"></div>
701
+        	<div id="polar-<?php print str_replace(' ', '_', strtolower($eachpolar['source_name'])); ?>" class="chart" width="100%"></div>
702 702
         	<script>
703 703
         	    (function() {
704 704
         	    var margin = {top: 100, right: 100, bottom: 100, left: 100},
@@ -722,7 +722,7 @@  discard block
 block discarded – undo
722 722
 		      color: color,
723 723
 		      unit: '<?php echo $unit; ?>'
724 724
 		    };
725
-		    RadarChart("#polar-<?php print str_replace(' ','_',strtolower($eachpolar['source_name'])); ?>", data, radarChartOptions);
725
+		    RadarChart("#polar-<?php print str_replace(' ', '_', strtolower($eachpolar['source_name'])); ?>", data, radarChartOptions);
726 726
 		    })();
727 727
 		</script>
728 728
             </div>
@@ -736,22 +736,22 @@  discard block
 block discarded – undo
736 736
         	<?php
737 737
         	    //$msg = $Stats->getStatsSource(date('Y-m-d'),'msg');
738 738
         	    if ($year == '' && $month == '') {
739
-        		$msg = $Stats->getStatsSource('msg',date('Y'),date('m'),date('d'));
739
+        		$msg = $Stats->getStatsSource('msg', date('Y'), date('m'), date('d'));
740 740
         	    } else {
741
-        		$msg = $Stats->getStatsSource('msg',$year,$month);
741
+        		$msg = $Stats->getStatsSource('msg', $year, $month);
742 742
         	    }
743 743
         	    if (!empty($msg)) {
744 744
             		print '<h2>'._("Messages received").'</h2>';
745 745
         		foreach ($msg as $eachmsg) {
746 746
         		    //$eachmsg = $msg[0];
747 747
         		    $data = $eachmsg['source_data'];
748
-        		    if ($data > 500) $max = (round(($data+100)/100))*100;
748
+        		    if ($data > 500) $max = (round(($data + 100)/100))*100;
749 749
         		    else $max = 500;
750 750
         	?>
751
-        	<div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
751
+        	<div id="msg-<?php print str_replace(' ', '_', strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
752 752
         	<script>
753 753
 		      var g = new JustGage({
754
-			    id: "msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>",
754
+			    id: "msg-<?php print str_replace(' ', '_', strtolower($eachmsg['source_name'])); ?>",
755 755
 			    value: <?php echo $data; ?>,
756 756
 			    min: 0,
757 757
 			    max: <?php print $max; ?>,
@@ -773,9 +773,9 @@  discard block
 block discarded – undo
773 773
             <?php
774 774
 		//$hist = $Stats->getStatsSource(date('Y-m-d'),'hist');
775 775
 		if ($year == '' && $month == '') {
776
-			$hist = $Stats->getStatsSource('hist',date('Y'),date('m'),date('d'));
776
+			$hist = $Stats->getStatsSource('hist', date('Y'), date('m'), date('d'));
777 777
 		} else {
778
-			$hist = $Stats->getStatsSource('hist',$year,$month);
778
+			$hist = $Stats->getStatsSource('hist', $year, $month);
779 779
 		}
780 780
 		foreach ($hist as $hists) {
781 781
 			//$hist_data = '';
@@ -784,7 +784,7 @@  discard block
 block discarded – undo
784 784
 			$source = $hists['source_name'];
785 785
 			$hist_array = json_decode($hists['source_data']);
786 786
 			$unit = 'km';
787
-			foreach($hist_array as $distance => $nb)
787
+			foreach ($hist_array as $distance => $nb)
788 788
 			{
789 789
 				if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
790 790
 					$distance = round($distance*0.539957);
@@ -805,18 +805,18 @@  discard block
 block discarded – undo
805 805
 			$nb_data = "['flights',".substr($nb_data, 0, -1)."]";
806 806
             ?>
807 807
             <div class="col-md-6">
808
-                <h2><?php echo sprintf(_("Flights Distance for %s"),$source); ?></h2>
808
+                <h2><?php echo sprintf(_("Flights Distance for %s"), $source); ?></h2>
809 809
                 <?php
810
-                    print '<div id="charthist-'.str_replace(' ','_',strtolower($source)).'" class="chart" width="100%"></div><script>';
810
+                    print '<div id="charthist-'.str_replace(' ', '_', strtolower($source)).'" class="chart" width="100%"></div><script>';
811 811
 		    print 'c3.generate({
812
-			bindto: "#charthist-'.str_replace(' ','_',strtolower($source)).'",
812
+			bindto: "#charthist-'.str_replace(' ', '_', strtolower($source)).'",
813 813
 			data: { x: "x",
814 814
 			columns: ['.$distance_data.','.$nb_data.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
815 815
 			axis: { x: {label : { text: "Distance in '.$unit.'", position: "outer-right"}}, y: { label: "# of Flights"}},legend: { show: false }});';
816 816
 		    print '</script>';
817 817
         	?>
818 818
     	    </div>
819
-	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
819
+	    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
820 820
         	<?php
821 821
                   }
822 822
                 ?>
Please login to merge, or discard this patch.