Completed
Push — master ( aba7aa...4c247d )
by Yannick
07:22
created
require/class.SpotterLive.php 1 patch
Indentation   +206 added lines, -206 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();
@@ -128,11 +128,11 @@  discard block
 block discarded – undo
128 128
 	}
129 129
 
130 130
 	/**
131
-	* Gets all the spotter information based on the latest data entry
132
-	*
133
-	* @return Array the spotter information
134
-	*
135
-	*/
131
+	 * Gets all the spotter information based on the latest data entry
132
+	 *
133
+	 * @return Array the spotter information
134
+	 *
135
+	 */
136 136
 	public function getLiveSpotterData($limit = '', $sort = '', $filter = array())
137 137
 	{
138 138
 		global $globalDBdriver, $globalLiveInterval;
@@ -174,11 +174,11 @@  discard block
 block discarded – undo
174 174
 	}
175 175
 
176 176
 	/**
177
-	* Gets Minimal Live Spotter data
178
-	*
179
-	* @return Array the spotter information
180
-	*
181
-	*/
177
+	 * Gets Minimal Live Spotter data
178
+	 *
179
+	 * @return Array the spotter information
180
+	 *
181
+	 */
182 182
 	public function getMinLiveSpotterData($filter = array())
183 183
 	{
184 184
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
@@ -215,11 +215,11 @@  discard block
 block discarded – undo
215 215
 	}
216 216
 
217 217
 	/**
218
-	* Gets Minimal Live Spotter data since xx seconds
219
-	*
220
-	* @return Array the spotter information
221
-	*
222
-	*/
218
+	 * Gets Minimal Live Spotter data since xx seconds
219
+	 *
220
+	 * @return Array the spotter information
221
+	 *
222
+	 */
223 223
 	public function getMinLastLiveSpotterData($filter = array())
224 224
 	{
225 225
 		global $globalDBdriver, $globalLiveInterval;
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 			$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
238 238
 			FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' 
239 239
 			ORDER BY spotter_live.flightaware_id, spotter_live.date";
240
-                } else {
240
+				} else {
241 241
 /*
242 242
 			$query  = "SELECT a.aircraft_shadow, a.engine_type, a.engine_count, a.wake_category, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
243 243
 			FROM spotter_live LEFT JOIN (SELECT aircraft_shadow,engine_type, engine_count, wake_category, icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' 
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 //			echo $query;
250 250
 		}
251 251
 
252
-    		try {
252
+			try {
253 253
 			$sth = $this->db->prepare($query);
254 254
 			$sth->execute();
255 255
 		} catch(PDOException $e) {
@@ -261,11 +261,11 @@  discard block
 block discarded – undo
261 261
 	}
262 262
 
263 263
 	/**
264
-	* Gets number of latest data entry
265
-	*
266
-	* @return String number of entry
267
-	*
268
-	*/
264
+	 * Gets number of latest data entry
265
+	 *
266
+	 * @return String number of entry
267
+	 *
268
+	 */
269 269
 	public function getLiveSpotterCount($filter = array())
270 270
 	{
271 271
 		global $globalDBdriver, $globalLiveInterval;
@@ -292,11 +292,11 @@  discard block
 block discarded – undo
292 292
 	}
293 293
 
294 294
 	/**
295
-	* Gets all the spotter information based on the latest data entry and coord
296
-	*
297
-	* @return Array the spotter information
298
-	*
299
-	*/
295
+	 * Gets all the spotter information based on the latest data entry and coord
296
+	 *
297
+	 * @return Array the spotter information
298
+	 *
299
+	 */
300 300
 	public function getLiveSpotterDatabyCoord($coord, $filter = array())
301 301
 	{
302 302
 		global $globalDBdriver, $globalLiveInterval;
@@ -321,11 +321,11 @@  discard block
 block discarded – undo
321 321
 	}
322 322
 
323 323
 	/**
324
-	* Gets all the spotter information based on the latest data entry and coord
325
-	*
326
-	* @return Array the spotter information
327
-	*
328
-	*/
324
+	 * Gets all the spotter information based on the latest data entry and coord
325
+	 *
326
+	 * @return Array the spotter information
327
+	 *
328
+	 */
329 329
 	public function getMinLiveSpotterDatabyCoord($coord, $filter = array())
330 330
 	{
331 331
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
@@ -390,11 +390,11 @@  discard block
 block discarded – undo
390 390
 	}
391 391
 
392 392
 	/**
393
-	* Gets all the spotter information based on a user's latitude and longitude
394
-	*
395
-	* @return Array the spotter information
396
-	*
397
-	*/
393
+	 * Gets all the spotter information based on a user's latitude and longitude
394
+	 *
395
+	 * @return Array the spotter information
396
+	 *
397
+	 */
398 398
 	public function getLatestSpotterForLayar($lat, $lng, $radius, $interval)
399 399
 	{
400 400
 		$Spotter = new Spotter($this->db);
@@ -404,145 +404,145 @@  discard block
 block discarded – undo
404 404
 				return false;
405 405
 			}
406 406
 		}
