Completed
Push — master ( ed2ab5...76a3f8 )
by Yannick
29:35
created
require/class.TrackerLive.php 1 patch
Indentation   +196 added lines, -196 removed lines patch added patch discarded remove patch
@@ -12,10 +12,10 @@  discard block
 block discarded – undo
12 12
 
13 13
 
14 14
 	/**
15
-	* Get SQL query part for filter used
16
-	* @param Array $filter the filter
17
-	* @return Array the SQL part
18
-	*/
15
+	 * Get SQL query part for filter used
16
+	 * @param Array $filter the filter
17
+	 * @return Array the SQL part
18
+	 */
19 19
 	public function getFilter($filter = array(),$where = false,$and = false) {
20 20
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
21 21
 		$filters = array();
@@ -86,11 +86,11 @@  discard block
 block discarded – undo
86 86
 	}
87 87
 
88 88
 	/**
89
-	* Gets all the spotter information based on the latest data entry
90
-	*
91
-	* @return Array the spotter information
92
-	*
93
-	*/
89
+	 * Gets all the spotter information based on the latest data entry
90
+	 *
91
+	 * @return Array the spotter information
92
+	 *
93
+	 */
94 94
 	public function getLiveTrackerData($limit = '', $sort = '', $filter = array())
95 95
 	{
96 96
 		global $globalDBdriver, $globalLiveInterval;
@@ -132,11 +132,11 @@  discard block
 block discarded – undo
132 132
 	}
133 133
 
134 134
 	/**
135
-	* Gets Minimal Live Spotter data
136
-	*
137
-	* @return Array the spotter information
138
-	*
139
-	*/
135
+	 * Gets Minimal Live Spotter data
136
+	 *
137
+	 * @return Array the spotter information
138
+	 *
139
+	 */
140 140
 	public function getMinLiveTrackerData($filter = array())
141 141
 	{
142 142
 		global $globalDBdriver, $globalLiveInterval;
@@ -170,11 +170,11 @@  discard block
 block discarded – undo
170 170
 	}
171 171
 
172 172
 	/**
173
-	* Gets Minimal Live Spotter data since xx seconds
174
-	*
175
-	* @return Array the spotter information
176
-	*
177
-	*/
173
+	 * Gets Minimal Live Spotter data since xx seconds
174
+	 *
175
+	 * @return Array the spotter information
176
+	 *
177
+	 */
178 178
 	public function getMinLastLiveTrackerData($filter = array())
179 179
 	{
180 180
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
@@ -230,11 +230,11 @@  discard block
 block discarded – undo
230 230
 	}
231 231
 
232 232
 	/**
233
-	* Gets number of latest data entry
234
-	*
235
-	* @return String number of entry
236
-	*
237
-	*/
233
+	 * Gets number of latest data entry
234
+	 *
235
+	 * @return String number of entry
236
+	 *
237
+	 */
238 238
 	public function getLiveTrackerCount($filter = array())
239 239
 	{
240 240
 		global $globalDBdriver, $globalLiveInterval;
@@ -259,11 +259,11 @@  discard block
 block discarded – undo
259 259
 	}
260 260
 
261 261
 	/**
262
-	* Gets all the spotter information based on the latest data entry and coord
263
-	*
264
-	* @return Array the spotter information
265
-	*
266
-	*/
262
+	 * Gets all the spotter information based on the latest data entry and coord
263
+	 *
264
+	 * @return Array the spotter information
265
+	 *
266
+	 */
267 267
 	public function getLiveTrackerDatabyCoord($coord, $filter = array())
268 268
 	{
269 269
 		global $globalDBdriver, $globalLiveInterval;
@@ -287,11 +287,11 @@  discard block
 block discarded – undo
287 287
 	}
288 288
 
289 289
 	/**
290
-	* Gets all the spotter information based on the latest data entry and coord
291
-	*
292
-	* @return Array the spotter information
293
-	*
294
-	*/
290
+	 * Gets all the spotter information based on the latest data entry and coord
291
+	 *
292
+	 * @return Array the spotter information
293
+	 *
294
+	 */
295 295
 	public function getMinLiveTrackerDatabyCoord($coord, $filter = array())
296 296
 	{
297 297
 		global $globalDBdriver, $globalLiveInterval;
@@ -318,11 +318,11 @@  discard block
 block discarded – undo
318 318
 	}
319 319
 
320 320
 	/**
321
-	* Gets all the spotter information based on a user's latitude and longitude
322
-	*
323
-	* @return Array the spotter information
324
-	*
325
-	*/
321
+	 * Gets all the spotter information based on a user's latitude and longitude
322
+	 *
323
+	 * @return Array the spotter information
324
+	 *
325
+	 */
326 326
 	public function getLatestTrackerForLayar($lat, $lng, $radius, $interval)
327 327
 	{
328 328
 		$Tracker = new Tracker($this->db);
@@ -335,142 +335,142 @@  discard block
 block discarded – undo
335 335
 		if ($lng != '')
336 336
 		{
337 337
 			if (!is_numeric($lng))
338
-                        {
339
-                                return false;
340
-                        }
341
-                }
342
-
343
-                if ($radius != '')
344
-                {
345
-                        if (!is_numeric($radius))
346
-                        {
347
-                                return false;
348
-                        }
349
-                }
338
+						{
339
+								return false;
340
+						}
341
+				}
342
+
343
+				if ($radius != '')
344
+				{
345
+						if (!is_numeric($radius))
346
+						{
347
+								return false;
348
+						}
349
+				}
350 350
 		$additional_query = '';
351 351
 		if ($interval != '')
352
-                {
353
-                        if (!is_string($interval))
354
-                        {
355
-                                //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date ';
356
-			        return false;
357
-                        } else {
358
-                if ($interval == '1m')
359
-                {
360
-                    $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date ';
361
-                } else if ($interval == '15m'){
362
-                    $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= tracker_live.date ';
363
-                } 
364
-            }
365
-                } else {
366
-         $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date ';   
367
-        }
368
-
369
-                $query  = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live 
352
+				{
353
+						if (!is_string($interval))
354
+						{
355
+								//$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date ';
356
+					return false;
357
+						} else {
358
+				if ($interval == '1m')
359
+				{
360
+					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date ';
361
+				} else if ($interval == '15m'){
362
+					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= tracker_live.date ';
363
+				} 
364
+			}
365
+				} else {
366
+		 $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date ';   
367
+		}
368
+
369
+				$query  = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live 
370 370
                    WHERE tracker_live.latitude <> '' 
371 371
                                    AND tracker_live.longitude <> '' 
372 372
                    ".$additional_query."
373 373
                    HAVING distance < :radius  
374 374
                                    ORDER BY distance";
375 375
 
376
-                $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
376
+				$spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
377 377
 
378
-                return $spotter_array;
379
-        }
378
+				return $spotter_array;
379
+		}
380 380
 
381 381
     
382
-        /**
383
-	* Gets all the spotter information based on a particular callsign
384
-	*
385
-	* @return Array the spotter information
386
-	*
387
-	*/
382
+		/**
383
+		 * Gets all the spotter information based on a particular callsign
384
+		 *
385
+		 * @return Array the spotter information
386
+		 *
387
+		 */
388 388
 	public function getLastLiveTrackerDataByIdent($ident)
389 389
 	{
390 390
 		$Tracker = new Tracker($this->db);
391 391
 		date_default_timezone_set('UTC');
392 392
 
393 393
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
394
-                $query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
394
+				$query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
395 395
 
396 396
 		$spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident),'',true);
397 397
 
398 398
 		return $spotter_array;
399 399
 	}
400 400
 
401
-        /**
402
-	* Gets all the spotter information based on a particular callsign
403
-	*
404
-	* @return Array the spotter information
405
-	*
406
-	*/
401
+		/**
402
+		 * Gets all the spotter information based on a particular callsign
403
+		 *
404
+		 * @return Array the spotter information
405
+		 *
406
+		 */
407 407
 	public function getDateLiveTrackerDataByIdent($ident,$date)
408 408
 	{
409 409
 		$Tracker = new Tracker($this->db);
410 410
 		date_default_timezone_set('UTC');
411 411
 
412 412
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
413
-                $query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
413
+				$query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
414 414
 
415
-                $date = date('c',$date);
415
+				$date = date('c',$date);
416 416
 		$spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
417 417
 
418 418
 		return $spotter_array;
419 419
 	}
420 420
 
421
-        /**
422
-	* Gets last spotter information based on a particular callsign
423
-	*
424
-	* @return Array the spotter information
425
-	*
426
-	*/
421
+		/**
422
+		 * Gets last spotter information based on a particular callsign
423
+		 *
424
+		 * @return Array the spotter information
425
+		 *
426
+		 */
427 427
 	public function getLastLiveTrackerDataById($id)
428 428
 	{
429 429
 		$Tracker = new Tracker($this->db);
430 430
 		date_default_timezone_set('UTC');
431 431
 
432 432
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
433
-                $query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
433
+				$query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
434 434
 
435 435
 		$spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id),'',true);
436 436
 
437 437
 		return $spotter_array;
438 438
 	}
439 439
 
440
-        /**
441
-	* Gets last spotter information based on a particular callsign
442
-	*
443
-	* @return Array the spotter information
444
-	*
445
-	*/
440
+		/**
441
+		 * Gets last spotter information based on a particular callsign
442
+		 *
443
+		 * @return Array the spotter information
444
+		 *
445
+		 */
446 446
 	public function getDateLiveTrackerDataById($id,$date)
447 447
 	{
448 448
 		$Tracker = new Tracker($this->db);
449 449
 		date_default_timezone_set('UTC');
450 450
 
451 451
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
452
-                $query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
453
-                $date = date('c',$date);
452
+				$query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
453
+				$date = date('c',$date);
454 454
 		$spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
455 455
 
456 456
 		return $spotter_array;
457 457
 	}
458 458
 
459
-        /**
460
-	* Gets altitude information based on a particular callsign
461
-	*
462
-	* @return Array the spotter information
463
-	*
464
-	*/
459
+		/**
460
+		 * Gets altitude information based on a particular callsign
461
+		 *
462
+		 * @return Array the spotter information
463
+		 *
464
+		 */
465 465
 	public function getAltitudeLiveTrackerDataByIdent($ident)