407
-        if ($lng != '')
408
-                {
409
-                        if (!is_numeric($lng))
410
-                        {
411
-                                return false;
412
-                        }
413
-                }
414
-
415
-                if ($radius != '')
416
-                {
417
-                        if (!is_numeric($radius))
418
-                        {
419
-                                return false;
420
-                        }
421
-                }
407
+		if ($lng != '')
408
+				{
409
+						if (!is_numeric($lng))
410
+						{
411
+								return false;
412
+						}
413
+				}
414
+
415
+				if ($radius != '')
416
+				{
417
+						if (!is_numeric($radius))
418
+						{
419
+								return false;
420
+						}
421
+				}
422 422
 		$additional_query = '';
423
-        if ($interval != '')
424
-                {
425
-                        if (!is_string($interval))
426
-                        {
427
-                                //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
428
-			        return false;
429
-                        } else {
430
-                if ($interval == '1m')
431
-                {
432
-                    $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
433
-                } else if ($interval == '15m'){
434
-                    $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date ';
435
-                } 
436
-            }
437
-                } else {
438
-         $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';   
439
-        }
440
-
441
-                $query  = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live 
423
+		if ($interval != '')
424
+				{
425
+						if (!is_string($interval))
426
+						{
427
+								//$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
428
+					return false;
429
+						} else {
430
+				if ($interval == '1m')
431
+				{
432
+					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
433
+				} else if ($interval == '15m'){
434
+					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date ';
435
+				} 
436
+			}
437
+				} else {
438
+		 $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';   
439
+		}
440
+
441
+				$query  = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live 
442 442
                    WHERE spotter_live.latitude <> '' 
443 443
                                    AND spotter_live.longitude <> '' 
444 444
                    ".$additional_query."
445 445
                    HAVING distance < :radius  
446 446
                                    ORDER BY distance";
447 447
 
448
-                $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
448
+				$spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
449 449
 
450
-                return $spotter_array;
451
-        }
450
+				return $spotter_array;
451
+		}
452 452
 
453 453
     
454
-        /**
455
-	* Gets all the spotter information based on a particular callsign
456
-	*
457
-	* @return Array the spotter information
458
-	*
459
-	*/
454
+		/**
455
+		 * Gets all the spotter information based on a particular callsign
456
+		 *
457
+		 * @return Array the spotter information
458
+		 *
459
+		 */
460 460
 	public function getLastLiveSpotterDataByIdent($ident)
461 461
 	{
462 462
 		$Spotter = new Spotter($this->db);
463 463
 		date_default_timezone_set('UTC');
464 464
 
465 465
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
466
-                $query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
466
+				$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
467 467
 
468 468
 		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true);
469 469
 
470 470
 		return $spotter_array;
471 471
 	}
472 472
 
473
-        /**
474
-	* Gets all the spotter information based on a particular callsign
475
-	*
476
-	* @return Array the spotter information
477
-	*
478
-	*/
473
+		/**
474
+		 * Gets all the spotter information based on a particular callsign
475
+		 *
476
+		 * @return Array the spotter information
477
+		 *
478
+		 */
479 479
 	public function getDateLiveSpotterDataByIdent($ident,$date)
480 480
 	{
481 481
 		$Spotter = new Spotter($this->db);
482 482
 		date_default_timezone_set('UTC');
483 483
 
484 484
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
485
-                $query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
485
+				$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
486 486
 
487
-                $date = date('c',$date);
487
+				$date = date('c',$date);
488 488
 		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
489 489
 
490 490
 		return $spotter_array;
491 491
 	}
492 492
 
493
-        /**
494
-	* Gets last spotter information based on a particular callsign
495
-	*
496
-	* @return Array the spotter information
497
-	*
498
-	*/
493
+		/**
494
+		 * Gets last spotter information based on a particular callsign
495
+		 *
496
+		 * @return Array the spotter information
497
+		 *
498
+		 */
499 499
 	public function getLastLiveSpotterDataById($id)
500 500
 	{
501 501
 		$Spotter = new Spotter($this->db);
502 502
 		date_default_timezone_set('UTC');
503 503
 
504 504
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
505
-                $query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
505
+				$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
506 506
 
507 507
 		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true);
508 508
 