466 466
 	{
467 467
 
468 468
 		date_default_timezone_set('UTC');
469 469
 
470 470
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
471
-                $query  = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident';
471
+				$query  = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident';
472 472
 
473
-    		try {
473
+			try {
474 474
 			
475 475
 			$sth = $this->db->prepare($query);
476 476
 			$sth->execute(array(':ident' => $ident));
@@ -483,12 +483,12 @@  discard block
 block discarded – undo
483 483
 		return $spotter_array;
484 484
 	}
485 485
 
486
-        /**
487
-	* Gets all the spotter information based on a particular id
488
-	*
489
-	* @return Array the spotter information
490
-	*
491
-	*/
486
+		/**
487
+		 * Gets all the spotter information based on a particular id
488
+		 *
489
+		 * @return Array the spotter information
490
+		 *
491
+		 */
492 492
 	public function getAllLiveTrackerDataById($id,$liveinterval = false)
493 493
 	{
494 494
 		global $globalDBdriver, $globalLiveInterval;
@@ -516,18 +516,18 @@  discard block
 block discarded – undo
516 516
 		return $spotter_array;
517 517
 	}
518 518
 
519
-        /**
520
-	* Gets all the spotter information based on a particular ident
521
-	*
522
-	* @return Array the spotter information
523
-	*
524
-	*/
519
+		/**
520
+		 * Gets all the spotter information based on a particular ident
521
+		 *
522
+		 * @return Array the spotter information
523
+		 *
524
+		 */
525 525
 	public function getAllLiveTrackerDataByIdent($ident)
526 526
 	{
527 527
 		date_default_timezone_set('UTC');
528 528
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
529 529
 		$query  = self::$global_query.' WHERE tracker_live.ident = :ident';
530
-    		try {
530
+			try {
531 531
 			
532 532
 			$sth = $this->db->prepare($query);
533 533
 			$sth->execute(array(':ident' => $ident));
@@ -541,23 +541,23 @@  discard block
 block discarded – undo
541 541
 
542 542
 
543 543
 	/**
544
-	* Deletes all info in the table
545
-	*
546
-	* @return String success or false
547
-	*
548
-	*/
544
+	 * Deletes all info in the table
545
+	 *
546
+	 * @return String success or false
547
+	 *
548
+	 */
549 549
 	public function deleteLiveTrackerData()
550 550
 	{
551 551
 		global $globalDBdriver;
552 552
 		if ($globalDBdriver == 'mysql') {
553 553
 			//$query  = "DELETE FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= tracker_live.date";
554 554
 			$query  = 'DELETE FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= tracker_live.date';
555
-            		//$query  = "DELETE FROM tracker_live WHERE tracker_live.id IN (SELECT tracker_live.id FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= tracker_live.date)";
555
+					//$query  = "DELETE FROM tracker_live WHERE tracker_live.id IN (SELECT tracker_live.id FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= tracker_live.date)";
556 556
 		} else {
557 557
 			$query  = "DELETE FROM tracker_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= tracker_live.date";
558 558
 		}
559 559
         
560
-    		try {
560
+			try {
561 561
 			
562 562
 			$sth = $this->db->prepare($query);
563 563
 			$sth->execute();
@@ -569,18 +569,18 @@  discard block
 block discarded – undo
569 569
 	}
570 570
 
571 571
 	/**
572
-	* Deletes all info in the table for aircraft not seen since 2 HOUR
573
-	*
574
-	* @return String success or false
575
-	*
576
-	*/
572
+	 * Deletes all info in the table for aircraft not seen since 2 HOUR
573
+	 *
574
+	 * @return String success or false
575
+	 *
576
+	 */
577 577
 	public function deleteLiveTrackerDataNotUpdated()
578 578
 	{
579 579
 		global $globalDBdriver, $globalDebug;
580 580
 		if ($globalDBdriver == 'mysql') {
581 581
 			//$query = 'SELECT famtrackid FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= tracker_live.date AND tracker_live.famtrackid NOT IN (SELECT famtrackid FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < tracker_live.date) LIMIT 800 OFFSET 0';
582
-    			$query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0";
583
-    			try {
582
+				$query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0";
583
+				try {
584 584
 				
585 585
 				$sth = $this->db->prepare($query);
586 586
 				$sth->execute();
@@ -588,8 +588,8 @@  discard block
 block discarded – undo
588 588
 				return "error";
589 589
 			}
590 590
 			$query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN (';
591
-                        $i = 0;
592
-                        $j =0;
591
+						$i = 0;
592
+						$j =0;
593 593
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
594 594
 			foreach($all as $row)
595 595
 			{
@@ -597,20 +597,20 @@  discard block
 block discarded – undo
597 597
 				$j++;
598 598
 				if ($j == 30) {
599 599
 					if ($globalDebug) echo ".";
600
-				    	try {
600
+						try {
601 601
 						
602 602
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
603 603
 						$sth->execute();
604 604
 					} catch(PDOException $e) {
605 605
 						return "error";
606 606
 					}
607
-                                	$query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN (';
608
-                                	$j = 0;
607
+									$query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN (';
608
+									$j = 0;
609 609
 				}
610 610
 				$query_delete .= "'".$row['famtrackid']."',";
611 611
 			}
612 612
 			if ($i > 0) {
613
-    				try {
613
+					try {
614 614
 					
615 615
 					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
616 616
 					$sth->execute();
@@ -621,9 +621,9 @@  discard block
 block discarded – undo
621 621
 			return "success";
622 622
 		} elseif ($globalDBdriver == 'pgsql') {
623 623
 			//$query = "SELECT famtrackid FROM tracker_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= tracker_live.date AND tracker_live.famtrackid NOT IN (SELECT famtrackid FROM tracker_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < tracker_live.date) LIMIT 800 OFFSET 0";
624
-    			//$query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0";
625
-    			$query = "DELETE FROM tracker_live WHERE famtrackid IN (SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)";
626
-    			try {
624
+				//$query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0";
625
+				$query = "DELETE FROM tracker_live WHERE famtrackid IN (SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)";
626
+				try {
627 627
 				
628 628
 				$sth = $this->db->prepare($query);
629 629
 				$sth->execute();
@@ -667,17 +667,17 @@  discard block
 block discarded – undo
667 667
 	}
668 668
 
669 669
 	/**
670
-	* Deletes all info in the table for an ident
671
-	*
672
-	* @return String success or false
673
-	*
674
-	*/
670
+	 * Deletes all info in the table for an ident
671
+	 *
672
+	 * @return String success or false
673
+	 *
674
+	 */
675 675
 	public function deleteLiveTrackerDataByIdent($ident)
676 676
 	{
677 677
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
678 678
 		$query  = 'DELETE FROM tracker_live WHERE ident = :ident';
679 679
         
680
-    		try {
680
+			try {
681 681
 			
682 682
 			$sth = $this->db->prepare($query);
683 683
 			$sth->execute(array(':ident' => $ident));
@@ -689,17 +689,17 @@  discard block
 block discarded – undo
689 689
 	}
690 690
 
691 691
 	/**
692
-	* Deletes all info in the table for an id
693
-	*
694
-	* @return String success or false
695
-	*
696
-	*/
692
+	 * Deletes all info in the table for an id
693
+	 *
694
+	 * @return String success or false
695
+	 *
696
+	 */
697 697
 	public function deleteLiveTrackerDataById($id)
698 698
 	{
699 699
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
700 700
 		$query  = 'DELETE FROM tracker_live WHERE famtrackid = :id';
701 701
         
702
-    		try {
702
+			try {
703 703
 			
704 704
 			$sth = $this->db->prepare($query);
705 705
 			$sth->execute(array(':id' => $id));
@@ -712,11 +712,11 @@  discard block
 block discarded – undo
712 712
 
713 713
 
714 714
 	/**
715
-	* Gets the aircraft ident within the last hour
716
-	*
717
-	* @return String the ident
718
-	*
719
-	*/
715
+	 * Gets the aircraft ident within the last hour
716
+	 *
717
+	 * @return String the ident
718
+	 *
719
+	 */
720 720
 	public function getIdentFromLastHour($ident)
721 721
 	{
722 722
 		global $globalDBdriver, $globalTimezone;
@@ -742,14 +742,14 @@  discard block
 block discarded – undo
742 742
 			$ident_result = $row['ident'];
743 743
 		}
744 744
 		return $ident_result;
745
-        }
745
+		}
746 746
 
747 747
 	/**
748
-	* Check recent aircraft
749
-	*
750
-	* @return String the ident
751
-	*
752
-	*/
748
+	 * Check recent aircraft
749
+	 *
750
+	 * @return String the ident
751
+	 *
752
+	 */
753 753
 	public function checkIdentRecent($ident)
754 754
 	{
755 755
 		global $globalDBdriver, $globalTimezone;
@@ -775,14 +775,14 @@  discard block
 block discarded – undo
775 775
 			$ident_result = $row['famtrackid'];
776 776
 		}
777 777
 		return $ident_result;
778
-        }
778
+		}
779 779
 
780 780
 	/**
781
-	* Check recent aircraft by id
782
-	*
783
-	* @return String the ident
784
-	*
785
-	*/
781
+	 * Check recent aircraft by id
782
+	 *
783
+	 * @return String the ident
784
+	 *
785
+	 */
786 786
 	public function checkIdRecent($id)
787 787
 	{
788 788
 		global $globalDBdriver, $globalTimezone;
@@ -808,19 +808,19 @@  discard block
 block discarded – undo
808 808
 			$ident_result = $row['famtrackid'];
809 809
 		}
810 810
 		return $ident_result;
811
-        }
811
+		}
812 812
 
813 813
 	/**
814
-	* Adds a new spotter data
815
-	*
816
-	* @param String $famtrackid the ID from flightaware
817
-	* @param String $ident the flight ident
818
-	* @param String $aircraft_icao the aircraft type
819
-	* @param String $departure_airport_icao the departure airport
820
-	* @param String $arrival_airport_icao the arrival airport
821
-	* @return String success or false
822
-	*
823
-	*/
814
+	 * Adds a new spotter data
815
+	 *
816
+	 * @param String $famtrackid the ID from flightaware
817
+	 * @param String $ident the flight ident
818
+	 * @param String $aircraft_icao the aircraft type
819
+	 * @param String $departure_airport_icao the departure airport
820
+	 * @param String $arrival_airport_icao the arrival airport
821
+	 * @return String success or false
822
+	 *
823
+	 */
824 824
 	public function addLiveTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '')
825 825
 	{
826 826
 		global $globalURL, $globalArchive, $globalDebug;
@@ -893,8 +893,8 @@  discard block
 block discarded – undo
893 893
 		$comment = filter_var($comment,FILTER_SANITIZE_STRING);
894 894
 		$type = filter_var($type,FILTER_SANITIZE_STRING);
895 895
 
896
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
897
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
896
+				if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
897
+				if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
898 898
             	
899 899
 		$query = '';
900 900
 		if ($globalArchive) {
@@ -909,18 +909,18 @@  discard block
 block discarded – undo
909 909
 			
910 910
 			$sth = $this->db->prepare($query);
911 911
 			$sth->execute($query_values);
912
-                } catch(PDOException $e) {
913
-                	return "error : ".$e->getMessage();
914
-                }
915
-                /*
912
+				} catch(PDOException $e) {
913
+					return "error : ".$e->getMessage();
914
+				}
915
+				/*
916 916
                 echo 'putinarchive : '.$putinarchive."\n";
917 917
                 echo 'noarchive : '.$noarchive."\n";
918 918
                 */
919 919
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
920
-		    if ($globalDebug) echo '(Add to Tracker archive '.$famtrackid.' : ';
921
-		    $TrackerArchive = new TrackerArchive($this->db);
922
-		    $result =  $TrackerArchive->addTrackerArchiveData($famtrackid, $ident,$latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type,$noarchive,$format_source, $source_name, $over_country);
923
-		    if ($globalDebug) echo $result.')';
920
+			if ($globalDebug) echo '(Add to Tracker archive '.$famtrackid.' : ';
921
+			$TrackerArchive = new TrackerArchive($this->db);
922
+			$result =  $TrackerArchive->addTrackerArchiveData($famtrackid, $ident,$latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type,$noarchive,$format_source, $source_name, $over_country);
923
+			if ($globalDebug) echo $result.')';
924 924
 		}
925 925
 
926 926
 		return "success";
Please login to merge, or discard this patch.
require/class.TrackerImport.php 1 patch
Indentation   +174 added lines, -174 removed lines patch added patch discarded remove patch
@@ -7,16 +7,16 @@  discard block
 block discarded – undo
7 7
 require_once(dirname(__FILE__).'/class.Source.php');
8 8
 
9 9
 class TrackerImport {
10
-    private $all_tracked = array();
11
-    private $last_delete_hourly = 0;
12
-    private $last_delete = 0;
13
-    private $stats = array();
14
-    private $tmd = 0;
15
-    private $source_location = array();
16
-    public $db = null;
17
-    public $nb = 0;
10
+	private $all_tracked = array();
11
+	private $last_delete_hourly = 0;
12
+	private $last_delete = 0;
13
+	private $stats = array();
14
+	private $tmd = 0;
15
+	private $source_location = array();
16
+	public $db = null;
17
+	public $nb = 0;
18 18
 
19
-    public function __construct($dbc = null) {
19
+	public function __construct($dbc = null) {
20 20
 	global $globalBeta;
21 21
 	$Connection = new Connection($dbc);
22 22
 	$this->db = $Connection->db();
@@ -38,50 +38,50 @@  discard block
 block discarded – undo
38 38
 	    }
39 39
 	}
40 40
 	*/
41
-    }
41
+	}
42 42
 
43
-    public function checkAll() {
43
+	public function checkAll() {
44 44
 	global $globalDebug;
45 45
 	if ($globalDebug) echo "Update last seen tracked data...\n";
46 46
 	foreach ($this->all_tracked as $key => $flight) {
47
-	    if (isset($this->all_tracked[$key]['id'])) {
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
-    		$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']);
51
-            }
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']);
51
+			}
52
+	}
52 53
 	}
53
-    }
54 54
 
55
-    public function del() {
55
+	public function del() {
56 56
 	global $globalDebug;
57 57
 	// Delete old infos
58 58
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
59 59
 	foreach ($this->all_tracked as $key => $flight) {
60
-    	    if (isset($flight['lastupdate'])) {
61
-        	if ($flight['lastupdate'] < (time()-3000)) {
62
-            	    if (isset($this->all_tracked[$key]['id'])) {
63
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
60
+			if (isset($flight['lastupdate'])) {
61
+			if ($flight['lastupdate'] < (time()-3000)) {
62
+					if (isset($this->all_tracked[$key]['id'])) {
63
+					if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
64 64
 			/*
65 65
 			$TrackerLive = new TrackerLive();
66 66
             		$TrackerLive->deleteLiveTrackerDataById($this->all_tracked[$key]['id']);
67 67
 			$TrackerLive->db = null;
68 68
 			*/
69
-            		//$real_arrival = $this->arrival($key);
70
-            		$Tracker = new Tracker($this->db);
71
-            		if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
69
+					//$real_arrival = $this->arrival($key);
70
+					$Tracker = new Tracker($this->db);
71
+					if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
72 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
76 76
 //			$Tracker->db = null;
77
-            	    }
78
-            	    unset($this->all_tracked[$key]);
79
-    	        }
80
-	    }
81
-        }
82
-    }
77
+					}
78
+					unset($this->all_tracked[$key]);
79
+				}
80
+		}
81
+		}
82
+	}
83 83
 
84
-    public function add($line) {
84
+	public function add($line) {
85 85
 	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChangeTracker, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked;
86 86
 	if (!isset($globalCoordMinChangeTracker) || $globalCoordMinChangeTracker == '') $globalCoordMinChange = '0.015';
87 87
 	date_default_timezone_set('UTC');
@@ -90,47 +90,47 @@  discard block
 block discarded – undo
90 90
 	
91 91
 	// SBS format is CSV format
92 92
 	if(is_array($line) && isset($line['ident'])) {
93
-	    //print_r($line);
94
-  	    if (isset($line['ident'])) {
93
+		//print_r($line);
94
+  		if (isset($line['ident'])) {
95 95
 
96 96
 		
97 97
 		// Increment message number
98 98
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
99
-		    $current_date = date('Y-m-d');
100
-		    if (isset($line['source_name'])) $source = $line['source_name'];
101
-		    else $source = '';
102
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
103
-		    if (!isset($this->stats[$current_date][$source]['msg'])) {
104
-		    	$this->stats[$current_date][$source]['msg']['date'] = time();
105
-		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
106
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
99
+			$current_date = date('Y-m-d');
100
+			if (isset($line['source_name'])) $source = $line['source_name'];
101
+			else $source = '';
102
+			if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
103
+			if (!isset($this->stats[$current_date][$source]['msg'])) {
104
+				$this->stats[$current_date][$source]['msg']['date'] = time();
105
+				$this->stats[$current_date][$source]['msg']['nb'] = 1;
106
+			} else $this->stats[$current_date][$source]['msg']['nb'] += 1;
107 107
 		}
108 108
 		
109 109
 		
110 110
 		$Common = new Common();
111
-	        if (!isset($line['id'])) $id = trim($line['ident']);
112
-	        else $id = trim($line['id']);
111
+			if (!isset($line['id'])) $id = trim($line['ident']);
112
+			else $id = trim($line['id']);
113 113
 		
114 114
 		if (!isset($this->all_tracked[$id])) {
115
-		    $this->all_tracked[$id] = array();
116
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedTracker' => 0));
117
-		    $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' => ''));
118
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
119
-		    if (!isset($line['id'])) {
115
+			$this->all_tracked[$id] = array();
116
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedTracker' => 0));
117
+			$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' => ''));
118
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
119
+			if (!isset($line['id'])) {
120 120
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
121 121
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
122
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
123
-		    if ($globalAllTracked !== FALSE) $dataFound = true;
122
+			 } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
123
+			if ($globalAllTracked !== FALSE) $dataFound = true;
124 124
 		}
125 125
 		
126 126
 		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
127
-		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) {
127
+			if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) {
128 128
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
129
-		    } else {
129
+			} else {
130 130
 				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";
131 131
 				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";
132 132
 				return '';
133
-		    }
133
+			}
134 134
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
135 135
 			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
136 136
 			return '';
@@ -147,38 +147,38 @@  discard block
 block discarded – undo
147 147
 		
148 148
 		//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'])) {
149 149
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) {
150
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
151
-		    if ($this->all_tracked[$id]['addedTracker'] == 1) {
150
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
151
+			if ($this->all_tracked[$id]['addedTracker'] == 1) {
152 152
 			$timeelapsed = microtime(true);
153
-            		$Tracker = new Tracker($this->db);
154
-            		$fromsource = NULL;
155
-            		$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
153
+					$Tracker = new Tracker($this->db);
154
+					$fromsource = NULL;
155
+					$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
156 156
 			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
157 157
 			$Tracker->db = null;
158 158
 			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
159
-		    }
160
-		    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
+			}
160
+			if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
161 161
 		}
162 162
 
163 163
 		if (isset($line['speed']) && $line['speed'] != '') {
164
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
165
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
164
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
165
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
166 166
 		} 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'])) {
167
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
168
-		    if ($distance > 100 && $distance < 10000) {
167
+			$distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
168
+			if ($distance > 100 && $distance < 10000) {
169 169
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
170 170
 			$speed = $speed*3.6;
171 171
 			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
172 172
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n";
173
-		    }
173
+			}
174 174
 		}
175 175
 
176
-	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
177
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
178
-	    	    else unset($timediff);
179
-	    	    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')))) {
176
+			if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
177
+				if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
178
+				else unset($timediff);
179
+				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')))) {
180 180
 			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'])) {
181
-			    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'],0.1)) {
181
+				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'],0.1)) {
182 182
 				$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
183 183
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
184 184
 				$this->all_tracked[$id]['putinarchive'] = true;
@@ -192,30 +192,30 @@  discard block
 block discarded – undo
192 192
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
193 193
 				$this->tmd = 0;
194 194
 				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
195
-			    }
195
+				}
196 196
 			}
197 197
 
198 198
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
199 199
 				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
200 200
 				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') {
201
-				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
202
-				    $dataFound = true;
203
-				    $this->all_tracked[$id]['time_last_coord'] = time();
201
+					$this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
202
+					$dataFound = true;
203
+					$this->all_tracked[$id]['time_last_coord'] = time();
204 204
 				}
205 205
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
206 206
 			}
207 207
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
208
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
208
+				if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
209 209
 				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
210 210
 				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') {
211
-				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
212
-				    $dataFound = true;
213
-				    $this->all_tracked[$id]['time_last_coord'] = time();
211
+					$this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
212
+					$dataFound = true;
213
+					$this->all_tracked[$id]['time_last_coord'] = time();
214 214
 				}
215 215
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude']));
216 216
 			}
217 217
 
218
-		    } else if ($globalDebug && $timediff > 20) {
218
+			} else if ($globalDebug && $timediff > 20) {
219 219
 			$this->tmd = $this->tmd + 1;
220 220
 			if ($line['latitude'] != $this->all_tracked[$id]['latitude'] && $line['longitude'] != $this->all_tracked[$id]['longitude']) {
221 221
 				echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n";
@@ -223,131 +223,131 @@  discard block
 block discarded – undo
223 223
 				echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
224 224
 				echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n";
225 225
 			}
226
-		    }
226
+			}
227 227
 		}
228 228
 		if (isset($line['last_update']) && $line['last_update'] != '') {
229
-		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
230
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
229
+			if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
230
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
231 231
 		}
232 232
 		if (isset($line['format_source']) && $line['format_source'] != '') {
233
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
233
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
234 234
 		}
235 235
 		if (isset($line['source_name']) && $line['source_name'] != '') {
236
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
236
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
237 237
 		}
238 238
 		if (isset($line['comment']) && $line['comment'] != '') {
239
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment']));
240
-		    //$dataFound = true;
239
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment']));
240
+			//$dataFound = true;
241 241
 		}
242 242
 		if (isset($line['type']) && $line['type'] != '') {
243
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
244
-		    //$dataFound = true;
243
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
244
+			//$dataFound = true;
245 245
 		}
246 246
 
247 247
 		if (isset($line['altitude']) && $line['altitude'] != '') {
248
-		    //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
248
+			//if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
249 249
 			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;
250 250
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => $line['altitude']));
251 251
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude']));
252 252
 			//$dataFound = true;
253
-		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
253
+			//} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
254 254
   		}
255 255
 
256 256
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
257
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
257
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
258 258
 		}
259 259
 		
260 260
 		if (isset($line['heading']) && $line['heading'] != '') {
261
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
262
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
263
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
264
-		    //$dataFound = true;
261
+			if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
262
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
263
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
264
+			//$dataFound = true;
265 265
   		} 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']) {
266
-  		    $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']);
267
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
268
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
269
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
266
+  			$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']);
267
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
268
+			if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
269
+  			if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
270 270
   		}
271 271
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
272 272
 
273 273
 		if ($dataFound === true && isset($this->all_tracked[$id]['ident'])) {
274
-		    $this->all_tracked[$id]['lastupdate'] = time();
275
-		    if ($this->all_tracked[$id]['addedTracker'] == 0) {
276
-		        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'])) {
277
-			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
274
+			$this->all_tracked[$id]['lastupdate'] = time();
275
+			if ($this->all_tracked[$id]['addedTracker'] == 0) {
276
+				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'])) {
277
+				if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
278 278
 				if ($globalDebug) echo "Check if aircraft is already in DB...";
279 279
 				$timeelapsed = microtime(true);
280 280
 				$TrackerLive = new TrackerLive($this->db);
281 281
 				if (isset($line['id'])) {
282
-				    $recent_ident = $TrackerLive->checkIdRecent($line['id']);
283
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
282
+					$recent_ident = $TrackerLive->checkIdRecent($line['id']);
283
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
284 284
 				} elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
285
-				    $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']);
286
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
285
+					$recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']);
286
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
287 287
 				} else $recent_ident = '';
288 288
 				$TrackerLive->db=null;
289 289
 
290 290
 				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
291 291
 				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
292
-			    } else {
292
+				} else {
293 293
 				$recent_ident = '';
294 294
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
295
-			    }
296
-			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
297
-			    if($recent_ident == "")
298
-			    {
295
+				}
296
+				//if there was no aircraft with the same callsign within the last hour and go post it into the archive
297
+				if($recent_ident == "")
298
+				{
299 299
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
300 300
 				//adds the spotter data for the archive
301
-				    $highlight = '';
302
-				    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')));
303
-				    $timeelapsed = microtime(true);
304
-				    $Tracker = new Tracker($this->db);
305
-				    $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']);
306
-				    $Tracker->db = null;
307
-				    if ($globalDebug && isset($result)) echo $result."\n";
308
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
301
+					$highlight = '';
302
+					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')));
303
+					$timeelapsed = microtime(true);
304
+					$Tracker = new Tracker($this->db);
305
+					$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']);
306
+					$Tracker->db = null;
307
+					if ($globalDebug && isset($result)) echo $result."\n";
308
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
309 309
 				    
310 310
 				    
311
-				    // Add source stat in DB
312
-				    $Stats = new Stats($this->db);
313
-				    if (!empty($this->stats)) {
311
+					// Add source stat in DB
312
+					$Stats = new Stats($this->db);
313
+					if (!empty($this->stats)) {
314 314
 					if ($globalDebug) echo 'Add source stats : ';
315
-				        foreach($this->stats as $date => $data) {
316
-					    foreach($data as $source => $sourced) {
317
-					        //print_r($sourced);
318
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date);
319
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date);
320
-				    		if (isset($sourced['msg'])) {
321
-				    		    if (time() - $sourced['msg']['date'] > 10) {
322
-				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
323
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg_tracker',$date);
324
-			    			        unset($this->stats[$date][$source]['msg']);
325
-			    			    }
326
-			    			}
327
-			    		    }
328
-			    		    if ($date != date('Y-m-d')) {
329
-			    			unset($this->stats[$date]);
330
-			    		    }
331
-				    	}
332
-				    	if ($globalDebug) echo 'Done'."\n";
315
+						foreach($this->stats as $date => $data) {
316
+						foreach($data as $source => $sourced) {
317
+							//print_r($sourced);
318
+								if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date);
319
+								if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date);
320
+							if (isset($sourced['msg'])) {
321
+								if (time() - $sourced['msg']['date'] > 10) {
322
+									$nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
323
+									echo $Stats->addStatSource($nbmsg,$source,'msg_tracker',$date);
324
+									unset($this->stats[$date][$source]['msg']);
325
+								}
326
+							}
327
+							}
328
+							if ($date != date('Y-m-d')) {
329
+							unset($this->stats[$date]);
330
+							}
331
+						}
332
+						if ($globalDebug) echo 'Done'."\n";
333 333
 
334
-				    }
335
-				    $Stats->db = null;
334
+					}
335
+					$Stats->db = null;
336 336
 				    
337
-				    $this->del();
337
+					$this->del();
338 338
 				//$ignoreImport = false;
339 339
 				$this->all_tracked[$id]['addedTracker'] = 1;
340 340
 				//print_r($this->all_tracked[$id]);
341 341
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
342
-				    if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours...";
343
-				    //TrackerLive->deleteLiveTrackerDataNotUpdated();
344
-				    $TrackerLive = new TrackerLive($this->db);
345
-				    $TrackerLive->deleteLiveTrackerData();
346
-				    $TrackerLive->db=null;
347
-				    if ($globalDebug) echo " Done\n";
348
-				    $this->last_delete = time();
342
+					if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours...";
343
+					//TrackerLive->deleteLiveTrackerDataNotUpdated();
344
+					$TrackerLive = new TrackerLive($this->db);
345
+					$TrackerLive->deleteLiveTrackerData();
346
+					$TrackerLive->db=null;
347
+					if ($globalDebug) echo " Done\n";
348
+					$this->last_delete = time();
349 349
 				}
350
-			    } else {
350
+				} else {
351 351
 				$this->all_tracked[$id]['id'] = $recent_ident;
352 352
 				$this->all_tracked[$id]['addedTracker'] = 1;
353 353
 				if (isset($globalDaemon) && !$globalDaemon) {
@@ -356,16 +356,16 @@  discard block
 block discarded – undo
356 356
 					$Tracker->db = null;
357 357
 				}
358 358
 				
359
-			    }
359
+				}
360 360
 			}
361
-		    }
362
-		    //adds the spotter LIVE data
363
-		    if ($globalDebug) {
361
+			}
362
+			//adds the spotter LIVE data
363
+			if ($globalDebug) {
364 364
 			echo 'DATA : ident : '.$this->all_tracked[$id]['ident'].' - type : '.$this->all_tracked[$id]['type'].' - Latitude : '.$this->all_tracked[$id]['latitude'].' - Longitude : '.$this->all_tracked[$id]['longitude'].' - Altitude : '.$this->all_tracked[$id]['altitude'].' - Heading : '.$this->all_tracked[$id]['heading'].' - Speed : '.$this->all_tracked[$id]['speed']."\n";
365
-		    }
366
-		    $ignoreImport = false;
365
+			}
366
+			$ignoreImport = false;
367 367
 
368
-		    if (!$ignoreImport) {
368
+			if (!$ignoreImport) {
369 369
 			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'])) {
370 370
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
371 371
 				$timeelapsed = microtime(true);
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
 					if ($stats_heading == 16) $stats_heading = 0;
404 404
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
405 405
 						for ($i=0;$i<=15;$i++) {
406
-						    $this->stats[$current_date][$source]['polar'][$i] = 0;
406
+							$this->stats[$current_date][$source]['polar'][$i] = 0;
407 407
 						}
408 408
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
409 409
 					} else {
@@ -416,11 +416,11 @@  discard block
 block discarded – undo
416 416
 					//var_dump($this->stats);
417 417
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
418 418
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
419
-						    end($this->stats[$current_date][$source]['hist']);
420
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
419
+							end($this->stats[$current_date][$source]['hist']);
420
+							$mini = key($this->stats[$current_date][$source]['hist'])+10;
421 421
 						} else $mini = 0;
422 422
 						for ($i=$mini;$i<=$distance;$i+=10) {
423
-						    $this->stats[$current_date][$source]['hist'][$i] = 0;
423
+							$this->stats[$current_date][$source]['hist'][$i] = 0;
424 424
 						}
425 425
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
426 426
 					} else {
@@ -436,22 +436,22 @@  discard block
 block discarded – undo
436 436
 			
437 437
 			
438 438
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
439
-			    if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour...";
440
-			    $TrackerLive = new TrackerLive($this->db);
441
-			    $TrackerLive->deleteLiveTrackerDataNotUpdated();
442
-			    $TrackerLive->db = null;
443
-			    //TrackerLive->deleteLiveTrackerData();
444
-			    if ($globalDebug) echo " Done\n";
445
-			    $this->last_delete_hourly = time();
439
+				if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour...";
440
+				$TrackerLive = new TrackerLive($this->db);
441
+				$TrackerLive->deleteLiveTrackerDataNotUpdated();
442
+				$TrackerLive->db = null;
443
+				//TrackerLive->deleteLiveTrackerData();
444
+				if ($globalDebug) echo " Done\n";
445
+				$this->last_delete_hourly = time();
446 446
 			}
447 447
 			
448
-		    }
449
-		    //$ignoreImport = false;
448
+			}
449
+			//$ignoreImport = false;
450 450
 		}
451 451
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
452 452
 		if ($send) return $this->all_tracked[$id];
453
-	    }
453
+		}
454
+	}
454 455
 	}
455
-    }
456 456
 }
457 457
 ?>
Please login to merge, or discard this patch.
scripts/daemon-spotter.php 1 patch
Indentation   +942 added lines, -942 removed lines patch added patch discarded remove patch
@@ -16,8 +16,8 @@  discard block
 block discarded – undo
16 16
 require_once(dirname(__FILE__).'/../require/class.Common.php');
17 17
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
18 18
 if (isset($globalMarine) && $globalMarine) {
19
-    require_once(dirname(__FILE__).'/../require/class.AIS.php');
20
-    require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
19
+	require_once(dirname(__FILE__).'/../require/class.AIS.php');
20
+	require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
21 21
 }
22 22
 
23 23
 if (!isset($globalDebug)) $globalDebug = FALSE;
@@ -25,42 +25,42 @@  discard block
 block discarded – undo
25 25
 // Check if schema is at latest version
26 26
 $Connection = new Connection();
27 27
 if ($Connection->latest() === false) {
28
-    echo "You MUST update to latest schema. Run install/index.php";
29
-    exit();
28
+	echo "You MUST update to latest schema. Run install/index.php";
29
+	exit();
30 30
 }
31 31
 if (PHP_SAPI != 'cli') {
32
-    echo "This script MUST be called from console, not a web browser.";
32
+	echo "This script MUST be called from console, not a web browser.";
33 33
 //    exit();
34 34
 }
35 35
 
36 36
 // This is to be compatible with old version of settings.php
37 37
 if (!isset($globalSources)) {
38
-    if (isset($globalSBS1Hosts)) {
39
-        //$hosts = $globalSBS1Hosts;
40
-        foreach ($globalSBS1Hosts as $host) {
41
-	    $globalSources[] = array('host' => $host);
42
-    	}
43
-    } else {
44
-        if (!isset($globalSBS1Host)) {
45
-	    echo '$globalSources MUST be defined !';
46
-	    die;
38
+	if (isset($globalSBS1Hosts)) {
39
+		//$hosts = $globalSBS1Hosts;
40
+		foreach ($globalSBS1Hosts as $host) {
41
+		$globalSources[] = array('host' => $host);
42
+		}
43
+	} else {
44
+		if (!isset($globalSBS1Host)) {
45
+		echo '$globalSources MUST be defined !';
46
+		die;
47 47
 	}
48 48
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
49 49
 	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
50
-    }
50
+	}
51 51
 }
52 52
 
53 53
 $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver'));
54 54
 //if (isset($options['s'])) $hosts = array($options['s']);
55 55
 //elseif (isset($options['source'])) $hosts = array($options['source']);
56 56
 if (isset($options['s'])) {
57
-    $globalSources = array();
58
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
59
-    else $globalSources[] = array('host' => $options['s']);
57
+	$globalSources = array();
58
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
59
+	else $globalSources[] = array('host' => $options['s']);
60 60
 } elseif (isset($options['source'])) {
61
-    $globalSources = array();
62
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
63
-    else $globalSources[] = array('host' => $options['source']);
61
+	$globalSources = array();
62
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
63
+	else $globalSources[] = array('host' => $options['source']);
64 64
 }
65 65
 if (isset($options['aprsserverhost'])) {
66 66
 	$globalServerAPRS = TRUE;
@@ -75,8 +75,8 @@  discard block
 block discarded – undo
75 75
 if (isset($options['idsource'])) $id_source = $options['idsource'];
76 76
 else $id_source = 1;
77 77
 if (isset($globalServer) && $globalServer) {
78
-    if ($globalDebug) echo "Using Server Mode\n";
79
-    $SI=new SpotterServer();
78
+	if ($globalDebug) echo "Using Server Mode\n";
79
+	$SI=new SpotterServer();
80 80
 /*
81 81
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
82 82
     $SI = new adsb2aprs();
@@ -85,8 +85,8 @@  discard block
 block discarded – undo
85 85
 } else $SI=new SpotterImport($Connection->db);
86 86
 if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
87 87
 if (isset($globalMarine) && $globalMarine) {
88
-    $AIS = new AIS();
89
-    $MI = new MarineImport($Connection->db);
88
+	$AIS = new AIS();
89
+	$MI = new MarineImport($Connection->db);
90 90
 }
91 91
 //$APRS=new APRS($Connection->db);
92 92
 $SBS=new SBS();
@@ -97,12 +97,12 @@  discard block
 block discarded – undo
97 97
 //$servertz = system('date +%Z');
98 98
 // signal handler - playing nice with sockets and dump1090
99 99
 if (function_exists('pcntl_fork')) {
100
-    pcntl_signal(SIGINT,  function() {
101
-        global $sockets;
102
-        echo "\n\nctrl-c or kill signal received. Tidying up ... ";
103
-        die("Bye!\n");
104
-    });
105
-    pcntl_signal_dispatch();
100
+	pcntl_signal(SIGINT,  function() {
101
+		global $sockets;
102
+		echo "\n\nctrl-c or kill signal received. Tidying up ... ";
103
+		die("Bye!\n");
104
+	});
105
+	pcntl_signal_dispatch();
106 106
 }
107 107
 
108 108
 // let's try and connect
@@ -112,36 +112,36 @@  discard block
 block discarded – undo
112 112
 $reset = 0;
113 113
 
114 114
 function connect_all($hosts) {
115
-    //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
116
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
117
-    $reset++;
118
-    if ($globalDebug) echo 'Connect to all...'."\n";
119
-    foreach ($hosts as $id => $value) {
115
+	//global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
116
+	global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
117
+	$reset++;
118
+	if ($globalDebug) echo 'Connect to all...'."\n";
119
+	foreach ($hosts as $id => $value) {
120 120
 	$host = $value['host'];
121 121
 	$globalSources[$id]['last_exec'] = 0;
122 122
 	// Here we check type of source(s)
123 123
 	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
124
-            if (preg_match('/deltadb.txt$/i',$host)) {
125
-        	//$formats[$id] = 'deltadbtxt';
126
-        	$globalSources[$id]['format'] = 'deltadbtxt';
127
-        	//$last_exec['deltadbtxt'] = 0;
128
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
129
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
130
-        	//$formats[$id] = 'vatsimtxt';
131
-        	$globalSources[$id]['format'] = 'vatsimtxt';
132
-        	//$last_exec['vatsimtxt'] = 0;
133
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
134
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
135
-        	//$formats[$id] = 'aircraftlistjson';
136
-        	$globalSources[$id]['format'] = 'aircraftlistjson';
137
-        	//$last_exec['aircraftlistjson'] = 0;
138
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
139
-    	    } else if (preg_match('/opensky/i',$host)) {
140
-        	//$formats[$id] = 'aircraftlistjson';
141
-        	$globalSources[$id]['format'] = 'opensky';
142
-        	//$last_exec['aircraftlistjson'] = 0;
143
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
144
-    	    /*
124
+			if (preg_match('/deltadb.txt$/i',$host)) {
125
+			//$formats[$id] = 'deltadbtxt';
126
+			$globalSources[$id]['format'] = 'deltadbtxt';
127
+			//$last_exec['deltadbtxt'] = 0;
128
+			if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
129
+			} else if (preg_match('/vatsim-data.txt$/i',$host)) {
130
+			//$formats[$id] = 'vatsimtxt';
131
+			$globalSources[$id]['format'] = 'vatsimtxt';
132
+			//$last_exec['vatsimtxt'] = 0;
133
+			if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
134
+			} else if (preg_match('/aircraftlist.json$/i',$host)) {
135
+			//$formats[$id] = 'aircraftlistjson';
136
+			$globalSources[$id]['format'] = 'aircraftlistjson';
137
+			//$last_exec['aircraftlistjson'] = 0;
138
+			if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
139
+			} else if (preg_match('/opensky/i',$host)) {
140
+			//$formats[$id] = 'aircraftlistjson';
141
+			$globalSources[$id]['format'] = 'opensky';
142
+			//$last_exec['aircraftlistjson'] = 0;
143
+			if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
144
+			/*
145 145
     	    // Disabled for now, site change source format
146 146
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
147 147
         	//$formats[$id] = 'radarvirtueljson';
@@ -153,118 +153,118 @@  discard block
 block discarded – undo
153 153
         	    exit(0);
154 154
         	}
155 155
     	    */
156
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
157
-        	//$formats[$id] = 'planeupdatefaa';
158
-        	$globalSources[$id]['format'] = 'planeupdatefaa';
159
-        	//$last_exec['planeupdatefaa'] = 0;
160
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
161
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
162
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
163
-        	    exit(0);
164
-        	}
165
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
166
-        	//$formats[$id] = 'phpvmacars';
167
-        	$globalSources[$id]['format'] = 'phpvmacars';
168
-        	//$last_exec['phpvmacars'] = 0;
169
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
170
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
171
-        	//$formats[$id] = 'phpvmacars';
172
-        	$globalSources[$id]['format'] = 'vam';
173
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
174
-            } else if (preg_match('/whazzup/i',$host)) {
175
-        	//$formats[$id] = 'whazzup';
176
-        	$globalSources[$id]['format'] = 'whazzup';
177
-        	//$last_exec['whazzup'] = 0;
178
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
179
-            } else if (preg_match('/airwhere/i',$host)) {
180
-        	$globalSources[$id]['format'] = 'airwhere';
181
-        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
182
-            } else if (preg_match('/recentpireps/i',$host)) {
183
-        	//$formats[$id] = 'pirepsjson';
184
-        	$globalSources[$id]['format'] = 'pirepsjson';
185
-        	//$last_exec['pirepsjson'] = 0;
186
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
187
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
188
-        	//$formats[$id] = 'fr24json';
189
-        	$globalSources[$id]['format'] = 'fr24json';
190
-        	//$last_exec['fr24json'] = 0;
191
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
192
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
193
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
194
-        	    exit(0);
195
-        	}
196
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
197
-        	//$formats[$id] = 'fr24json';
198
-        	$globalSources[$id]['format'] = 'myshiptracking';
199
-        	//$last_exec['fr24json'] = 0;
200
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
201
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
202
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
203
-        	    exit(0);
204
-        	}
205
-            //} else if (preg_match('/10001/',$host)) {
206
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
207
-        	//$formats[$id] = 'tsv';
208
-        	$globalSources[$id]['format'] = 'tsv';
209
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
210
-            }
211
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
212
-    		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
213
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
214
-    		    if ($idf !== false) {
215
-    			$httpfeeds[$id] = $idf;
216
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
217
-    		    }
218
-    		    elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
219
-    		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
220
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
221
-	    $hostport = explode(':',$host);
222
-	    if (isset($hostport[1])) {
156
+			} else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
157
+			//$formats[$id] = 'planeupdatefaa';
158
+			$globalSources[$id]['format'] = 'planeupdatefaa';
159
+			//$last_exec['planeupdatefaa'] = 0;
160
+			if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
161
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
162
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
163
+				exit(0);
164
+			}
165
+			} else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
166
+			//$formats[$id] = 'phpvmacars';
167
+			$globalSources[$id]['format'] = 'phpvmacars';
168
+			//$last_exec['phpvmacars'] = 0;
169
+			if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
170
+			} else if (preg_match('/VAM-json.php$/i',$host)) {
171
+			//$formats[$id] = 'phpvmacars';
172
+			$globalSources[$id]['format'] = 'vam';
173
+			if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
174
+			} else if (preg_match('/whazzup/i',$host)) {
175
+			//$formats[$id] = 'whazzup';
176
+			$globalSources[$id]['format'] = 'whazzup';
177
+			//$last_exec['whazzup'] = 0;
178
+			if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
179
+			} else if (preg_match('/airwhere/i',$host)) {
180
+			$globalSources[$id]['format'] = 'airwhere';
181
+			if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
182
+			} else if (preg_match('/recentpireps/i',$host)) {
183
+			//$formats[$id] = 'pirepsjson';
184
+			$globalSources[$id]['format'] = 'pirepsjson';
185
+			//$last_exec['pirepsjson'] = 0;
186
+			if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
187
+			} else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
188
+			//$formats[$id] = 'fr24json';
189
+			$globalSources[$id]['format'] = 'fr24json';
190
+			//$last_exec['fr24json'] = 0;
191
+			if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
192
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
193
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
194
+				exit(0);
195
+			}
196
+			} else if (preg_match(':myshiptracking.com/:i',$host)) {
197
+			//$formats[$id] = 'fr24json';
198
+			$globalSources[$id]['format'] = 'myshiptracking';
199
+			//$last_exec['fr24json'] = 0;
200
+			if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
201
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
202
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
203
+				exit(0);
204
+			}
205
+			//} else if (preg_match('/10001/',$host)) {
206
+			} else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
207
+			//$formats[$id] = 'tsv';
208
+			$globalSources[$id]['format'] = 'tsv';
209
+			if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
210
+			}
211
+		} elseif (filter_var($host,FILTER_VALIDATE_URL)) {
212
+			if ($globalSources[$id]['format'] == 'aisnmeahttp') {
213
+				$idf = fopen($globalSources[$id]['host'],'r',false,$context);
214
+				if ($idf !== false) {
215
+				$httpfeeds[$id] = $idf;
216
+				if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
217
+				}
218
+				elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
219
+			} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
220
+		} elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
221
+		$hostport = explode(':',$host);
222
+		if (isset($hostport[1])) {
223 223
 		$port = $hostport[1];
224 224
 		$hostn = $hostport[0];
225
-	    } else {
225
+		} else {
226 226
 		$port = $globalSources[$id]['port'];
227 227
 		$hostn = $globalSources[$id]['host'];
228
-	    }
229
-	    $Common = new Common();
230
-	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
231
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
232
-    	    } else {
233
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
234
-	    }
235
-	    if ($s) {
236
-    	        $sockets[$id] = $s;
237
-    	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
238
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
228
+		}
229
+		$Common = new Common();
230
+		if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
231
+			$s = $Common->create_socket($hostn,$port, $errno, $errstr);
232
+			} else {
233
+			$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
234
+		}
235
+		if ($s) {
236
+				$sockets[$id] = $s;
237
+				if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
238
+			if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
239 239
 			//$formats[$id] = 'aprs';
240 240
 			$globalSources[$id]['format'] = 'aprs';
241 241
 			//$aprs_connect = 0;
242 242
 			//$use_aprs = true;
243
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
243
+			} elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
244 244
 			$globalSources[$id]['format'] = 'vrstcp';
245
-    		    } elseif ($port == '10001') {
246
-        		//$formats[$id] = 'tsv';
247
-        		$globalSources[$id]['format'] = 'tsv';
248
-		    } elseif ($port == '30002') {
249
-        		//$formats[$id] = 'raw';
250
-        		$globalSources[$id]['format'] = 'raw';
251
-		    } elseif ($port == '5001') {
252
-        		//$formats[$id] = 'raw';
253
-        		$globalSources[$id]['format'] = 'flightgearmp';
254
-		    } elseif ($port == '30005') {
245
+				} elseif ($port == '10001') {
246
+				//$formats[$id] = 'tsv';
247
+				$globalSources[$id]['format'] = 'tsv';
248
+			} elseif ($port == '30002') {
249
+				//$formats[$id] = 'raw';
250
+				$globalSources[$id]['format'] = 'raw';
251
+			} elseif ($port == '5001') {
252
+				//$formats[$id] = 'raw';
253
+				$globalSources[$id]['format'] = 'flightgearmp';
254
+			} elseif ($port == '30005') {
255 255
 			// Not yet supported
256
-        		//$formats[$id] = 'beast';
257
-        		$globalSources[$id]['format'] = 'beast';
258
-		    //} else $formats[$id] = 'sbs';
259
-		    } else $globalSources[$id]['format'] = 'sbs';
260
-		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
256
+				//$formats[$id] = 'beast';
257
+				$globalSources[$id]['format'] = 'beast';
258
+			//} else $formats[$id] = 'sbs';
259
+			} else $globalSources[$id]['format'] = 'sbs';
260
+			//if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
261 261
 		}
262 262
 		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
263
-            } else {
263
+			} else {
264 264
 		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
265
-    	    }
266
-        }
267
-    }
265
+			}
266
+		}
267
+	}
268 268
 }
269 269
 if (!isset($globalMinFetch)) $globalMinFetch = 15;
270 270
 
@@ -287,9 +287,9 @@  discard block
 block discarded – undo
287 287
 //connect_all($globalSources);
288 288
 
289 289
 if (isset($globalProxy) && $globalProxy) {
290
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
290
+	$context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
291 291
 } else {
292
-    $context = stream_context_create(array('http' => array('timeout' => $timeout)));
292
+	$context = stream_context_create(array('http' => array('timeout' => $timeout)));
293 293
 }
294 294
 
295 295
 // APRS Configuration
@@ -298,21 +298,21 @@  discard block
 block discarded – undo
298 298
 	die;
299 299
 }
300 300
 foreach ($globalSources as $key => $source) {
301
-    if (!isset($source['format'])) {
302
-        $globalSources[$key]['format'] = 'auto';
303
-    }
304
-    if (isset($source['callback']) && $source['callback'] === TRUE) {
305
-        unset($globalSources[$key]);
306
-    }
301
+	if (!isset($source['format'])) {
302
+		$globalSources[$key]['format'] = 'auto';
303
+	}
304
+	if (isset($source['callback']) && $source['callback'] === TRUE) {
305
+		unset($globalSources[$key]);
306
+	}
307 307
 }
308 308
 connect_all($globalSources);
309 309
 foreach ($globalSources as $key => $source) {
310
-    if (isset($source['format']) && $source['format'] == 'aprs') {
310
+	if (isset($source['format']) && $source['format'] == 'aprs') {
311 311
 	$aprs_connect = 0;
312 312
 	$use_aprs = true;
313 313
 	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
314 314
 	break;
315
-    }
315
+	}
316 316
 }
317 317
 
318 318
 if ($use_aprs) {
@@ -353,115 +353,115 @@  discard block
 block discarded – undo
353 353
 
354 354
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
355 355
 while ($i > 0) {
356
-    if (!$globalDaemon) $i = $endtime-time();
357
-    // Delete old ATC
358
-    if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
356
+	if (!$globalDaemon) $i = $endtime-time();
357
+	// Delete old ATC
358
+	if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
359 359
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
360
-        $ATC->deleteOldATC();
361
-    }
360
+		$ATC->deleteOldATC();
361
+	}
362 362
     
363
-    if (count($last_exec) == count($globalSources)) {
363
+	if (count($last_exec) == count($globalSources)) {
364 364
 	$max = $globalMinFetch;
365 365
 	foreach ($last_exec as $last) {
366
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
366
+		if ((time() - $last['last']) < $max) $max = time() - $last['last'];
367 367
 	}
368 368
 	if ($max != $globalMinFetch) {
369
-	    if ($globalDebug) echo 'Sleeping...'."\n";
370
-	    sleep($globalMinFetch-$max+2);
369
+		if ($globalDebug) echo 'Sleeping...'."\n";
370
+		sleep($globalMinFetch-$max+2);
371
+	}
371 372
 	}
372
-    }
373 373
 
374 374
     