509 509
 		return $spotter_array;
510 510
 	}
511 511
 
512
-        /**
513
-	* Gets last spotter information based on a particular callsign
514
-	*
515
-	* @return Array the spotter information
516
-	*
517
-	*/
512
+		/**
513
+		 * Gets last spotter information based on a particular callsign
514
+		 *
515
+		 * @return Array the spotter information
516
+		 *
517
+		 */
518 518
 	public function getDateLiveSpotterDataById($id,$date)
519 519
 	{
520 520
 		$Spotter = new Spotter($this->db);
521 521
 		date_default_timezone_set('UTC');
522 522
 
523 523
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
524
-                $query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
525
-                $date = date('c',$date);
524
+				$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
525
+				$date = date('c',$date);
526 526
 		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
527 527
 
528 528
 		return $spotter_array;
529 529
 	}
530 530
 
531
-        /**
532
-	* Gets altitude information based on a particular callsign
533
-	*
534
-	* @return Array the spotter information
535
-	*
536
-	*/
531
+		/**
532
+		 * Gets altitude information based on a particular callsign
533
+		 *
534
+		 * @return Array the spotter information
535
+		 *
536
+		 */
537 537
 	public function getAltitudeLiveSpotterDataByIdent($ident)
538 538
 	{
539 539
 
540 540
 		date_default_timezone_set('UTC');
541 541
 
542 542
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
543
-                $query  = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
543
+				$query  = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
544 544
 
545
-    		try {
545
+			try {
546 546
 			
547 547
 			$sth = $this->db->prepare($query);
548 548
 			$sth->execute(array(':ident' => $ident));
@@ -555,12 +555,12 @@  discard block
 block discarded – undo
555 555
 		return $spotter_array;
556 556
 	}
557 557
 
558
-        /**
559
-	* Gets all the spotter information based on a particular id
560
-	*
561
-	* @return Array the spotter information
562
-	*
563
-	*/
558
+		/**
559
+		 * Gets all the spotter information based on a particular id
560
+		 *
561
+		 * @return Array the spotter information
562
+		 *
563
+		 */
564 564
 	public function getAllLiveSpotterDataById($id,$liveinterval = false)
565 565
 	{
566 566
 		global $globalDBdriver, $globalLiveInterval;
@@ -588,18 +588,18 @@  discard block
 block discarded – undo
588 588
 		return $spotter_array;
589 589
 	}
590 590
 
591
-        /**
592
-	* Gets all the spotter information based on a particular ident
593
-	*
594
-	* @return Array the spotter information
595
-	*
596
-	*/
591
+		/**
592
+		 * Gets all the spotter information based on a particular ident
593
+		 *
594
+		 * @return Array the spotter information
595
+		 *
596
+		 */
597 597
 	public function getAllLiveSpotterDataByIdent($ident)
598 598
 	{
599 599
 		date_default_timezone_set('UTC');
600 600
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
601 601
 		$query  = self::$global_query.' WHERE spotter_live.ident = :ident';
602
-    		try {
602
+			try {
603 603
 			
604 604
 			$sth = $this->db->prepare($query);
605 605
 			$sth->execute(array(':ident' => $ident));
@@ -613,23 +613,23 @@  discard block
 block discarded – undo
613 613
 
614 614
 
615 615
 	/**
616
-	* Deletes all info in the table
617
-	*
618
-	* @return String success or false
619
-	*
620
-	*/
616
+	 * Deletes all info in the table
617
+	 *
618
+	 * @return String success or false
619
+	 *
620
+	 */
621 621
 	public function deleteLiveSpotterData()
622 622
 	{
623 623
 		global $globalDBdriver;
624 624
 		if ($globalDBdriver == 'mysql') {
625 625
 			//$query  = "DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= spotter_live.date";
626 626
 			$query  = 'DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= spotter_live.date';
627
-            		//$query  = "DELETE FROM spotter_live WHERE spotter_live.id IN (SELECT spotter_live.id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= spotter_live.date)";
627
+					//$query  = "DELETE FROM spotter_live WHERE spotter_live.id IN (SELECT spotter_live.id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= spotter_live.date)";
628 628
 		} else {
629 629
 			$query  = "DELETE FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date";
630 630
 		}
631 631
         
632
-    		try {
632
+			try {
633 633
 			
634 634
 			$sth = $this->db->prepare($query);
635 635
 			$sth->execute();
@@ -641,18 +641,18 @@  discard block
 block discarded – undo
641 641
 	}
642 642
 
643 643
 	/**
644
-	* Deletes all info in the table for aircraft not seen since 2 HOUR
645
-	*
646
-	* @return String success or false
647
-	*
648
-	*/
644
+	 * Deletes all info in the table for aircraft not seen since 2 HOUR
645
+	 *
646
+	 * @return String success or false
647
+	 *
648
+	 */
649 649
 	public function deleteLiveSpotterDataNotUpdated()
650 650
 	{
651 651
 		global $globalDBdriver, $globalDebug;
652 652
 		if ($globalDBdriver == 'mysql') {
653 653
 			//$query = 'SELECT flightaware_id FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= spotter_live.date AND spotter_live.flightaware_id NOT IN (SELECT flightaware_id FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < spotter_live.date) LIMIT 800 OFFSET 0';
654
-    			$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 2000 OFFSET 0";
655
-    			try {
654
+				$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 2000 OFFSET 0";
655
+				try {
656 656
 				
657 657
 				$sth = $this->db->prepare($query);
658 658
 				$sth->execute();
@@ -660,8 +660,8 @@  discard block
 block discarded – undo
660 660
 				return "error";
661 661
 			}
662 662
 			$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
663
-                        $i = 0;
664
-                        $j =0;
663
+						$i = 0;
664
+						$j =0;
665 665
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
666 666
 			foreach($all as $row)
667 667
 			{
@@ -669,20 +669,20 @@  discard block
 block discarded – undo
669 669
 				$j++;
670 670
 				if ($j == 30) {
671 671
 					if ($globalDebug) echo ".";
672
-				    	try {
672
+						try {
673 673
 						
674 674
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
675 675
 						$sth->execute();
676 676
 					} catch(PDOException $e) {
677 677
 						return "error";
678 678
 					}
679
-                                	$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
680
-                                	$j = 0;
679
+									$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
680
+									$j = 0;
681 681
 				}
682 682
 				$query_delete .= "'".$row['flightaware_id']."',";
683 683
 			}
684 684
 			if ($i > 0) {
685
-    				try {
685
+					try {
686 686
 					
687 687
 					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
688 688
 					$sth->execute();
@@ -693,9 +693,9 @@  discard block
 block discarded – undo
693 693
 			return "success";
694 694
 		} elseif ($globalDBdriver == 'pgsql') {
695 695
 			//$query = "SELECT flightaware_id FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date AND spotter_live.flightaware_id NOT IN (SELECT flightaware_id FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < spotter_live.date) LIMIT 800 OFFSET 0";
696
-    			//$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0";
697
-    			$query = "DELETE FROM spotter_live WHERE flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 2000 OFFSET 0)";
698
-    			try {
696
+				//$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0";
697
+				$query = "DELETE FROM spotter_live WHERE flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 2000 OFFSET 0)";
698
+				try {
699 699
 				
700 700
 				$sth = $this->db->prepare($query);
701 701
 				$sth->execute();
@@ -739,17 +739,17 @@  discard block
 block discarded – undo
739 739
 	}
740 740
 
741 741
 	/**
742
-	* Deletes all info in the table for an ident
743
-	*
744
-	* @return String success or false
745
-	*
746
-	*/
742
+	 * Deletes all info in the table for an ident
743
+	 *
744
+	 * @return String success or false
745
+	 *
746
+	 */
747 747
 	public function deleteLiveSpotterDataByIdent($ident)
748 748
 	{
749 749
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
750 750
 		$query  = 'DELETE FROM spotter_live WHERE ident = :ident';
751 751
         
752
-    		try {
752
+			try {
753 753
 			
754 754
 			$sth = $this->db->prepare($query);
755 755
 			$sth->execute(array(':ident' => $ident));
@@ -761,17 +761,17 @@  discard block
 block discarded – undo
761 761
 	}
762 762
 
763 763
 	/**
764
-	* Deletes all info in the table for an id
765
-	*
766
-	* @return String success or false
767
-	*
768
-	*/
764
+	 * Deletes all info in the table for an id
765
+	 *
766
+	 * @return String success or false
767
+	 *
768
+	 */
769 769
 	public function deleteLiveSpotterDataById($id)
770 770
 	{
771 771
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
772 772
 		$query  = 'DELETE FROM spotter_live WHERE flightaware_id = :id';
773 773
         
774
-    		try {
774
+			try {
775 775
 			
776 776
 			$sth = $this->db->prepare($query);
777 777
 			$sth->execute(array(':id' => $id));
@@ -784,11 +784,11 @@  discard block
 block discarded – undo
784 784
 
785 785
 
786 786
 	/**
787
-	* Gets the aircraft ident within the last hour
788
-	*
789
-	* @return String the ident
790
-	*
791
-	*/
787
+	 * Gets the aircraft ident within the last hour
788
+	 *
789
+	 * @return String the ident
790
+	 *
791
+	 */
792 792
 	public function getIdentFromLastHour($ident)
793 793
 	{
794 794
 		global $globalDBdriver, $globalTimezone;
@@ -814,14 +814,14 @@  discard block
 block discarded – undo
814 814
 			$ident_result = $row['ident'];
815 815
 		}
816 816
 		return $ident_result;
817
-        }
817
+		}
818 818
 
819 819
 	/**
820
-	* Check recent aircraft
821
-	*
822
-	* @return String the ident
823
-	*
824
-	*/
820
+	 * Check recent aircraft
821
+	 *
822
+	 * @return String the ident
823
+	 *
824
+	 */
825 825
 	public function checkIdentRecent($ident)
826 826
 	{
827 827
 		global $globalDBdriver, $globalTimezone;
@@ -847,14 +847,14 @@  discard block
 block discarded – undo
847 847
 			$ident_result = $row['flightaware_id'];
848 848
 		}
849 849
 		return $ident_result;
850
-        }
850
+		}
851 851
 
852 852
 	/**
853
-	* Check recent aircraft by id
854
-	*
855
-	* @return String the ident
856
-	*
857
-	*/
853
+	 * Check recent aircraft by id
854
+	 *
855
+	 * @return String the ident
856
+	 *
857
+	 */
858 858
 	public function checkIdRecent($id)
859 859
 	{
860 860
 		global $globalDBdriver, $globalTimezone;
@@ -880,14 +880,14 @@  discard block
 block discarded – undo
880 880
 			$ident_result = $row['flightaware_id'];
881 881
 		}
882 882
 		return $ident_result;
883
-        }
883
+		}
884 884
 
885 885
 	/**
886
-	* Check recent aircraft by ModeS
887
-	*
888
-	* @return String the ModeS
889
-	*
890
-	*/
886
+	 * Check recent aircraft by ModeS
887
+	 *
888
+	 * @return String the ModeS
889
+	 *
890
+	 */
891 891
 	public function checkModeSRecent($modes)
892 892
 	{
893 893
 		global $globalDBdriver, $globalTimezone;
@@ -914,19 +914,19 @@  discard block
 block discarded – undo
914 914
 			$ident_result = $row['flightaware_id'];
915 915
 		}
916 916
 		return $ident_result;
917
-        }
917
+		}
918 918
 
919 919
 	/**
920
-	* Adds a new spotter data
921
-	*
922
-	* @param String $flightaware_id the ID from flightaware
923
-	* @param String $ident the flight ident
924
-	* @param String $aircraft_icao the aircraft type
925
-	* @param String $departure_airport_icao the departure airport
926
-	* @param String $arrival_airport_icao the arrival airport
927
-	* @return String success or false
928
-	*
929
-	*/
920
+	 * Adds a new spotter data
921
+	 *
922
+	 * @param String $flightaware_id the ID from flightaware
923
+	 * @param String $ident the flight ident
924
+	 * @param String $aircraft_icao the aircraft type
925
+	 * @param String $departure_airport_icao the departure airport
926
+	 * @param String $arrival_airport_icao the arrival airport
927
+	 * @return String success or false
928
+	 *
929
+	 */
930 930
 	public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '',$heading = '', $groundspeed = '', $date = '',$departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false,$registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false,$format_source = '', $source_name = '', $over_country = '')
931 931
 	{
932 932
 		global $globalURL, $globalArchive, $globalDebug;
@@ -1061,10 +1061,10 @@  discard block
 block discarded – undo
1061 1061
 		$arrival_airport_country = '';
1062 1062
 		
1063 1063
             	
1064
-            	if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
1065
-            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
1066
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1067
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1064
+				if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
1065
+				if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
1066
+				if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1067
+				if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1068 1068
 		
1069 1069
 		$query = '';
1070 1070
 		if ($globalArchive) {
@@ -1085,10 +1085,10 @@  discard block
 block discarded – undo
1085 1085
 			return "error : ".$e->getMessage();
1086 1086
 		}
1087 1087
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
1088
-		    if ($globalDebug) echo '(Add to SBS archive : ';
1089
-		    $SpotterArchive = new SpotterArchive($this->db);
1090
-		    $result =  $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country);
1091
-		    if ($globalDebug) echo $result.')';
1088
+			if ($globalDebug) echo '(Add to SBS archive : ';
1089
+			$SpotterArchive = new SpotterArchive($this->db);
1090
+			$result =  $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country);
1091
+			if ($globalDebug) echo $result.')';
1092 1092
 		}
1093 1093
 		return "success";
1094 1094
 
Please login to merge, or discard this patch.