375
-    //foreach ($formats as $id => $value) {
376
-    foreach ($globalSources as $id => $value) {
375
+	//foreach ($formats as $id => $value) {
376
+	foreach ($globalSources as $id => $value) {
377 377
 	date_default_timezone_set('UTC');
378 378
 	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
379 379
 	if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
380
-	    //$buffer = $Common->getData($hosts[$id]);
381
-	    $buffer = $Common->getData($value['host']);
382
-	    if ($buffer != '') $reset = 0;
383
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
384
-	    $buffer = explode('\n',$buffer);
385
-	    foreach ($buffer as $line) {
386
-    		if ($line != '' && count($line) > 7) {
387
-    		    $line = explode(',', $line);
388
-	            $data = array();
389
-	            $data['hex'] = $line[1]; // hex
390
-	            $data['ident'] = $line[2]; // ident
391
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
392
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
393
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
394
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
395
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
396
-	            $data['verticalrate'] = ''; // vertical rate
397
-	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
398
-	            $data['emergency'] = ''; // emergency
399
-		    $data['datetime'] = date('Y-m-d H:i:s');
400
-		    $data['format_source'] = 'deltadbtxt';
401
-    		    $data['id_source'] = $id_source;
402
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
403
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
404
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
405
-    		    $SI->add($data);
406
-		    unset($data);
407
-    		}
408
-    	    }
409
-    	    $last_exec[$id]['last'] = time();
380
+		//$buffer = $Common->getData($hosts[$id]);
381
+		$buffer = $Common->getData($value['host']);
382
+		if ($buffer != '') $reset = 0;
383
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
384
+		$buffer = explode('\n',$buffer);
385
+		foreach ($buffer as $line) {
386
+			if ($line != '' && count($line) > 7) {
387
+				$line = explode(',', $line);
388
+				$data = array();
389
+				$data['hex'] = $line[1]; // hex
390
+				$data['ident'] = $line[2]; // ident
391
+				if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
392
+				if (isset($line[4])) $data['speed'] = $line[4]; // speed
393
+				if (isset($line[5])) $data['heading'] = $line[5]; // heading
394
+				if (isset($line[6])) $data['latitude'] = $line[6]; // lat
395
+				if (isset($line[7])) $data['longitude'] = $line[7]; // long
396
+				$data['verticalrate'] = ''; // vertical rate
397
+				//if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
398
+				$data['emergency'] = ''; // emergency
399
+			$data['datetime'] = date('Y-m-d H:i:s');
400
+			$data['format_source'] = 'deltadbtxt';
401
+				$data['id_source'] = $id_source;
402
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
403
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
404
+			if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
405
+				$SI->add($data);
406
+			unset($data);
407
+			}
408
+			}
409
+			$last_exec[$id]['last'] = time();
410 410
 	} elseif ($value['format'] == 'aisnmeatxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
411
-	    date_default_timezone_set('CET');
412
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
413
-	    date_default_timezone_set('UTC');
414
-	    if ($buffer != '') $reset = 0;
415
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
416
-	    $buffer = explode('\n',$buffer);
417
-	    foreach ($buffer as $line) {
411
+		date_default_timezone_set('CET');
412
+		$buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
413
+		date_default_timezone_set('UTC');
414
+		if ($buffer != '') $reset = 0;
415
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
416
+		$buffer = explode('\n',$buffer);
417
+		foreach ($buffer as $line) {
418 418
 		if ($line != '') {
419
-		    //echo "'".$line."'\n";
420
-		    $add = false;
421
-		    $ais_data = $AIS->parse_line(trim($line));
422
-		    $data = array();
423
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
424
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
425
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
426
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
427
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
428
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
429
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
430
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
431
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
432
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
433
-		    if (isset($ais_data['timestamp'])) {
419
+			//echo "'".$line."'\n";
420
+			$add = false;
421
+			$ais_data = $AIS->parse_line(trim($line));
422
+			$data = array();
423
+			if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
424
+			if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
425
+			if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
426
+			if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
427
+			if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
428
+			if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
429
+			if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
430
+			if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
431
+			if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
432
+			if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
433
+			if (isset($ais_data['timestamp'])) {
434 434
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
435 435
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
436
-			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
437
-			    $add = true;
436
+				$last_exec[$id]['timestamp'] = $ais_data['timestamp'];
437
+				$add = true;
438 438
 			}
439
-		    } else {
439
+			} else {
440 440
 			$data['datetime'] = date('Y-m-d H:i:s');
441 441
 			$add = true;
442
-		    }
443
-		    $data['format_source'] = 'aisnmeatxt';
444
-    		    $data['id_source'] = $id_source;
445
-		    //print_r($data);
446
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
447
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
448
-		    unset($data);
442
+			}
443
+			$data['format_source'] = 'aisnmeatxt';
444
+				$data['id_source'] = $id_source;
445
+			//print_r($data);
446
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
447
+			if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
448
+			unset($data);
449 449
 		}
450
-    	    }
451
-    	    $last_exec[$id]['last'] = time();
450
+			}
451
+			$last_exec[$id]['last'] = time();
452 452
 	} elseif ($value['format'] == 'aisnmeahttp') {
453
-	    $arr = $httpfeeds;
454
-	    $w = $e = null;
453
+		$arr = $httpfeeds;
454
+		$w = $e = null;
455 455
 	    
456
-	    if (isset($arr[$id])) {
456
+		if (isset($arr[$id])) {
457 457
 		$nn = stream_select($arr,$w,$e,$timeout);
458 458
 		if ($nn > 0) {
459
-		    foreach ($httpfeeds as $feed) {
459
+			foreach ($httpfeeds as $feed) {
460 460
 			$buffer = stream_get_line($feed,2000,"\n");
461 461
 			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
462 462
 			$buffer = explode('\n',$buffer);
463 463
 			foreach ($buffer as $line) {
464
-			    if ($line != '') {
464
+				if ($line != '') {
465 465
 				$ais_data = $AIS->parse_line(trim($line));
466 466
 				$data = array();
467 467
 				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
@@ -479,96 +479,96 @@  discard block
 block discarded – undo
479 479
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
480 480
 				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
481 481
 				if (isset($ais_data['timestamp'])) {
482
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
482
+					$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
483 483
 				} else {
484
-				    $data['datetime'] = date('Y-m-d H:i:s');
484
+					$data['datetime'] = date('Y-m-d H:i:s');
485 485
 				}
486 486
 				$data['format_source'] = 'aisnmeahttp';
487 487
 				$data['id_source'] = $id_source;
488 488
 				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
489 489
 				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
490 490
 				unset($data);
491
-			    }
491
+				}
492
+			}
492 493
 			}
493
-		    }
494 494
 		} else {
495
-		    $format = $value['format'];
496
-		    if (isset($tt[$format])) $tt[$format]++;
497
-		    else $tt[$format] = 0;
498
-		    if ($tt[$format] > 30) {
495
+			$format = $value['format'];
496
+			if (isset($tt[$format])) $tt[$format]++;
497
+			else $tt[$format] = 0;
498
+			if ($tt[$format] > 30) {
499 499
 			if ($globalDebug) echo 'Reconnect...'."\n";
500 500
 			sleep(2);
501 501
 			$sourceeen[] = $value;
502 502
 			connect_all($sourceeen);
503 503
 			$sourceeen = array();
504
-		    }
504
+			}
505
+		}
505 506
 		}
506
-	    }
507 507
 	} elseif ($value['format'] == 'myshiptracking' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
508
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
509
-	    if ($buffer != '') {
508
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
509
+		if ($buffer != '') {
510 510
 		//echo $buffer;
511 511
 		$all_data = json_decode($buffer,true);
512 512
 		//print_r($all_data);
513 513
 		if (isset($all_data[0]['DATA'])) {
514
-		    foreach ($all_data[0]['DATA'] as $line) {
514
+			foreach ($all_data[0]['DATA'] as $line) {
515 515
 			if ($line != '') {
516
-			    $data = array();
517
-			    $data['ident'] = $line['NAME'];
518
-			    $data['mmsi'] = $line['MMSI'];
519
-			    $data['speed'] = $line['SOG'];
520
-			    $data['heading'] = $line['COG'];
521
-			    $data['latitude'] = $line['LAT'];
522
-			    $data['longitude'] = $line['LNG'];
523
-			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
524
-			    $data['imo'] = $line['IMO'];
525
-			    //$data['arrival_code'] = $ais_data['destination'];
526
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
527
-			    $data['format_source'] = 'myshiptracking';
528
-			    $data['id_source'] = $id_source;
529
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
530
-			    $MI->add($data);
531
-			    unset($data);
516
+				$data = array();
517
+				$data['ident'] = $line['NAME'];
518
+				$data['mmsi'] = $line['MMSI'];
519
+				$data['speed'] = $line['SOG'];
520
+				$data['heading'] = $line['COG'];
521
+				$data['latitude'] = $line['LAT'];
522
+				$data['longitude'] = $line['LNG'];
523
+				//    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
524
+				$data['imo'] = $line['IMO'];
525
+				//$data['arrival_code'] = $ais_data['destination'];
526
+				$data['datetime'] = date('Y-m-d H:i:s',$line['T']);
527
+				$data['format_source'] = 'myshiptracking';
528
+				$data['id_source'] = $id_source;
529
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
530
+				$MI->add($data);
531
+				unset($data);
532
+			}
532 533
 			}
533
-		    }
534 534
 		}
535
-	    }
536
-	    $last_exec[$id]['last'] = time();
535
+		}
536
+		$last_exec[$id]['last'] = time();
537 537
 	} elseif ($value['format'] == 'boatbeaconapp' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
538
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
539
-	    if ($buffer != '') {
538
+		$buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
539
+		if ($buffer != '') {
540 540
 		$all_data = json_decode($buffer,true);
541 541
 		if (isset($all_data[0]['mmsi'])) {
542
-		    foreach ($all_data as $line) {
542
+			foreach ($all_data as $line) {
543 543
 			if ($line != '') {
544
-			    $data = array();
545
-			    $data['ident'] = $line['shipname'];
546
-			    $data['callsign'] = $line['callsign'];
547
-			    $data['mmsi'] = $line['mmsi'];
548
-			    $data['speed'] = $line['sog'];
549
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
550
-			    $data['latitude'] = $line['latitude'];
551
-			    $data['longitude'] = $line['longitude'];
552
-			    $data['type_id'] = $line['shiptype'];
553
-			    $data['arrival_code'] = $line['destination'];
554
-			    $data['datetime'] = $line['time'];
555
-			    $data['format_source'] = 'boatbeaconapp';
556
-			    $data['id_source'] = $id_source;
557
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
558
-			    $MI->add($data);
559
-			    unset($data);
544
+				$data = array();
545
+				$data['ident'] = $line['shipname'];
546
+				$data['callsign'] = $line['callsign'];
547
+				$data['mmsi'] = $line['mmsi'];
548
+				$data['speed'] = $line['sog'];
549
+				if ($line['heading'] != '511') $data['heading'] = $line['heading'];
550
+				$data['latitude'] = $line['latitude'];
551
+				$data['longitude'] = $line['longitude'];
552
+				$data['type_id'] = $line['shiptype'];
553
+				$data['arrival_code'] = $line['destination'];
554
+				$data['datetime'] = $line['time'];
555
+				$data['format_source'] = 'boatbeaconapp';
556
+				$data['id_source'] = $id_source;
557
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
558
+				$MI->add($data);
559
+				unset($data);
560
+			}
560 561
 			}
561
-		    }
562 562
 		}
563 563
 		
564
-	    }
565
-    	    $last_exec[$id]['last'] = time();
564
+		}
565
+			$last_exec[$id]['last'] = time();
566 566
 	} elseif ($value['format'] == 'boatnerd' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
567
-	    $buffer = $Common->getData($value['host']);
568
-	    if ($buffer != '') {
567
+		$buffer = $Common->getData($value['host']);
568
+		if ($buffer != '') {
569 569
 		$all_data = json_decode($buffer,true);
570 570
 		if (isset($all_data['features'][0]['id'])) {
571
-		    foreach ($all_data['features'] as $line) {
571
+			foreach ($all_data['features'] as $line) {
572 572
 			$data = array();
573 573
 			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
574 574
 			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
@@ -587,59 +587,59 @@  discard block
 block discarded – undo
587 587
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
588 588
 			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
589 589
 			unset($data);
590
-		    }
590
+			}
591 591
 		}
592 592
 		
593
-	    }
594
-    	    $last_exec[$id]['last'] = time();
593
+		}
594
+			$last_exec[$id]['last'] = time();
595 595
 	} elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
596
-	    echo 'download...';
597
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
598
-	    echo 'done !'."\n";
599
-	    if ($buffer != '') $reset = 0;
600
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
601
-	    $buffer = explode('\n',$buffer);
602
-	    foreach ($buffer as $line) {
596
+		echo 'download...';
597
+		$buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
598
+		echo 'done !'."\n";
599
+		if ($buffer != '') $reset = 0;
600
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
601
+		$buffer = explode('\n',$buffer);
602
+		foreach ($buffer as $line) {
603 603
 		if ($line != '') {
604
-		    $data = array();
605
-		    $data['mmsi'] = (int)substr($line,0,9);
606
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
607
-		    //$data['status'] = substr($line,21,2);
608
-		    //$data['type'] = substr($line,24,3);
609
-		    $data['latitude'] = substr($line,29,9);
610
-		    $data['longitude'] = substr($line,41,9);
611
-		    $data['speed'] = round(substr($line,51,5));
612
-		    //$data['course'] = substr($line,57,5);
613
-		    $data['heading'] = round(substr($line,63,3));
614
-		    //$data['draft'] = substr($line,67,4);
615
-		    //$data['length'] = substr($line,72,3);
616
-		    //$data['beam'] = substr($line,76,2);
617
-		    $data['ident'] = trim(utf8_encode(substr($line,79,20)));
618
-		    //$data['callsign'] = trim(substr($line,100,7);
619
-		    //$data['dest'] = substr($line,108,20);
620
-		    //$data['etaDate'] = substr($line,129,5);
621
-		    //$data['etaTime'] = substr($line,135,5);
622
-		    $data['format_source'] = 'shipplotter';
623
-    		    $data['id_source'] = $id_source;
624
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
625
-		    //print_r($data);
626
-		    echo 'Add...'."\n";
627
-		    $MI->add($data);
628
-		    unset($data);
604
+			$data = array();
605
+			$data['mmsi'] = (int)substr($line,0,9);
606
+			$data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
607
+			//$data['status'] = substr($line,21,2);
608
+			//$data['type'] = substr($line,24,3);
609
+			$data['latitude'] = substr($line,29,9);
610
+			$data['longitude'] = substr($line,41,9);
611
+			$data['speed'] = round(substr($line,51,5));
612
+			//$data['course'] = substr($line,57,5);
613
+			$data['heading'] = round(substr($line,63,3));
614
+			//$data['draft'] = substr($line,67,4);
615
+			//$data['length'] = substr($line,72,3);
616
+			//$data['beam'] = substr($line,76,2);
617
+			$data['ident'] = trim(utf8_encode(substr($line,79,20)));
618
+			//$data['callsign'] = trim(substr($line,100,7);
619
+			//$data['dest'] = substr($line,108,20);
620
+			//$data['etaDate'] = substr($line,129,5);
621
+			//$data['etaTime'] = substr($line,135,5);
622
+			$data['format_source'] = 'shipplotter';
623
+				$data['id_source'] = $id_source;
624
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
625
+			//print_r($data);
626
+			echo 'Add...'."\n";
627
+			$MI->add($data);
628
+			unset($data);
629 629
 		}
630
-    	    }
631
-    	    $last_exec[$id]['last'] = time();
630
+			}
631
+			$last_exec[$id]['last'] = time();
632 632
 	//} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) {
633 633
 	} elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) {
634
-	    //$buffer = $Common->getData($hosts[$id]);
635
-	    $buffer = $Common->getData($value['host']);
636
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
637
-	    $buffer = explode('\n',$buffer);
638
-	    $reset = 0;
639
-	    foreach ($buffer as $line) {
640
-    		if ($line != '') {
641
-    		    $line = explode(':', $line);
642
-    		    if (count($line) > 30 && $line[0] != 'callsign') {
634
+		//$buffer = $Common->getData($hosts[$id]);
635
+		$buffer = $Common->getData($value['host']);
636
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
637
+		$buffer = explode('\n',$buffer);
638
+		$reset = 0;
639
+		foreach ($buffer as $line) {
640
+			if ($line != '') {
641
+				$line = explode(':', $line);
642
+				if (count($line) > 30 && $line[0] != 'callsign') {
643 643
 			$data = array();
644 644
 			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
645 645
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
@@ -652,37 +652,37 @@  discard block
 block discarded – undo
652 652
 			if (isset($line[45])) $data['heading'] = $line[45]; // heading
653 653
 			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
654 654
 			$data['latitude'] = $line[5]; // lat
655
-	        	$data['longitude'] = $line[6]; // long
656
-	        	$data['verticalrate'] = ''; // vertical rate
657
-	        	$data['squawk'] = ''; // squawk
658
-	        	$data['emergency'] = ''; // emergency
659
-	        	$data['waypoints'] = $line[30];
655
+				$data['longitude'] = $line[6]; // long
656
+				$data['verticalrate'] = ''; // vertical rate
657
+				$data['squawk'] = ''; // squawk
658
+				$data['emergency'] = ''; // emergency
659
+				$data['waypoints'] = $line[30];
660 660
 			$data['datetime'] = date('Y-m-d H:i:s');
661 661
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
662 662
 			//if (isset($line[37])) $data['last_update'] = $line[37];
663
-		        $data['departure_airport_icao'] = $line[11];
664
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
665
-		        $data['arrival_airport_icao'] = $line[13];
663
+				$data['departure_airport_icao'] = $line[11];
664
+				$data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
665
+				$data['arrival_airport_icao'] = $line[13];
666 666
 			$data['frequency'] = $line[4];
667 667
 			$data['type'] = $line[18];
668 668
 			$data['range'] = $line[19];
669 669
 			if (isset($line[35])) $data['info'] = $line[35];
670
-    			$data['id_source'] = $id_source;
671
-	    		//$data['arrival_airport_time'] = ;
672
-	    		if ($line[9] != '') {
673
-	    		    $aircraft_data = explode('/',$line[9]);
674
-	    		    if (isset($aircraft_data[1])) {
675
-	    			$data['aircraft_icao'] = $aircraft_data[1];
676
-	    		    }
677
-        		}
678
-	    		/*
670
+				$data['id_source'] = $id_source;
671
+				//$data['arrival_airport_time'] = ;
672
+				if ($line[9] != '') {
673
+					$aircraft_data = explode('/',$line[9]);
674
+					if (isset($aircraft_data[1])) {
675
+					$data['aircraft_icao'] = $aircraft_data[1];
676
+					}
677
+				}
678
+				/*
679 679
 	    		if ($value == 'whazzup') $data['format_source'] = 'whazzup';
680 680
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
681 681
 	    		*/
682
-	    		$data['format_source'] = $value['format'];
682
+				$data['format_source'] = $value['format'];
683 683
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
684 684
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
685
-    			if ($line[3] == 'PILOT') $SI->add($data);
685
+				if ($line[3] == 'PILOT') $SI->add($data);
686 686
 			elseif ($line[3] == 'ATC') {
687 687
 				//print_r($data);
688 688
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
@@ -703,16 +703,16 @@  discard block
 block discarded – undo
703 703
 					else echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
704 704
 				}
705 705
 			}
706
-    			unset($data);
707
-    		    }
708
-    		}
709
-    	    }
710
-    	    //if ($value == 'whazzup') $last_exec['whazzup'] = time();
711
-    	    //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
712
-    	    $last_exec[$id]['last'] = time();
713
-    	} elseif ($value['format'] == 'airwhere' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
714
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
715
-	    if ($buffer != '') {
706
+				unset($data);
707
+				}
708
+			}
709
+			}
710
+			//if ($value == 'whazzup') $last_exec['whazzup'] = time();
711
+			//elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
712
+			$last_exec[$id]['last'] = time();
713
+		} elseif ($value['format'] == 'airwhere' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
714
+		$buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
715
+		if ($buffer != '') {
716 716
 		$all_data = simplexml_load_string($buffer);
717 717
 		foreach($all_data->children() as $childdata) {
718 718
 			$data = array();
@@ -734,10 +734,10 @@  discard block
 block discarded – undo
734 734
 			$SI->add($data);
735 735
 			unset($data);
736 736
 		}
737
-	    }
738
-	    $Source->deleteOldLocationByType('gs');
739
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
740
-	    if ($buffer != '') {
737
+		}
738
+		$Source->deleteOldLocationByType('gs');
739
+		$buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
740
+		if ($buffer != '') {
741 741
 		$all_data = simplexml_load_string($buffer);
742 742
 		foreach($all_data->children() as $childdata) {
743 743
 			$data = array();
@@ -755,249 +755,249 @@  discard block
 block discarded – undo
755 755
 			}
756 756
 			unset($data);
757 757
 		}
758
-	    }
759
-	    $last_exec[$id]['last'] = time();
758
+		}
759
+		$last_exec[$id]['last'] = time();
760 760
 	} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
761
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
762
-	    if ($buffer != '') {
763
-	    $all_data = json_decode($buffer,true);
764
-	    if (isset($all_data['acList'])) {
761
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
762
+		if ($buffer != '') {
763
+		$all_data = json_decode($buffer,true);
764
+		if (isset($all_data['acList'])) {
765 765
 		$reset = 0;
766 766
 		foreach ($all_data['acList'] as $line) {
767
-		    $data = array();
768
-		    $data['hex'] = $line['Icao']; // hex
769
-		    if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
770
-		    if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
771
-		    if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
772
-		    if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
773
-		    if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
774
-		    if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
775
-		    //$data['verticalrate'] = $line['']; // verticale rate
776
-		    if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
777
-		    $data['emergency'] = ''; // emergency
778
-		    if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
767
+			$data = array();
768
+			$data['hex'] = $line['Icao']; // hex
769
+			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
770
+			if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
771
+			if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
772
+			if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
773
+			if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
774
+			if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
775
+			//$data['verticalrate'] = $line['']; // verticale rate
776
+			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
777
+			$data['emergency'] = ''; // emergency
778
+			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
779 779
 		    
780
-		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
781
-		    else $data['datetime'] = date('Y-m-d H:i:s');
780
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
781
+			else $data['datetime'] = date('Y-m-d H:i:s');
782 782
 		    
783
-		    //$data['datetime'] = date('Y-m-d H:i:s');
784
-		    if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
785
-	    	    $data['format_source'] = 'aircraftlistjson';
786
-		    $data['id_source'] = $id_source;
787
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
788
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
789
-		    if (isset($data['latitude'])) $SI->add($data);
790
-		    unset($data);
783
+			//$data['datetime'] = date('Y-m-d H:i:s');
784
+			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
785
+				$data['format_source'] = 'aircraftlistjson';
786
+			$data['id_source'] = $id_source;
787
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
788
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
789
+			if (isset($data['latitude'])) $SI->add($data);
790
+			unset($data);
791 791
 		}
792
-	    } elseif (is_array($all_data)) {
792
+		} elseif (is_array($all_data)) {
793 793
 		$reset = 0;
794 794
 		foreach ($all_data as $line) {
795
-		    $data = array();
796
-		    $data['hex'] = $line['hex']; // hex
797
-		    $data['ident'] = $line['flight']; // ident
798
-		    $data['altitude'] = $line['altitude']; // altitude
799
-		    $data['speed'] = $line['speed']; // speed
800
-		    $data['heading'] = $line['track']; // heading
801
-		    $data['latitude'] = $line['lat']; // lat
802
-		    $data['longitude'] = $line['lon']; // long
803
-		    $data['verticalrate'] = $line['vrt']; // verticale rate
804
-		    $data['squawk'] = $line['squawk']; // squawk
805
-		    $data['emergency'] = ''; // emergency
806
-		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
807
-		    else $data['datetime'] = date('Y-m-d H:i:s');
808
-	    	    $data['format_source'] = 'aircraftlistjson';
809
-    		    $data['id_source'] = $id_source;
810
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
811
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
812
-		    $SI->add($data);
813
-		    unset($data);
795
+			$data = array();
796
+			$data['hex'] = $line['hex']; // hex
797
+			$data['ident'] = $line['flight']; // ident
798
+			$data['altitude'] = $line['altitude']; // altitude
799
+			$data['speed'] = $line['speed']; // speed
800
+			$data['heading'] = $line['track']; // heading
801
+			$data['latitude'] = $line['lat']; // lat
802
+			$data['longitude'] = $line['lon']; // long
803
+			$data['verticalrate'] = $line['vrt']; // verticale rate
804
+			$data['squawk'] = $line['squawk']; // squawk
805
+			$data['emergency'] = ''; // emergency
806
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
807
+			else $data['datetime'] = date('Y-m-d H:i:s');
808
+				$data['format_source'] = 'aircraftlistjson';
809
+				$data['id_source'] = $id_source;
810
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
811
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
812
+			$SI->add($data);
813
+			unset($data);
814 814
 		}
815
-	    }
816
-	    }
817
-    	    //$last_exec['aircraftlistjson'] = time();
818
-    	    $last_exec[$id]['last'] = time();
819
-    	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
820
-    	} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
821
-	    $buffer = $Common->getData($value['host']);
822
-	    $all_data = json_decode($buffer,true);
823
-	    if (isset($all_data['planes'])) {
815
+		}
816
+		}
817
+			//$last_exec['aircraftlistjson'] = time();
818
+			$last_exec[$id]['last'] = time();
819
+		//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
820
+		} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
821
+		$buffer = $Common->getData($value['host']);
822
+		$all_data = json_decode($buffer,true);
823
+		if (isset($all_data['planes'])) {
824 824
 		$reset = 0;
825 825
 		foreach ($all_data['planes'] as $key => $line) {
826
-		    $data = array();
827
-		    $data['hex'] = $key; // hex
828
-		    $data['ident'] = $line[3]; // ident
829
-		    $data['altitude'] = $line[6]; // altitude
830
-		    $data['speed'] = $line[8]; // speed
831
-		    $data['heading'] = $line[7]; // heading
832
-		    $data['latitude'] = $line[4]; // lat
833
-		    $data['longitude'] = $line[5]; // long
834
-		    //$data['verticalrate'] = $line[]; // verticale rate
835
-		    $data['squawk'] = $line[10]; // squawk
836
-		    $data['emergency'] = ''; // emergency
837
-		    $data['registration'] = $line[2];
838
-		    $data['aircraft_icao'] = $line[0];
839
-		    $deparr = explode('-',$line[1]);
840
-		    if (count($deparr) == 2) {
826
+			$data = array();
827
+			$data['hex'] = $key; // hex
828
+			$data['ident'] = $line[3]; // ident
829
+			$data['altitude'] = $line[6]; // altitude
830
+			$data['speed'] = $line[8]; // speed
831
+			$data['heading'] = $line[7]; // heading
832
+			$data['latitude'] = $line[4]; // lat
833
+			$data['longitude'] = $line[5]; // long
834
+			//$data['verticalrate'] = $line[]; // verticale rate
835
+			$data['squawk'] = $line[10]; // squawk
836
+			$data['emergency'] = ''; // emergency
837
+			$data['registration'] = $line[2];
838
+			$data['aircraft_icao'] = $line[0];
839
+			$deparr = explode('-',$line[1]);
840
+			if (count($deparr) == 2) {
841 841
 			$data['departure_airport_icao'] = $deparr[0];
842 842
 			$data['arrival_airport_icao'] = $deparr[1];
843
-		    }
844
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
845
-	    	    $data['format_source'] = 'planeupdatefaa';
846
-    		    $data['id_source'] = $id_source;
847
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
848
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
849
-		    $SI->add($data);
850
-		    unset($data);
843
+			}
844
+			$data['datetime'] = date('Y-m-d H:i:s',$line[9]);
845
+				$data['format_source'] = 'planeupdatefaa';
846
+				$data['id_source'] = $id_source;
847
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
848
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
849
+			$SI->add($data);
850
+			unset($data);
851
+		}
851 852
 		}
852
-	    }
853
-    	    //$last_exec['planeupdatefaa'] = time();
854
-    	    $last_exec[$id]['last'] = time();
855
-    	} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
856
-	    $buffer = $Common->getData($value['host']);
857
-	    $all_data = json_decode($buffer,true);
858
-	    if (isset($all_data['states'])) {
853
+			//$last_exec['planeupdatefaa'] = time();
854
+			$last_exec[$id]['last'] = time();
855
+		} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
856
+		$buffer = $Common->getData($value['host']);
857
+		$all_data = json_decode($buffer,true);
858
+		if (isset($all_data['states'])) {
859 859
 		$reset = 0;
860 860
 		foreach ($all_data['states'] as $key => $line) {
861
-		    $data = array();
862
-		    $data['hex'] = $line[0]; // hex
863
-		    $data['ident'] = trim($line[1]); // ident
864
-		    $data['altitude'] = round($line[7]*3.28084); // altitude
865
-		    $data['speed'] = round($line[9]*1.94384); // speed
866
-		    $data['heading'] = round($line[10]); // heading
867
-		    $data['latitude'] = $line[6]; // lat
868
-		    $data['longitude'] = $line[5]; // long
869
-		    $data['verticalrate'] = $line[11]; // verticale rate
870
-		    //$data['squawk'] = $line[10]; // squawk
871
-		    //$data['emergency'] = ''; // emergency
872
-		    //$data['registration'] = $line[2];
873
-		    //$data['aircraft_icao'] = $line[0];
874
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
875
-	    	    $data['format_source'] = 'opensky';
876
-    		    $data['id_source'] = $id_source;
877
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
878
-		    $SI->add($data);
879
-		    unset($data);
861
+			$data = array();
862
+			$data['hex'] = $line[0]; // hex
863
+			$data['ident'] = trim($line[1]); // ident
864
+			$data['altitude'] = round($line[7]*3.28084); // altitude
865
+			$data['speed'] = round($line[9]*1.94384); // speed
866
+			$data['heading'] = round($line[10]); // heading
867
+			$data['latitude'] = $line[6]; // lat
868
+			$data['longitude'] = $line[5]; // long
869
+			$data['verticalrate'] = $line[11]; // verticale rate
870
+			//$data['squawk'] = $line[10]; // squawk
871
+			//$data['emergency'] = ''; // emergency
872
+			//$data['registration'] = $line[2];
873
+			//$data['aircraft_icao'] = $line[0];
874
+			$data['datetime'] = date('Y-m-d H:i:s',$line[3]);
875
+				$data['format_source'] = 'opensky';
876
+				$data['id_source'] = $id_source;
877
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
878
+			$SI->add($data);
879
+			unset($data);
880 880
 		}
881
-	    }
882
-    	    //$last_exec['planeupdatefaa'] = time();
883
-    	    $last_exec[$id]['last'] = time();
884
-    	//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
885
-    	} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
886
-	    //$buffer = $Common->getData($hosts[$id]);
887
-	    $buffer = $Common->getData($value['host']);
888
-	    $all_data = json_decode($buffer,true);
889
-	    if (!empty($all_data)) $reset = 0;
890
-	    foreach ($all_data as $key => $line) {
881
+		}
882
+			//$last_exec['planeupdatefaa'] = time();
883
+			$last_exec[$id]['last'] = time();
884
+		//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
885
+		} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
886
+		//$buffer = $Common->getData($hosts[$id]);
887
+		$buffer = $Common->getData($value['host']);
888
+		$all_data = json_decode($buffer,true);
889
+		if (!empty($all_data)) $reset = 0;
890
+		foreach ($all_data as $key => $line) {
891 891
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
892
-		    $data = array();
893
-		    $data['hex'] = $line[0];
894
-		    $data['ident'] = $line[16]; //$line[13]
895
-	    	    $data['altitude'] = $line[4]; // altitude
896
-	    	    $data['speed'] = $line[5]; // speed
897
-	    	    $data['heading'] = $line[3]; // heading
898
-	    	    $data['latitude'] = $line[1]; // lat
899
-	    	    $data['longitude'] = $line[2]; // long
900
-	    	    $data['verticalrate'] = $line[15]; // verticale rate
901
-	    	    $data['squawk'] = $line[6]; // squawk
902
-	    	    $data['aircraft_icao'] = $line[8];
903
-	    	    $data['registration'] = $line[9];
904
-		    $data['departure_airport_iata'] = $line[11];
905
-		    $data['arrival_airport_iata'] = $line[12];
906
-	    	    $data['emergency'] = ''; // emergency
907
-		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
908
-	    	    $data['format_source'] = 'fr24json';
909
-    		    $data['id_source'] = $id_source;
910
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
911
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
912
-		    $SI->add($data);
913
-		    unset($data);
892
+			$data = array();
893
+			$data['hex'] = $line[0];
894
+			$data['ident'] = $line[16]; //$line[13]
895
+				$data['altitude'] = $line[4]; // altitude
896
+				$data['speed'] = $line[5]; // speed
897
+				$data['heading'] = $line[3]; // heading
898
+				$data['latitude'] = $line[1]; // lat
899
+				$data['longitude'] = $line[2]; // long
900
+				$data['verticalrate'] = $line[15]; // verticale rate
901
+				$data['squawk'] = $line[6]; // squawk
902
+				$data['aircraft_icao'] = $line[8];
903
+				$data['registration'] = $line[9];
904
+			$data['departure_airport_iata'] = $line[11];
905
+			$data['arrival_airport_iata'] = $line[12];
906
+				$data['emergency'] = ''; // emergency
907
+			$data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
908
+				$data['format_source'] = 'fr24json';
909
+				$data['id_source'] = $id_source;
910
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
911
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
912
+			$SI->add($data);
913
+			unset($data);
914
+		}
914 915
 		}
915
-	    }
916
-    	    //$last_exec['fr24json'] = time();
917
-    	    $last_exec[$id]['last'] = time();
918
-    	//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
919
-    	} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
920
-	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
921
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
922
-	    //echo $buffer;
923
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
924
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
925
-	    $all_data = json_decode($buffer,true);
926
-	    if (json_last_error() != JSON_ERROR_NONE) {
916
+			//$last_exec['fr24json'] = time();
917
+			$last_exec[$id]['last'] = time();
918
+		//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
919
+		} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
920
+		//$buffer = $Common->getData($hosts[$id],'get','','','','','150');
921
+		$buffer = $Common->getData($value['host'],'get','','','','','150');
922
+		//echo $buffer;
923
+		$buffer = str_replace(array("\n","\r"),"",$buffer);
924
+		$buffer = preg_replace('/,"num":(.+)/','}',$buffer);
925
+		$all_data = json_decode($buffer,true);
926
+		if (json_last_error() != JSON_ERROR_NONE) {
927 927
 		die(json_last_error_msg());
928
-	    }
929
-	    if (isset($all_data['mrkrs'])) {
928
+		}
929
+		if (isset($all_data['mrkrs'])) {
930 930
 		$reset = 0;
931 931
 		foreach ($all_data['mrkrs'] as $key => $line) {
932
-		    if (isset($line['inf'])) {
932
+			if (isset($line['inf'])) {
933 933
 			$data = array();
934 934
 			$data['hex'] = $line['inf']['ia'];
935 935
 			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
936
-	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
937
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
938
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
939
-	    		$data['latitude'] = $line['pt'][0]; // lat
940
-	    		$data['longitude'] = $line['pt'][1]; // long
941
-	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
942
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
943
-	    		//$data['aircraft_icao'] = $line[8];
944
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
936
+				$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
937
+				if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
938
+				if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
939
+				$data['latitude'] = $line['pt'][0]; // lat
940
+				$data['longitude'] = $line['pt'][1]; // long
941
+				//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
942
+				if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
943
+				//$data['aircraft_icao'] = $line[8];
944
+				if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
945 945
 			//$data['departure_airport_iata'] = $line[11];
946 946
 			//$data['arrival_airport_iata'] = $line[12];
947
-	    		//$data['emergency'] = ''; // emergency
947
+				//$data['emergency'] = ''; // emergency
948 948
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
949
-	    		$data['format_source'] = 'radarvirtueljson';
950
-    			$data['id_source'] = $id_source;
949
+				$data['format_source'] = 'radarvirtueljson';
950
+				$data['id_source'] = $id_source;
951 951
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
952 952
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
953 953
 			$SI->add($data);
954 954
 			unset($data);
955
-		    }
955
+			}
956 956
 		}
957
-	    }
958
-    	    //$last_exec['radarvirtueljson'] = time();
959
-    	    $last_exec[$id]['last'] = time();
960
-    	//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
961
-    	} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
962
-	    //$buffer = $Common->getData($hosts[$id]);
963
-	    $buffer = $Common->getData($value['host'].'?'.time());
964
-	    $all_data = json_decode(utf8_encode($buffer),true);
957
+		}
958
+			//$last_exec['radarvirtueljson'] = time();
959
+			$last_exec[$id]['last'] = time();
960
+		//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
961
+		} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
962
+		//$buffer = $Common->getData($hosts[$id]);
963
+		$buffer = $Common->getData($value['host'].'?'.time());
964
+		$all_data = json_decode(utf8_encode($buffer),true);
965 965
 	    
966
-	    if (isset($all_data['pireps'])) {
966
+		if (isset($all_data['pireps'])) {
967 967
 		$reset = 0;
968
-	        foreach ($all_data['pireps'] as $line) {
969
-		    $data = array();
970
-		    $data['id'] = $line['id'];
971
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
972
-		    $data['ident'] = $line['callsign']; // ident
973
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
974
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
975
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
976
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
977
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
978
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
979
-		    $data['latitude'] = $line['lat']; // lat
980
-		    $data['longitude'] = $line['lon']; // long
981
-		    //$data['verticalrate'] = $line['vrt']; // verticale rate
982
-		    //$data['squawk'] = $line['squawk']; // squawk
983
-		    //$data['emergency'] = ''; // emergency
984
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
985
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
986
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
987
-		    //$data['arrival_airport_time'] = $line['arrtime'];
988
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
989
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
990
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
991
-		    else $data['info'] = '';
992
-		    $data['format_source'] = 'pireps';
993
-    		    $data['id_source'] = $id_source;
994
-		    $data['datetime'] = date('Y-m-d H:i:s');
995
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
996
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
997
-		    if ($line['icon'] == 'plane') {
968
+			foreach ($all_data['pireps'] as $line) {
969
+			$data = array();
970
+			$data['id'] = $line['id'];
971
+			$data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
972
+			$data['ident'] = $line['callsign']; // ident
973
+			if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
974
+			if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
975
+			if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
976
+			if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
977
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
978
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
979
+			$data['latitude'] = $line['lat']; // lat
980
+			$data['longitude'] = $line['lon']; // long
981
+			//$data['verticalrate'] = $line['vrt']; // verticale rate
982
+			//$data['squawk'] = $line['squawk']; // squawk
983
+			//$data['emergency'] = ''; // emergency
984
+			if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
985
+			if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
986
+			if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
987
+			//$data['arrival_airport_time'] = $line['arrtime'];
988
+			if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
989
+			if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
990
+			if (isset($line['atis'])) $data['info'] = $line['atis'];
991
+			else $data['info'] = '';
992
+			$data['format_source'] = 'pireps';
993
+				$data['id_source'] = $id_source;
994
+			$data['datetime'] = date('Y-m-d H:i:s');
995
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
996
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
997
+			if ($line['icon'] == 'plane') {
998 998
 			$SI->add($data);
999
-		    //    print_r($data);
1000
-    		    } elseif ($line['icon'] == 'ct') {
999
+			//    print_r($data);
1000
+				} elseif ($line['icon'] == 'ct') {
1001 1001
 			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1002 1002
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1003 1003
 			$typec = substr($data['ident'],-3);
@@ -1012,203 +1012,203 @@  discard block
 block discarded – undo
1012 1012
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
1013 1013
 			else $data['type'] = 'Observer';
1014 1014
 			if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
1015
-		    }
1016
-		    unset($data);
1015
+			}
1016
+			unset($data);
1017
+		}
1017 1018
 		}
1018
-	    }
1019
-    	    //$last_exec['pirepsjson'] = time();
1020
-    	    $last_exec[$id]['last'] = time();
1021
-    	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
1022
-    	} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
1023
-	    //$buffer = $Common->getData($hosts[$id]);
1024
-	    if ($globalDebug) echo 'Get Data...'."\n";
1025
-	    $buffer = $Common->getData($value['host']);
1026
-	    $all_data = json_decode($buffer,true);
1027
-	    if ($buffer != '' && is_array($all_data)) {
1019
+			//$last_exec['pirepsjson'] = time();
1020
+			$last_exec[$id]['last'] = time();
1021
+		//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
1022
+		} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
1023
+		//$buffer = $Common->getData($hosts[$id]);
1024
+		if ($globalDebug) echo 'Get Data...'."\n";
1025
+		$buffer = $Common->getData($value['host']);
1026
+		$all_data = json_decode($buffer,true);
1027
+		if ($buffer != '' && is_array($all_data)) {
1028 1028
 		$reset = 0;
1029 1029
 		foreach ($all_data as $line) {
1030
-	    	    $data = array();
1031
-	    	    //$data['id'] = $line['id']; // id not usable
1032
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1033
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1034
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1035
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1036
-	    	    $data['ident'] = $line['flightnum']; // ident
1037
-	    	    $data['altitude'] = $line['alt']; // altitude
1038
-	    	    $data['speed'] = $line['gs']; // speed
1039
-	    	    $data['heading'] = $line['heading']; // heading
1040
-	    	    $data['latitude'] = $line['lat']; // lat
1041
-	    	    $data['longitude'] = $line['lng']; // long
1042
-	    	    $data['verticalrate'] = ''; // verticale rate
1043
-	    	    $data['squawk'] = ''; // squawk
1044
-	    	    $data['emergency'] = ''; // emergency
1045
-	    	    //$data['datetime'] = $line['lastupdate'];
1046
-	    	    //$data['last_update'] = $line['lastupdate'];
1047
-	    	    if (isset($value['timezone'])) {
1048
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1049
-	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1050
-	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1051
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1052
-	    	    $data['departure_airport_icao'] = $line['depicao'];
1053
-	    	    $data['departure_airport_time'] = $line['deptime'];
1054
-	    	    $data['arrival_airport_icao'] = $line['arricao'];
1055
-    		    $data['arrival_airport_time'] = $line['arrtime'];
1056
-    		    $data['registration'] = $line['aircraft'];
1057
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1058
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1059
-		    if (isset($line['aircraftname'])) {
1030
+				$data = array();
1031
+				//$data['id'] = $line['id']; // id not usable
1032
+				if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1033
+				$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1034
+				if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1035
+				if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1036
+				$data['ident'] = $line['flightnum']; // ident
1037
+				$data['altitude'] = $line['alt']; // altitude
1038
+				$data['speed'] = $line['gs']; // speed
1039
+				$data['heading'] = $line['heading']; // heading
1040
+				$data['latitude'] = $line['lat']; // lat
1041
+				$data['longitude'] = $line['lng']; // long
1042
+				$data['verticalrate'] = ''; // verticale rate
1043
+				$data['squawk'] = ''; // squawk
1044
+				$data['emergency'] = ''; // emergency
1045
+				//$data['datetime'] = $line['lastupdate'];
1046
+				//$data['last_update'] = $line['lastupdate'];
1047
+				if (isset($value['timezone'])) {
1048
+				$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1049
+				$datetime->setTimeZone(new DateTimeZone('UTC'));
1050
+				$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1051
+				} else $data['datetime'] = date('Y-m-d H:i:s');
1052
+				$data['departure_airport_icao'] = $line['depicao'];
1053
+				$data['departure_airport_time'] = $line['deptime'];
1054
+				$data['arrival_airport_icao'] = $line['arricao'];
1055
+				$data['arrival_airport_time'] = $line['arrtime'];
1056
+				$data['registration'] = $line['aircraft'];
1057
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1058
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1059
+			if (isset($line['aircraftname'])) {
1060 1060
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1061 1061
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1062
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1063
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1064
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1065
-	    		else {
1066
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1067
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1068
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1069
-	    		}
1070
-	    	    }
1071
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1072
-    		    $data['id_source'] = $id_source;
1073
-	    	    $data['format_source'] = 'phpvmacars';
1074
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1075
-		    $SI->add($data);
1076
-		    unset($data);
1062
+				$aircraft_data = explode('-',$line['aircraftname']);
1063
+				if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1064
+				elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1065
+				else {
1066
+					$aircraft_data = explode(' ',$line['aircraftname']);
1067
+					if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1068
+					else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1069
+				}
1070
+				}
1071
+				if (isset($line['route'])) $data['waypoints'] = $line['route'];
1072
+				$data['id_source'] = $id_source;
1073
+				$data['format_source'] = 'phpvmacars';
1074
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1075
+			$SI->add($data);
1076
+			unset($data);
1077 1077
 		}
1078 1078
 		if ($globalDebug) echo 'No more data...'."\n";
1079 1079
 		unset($buffer);
1080 1080
 		unset($all_data);
1081
-	    }
1082
-    	    //$last_exec['phpvmacars'] = time();
1083
-    	    $last_exec[$id]['last'] = time();
1084
-    	} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
1085
-	    //$buffer = $Common->getData($hosts[$id]);
1086
-	    if ($globalDebug) echo 'Get Data...'."\n";
1087
-	    $buffer = $Common->getData($value['host']);
1088
-	    $all_data = json_decode($buffer,true);
1089
-	    if ($buffer != '' && is_array($all_data)) {
1081
+		}
1082
+			//$last_exec['phpvmacars'] = time();
1083
+			$last_exec[$id]['last'] = time();
1084
+		} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
1085
+		//$buffer = $Common->getData($hosts[$id]);
1086
+		if ($globalDebug) echo 'Get Data...'."\n";
1087
+		$buffer = $Common->getData($value['host']);
1088
+		$all_data = json_decode($buffer,true);
1089
+		if ($buffer != '' && is_array($all_data)) {
1090 1090
 		$reset = 0;
1091 1091
 		foreach ($all_data as $line) {
1092
-	    	    $data = array();
1093
-	    	    //$data['id'] = $line['id']; // id not usable
1094
-	    	    $data['id'] = trim($line['flight_id']);
1095
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1096
-	    	    $data['pilot_name'] = $line['pilot_name'];
1097
-	    	    $data['pilot_id'] = $line['pilot_id'];
1098
-	    	    $data['ident'] = trim($line['callsign']); // ident
1099
-	    	    $data['altitude'] = $line['altitude']; // altitude
1100
-	    	    $data['speed'] = $line['gs']; // speed
1101
-	    	    $data['heading'] = $line['heading']; // heading
1102
-	    	    $data['latitude'] = $line['latitude']; // lat
1103
-	    	    $data['longitude'] = $line['longitude']; // long
1104
-	    	    $data['verticalrate'] = ''; // verticale rate
1105
-	    	    $data['squawk'] = ''; // squawk
1106
-	    	    $data['emergency'] = ''; // emergency
1107
-	    	    //$data['datetime'] = $line['lastupdate'];
1108
-	    	    $data['last_update'] = $line['last_update'];
1109
-		    $data['datetime'] = date('Y-m-d H:i:s');
1110
-	    	    $data['departure_airport_icao'] = $line['departure'];
1111
-	    	    //$data['departure_airport_time'] = $line['departure_time'];
1112
-	    	    $data['arrival_airport_icao'] = $line['arrival'];
1113
-    		    //$data['arrival_airport_time'] = $line['arrival_time'];
1114
-    		    //$data['registration'] = $line['aircraft'];
1115
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1116
-	    	    $data['aircraft_icao'] = $line['plane_type'];
1117
-    		    $data['id_source'] = $id_source;
1118
-	    	    $data['format_source'] = 'vam';
1119
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1120
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1121
-		    $SI->add($data);
1122
-		    unset($data);
1092
+				$data = array();
1093
+				//$data['id'] = $line['id']; // id not usable
1094
+				$data['id'] = trim($line['flight_id']);
1095
+				$data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1096
+				$data['pilot_name'] = $line['pilot_name'];
1097
+				$data['pilot_id'] = $line['pilot_id'];
1098
+				$data['ident'] = trim($line['callsign']); // ident
1099
+				$data['altitude'] = $line['altitude']; // altitude
1100
+				$data['speed'] = $line['gs']; // speed
1101
+				$data['heading'] = $line['heading']; // heading
1102
+				$data['latitude'] = $line['latitude']; // lat
1103
+				$data['longitude'] = $line['longitude']; // long
1104
+				$data['verticalrate'] = ''; // verticale rate
1105
+				$data['squawk'] = ''; // squawk
1106
+				$data['emergency'] = ''; // emergency
1107
+				//$data['datetime'] = $line['lastupdate'];
1108
+				$data['last_update'] = $line['last_update'];
1109
+			$data['datetime'] = date('Y-m-d H:i:s');
1110
+				$data['departure_airport_icao'] = $line['departure'];
1111
+				//$data['departure_airport_time'] = $line['departure_time'];
1112
+				$data['arrival_airport_icao'] = $line['arrival'];
1113
+				//$data['arrival_airport_time'] = $line['arrival_time'];
1114
+				//$data['registration'] = $line['aircraft'];
1115
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1116
+				$data['aircraft_icao'] = $line['plane_type'];
1117
+				$data['id_source'] = $id_source;
1118
+				$data['format_source'] = 'vam';
1119
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1120
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1121
+			$SI->add($data);
1122
+			unset($data);
1123 1123
 		}
1124 1124
 		if ($globalDebug) echo 'No more data...'."\n";
1125 1125
 		unset($buffer);
1126 1126
 		unset($all_data);
1127
-	    }
1128
-    	    //$last_exec['phpvmacars'] = time();
1129
-    	    $last_exec[$id]['last'] = time();
1127
+		}
1128
+			//$last_exec['phpvmacars'] = time();
1129
+			$last_exec[$id]['last'] = time();
1130 1130
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
1131 1131
 	} elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'famaprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') {
1132
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1133
-    	    //$last_exec[$id]['last'] = time();
1132
+		if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1133
+			//$last_exec[$id]['last'] = time();
1134 1134
 
1135
-	    //$read = array( $sockets[$id] );
1136
-	    $read = $sockets;
1137
-	    $write = NULL;
1138
-	    $e = NULL;
1139
-	    $n = socket_select($read, $write, $e, $timeout);
1140
-	    if ($e != NULL) var_dump($e);
1141
-	    if ($n > 0) {
1135
+		//$read = array( $sockets[$id] );
1136
+		$read = $sockets;
1137
+		$write = NULL;
1138
+		$e = NULL;
1139
+		$n = socket_select($read, $write, $e, $timeout);
1140
+		if ($e != NULL) var_dump($e);
1141
+		if ($n > 0) {
1142 1142
 		$reset = 0;
1143 1143
 		foreach ($read as $nb => $r) {
1144
-		    //$value = $formats[$nb];
1145
-		    $format = $globalSources[$nb]['format'];
1146
-		    if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1144
+			//$value = $formats[$nb];
1145
+			$format = $globalSources[$nb]['format'];
1146
+			if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1147 1147
 			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1148
-		    } elseif ($format == 'vrstcp') {
1148
+			} elseif ($format == 'vrstcp') {
1149 1149
 			$buffer = @socket_read($r, 6000);
1150
-		    } else {
1150
+			} else {
1151 1151
 			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1152
-		    }
1153
-		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1154
-		    //echo $buffer."\n";
1155
-		    // lets play nice and handle signals such as ctrl-c/kill properly
1156
-		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1157
-		    $error = false;
1158
-		    //$SI::del();
1159
-		    if ($format == 'vrstcp') {
1152
+			}
1153
+			//$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1154
+			//echo $buffer."\n";
1155
+			// lets play nice and handle signals such as ctrl-c/kill properly
1156
+			//if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1157
+			$error = false;
1158
+			//$SI::del();
1159
+			if ($format == 'vrstcp') {
1160 1160
 			$buffer = explode('},{',$buffer);
1161
-		    } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1162
-		    // SBS format is CSV format
1163
-		    if ($buffer !== FALSE && $buffer != '') {
1161
+			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1162
+			// SBS format is CSV format
1163
+			if ($buffer !== FALSE && $buffer != '') {
1164 1164
 			$tt[$format] = 0;
1165 1165
 			if ($format == 'acarssbs3') {
1166
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1167
-			    $ACARS->add(trim($buffer));
1168
-			    $ACARS->deleteLiveAcarsData();
1166
+				if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1167
+				$ACARS->add(trim($buffer));
1168
+				$ACARS->deleteLiveAcarsData();
1169 1169
 			} elseif ($format == 'raw') {
1170
-			    // AVR format
1171
-			    $data = $SBS->parse($buffer);
1172
-			    if (is_array($data)) {
1170
+				// AVR format
1171
+				$data = $SBS->parse($buffer);
1172
+				if (is_array($data)) {
1173 1173
 				$data['datetime'] = date('Y-m-d H:i:s');
1174 1174
 				$data['format_source'] = 'raw';
1175 1175
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1176 1176
 				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1177 1177
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1178 1178
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1179
-			    }
1179
+				}
1180 1180
 			} elseif ($format == 'ais') {
1181
-			    $ais_data = $AIS->parse_line(trim($buffer));
1182
-			    $data = array();
1183
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1184
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1185
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1186
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1187
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1188
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1189
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1190
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1191
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1192
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1193
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1194
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1195
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1196
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1197
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1198
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1181
+				$ais_data = $AIS->parse_line(trim($buffer));
1182
+				$data = array();
1183
+				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1184
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1185
+				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1186
+				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1187
+				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1188
+				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1189
+				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1190
+				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1191
+				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1192
+				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1193
+				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1194
+				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1195
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1196
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1197
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1198
+				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1199 1199
 
1200
-			    if (isset($ais_data['timestamp'])) {
1200
+				if (isset($ais_data['timestamp'])) {
1201 1201
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1202
-			    } else {
1202
+				} else {
1203 1203
 				$data['datetime'] = date('Y-m-d H:i:s');
1204
-			    }
1205
-			    $data['format_source'] = 'aisnmea';
1206
-    			    $data['id_source'] = $id_source;
1207
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1208
-			    unset($data);
1209
-                        } elseif ($format == 'flightgearsp') {
1210
-                    	    //echo $buffer."\n";
1211
-                    	    if (strlen($buffer) > 5) {
1204
+				}
1205
+				$data['format_source'] = 'aisnmea';
1206
+					$data['id_source'] = $id_source;
1207
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1208
+				unset($data);
1209
+						} elseif ($format == 'flightgearsp') {
1210
+							//echo $buffer."\n";
1211
+							if (strlen($buffer) > 5) {
1212 1212
 				$line = explode(',',$buffer);
1213 1213
 				$data = array();
1214 1214
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
@@ -1225,38 +1225,38 @@  discard block
 block discarded – undo
1225 1225
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1226 1226
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1227 1227
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1228
-			    }
1229
-                        } elseif ($format == 'acars') {
1230
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1231
-			    $ACARS->add(trim($buffer));
1232
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1233
-			    $ACARS->deleteLiveAcarsData();
1228
+				}
1229
+						} elseif ($format == 'acars') {
1230
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1231
+				$ACARS->add(trim($buffer));
1232
+				socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1233
+				$ACARS->deleteLiveAcarsData();
1234 1234
 			} elseif ($format == 'flightgearmp') {
1235
-			    if (substr($buffer,0,1) != '#') {
1235
+				if (substr($buffer,0,1) != '#') {
1236 1236
 				$data = array();
1237 1237
 				//echo $buffer."\n";
1238 1238
 				$line = explode(' ',$buffer);
1239 1239
 				if (count($line) == 11) {
1240
-				    $userserver = explode('@',$line[0]);
1241
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1242
-				    $data['ident'] = $userserver[0];
1243
-				    $data['registration'] = $userserver[0];
1244
-				    $data['latitude'] = $line[4];
1245
-				    $data['longitude'] = $line[5];
1246
-				    $data['altitude'] = $line[6];
1247
-				    $data['datetime'] = date('Y-m-d H:i:s');
1248
-				    $aircraft_type = $line[10];
1249
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1250
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1251
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1252
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1240
+					$userserver = explode('@',$line[0]);
1241
+					$data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1242
+					$data['ident'] = $userserver[0];
1243
+					$data['registration'] = $userserver[0];
1244
+					$data['latitude'] = $line[4];
1245
+					$data['longitude'] = $line[5];
1246
+					$data['altitude'] = $line[6];
1247
+					$data['datetime'] = date('Y-m-d H:i:s');
1248
+					$aircraft_type = $line[10];
1249
+					$aircraft_type = preg_split(':/:',$aircraft_type);
1250
+					$data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1251
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1252
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1253
+				}
1253 1254
 				}
1254
-			    }
1255 1255
 			} elseif ($format == 'beast') {
1256
-			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1257
-			    die;
1256
+				echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1257
+				die;
1258 1258
 			} elseif ($format == 'vrstcp') {
1259
-			    foreach($buffer as $all_data) {
1259
+				foreach($buffer as $all_data) {
1260 1260
 				$line = json_decode('{'.$all_data.'}',true);
1261 1261
 				$data = array();
1262 1262
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
@@ -1276,148 +1276,148 @@  discard block
 block discarded – undo
1276 1276
 				*/
1277 1277
 				$data['datetime'] = date('Y-m-d H:i:s');
1278 1278
 				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1279
-		    		$data['format_source'] = 'vrstcp';
1279
+					$data['format_source'] = 'vrstcp';
1280 1280
 				$data['id_source'] = $id_source;
1281 1281
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1282 1282
 				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1283 1283
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1284 1284
 				unset($data);
1285
-			    }
1285
+				}
1286 1286
 			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
1287
-			    $line = explode("\t", $buffer);
1288
-			    for($k = 0; $k < count($line); $k=$k+2) {
1287
+				$line = explode("\t", $buffer);
1288
+				for($k = 0; $k < count($line); $k=$k+2) {
1289 1289
 				$key = $line[$k];
1290
-			        $lined[$key] = $line[$k+1];
1291
-			    }
1292
-    			    if (count($lined) > 3) {
1293
-    				$data['hex'] = $lined['hexid'];
1294
-    				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1295
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1296
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1297
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1298
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1299
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1300
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1301
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1302
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1303
-    				$data['id_source'] = $id_source;
1304
-    				$data['format_source'] = 'tsv';
1305
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1306
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1290
+					$lined[$key] = $line[$k+1];
1291
+				}
1292
+					if (count($lined) > 3) {
1293
+					$data['hex'] = $lined['hexid'];
1294
+					//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1295
+					$data['datetime'] = date('Y-m-d H:i:s');;
1296
+					if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1297
+					if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1298
+					if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1299
+					if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1300
+					if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1301
+					if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1302
+					if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1303
+					$data['id_source'] = $id_source;
1304
+					$data['format_source'] = 'tsv';
1305
+					if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1306
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1307 1307
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1308
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1309
-    				unset($lined);
1310
-    				unset($data);
1311
-    			    } else $error = true;
1308
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1309
+					unset($lined);
1310
+					unset($data);
1311
+					} else $error = true;
1312 1312
 			} elseif ($format == 'aprs' && $use_aprs) {
1313
-			    if ($aprs_connect == 0) {
1313
+				if ($aprs_connect == 0) {
1314 1314
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1315 1315
 				$aprs_connect = 1;
1316
-			    }
1316
+				}
1317 1317
 			    
1318
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1318
+				if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1319 1319
 				$aprs_last_tx = time();
1320 1320
 				$data_aprs = "# Keep alive";
1321 1321
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1322
-			    }
1322
+				}
1323 1323
 			    
1324
-			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1325
-			    //echo 'APRS data : '.$buffer."\n";
1326
-			    $buffer = str_replace('APRS <- ','',$buffer);
1327
-			    $buffer = str_replace('APRS -> ','',$buffer);
1328
-			    //echo $buffer."\n";
1329
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1324
+				//echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1325
+				//echo 'APRS data : '.$buffer."\n";
1326
+				$buffer = str_replace('APRS <- ','',$buffer);
1327
+				$buffer = str_replace('APRS -> ','',$buffer);
1328
+				//echo $buffer."\n";
1329
+				if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1330 1330
 				$line = $APRS->parse($buffer);
1331 1331
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1332 1332
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
1333
-				    $aprs_last_tx = time();
1334
-				    $data = array();
1335
-				    //print_r($line);
1336
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1337
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1338
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1339
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1340
-				    if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code'];
1341
-				    if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1342
-				    if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1343
-				    if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1344
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1345
-				    else $data['datetime'] = date('Y-m-d H:i:s');
1346
-				    //$data['datetime'] = date('Y-m-d H:i:s');
1347
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
1348
-				    $data['latitude'] = $line['latitude'];
1349
-				    $data['longitude'] = $line['longitude'];
1350
-				    //$data['verticalrate'] = $line[16];
1351
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
1352
-				    //else $data['speed'] = 0;
1353
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1354
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1355
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1356
-				    if (isset($line['heading'])) $data['heading'] = $line['heading'];
1357
-				    //else $data['heading'] = 0;
1358
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1359
-				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1360
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1361
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1362
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1363
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1364
-    				    $data['id_source'] = $id_source;
1365
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1366
-				    else $data['format_source'] = 'aprs';
1367
-				    $data['source_name'] = $line['source'];
1368
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1369
-				    else $data['source_type'] = 'flarm';
1370
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1371
-				    $currentdate = date('Y-m-d H:i:s');
1372
-				    $aprsdate = strtotime($data['datetime']);
1373
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1374
-				    // Accept data if time <= system time + 20s
1375
-				    //if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1376
-				    if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1333
+					$aprs_last_tx = time();
1334
+					$data = array();
1335
+					//print_r($line);
1336
+					if (isset($line['address'])) $data['hex'] = $line['address'];
1337
+					if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1338
+					if (isset($line['imo'])) $data['imo'] = $line['imo'];
1339
+					if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1340
+					if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code'];
1341
+					if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1342
+					if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1343
+					if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1344
+					if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1345
+					else $data['datetime'] = date('Y-m-d H:i:s');
1346
+					//$data['datetime'] = date('Y-m-d H:i:s');
1347
+					if (isset($line['ident'])) $data['ident'] = $line['ident'];
1348
+					$data['latitude'] = $line['latitude'];
1349
+					$data['longitude'] = $line['longitude'];
1350
+					//$data['verticalrate'] = $line[16];
1351
+					if (isset($line['speed'])) $data['speed'] = $line['speed'];
1352
+					//else $data['speed'] = 0;
1353
+					if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1354
+					if (isset($line['comment'])) $data['comment'] = $line['comment'];
1355
+					if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1356
+					if (isset($line['heading'])) $data['heading'] = $line['heading'];
1357
+					//else $data['heading'] = 0;
1358
+					if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1359
+					//if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1360
+					if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1361
+					elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1362
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1363
+					elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1364
+						$data['id_source'] = $id_source;
1365
+						if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1366
+					else $data['format_source'] = 'aprs';
1367
+					$data['source_name'] = $line['source'];
1368
+					if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1369
+					else $data['source_type'] = 'flarm';
1370
+						if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1371
+					$currentdate = date('Y-m-d H:i:s');
1372
+					$aprsdate = strtotime($data['datetime']);
1373
+					if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1374
+					// Accept data if time <= system time + 20s
1375
+					//if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1376
+					if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1377 1377
 					$send = $SI->add($data);
1378
-				    } elseif ($data['source_type'] == 'ais') {
1378
+					} elseif ($data['source_type'] == 'ais') {
1379 1379
 					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
1380
-				    } elseif (isset($line['stealth'])) {
1380
+					} elseif (isset($line['stealth'])) {
1381 1381
 					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1382 1382
 					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1383
-				    } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1384
-					    //$line['symbol'] == 'Balloon' ||
1385
-					    $line['symbol'] == 'Glider' || 
1386
-					    $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) {
1387
-					    if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL';
1388
-					    if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
1389
-					    $send = $SI->add($data);
1390
-				    } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1391
-					    $line['symbol'] == 'Yacht (Sail)' || 
1392
-					    $line['symbol'] == 'Ship (Power Boat)')) {
1393
-					    $send = $MI->add($data);
1394
-				    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1395
-					    $line['symbol'] == 'Car' || 
1396
-					    $line['symbol'] == 'Ambulance' || 
1397
-					    $line['symbol'] == 'Van' || 
1398
-					    $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || 
1399
-					    $line['symbol'] == 'Motorcycle' || 
1400
-					    $line['symbol'] == 'Tractor' || 
1401
-					    $line['symbol'] == 'Police' || 
1402
-					    $line['symbol'] == 'Bike' || 
1403
-					    $line['symbol'] == 'Jogger' || 
1404
-					    $line['symbol'] == 'Horse' || 
1405
-					    $line['symbol'] == 'Bus' || 
1406
-					    $line['symbol'] == 'Jeep' || 
1407
-					    $line['symbol'] == 'Recreational Vehicle' || 
1408
-					    $line['symbol'] == 'Yacht (Sail)' || 
1409
-					    $line['symbol'] == 'Ship (Power Boat)' || 
1410
-					    $line['symbol'] == 'Firetruck' || 
1411
-					    $line['symbol'] == 'Balloon' || $line['symbol'] == 'Glider' || 
1412
-					    $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter' || 
1413
-					    $line['symbol'] == 'SUV' ||
1414
-					    $line['symbol'] == 'Snowmobile' ||
1415
-					    $line['symbol'] == 'Mobile Satellite Station')) {
1416
-				    //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1383
+					} elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1384
+						//$line['symbol'] == 'Balloon' ||
1385
+						$line['symbol'] == 'Glider' || 
1386
+						$line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) {
1387
+						if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL';
1388
+						if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
1389
+						$send = $SI->add($data);
1390
+					} elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1391
+						$line['symbol'] == 'Yacht (Sail)' || 
1392
+						$line['symbol'] == 'Ship (Power Boat)')) {
1393
+						$send = $MI->add($data);
1394
+					} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1395
+						$line['symbol'] == 'Car' || 
1396
+						$line['symbol'] == 'Ambulance' || 
1397
+						$line['symbol'] == 'Van' || 
1398
+						$line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || 
1399
+						$line['symbol'] == 'Motorcycle' || 
1400
+						$line['symbol'] == 'Tractor' || 
1401
+						$line['symbol'] == 'Police' || 
1402
+						$line['symbol'] == 'Bike' || 
1403
+						$line['symbol'] == 'Jogger' || 
1404
+						$line['symbol'] == 'Horse' || 
1405
+						$line['symbol'] == 'Bus' || 
1406
+						$line['symbol'] == 'Jeep' || 
1407
+						$line['symbol'] == 'Recreational Vehicle' || 
1408
+						$line['symbol'] == 'Yacht (Sail)' || 
1409
+						$line['symbol'] == 'Ship (Power Boat)' || 
1410
+						$line['symbol'] == 'Firetruck' || 
1411
+						$line['symbol'] == 'Balloon' || $line['symbol'] == 'Glider' || 
1412
+						$line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter' || 
1413
+						$line['symbol'] == 'SUV' ||
1414
+						$line['symbol'] == 'Snowmobile' ||
1415
+						$line['symbol'] == 'Mobile Satellite Station')) {
1416
+					//} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1417 1417
 				//    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1418 1418
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1419 1419
 					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
1420
-				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1420
+					} elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1421 1421
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
1422 1422
 					$Source->deleteOldLocationByType('gs');
1423 1423
 					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
@@ -1425,7 +1425,7 @@  discard block
 block discarded – undo
1425 1425
 					} else {
1426 1426
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1427 1427
 					}
1428
-				    } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1428
+					} elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1429 1429
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1430 1430
 					if ($globalDebug) echo '# Weather Station added'."\n";
1431 1431
 					$Source->deleteOldLocationByType('wx');
@@ -1435,7 +1435,7 @@  discard block
 block discarded – undo
1435 1435
 					} else {
1436 1436
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1437 1437
 					}
1438
-				    } elseif (isset($line['symbol']) && $line['symbol'] == 'Lightning') {
1438
+					} elseif (isset($line['symbol']) && $line['symbol'] == 'Lightning') {
1439 1439
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1440 1440
 					if ($globalDebug) echo '☈ Lightning added'."\n";
1441 1441
 					$Source->deleteOldLocationByType('lightning');
@@ -1444,11 +1444,11 @@  discard block
 block discarded – undo
1444 1444
 					} else {
1445 1445
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1446 1446
 					}
1447
-				    } elseif ($globalDebug) {
1448
-				    	echo '/!\ Not added: '.$buffer."\n";
1449
-				    	print_r($line);
1450
-				    }
1451
-				    unset($data);
1447
+					} elseif ($globalDebug) {
1448
+						echo '/!\ Not added: '.$buffer."\n";
1449
+						print_r($line);
1450
+					}
1451
+					unset($data);
1452 1452
 				}
1453 1453
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1454 1454
 					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
@@ -1467,12 +1467,12 @@  discard block
 block discarded – undo
1467 1467
 				} elseif (!isset($globalSources[$nb]['last_weather_clean'])) {
1468 1468
 					$globalSources[$nb]['last_weather_clean'] = time();
1469 1469
 				}
1470
-			    }
1470
+				}
1471 1471
 			} else {
1472
-			    $line = explode(',', $buffer);
1473
-    			    if (count($line) > 20) {
1474
-    			    	$data['hex'] = $line[4];
1475
-    				/*
1472
+				$line = explode(',', $buffer);
1473
+					if (count($line) > 20) {
1474
+						$data['hex'] = $line[4];
1475
+					/*
1476 1476
     				$data['datetime'] = $line[6].' '.$line[7];
1477 1477
     					date_default_timezone_set($globalTimezone);
1478 1478
     					$datetime = new DateTime($data['datetime']);
@@ -1480,30 +1480,30 @@  discard block
 block discarded – undo
1480 1480
     					$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1481 1481
     					date_default_timezone_set('UTC');
1482 1482
     				*/
1483
-    				// Force datetime to current UTC datetime
1484
-    				date_default_timezone_set('UTC');
1485
-    				$data['datetime'] = date('Y-m-d H:i:s');
1486
-    				$data['ident'] = trim($line[10]);
1487
-    				$data['latitude'] = $line[14];
1488
-    				$data['longitude'] = $line[15];
1489
-    				$data['verticalrate'] = $line[16];
1490
-    				$data['emergency'] = $line[20];
1491
-    				$data['speed'] = $line[12];
1492
-    				$data['squawk'] = $line[17];
1493
-    				$data['altitude'] = $line[11];
1494
-    				$data['heading'] = $line[13];
1495
-    				$data['ground'] = $line[21];
1496
-    				$data['emergency'] = $line[19];
1497
-    				$data['format_source'] = 'sbs';
1483
+					// Force datetime to current UTC datetime
1484
+					date_default_timezone_set('UTC');
1485
+					$data['datetime'] = date('Y-m-d H:i:s');
1486
+					$data['ident'] = trim($line[10]);
1487
+					$data['latitude'] = $line[14];
1488
+					$data['longitude'] = $line[15];
1489
+					$data['verticalrate'] = $line[16];
1490
+					$data['emergency'] = $line[20];
1491
+					$data['speed'] = $line[12];
1492
+					$data['squawk'] = $line[17];
1493
+					$data['altitude'] = $line[11];
1494
+					$data['heading'] = $line[13];
1495
+					$data['ground'] = $line[21];
1496
+					$data['emergency'] = $line[19];
1497
+					$data['format_source'] = 'sbs';
1498 1498
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1499
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1499
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1500 1500
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1501
-    				$data['id_source'] = $id_source;
1502
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1503
-    				else $error = true;
1504
-    				unset($data);
1505
-    			    } else $error = true;
1506
-			    if ($error) {
1501
+					$data['id_source'] = $id_source;
1502
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1503
+					else $error = true;
1504
+					unset($data);
1505
+					} else $error = true;
1506
+				if ($error) {
1507 1507
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
1508 1508
 					if ($globalDebug) echo "Not a message. Ignoring... \n";
1509 1509
 				} else {
@@ -1519,13 +1519,13 @@  discard block
 block discarded – undo
1519 1519
 					connect_all($sourceer);
1520 1520
 					$sourceer = array();
1521 1521
 				}
1522
-			    }
1522
+				}
1523 1523
 			}
1524 1524
 			// Sleep for xxx microseconds
1525 1525
 			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1526
-		    } else {
1526
+			} else {
1527 1527
 			if ($format == 'flightgearmp') {
1528
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1528
+					if ($globalDebug) echo "Reconnect FlightGear MP...";
1529 1529
 				//@socket_close($r);
1530 1530
 				sleep($globalMinFetch);
1531 1531
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1534,9 +1534,9 @@  discard block
 block discarded – undo
1534 1534
 				break;
1535 1535
 				
1536 1536
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1537
-			    if (isset($tt[$format])) $tt[$format]++;
1538
-			    else $tt[$format] = 0;
1539
-			    if ($tt[$format] > 30) {
1537
+				if (isset($tt[$format])) $tt[$format]++;
1538
+				else $tt[$format] = 0;
1539
+				if ($tt[$format] > 30) {
1540 1540
 				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
1541 1541
 				//@socket_close($r);
1542 1542
 				sleep(2);
@@ -1547,23 +1547,23 @@  discard block
 block discarded – undo
1547 1547
 				//connect_all($globalSources);
1548 1548
 				$tt[$format]=0;
1549 1549
 				break;
1550
-			    }
1550
+				}
1551
+			}
1551 1552
 			}
1552
-		    }
1553 1553
 		}
1554
-	    } else {
1554
+		} else {
1555 1555
 		$error = socket_strerror(socket_last_error());
1556 1556
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1557 1557
 			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1558 1558
 			if (isset($globalDebug)) echo "Restarting...\n";
1559 1559
 			// Restart the script if possible
1560 1560
 			if (is_array($sockets)) {
1561
-			    if ($globalDebug) echo "Shutdown all sockets...";
1561
+				if ($globalDebug) echo "Shutdown all sockets...";
1562 1562
 			    
1563
-			    foreach ($sockets as $sock) {
1563
+				foreach ($sockets as $sock) {
1564 1564
 				@socket_shutdown($sock,2);
1565 1565
 				@socket_close($sock);
1566
-			    }
1566
+				}
1567 1567
 			    
1568 1568
 			}
1569 1569
 			if ($globalDebug) echo "Waiting...";
@@ -1578,15 +1578,15 @@  discard block
 block discarded – undo
1578 1578
 			if ($globalDebug) echo "Restart all connections...";
1579 1579
 			connect_all($globalSources);
1580 1580
 		}
1581
-	    }
1581
+		}
1582 1582
 	}
1583 1583
 	if ($globalDaemon === false) {
1584
-	    if ($globalDebug) echo 'Check all...'."\n";
1585
-	    if (isset($SI)) $SI->checkAll();
1586
-	    if (isset($TI)) $TI->checkAll();
1587
-	    if (isset($MI)) $MI->checkAll();
1584
+		if ($globalDebug) echo 'Check all...'."\n";
1585
+		if (isset($SI)) $SI->checkAll();
1586
+		if (isset($TI)) $TI->checkAll();
1587
+		if (isset($MI)) $MI->checkAll();
1588
+	}
1588 1589
 	}
1589
-    }
1590 1590
 }
1591 1591
 
1592 1592
 ?>
Please login to merge, or discard this patch.
index.php 1 patch
Indentation   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
     <?php }; if (isset($globalTracker) && $globalTracker) { ?><td><div id="ibxtracker"><h4><?php echo _("Trackers Detected"); ?></h4><br /><i class="fa fa-spinner fa-pulse fa-fw"></i></div></td><?php } ?>
46 46
 </tr></table></div>
47 47
 <?php
48
-    if ((!isset($_COOKIE['MapFormat']) && isset($globalMap3Ddefault) && $globalMap3Ddefault) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d')) {
48
+	if ((!isset($_COOKIE['MapFormat']) && isset($globalMap3Ddefault) && $globalMap3Ddefault) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d')) {
49 49
 
50 50
 ?>
51 51
 <script src="<?php echo $globalURL; ?>/js/map.3d.js.php"></script>
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 <script src="<?php echo $globalURL; ?>/js/map-marine.3d.js.php"></script>
66 66
 <?php
67 67
 	}
68
-    }
68
+	}
69 69
 ?>
70 70
 
71 71
 <div id="sidebar" class="sidebar collapsed">
@@ -76,34 +76,34 @@  discard block
 block discarded – undo
76 76
 	<li><a href="#" onclick="getUserLocation(); return false;" title="<?php echo _("Plot your Location"); ?>"><i class="fa fa-map-marker"></i></a></li>
77 77
 	<li><a href="#" onclick="getCompassDirection(); return false;" title="<?php echo _("Compass Mode"); ?>"><i class="fa fa-compass"></i></a></li>
78 78
 <?php
79
-    if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
79
+	if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
80 80
 	if (isset($globalArchive) && $globalArchive == TRUE) {
81 81
 ?>
82 82
 	<li><a href="#archive" role="tab" title="<?php echo _("Archive"); ?>"><i class="fa fa-archive"></i></a></li>
83 83
 <?php
84 84
 	}
85
-    }
85
+	}
86 86
 ?>
87 87
 	<li><a href="#home" role="tab" title="<?php echo _("Layers"); ?>"><i class="fa fa-map"></i></a></li>
88 88
 	<li><a href="#filters" role="tab" title="<?php echo _("Filters"); ?>"><i class="fa fa-filter"></i></a></li>
89 89
 	<li><a href="#settings" role="tab" title="<?php echo _("Settings"); ?>"><i class="fa fa-gears"></i></a></li>
90 90
 <?php
91
-    if (isset($globalMap3D) && $globalMap3D) {
91
+	if (isset($globalMap3D) && $globalMap3D) {
92 92
 	if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
93 93
 ?>
94 94
 	<li><a href="#" onclick="show3D(); return false;" role="tab" title="3D"><b>3D</b></a></li>
95 95
 <?php
96
-        } else {
97
-    	    if (isset($globalMapSatellites) && $globalMapSatellites) {
96
+		} else {
97
+			if (isset($globalMapSatellites) && $globalMapSatellites) {
98 98
 ?>
99 99
 	<li><a href="#satellites" role="tab" title="<?php echo _("Satellites"); ?>"><i class="satellite"></i></a></li>
100 100
 <?php
101
-	    }
101
+		}
102 102
 ?>
103 103
 	<li><a href="#" onclick="show2D(); return false;" role="tab" title="2D"><b>2D</b></a></li>
104 104
 <?php
105 105
 	}
106
-    }
106
+	}
107 107
 ?>
108 108
     </ul>
109 109
 
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 ?>
179 179
         </div>
180 180
 <?php
181
-    if (isset($globalArchive) && $globalArchive == TRUE) {
181
+	if (isset($globalArchive) && $globalArchive == TRUE) {
182 182
 ?>
183 183
         <div class="sidebar-pane" id="archive">
184 184
 	    <h1 class="sidebar-header"><?php echo _("Playback"); ?> <i>Bêta</i><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1>
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 	    </form>
239 239
 	</div>
240 240
 <?php
241
-    }
241
+	}
242 242
 ?>
243 243
         <div class="sidebar-pane" id="settings">
244 244
 	    <h1 class="sidebar-header"><?php echo _("Settings"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1>
@@ -249,56 +249,56 @@  discard block
 block discarded – undo
249 249
 			    <?php
250 250
 				if (!isset($_COOKIE['MapType']) || $_COOKIE['MapType'] == '') $MapType = $globalMapProvider;
251 251
 				else $MapType = $_COOKIE['MapType'];
252
-			    ?>
252
+				?>
253 253
 			    <?php
254 254
 				if (isset($globalBingMapKey) && $globalBingMapKey != '') {
255
-			    ?>
255
+				?>
256 256
 			    <option value="Bing-Aerial"<?php if ($MapType == 'Bing-Aerial') print ' selected'; ?>>Bing-Aerial</option>
257 257
 			    <option value="Bing-Hybrid"<?php if ($MapType == 'Bing-Hybrid') print ' selected'; ?>>Bing-Hybrid</option>
258 258
 			    <option value="Bing-Road"<?php if ($MapType == 'Bing-Road') print ' selected'; ?>>Bing-Road</option>
259 259
 			    <?php
260 260
 				}
261
-			    ?>
261
+				?>
262 262
 			    <?php
263
-			        if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
264
-			    ?>
263
+					if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
264
+				?>
265 265
 			    <?php
266
-				    if (isset($globalHereappId) && $globalHereappId != '' && isset($globalHereappCode) && $globalHereappCode != '') {
267
-			    ?>
266
+					if (isset($globalHereappId) && $globalHereappId != '' && isset($globalHereappCode) && $globalHereappCode != '') {
267
+				?>
268 268
 			    <option value="Here-Aerial"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Aerial</option>
269 269
 			    <option value="Here-Hybrid"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Hybrid</option>
270 270
 			    <option value="Here-Road"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Road</option>
271 271
 			    <?php
272
-				    }
273
-			    ?>
272
+					}
273
+				?>
274 274
 			    <?php
275
-				    if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '') {
276
-			    ?>
275
+					if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '') {
276
+				?>
277 277
 			    <option value="Google-Roadmap"<?php if ($MapType == 'Google-Roadmap') print ' selected'; ?>>Google Roadmap</option>
278 278
 			    <option value="Google-Satellite"<?php if ($MapType == 'Google-Satellite') print ' selected'; ?>>Google Satellite</option>
279 279
 			    <option value="Google-Hybrid"<?php if ($MapType == 'Google-Hybrid') print ' selected'; ?>>Google Hybrid</option>
280 280
 			    <option value="Google-Terrain"<?php if ($MapType == 'Google-Terrain') print ' selected'; ?>>Google Terrain</option>
281 281
 			    <?php
282
-				    }
283
-			    ?>
282
+					}
283
+				?>
284 284
 			    <?php
285
-				    if (isset($globalMapQuestKey) && $globalMapQuestKey != '') {
286
-			    ?>
285
+					if (isset($globalMapQuestKey) && $globalMapQuestKey != '') {
286
+				?>
287 287
 			    <option value="MapQuest-OSM"<?php if ($MapType == 'MapQuest-OSM') print ' selected'; ?>>MapQuest-OSM</option>
288 288
 			    <option value="MapQuest-Aerial"<?php if ($MapType == 'MapQuest-Aerial') print ' selected'; ?>>MapQuest-Aerial</option>
289 289
 			    <option value="MapQuest-Hybrid"<?php if ($MapType == 'MapQuest-Hybrid') print ' selected'; ?>>MapQuest-Hybrid</option>
290 290
 			    <?php
291
-				    }
292
-			    ?>
291
+					}
292
+				?>
293 293
 			    <option value="Yandex"<?php if ($MapType == 'Yandex') print ' selected'; ?>>Yandex</option>
294 294
 			    <?php
295 295
 				}
296
-			    ?>
296
+				?>
297 297
 			    <?php
298
-				    if (isset($globalMapboxToken) && $globalMapboxToken != '') {
298
+					if (isset($globalMapboxToken) && $globalMapboxToken != '') {
299 299
 					if (!isset($_COOKIE['MapTypeId'])) $MapBoxId = 'default';
300 300
 					else $MapBoxId = $_COOKIE['MapTypeId'];
301
-			    ?>
301
+				?>
302 302
 			    <option value="Mapbox-default"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'default') print ' selected'; ?>>Mapbox default</option>
303 303
 			    <option value="Mapbox-mapbox.streets"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets') print ' selected'; ?>>Mapbox streets</option>
304 304
 			    <option value="Mapbox-mapbox.light"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.light') print ' selected'; ?>>Mapbox light</option>
@@ -312,13 +312,13 @@  discard block
 block discarded – undo
312 312
 			    <option value="Mapbox-mapbox.pirates"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pirates') print ' selected'; ?>>Mapbox pirates</option>
313 313
 			    <option value="Mapbox-mapbox.emerald"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.emerald') print ' selected'; ?>>Mapbox emerald</option>
314 314
 			    <?php
315
-				    }
316
-			    ?>
315
+					}
316
+				?>
317 317
 			    <option value="OpenStreetMap"<?php if ($MapType == 'OpenStreetMap') print ' selected'; ?>>OpenStreetMap</option>
318 318
 			</select>
319 319
 		    </li>
320 320
 <?php
321
-    if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
321
+	if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
322 322
 ?>
323 323
 		    <li><?php echo _("Type of Terrain:"); ?>
324 324
 			<select  class="selectpicker" onchange="terrainType(this);">
@@ -329,10 +329,10 @@  discard block
 block discarded – undo
329 329
 			</select>
330 330
 		    </li>
331 331
 <?php
332
-    }
332
+	}
333 333
 ?>
334 334
 <?php
335
-    if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
335
+	if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
336 336
 ?>
337 337
 		    
338 338
 		    <li><div class="checkbox"><label><input type="checkbox" name="flightpopup" value="1" onclick="clickFlightPopup(this)" <?php if (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true') print 'checked'; ?> ><?php echo _("Display flight info as popup"); ?></label></div></li>
@@ -341,87 +341,87 @@  discard block
 block discarded – undo
341 341
 		    <li><div class="checkbox"><label><input type="checkbox" name="flightremainingroute" value="1" onclick="clickFlightRemainingRoute(this)" <?php if ((isset($_COOKIE['MapRemainingRoute']) && $_COOKIE['MapRemainingRoute'] == 'true') || !isset($_COOKIE['MapRemainingRoute']) || (isset($globalMapRemainingRoute) && $globalMapRemainingRoute)) print 'checked'; ?> ><?php echo _("Display flight remaining route on click"); ?></label></div></li>
342 342
 		    <li><div class="checkbox"><label><input type="checkbox" name="flightestimation" value="1" onclick="clickFlightEstimation(this)" <?php if ((isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'true') || (!isset($_COOKIE['flightestimation']) && !isset($globalMapEstimation)) || (!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation)) print 'checked'; ?> ><?php echo _("Planes animate between updates"); ?></label></div></li>
343 343
 <?php
344
-    }
344
+	}
345 345
 ?>
346 346
 		    <li><div class="checkbox"><label><input type="checkbox" name="displayairports" value="1" onclick="clickDisplayAirports(this)" <?php if (isset($_COOKIE['displayairports']) && $_COOKIE['displayairports'] == 'true' || !isset($_COOKIE['displayairports'])) print 'checked'; ?> ><?php echo _("Display airports on map"); ?></label></div></li>
347 347
 		    <li><div class="checkbox"><label><input type="checkbox" name="displaygroundstation" value="1" onclick="clickDisplayGroundStation(this)" <?php if ((isset($_COOKIE['show_GroundStation']) && $_COOKIE['show_GroundStation'] == 'true') || (!isset($_COOKIE['show_GroundStation']) && (!isset($globalMapGroundStation) || $globalMapGroundStation === TRUE))) print 'checked'; ?> ><?php echo _("Display ground station on map"); ?></label></div></li>
348 348
 <?php
349
-    if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
349
+	if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
350 350
 ?>
351 351
 		    <li><div class="checkbox"><label><input type="checkbox" name="displayminimap" value="1" onclick="clickDisplayMinimap(this)" <?php if (!isset($_COOKIE['displayminimap']) || (isset($_COOKIE['displayminimap']) && $_COOKIE['displayminimap'] == 'true')) print 'checked'; ?> ><?php echo _("Show mini-map"); ?></label></div></li>
352 352
 <?php
353
-    }
354
-    if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) {
353
+	}
354
+	if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) {
355 355
 ?>
356 356
 		    <li><div class="checkbox"><label><input type="checkbox" name="displaysanta" value="1" onclick="clickSanta(this)"><i class="fa fa-snowflake-o" aria-hidden="true"></i> <?php echo _("Show Santa Claus now"); ?> <i class="fa fa-snowflake-o" aria-hidden="true"></i></label></div></li>
357 357
 <?php
358
-    }
358
+	}
359 359
 ?>
360 360
 
361 361
 		    <?php
362 362
 			if (function_exists('array_column')) {
363
-			    if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) {
364
-		    ?>
363
+				if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) {
364
+			?>
365 365
 		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li>
366 366
 		    <?php
367
-			    }
367
+				}
368 368
 			} elseif (isset($globalSources)) {
369
-			    $dispolar = false;
370
-			    foreach ($globalSources as $testsource) {
371
-			        if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true;
372
-			    }
373
-			    if ($dispolar) {
374
-		    ?>
369
+				$dispolar = false;
370
+				foreach ($globalSources as $testsource) {
371
+					if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true;
372
+				}
373
+				if ($dispolar) {
374
+			?>
375 375
 		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li>
376 376
 		    <?php
377
-			    }
378
-		        }
379
-		    ?>
377
+				}
378
+				}
379
+			?>
380 380
 <?php
381
-    if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
381
+	if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
382 382
 ?>
383 383
 
384 384
 		    <?php
385 385
 			if (!isset($globalAircraft) || $globalAircraft === TRUE) {
386
-		    	    if (extension_loaded('gd') && function_exists('gd_info')) {
387
-		    ?>
386
+					if (extension_loaded('gd') && function_exists('gd_info')) {
387
+			?>
388 388
 		    <li><input type="checkbox" name="aircraftcoloraltitude" value="1" onclick="iconColorAltitude(this)" <?php if (isset($_COOKIE['IconColorAltitude']) && $_COOKIE['IconColorAltitude'] == 'true') print 'checked'; ?> ><?php echo _("Aircraft icon color based on altitude"); ?></li>
389 389
 		    <?php 
390 390
 				if (!isset($_COOKIE['IconColorAltitude']) || $_COOKIE['IconColorAltitude'] == 'false') {
391
-		    ?>
391
+			?>
392 392
 		    <li><?php echo _("Aircraft icon color:"); ?>
393 393
 			<input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) print $_COOKIE['IconColor']; elseif (isset($globalAircraftIconColor)) print $globalAircraftIconColor; else print '1a3151'; ?>">
394 394
 		    </li>
395 395
 		    <?php
396 396
 				}
397
-			    }
398
-		        }
399
-		    ?>
397
+				}
398
+				}
399
+			?>
400 400
 		    <?php
401 401
 			if (isset($globalMarine) && $globalMarine === TRUE) {
402
-			    if (extension_loaded('gd') && function_exists('gd_info')) {
403
-		    ?>
402
+				if (extension_loaded('gd') && function_exists('gd_info')) {
403
+			?>
404 404
 		    <li><?php echo _("Marine icon color:"); ?>
405 405
 			<input type="color" name="marinecolor" id="html5colorpicker" onchange="MarineiconColor(marinecolor.value);" value="#<?php if (isset($_COOKIE['MarineIconColor'])) print $_COOKIE['MarineIconColor']; elseif (isset($globalMarineIconColor)) print $globalMarineIconColor; else print '1a3151'; ?>">
406 406
 		    </li>
407 407
 		    <?php
408
-			    }
409
-		        }
410
-		    ?>
408
+				}
409
+				}
410
+			?>
411 411
 		    <?php
412 412
 			if (isset($globalTracker) && $globalTracker === TRUE) {
413
-			    if (extension_loaded('gd') && function_exists('gd_info')) {
414
-		    ?>
413
+				if (extension_loaded('gd') && function_exists('gd_info')) {
414
+			?>
415 415
 		    <li><?php echo _("Tracker icon color:"); ?>
416 416
 			<input type="color" name="trackercolor" id="html5colorpicker" onchange="TrackericonColor(trackercolor.value);" value="#<?php if (isset($_COOKIE['TrackerIconColor'])) print $_COOKIE['TrackerIconColor']; elseif (isset($globalTrackerIconColor)) print $globalTrackerIconColor; else print '1a3151'; ?>">
417 417
 		    </li>
418 418
 		    <?php
419
-			    }
420
-		        }
421
-		    ?>
419
+				}
420
+				}
421
+			?>
422 422
 		    <?php
423 423
 			if (!isset($globalAircraft) || $globalAircraft === TRUE) {
424
-		    ?>
424
+			?>
425 425
 		    <li><?php echo _("Show airport icon at zoom level:"); ?>
426 426
 			<div class="range">
427 427
 			    <input type="range" min="0" max="19" step="1" name="airportzoom" onchange="range.value=value;airportDisplayZoom(airportzoom.value);" value="<?php if (isset($_COOKIE['AirportZoom'])) print $_COOKIE['AirportZoom']; elseif (isset($globalAirportZoom)) print $globalAirportZoom; else print '7'; ?>">
@@ -430,9 +430,9 @@  discard block
 block discarded – undo
430 430
 		    </li>
431 431
 		    <?php
432 432
 			}
433
-		    ?>
433
+			?>
434 434
 <?php
435
-    } elseif (isset($_COOKIE['MapFormat']) || $_COOKIE['MapFOrmat'] == '3d') {
435
+	} elseif (isset($_COOKIE['MapFormat']) || $_COOKIE['MapFOrmat'] == '3d') {
436 436
 ?>
437 437
 <?php
438 438
 	if (!isset($globalAircraft) || $globalAircraft === TRUE) {
@@ -463,7 +463,7 @@  discard block
 block discarded – undo
463 463
 		    </li>
464 464
 <?php
465 465
 	}
466
-    }
466
+	}
467 467
 ?>
468 468
 		    <li><?php echo _("Distance unit:"); ?>
469 469
 			<select class="selectpicker" onchange="unitdistance(this);">
@@ -496,19 +496,19 @@  discard block
 block discarded – undo
496 496
 		    <ul>
497 497
 		    <?php
498 498
 			if (!isset($globalAircraft) || $globalAircraft) {
499
-		    ?>
499
+			?>
500 500
 		    <?php
501 501
 			if (((isset($globalVATSIM) && $globalVATSIM) || isset($globalIVAO) && $globalIVAO || isset($globalphpVMS) && $globalphpVMS) && (!isset($globalMapVAchoose) || $globalMapVAchoose)) {
502
-		    ?>
502
+			?>
503 503
 			<?php if (isset($globalVATSIM) && $globalVATSIM) { ?><li><input type="checkbox" name="vatsim" value="1" onclick="clickVATSIM(this)" <?php if ((isset($_COOKIE['ShowVATSIM']) && $_COOKIE['ShowVATSIM'] == 'true') || !isset($_COOKIE['ShowVATSIM'])) print 'checked'; ?> ><?php echo _("Display VATSIM data"); ?></li><?php } ?>
504 504
 			<?php if (isset($globalIVAO) && $globalIVAO) { ?><li><input type="checkbox" name="ivao" value="1" onclick="clickIVAO(this)" <?php if ((isset($_COOKIE['ShowIVAO']) && $_COOKIE['ShowIVAO'] == 'true') || !isset($_COOKIE['ShowIVAO'])) print 'checked'; ?> ><?php echo _("Display IVAO data"); ?></li><?php } ?>
505 505
 			<?php if (isset($globalphpVMS) && $globalphpVMS) { ?><li><input type="checkbox" name="phpvms" value="1" onclick="clickphpVMS(this)" <?php if ((isset($_COOKIE['ShowVMS']) && $_COOKIE['ShowVMS'] == 'true') || !isset($_COOKIE['ShowVMS'])) print 'checked'; ?> ><?php echo _("Display phpVMS data"); ?></li><?php } ?>
506 506
 		    <?php
507 507
 			}
508
-		    ?>
508
+			?>
509 509
 		    <?php
510 510
 			if (!(isset($globalVA) && $globalVA) && !(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS) && isset($globalSBS1) && $globalSBS1 && isset($globalAPRS) && $globalAPRS && (!isset($globalMapchoose) || $globalMapchoose)) {
511
-		    ?>
511
+			?>
512 512
 			<?php if (isset($globalSBS1) && $globalSBS1) { ?>
513 513
 			    <li><div class="checkbox"><label><input type="checkbox" name="sbs" value="1" onclick="clickSBS1(this)" <?php if ((isset($_COOKIE['ShowSBS1']) && $_COOKIE['ShowSBS1'] == 'true') || !isset($_COOKIE['ShowSBS1'])) print 'checked'; ?> ><?php echo _("Display ADS-B data"); ?></label></div></li>
514 514
 			<?php } ?>
@@ -517,7 +517,7 @@  discard block
 block discarded – undo
517 517
 			<?php } ?>
518 518
 		    <?php
519 519
 			}
520
-		    ?>
520
+			?>
521 521
 		    <li><?php echo _("Display airlines:"); ?>
522 522
 		    <br/>
523 523
 			<select class="selectpicker" multiple onchange="airlines(this);" id="display_airlines">
@@ -537,14 +537,14 @@  discard block
 block discarded – undo
537 537
 						echo '<option value="'.$airline['airline_icao'].'">'.$airline_name.'</option>';
538 538
 					}
539 539
 				}
540
-			    ?>
540
+				?>
541 541
 			</select>
542 542
 		    </li>
543 543
 		    <?php
544 544
 			$Spotter = new Spotter();
545 545
 			$allalliancenames = $Spotter->getAllAllianceNames();
546 546
 			if (!empty($allalliancenames)) {
547
-		    ?>
547
+			?>
548 548
 		    <li><?php echo _("Display alliance:"); ?>
549 549
 		    <br/>
550 550
 			<select class="selectpicker" onchange="alliance(this);" id="display_alliance">
@@ -558,18 +558,18 @@  discard block
 block discarded – undo
558 558
 						echo '<option value="'.$alliance_name.'">'.$alliance_name.'</option>';
559 559
 					}
560 560
 				}
561
-			    ?>
561
+				?>
562 562
 			</select>
563 563
 		    </li>
564 564
 		    <?php
565 565
 			}
566
-		    ?>
566
+			?>
567 567
 		    <?php
568 568
 			}
569
-		    ?>
569
+			?>
570 570
 		    <?php
571 571
 			if (isset($globalAPRS) && $globalAPRS) {
572
-		    ?>
572
+			?>
573 573
 		    <li><?php echo _("Display APRS sources name:"); ?>
574 574
 			<select class="selectpicker" multiple onchange="sources(this);">
575 575
 			    <?php
@@ -581,18 +581,18 @@  discard block
 block discarded – undo
581 581
 						echo '<option value="'.$source['source_name'].'">'.$source['source_name'].'</option>';
582 582
 					}
583 583
 				}
584
-			    ?>
584
+				?>
585 585
 			</select>
586 586
 		    </li>
587 587
 		    <?php
588 588
 			}
589
-		    ?>
589
+			?>
590 590
 		    <?php
591 591
 			if (!isset($globalAircraft) && $globalAircraft) {
592
-		    ?>
592
+			?>
593 593
 		    <?php
594 594
 			if (!(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS)) {
595
-		    ?>
595
+			?>
596 596
 		    <li><?php echo _("Display airlines of type:"); ?><br/>
597 597
 			<select class="selectpicker" onchange="airlinestype(this);">
598 598
 			    <option value="all"<?php if (!isset($_COOKIE['filter_airlinestype']) || $_COOKIE['filter_airlinestype'] == 'all' || $_COOKIE['filter_airlinestype'] == '') echo ' selected'; ?>><?php echo _("All"); ?></option>
@@ -603,14 +603,14 @@  discard block
 block discarded – undo
603 603
 		    </li>
604 604
 		    <?php
605 605
 			}
606
-		    ?>
606
+			?>
607 607
 		    <li>
608 608
 			<?php echo _("Display flight with ident:"); ?>
609 609
 			<input type="text" name="identfilter" onchange="identfilter();" id="identfilter" value="<?php if (isset($_COOKIE['filter_ident'])) print $_COOKIE['filter_ident']; ?>" />
610 610
 		    </li>
611 611
 		    <?php
612 612
 			}
613
-		    ?>
613
+			?>
614 614
 		</ul>
615 615
 	    </form>
616 616
 	    <form method="post">
@@ -619,7 +619,7 @@  discard block
 block discarded – undo
619 619
 	    </form>
620 620
     	</div>
621 621
 <?php
622
-    if (isset($globalMapSatellites) && $globalMapSatellites && isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
622
+	if (isset($globalMapSatellites) && $globalMapSatellites && isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
623 623
 ?>
624 624
         <div class="sidebar-pane" id="satellites">
625 625
 	    <h1 class="sidebar-header"><?php echo _("Satellites"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1>
@@ -659,14 +659,14 @@  discard block
 block discarded – undo
659 659
 						print '<option value="'.$type['tle_type'].'">'.$type_name.'</option>';
660 660
 					}
661 661
 				}
662
-			    ?>
662
+				?>
663 663
 			</select>
664 664
 		    </li>
665 665
 		</ul>
666 666
 	    </form>
667 667
 	</div>
668 668
 <?php
669
-    }
669
+	}
670 670
 ?>
671 671
     </div>
672 672
 </div>
Please login to merge, or discard this patch.
getImages.php 1 patch
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -4,31 +4,31 @@  discard block
 block discarded – undo
4 4
 	$hex = str_replace("#", "", $hex);
5 5
 	$color = array();
6 6
 	if (strlen($hex) == 3) {
7
-	    $color['r'] = hexdec(substr($hex, 0, 1) . substr($hex,0,1));
8
-	    $color['g'] = hexdec(substr($hex, 1, 1) . substr($hex,1,1));
9
-	    $color['b'] = hexdec(substr($hex, 2, 1) . substr($hex,2,1));
7
+		$color['r'] = hexdec(substr($hex, 0, 1) . substr($hex,0,1));
8
+		$color['g'] = hexdec(substr($hex, 1, 1) . substr($hex,1,1));
9
+		$color['b'] = hexdec(substr($hex, 2, 1) . substr($hex,2,1));
10 10
 	} else if (strlen($hex) == 6) {
11
-	    $color['r'] = hexdec(substr($hex, 0, 2));
12
-	    $color['g'] = hexdec(substr($hex, 2, 2));
13
-	    $color['b'] = hexdec(substr($hex, 4, 2));
11
+		$color['r'] = hexdec(substr($hex, 0, 2));
12
+		$color['g'] = hexdec(substr($hex, 2, 2));
13
+		$color['b'] = hexdec(substr($hex, 4, 2));
14 14
 	}
15 15
 	return $color;
16 16
 }
17 17
 
18 18
 
19 19
 if (!isset($_GET['color']) || $_GET['color'] == '' || !preg_match('/^([a-fA-F0-9]){3}(([a-fA-F0-9]){3})?\b/',$_GET['color'])) { 
20
-    exit(0);
20
+	exit(0);
21 21
 }
22 22
 $color = $_GET['color'];
23 23
 if (!isset($_GET['filename']) || !preg_match('/^[a-z0-9-_]+\.png$/', strtolower($_GET['filename']))) {
24
-    echo "Incorrect filename";
25
-    exit(0);
24
+	echo "Incorrect filename";
25
+	exit(0);
26 26
 }
27 27
 $filename = $_GET['filename'];
28 28
 if (file_exists(dirname(__FILE__).DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR.$color.'-'.$filename)) {
29
-    header('Content-type: image/png');
30
-    readfile(dirname(__FILE__).DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR.$color.'-'.$filename);
31
-    exit(0);
29
+	header('Content-type: image/png');
30
+	readfile(dirname(__FILE__).DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR.$color.'-'.$filename);
31
+	exit(0);
32 32
 }
33 33
 if (isset($_GET['tracker'])) {
34 34
 	$original = dirname(__FILE__).DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.'vehicules'.DIRECTORY_SEPARATOR.'color'.DIRECTORY_SEPARATOR.$filename;
@@ -42,66 +42,66 @@  discard block
 block discarded – undo
42 42
 	$original = dirname(__FILE__).DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.'aircrafts'.DIRECTORY_SEPARATOR.'new'.DIRECTORY_SEPARATOR.$filename;
43 43
 }
44 44
 if (!file_exists($original)) {
45
-    echo "File not found";
45
+	echo "File not found";
46 46
 }
47 47
 
48 48
 if (extension_loaded('gd') && function_exists('gd_info')) {
49
-    $image = imagecreatefrompng($original);
50
-    $index = imagecolorexact($image,26,49,81);
51
-    if ($index < 0) {
49
+	$image = imagecreatefrompng($original);
50
+	$index = imagecolorexact($image,26,49,81);
51
+	if ($index < 0) {
52 52
 	$index = imagecolorexact($image,25,49,79);
53
-    }
54
-    if ($index < 0) {
53
+	}
54
+	if ($index < 0) {
55 55
 	$index = imagecolorexact($image,0,0,0);
56
-    }
57
-    $c = hexToRGB($color);
58
-    imagecolorset($image,$index,$c['r'],$c['g'],$c['b']);
56
+	}
57
+	$c = hexToRGB($color);
58
+	imagecolorset($image,$index,$c['r'],$c['g'],$c['b']);
59 59
  /*
60 60
     $ig = imagecolorat($image, 0, 0);
61 61
     imagecolortransparent($image, $ig);
62 62
    */
63 63
 
64
-    header('Content-type: image/png');
65
-    if (isset($_GET['resize']) && function_exists('imagecopyresampled')) {
64
+	header('Content-type: image/png');
65
+	if (isset($_GET['resize']) && function_exists('imagecopyresampled')) {
66 66
 	$resize = filter_input(INPUT_GET,'resize',FILTER_SANITIZE_NUMBER_INT);
67 67
 	$newimg = imagecreatetruecolor($resize,$resize);
68
-        imagealphablending($newimg, false);
68
+		imagealphablending($newimg, false);
69 69
 	imagesavealpha($newimg, true);
70 70
 	imagecopyresampled($newimg,$image,0,0,0,0,15,15,imagesx($image),imagesy($image));
71 71
 	if (isset($_GET['heading'])) {
72
-    	    $heading = filter_input(INPUT_GET,'heading',FILTER_SANITIZE_NUMBER_INT);
73
-    	    $rotation = imagerotate($newimg,$heading,imageColorAllocateAlpha($newimg,0,0,0,127));
74
-    	    imagealphablending($rotation, false);
75
-	    imagesavealpha($rotation, true);
76
-    	    imagepng($rotation);
77
-    	    imagedestroy($newimg);
78
-    	    imagedestroy($image);
79
-    	    imagedestroy($rotation);
72
+			$heading = filter_input(INPUT_GET,'heading',FILTER_SANITIZE_NUMBER_INT);
73
+			$rotation = imagerotate($newimg,$heading,imageColorAllocateAlpha($newimg,0,0,0,127));
74
+			imagealphablending($rotation, false);
75
+		imagesavealpha($rotation, true);
76
+			imagepng($rotation);
77
+			imagedestroy($newimg);
78
+			imagedestroy($image);
79
+			imagedestroy($rotation);
80 80
 	
81 81
 	} else {
82
-    	    imagepng($newimg);
83
-    	    imagedestroy($newimg);
84
-    	    imagedestroy($image);
85
-        }
86
-    } else {
82
+			imagepng($newimg);
83
+			imagedestroy($newimg);
84
+			imagedestroy($image);
85
+		}
86
+	} else {
87 87
 	imagealphablending($image, false);
88
-        imagesavealpha($image, true);
88
+		imagesavealpha($image, true);
89 89
 	imagepng($image);
90 90
 	imagepng($image);
91 91
 	if (is_writable('cache')) {
92
-    	    imagepng($image,dirname(__FILE__).DIRECTORY_SEPARATOR.'cache/'.$color.'-'.$filename);
92
+			imagepng($image,dirname(__FILE__).DIRECTORY_SEPARATOR.'cache/'.$color.'-'.$filename);
93
+	}
94
+		imagedestroy($image);
93 95
 	}
94
-        imagedestroy($image);
95
-    }
96 96
 } else {
97
-    header('Content-type: image/png');
98
-    if (isset($_GET['tracker'])) {
99
-        readfile(dirname(__FILE__).DIRECTORY_SEPARATOR.'images/vehicules/'.$filename);
100
-    } elseif (isset($_GET['marine'])) {
101
-        readfile(dirname(__FILE__).DIRECTORY_SEPARATOR.'images/vehicules/'.$filename);
102
-    } else {
103
-        if ($color == 'FF0000') readfile(dirname(__FILE__).DIRECTORY_SEPARATOR.'images/aircrafts/selected/'.$filename);
97
+	header('Content-type: image/png');
98
+	if (isset($_GET['tracker'])) {
99
+		readfile(dirname(__FILE__).DIRECTORY_SEPARATOR.'images/vehicules/'.$filename);
100
+	} elseif (isset($_GET['marine'])) {
101
+		readfile(dirname(__FILE__).DIRECTORY_SEPARATOR.'images/vehicules/'.$filename);
102
+	} else {
103
+		if ($color == 'FF0000') readfile(dirname(__FILE__).DIRECTORY_SEPARATOR.'images/aircrafts/selected/'.$filename);
104 104
 	else readfile(dirname(__FILE__).DIRECTORY_SEPARATOR.'images/aircrafts/'.$filename);
105
-    }
105
+	}
106 106
 }
107 107
 ?>
108 108
\ No newline at end of file
Please login to merge, or discard this patch.