Completed
Push — master ( 49d1e9...639942 )
by Yannick
06:34
created
require/class.Scheduler.php 1 patch
Indentation   +160 added lines, -160 removed lines patch added patch discarded remove patch
@@ -8,29 +8,29 @@  discard block
 block discarded – undo
8 8
 
9 9
 class Schedule {
10 10
 	protected $cookies = array();
11
-        public $db;
11
+		public $db;
12 12
 	public function __construct($dbc = null) {
13 13
 		$Connection = new Connection($dbc);
14 14
 		$this->db = $Connection->db();
15
-        }
15
+		}
16 16
 	
17 17
 	/**
18
-	* Add schedule data to database
19
-	* @param String $ident aircraft ident
20
-	* @param String $departure_airport_icao departure airport icao
21
-	* @param String $departure_airport_time departure airport time
22
-	* @param String $arrival_airport_icao arrival airport icao
23
-	* @param String $arrival_airport_time arrival airport time
18
+	 * Add schedule data to database
19
+	 * @param String $ident aircraft ident
20
+	 * @param String $departure_airport_icao departure airport icao
21
+	 * @param String $departure_airport_time departure airport time
22
+	 * @param String $arrival_airport_icao arrival airport icao
23
+	 * @param String $arrival_airport_time arrival airport time
24 24
 	/ @param String $source source of data
25
-	*/
25
+	 */
26 26
 	
27 27
 	public function addSchedule($ident,$departure_airport_icao,$departure_airport_time,$arrival_airport_icao,$arrival_airport_time,$source = 'website') {
28 28
 		date_default_timezone_set('UTC');
29 29
 		$date = date("Y-m-d H:i:s",time());
30
-	        //if ($departure_airport_time == '' && $arrival_airport_time == '') exit;
31
-	        //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident";
32
-	        $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident";
33
-	        $query_values = array(':ident' => $ident);
30
+			//if ($departure_airport_time == '' && $arrival_airport_time == '') exit;
31
+			//$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident";
32
+			$query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident";
33
+			$query_values = array(':ident' => $ident);
34 34
 		 try {
35 35
 			$sth = $this->db->prepare($query);
36 36
 			$sth->execute($query_values);
@@ -39,18 +39,18 @@  discard block
 block discarded – undo
39 39
 		}
40 40
 		if ($sth->fetchColumn() > 0) {
41 41
 			if ($departure_airport_time == '' && $arrival_airport_time == '') {
42
-			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao";
43
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao);
42
+				$query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao";
43
+				$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao);
44 44
 			} elseif ($arrival_airport_time == '') {
45
-			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao";
46
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao);
45
+				$query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao";
46
+				$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao);
47 47
 			} elseif ($departure_airport_time == '') {
48
-			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time";
49
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
48
+				$query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time";
49
+				$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
50 50
 			} else {
51
-			    //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident AND departure_airport_icao = :departure_airport_icao AND departure_airport_time = :departure_airport_time AND arrival_airport_icao = :arrival_airport_icao AND arrival_airport_time = :arrival_airport_time";
52
-			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time";
53
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
51
+				//$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident AND departure_airport_icao = :departure_airport_icao AND departure_airport_time = :departure_airport_time AND arrival_airport_icao = :arrival_airport_icao AND arrival_airport_time = :arrival_airport_time";
52
+				$query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time";
53
+				$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
54 54
 			}
55 55
 			try {
56 56
 				$sth = $this->db->prepare($query);
@@ -61,17 +61,17 @@  discard block
 block discarded – undo
61 61
 			if ($sth->fetchColumn() == 0) {
62 62
 				//$query = 'UPDATE schedule SET departure_airport_icao = :departure_airport_icao, departure_airport_time = :departure_airport_time, arrival_airport_icao = :arrival_airport_icao, arrival_airport_time = :arrival_airport_time, date_modified = :date, source = :source WHERE ident = :ident';
63 63
 				if ($departure_airport_time == '' && $arrival_airport_time == '') {
64
-                            	    $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident';
65
-				    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source);
64
+									$query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident';
65
+					$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source);
66 66
 				} elseif ($arrival_airport_time == '') {
67
-                            	    $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident';
68
-				    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source);
67
+									$query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident';
68
+					$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source);
69 69
 				} elseif ($departure_airport_time == '') {
70
-                            	    $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident';
71
-				    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
70
+									$query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident';
71
+					$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
72 72
 				} else {
73
-                            	    $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident';
74
-				    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
73
+									$query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident';
74
+					$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
75 75
 				}
76 76
 				 try {
77 77
 					$sth = $this->db->prepare($query);
@@ -104,15 +104,15 @@  discard block
 block discarded – undo
104 104
 	}
105 105
 
106 106
 	public function getSchedule($ident) {
107
-	        $Translation = new Translation($this->db);
108
-	        $operator = $Translation->checkTranslation($ident,false);
109
-	        if ($ident != $operator) {
110
-	    		$query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE CallSign = :operator OR CallSign = :ident LIMIT 1";
111
-	    		$query_values = array(':ident' => $ident,'operator' => $operator);
112
-	    	} else {
113
-		        $query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE CallSign = :ident LIMIT 1";
114
-	    		$query_values = array(':ident' => $ident);
115
-	    	}
107
+			$Translation = new Translation($this->db);
108
+			$operator = $Translation->checkTranslation($ident,false);
109
+			if ($ident != $operator) {
110
+				$query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE CallSign = :operator OR CallSign = :ident LIMIT 1";
111
+				$query_values = array(':ident' => $ident,'operator' => $operator);
112
+			} else {
113
+				$query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE CallSign = :ident LIMIT 1";
114
+				$query_values = array(':ident' => $ident);
115
+			}
116 116
 		 try {
117 117
 			$sth = $this->db->prepare($query);
118 118
 			$sth->execute($query_values);
@@ -128,15 +128,15 @@  discard block
 block discarded – undo
128 128
 
129 129
 	public function checkSchedule($ident) {
130 130
 		global $globalDBdriver;
131
-	        //$query = "SELECT COUNT(*) as nb FROM schedule WHERE ident = :ident AND date_added > DATE_SUB(CURDATE(), INTERVAL 8 DAY) - 8 LIMIT 1";
132
-	        if ($globalDBdriver == 'mysql') {
131
+			//$query = "SELECT COUNT(*) as nb FROM schedule WHERE ident = :ident AND date_added > DATE_SUB(CURDATE(), INTERVAL 8 DAY) - 8 LIMIT 1";
132
+			if ($globalDBdriver == 'mysql') {
133 133
 			$query = "SELECT COUNT(*) as nb FROM routes WHERE CallSign = :ident AND ((date_added BETWEEN DATE(DATE_SUB(CURDATE(), INTERVAL 1 MONTH)) AND DATE(NOW()) and date_modified IS NULL) OR (date_modified BETWEEN DATE(DATE_SUB(CURDATE(), INTERVAL 15 DAY)) AND DATE(NOW()))) LIMIT 1";
134 134
 		} else {
135 135
 			$query = "SELECT COUNT(*) as nb FROM routes WHERE CallSign = :ident 
136 136
 			AND ((date_added::timestamp BETWEEN CURRENT_TIMESTAMP - INTERVAL '1 MONTH' AND CURRENT_TIMESTAMP) and date_modified::timestamp IS NULL)
137 137
 			     OR (date_modified::timestamp BETWEEN CURRENT_TIMESTAMP - INTERVAL '1 MONTH' AND CURRENT_TIMESTAMP) LIMIT 1";
138 138
 		}
139
-	        $query_values = array(':ident' => $ident);
139
+			$query_values = array(':ident' => $ident);
140 140
 		 try {
141 141
 			$sth = $this->db->prepare($query);
142 142
 			$sth->execute($query_values);
@@ -149,12 +149,12 @@  discard block
 block discarded – undo
149 149
 	}
150 150
 
151 151
 	/**
152
-	* Get flight info from Air France
153
-	* @param String $callsign The callsign
154
-	* @param String $date date we want flight number info
155
-	* @param String $carrier IATA code
156
-	* @return Flight departure and arrival airports and time
157
-	*/
152
+	 * Get flight info from Air France
153
+	 * @param String $callsign The callsign
154
+	 * @param String $date date we want flight number info
155
+	 * @param String $carrier IATA code
156
+	 * @return Flight departure and arrival airports and time
157
+	 */
158 158
 	private function getAirFrance($callsign, $date = 'NOW',$carrier = 'AF') {
159 159
 		$Common = new Common();
160 160
 		$check_date = new Datetime($date);
@@ -190,11 +190,11 @@  discard block
 block discarded – undo
190 190
 	}
191 191
 
192 192
 	/**
193
-	* Get flight info from EasyJet
194
-	* @param String $callsign The callsign
195
-	* @param String $date date we want flight number info
196
-	* @return Flight departure and arrival airports and time
197
-	*/
193
+	 * Get flight info from EasyJet
194
+	 * @param String $callsign The callsign
195
+	 * @param String $date date we want flight number info
196
+	 * @return Flight departure and arrival airports and time
197
+	 */
198 198
 	private function getEasyJet($callsign, $date = 'NOW') {
199 199
 		global $globalTimezone;
200 200
 		$Common = new Common();
@@ -218,10 +218,10 @@  discard block
 block discarded – undo
218 218
 	}
219 219
 
220 220
 	/**
221
-	* Get flight info from Ryanair
222
-	* @param String $callsign The callsign
223
-	* @return Flight departure and arrival airports and time
224
-	*/
221
+	 * Get flight info from Ryanair
222
+	 * @param String $callsign The callsign
223
+	 * @return Flight departure and arrival airports and time
224
+	 */
225 225
 	private function getRyanair($callsign) {
226 226
 		$Common = new Common();
227 227
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -244,10 +244,10 @@  discard block
 block discarded – undo
244 244
 	}
245 245
 
246 246
 	/**
247
-	* Get flight info from Swiss
248
-	* @param String $callsign The callsign
249
-	* @return Flight departure and arrival airports and time
250
-	*/
247
+	 * Get flight info from Swiss
248
+	 * @param String $callsign The callsign
249
+	 * @return Flight departure and arrival airports and time
250
+	 */
251 251
 	private function getSwiss($callsign) {
252 252
 		$Common = new Common();
253 253
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -276,11 +276,11 @@  discard block
 block discarded – undo
276 276
 	}
277 277
 	
278 278
 	/**
279
-	* Get flight info from British Airways API
280
-	* @param String $callsign The callsign
281
-	* @param String $date date we want flight number info
282
-	* @return Flight departure and arrival airports and time
283
-	*/
279
+	 * Get flight info from British Airways API
280
+	 * @param String $callsign The callsign
281
+	 * @param String $date date we want flight number info
282
+	 * @return Flight departure and arrival airports and time
283
+	 */
284 284
 	public function getBritishAirways($callsign, $date = 'NOW') {
285 285
 		global $globalBritishAirwaysKey;
286 286
 		$Common = new Common();
@@ -304,11 +304,11 @@  discard block
 block discarded – undo
304 304
 	}
305 305
 
306 306
 	/**
307
-	* Get flight info from Lutfhansa API
308
-	* @param String $callsign The callsign
309
-	* @param String $date date we want flight number info
310
-	* @return Flight departure and arrival airports and time
311
-	*/
307
+	 * Get flight info from Lutfhansa API
308
+	 * @param String $callsign The callsign
309
+	 * @param String $date date we want flight number info
310
+	 * @return Flight departure and arrival airports and time
311
+	 */
312 312
 	public function getLufthansa($callsign, $date = 'NOW') {
313 313
 		global $globalLufthansaKey;
314 314
 		$Common = new Common();
@@ -338,11 +338,11 @@  discard block
 block discarded – undo
338 338
 	}
339 339
 
340 340
 	/**
341
-	* Get flight info from Transavia API
342
-	* @param String $callsign The callsign
343
-	* @param String $date date we want flight number info
344
-	* @return Flight departure and arrival airports and time
345
-	*/
341
+	 * Get flight info from Transavia API
342
+	 * @param String $callsign The callsign
343
+	 * @param String $date date we want flight number info
344
+	 * @return Flight departure and arrival airports and time
345
+	 */
346 346
 	public function getTransavia($callsign, $date = 'NOW') {
347 347
 		global $globalTransaviaKey;
348 348
 		$Common = new Common();
@@ -368,10 +368,10 @@  discard block
 block discarded – undo
368 368
 	}
369 369
 
370 370
 	/**
371
-	* Get flight info from Tunisair
372
-	* @param String $callsign The callsign
373
-	* @return Flight departure and arrival airports and time
374
-	*/
371
+	 * Get flight info from Tunisair
372
+	 * @param String $callsign The callsign
373
+	 * @return Flight departure and arrival airports and time
374
+	 */
375 375
 	public function getTunisair($callsign) {
376 376
 		$Common = new Common();
377 377
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -388,10 +388,10 @@  discard block
 block discarded – undo
388 388
 	}
389 389
 
390 390
 	/**
391
-	* Get flight info from Vueling
392
-	* @param String $callsign The callsign
393
-	* @return Flight departure and arrival airports and time
394
-	*/
391
+	 * Get flight info from Vueling
392
+	 * @param String $callsign The callsign
393
+	 * @return Flight departure and arrival airports and time
394
+	 */
395 395
 	public function getVueling($callsign,$date = 'NOW') {
396 396
 		$Common = new Common();
397 397
 		$check_date = new Datetime($date);
@@ -413,11 +413,11 @@  discard block
 block discarded – undo
413 413
 	}
414 414
 
415 415
 	/**
416
-	* Get flight info from Iberia
417
-	* @param String $callsign The callsign
418
-	* @param String $date date we want flight number info
419
-	* @return Flight departure and arrival airports and time
420
-	*/
416
+	 * Get flight info from Iberia
417
+	 * @param String $callsign The callsign
418
+	 * @param String $date date we want flight number info
419
+	 * @return Flight departure and arrival airports and time
420
+	 */
421 421
 	public function getIberia($callsign, $date = 'NOW') {
422 422
 		$Common = new Common();
423 423
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -447,11 +447,11 @@  discard block
 block discarded – undo
447 447
 	}
448 448
 
449 449
 	/**
450
-	* Get flight info from Star Alliance
451
-	* @param String $callsign The callsign
452
-	* @param String $date date we want flight number info
453
-	* @return Flight departure and arrival airports and time
454
-	*/
450
+	 * Get flight info from Star Alliance
451
+	 * @param String $callsign The callsign
452
+	 * @param String $date date we want flight number info
453
+	 * @return Flight departure and arrival airports and time
454
+	 */
455 455
 
456 456
 	private function getStarAlliance($callsign, $date = 'NOW',$carrier = '') {
457 457
 		$Common = new Common();
@@ -483,11 +483,11 @@  discard block
 block discarded – undo
483 483
 
484 484
 
485 485
 	/**
486
-	* Get flight info from Alitalia
487
-	* @param String $callsign The callsign
488
-	* @param String $date date we want flight number info
489
-	* @return Flight departure and arrival airports and time
490
-	*/
486
+	 * Get flight info from Alitalia
487
+	 * @param String $callsign The callsign
488
+	 * @param String $date date we want flight number info
489
+	 * @return Flight departure and arrival airports and time
490
+	 */
491 491
 	private function getAlitalia($callsign, $date = 'NOW') {
492 492
 		$Common = new Common();
493 493
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -506,11 +506,11 @@  discard block
 block discarded – undo
506 506
 	}
507 507
 
508 508
 	/**
509
-	* Get flight info from Brussels airlines
510
-	* @param String $callsign The callsign
511
-	* @param String $date date we want flight number info
512
-	* @return Flight departure and arrival airports and time
513
-	*/
509
+	 * Get flight info from Brussels airlines
510
+	 * @param String $callsign The callsign
511
+	 * @param String $date date we want flight number info
512
+	 * @return Flight departure and arrival airports and time
513
+	 */
514 514
 	private function getBrussels($callsign, $date = 'NOW') {
515 515
 		$Common = new Common();
516 516
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -520,24 +520,24 @@  discard block
 block discarded – undo
520 520
 		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
521 521
 		$data = $Common->getData($url);
522 522
 		if ($data != '') {
523
-		    //echo $data;
524
-		    $parsed_json = json_decode($data,true);
525
-		    if (isset($parsed_json[0]['FromAirportCode'])) {
523
+			//echo $data;
524
+			$parsed_json = json_decode($data,true);
525
+			if (isset($parsed_json[0]['FromAirportCode'])) {
526 526
 			$DepartureAirportIata = $parsed_json[0]['FromAirportCode'];
527 527
 			$ArrivalAirportIata = $parsed_json[0]['ToAirportCode'];
528 528
 			$departureTime = date('H:i',strtotime($parsed_json[0]['ScheduledDepatureDate']));
529 529
 			$arrivalTime = date('H:i',strtotime($parsed_json[0]['ScheduledArrivalDate']));
530 530
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_brussels');
531
-		    }
531
+			}
532 532
 		}
533 533
 	}
534 534
 
535 535
 	/**
536
-	* Get flight info from FlightRadar24
537
-	* @param String $callsign The callsign
538
-	* @param String $date date we want flight number info
539
-	* @return Flight departure and arrival airports and time
540
-	*/
536
+	 * Get flight info from FlightRadar24
537
+	 * @param String $callsign The callsign
538
+	 * @param String $date date we want flight number info
539
+	 * @return Flight departure and arrival airports and time
540
+	 */
541 541
 /*
542 542
 	public function getFlightRadar24($callsign, $date = 'NOW') {
543 543
 		$Common = new Common();
@@ -566,11 +566,11 @@  discard block
 block discarded – undo
566 566
 	}
567 567
   */
568 568
 	/**
569
-	* Get flight info from Lufthansa
570
-	* @param String $callsign The callsign
571
-	* @param String $date date we want flight number info
572
-	* @return Flight departure and arrival airports and time
573
-	*/
569
+	 * Get flight info from Lufthansa
570
+	 * @param String $callsign The callsign
571
+	 * @param String $date date we want flight number info
572
+	 * @return Flight departure and arrival airports and time
573
+	 */
574 574
 
575 575
 /*	private function getLufthansa($callsign, $date = 'NOW') {
576 576
 		$Common = new Common();
@@ -598,10 +598,10 @@  discard block
 block discarded – undo
598 598
 	}
599 599
   */
600 600
 	/**
601
-	* Get flight info from flytap
602
-	* @param String $callsign The callsign
603
-	* @return Flight departure and arrival airports and time
604
-	*/
601
+	 * Get flight info from flytap
602
+	 * @param String $callsign The callsign
603
+	 * @return Flight departure and arrival airports and time
604
+	 */
605 605
 	private function getFlyTap($callsign) {
606 606
 		$Common = new Common();
607 607
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -624,10 +624,10 @@  discard block
 block discarded – undo
624 624
 	}
625 625
 
626 626
 	/**
627
-	* Get flight info from flightmapper
628
-	* @param String $callsign The callsign
629
-	* @return Flight departure and arrival airports and time
630
-	*/
627
+	 * Get flight info from flightmapper
628
+	 * @param String $callsign The callsign
629
+	 * @return Flight departure and arrival airports and time
630
+	 */
631 631
 	public function getFlightMapper($callsign) {
632 632
 		$Common = new Common();
633 633
 		$airline_icao = '';
@@ -655,11 +655,11 @@  discard block
 block discarded – undo
655 655
 				$aarr = '';
656 656
 				$n = sscanf($sched,'%*s %5[0-9:] %*[^()] (%3[A-Z]) %5[0-9:] %*[^()] (%3[A-Z])',$dhour,$darr,$ahour,$aarr);
657 657
 				if ($n == 7) {
658
-				    $departureTime = $dhour;
659
-				    $arrivalTime = $ahour;
660
-				    $DepartureAirportIata = str_replace(array('(',')'),'',$darr);
661
-				    $ArrivalAirportIata = str_replace(array('(',')'),'',$aarr);
662
-				    return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightmapper');
658
+					$departureTime = $dhour;
659
+					$arrivalTime = $ahour;
660
+					$DepartureAirportIata = str_replace(array('(',')'),'',$darr);
661
+					$ArrivalAirportIata = str_replace(array('(',')'),'',$aarr);
662
+					return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightmapper');
663 663
 				}
664 664
 			}
665 665
 		}
@@ -667,10 +667,10 @@  discard block
 block discarded – undo
667 667
 	}
668 668
 
669 669
 	/**
670
-	* Get flight info from flightaware
671
-	* @param String $callsign The callsign
672
-	* @return Flight departure and arrival airports and time
673
-	*/
670
+	 * Get flight info from flightaware
671
+	 * @param String $callsign The callsign
672
+	 * @return Flight departure and arrival airports and time
673
+	 */
674 674
 	public function getFlightAware($callsign) {
675 675
 		$Common = new Common();
676 676
 		/*
@@ -703,10 +703,10 @@  discard block
 block discarded – undo
703 703
 	}
704 704
 
705 705
 	/**
706
-	* Get flight info from CostToTravel
707
-	* @param String $callsign The callsign
708
-	* @return Flight departure and arrival airports and time
709
-	*/
706
+	 * Get flight info from CostToTravel
707
+	 * @param String $callsign The callsign
708
+	 * @return Flight departure and arrival airports and time
709
+	 */
710 710
 	public function getCostToTravel($callsign) {
711 711
 		$Common = new Common();
712 712
 		$url= "http://www.costtotravel.com/flight-number/".$callsign;
@@ -728,11 +728,11 @@  discard block
 block discarded – undo
728 728
 	}
729 729
 
730 730
 	/**
731
-	* Get flight info from Air Canada
732
-	* @param String $callsign The callsign
733
-	* @param String $date date we want flight number info
734
-	* @return Flight departure and arrival airports and time
735
-	*/
731
+	 * Get flight info from Air Canada
732
+	 * @param String $callsign The callsign
733
+	 * @param String $date date we want flight number info
734
+	 * @return Flight departure and arrival airports and time
735
+	 */
736 736
 	private function getAirCanada($callsign,$date = 'NOW') {
737 737
 		$Common = new Common();
738 738
 		date_default_timezone_set('UTC');
@@ -756,11 +756,11 @@  discard block
 block discarded – undo
756 756
 	}
757 757
 
758 758
 	/**
759
-	* Get flight info from Vietnam Airlines
760
-	* @param String $callsign The callsign
761
-	* @param String $date date we want flight number info
762
-	* @return Flight departure and arrival airports and time
763
-	*/
759
+	 * Get flight info from Vietnam Airlines
760
+	 * @param String $callsign The callsign
761
+	 * @param String $date date we want flight number info
762
+	 * @return Flight departure and arrival airports and time
763
+	 */
764 764
 	private function getVietnamAirlines($callsign, $date = 'NOW') {
765 765
 		$Common = new Common();
766 766
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -782,12 +782,12 @@  discard block
 block discarded – undo
782 782
 	}
783 783
 
784 784
 	/**
785
-	* Get flight info from Air Berlin
786
-	* @param String $callsign The callsign
787
-	* @param String $date date we want flight number info
788
-	* @param String $carrier airline code
789
-	* @return Flight departure and arrival airports and time
790
-	*/
785
+	 * Get flight info from Air Berlin
786
+	 * @param String $callsign The callsign
787
+	 * @param String $date date we want flight number info
788
+	 * @param String $carrier airline code
789
+	 * @return Flight departure and arrival airports and time
790
+	 */
791 791
 	private function getAirBerlin($callsign, $date = 'NOW',$carrier = 'AB') {
792 792
 		$Common = new Common();
793 793
 		date_default_timezone_set('UTC');
@@ -816,11 +816,11 @@  discard block
 block discarded – undo
816 816
 			$table = $Common->table2array($data);
817 817
 			$flight = $table;
818 818
 			if (isset($flight[5][4])) {
819
-			    $arrivalTime = $flight[5][4];
820
-			    $arrivalAirport = $flight[5][3];
819
+				$arrivalTime = $flight[5][4];
820
+				$arrivalAirport = $flight[5][3];
821 821
 			} else {
822
-			    $arrivalTime = '';
823
-			    $arrivalAirport = '';
822
+				$arrivalTime = '';
823
+				$arrivalAirport = '';
824 824
 			}
825 825
 		} else return array();
826 826
 		$url = 'http://www.airberlin.com/en-US/site/json/suggestAirport.php?searchfor=departures&searchflightid=0&departures%5B%5D=&suggestsource%5B0%5D=activeairports&withcountries=0&withoutroutings=0&promotion%5Bid%5D=&promotion%5Btype%5D=&routesource%5B0%5D=airberlin&routesource%5B1%5D=partner';
@@ -1088,7 +1088,7 @@  discard block
 block discarded – undo
1088 1088
 					}
1089 1089
 			}
1090 1090
 		}
1091
-	        return array();
1091
+			return array();
1092 1092
 	}
1093 1093
 }
1094 1094
 
Please login to merge, or discard this patch.
require/class.SpotterImport.php 1 patch
Indentation   +351 added lines, -351 removed lines patch added patch discarded remove patch
@@ -9,16 +9,16 @@  discard block
 block discarded – undo
9 9
 require_once(dirname(__FILE__).'/class.Source.php');
10 10
 
11 11
 class SpotterImport {
12
-    private $all_flights = array();
13
-    private $last_delete_hourly = 0;
14
-    private $last_delete = 0;
15
-    private $stats = array();
16
-    private $tmd = 0;
17
-    private $source_location = array();
18
-    public $db = null;
19
-    public $nb = 0;
20
-
21
-    public function __construct($dbc = null) {
12
+	private $all_flights = array();
13
+	private $last_delete_hourly = 0;
14
+	private $last_delete = 0;
15
+	private $stats = array();
16
+	private $tmd = 0;
17
+	private $source_location = array();
18
+	public $db = null;
19
+	public $nb = 0;
20
+
21
+	public function __construct($dbc = null) {
22 22
 	global $globalBeta;
23 23
 	$Connection = new Connection($dbc);
24 24
 	$this->db = $Connection->db();
@@ -29,18 +29,18 @@  discard block
 block discarded – undo
29 29
 	$currentdate = date('Y-m-d');
30 30
 	$sourcestat = $Stats->getStatsSource($currentdate);
31 31
 	if (!empty($sourcestat)) {
32
-	    foreach($sourcestat as $srcst) {
33
-	    	$type = $srcst['stats_type'];
32
+		foreach($sourcestat as $srcst) {
33
+			$type = $srcst['stats_type'];
34 34
 		if ($type == 'polar' || $type == 'hist') {
35
-		    $source = $srcst['source_name'];
36
-		    $data = $srcst['source_data'];
37
-		    $this->stats[$currentdate][$source][$type] = json_decode($data,true);
38
-	        }
39
-	    }
35
+			$source = $srcst['source_name'];
36
+			$data = $srcst['source_data'];
37
+			$this->stats[$currentdate][$source][$type] = json_decode($data,true);
38
+			}
39
+		}
40
+	}
40 41
 	}
41
-    }
42 42
 
43
-    public function get_Schedule($id,$ident) {
43
+	public function get_Schedule($id,$ident) {
44 44
 	global $globalDebug, $globalFork, $globalSchedulesFetch;
45 45
 	// Get schedule here, so it's done only one time
46 46
 	
@@ -59,35 +59,35 @@  discard block
 block discarded – undo
59 59
 	$Translation = new Translation($dbc);
60 60
 	$operator = $Spotter->getOperator($ident);
61 61
 	if ($Schedule->checkSchedule($operator) == 0) {
62
-	    $operator = $Translation->checkTranslation($ident);
63
-	    if ($Schedule->checkSchedule($operator) == 0) {
62
+		$operator = $Translation->checkTranslation($ident);
63
+		if ($Schedule->checkSchedule($operator) == 0) {
64 64
 		$schedule = $Schedule->fetchSchedule($operator);
65 65
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
66
-		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
67
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
68
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
69
-		    // Should also check if route schedule = route from DB
70
-		    if ($schedule['DepartureAirportIATA'] != '') {
66
+			if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
67
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
68
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
69
+			// Should also check if route schedule = route from DB
70
+			if ($schedule['DepartureAirportIATA'] != '') {
71 71
 			if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) {
72
-			    $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
73
-			    if ($airport_icao != '') {
72
+				$airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
73
+				if ($airport_icao != '') {
74 74
 				$this->all_flights[$id]['departure_airport'] = $airport_icao;
75 75
 				if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
76
-			    }
76
+				}
77
+			}
77 78
 			}
78
-		    }
79
-		    if ($schedule['ArrivalAirportIATA'] != '') {
79
+			if ($schedule['ArrivalAirportIATA'] != '') {
80 80
 			if ($this->all_flights[$id]['arrival_airport'] != $Spotter->getAirportIcao($schedule['ArrivalAirportIATA'])) {
81
-			    $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
82
-			    if ($airport_icao != '') {
81
+				$airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
82
+				if ($airport_icao != '') {
83 83
 				$this->all_flights[$id]['arrival_airport'] = $airport_icao;
84 84
 				if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
85
-			    }
85
+				}
86
+			}
86 87
 			}
87
-		    }
88
-		    $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']);
88
+			$Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']);
89
+		}
89 90
 		}
90
-	    }
91 91
 	}
92 92
 	// close connection, at least one way will work ?
93 93
        
@@ -105,92 +105,92 @@  discard block
 block discarded – undo
105 105
 	}
106 106
 	  */
107 107
 	}
108
-    }
108
+	}
109 109
 
110
-    public function checkAll() {
110
+	public function checkAll() {
111 111
 	global $globalDebug;
112 112
 	if ($globalDebug) echo "Update last seen flights data...\n";
113 113
 	foreach ($this->all_flights as $key => $flight) {
114
-	    if (isset($this->all_flights[$key]['id'])) {
114
+		if (isset($this->all_flights[$key]['id'])) {
115 115
 		//echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
116
-    		$Spotter = new Spotter($this->db);
117
-        	$real_arrival = $this->arrival($key);
118
-        	$Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
119
-            }
116
+			$Spotter = new Spotter($this->db);
117
+			$real_arrival = $this->arrival($key);
118
+			$Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
119
+			}
120
+	}
120 121
 	}
121
-    }
122 122
 
123
-    public function arrival($key) {
123
+	public function arrival($key) {
124 124
 	global $globalClosestMinDist, $globalDebug;
125 125
 	if ($globalDebug) echo 'Update arrival...'."\n";
126 126
 	$Spotter = new Spotter($this->db);
127
-        $airport_icao = '';
128
-        $airport_time = '';
129
-        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
127
+		$airport_icao = '';
128
+		$airport_time = '';
129
+		if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
130 130
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
131
-	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
132
-    	    if (isset($closestAirports[0])) {
133
-        	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
134
-        	    $airport_icao = $closestAirports[0]['icao'];
135
-        	    $airport_time = $this->all_flights[$key]['datetime'];
136
-        	    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
137
-        	} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
138
-        	    foreach ($closestAirports as $airport) {
139
-        		if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
140
-        		    $airport_icao = $airport['icao'];
141
-        		    $airport_time = $this->all_flights[$key]['datetime'];
142
-        		    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
143
-        		    break;
144
-        		}
145
-        	    }
146
-        	} elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) {
147
-        		$airport_icao = $closestAirports[0]['icao'];
148
-        		$airport_time = $this->all_flights[$key]['datetime'];
149
-        	} else {
150
-        		if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
151
-        	}
152
-    	    } else {
153
-    		    if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
154
-    	    }
155
-
156
-        } else {
157
-        	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
158
-        }
159
-        return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
160
-    }
161
-
162
-
163
-
164
-    public function del() {
131
+		$closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
132
+			if (isset($closestAirports[0])) {
133
+			if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
134
+				$airport_icao = $closestAirports[0]['icao'];
135
+				$airport_time = $this->all_flights[$key]['datetime'];
136
+				if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
137
+			} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
138
+				foreach ($closestAirports as $airport) {
139
+				if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
140
+					$airport_icao = $airport['icao'];
141
+					$airport_time = $this->all_flights[$key]['datetime'];
142
+					if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
143
+					break;
144
+				}
145
+				}
146
+			} elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) {
147
+				$airport_icao = $closestAirports[0]['icao'];
148
+				$airport_time = $this->all_flights[$key]['datetime'];
149
+			} else {
150
+				if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
151
+			}
152
+			} else {
153
+				if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
154
+			}
155
+
156
+		} else {
157
+			if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
158
+		}
159
+		return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
160
+	}
161
+
162
+
163
+
164
+	public function del() {
165 165
 	global $globalDebug;
166 166
 	// Delete old infos
167 167
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
168 168
 	foreach ($this->all_flights as $key => $flight) {
169
-    	    if (isset($flight['lastupdate'])) {
170
-        	if ($flight['lastupdate'] < (time()-3000)) {
171
-            	    if (isset($this->all_flights[$key]['id'])) {
172
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
169
+			if (isset($flight['lastupdate'])) {
170
+			if ($flight['lastupdate'] < (time()-3000)) {
171
+					if (isset($this->all_flights[$key]['id'])) {
172
+					if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
173 173
 			/*
174 174
 			$SpotterLive = new SpotterLive();
175 175
             		$SpotterLive->deleteLiveSpotterDataById($this->all_flights[$key]['id']);
176 176
 			$SpotterLive->db = null;
177 177
 			*/
178
-            		$real_arrival = $this->arrival($key);
179
-            		$Spotter = new Spotter($this->db);
180
-            		if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
178
+					$real_arrival = $this->arrival($key);
179
+					$Spotter = new Spotter($this->db);
180
+					if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
181 181
 				$result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
182 182
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
183 183
 			}
184 184
 			// Put in archive
185 185
 //			$Spotter->db = null;
186
-            	    }
187
-            	    unset($this->all_flights[$key]);
188
-    	        }
189
-	    }
190
-        }
191
-    }
192
-
193
-    public function add($line) {
186
+					}
187
+					unset($this->all_flights[$key]);
188
+				}
189
+		}
190
+		}
191
+	}
192
+
193
+	public function add($line) {
194 194
 	global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights;
195 195
 	//if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE;
196 196
 	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
@@ -215,18 +215,18 @@  discard block
 block discarded – undo
215 215
 	
216 216
 	// SBS format is CSV format
217 217
 	if(is_array($line) && isset($line['hex'])) {
218
-	    //print_r($line);
219
-  	    if ($line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6) {
218
+		//print_r($line);
219
+  		if ($line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6) {
220 220
 
221 221
 		// Increment message number
222 222
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
223
-		    $current_date = date('Y-m-d');
224
-		    $source = $line['source_name'];
225
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
226
-		    if (!isset($this->stats[$current_date][$source]['msg'])) {
227
-		    	$this->stats[$current_date][$source]['msg']['date'] = time();
228
-		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
229
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
223
+			$current_date = date('Y-m-d');
224
+			$source = $line['source_name'];
225
+			if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
226
+			if (!isset($this->stats[$current_date][$source]['msg'])) {
227
+				$this->stats[$current_date][$source]['msg']['date'] = time();
228
+				$this->stats[$current_date][$source]['msg']['nb'] = 1;
229
+			} else $this->stats[$current_date][$source]['msg']['nb'] += 1;
230 230
 		}
231 231
 		
232 232
 		/*
@@ -242,17 +242,17 @@  discard block
 block discarded – undo
242 242
 		//$this->db = $dbc;
243 243
 
244 244
 		$hex = trim($line['hex']);
245
-	        if (!isset($line['id'])) $id = trim($line['hex']);
246
-	        else $id = trim($line['id']);
245
+			if (!isset($line['id'])) $id = trim($line['hex']);
246
+			else $id = trim($line['id']);
247 247
 		
248 248
 		//print_r($this->all_flights);
249 249
 		if (!isset($this->all_flights[$id]['hex']) && ctype_xdigit($hex)) {
250
-		    $this->all_flights[$id] = array('hex' => $hex);
251
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
252
-		    //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
250
+			$this->all_flights[$id] = array('hex' => $hex);
251
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
252
+			//if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
253 253
 			//$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
254
-		    //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
255
-		    if (!isset($line['aircraft_name']) && (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????')) {
254
+			//} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
255
+			if (!isset($line['aircraft_name']) && (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????')) {
256 256
 
257 257
 			$timeelapsed = microtime(true);
258 258
 			$Spotter = new Spotter($this->db);
@@ -261,38 +261,38 @@  discard block
 block discarded – undo
261 261
 			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
262 262
 
263 263
 			if ($aircraft_icao == '' && isset($line['aircraft_type'])) {
264
-			    if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID';
265
-			    elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
266
-			    elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
267
-			    elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
264
+				if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID';
265
+				elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
266
+				elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
267
+				elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
268 268
 			}
269 269
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
270
-		    } else if (isset($line['aircraft_name'])) {
270
+			} else if (isset($line['aircraft_name'])) {
271 271
 			// Get aircraft ICAO from aircraft name
272 272
 			$Spotter = new Spotter($this->db);
273 273
 			$aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']);
274 274
 			$Spotter->db = null;
275 275
 			if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
276 276
 			else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
277
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao']));
278
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true));
279
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
280
-		    if (!isset($line['id'])) {
277
+			} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao']));
278
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true));
279
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
280
+			if (!isset($line['id'])) {
281 281
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
282 282
 //			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
283 283
 //			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
284 284
 			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
285
-		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
286
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
285
+				//else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
286
+			 } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
287 287
 
288
-		    if ($globalDebug) echo "*********** New aircraft hex : ".$hex." ***********\n";
289
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
288
+			if ($globalDebug) echo "*********** New aircraft hex : ".$hex." ***********\n";
289
+			if ($globalAllFlights !== FALSE) $dataFound = true;
290 290
 		}
291 291
 		
292 292
 		if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
293
-		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
293
+			if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
294 294
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
295
-		    } else {
295
+			} else {
296 296
 				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
297 297
 				elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
298 298
 				/*
@@ -301,38 +301,38 @@  discard block
 block discarded – undo
301 301
 				print_r($line);
302 302
 				*/
303 303
 				return '';
304
-		    }
304
+			}
305 305
 		} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
306 306
 
307 307
 		if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') {
308
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
308
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
309 309
 		}
310 310
 		if (isset($line['waypoints']) && $line['waypoints'] != '') {
311
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
311
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
312 312
 		}
313 313
 		if (isset($line['pilot_id']) && $line['pilot_id'] != '') {
314
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => $line['pilot_id']));
314
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => $line['pilot_id']));
315 315
 		}
316 316
 		if (isset($line['pilot_name']) && $line['pilot_name'] != '') {
317
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => $line['pilot_name']));
317
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => $line['pilot_name']));
318 318
 		}
319 319
  
320 320
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) {
321
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
322
-		    if ($this->all_flights[$id]['addedSpotter'] == 1) {
321
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
322
+			if ($this->all_flights[$id]['addedSpotter'] == 1) {
323 323
 			$timeelapsed = microtime(true);
324
-            		$Spotter = new Spotter($this->db);
325
-            		$fromsource = NULL;
326
-            		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
327
-            		elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
324
+					$Spotter = new Spotter($this->db);
325
+					$fromsource = NULL;
326
+					if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
327
+					elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
328 328
 			elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
329 329
 			elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
330 330
 			elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
331
-            		$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
331
+					$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
332 332
 			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
333 333
 			$Spotter->db = null;
334 334
 			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
335
-		    }
335
+			}
336 336
 
337 337
 /*
338 338
 		    if (!isset($line['id'])) {
@@ -342,26 +342,26 @@  discard block
 block discarded – undo
342 342
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
343 343
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
344 344
   */
345
-		    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
345
+			if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
346 346
 
347
-		    //$putinarchive = true;
348
-		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
347
+			//$putinarchive = true;
348
+			if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
349 349
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time']));
350
-		    }
351
-		    if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
350
+			}
351
+			if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
352 352
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time']));
353
-		    }
354
-		    if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
355
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
356
-		    } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
353
+			}
354
+			if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
355
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
356
+			} elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
357 357
 				$timeelapsed = microtime(true);
358 358
 				$Spotter = new Spotter($this->db);
359 359
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
360 360
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
361
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
361
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
362 362
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
363 363
 
364
-		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
364
+			} elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
365 365
 			$timeelapsed = microtime(true);
366 366
 			$Spotter = new Spotter($this->db);
367 367
 			$route = $Spotter->getRouteInfo(trim($line['ident']));
@@ -375,43 +375,43 @@  discard block
 block discarded – undo
375 375
 			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
376 376
 
377 377
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
378
-			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
379
-			    if ($route['fromairport_icao'] != $route['toairport_icao']) {
378
+				//if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
379
+				if ($route['fromairport_icao'] != $route['toairport_icao']) {
380 380
 				//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['FromAirport_ICAO'],'arrival_airport' => $route['ToAirport_ICAO'],'route_stop' => $route['RouteStop']));
381
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop']));
382
-		    	    }
381
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop']));
382
+					}
383 383
 			}
384 384
 			if (!isset($globalFork)) $globalFork = TRUE;
385 385
 			if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
386 386
 				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
387 387
 			}
388
-		    }
388
+			}
389 389
 		}
390 390
 
391 391
 		if (isset($line['speed']) && $line['speed'] != '') {
392 392
 		//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12]));
393
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
394
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
395
-		    //$dataFound = true;
393
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
394
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
395
+			//$dataFound = true;
396 396
 		} else if (!isset($this->all_flights[$id]['speed_fromsrc']) && isset($this->all_flights[$id]['time_last_coord']) && $this->all_flights[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
397
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
398
-		    if ($distance > 1000 && $distance < 10000) {
399
-		    // use datetime
397
+			$distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
398
+			if ($distance > 1000 && $distance < 10000) {
399
+			// use datetime
400 400
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
401 401
 			$speed = $speed*3.6;
402 402
 			if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
403 403
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
404
-		    }
404
+			}
405 405
 		}
406 406
 
407 407
 
408 408
 
409
-	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
410
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
411
-	    	    else unset($timediff);
412
-	    	    if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 800 || ($timediff > 10 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) {
409
+			if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
410
+				if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
411
+				else unset($timediff);
412
+				if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 800 || ($timediff > 10 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) {
413 413
 			if (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude'])) {
414
-			    if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
414
+				if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
415 415
 				$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
416 416
 				$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
417 417
 				$this->all_flights[$id]['putinarchive'] = true;
@@ -425,16 +425,16 @@  discard block
 block discarded – undo
425 425
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
426 426
 				$this->tmd = 0;
427 427
 				if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
428
-			    }
428
+				}
429 429
 			}
430 430
 
431 431
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
432
-			    //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
432
+				//if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
433 433
 				if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
434 434
 				if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
435
-				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
436
-				    $dataFound = true;
437
-				    $this->all_flights[$id]['time_last_coord'] = time();
435
+					$this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
436
+					$dataFound = true;
437
+					$this->all_flights[$id]['time_last_coord'] = time();
438 438
 				}
439 439
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
440 440
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude']));
@@ -445,20 +445,20 @@  discard block
 block discarded – undo
445 445
 				    //$putinarchive = true;
446 446
 				}
447 447
 				*/
448
-			    /*
448
+				/*
449 449
 			    } elseif (isset($this->all_flights[$id]['latitude'])) {
450 450
 				if ($globalDebug) echo '!!! Strange latitude value - diff : '.abs($this->all_flights[$id]['latitude']-$line['latitude']).'- previous lat : '.$this->all_flights[$id]['latitude'].'- new lat : '.$line['latitude']."\n";
451 451
 			    }
452 452
 			    */
453 453
 			}
454 454
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
455
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
456
-			    //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == ''  || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
455
+				if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
456
+				//if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == ''  || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
457 457
 				if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
458 458
 				if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
459
-				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
460
-				    $dataFound = true;
461
-				    $this->all_flights[$id]['time_last_coord'] = time();
459
+					$this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
460
+					$dataFound = true;
461
+					$this->all_flights[$id]['time_last_coord'] = time();
462 462
 				}
463 463
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
464 464
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude']));
@@ -476,53 +476,53 @@  discard block
 block discarded – undo
476 476
 			    */
477 477
 			}
478 478
 
479
-		    } else if ($globalDebug && $timediff > 20) {
479
+			} else if ($globalDebug && $timediff > 20) {
480 480
 			$this->tmd = $this->tmd + 1;
481 481
 			echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n";
482 482
 			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -";
483 483
 			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
484 484
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n";
485
-		    }
485
+			}
486 486
 		}
487 487
 		if (isset($line['last_update']) && $line['last_update'] != '') {
488
-		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
489
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
488
+			if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
489
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
490 490
 		}
491 491
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
492
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
493
-		    //$dataFound = true;
492
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
493
+			//$dataFound = true;
494 494
 		}
495 495
 		if (isset($line['format_source']) && $line['format_source'] != '') {
496
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
496
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
497 497
 		}
498 498
 		if (isset($line['source_name']) && $line['source_name'] != '') {
499
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
499
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
500 500
 		}
501 501
 		if (isset($line['emergency']) && $line['emergency'] != '') {
502
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
503
-		    //$dataFound = true;
502
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
503
+			//$dataFound = true;
504 504
 		}
505 505
 		if (isset($line['ground']) && $line['ground'] != '') {
506
-		    if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
506
+			if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
507 507
 			// Here we force archive of flight because after ground it's a new one (or should be)
508 508
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
509 509
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
510 510
 			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi')));
511
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
511
+				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
512 512
 			elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
513
-		    }
514
-		    if ($line['ground'] != 1) $line['ground'] = 0;
515
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
516
-		    //$dataFound = true;
513
+			}
514
+			if ($line['ground'] != 1) $line['ground'] = 0;
515
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
516
+			//$dataFound = true;
517 517
 		}
518 518
 		if (isset($line['squawk']) && $line['squawk'] != '') {
519
-		    if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) {
520
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
521
-			    $highlight = '';
522
-			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
523
-			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
524
-			    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
525
-			    if ($highlight != '') {
519
+			if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) {
520
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
521
+				$highlight = '';
522
+				if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
523
+				if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
524
+				if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
525
+				if ($highlight != '') {
526 526
 				$timeelapsed = microtime(true);
527 527
 				$Spotter = new Spotter($this->db);
528 528
 				$Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
@@ -532,38 +532,38 @@  discard block
 block discarded – undo
532 532
 				$this->all_flights[$id]['putinarchive'] = true;
533 533
 				//$putinarchive = true;
534 534
 				//$highlight = '';
535
-			    }
535
+				}
536 536
 			    
537
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
538
-		    //$dataFound = true;
537
+			} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
538
+			//$dataFound = true;
539 539
 		}
540 540
 
541 541
 		if (isset($line['altitude']) && $line['altitude'] != '') {
542
-		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
542
+			//if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
543 543
 			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 2) $this->all_flights[$id]['putinarchive'] = true;
544 544
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
545 545
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
546 546
 			//$dataFound = true;
547
-		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
547
+			//} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
548 548
   		}
549 549
 
550 550
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
551
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
551
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
552 552
 		}
553 553
 		
554 554
 		if (isset($line['heading']) && $line['heading'] != '') {
555
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 2) $this->all_flights[$id]['putinarchive'] = true;
556
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
557
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
558
-		    //$dataFound = true;
555
+			if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 2) $this->all_flights[$id]['putinarchive'] = true;
556
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
557
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
558
+			//$dataFound = true;
559 559
   		} elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) {
560
-  		    $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
561
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
562
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 2) $this->all_flights[$id]['putinarchive'] = true;
563
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
560
+  			$heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
561
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
562
+			if (abs($this->all_flights[$id]['heading']-round($heading)) > 2) $this->all_flights[$id]['putinarchive'] = true;
563
+  			if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
564 564
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
565
-  		    // If not enough messages and ACARS set heading to 0
566
-  		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
565
+  			// If not enough messages and ACARS set heading to 0
566
+  			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
567 567
   		}
568 568
 		if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
569 569
 		elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
@@ -574,119 +574,119 @@  discard block
 block discarded – undo
574 574
 		//if ($dataFound == true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['ident'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
575 575
 		//if ($dataFound === true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['heading'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
576 576
 		if ($dataFound === true && isset($this->all_flights[$id]['hex'])) {
577
-		    $this->all_flights[$id]['lastupdate'] = time();
578
-		    if ($this->all_flights[$id]['addedSpotter'] == 0) {
579
-		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == ''  || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
580
-			    //print_r($this->all_flights);
581
-			    //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
582
-			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
583
-			    if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
577
+			$this->all_flights[$id]['lastupdate'] = time();
578
+			if ($this->all_flights[$id]['addedSpotter'] == 0) {
579
+				if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == ''  || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
580
+				//print_r($this->all_flights);
581
+				//echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
582
+				//$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
583
+				if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
584 584
 				if ($globalDebug) echo "Check if aircraft is already in DB...";
585 585
 				$timeelapsed = microtime(true);
586 586
 				$SpotterLive = new SpotterLive($this->db);
587 587
 				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) {
588
-				    $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
589
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
588
+					$recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
589
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
590 590
 				} elseif (isset($line['id'])) {
591
-				    $recent_ident = $SpotterLive->checkIdRecent($line['id']);
592
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
591
+					$recent_ident = $SpotterLive->checkIdRecent($line['id']);
592
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
593 593
 				} elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
594
-				    $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
595
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
594
+					$recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
595
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
596 596
 				} else $recent_ident = '';
597 597
 				$SpotterLive->db=null;
598 598
 
599 599
 				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
600 600
 				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
601
-			    } else {
601
+				} else {
602 602
 				$recent_ident = '';
603 603
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
604
-			    }
605
-			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
606
-			    if($recent_ident == "")
607
-			    {
604
+				}
605
+				//if there was no aircraft with the same callsign within the last hour and go post it into the archive
606
+				if($recent_ident == "")
607
+				{
608 608
 				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
609 609
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
610 610
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
611 611
 				//adds the spotter data for the archive
612 612
 				$ignoreImport = false;
613 613
 				foreach($globalAirportIgnore as $airportIgnore) {
614
-				    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
614
+					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
615 615
 					$ignoreImport = true;
616
-				    }
616
+					}
617 617
 				}
618 618
 				if (count($globalAirportAccept) > 0) {
619
-				    $ignoreImport = true;
620
-				    foreach($globalAirportIgnore as $airportIgnore) {
619
+					$ignoreImport = true;
620
+					foreach($globalAirportIgnore as $airportIgnore) {
621 621
 					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
622
-					    $ignoreImport = false;
622
+						$ignoreImport = false;
623
+					}
623 624
 					}
624
-				    }
625 625
 				}
626 626
 				if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
627
-				    foreach($globalAirlineIgnore as $airlineIgnore) {
627
+					foreach($globalAirlineIgnore as $airlineIgnore) {
628 628
 					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
629
-					    $ignoreImport = true;
629
+						$ignoreImport = true;
630
+					}
630 631
 					}
631
-				    }
632 632
 				}
633 633
 				if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
634
-				    $ignoreImport = true;
635
-				    foreach($globalAirlineAccept as $airlineAccept) {
634
+					$ignoreImport = true;
635
+					foreach($globalAirlineAccept as $airlineAccept) {
636 636
 					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
637
-					    $ignoreImport = false;
637
+						$ignoreImport = false;
638
+					}
638 639
 					}
639
-				    }
640 640
 				}
641 641
 				if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
642
-				    $ignoreImport = true;
643
-				    foreach($globalPilotIdAccept as $pilotIdAccept) {
642
+					$ignoreImport = true;
643
+					foreach($globalPilotIdAccept as $pilotIdAccept) {
644 644
 					if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
645
-					    $ignoreImport = false;
645
+						$ignoreImport = false;
646
+					}
646 647
 					}
647
-				    }
648 648
 				}
649 649
 				
650 650
 				if (!$ignoreImport) {
651
-				    $highlight = '';
652
-				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
653
-				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
654
-				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
655
-				    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
656
-				    $timeelapsed = microtime(true);
657
-				    $Spotter = new Spotter($this->db);
658
-				    $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name']);
659
-				    $Spotter->db = null;
660
-				    if ($globalDebug && isset($result)) echo $result."\n";
661
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
651
+					$highlight = '';
652
+					if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
653
+					if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
654
+					if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
655
+					if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
656
+					$timeelapsed = microtime(true);
657
+					$Spotter = new Spotter($this->db);
658
+					$result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name']);
659
+					$Spotter->db = null;
660
+					if ($globalDebug && isset($result)) echo $result."\n";
661
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
662 662
 				    
663
-				    // Add source stat in DB
664
-				    $Stats = new Stats($this->db);
665
-				    if (!empty($this->stats)) {
663
+					// Add source stat in DB
664
+					$Stats = new Stats($this->db);
665
+					if (!empty($this->stats)) {
666 666
 					if ($globalDebug) echo 'Add source stats : ';
667
-				        foreach($this->stats as $date => $data) {
668
-					    foreach($data as $source => $sourced) {
669
-					        //print_r($sourced);
670
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
671
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
672
-				    		if (isset($sourced['msg'])) {
673
-				    		    if (time() - $sourced['msg']['date'] > 10) {
674
-				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
675
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
676
-			    			        unset($this->stats[$date][$source]['msg']);
677
-			    			    }
678
-			    			}
679
-			    		    }
680
-			    		    if ($date != date('Y-m-d')) {
681
-			    			unset($this->stats[$date]);
682
-			    		    }
683
-				    	}
684
-				    	if ($globalDebug) echo 'Done'."\n";
685
-
686
-				    }
687
-				    $Stats->db = null;
667
+						foreach($this->stats as $date => $data) {
668
+						foreach($data as $source => $sourced) {
669
+							//print_r($sourced);
670
+								if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
671
+								if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
672
+							if (isset($sourced['msg'])) {
673
+								if (time() - $sourced['msg']['date'] > 10) {
674
+									$nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
675
+									echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
676
+									unset($this->stats[$date][$source]['msg']);
677
+								}
678
+							}
679
+							}
680
+							if ($date != date('Y-m-d')) {
681
+							unset($this->stats[$date]);
682
+							}
683
+						}
684
+						if ($globalDebug) echo 'Done'."\n";
685
+
686
+					}
687
+					$Stats->db = null;
688 688
 				    
689
-				    $this->del();
689
+					$this->del();
690 690
 				} elseif ($globalDebug) echo 'Ignore data'."\n";
691 691
 				//$ignoreImport = false;
692 692
 				$this->all_flights[$id]['addedSpotter'] = 1;
@@ -704,18 +704,18 @@  discard block
 block discarded – undo
704 704
 			*/
705 705
 			//SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']);
706 706
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
707
-				    if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
708
-				    //SpotterLive->deleteLiveSpotterDataNotUpdated();
709
-				    $SpotterLive = new SpotterLive($this->db);
710
-				    $SpotterLive->deleteLiveSpotterData();
711
-				    $SpotterLive->db=null;
712
-				    if ($globalDebug) echo " Done\n";
713
-				    $this->last_delete = time();
707
+					if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
708
+					//SpotterLive->deleteLiveSpotterDataNotUpdated();
709
+					$SpotterLive = new SpotterLive($this->db);
710
+					$SpotterLive->deleteLiveSpotterData();
711
+					$SpotterLive->db=null;
712
+					if ($globalDebug) echo " Done\n";
713
+					$this->last_delete = time();
714 714
 				}
715
-			    } else {
715
+				} else {
716 716
 				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa'  || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson')) {
717
-				    $this->all_flights[$id]['id'] = $recent_ident;
718
-				    $this->all_flights[$id]['addedSpotter'] = 1;
717
+					$this->all_flights[$id]['id'] = $recent_ident;
718
+					$this->all_flights[$id]['addedSpotter'] = 1;
719 719
 				}
720 720
 				if (isset($globalDaemon) && !$globalDaemon) {
721 721
 					$Spotter = new Spotter($this->db);
@@ -723,14 +723,14 @@  discard block
 block discarded – undo
723 723
 					$Spotter->db = null;
724 724
 				}
725 725
 				
726
-			    }
726
+				}
727
+			}
727 728
 			}
728
-		    }
729
-		    //adds the spotter LIVE data
730
-		    //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed);
731
-		    //echo "\nAdd in Live !! \n";
732
-		    //echo "{$line[8]} {$line[7]} - MODES:{$line[4]}  CALLSIGN:{$line[10]}   ALT:{$line[11]}   VEL:{$line[12]}   HDG:{$line[13]}   LAT:{$line[14]}   LON:{$line[15]}   VR:{$line[16]}   SQUAWK:{$line[17]}\n";
733
-		    if ($globalDebug) {
729
+			//adds the spotter LIVE data
730
+			//SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed);
731
+			//echo "\nAdd in Live !! \n";
732
+			//echo "{$line[8]} {$line[7]} - MODES:{$line[4]}  CALLSIGN:{$line[10]}   ALT:{$line[11]}   VEL:{$line[12]}   HDG:{$line[13]}   LAT:{$line[14]}   LON:{$line[15]}   VR:{$line[16]}   SQUAWK:{$line[17]}\n";
733
+			if ($globalDebug) {
734 734
 			if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) {
735 735
 				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n";
736 736
 				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n";
@@ -738,49 +738,49 @@  discard block
 block discarded – undo
738 738
 				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n";
739 739
 				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n";
740 740
 			}
741
-		    }
742
-		    $ignoreImport = false;
743
-		    if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
744
-		    if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
741
+			}
742
+			$ignoreImport = false;
743
+			if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
744
+			if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
745 745
 
746
-		    foreach($globalAirportIgnore as $airportIgnore) {
747
-		        if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
748
-			    $ignoreImport = true;
746
+			foreach($globalAirportIgnore as $airportIgnore) {
747
+				if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
748
+				$ignoreImport = true;
749
+			}
749 750
 			}
750
-		    }
751
-		    if (count($globalAirportAccept) > 0) {
752
-		        $ignoreImport = true;
753
-		        foreach($globalAirportIgnore as $airportIgnore) {
754
-			    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
751
+			if (count($globalAirportAccept) > 0) {
752
+				$ignoreImport = true;
753
+				foreach($globalAirportIgnore as $airportIgnore) {
754
+				if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
755 755
 				$ignoreImport = false;
756
-			    }
756
+				}
757 757
 			}
758
-		    }
759
-		    if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
758
+			}
759
+			if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
760 760
 			foreach($globalAirlineIgnore as $airlineIgnore) {
761
-			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
761
+				if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
762 762
 				$ignoreImport = true;
763
-			    }
763
+				}
764 764
 			}
765
-		    }
766
-		    if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
765
+			}
766
+			if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
767 767
 			$ignoreImport = true;
768 768
 			foreach($globalAirlineAccept as $airlineAccept) {
769
-			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
769
+				if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
770 770
 				$ignoreImport = false;
771
-			    }
771
+				}
772 772
 			}
773
-		    }
774
-		    if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
773
+			}
774
+			if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
775 775
 			$ignoreImport = true;
776 776
 			foreach($globalPilotIdAccept as $pilotIdAccept) {
777
-			    if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
778
-			        $ignoreImport = false;
779
-			    }
777
+				if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
778
+					$ignoreImport = false;
779
+				}
780
+			}
780 781
 			}
781
-		    }
782 782
 
783
-		    if (!$ignoreImport) {
783
+			if (!$ignoreImport) {
784 784
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
785 785
 				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
786 786
 				$timeelapsed = microtime(true);
@@ -818,7 +818,7 @@  discard block
 block discarded – undo
818 818
 					if ($stats_heading == 16) $stats_heading = 0;
819 819
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
820 820
 						for ($i=0;$i<=15;$i++) {
821
-						    $this->stats[$current_date][$source]['polar'][$i] = 0;
821
+							$this->stats[$current_date][$source]['polar'][$i] = 0;
822 822
 						}
823 823
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
824 824
 					} else {
@@ -831,11 +831,11 @@  discard block
 block discarded – undo
831 831
 					//var_dump($this->stats);
832 832
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
833 833
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
834
-						    end($this->stats[$current_date][$source]['hist']);
835
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
834
+							end($this->stats[$current_date][$source]['hist']);
835
+							$mini = key($this->stats[$current_date][$source]['hist'])+10;
836 836
 						} else $mini = 0;
837 837
 						for ($i=$mini;$i<=$distance;$i+=10) {
838
-						    $this->stats[$current_date][$source]['hist'][$i] = 0;
838
+							$this->stats[$current_date][$source]['hist'][$i] = 0;
839 839
 						}
840 840
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
841 841
 					} else {
@@ -852,22 +852,22 @@  discard block
 block discarded – undo
852 852
 			
853 853
 			
854 854
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
855
-			    if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour...";
856
-			    $SpotterLive = new SpotterLive($this->db);
857
-			    $SpotterLive->deleteLiveSpotterDataNotUpdated();
858
-			    $SpotterLive->db = null;
859
-			    //SpotterLive->deleteLiveSpotterData();
860
-			    if ($globalDebug) echo " Done\n";
861
-			    $this->last_delete_hourly = time();
855
+				if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour...";
856
+				$SpotterLive = new SpotterLive($this->db);
857
+				$SpotterLive->deleteLiveSpotterDataNotUpdated();
858
+				$SpotterLive->db = null;
859
+				//SpotterLive->deleteLiveSpotterData();
860
+				if ($globalDebug) echo " Done\n";
861
+				$this->last_delete_hourly = time();
862 862
 			}
863 863
 			
864
-		    }
865
-		    //$ignoreImport = false;
864
+			}
865
+			//$ignoreImport = false;
866 866
 		}
867 867
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
868 868
 		if ($send) return $this->all_flights[$id];
869
-	    }
869
+		}
870
+	}
870 871
 	}
871
-    }
872 872
 }
873 873
 ?>
Please login to merge, or discard this patch.
statistics.php 1 patch
Indentation   +179 added lines, -179 removed lines patch added patch discarded remove patch
@@ -39,11 +39,11 @@  discard block
 block discarded – undo
39 39
 		if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone);
40 40
 		print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>';
41 41
 	}
42
-    ?>
42
+	?>
43 43
     </div>
44 44
     <?php    
45 45
 	// print_r($Stats->getAllAirlineNames()); 
46
-    ?>
46
+	?>
47 47
     <?php include('statistics-sub-menu.php'); ?>
48 48
     <p class="global-stats">
49 49
         <span><span class="badge"><?php print number_format($Stats->countOverallFlights($airline_icao,$filter_name)); ?></span> <?php echo _("Flights"); ?></span>
@@ -51,23 +51,23 @@  discard block
 block discarded – undo
51 51
         <span><span class="badge"><?php print number_format($Stats->countOverallArrival($airline_icao,$filter_name)); ?></span> <?php echo _("Arrivals seen"); ?></span>
52 52
         <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
53 53
 	<?php
54
-	    if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
54
+		if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
55 55
 	?>
56 56
     	    <span><span class="badge"><?php print number_format($Stats->countOverallPilots($airline_icao,$filter_name)); ?></span> <?php echo _("Pilots"); ?></span>
57 57
 	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
58 58
         <?php
59
-    	    } else {
60
-    	?>
59
+			} else {
60
+		?>
61 61
     	    <span><span class="badge"><?php print number_format($Stats->countOverallOwners($airline_icao,$filter_name)); ?></span> <?php echo _("Owners"); ?></span>
62 62
 	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
63 63
     	<?php
64
-    	    }
65
-    	?>
64
+			}
65
+		?>
66 66
         <span><span class="badge"><?php print number_format($Stats->countOverallAircrafts($airline_icao,$filter_name)); ?></span> <?php echo _("Aircrafts"); ?></span>
67 67
         <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
68 68
         <?php
69
-    		if ($airline_icao == '') {
70
-    	?>
69
+			if ($airline_icao == '') {
70
+		?>
71 71
         <span><span class="badge"><?php print number_format($Stats->countOverallAirlines($filter_name)); ?></span> <?php echo _("Airlines"); ?></span>
72 72
 	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
73 73
 	<?php
@@ -88,25 +88,25 @@  discard block
 block discarded – undo
88 88
             <div class="col-md-6">
89 89
                 <h2><?php echo _("Top 10 Most Common Aircraft Type"); ?></h2>
90 90
                  <?php
91
-                  $aircraft_array = $Stats->countAllAircraftTypes(true,$airline_icao,$filter_name);
92
-		    if (count($aircraft_array) == 0) print _("No data available");
93
-		    else {
91
+				  $aircraft_array = $Stats->countAllAircraftTypes(true,$airline_icao,$filter_name);
92
+			if (count($aircraft_array) == 0) print _("No data available");
93
+			else {
94 94
 
95
-                    print '<div id="chart1" class="chart" width="100%"></div>
95
+					print '<div id="chart1" class="chart" width="100%"></div>
96 96
                     <script> 
97 97
                         google.load("visualization", "1", {packages:["corechart"]});
98 98
                       google.setOnLoadCallback(drawChart1);
99 99
                       function drawChart1() {
100 100
                         var data = google.visualization.arrayToDataTable([
101 101
                             ["'._("Aircraft").'", "'._("# of times").'"], ';
102
-                            $aircraft_data = '';
103
-                          foreach($aircraft_array as $aircraft_item)
104
-                                    {
105
-                                            $aircraft_data .= '[ "'.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
106
-                                    }
107
-                                    $aircraft_data = substr($aircraft_data, 0, -1);
108
-                                    print $aircraft_data;
109
-                        print ']);
102
+							$aircraft_data = '';
103
+						  foreach($aircraft_array as $aircraft_item)
104
+									{
105
+											$aircraft_data .= '[ "'.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
106
+									}
107
+									$aircraft_data = substr($aircraft_data, 0, -1);
108
+									print $aircraft_data;
109
+						print ']);
110 110
 
111 111
                         var options = {
112 112
                             chartArea: {"width": "80%", "height": "60%"},
@@ -121,8 +121,8 @@  discard block
 block discarded – undo
121 121
                               drawChart1();
122 122
                             });
123 123
                   </script>';
124
-                  }
125
-                  ?>
124
+				  }
125
+				  ?>
126 126
                 <div class="more">
127 127
                     <a href="<?php print $globalURL; ?>/statistics/aircraft" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
128 128
                 </div>
@@ -130,26 +130,26 @@  discard block
 block discarded – undo
130 130
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
131 131
 <?php
132 132
 //    echo $airline_icao;
133
-    if ($airline_icao == '' || $airline_icao == 'all') {
133
+	if ($airline_icao == '' || $airline_icao == 'all') {
134 134
 	$airline_array = $Stats->countAllAirlines(true,$filter_name);
135 135
 	if (count($airline_array) > 0) {
136
-            print '<div class="col-md-6">';
137
-	    print '<h2>'._("Top 10 Most Common Airline").'</h2>';
138
-	    print '<div id="chart2" class="chart" width="100%"></div>
136
+			print '<div class="col-md-6">';
137
+		print '<h2>'._("Top 10 Most Common Airline").'</h2>';
138
+		print '<div id="chart2" class="chart" width="100%"></div>
139 139
                     <script> 
140 140
                         google.load("visualization", "1", {packages:["corechart"]});
141 141
                       google.setOnLoadCallback(drawChart2);
142 142
                       function drawChart2() {
143 143
                         var data = google.visualization.arrayToDataTable([
144 144
                             ["'._("Airline").'", "'._("# of times").'"], ';
145
-	    $airline_data = '';
146
-	    foreach($airline_array as $airline_item)
147
-	    {
145
+		$airline_data = '';
146
+		foreach($airline_array as $airline_item)
147
+		{
148 148
 		$airline_data .= '[ "'.$airline_item['airline_name'].' ('.$airline_item['airline_icao'].')",'.$airline_item['airline_count'].'],';
149
-	    }
150
-	    $airline_data = substr($airline_data, 0, -1);
151
-	    print $airline_data;
152
-	    print ']);
149
+		}
150
+		$airline_data = substr($airline_data, 0, -1);
151
+		print $airline_data;
152
+		print ']);
153 153
 
154 154
                         var options = {
155 155
                             chartArea: {"width": "80%", "height": "60%"},
@@ -164,23 +164,23 @@  discard block
 block discarded – undo
164 164
                               drawChart2();
165 165
                             });
166 166
                   </script>';
167
-	    print '<div class="more"><a href="'.$globalURL.'/statistics/airline" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
168
-    	    print '</div>';
167
+		print '<div class="more"><a href="'.$globalURL.'/statistics/airline" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
168
+			print '</div>';
169 169
 	}
170 170
 ?>
171 171
         </div>
172 172
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
173 173
 <?php
174
-    }
174
+	}
175 175
 ?>
176 176
         <div class="row column">
177 177
 <?php
178
-    $flightover_array = $Stats->countAllFlightOverCountries($airline_icao,$filter_name);
179
-    if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
178
+	$flightover_array = $Stats->countAllFlightOverCountries($airline_icao,$filter_name);
179
+	if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
180 180
 	if (empty($flightover_array)) {
181
-	    print '<div class="col-md-12">';
181
+		print '<div class="col-md-12">';
182 182
 	} else {
183
-            print '<div class="col-md-6">';
183
+			print '<div class="col-md-6">';
184 184
 	}
185 185
 ?>
186 186
                 <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2>
@@ -188,21 +188,21 @@  discard block
 block discarded – undo
188 188
 	$pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name);
189 189
 	if (count($pilot_array) == 0) print _("No data available");
190 190
 	else {
191
-	    print '<div id="chart7" class="chart" width="100%"></div>
191
+		print '<div id="chart7" class="chart" width="100%"></div>
192 192
                     <script> 
193 193
                         google.load("visualization", "1", {packages:["corechart"]});
194 194
                       google.setOnLoadCallback(drawChart7);
195 195
                       function drawChart7() {
196 196
                         var data = google.visualization.arrayToDataTable([
197 197
                             ["'._("Pilots").'", "'._("# of times").'"], ';
198
-	    $pilot_data = '';
199
-	    foreach($pilot_array as $pilot_item)
200
-	    {
198
+		$pilot_data = '';
199
+		foreach($pilot_array as $pilot_item)
200
+		{
201 201
 		$pilot_data .= '[ "'.$pilot_item['pilot_name'].' ('.$pilot_item['pilot_id'].')",'.$pilot_item['pilot_count'].'],';
202
-	    }
203
-	    $pilot_data = substr($pilot_data, 0, -1);
204
-	    print $pilot_data;
205
-	    print ']);
202
+		}
203
+		$pilot_data = substr($pilot_data, 0, -1);
204
+		print $pilot_data;
205
+		print ']);
206 206
 
207 207
                         var options = {
208 208
                             chartArea: {"width": "80%", "height": "60%"},
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
                               drawChart7();
218 218
                             });
219 219
                   </script>';
220
-        }
220
+		}
221 221
 ?>
222 222
                 <div class="more">
223 223
                     <a href="<?php print $globalURL; ?>/statistics/pilot" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
         
227 227
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
228 228
 <?php
229
-    } else {
229
+	} else {
230 230
 ?>
231 231
             <div class="col-md-6">
232 232
                 <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
@@ -234,21 +234,21 @@  discard block
 block discarded – undo
234 234
 	$owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name);
235 235
 	if (count($owner_array) == 0) print _("No data available");
236 236
 	else {
237
-	    print '<div id="chart7" class="chart" width="100%"></div>
237
+		print '<div id="chart7" class="chart" width="100%"></div>
238 238
                     <script> 
239 239
                         google.load("visualization", "1", {packages:["corechart"]});
240 240
                       google.setOnLoadCallback(drawChart7);
241 241
                       function drawChart7() {
242 242
                         var data = google.visualization.arrayToDataTable([
243 243
                             ["'._("Owner").'", "'._("# of times").'"], ';
244
-                            $owner_data = '';
245
-	    foreach($owner_array as $owner_item)
246
-	    {
244
+							$owner_data = '';
245
+		foreach($owner_array as $owner_item)
246
+		{
247 247
 		$owner_data .= '[ "'.$owner_item['owner_name'].'",'.$owner_item['owner_count'].'],';
248
-	    }
249
-	    $owner_data = substr($owner_data, 0, -1);
250
-	    print $owner_data;
251
-	    print ']);
248
+		}
249
+		$owner_data = substr($owner_data, 0, -1);
250
+		print $owner_data;
251
+		print ']);
252 252
 
253 253
                         var options = {
254 254
                             chartArea: {"width": "80%", "height": "60%"},
@@ -272,8 +272,8 @@  discard block
 block discarded – undo
272 272
         
273 273
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
274 274
 <?php
275
-    }
276
-    if (!empty($flightover_array)) {
275
+	}
276
+	if (!empty($flightover_array)) {
277 277
 ?>
278 278
             <div class="col-md-6">
279 279
                 <h2><?php echo _("Top 20 Most Common Country a Flight was Over"); ?></h2>
@@ -281,21 +281,21 @@  discard block
 block discarded – undo
281 281
 	 //$flightover_array = $Stats->countAllFlightOverCountries();
282 282
 	if (count($flightover_array) == 0) print _("No data available");
283 283
 	else {
284
-	    print '<div id="chart10" class="chart" width="100%"></div>
284
+		print '<div id="chart10" class="chart" width="100%"></div>
285 285
                     <script> 
286 286
                         google.load("visualization", "1", {packages:["corechart"]});
287 287
                       google.setOnLoadCallback(drawChart10);
288 288
                       function drawChart10() {
289 289
                         var data = google.visualization.arrayToDataTable([
290 290
                             ["'._("Country").'", "'._("# of times").'"], ';
291
-                            $flightover_data = '';
292
-	    foreach($flightover_array as $flightover_item)
293
-	    {
291
+							$flightover_data = '';
292
+		foreach($flightover_array as $flightover_item)
293
+		{
294 294
 		$flightover_data .= '[ "'.$flightover_item['flight_country'].' ('.$flightover_item['flight_country_iso2'].')",'.$flightover_item['flight_count'].'],';
295
-	    }
296
-	    $flightover_data = substr($flightover_data, 0, -1);
297
-	    print $flightover_data;
298
-	    print ']);
295
+		}
296
+		$flightover_data = substr($flightover_data, 0, -1);
297
+		print $flightover_data;
298
+		print ']);
299 299
 
300 300
                         var options = {
301 301
                             chartArea: {"width": "80%", "height": "60%"},
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
                 </div>
320 320
             </div>
321 321
 <?php
322
-    }
322
+	}
323 323
 ?>
324 324
         </div>
325 325
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -329,8 +329,8 @@  discard block
 block discarded – undo
329 329
         <div class="row column">
330 330
             <div class="col-md-6">
331 331
 <?php
332
-    $airport_airport_array = $Stats->countAllDepartureAirports(true,$airline_icao,$filter_name);
333
-    if (count($airport_airport_array) > 0) {
332
+	$airport_airport_array = $Stats->countAllDepartureAirports(true,$airline_icao,$filter_name);
333
+	if (count($airport_airport_array) > 0) {
334 334
 	print '<h2>'._("Top 10 Most Common Departure Airports").'</h2>';
335 335
 	print '<div id="chart3" class="chart" width="100%"></div>
336 336
                 <script>
@@ -343,13 +343,13 @@  discard block
 block discarded – undo
343 343
 
344 344
                 var data = google.visualization.arrayToDataTable([ 
345 345
                     ["'._("Airport").'", "'._("# of times").'"],';
346
-                    $airport_data = '';
346
+					$airport_data = '';
347 347
 	foreach($airport_airport_array as $airport_item)
348 348
 	{
349
-	    $name = $airport_item['airport_departure_city'].', '.$airport_item['airport_departure_country'].' ('.$airport_item['airport_departure_icao'].')';
350
-	    $name = str_replace("'", "", $name);
351
-	    $name = str_replace('"', "", $name);
352
-	    $airport_data .= '[ "'.$name.'",'.$airport_item['airport_departure_icao_count'].'],';
349
+		$name = $airport_item['airport_departure_city'].', '.$airport_item['airport_departure_country'].' ('.$airport_item['airport_departure_icao'].')';
350
+		$name = str_replace("'", "", $name);
351
+		$name = str_replace('"', "", $name);
352
+		$airport_data .= '[ "'.$name.'",'.$airport_item['airport_departure_icao_count'].'],';
353 353
 	}
354 354
 	$airport_data = substr($airport_data, 0, -1);
355 355
 	print $airport_data;
@@ -368,15 +368,15 @@  discard block
 block discarded – undo
368 368
               }
369 369
                 </script>';
370 370
 	print '<div class="more"><a href="'.$globalURL.'/statistics/airport-departure" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
371
-    }
371
+	}
372 372
 ?>
373 373
             </div>
374 374
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
375 375
 
376 376
             <div class="col-md-6">
377 377
 <?php
378
-    $airport_airport_array2 = $Stats->countAllArrivalAirports(true,$airline_icao,$filter_name);
379
-    if (count($airport_airport_array2) > 0) {
378
+	$airport_airport_array2 = $Stats->countAllArrivalAirports(true,$airline_icao,$filter_name);
379
+	if (count($airport_airport_array2) > 0) {
380 380
 	print '<h2>'._("Top 10 Most Common Arrival Airports").'</h2>';
381 381
 	print '<div id="chart4" class="chart" width="100%"></div>
382 382
                 <script>
@@ -392,9 +392,9 @@  discard block
 block discarded – undo
392 392
 	$airport_data2 = '';
393 393
 	foreach($airport_airport_array2 as $airport_item2)
394 394
 	{
395
-	    $name2 = $airport_item2['airport_arrival_city'].', '.$airport_item2['airport_arrival_country'].' ('.$airport_item2['airport_arrival_icao'].')';
396
-	    $name2 = str_replace(array("'",'"'), '', $name2);
397
-	    $airport_data2 .= '[ "'.$name2.'",'.$airport_item2['airport_arrival_icao_count'].'],';
395
+		$name2 = $airport_item2['airport_arrival_city'].', '.$airport_item2['airport_arrival_country'].' ('.$airport_item2['airport_arrival_icao'].')';
396
+		$name2 = str_replace(array("'",'"'), '', $name2);
397
+		$airport_data2 .= '[ "'.$name2.'",'.$airport_item2['airport_arrival_icao_count'].'],';
398 398
 	}
399 399
 	$airport_data2 = substr($airport_data2, 0, -1);
400 400
 	print $airport_data2;
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
               }
414 414
                 </script>';
415 415
 	print '<div class="more"><a href="'.$globalURL.'/statistics/airport-arrival" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
416
-    }
416
+	}
417 417
 ?>
418 418
             </div>
419 419
         </div>
@@ -423,24 +423,24 @@  discard block
 block discarded – undo
423 423
             <div class="col-md-6">
424 424
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
425 425
                 <?php
426
-                  $year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
427
-		    if (count($year_array) == 0) print _("No data available");
428
-		    else {
429
-                  print '<div id="chart8" class="chart" width="100%"></div>
426
+				  $year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
427
+			if (count($year_array) == 0) print _("No data available");
428
+			else {
429
+				  print '<div id="chart8" class="chart" width="100%"></div>
430 430
                     <script> 
431 431
                         google.load("visualization", "1", {packages:["corechart"]});
432 432
                       google.setOnLoadCallback(drawChart8);
433 433
                       function drawChart8() {
434 434
                         var data = google.visualization.arrayToDataTable([
435 435
                             ["'._("Month").'", "'._("# of Flights").'"], ';
436
-                            $year_data = '';
437
-                          foreach($year_array as $year_item)
438
-                                    {
439
-                                        $year_data .= '[ "'.date('F, Y',strtotime($year_item['year_name'].'-'.$year_item['month_name'].'-01')).'",'.$year_item['date_count'].'],';
440
-                                    }
441
-                                    $year_data = substr($year_data, 0, -1);
442
-                                    print $year_data;
443
-                        print ']);
436
+							$year_data = '';
437
+						  foreach($year_array as $year_item)
438
+									{
439
+										$year_data .= '[ "'.date('F, Y',strtotime($year_item['year_name'].'-'.$year_item['month_name'].'-01')).'",'.$year_item['date_count'].'],';
440
+									}
441
+									$year_data = substr($year_data, 0, -1);
442
+									print $year_data;
443
+						print ']);
444 444
 
445 445
                         var options = {
446 446
                             legend: {position: "none"},
@@ -458,8 +458,8 @@  discard block
 block discarded – undo
458 458
                               drawChart8();
459 459
                             });
460 460
                   </script>';
461
-                  }
462
-                  ?>
461
+				  }
462
+				  ?>
463 463
                 <div class="more">
464 464
                     <a href="<?php print $globalURL; ?>/statistics/year" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
465 465
                 </div>
@@ -469,24 +469,24 @@  discard block
 block discarded – undo
469 469
             <div class="col-md-6">
470 470
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
471 471
                 <?php
472
-                  $month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
473
-		    if (count($month_array) == 0) print _("No data available");
474
-		    else {
475
-                  print '<div id="chart9" class="chart" width="100%"></div>
472
+				  $month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
473
+			if (count($month_array) == 0) print _("No data available");
474
+			else {
475
+				  print '<div id="chart9" class="chart" width="100%"></div>
476 476
                     <script> 
477 477
                         google.load("visualization", "1", {packages:["corechart"]});
478 478
                       google.setOnLoadCallback(drawChart9);
479 479
                       function drawChart9() {
480 480
                         var data = google.visualization.arrayToDataTable([
481 481
                             ["'._("Day").'", "'._("# of Flights").'"], ';
482
-                            $month_data = '';
483
-                          foreach($month_array as $month_item)
484
-                                    {
485
-                                        $month_data .= '[ "'.date('F j, Y',strtotime($month_item['date_name'])).'",'.$month_item['date_count'].'],';
486
-                                    }
487
-                                    $month_data = substr($month_data, 0, -1);
488
-                                    print $month_data;
489
-                        print ']);
482
+							$month_data = '';
483
+						  foreach($month_array as $month_item)
484
+									{
485
+										$month_data .= '[ "'.date('F j, Y',strtotime($month_item['date_name'])).'",'.$month_item['date_count'].'],';
486
+									}
487
+									$month_data = substr($month_data, 0, -1);
488
+									print $month_data;
489
+						print ']);
490 490
 
491 491
                         var options = {
492 492
                             legend: {position: "none"},
@@ -504,8 +504,8 @@  discard block
 block discarded – undo
504 504
                               drawChart9();
505 505
                             });
506 506
                   </script>';
507
-                  }
508
-                  ?>
507
+				  }
508
+				  ?>
509 509
                 <div class="more">
510 510
                     <a href="<?php print $globalURL; ?>/statistics/month" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
511 511
                 </div>
@@ -515,25 +515,25 @@  discard block
 block discarded – undo
515 515
             <div class="col-md-6">
516 516
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
517 517
                 <?php
518
-                    $date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
519
-		    if (empty($date_array)) print _("No data available");
520
-		    else {
521
-                  print '<div id="chart5" class="chart" width="100%"></div>
518
+					$date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
519
+			if (empty($date_array)) print _("No data available");
520
+			else {
521
+				  print '<div id="chart5" class="chart" width="100%"></div>
522 522
                     <script> 
523 523
                         google.load("visualization", "1", {packages:["corechart"]});
524 524
                       google.setOnLoadCallback(drawChart5);
525 525
                       function drawChart5() {
526 526
                         var data = google.visualization.arrayToDataTable([
527 527
                             ["'._("Date").'", "'._("# of Flights").'"], ';
528
-                            $date_data = '';
528
+							$date_data = '';
529 529
                         
530
-                          foreach($date_array as $date_item)
531
-                                    {
532
-                                        $date_data .= '[ "'.date("F j, Y", strtotime($date_item['date_name'])).'",'.$date_item['date_count'].'],';
533
-                                    }
534
-                                    $date_data = substr($date_data, 0, -1);
535
-                                    print $date_data;
536
-                        print ']);
530
+						  foreach($date_array as $date_item)
531
+									{
532
+										$date_data .= '[ "'.date("F j, Y", strtotime($date_item['date_name'])).'",'.$date_item['date_count'].'],';
533
+									}
534
+									$date_data = substr($date_data, 0, -1);
535
+									print $date_data;
536
+						print ']);
537 537
 
538 538
                         var options = {
539 539
                             legend: {position: "none"},
@@ -551,8 +551,8 @@  discard block
 block discarded – undo
551 551
                               drawChart5();
552 552
                             });
553 553
                   </script>';
554
-                  }
555
-                  ?>
554
+				  }
555
+				  ?>
556 556
                 <div class="more">
557 557
                     <a href="<?php print $globalURL; ?>/statistics/date" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
558 558
                 </div>
@@ -562,25 +562,25 @@  discard block
 block discarded – undo
562 562
             <div class="col-md-6">
563 563
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
564 564
                 <?php
565
-                  $hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
566
-		    if (empty($hour_array)) print _("No data available");
567
-		    else {
565
+				  $hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
566
+			if (empty($hour_array)) print _("No data available");
567
+			else {
568 568
 
569
-                  print '<div id="chart6" class="chart" width="100%"></div>
569
+				  print '<div id="chart6" class="chart" width="100%"></div>
570 570
                     <script> 
571 571
                         google.load("visualization", "1", {packages:["corechart"]});
572 572
                       google.setOnLoadCallback(drawChart6);
573 573
                       function drawChart6() {
574 574
                         var data = google.visualization.arrayToDataTable([
575 575
                             ["'._("Hour").'", "'._("# of Flights").'"], ';
576
-                            $hour_data = '';
577
-                          foreach($hour_array as $hour_item)
578
-                                    {
579
-                                        $hour_data .= '[ "'.$hour_item['hour_name'].':00",'.$hour_item['hour_count'].'],';
580
-                                    }
581
-                                    $hour_data = substr($hour_data, 0, -1);
582
-                                    print $hour_data;
583
-                        print ']);
576
+							$hour_data = '';
577
+						  foreach($hour_array as $hour_item)
578
+									{
579
+										$hour_data .= '[ "'.$hour_item['hour_name'].':00",'.$hour_item['hour_count'].'],';
580
+									}
581
+									$hour_data = substr($hour_data, 0, -1);
582
+									print $hour_data;
583
+						print ']);
584 584
 
585 585
                         var options = {
586 586
                             legend: {position: "none"},
@@ -598,8 +598,8 @@  discard block
 block discarded – undo
598 598
                               drawChart6();
599 599
                             });
600 600
                   </script>';
601
-                  }
602
-                ?>
601
+				  }
602
+				?>
603 603
                 <div class="more">
604 604
                     <a href="<?php print $globalURL; ?>/statistics/time" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
605 605
                 </div>
@@ -607,21 +607,21 @@  discard block
 block discarded – undo
607 607
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
608 608
         </div>
609 609
 <?php
610
-    if (($airline_icao == '' || $airline_icao == 'all') && $filter_name == '') {
610
+	if (($airline_icao == '' || $airline_icao == 'all') && $filter_name == '') {
611 611
 ?>
612 612
         <div class="row column">
613 613
         	<?php
614
-        	    $polar = $Stats->getStatsSource(date('Y-m-d'),'polar');
615
-        	    if (!empty($polar)) {
616
-            		print '<h2>'._("Coverage pattern").'</h2>';
617
-        		foreach ($polar as $eachpolar) {
618
-        		    unset($polar_data);
619
-	        	    $Spotter = new Spotter();
620
-        		    $data = json_decode($eachpolar['source_data']);
621
-        		    foreach($data as $value => $key) {
622
-        			$direction = $Spotter->parseDirection(($value*22.5));
623
-        			$distance = $key;
624
-        			$unit = 'km';
614
+				$polar = $Stats->getStatsSource(date('Y-m-d'),'polar');
615
+				if (!empty($polar)) {
616
+					print '<h2>'._("Coverage pattern").'</h2>';
617
+				foreach ($polar as $eachpolar) {
618
+					unset($polar_data);
619
+					$Spotter = new Spotter();
620
+					$data = json_decode($eachpolar['source_data']);
621
+					foreach($data as $value => $key) {
622
+					$direction = $Spotter->parseDirection(($value*22.5));
623
+					$distance = $key;
624
+					$unit = 'km';
625 625
 				if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
626 626
 					$distance = round($distance*0.539957);
627 627
 					$unit = 'nm';
@@ -632,10 +632,10 @@  discard block
 block discarded – undo
632 632
 					$distance = $distance;
633 633
 					$unit = 'km';
634 634
 				}
635
-        			if (!isset($polar_data)) $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
636
-        	    		else $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
637
-        		    }
638
-        	?>
635
+					if (!isset($polar_data)) $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
636
+						else $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
637
+					}
638
+			?>
639 639
             <div class="col-md-6">
640 640
                 <h4><?php print $eachpolar['source_name']; ?></h4>
641 641
         	<div id="polar-<?php print str_replace(' ','_',strtolower($eachpolar['source_name'])); ?>" class="chart" width="100%"></div>
@@ -667,22 +667,22 @@  discard block
 block discarded – undo
667 667
 		</script>
668 668
             </div>
669 669
             <?php
670
-        	    }
671
-        	}
672
-            ?>
670
+				}
671
+			}
672
+			?>
673 673
         </div>
674 674
         <div class="row column">
675 675
             <div class="col-md-6">
676 676
         	<?php
677
-        	    $msg = $Stats->getStatsSource(date('Y-m-d'),'msg');
678
-        	    if (!empty($msg)) {
679
-            		print '<h2>'._("Messages received").'</h2>';
680
-        		foreach ($msg as $eachmsg) {
681
-        		    //$eachmsg = $msg[0];
682
-        		    $data = $eachmsg['source_data'];
683
-        		    if ($data > 500) $max = (round(($data+100)/100))*100;
684
-        		    else $max = 500;
685
-        	?>
677
+				$msg = $Stats->getStatsSource(date('Y-m-d'),'msg');
678
+				if (!empty($msg)) {
679
+					print '<h2>'._("Messages received").'</h2>';
680
+				foreach ($msg as $eachmsg) {
681
+					//$eachmsg = $msg[0];
682
+					$data = $eachmsg['source_data'];
683
+					if ($data > 500) $max = (round(($data+100)/100))*100;
684
+					else $max = 500;
685
+			?>
686 686
         	<div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
687 687
         	<script>
688 688
 		      var g = new JustGage({
@@ -698,9 +698,9 @@  discard block
 block discarded – undo
698 698
 			  });
699 699
 		</script>
700 700
             <?php
701
-        	   }
702
-        	}
703
-            ?>
701
+			   }
702
+			}
703
+			?>
704 704
             </div>
705 705
         </div>
706 706
         <div class="row column">
@@ -727,19 +727,19 @@  discard block
 block discarded – undo
727 727
 				$hist_data .= '[ "'.$distance.'",'.$nb.'],';
728 728
 			}
729 729
 			$hist_data = substr($hist_data, 0, -1);
730
-            ?>
730
+			?>
731 731
             <div class="col-md-6">
732 732
                 <h2><?php echo sprintf(_("Flights Distance for %s"),$source); ?></h2>
733 733
                 <?php
734
-                  print '<div id="charthist-'.str_replace(' ','_',strtolower($source)).'" class="chart" width="100%"></div>
734
+				  print '<div id="charthist-'.str_replace(' ','_',strtolower($source)).'" class="chart" width="100%"></div>
735 735
                     <script> 
736 736
                         google.load("visualization", "1", {packages:["corechart"]});
737 737
                       google.setOnLoadCallback(drawCharthist_'.str_replace(' ','_',strtolower($source)).');
738 738
                       function drawCharthist_'.str_replace(' ','_',strtolower($source)).'() {
739 739
                         var data = google.visualization.arrayToDataTable([
740 740
                             ["'._("Distance").'", "'._("# of Flights").'"], ';
741
-                            print $hist_data;
742
-                        print ']);
741
+							print $hist_data;
742
+						print ']);
743 743
 
744 744
                         var options = {
745 745
                             legend: {position: "none"},
@@ -757,15 +757,15 @@  discard block
 block discarded – undo
757 757
                               drawCharthist_'.str_replace(' ','_',strtolower($source)).'();
758 758
                             });
759 759
                   </script>';
760
-        	?>
760
+			?>
761 761
     	    </div>
762 762
 	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
763 763
         	<?php
764
-                  }
765
-                ?>
764
+				  }
765
+				?>
766 766
         </div>
767 767
 <?php
768
-    }
768
+	}
769 769
 ?>
770 770
     </div>
771 771
 </div>  
Please login to merge, or discard this patch.
live-geojson.php 1 patch
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -11,10 +11,10 @@  discard block
 block discarded – undo
11 11
 $Common = new Common();
12 12
 
13 13
 if (isset($_GET['download'])) {
14
-    if ($_GET['download'] == "true")
15
-    {
14
+	if ($_GET['download'] == "true")
15
+	{
16 16
 	header('Content-disposition: attachment; filename="flightairmap.json"');
17
-    }
17
+	}
18 18
 }
19 19
 header('Content-Type: text/javascript');
20 20
 
@@ -333,26 +333,26 @@  discard block
 block discarded – undo
333 333
 				
334 334
 				if ((isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') 
335 335
 				|| (!isset($_COOKIE['flightpath']) 
336
-				    && (!isset($globalMapHistory) || $globalMapHistory || $allhistory)
337
-				    || (isset($history) && $history != '' && $history != 'NA' && ($history == $spotter_item['ident'] || $history == $spotter_item['flightaware_id']))) 
336
+					&& (!isset($globalMapHistory) || $globalMapHistory || $allhistory)
337
+					|| (isset($history) && $history != '' && $history != 'NA' && ($history == $spotter_item['ident'] || $history == $spotter_item['flightaware_id']))) 
338 338
 				|| (isset($history) && $history == '' && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])) {
339
-                                    if ($from_archive) {
340
-					    $spotter_history_array = $SpotterArchive->getAllArchiveSpotterDataById($spotter_item['flightaware_id']);
341
-                                    } else {
342
-					    $spotter_history_array = $SpotterLive->getAllLiveSpotterDataById($spotter_item['flightaware_id']);
343
-                                    }
344
-                            	$d = false;
339
+									if ($from_archive) {
340
+						$spotter_history_array = $SpotterArchive->getAllArchiveSpotterDataById($spotter_item['flightaware_id']);
341
+									} else {
342
+						$spotter_history_array = $SpotterLive->getAllLiveSpotterDataById($spotter_item['flightaware_id']);
343
+									}
344
+								$d = false;
345 345
 				foreach ($spotter_history_array as $key => $spotter_history)
346 346
 				{
347 347
 					$alt = round($spotter_history['altitude']/10)*10;
348 348
 					if (!isset($prev_alt) || $prev_alt != $alt) {
349
-					    if (isset($prev_alt)) {
349
+						if (isset($prev_alt)) {
350 350
 						$output_history .= '['.$spotter_history['longitude'].', '.$spotter_history['latitude'].', '.$spotter_history['altitude'].']';
351 351
 						$output_history .= ']}},';
352 352
 						$output .= $output_history;
353
-					    }
354
-					    if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
355
-					    else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
353
+						}
354
+						if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
355
+						else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
356 356
 					}
357 357
 					$output_history .= '[';
358 358
 					$output_history .=  $spotter_history['longitude'].', ';
@@ -360,38 +360,38 @@  discard block
 block discarded – undo
360 360
 					$output_history .=  $spotter_history['altitude']*30.48;
361 361
 					$output_history .= '],';
362 362
 					$prev_alt = $alt;
363
-				    //}
363
+					//}
364 364
 				}
365 365
 				if (isset($output_history)) {
366
-				    $output_history  = substr($output_history, 0, -1);
367
-				    $output_history .= ']}},';
368
-				    $output .= $output_history;
369
-				    unset($prev_alt);
370
-				    unset($output_history);
366
+					$output_history  = substr($output_history, 0, -1);
367
+					$output_history .= ']}},';
368
+					$output .= $output_history;
369
+					unset($prev_alt);
370
+					unset($output_history);
371 371
 				}
372 372
 				}
373 373
 				
374 374
 				if (isset($history) && $history == $spotter_item['ident'] && isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA' && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) {
375
-				    $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": [';
376
-				    if (isset($spotter_item['departure_airport_latitude'])) {
375
+					$output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": [';
376
+					if (isset($spotter_item['departure_airport_latitude'])) {
377 377
 					$output_air .= '['.$spotter_item['departure_airport_longitude'].','.$spotter_item['departure_airport_latitude'].'],';
378
-				    } elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') {
378
+					} elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') {
379 379
 					$dairport = $Spotter->getAllAirportInfo($spotter_item['departure_airport']);
380 380
 					if (isset($dairport[0]['latitude'])) {
381
-					    $output_air .= '['.$dairport[0]['longitude'].','.$dairport[0]['latitude'].'],';
381
+						$output_air .= '['.$dairport[0]['longitude'].','.$dairport[0]['latitude'].'],';
382 382
 					}
383
-				    }
384
-				    if (isset($spotter_item['arrival_airport_latitude'])) {
383
+					}
384
+					if (isset($spotter_item['arrival_airport_latitude'])) {
385 385
 					$output_air .= '['.$spotter_item['arrival_airport_longitude'].','.$spotter_item['arrival_airport_latitude'].']';
386
-				    } elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') {
386
+					} elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') {
387 387
 					$aairport = $Spotter->getAllAirportInfo($spotter_item['arrival_airport']);
388 388
 					if (isset($aairport[0]['latitude'])) {
389
-					    $output_air .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].']';
389
+						$output_air .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].']';
390 390
 					}
391
-				    }
392
-				    $output_air .= ']}},';
393
-				    $output .= $output_air;
394
-				    unset($output_air);
391
+					}
392
+					$output_air .= ']}},';
393
+					$output .= $output_air;
394
+					unset($output_air);
395 395
 				}
396 396
 			}
397 397
 			$output  = substr($output, 0, -1);
Please login to merge, or discard this patch.
require/class.SpotterLive.php 1 patch
Indentation   +204 added lines, -204 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;
21 21
 		$filters = array();
@@ -83,11 +83,11 @@  discard block
 block discarded – undo
83 83
 	}
84 84
 
85 85
 	/**
86
-	* Gets all the spotter information based on the latest data entry
87
-	*
88
-	* @return Array the spotter information
89
-	*
90
-	*/
86
+	 * Gets all the spotter information based on the latest data entry
87
+	 *
88
+	 * @return Array the spotter information
89
+	 *
90
+	 */
91 91
 	public function getLiveSpotterData($limit = '', $sort = '', $filter = array())
92 92
 	{
93 93
 		global $globalDBdriver, $globalLiveInterval;
@@ -126,11 +126,11 @@  discard block
 block discarded – undo
126 126
 	}
127 127
 
128 128
 	/**
129
-	* Gets Minimal Live Spotter data
130
-	*
131
-	* @return Array the spotter information
132
-	*
133
-	*/
129
+	 * Gets Minimal Live Spotter data
130
+	 *
131
+	 * @return Array the spotter information
132
+	 *
133
+	 */
134 134
 	public function getMinLiveSpotterData($filter = array())
135 135
 	{
136 136
 		global $globalDBdriver, $globalLiveInterval;
@@ -181,11 +181,11 @@  discard block
 block discarded – undo
181 181
 	}
182 182
 
183 183
 	/**
184
-	* Gets Minimal Live Spotter data since xx seconds
185
-	*
186
-	* @return Array the spotter information
187
-	*
188
-	*/
184
+	 * Gets Minimal Live Spotter data since xx seconds
185
+	 *
186
+	 * @return Array the spotter information
187
+	 *
188
+	 */
189 189
 	public function getMinLastLiveSpotterData($filter = array())
190 190
 	{
191 191
 		global $globalDBdriver, $globalLiveInterval;
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 			$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 
200 200
 			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.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' 
201 201
 			ORDER BY spotter_live.flightaware_id, spotter_live.date";
202
-                } else {
202
+				} else {
203 203
 /*
204 204
 			$query  = "SELECT a.aircraft_shadow, 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 
205 205
 			FROM spotter_live WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date 
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 //			echo $query;
212 212
 		}
213 213
 
214
-    		try {
214
+			try {
215 215
 			$sth = $this->db->prepare($query);
216 216
 			$sth->execute();
217 217
 		} catch(PDOException $e) {
@@ -223,11 +223,11 @@  discard block
 block discarded – undo
223 223
 	}
224 224
 
225 225
 	/**
226
-	* Gets number of latest data entry
227
-	*
228
-	* @return String number of entry
229
-	*
230
-	*/
226
+	 * Gets number of latest data entry
227
+	 *
228
+	 * @return String number of entry
229
+	 *
230
+	 */
231 231
 	public function getLiveSpotterCount($filter = array())
232 232
 	{
233 233
 		global $globalDBdriver, $globalLiveInterval;
@@ -254,11 +254,11 @@  discard block
 block discarded – undo
254 254
 	}
255 255
 
256 256
 	/**
257
-	* Gets all the spotter information based on the latest data entry and coord
258
-	*
259
-	* @return Array the spotter information
260
-	*
261
-	*/
257
+	 * Gets all the spotter information based on the latest data entry and coord
258
+	 *
259
+	 * @return Array the spotter information
260
+	 *
261
+	 */
262 262
 	public function getLiveSpotterDatabyCoord($coord, $filter = array())
263 263
 	{
264 264
 		global $globalDBdriver, $globalLiveInterval;
@@ -283,11 +283,11 @@  discard block
 block discarded – undo
283 283
 	}
284 284
 
285 285
 	/**
286
-	* Gets all the spotter information based on a user's latitude and longitude
287
-	*
288
-	* @return Array the spotter information
289
-	*
290
-	*/
286
+	 * Gets all the spotter information based on a user's latitude and longitude
287
+	 *
288
+	 * @return Array the spotter information
289
+	 *
290
+	 */
291 291
 	public function getLatestSpotterForLayar($lat, $lng, $radius, $interval)
292 292
 	{
293 293
 		$Spotter = new Spotter($this->db);
@@ -297,145 +297,145 @@  discard block
 block discarded – undo
297 297
 				return false;
298 298
 			}
299 299
 		}
300
-        if ($lng != '')
301
-                {
302
-                        if (!is_numeric($lng))
303
-                        {
304
-                                return false;
305
-                        }
306
-                }
307
-
308
-                if ($radius != '')
309
-                {
310
-                        if (!is_numeric($radius))
311
-                        {
312
-                                return false;
313
-                        }
314
-                }
300
+		if ($lng != '')
301
+				{
302
+						if (!is_numeric($lng))
303
+						{
304
+								return false;
305
+						}
306
+				}
307
+
308
+				if ($radius != '')
309
+				{
310
+						if (!is_numeric($radius))
311
+						{
312
+								return false;
313
+						}
314
+				}
315 315
 		$additional_query = '';
316
-        if ($interval != '')
317
-                {
318
-                        if (!is_string($interval))
319
-                        {
320
-                                //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
321
-			        return false;
322
-                        } else {
323
-                if ($interval == '1m')
324
-                {
325
-                    $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
326
-                } else if ($interval == '15m'){
327
-                    $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date ';
328
-                } 
329
-            }
330
-                } else {
331
-         $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';   
332
-        }
333
-
334
-                $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 
316
+		if ($interval != '')
317
+				{
318
+						if (!is_string($interval))
319
+						{
320
+								//$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
321
+					return false;
322
+						} else {
323
+				if ($interval == '1m')
324
+				{
325
+					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
326
+				} else if ($interval == '15m'){
327
+					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date ';
328
+				} 
329
+			}
330
+				} else {
331
+		 $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';   
332
+		}
333
+
334
+				$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 
335 335
                    WHERE spotter_live.latitude <> '' 
336 336
                                    AND spotter_live.longitude <> '' 
337 337
                    ".$additional_query."
338 338
                    HAVING distance < :radius  
339 339
                                    ORDER BY distance";
340 340
 
341
-                $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
341
+				$spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
342 342
 
343
-                return $spotter_array;
344
-        }
343
+				return $spotter_array;
344
+		}
345 345
 
346 346
     
347
-        /**
348
-	* Gets all the spotter information based on a particular callsign
349
-	*
350
-	* @return Array the spotter information
351
-	*
352
-	*/
347
+		/**
348
+		 * Gets all the spotter information based on a particular callsign
349
+		 *
350
+		 * @return Array the spotter information
351
+		 *
352
+		 */
353 353
 	public function getLastLiveSpotterDataByIdent($ident)
354 354
 	{
355 355
 		$Spotter = new Spotter($this->db);
356 356
 		date_default_timezone_set('UTC');
357 357
 
358 358
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
359
-                $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';
359
+				$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';
360 360
 
361 361
 		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true);
362 362
 
363 363
 		return $spotter_array;
364 364
 	}
365 365
 
366
-        /**
367
-	* Gets all the spotter information based on a particular callsign
368
-	*
369
-	* @return Array the spotter information
370
-	*
371
-	*/
366
+		/**
367
+		 * Gets all the spotter information based on a particular callsign
368
+		 *
369
+		 * @return Array the spotter information
370
+		 *
371
+		 */
372 372
 	public function getDateLiveSpotterDataByIdent($ident,$date)
373 373
 	{
374 374
 		$Spotter = new Spotter($this->db);
375 375
 		date_default_timezone_set('UTC');
376 376
 
377 377
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
378
-                $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';
378
+				$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';
379 379
 
380
-                $date = date('c',$date);
380
+				$date = date('c',$date);
381 381
 		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
382 382
 
383 383
 		return $spotter_array;
384 384
 	}
385 385
 
386
-        /**
387
-	* Gets last spotter information based on a particular callsign
388
-	*
389
-	* @return Array the spotter information
390
-	*
391
-	*/
386
+		/**
387
+		 * Gets last spotter information based on a particular callsign
388
+		 *
389
+		 * @return Array the spotter information
390
+		 *
391
+		 */
392 392
 	public function getLastLiveSpotterDataById($id)
393 393
 	{
394 394
 		$Spotter = new Spotter($this->db);
395 395
 		date_default_timezone_set('UTC');
396 396
 
397 397
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
398
-                $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';
398
+				$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';
399 399
 
400 400
 		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true);
401 401
 
402 402
 		return $spotter_array;
403 403
 	}
404 404
 
405
-        /**
406
-	* Gets last spotter information based on a particular callsign
407
-	*
408
-	* @return Array the spotter information
409
-	*
410
-	*/
405
+		/**
406
+		 * Gets last spotter information based on a particular callsign
407
+		 *
408
+		 * @return Array the spotter information
409
+		 *
410
+		 */
411 411
 	public function getDateLiveSpotterDataById($id,$date)
412 412
 	{
413 413
 		$Spotter = new Spotter($this->db);
414 414
 		date_default_timezone_set('UTC');
415 415
 
416 416
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
417
-                $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';
418
-                $date = date('c',$date);
417
+				$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';
418
+				$date = date('c',$date);
419 419
 		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
420 420
 
421 421
 		return $spotter_array;
422 422
 	}
423 423
 
424
-        /**
425
-	* Gets altitude information based on a particular callsign
426
-	*
427
-	* @return Array the spotter information
428
-	*
429
-	*/
424
+		/**
425
+		 * Gets altitude information based on a particular callsign
426
+		 *
427
+		 * @return Array the spotter information
428
+		 *
429
+		 */
430 430
 	public function getAltitudeLiveSpotterDataByIdent($ident)
431 431
 	{
432 432
 
433 433
 		date_default_timezone_set('UTC');
434 434
 
435 435
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
436
-                $query  = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
436
+				$query  = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
437 437
 
438
-    		try {
438
+			try {
439 439
 			
440 440
 			$sth = $this->db->prepare($query);
441 441
 			$sth->execute(array(':ident' => $ident));
@@ -448,12 +448,12 @@  discard block
 block discarded – undo
448 448
 		return $spotter_array;
449 449
 	}
450 450
 
451
-        /**
452
-	* Gets all the spotter information based on a particular id
453
-	*
454
-	* @return Array the spotter information
455
-	*
456
-	*/
451
+		/**
452
+		 * Gets all the spotter information based on a particular id
453
+		 *
454
+		 * @return Array the spotter information
455
+		 *
456
+		 */
457 457
 	public function getAllLiveSpotterDataById($id,$liveinterval = false)
458 458
 	{
459 459
 		global $globalDBdriver, $globalLiveInterval;
@@ -481,18 +481,18 @@  discard block
 block discarded – undo
481 481
 		return $spotter_array;
482 482
 	}
483 483
 
484
-        /**
485
-	* Gets all the spotter information based on a particular ident
486
-	*
487
-	* @return Array the spotter information
488
-	*
489
-	*/
484
+		/**
485
+		 * Gets all the spotter information based on a particular ident
486
+		 *
487
+		 * @return Array the spotter information
488
+		 *
489
+		 */
490 490
 	public function getAllLiveSpotterDataByIdent($ident)
491 491
 	{
492 492
 		date_default_timezone_set('UTC');
493 493
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
494 494
 		$query  = self::$global_query.' WHERE spotter_live.ident = :ident';
495
-    		try {
495
+			try {
496 496
 			
497 497
 			$sth = $this->db->prepare($query);
498 498
 			$sth->execute(array(':ident' => $ident));
@@ -506,23 +506,23 @@  discard block
 block discarded – undo
506 506
 
507 507
 
508 508
 	/**
509
-	* Deletes all info in the table
510
-	*
511
-	* @return String success or false
512
-	*
513
-	*/
509
+	 * Deletes all info in the table
510
+	 *
511
+	 * @return String success or false
512
+	 *
513
+	 */
514 514
 	public function deleteLiveSpotterData()
515 515
 	{
516 516
 		global $globalDBdriver;
517 517
 		if ($globalDBdriver == 'mysql') {
518 518
 			//$query  = "DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= spotter_live.date";
519 519
 			$query  = 'DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= spotter_live.date';
520
-            		//$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)";
520
+					//$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)";
521 521
 		} else {
522 522
 			$query  = "DELETE FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date";
523 523
 		}
524 524
         
525
-    		try {
525
+			try {
526 526
 			
527 527
 			$sth = $this->db->prepare($query);
528 528
 			$sth->execute();
@@ -534,18 +534,18 @@  discard block
 block discarded – undo
534 534
 	}
535 535
 
536 536
 	/**
537
-	* Deletes all info in the table for aircraft not seen since 2 HOUR
538
-	*
539
-	* @return String success or false
540
-	*
541
-	*/
537
+	 * Deletes all info in the table for aircraft not seen since 2 HOUR
538
+	 *
539
+	 * @return String success or false
540
+	 *
541
+	 */
542 542
 	public function deleteLiveSpotterDataNotUpdated()
543 543
 	{
544 544
 		global $globalDBdriver, $globalDebug;
545 545
 		if ($globalDBdriver == 'mysql') {
546 546
 			//$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';
547
-    			$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 1200 OFFSET 0";
548
-    			try {
547
+				$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 1200 OFFSET 0";
548
+				try {
549 549
 				
550 550
 				$sth = $this->db->prepare($query);
551 551
 				$sth->execute();
@@ -553,8 +553,8 @@  discard block
 block discarded – undo
553 553
 				return "error";
554 554
 			}
555 555
 			$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
556
-                        $i = 0;
557
-                        $j =0;
556
+						$i = 0;
557
+						$j =0;
558 558
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
559 559
 			foreach($all as $row)
560 560
 			{
@@ -562,20 +562,20 @@  discard block
 block discarded – undo
562 562
 				$j++;
563 563
 				if ($j == 30) {
564 564
 					if ($globalDebug) echo ".";
565
-				    	try {
565
+						try {
566 566
 						
567 567
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
568 568
 						$sth->execute();
569 569
 					} catch(PDOException $e) {
570 570
 						return "error";
571 571
 					}
572
-                                	$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
573
-                                	$j = 0;
572
+									$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
573
+									$j = 0;
574 574
 				}
575 575
 				$query_delete .= "'".$row['flightaware_id']."',";
576 576
 			}
577 577
 			if ($i > 0) {
578
-    				try {
578
+					try {
579 579
 					
580 580
 					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
581 581
 					$sth->execute();
@@ -586,9 +586,9 @@  discard block
 block discarded – undo
586 586
 			return "success";
587 587
 		} elseif ($globalDBdriver == 'pgsql') {
588 588
 			//$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";
589
-    			//$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";
590
-    			$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 800 OFFSET 0)";
591
-    			try {
589
+				//$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";
590
+				$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 800 OFFSET 0)";
591
+				try {
592 592
 				
593 593
 				$sth = $this->db->prepare($query);
594 594
 				$sth->execute();
@@ -632,17 +632,17 @@  discard block
 block discarded – undo
632 632
 	}
633 633
 
634 634
 	/**
635
-	* Deletes all info in the table for an ident
636
-	*
637
-	* @return String success or false
638
-	*
639
-	*/
635
+	 * Deletes all info in the table for an ident
636
+	 *
637
+	 * @return String success or false
638
+	 *
639
+	 */
640 640
 	public function deleteLiveSpotterDataByIdent($ident)
641 641
 	{
642 642
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
643 643
 		$query  = 'DELETE FROM spotter_live WHERE ident = :ident';
644 644
         
645
-    		try {
645
+			try {
646 646
 			
647 647
 			$sth = $this->db->prepare($query);
648 648
 			$sth->execute(array(':ident' => $ident));
@@ -654,17 +654,17 @@  discard block
 block discarded – undo
654 654
 	}
655 655
 
656 656
 	/**
657
-	* Deletes all info in the table for an id
658
-	*
659
-	* @return String success or false
660
-	*
661
-	*/
657
+	 * Deletes all info in the table for an id
658
+	 *
659
+	 * @return String success or false
660
+	 *
661
+	 */
662 662
 	public function deleteLiveSpotterDataById($id)
663 663
 	{
664 664
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
665 665
 		$query  = 'DELETE FROM spotter_live WHERE flightaware_id = :id';
666 666
         
667
-    		try {
667
+			try {
668 668
 			
669 669
 			$sth = $this->db->prepare($query);
670 670
 			$sth->execute(array(':id' => $id));
@@ -677,11 +677,11 @@  discard block
 block discarded – undo
677 677
 
678 678
 
679 679
 	/**
680
-	* Gets the aircraft ident within the last hour
681
-	*
682
-	* @return String the ident
683
-	*
684
-	*/
680
+	 * Gets the aircraft ident within the last hour
681
+	 *
682
+	 * @return String the ident
683
+	 *
684
+	 */
685 685
 	public function getIdentFromLastHour($ident)
686 686
 	{
687 687
 		global $globalDBdriver, $globalTimezone;
@@ -707,14 +707,14 @@  discard block
 block discarded – undo
707 707
 			$ident_result = $row['ident'];
708 708
 		}
709 709
 		return $ident_result;
710
-        }
710
+		}
711 711
 
712 712
 	/**
713
-	* Check recent aircraft
714
-	*
715
-	* @return String the ident
716
-	*
717
-	*/
713
+	 * Check recent aircraft
714
+	 *
715
+	 * @return String the ident
716
+	 *
717
+	 */
718 718
 	public function checkIdentRecent($ident)
719 719
 	{
720 720
 		global $globalDBdriver, $globalTimezone;
@@ -740,14 +740,14 @@  discard block
 block discarded – undo
740 740
 			$ident_result = $row['flightaware_id'];
741 741
 		}
742 742
 		return $ident_result;
743
-        }
743
+		}
744 744
 
745 745
 	/**
746
-	* Check recent aircraft by id
747
-	*
748
-	* @return String the ident
749
-	*
750
-	*/
746
+	 * Check recent aircraft by id
747
+	 *
748
+	 * @return String the ident
749
+	 *
750
+	 */
751 751
 	public function checkIdRecent($id)
752 752
 	{
753 753
 		global $globalDBdriver, $globalTimezone;
@@ -773,14 +773,14 @@  discard block
 block discarded – undo
773 773
 			$ident_result = $row['flightaware_id'];
774 774
 		}
775 775
 		return $ident_result;
776
-        }
776
+		}
777 777
 
778 778
 	/**
779
-	* Check recent aircraft by ModeS
780
-	*
781
-	* @return String the ModeS
782
-	*
783
-	*/
779
+	 * Check recent aircraft by ModeS
780
+	 *
781
+	 * @return String the ModeS
782
+	 *
783
+	 */
784 784
 	public function checkModeSRecent($modes)
785 785
 	{
786 786
 		global $globalDBdriver, $globalTimezone;
@@ -807,19 +807,19 @@  discard block
 block discarded – undo
807 807
 			$ident_result = $row['flightaware_id'];
808 808
 		}
809 809
 		return $ident_result;
810
-        }
810
+		}
811 811
 
812 812
 	/**
813
-	* Adds a new spotter data
814
-	*
815
-	* @param String $flightaware_id the ID from flightaware
816
-	* @param String $ident the flight ident
817
-	* @param String $aircraft_icao the aircraft type
818
-	* @param String $departure_airport_icao the departure airport
819
-	* @param String $arrival_airport_icao the arrival airport
820
-	* @return String success or false
821
-	*
822
-	*/
813
+	 * Adds a new spotter data
814
+	 *
815
+	 * @param String $flightaware_id the ID from flightaware
816
+	 * @param String $ident the flight ident
817
+	 * @param String $aircraft_icao the aircraft type
818
+	 * @param String $departure_airport_icao the departure airport
819
+	 * @param String $arrival_airport_icao the arrival airport
820
+	 * @return String success or false
821
+	 *
822
+	 */
823 823
 	public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $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 = '')
824 824
 	{
825 825
 		global $globalURL, $globalArchive, $globalDebug;
@@ -954,10 +954,10 @@  discard block
 block discarded – undo
954 954
 		$arrival_airport_country = '';
955 955
 		
956 956
             	
957
-            	if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
958
-            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
959
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
960
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
957
+				if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
958
+				if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
959
+				if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
960
+				if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
961 961
             	
962 962
 		$query  = 'INSERT INTO spotter_live (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop, ModeS, pilot_id, pilot_name, verticalrate, ground, format_source, source_name, over_country) 
963 963
 		VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_shadow,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name, :departure_airport_city, :departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date,:departure_airport_time,:arrival_airport_time,:squawk,:route_stop,:ModeS, :pilot_id, :pilot_name, :verticalrate, :ground, :format_source, :source_name, :over_country)';
@@ -967,14 +967,14 @@  discard block
 block discarded – undo
967 967
 			
968 968
 			$sth = $this->db->prepare($query);
969 969
 			$sth->execute($query_values);
970
-                } catch(PDOException $e) {
971
-                	return "error : ".$e->getMessage();
972
-                }
970
+				} catch(PDOException $e) {
971
+					return "error : ".$e->getMessage();
972
+				}
973 973
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
974
-		    if ($globalDebug) echo '(Add to SBS archive : ';
975
-		    $SpotterArchive = new SpotterArchive($this->db);
976
-		    $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);
977
-		    if ($globalDebug) echo $result.')';
974
+			if ($globalDebug) echo '(Add to SBS archive : ';
975
+			$SpotterArchive = new SpotterArchive($this->db);
976
+			$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);
977
+			if ($globalDebug) echo $result.')';
978 978
 		}
979 979
 		return "success";
980 980
 
Please login to merge, or discard this patch.
require/class.Stats.php 1 patch
Indentation   +851 added lines, -851 removed lines patch added patch discarded remove patch
@@ -15,33 +15,33 @@  discard block
 block discarded – undo
15 15
 		if (isset($globalFilterName)) $this->filter_name = $globalFilterName;
16 16
 		$Connection = new Connection($dbc);
17 17
 		$this->db = $Connection->db();
18
-        }
18
+		}
19 19
               
20 20
 	public function addLastStatsUpdate($type,$stats_date) {
21
-                $query = "DELETE FROM config WHERE name = :type;
21
+				$query = "DELETE FROM config WHERE name = :type;
22 22
             		INSERT INTO config (name,value) VALUES (:type,:stats_date);";
23
-                $query_values = array('type' => $type,':stats_date' => $stats_date);
24
-                 try {
25
-                        $sth = $this->db->prepare($query);
26
-                        $sth->execute($query_values);
27
-                } catch(PDOException $e) {
28
-                        return "error : ".$e->getMessage();
29
-                }
30
-        }
23
+				$query_values = array('type' => $type,':stats_date' => $stats_date);
24
+				 try {
25
+						$sth = $this->db->prepare($query);
26
+						$sth->execute($query_values);
27
+				} catch(PDOException $e) {
28
+						return "error : ".$e->getMessage();
29
+				}
30
+		}
31 31
 
32 32
 	public function getLastStatsUpdate($type = 'last_update_stats') {
33
-                $query = "SELECT value FROM config WHERE name = :type";
34
-                 try {
35
-                        $sth = $this->db->prepare($query);
36
-                        $sth->execute(array(':type' => $type));
37
-                } catch(PDOException $e) {
38
-                        echo "error : ".$e->getMessage();
39
-                }
40
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
41
-                return $all;
42
-        }
43
-        public function deleteStats($filter_name = '') {
44
-        	/*
33
+				$query = "SELECT value FROM config WHERE name = :type";
34
+				 try {
35
+						$sth = $this->db->prepare($query);
36
+						$sth->execute(array(':type' => $type));
37
+				} catch(PDOException $e) {
38
+						echo "error : ".$e->getMessage();
39
+				}
40
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
41
+				return $all;
42
+		}
43
+		public function deleteStats($filter_name = '') {
44
+			/*
45 45
         	$query = "DELETE FROM config WHERE name = 'last_update_stats'";
46 46
                  try {
47 47
                         $sth = $this->db->prepare($query);
@@ -50,80 +50,80 @@  discard block
 block discarded – undo
50 50
                         return "error : ".$e->getMessage();
51 51
                 }
52 52
                 */
53
-        	$query = "DELETE FROM stats WHERE filter_name = :filter_name;DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_airport WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_flight WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;";
54
-                 try {
55
-                        $sth = $this->db->prepare($query);
56
-                        $sth->execute(array(':filter_name' => $filter_name));
57
-                } catch(PDOException $e) {
58
-                        return "error : ".$e->getMessage();
59
-                }
60
-        }
61
-        public function deleteOldStats($filter_name = '') {
53
+			$query = "DELETE FROM stats WHERE filter_name = :filter_name;DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_airport WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_flight WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;";
54
+				 try {
55
+						$sth = $this->db->prepare($query);
56
+						$sth->execute(array(':filter_name' => $filter_name));
57
+				} catch(PDOException $e) {
58
+						return "error : ".$e->getMessage();
59
+				}
60
+		}
61
+		public function deleteOldStats($filter_name = '') {
62 62
         	
63
-        	$query = "DELETE FROM config WHERE name = 'last_update_stats'";
64
-                 try {
65
-                        $sth = $this->db->prepare($query);
66
-                        $sth->execute();
67
-                } catch(PDOException $e) {
68
-                        return "error : ".$e->getMessage();
69
-                }
63
+			$query = "DELETE FROM config WHERE name = 'last_update_stats'";
64
+				 try {
65
+						$sth = $this->db->prepare($query);
66
+						$sth->execute();
67
+				} catch(PDOException $e) {
68
+						return "error : ".$e->getMessage();
69
+				}
70 70
                 
71
-        	$query = "DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;";
72
-                 try {
73
-                        $sth = $this->db->prepare($query);
74
-                        $sth->execute(array(':filter_name' => $filter_name));
75
-                } catch(PDOException $e) {
76
-                        return "error : ".$e->getMessage();
77
-                }
78
-        }
71
+			$query = "DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;";
72
+				 try {
73
+						$sth = $this->db->prepare($query);
74
+						$sth->execute(array(':filter_name' => $filter_name));
75
+				} catch(PDOException $e) {
76
+						return "error : ".$e->getMessage();
77
+				}
78
+		}
79 79
 	public function getAllAirlineNames($filter_name = '') {
80 80
 		if ($filter_name == '') $filter_name = $this->filter_name;
81
-                $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC";
82
-                 try {
83
-                        $sth = $this->db->prepare($query);
84
-                        $sth->execute(array(':filter_name' => $filter_name));
85
-                } catch(PDOException $e) {
86
-                        echo "error : ".$e->getMessage();
87
-                }
88
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
89
-                return $all;
90
-        }
81
+				$query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC";
82
+				 try {
83
+						$sth = $this->db->prepare($query);
84
+						$sth->execute(array(':filter_name' => $filter_name));
85
+				} catch(PDOException $e) {
86
+						echo "error : ".$e->getMessage();
87
+				}
88
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
89
+				return $all;
90
+		}
91 91
 	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
92 92
 		if ($filter_name == '') $filter_name = $this->filter_name;
93
-                $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
94
-                 try {
95
-                        $sth = $this->db->prepare($query);
96
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
97
-                } catch(PDOException $e) {
98
-                        echo "error : ".$e->getMessage();
99
-                }
100
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
101
-                return $all;
102
-        }
93
+				$query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
94
+				 try {
95
+						$sth = $this->db->prepare($query);
96
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
97
+				} catch(PDOException $e) {
98
+						echo "error : ".$e->getMessage();
99
+				}
100
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
101
+				return $all;
102
+		}
103 103
 	public function getAllManufacturers($stats_airline = '',$filter_name = '') {
104 104
 		if ($filter_name == '') $filter_name = $this->filter_name;
105
-                $query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC";
106
-                 try {
107
-                        $sth = $this->db->prepare($query);
108
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
109
-                } catch(PDOException $e) {
110
-                        echo "error : ".$e->getMessage();
111
-                }
112
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
113
-                return $all;
114
-        }
105
+				$query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC";
106
+				 try {
107
+						$sth = $this->db->prepare($query);
108
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
109
+				} catch(PDOException $e) {
110
+						echo "error : ".$e->getMessage();
111
+				}
112
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
113
+				return $all;
114
+		}
115 115
 	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
116 116
 		if ($filter_name == '') $filter_name = $this->filter_name;
117
-                $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC";
118
-                 try {
119
-                        $sth = $this->db->prepare($query);
120
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
121
-                } catch(PDOException $e) {
122
-                        echo "error : ".$e->getMessage();
123
-                }
124
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
125
-                return $all;
126
-        }
117
+				$query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC";
118
+				 try {
119
+						$sth = $this->db->prepare($query);
120
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
121
+				} catch(PDOException $e) {
122
+						echo "error : ".$e->getMessage();
123
+				}
124
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
125
+				return $all;
126
+		}
127 127
 
128 128
 
129 129
 	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '') {
@@ -131,66 +131,66 @@  discard block
 block discarded – undo
131 131
 		if ($filter_name == '') $filter_name = $this->filter_name;
132 132
 		if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
133 133
 		else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
134
-                 try {
135
-                        $sth = $this->db->prepare($query);
136
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
137
-                } catch(PDOException $e) {
138
-                        echo "error : ".$e->getMessage();
139
-                }
140
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
141
-                if (empty($all)) {
142
-            	    $filters = array('airlines' => array($stats_airline));
143
-            	    if ($filter_name != '') {
144
-            		    $filters = array_merge($filters,$globalStatsFilters[$filter_name]);
145
-            	    }
146
-            	    $Spotter = new Spotter($this->db);
147
-            	    $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters);
148
-                }
149
-                return $all;
134
+				 try {
135
+						$sth = $this->db->prepare($query);
136
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
137
+				} catch(PDOException $e) {
138
+						echo "error : ".$e->getMessage();
139
+				}
140
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
141
+				if (empty($all)) {
142
+					$filters = array('airlines' => array($stats_airline));
143
+					if ($filter_name != '') {
144
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
145
+					}
146
+					$Spotter = new Spotter($this->db);
147
+					$all = $Spotter->countAllAircraftTypes($limit,0,'',$filters);
148
+				}
149
+				return $all;
150 150
 	}
151 151
 	public function countAllAirlineCountries($limit = true,$filter_name = '') {
152 152
 		global $globalStatsFilters;
153 153
 		if ($filter_name == '') $filter_name = $this->filter_name;
154 154
 		if ($limit) $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0";
155 155
 		else $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC";
156
-                 try {
157
-                        $sth = $this->db->prepare($query);
158
-                        $sth->execute(array(':filter_name' => $filter_name));
159
-                } catch(PDOException $e) {
160
-                        echo "error : ".$e->getMessage();
161
-                }
162
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
163
-                if (empty($all)) {
164
-            		$Spotter = new Spotter($this->db);
165
-            		$filters = array();
166
-            		if ($filter_name != '') {
167
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
168
-			}
169
-            		$all = $Spotter->countAllAirlineCountries($limit,$filters);
170
-                }
171
-                return $all;
156
+				 try {
157
+						$sth = $this->db->prepare($query);
158
+						$sth->execute(array(':filter_name' => $filter_name));
159
+				} catch(PDOException $e) {
160
+						echo "error : ".$e->getMessage();
161
+				}
162
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
163
+				if (empty($all)) {
164
+					$Spotter = new Spotter($this->db);
165
+					$filters = array();
166
+					if ($filter_name != '') {
167
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
168
+			}
169
+					$all = $Spotter->countAllAirlineCountries($limit,$filters);
170
+				}
171
+				return $all;
172 172
 	}
173 173
 	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '') {
174 174
 		global $globalStatsFilters;
175 175
 		if ($filter_name == '') $filter_name = $this->filter_name;
176 176
 		if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
177 177
 		else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
178
-                 try {
179
-                        $sth = $this->db->prepare($query);
180
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
181
-                } catch(PDOException $e) {
182
-                        echo "error : ".$e->getMessage();
183
-                }
184
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
185
-                if (empty($all)) {
186
-            		$filters = array('airlines' => array($stats_airline));
187
-            		if ($filter_name != '') {
188
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
178
+				 try {
179
+						$sth = $this->db->prepare($query);
180
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
181
+				} catch(PDOException $e) {
182
+						echo "error : ".$e->getMessage();
183
+				}
184
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
185
+				if (empty($all)) {
186
+					$filters = array('airlines' => array($stats_airline));
187
+					if ($filter_name != '') {
188
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
189 189
 			}
190
-            		$Spotter = new Spotter($this->db);
190
+					$Spotter = new Spotter($this->db);
191 191
 			$all = $Spotter->countAllAircraftManufacturers($filters);
192
-                }
193
-                return $all;
192
+				}
193
+				return $all;
194 194
 	}
195 195
 
196 196
 	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '') {
@@ -198,44 +198,44 @@  discard block
 block discarded – undo
198 198
 		if ($filter_name == '') $filter_name = $this->filter_name;
199 199
 		if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
200 200
 		else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC";
201
-                 try {
202
-                        $sth = $this->db->prepare($query);
203
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
204
-                } catch(PDOException $e) {
205
-                        echo "error : ".$e->getMessage();
206
-                }
207
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
208
-                if (empty($all)) {
201
+				 try {
202
+						$sth = $this->db->prepare($query);
203
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
204
+				} catch(PDOException $e) {
205
+						echo "error : ".$e->getMessage();
206
+				}
207
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
208
+				if (empty($all)) {
209 209
 			$filters = array('airlines' => array($stats_airline));
210 210
 			if ($filter_name != '') {
211
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
211
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
212 212
 			}
213 213
 			$Spotter = new Spotter($this->db);
214 214
 			$all = $Spotter->countAllArrivalCountries($limit,$filters);
215
-                }
216
-                return $all;
215
+				}
216
+				return $all;
217 217
 	}
218 218
 	public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '') {
219 219
 		global $globalStatsFilters;
220 220
 		if ($filter_name == '') $filter_name = $this->filter_name;
221 221
 		if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
222 222
 		else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC";
223
-                 try {
224
-                        $sth = $this->db->prepare($query);
225
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
226
-                } catch(PDOException $e) {
227
-                        echo "error : ".$e->getMessage();
228
-                }
229
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
230
-                if (empty($all)) {
223
+				 try {
224
+						$sth = $this->db->prepare($query);
225
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
226
+				} catch(PDOException $e) {
227
+						echo "error : ".$e->getMessage();
228
+				}
229
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
230
+				if (empty($all)) {
231 231
 			$filters = array('airlines' => array($stats_airline));
232 232
 			if ($filter_name != '') {
233
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
233
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
234 234
 			}
235 235
 			$Spotter = new Spotter($this->db);
236 236
 			$all = $Spotter->countAllDepartureCountries($filters);
237
-                }
238
-                return $all;
237
+				}
238
+				return $all;
239 239
 	}
240 240
 
241 241
 	public function countAllAirlines($limit = true,$filter_name = '') {
@@ -243,45 +243,45 @@  discard block
 block discarded – undo
243 243
 		if ($filter_name == '') $filter_name = $this->filter_name;
244 244
 		if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
245 245
 		else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC";
246
-                 try {
247
-                        $sth = $this->db->prepare($query);
248
-                        $sth->execute(array(':filter_name' => $filter_name));
249
-                } catch(PDOException $e) {
250
-                        echo "error : ".$e->getMessage();
251
-                }
252
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
253
-                if (empty($all)) {
254
-	                $Spotter = new Spotter($this->db);
255
-            		$filters = array();
256
-            		if ($filter_name != '') {
257
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
246
+				 try {
247
+						$sth = $this->db->prepare($query);
248
+						$sth->execute(array(':filter_name' => $filter_name));
249
+				} catch(PDOException $e) {
250
+						echo "error : ".$e->getMessage();
251
+				}
252
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
253
+				if (empty($all)) {
254
+					$Spotter = new Spotter($this->db);
255
+					$filters = array();
256
+					if ($filter_name != '') {
257
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
258 258
 			}
259 259
 
260
-    		        $all = $Spotter->countAllAirlines($limit,0,'',$filters);
261
-                }
262
-                return $all;
260
+					$all = $Spotter->countAllAirlines($limit,0,'',$filters);
261
+				}
262
+				return $all;
263 263
 	}
264 264
 	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '') {
265 265
 		global $globalStatsFilters;
266 266
 		if ($filter_name == '') $filter_name = $this->filter_name;
267 267
 		if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0";
268 268
 		else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC";
269
-                 try {
270
-                        $sth = $this->db->prepare($query);
271
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
272
-                } catch(PDOException $e) {
273
-                        echo "error : ".$e->getMessage();
274
-                }
275
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
276
-                if (empty($all)) {
269
+				 try {
270
+						$sth = $this->db->prepare($query);
271
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
272
+				} catch(PDOException $e) {
273
+						echo "error : ".$e->getMessage();
274
+				}
275
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
276
+				if (empty($all)) {
277 277
 			$filters = array('airlines' => array($stats_airline));
278 278
 			if ($filter_name != '') {
279 279
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
280 280
 			}
281
-	                $Spotter = new Spotter($this->db);
282
-    		        $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters);
283
-                }
284
-                return $all;
281
+					$Spotter = new Spotter($this->db);
282
+					$all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters);
283
+				}
284
+				return $all;
285 285
 	}
286 286
 	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '') {
287 287
 		global $globalStatsFilters;
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
 				echo "error : ".$e->getMessage();
319 319
 			}
320 320
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
321
-                /*
321
+				/*
322 322
                 if (empty($all)) {
323 323
 	                $Spotter = new Spotter($this->db);
324 324
     		        $all = $Spotter->countAllFlightOverCountries($limit);
@@ -334,84 +334,84 @@  discard block
 block discarded – undo
334 334
 		if ($filter_name == '') $filter_name = $this->filter_name;
335 335
 		if ($limit) $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0";
336 336
 		else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC";
337
-                 try {
338
-                        $sth = $this->db->prepare($query);
339
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
340
-                } catch(PDOException $e) {
341
-                        echo "error : ".$e->getMessage();
342
-                }
343
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
344
-                if (empty($all)) {
337
+				 try {
338
+						$sth = $this->db->prepare($query);
339
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
340
+				} catch(PDOException $e) {
341
+						echo "error : ".$e->getMessage();
342
+				}
343
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
344
+				if (empty($all)) {
345 345
 			$filters = array('airlines' => array($stats_airline));
346 346
 			if ($filter_name != '') {
347 347
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
348 348
 			}
349
-            		$Spotter = new Spotter($this->db);
350
-            		$all = $Spotter->countAllPilots($limit,0,'',$filters);
351
-                }
352
-                return $all;
349
+					$Spotter = new Spotter($this->db);
350
+					$all = $Spotter->countAllPilots($limit,0,'',$filters);
351
+				}
352
+				return $all;
353 353
 	}
354 354
 	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '') {
355 355
 		global $globalStatsFilters;
356 356
 		if ($filter_name == '') $filter_name = $this->filter_name;
357 357
 		if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
358 358
 		else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC";
359
-                 try {
360
-                        $sth = $this->db->prepare($query);
361
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
362
-                } catch(PDOException $e) {
363
-                        echo "error : ".$e->getMessage();
364
-                }
365
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
366
-                if (empty($all)) {
359
+				 try {
360
+						$sth = $this->db->prepare($query);
361
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
362
+				} catch(PDOException $e) {
363
+						echo "error : ".$e->getMessage();
364
+				}
365
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
366
+				if (empty($all)) {
367 367
 			$filters = array('airlines' => array($stats_airline));
368 368
 			if ($filter_name != '') {
369 369
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
370 370
 			}
371
-            		$Spotter = new Spotter($this->db);
372
-            		$all = $Spotter->countAllOwners($limit,0,'',$filters);
373
-                }
374
-                return $all;
371
+					$Spotter = new Spotter($this->db);
372
+					$all = $Spotter->countAllOwners($limit,0,'',$filters);
373
+				}
374
+				return $all;
375 375
 	}
376 376
 	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '') {
377 377
 		global $globalStatsFilters;
378 378
 		if ($filter_name == '') $filter_name = $this->filter_name;
379 379
 		if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
380 380
 		else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
381
-                 try {
382
-                        $sth = $this->db->prepare($query);
383
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
384
-                } catch(PDOException $e) {
385
-                        echo "error : ".$e->getMessage();
386
-                }
387
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
388
-                if (empty($all)) {
381
+				 try {
382
+						$sth = $this->db->prepare($query);
383
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
384
+				} catch(PDOException $e) {
385
+						echo "error : ".$e->getMessage();
386
+				}
387
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
388
+				if (empty($all)) {
389 389
 			$filters = array('airlines' => array($stats_airline));
390
-            		if ($filter_name != '') {
391
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
392
-			}
393
-            		$Spotter = new Spotter($this->db);
394
-            		$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters);
395
-        		$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters);
396
-        		$all = array();
397
-        		foreach ($pall as $value) {
398
-        			$icao = $value['airport_departure_icao'];
399
-        			$all[$icao] = $value;
400
-        		}
390
+					if ($filter_name != '') {
391
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
392
+			}
393
+					$Spotter = new Spotter($this->db);
394
+					$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters);
395
+				$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters);
396
+				$all = array();
397
+				foreach ($pall as $value) {
398
+					$icao = $value['airport_departure_icao'];
399
+					$all[$icao] = $value;
400
+				}
401 401
         		
402
-        		foreach ($dall as $value) {
403
-        			$icao = $value['airport_departure_icao'];
404
-        			if (isset($all[$icao])) {
405
-        				$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
406
-        			} else $all[$icao] = $value;
407
-        		}
408
-        		$count = array();
409
-        		foreach ($all as $key => $row) {
410
-        			$count[$key] = $row['airport_departure_icao_count'];
411
-        		}
412
-        		array_multisort($count,SORT_DESC,$all);
413
-                }
414
-                return $all;
402
+				foreach ($dall as $value) {
403
+					$icao = $value['airport_departure_icao'];
404
+					if (isset($all[$icao])) {
405
+						$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
406
+					} else $all[$icao] = $value;
407
+				}
408
+				$count = array();
409
+				foreach ($all as $key => $row) {
410
+					$count[$key] = $row['airport_departure_icao_count'];
411
+				}
412
+				array_multisort($count,SORT_DESC,$all);
413
+				}
414
+				return $all;
415 415
 	}
416 416
 	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '') {
417 417
 		global $globalStatsFilters;
@@ -433,26 +433,26 @@  discard block
 block discarded – undo
433 433
 			$Spotter = new Spotter($this->db);
434 434
 			$pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters);
435 435
 			$dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters);
436
-        		$all = array();
437
-        		foreach ($pall as $value) {
438
-        			$icao = $value['airport_arrival_icao'];
439
-        			$all[$icao] = $value;
440
-        		}
436
+				$all = array();
437
+				foreach ($pall as $value) {
438
+					$icao = $value['airport_arrival_icao'];
439
+					$all[$icao] = $value;
440
+				}
441 441
         		
442
-        		foreach ($dall as $value) {
443
-        			$icao = $value['airport_arrival_icao'];
444
-        			if (isset($all[$icao])) {
445
-        				$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
446
-        			} else $all[$icao] = $value;
447
-        		}
448
-        		$count = array();
449
-        		foreach ($all as $key => $row) {
450
-        			$count[$key] = $row['airport_arrival_icao_count'];
451
-        		}
452
-        		array_multisort($count,SORT_DESC,$all);
453
-                }
442
+				foreach ($dall as $value) {
443
+					$icao = $value['airport_arrival_icao'];
444
+					if (isset($all[$icao])) {
445
+						$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
446
+					} else $all[$icao] = $value;
447
+				}
448
+				$count = array();
449
+				foreach ($all as $key => $row) {
450
+					$count[$key] = $row['airport_arrival_icao_count'];
451
+				}
452
+				array_multisort($count,SORT_DESC,$all);
453
+				}
454 454
  
455
-                return $all;
455
+				return $all;
456 456
 	}
457 457
 	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
458 458
 		global $globalDBdriver, $globalStatsFilters;
@@ -465,23 +465,23 @@  discard block
 block discarded – undo
465 465
 			else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
466 466
 		}
467 467
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
468
-                 try {
469
-                        $sth = $this->db->prepare($query);
470
-                        $sth->execute($query_data);
471
-                } catch(PDOException $e) {
472
-                        echo "error : ".$e->getMessage();
473
-                }
474
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
475
-                if (empty($all)) {
468
+				 try {
469
+						$sth = $this->db->prepare($query);
470
+						$sth->execute($query_data);
471
+				} catch(PDOException $e) {
472
+						echo "error : ".$e->getMessage();
473
+				}
474
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
475
+				if (empty($all)) {
476 476
 			$filters = array('airlines' => array($stats_airline));
477 477
 			if ($filter_name != '') {
478 478
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
479 479
 			}
480
-            		$Spotter = new Spotter($this->db);
481
-            		$all = $Spotter->countAllMonthsLastYear($filters);
482
-                }
480
+					$Spotter = new Spotter($this->db);
481
+					$all = $Spotter->countAllMonthsLastYear($filters);
482
+				}
483 483
                 
484
-                return $all;
484
+				return $all;
485 485
 	}
486 486
 	
487 487
 	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
@@ -489,22 +489,22 @@  discard block
 block discarded – undo
489 489
 		if ($filter_name == '') $filter_name = $this->filter_name;
490 490
 		$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline = :stats_airline AND filter_name = :filter_name";
491 491
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
492
-                 try {
493
-                        $sth = $this->db->prepare($query);
494
-                        $sth->execute($query_data);
495
-                } catch(PDOException $e) {
496
-                        echo "error : ".$e->getMessage();
497
-                }
498
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
499
-                if (empty($all)) {
492
+				 try {
493
+						$sth = $this->db->prepare($query);
494
+						$sth->execute($query_data);
495
+				} catch(PDOException $e) {
496
+						echo "error : ".$e->getMessage();
497
+				}
498
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
499
+				if (empty($all)) {
500 500
 			$filters = array('airlines' => array($stats_airline));
501 501
 			if ($filter_name != '') {
502 502
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
503 503
 			}
504
-            		$Spotter = new Spotter($this->db);
505
-            		$all = $Spotter->countAllDatesLastMonth($filters);
506
-                }
507
-                return $all;
504
+					$Spotter = new Spotter($this->db);
505
+					$all = $Spotter->countAllDatesLastMonth($filters);
506
+				}
507
+				return $all;
508 508
 	}
509 509
 	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
510 510
 		global $globalDBdriver, $globalStatsFilters;
@@ -515,108 +515,108 @@  discard block
 block discarded – undo
515 515
 			$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
516 516
 		}
517 517
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
518
-                 try {
519
-                        $sth = $this->db->prepare($query);
520
-                        $sth->execute($query_data);
521
-                } catch(PDOException $e) {
522
-                        echo "error : ".$e->getMessage();
523
-                }
524
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
525
-                if (empty($all)) {
518
+				 try {
519
+						$sth = $this->db->prepare($query);
520
+						$sth->execute($query_data);
521
+				} catch(PDOException $e) {
522
+						echo "error : ".$e->getMessage();
523
+				}
524
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
525
+				if (empty($all)) {
526 526
 			$filters = array('airlines' => array($stats_airline));
527 527
 			if ($filter_name != '') {
528 528
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
529 529
 			}
530
-            		$Spotter = new Spotter($this->db);
531
-            		$all = $Spotter->countAllDatesLast7Days($filters);
532
-                }
533
-                return $all;
530
+					$Spotter = new Spotter($this->db);
531
+					$all = $Spotter->countAllDatesLast7Days($filters);
532
+				}
533
+				return $all;
534 534
 	}
535 535
 	public function countAllDates($stats_airline = '',$filter_name = '') {
536 536
 		global $globalStatsFilters;
537 537
 		if ($filter_name == '') $filter_name = $this->filter_name;
538 538
 		$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline = :stats_airline AND filter_name = :filter_name";
539 539
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
540
-                 try {
541
-                        $sth = $this->db->prepare($query);
542
-                        $sth->execute($query_data);
543
-                } catch(PDOException $e) {
544
-                        echo "error : ".$e->getMessage();
545
-                }
546
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
547
-                if (empty($all)) {
540
+				 try {
541
+						$sth = $this->db->prepare($query);
542
+						$sth->execute($query_data);
543
+				} catch(PDOException $e) {
544
+						echo "error : ".$e->getMessage();
545
+				}
546
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
547
+				if (empty($all)) {
548 548
 			$filters = array('airlines' => array($stats_airline));
549 549
 			if ($filter_name != '') {
550
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
550
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
551 551
 			}
552
-            		$Spotter = new Spotter($this->db);
553
-            		$all = $Spotter->countAllDates($filters);
554
-                }
555
-                return $all;
552
+					$Spotter = new Spotter($this->db);
553
+					$all = $Spotter->countAllDates($filters);
554
+				}
555
+				return $all;
556 556
 	}
557 557
 	public function countAllDatesByAirlines($filter_name = '') {
558 558
 		global $globalStatsFilters;
559 559
 		if ($filter_name == '') $filter_name = $this->filter_name;
560 560
 		$query = "SELECT stats_airline as airline_icao, flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND filter_name = :filter_name";
561 561
 		$query_data = array('filter_name' => $filter_name);
562
-                 try {
563
-                        $sth = $this->db->prepare($query);
564
-                        $sth->execute($query_data);
565
-                } catch(PDOException $e) {
566
-                        echo "error : ".$e->getMessage();
567
-                }
568
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
569
-                if (empty($all)) {
570
-            		$filters = array();
571
-            		if ($filter_name != '') {
572
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
573
-			}
574
-            		$Spotter = new Spotter($this->db);
575
-            		$all = $Spotter->countAllDatesByAirlines($filters);
576
-                }
577
-                return $all;
562
+				 try {
563
+						$sth = $this->db->prepare($query);
564
+						$sth->execute($query_data);
565
+				} catch(PDOException $e) {
566
+						echo "error : ".$e->getMessage();
567
+				}
568
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
569
+				if (empty($all)) {
570
+					$filters = array();
571
+					if ($filter_name != '') {
572
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
573
+			}
574
+					$Spotter = new Spotter($this->db);
575
+					$all = $Spotter->countAllDatesByAirlines($filters);
576
+				}
577
+				return $all;
578 578
 	}
579 579
 	public function countAllMonths($stats_airline = '',$filter_name = '') {
580 580
 		global $globalStatsFilters;
581 581
 		if ($filter_name == '') $filter_name = $this->filter_name;
582
-	    	$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
583
-                 try {
584
-                        $sth = $this->db->prepare($query);
585
-                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
586
-                } catch(PDOException $e) {
587
-                        echo "error : ".$e->getMessage();
588
-                }
589
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
590
-                if (empty($all)) {
582
+			$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
583
+				 try {
584
+						$sth = $this->db->prepare($query);
585
+						$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
586
+				} catch(PDOException $e) {
587
+						echo "error : ".$e->getMessage();
588
+				}
589
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
590
+				if (empty($all)) {
591 591
 			$filters = array('airlines' => array($stats_airline));
592 592
 			if ($filter_name != '') {
593 593
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
594 594
 			}
595
-            		$Spotter = new Spotter($this->db);
596
-            		$all = $Spotter->countAllMonths($filters);
597
-                }
598
-                return $all;
595
+					$Spotter = new Spotter($this->db);
596
+					$all = $Spotter->countAllMonths($filters);
597
+				}
598
+				return $all;
599 599
 	}
600 600
 	public function countAllMilitaryMonths($filter_name = '') {
601 601
 		global $globalStatsFilters;
602 602
 		if ($filter_name == '') $filter_name = $this->filter_name;
603
-	    	$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'military_flights_bymonth' AND filter_name = :filter_name";
604
-                 try {
605
-                        $sth = $this->db->prepare($query);
606
-                        $sth->execute(array(':filter_name' => $filter_name));
607
-                } catch(PDOException $e) {
608
-                        echo "error : ".$e->getMessage();
609
-                }
610
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
611
-                if (empty($all)) {
612
-            		$filters = array();
613
-            		if ($filter_name != '') {
614
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
615
-			}
616
-            		$Spotter = new Spotter($this->db);
617
-            		$all = $Spotter->countAllMilitaryMonths($filters);
618
-                }
619
-                return $all;
603
+			$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'military_flights_bymonth' AND filter_name = :filter_name";
604
+				 try {
605
+						$sth = $this->db->prepare($query);
606
+						$sth->execute(array(':filter_name' => $filter_name));
607
+				} catch(PDOException $e) {
608
+						echo "error : ".$e->getMessage();
609
+				}
610
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
611
+				if (empty($all)) {
612
+					$filters = array();
613
+					if ($filter_name != '') {
614
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
615
+			}
616
+					$Spotter = new Spotter($this->db);
617
+					$all = $Spotter->countAllMilitaryMonths($filters);
618
+				}
619
+				return $all;
620 620
 	}
621 621
 	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
622 622
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
@@ -632,22 +632,22 @@  discard block
 block discarded – undo
632 632
 			$query .= " ORDER BY CAST(flight_date AS integer) ASC";
633 633
 		}
634 634
 		if ($orderby == 'count') $query .= " ORDER BY hour_count DESC";
635
-                 try {
636
-                        $sth = $this->db->prepare($query);
637
-                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
638
-                } catch(PDOException $e) {
639
-                        echo "error : ".$e->getMessage();
640
-                }
641
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
642
-                if (empty($all)) {
635
+				 try {
636
+						$sth = $this->db->prepare($query);
637
+						$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
638
+				} catch(PDOException $e) {
639
+						echo "error : ".$e->getMessage();
640
+				}
641
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
642
+				if (empty($all)) {
643 643
 			$filters = array('airlines' => array($stats_airline));
644 644
 			if ($filter_name != '') {
645
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
645
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
646 646
 			}
647
-            		$Spotter = new Spotter($this->db);
648
-            		$all = $Spotter->countAllHours($orderby,$filters);
649
-                }
650
-                return $all;
647
+					$Spotter = new Spotter($this->db);
648
+					$all = $Spotter->countAllHours($orderby,$filters);
649
+				}
650
+				return $all;
651 651
 	}
652 652
 	
653 653
 	public function countOverallFlights($stats_airline = '', $filter_name = '') {
@@ -669,9 +669,9 @@  discard block
 block discarded – undo
669 669
 		if ($filter_name == '') $filter_name = $this->filter_name;
670 670
 		$all = $this->getSumStats('military_flights_bymonth',date('Y'),'',$filter_name);
671 671
 		if (empty($all)) {
672
-		        $filters = array();
673
-            		if ($filter_name != '') {
674
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
672
+				$filters = array();
673
+					if ($filter_name != '') {
674
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
675 675
 			}
676 676
 			$Spotter = new Spotter($this->db);
677 677
 			$all = $Spotter->countOverallMilitaryFlights($filters);
@@ -710,19 +710,19 @@  discard block
 block discarded – undo
710 710
 		global $globalStatsFilters;
711 711
 		if ($filter_name == '') $filter_name = $this->filter_name;
712 712
 		$query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name";
713
-                 try {
714
-                        $sth = $this->db->prepare($query);
715
-                        $sth->execute(array(':filter_name' => $filter_name));
716
-                } catch(PDOException $e) {
717
-                        echo "error : ".$e->getMessage();
718
-                }
719
-                $result = $sth->fetchAll(PDO::FETCH_ASSOC);
720
-                $all = $result[0]['nb_airline'];
713
+				 try {
714
+						$sth = $this->db->prepare($query);
715
+						$sth->execute(array(':filter_name' => $filter_name));
716
+				} catch(PDOException $e) {
717
+						echo "error : ".$e->getMessage();
718
+				}
719
+				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
720
+				$all = $result[0]['nb_airline'];
721 721
 		//$all = $this->getSumStats('airlines_bymonth',date('Y'));
722 722
 		if (empty($all)) {
723
-            		$filters = array();
724
-            		if ($filter_name != '') {
725
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
723
+					$filters = array();
724
+					if ($filter_name != '') {
725
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
726 726
 			}
727 727
 			$Spotter = new Spotter($this->db);
728 728
 			$all = $Spotter->countOverallAirlines($filters);
@@ -773,166 +773,166 @@  discard block
 block discarded – undo
773 773
 		if ($filter_name == '') $filter_name = $this->filter_name;
774 774
 		$query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date";
775 775
 		$query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
776
-                 try {
777
-                        $sth = $this->db->prepare($query);
778
-                        $sth->execute($query_values);
779
-                } catch(PDOException $e) {
780
-                        echo "error : ".$e->getMessage();
781
-                }
782
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
783
-                return $all;
776
+				 try {
777
+						$sth = $this->db->prepare($query);
778
+						$sth->execute($query_values);
779
+				} catch(PDOException $e) {
780
+						echo "error : ".$e->getMessage();
781
+				}
782
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
783
+				return $all;
784 784
 	}
785 785
 	public function getStats($type,$stats_airline = '', $filter_name = '') {
786 786
 		if ($filter_name == '') $filter_name = $this->filter_name;
787
-                $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
788
-                $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
789
-                 try {
790
-                        $sth = $this->db->prepare($query);
791
-                        $sth->execute($query_values);
792
-                } catch(PDOException $e) {
793
-                        echo "error : ".$e->getMessage();
794
-                }
795
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
796
-                return $all;
797
-        }
787
+				$query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
788
+				$query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
789
+				 try {
790
+						$sth = $this->db->prepare($query);
791
+						$sth->execute($query_values);
792
+				} catch(PDOException $e) {
793
+						echo "error : ".$e->getMessage();
794
+				}
795
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
796
+				return $all;
797
+		}
798 798
 	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '') {
799 799
 		if ($filter_name == '') $filter_name = $this->filter_name;
800
-    		global $globalArchiveMonths, $globalDBdriver;
801
-    		if ($globalDBdriver == 'mysql') {
802
-	                $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name";
803
-	        } else {
804
-            		$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name";
805
-                }
806
-                $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
807
-                 try {
808
-                        $sth = $this->db->prepare($query);
809
-                        $sth->execute($query_values);
810
-                } catch(PDOException $e) {
811
-                        echo "error : ".$e->getMessage();
812
-                }
813
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
814
-                return $all[0]['total'];
815
-        }
800
+			global $globalArchiveMonths, $globalDBdriver;
801
+			if ($globalDBdriver == 'mysql') {
802
+					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name";
803
+			} else {
804
+					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name";
805
+				}
806
+				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
807
+				 try {
808
+						$sth = $this->db->prepare($query);
809
+						$sth->execute($query_values);
810
+				} catch(PDOException $e) {
811
+						echo "error : ".$e->getMessage();
812
+				}
813
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
814
+				return $all[0]['total'];
815
+		}
816 816
 	public function getStatsTotal($type, $stats_airline = '', $filter_name = '') {
817
-    		global $globalArchiveMonths, $globalDBdriver;
817
+			global $globalArchiveMonths, $globalDBdriver;
818 818
 		if ($filter_name == '') $filter_name = $this->filter_name;
819
-    		if ($globalDBdriver == 'mysql') {
819
+			if ($globalDBdriver == 'mysql') {
820 820
 			$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL ".$globalArchiveMonths." MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name";
821 821
 		} else {
822 822
 			$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveMonths." MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
823
-                }
824
-                $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
825
-                 try {
826
-                        $sth = $this->db->prepare($query);
827
-                        $sth->execute($query_values);
828
-                } catch(PDOException $e) {
829
-                        echo "error : ".$e->getMessage();
830
-                }
831
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
832
-                return $all[0]['total'];
833
-        }
823
+				}
824
+				$query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
825
+				 try {
826
+						$sth = $this->db->prepare($query);
827
+						$sth->execute($query_values);
828
+				} catch(PDOException $e) {
829
+						echo "error : ".$e->getMessage();
830
+				}
831
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
832
+				return $all[0]['total'];
833
+		}
834 834
 	public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') {
835
-    		global $globalArchiveMonths, $globalDBdriver;
835
+			global $globalArchiveMonths, $globalDBdriver;
836 836
 		if ($filter_name == '') $filter_name = $this->filter_name;
837
-    		if ($globalDBdriver == 'mysql') {
837
+			if ($globalDBdriver == 'mysql') {
838 838
 			$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
839
-                } else {
839
+				} else {
840 840
 			$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
841
-                }
842
-                 try {
843
-                        $sth = $this->db->prepare($query);
844
-                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
845
-                } catch(PDOException $e) {
846
-                        echo "error : ".$e->getMessage();
847
-                }
848
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
849
-                return $all[0]['total'];
850
-        }
841
+				}
842
+				 try {
843
+						$sth = $this->db->prepare($query);
844
+						$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
845
+				} catch(PDOException $e) {
846
+						echo "error : ".$e->getMessage();
847
+				}
848
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
849
+				return $all[0]['total'];
850
+		}
851 851
 	public function getStatsAirlineTotal($filter_name = '') {
852
-    		global $globalArchiveMonths, $globalDBdriver;
852
+			global $globalArchiveMonths, $globalDBdriver;
853 853
 		if ($filter_name == '') $filter_name = $this->filter_name;
854
-    		if ($globalDBdriver == 'mysql') {
854
+			if ($globalDBdriver == 'mysql') {
855 855
 			$query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name";
856
-                } else {
856
+				} else {
857 857
 			$query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name";
858
-                }
859
-                 try {
860
-                        $sth = $this->db->prepare($query);
861
-                        $sth->execute(array(':filter_name' => $filter_name));
862
-                } catch(PDOException $e) {
863
-                        echo "error : ".$e->getMessage();
864
-                }
865
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
866
-                return $all[0]['total'];
867
-        }
858
+				}
859
+				 try {
860
+						$sth = $this->db->prepare($query);
861
+						$sth->execute(array(':filter_name' => $filter_name));
862
+				} catch(PDOException $e) {
863
+						echo "error : ".$e->getMessage();
864
+				}
865
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
866
+				return $all[0]['total'];
867
+		}
868 868
 	public function getStatsOwnerTotal($filter_name = '') {
869
-    		global $globalArchiveMonths, $globalDBdriver;
869
+			global $globalArchiveMonths, $globalDBdriver;
870 870
 		if ($filter_name == '') $filter_name = $this->filter_name;
871
-    		if ($globalDBdriver == 'mysql') {
871
+			if ($globalDBdriver == 'mysql') {
872 872
 			$query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name";
873 873
 		} else {
874 874
 			$query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name";
875
-                }
876
-                 try {
877
-                        $sth = $this->db->prepare($query);
878
-                        $sth->execute(array(':filter_name' => $filter_name));
879
-                } catch(PDOException $e) {
880
-                        echo "error : ".$e->getMessage();
881
-                }
882
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
883
-                return $all[0]['total'];
884
-        }
875
+				}
876
+				 try {
877
+						$sth = $this->db->prepare($query);
878
+						$sth->execute(array(':filter_name' => $filter_name));
879
+				} catch(PDOException $e) {
880
+						echo "error : ".$e->getMessage();
881
+				}
882
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
883
+				return $all[0]['total'];
884
+		}
885 885
 	public function getStatsPilotTotal($filter_name = '') {
886
-    		global $globalArchiveMonths, $globalDBdriver;
886
+			global $globalArchiveMonths, $globalDBdriver;
887 887
 		if ($filter_name == '') $filter_name = $this->filter_name;
888
-    		if ($globalDBdriver == 'mysql') {
889
-            		$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
890
-            	} else {
891
-            		$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
892
-            	}
893
-                 try {
894
-                        $sth = $this->db->prepare($query);
895
-                        $sth->execute(array(':filter_name' => $filter_name));
896
-                } catch(PDOException $e) {
897
-                        echo "error : ".$e->getMessage();
898
-                }
899
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
900
-                return $all[0]['total'];
901
-        }
888
+			if ($globalDBdriver == 'mysql') {
889
+					$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
890
+				} else {
891
+					$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
892
+				}
893
+				 try {
894
+						$sth = $this->db->prepare($query);
895
+						$sth->execute(array(':filter_name' => $filter_name));
896
+				} catch(PDOException $e) {
897
+						echo "error : ".$e->getMessage();
898
+				}
899
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
900
+				return $all[0]['total'];
901
+		}
902 902
 
903 903
 	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
904 904
 		global $globalDBdriver;
905 905
 		if ($filter_name == '') $filter_name = $this->filter_name;
906 906
 		if ($globalDBdriver == 'mysql') {
907 907
 			$query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = :cnt";
908
-                } else {
908
+				} else {
909 909
 			$query = "UPDATE stats SET cnt = :cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE  stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
910 910
 		}
911
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
912
-                 try {
913
-                        $sth = $this->db->prepare($query);
914
-                        $sth->execute($query_values);
915
-                } catch(PDOException $e) {
916
-                        return "error : ".$e->getMessage();
917
-                }
918
-        }
911
+				$query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
912
+				 try {
913
+						$sth = $this->db->prepare($query);
914
+						$sth->execute($query_values);
915
+				} catch(PDOException $e) {
916
+						return "error : ".$e->getMessage();
917
+				}
918
+		}
919 919
 	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
920 920
 		global $globalDBdriver;
921 921
 		if ($filter_name == '') $filter_name = $this->filter_name;
922 922
 		if ($globalDBdriver == 'mysql') {
923 923
 			$query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
924 924
 		} else {
925
-            		//$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
925
+					//$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
926 926
 			$query = "UPDATE stats SET cnt = cnt+:cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE  stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
927
-                }
928
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
929
-                 try {
930
-                        $sth = $this->db->prepare($query);
931
-                        $sth->execute($query_values);
932
-                } catch(PDOException $e) {
933
-                        return "error : ".$e->getMessage();
934
-                }
935
-        }
927
+				}
928
+				$query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
929
+				 try {
930
+						$sth = $this->db->prepare($query);
931
+						$sth->execute($query_values);
932
+				} catch(PDOException $e) {
933
+						return "error : ".$e->getMessage();
934
+				}
935
+		}
936 936
 	public function getStatsSource($date,$stats_type = '') {
937 937
 		if ($stats_type == '') {
938 938
 			$query = "SELECT * FROM stats_source WHERE stats_date = :date ORDER BY source_name";
@@ -941,15 +941,15 @@  discard block
 block discarded – undo
941 941
 			$query = "SELECT * FROM stats_source WHERE stats_date = :date AND stats_type = :stats_type ORDER BY source_name";
942 942
 			$query_values = array(':date' => $date,':stats_type' => $stats_type);
943 943
 		}
944
-                 try {
945
-                        $sth = $this->db->prepare($query);
946
-                        $sth->execute($query_values);
947
-                } catch(PDOException $e) {
948
-                        echo "error : ".$e->getMessage();
949
-                }
950
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
951
-                return $all;
952
-        }
944
+				 try {
945
+						$sth = $this->db->prepare($query);
946
+						$sth->execute($query_values);
947
+				} catch(PDOException $e) {
948
+						echo "error : ".$e->getMessage();
949
+				}
950
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
951
+				return $all;
952
+		}
953 953
 
954 954
 	public function addStatSource($data,$source_name,$stats_type,$date) {
955 955
 		global $globalDBdriver;
@@ -957,25 +957,25 @@  discard block
 block discarded – undo
957 957
 			$query = "INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) VALUES (:data,:source_name,:stats_type,:stats_date) ON DUPLICATE KEY UPDATE source_data = :data";
958 958
 		} else {
959 959
 			$query = "UPDATE stats_source SET source_data = :data WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type; INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) SELECT :data,:source_name,:stats_type,:stats_date WHERE NOT EXISTS (SELECT 1 FROM stats_source WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type);"; 
960
-                }
961
-                $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type);
962
-                 try {
963
-                        $sth = $this->db->prepare($query);
964
-                        $sth->execute($query_values);
965
-                } catch(PDOException $e) {
966
-                        return "error : ".$e->getMessage();
967
-                }
968
-        }
960
+				}
961
+				$query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type);
962
+				 try {
963
+						$sth = $this->db->prepare($query);
964
+						$sth->execute($query_values);
965
+				} catch(PDOException $e) {
966
+						return "error : ".$e->getMessage();
967
+				}
968
+		}
969 969
 	public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') {
970
-                $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)";
971
-                $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
972
-                 try {
973
-                        $sth = $this->db->prepare($query);
974
-                        $sth->execute($query_values);
975
-                } catch(PDOException $e) {
976
-                        return "error : ".$e->getMessage();
977
-                }
978
-        }
970
+				$query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)";
971
+				$query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
972
+				 try {
973
+						$sth = $this->db->prepare($query);
974
+						$sth->execute($query_values);
975
+				} catch(PDOException $e) {
976
+						return "error : ".$e->getMessage();
977
+				}
978
+		}
979 979
 	public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '') {
980 980
 		global $globalDBdriver;
981 981
 		if ($globalDBdriver == 'mysql') {
@@ -983,14 +983,14 @@  discard block
 block discarded – undo
983 983
 		} else {
984 984
 			$query = "UPDATE stats_registration SET cnt = cnt+:cnt WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_registration (aircraft_icao,registration,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:registration,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_registration WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
985 985
 		}
986
-                $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
987
-                 try {
988
-                        $sth = $this->db->prepare($query);
989
-                        $sth->execute($query_values);
990
-                } catch(PDOException $e) {
991
-                        return "error : ".$e->getMessage();
992
-                }
993
-        }
986
+				$query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
987
+				 try {
988
+						$sth = $this->db->prepare($query);
989
+						$sth->execute($query_values);
990
+				} catch(PDOException $e) {
991
+						return "error : ".$e->getMessage();
992
+				}
993
+		}
994 994
 	public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '') {
995 995
 		global $globalDBdriver;
996 996
 		if ($globalDBdriver == 'mysql') {
@@ -998,14 +998,14 @@  discard block
 block discarded – undo
998 998
 		} else {
999 999
 			$query = "UPDATE stats_callsign SET cnt = cnt+:cnt WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name; INSERT INTO stats_callsign (callsign_icao,airline_icao,cnt,filter_name) SELECT :callsign_icao,:airline_icao,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_callsign WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name);"; 
1000 1000
 		}
1001
-                $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name);
1002
-                 try {
1003
-                        $sth = $this->db->prepare($query);
1004
-                        $sth->execute($query_values);
1005
-                } catch(PDOException $e) {
1006
-                        return "error : ".$e->getMessage();
1007
-                }
1008
-        }
1001
+				$query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name);
1002
+				 try {
1003
+						$sth = $this->db->prepare($query);
1004
+						$sth->execute($query_values);
1005
+				} catch(PDOException $e) {
1006
+						return "error : ".$e->getMessage();
1007
+				}
1008
+		}
1009 1009
 	public function addStatCountry($iso2,$iso3,$name,$cnt,$filter_name = '') {
1010 1010
 		global $globalDBdriver;
1011 1011
 		if ($globalDBdriver == 'mysql') {
@@ -1013,14 +1013,14 @@  discard block
 block discarded – undo
1013 1013
 		} else {
1014 1014
 			$query = "UPDATE stats_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name; INSERT INTO stats_country (iso2,iso3,name,cnt,filter_name) SELECT :iso2,:iso3,:name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_country WHERE iso2 = :iso2 AND filter_name = :filter_name);"; 
1015 1015
 		}
1016
-                $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name);
1017
-                 try {
1018
-                        $sth = $this->db->prepare($query);
1019
-                        $sth->execute($query_values);
1020
-                } catch(PDOException $e) {
1021
-                        return "error : ".$e->getMessage();
1022
-                }
1023
-        }
1016
+				$query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name);
1017
+				 try {
1018
+						$sth = $this->db->prepare($query);
1019
+						$sth->execute($query_values);
1020
+				} catch(PDOException $e) {
1021
+						return "error : ".$e->getMessage();
1022
+				}
1023
+		}
1024 1024
 	public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '') {
1025 1025
 		global $globalDBdriver;
1026 1026
 		if ($globalDBdriver == 'mysql') {
@@ -1028,14 +1028,14 @@  discard block
 block discarded – undo
1028 1028
 		} else {
1029 1029
 			$query = "UPDATE stats_aircraft SET cnt = cnt+:cnt, aircraft_name = :aircraft_name, aircraft_manufacturer = :aircraft_manufacturer, filter_name = :filter_name WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_aircraft (aircraft_icao,aircraft_name,aircraft_manufacturer,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:aircraft_name,:aircraft_manufacturer,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_aircraft WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1030 1030
 		}
1031
-                $query_values = array(':aircraft_icao' => $aircraft_icao,':aircraft_name' => $aircraft_name,':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1032
-                 try {
1033
-                        $sth = $this->db->prepare($query);
1034
-                        $sth->execute($query_values);
1035
-                } catch(PDOException $e) {
1036
-                        return "error : ".$e->getMessage();
1037
-                }
1038
-        }
1031
+				$query_values = array(':aircraft_icao' => $aircraft_icao,':aircraft_name' => $aircraft_name,':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1032
+				 try {
1033
+						$sth = $this->db->prepare($query);
1034
+						$sth->execute($query_values);
1035
+				} catch(PDOException $e) {
1036
+						return "error : ".$e->getMessage();
1037
+				}
1038
+		}
1039 1039
 	public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '') {
1040 1040
 		global $globalDBdriver;
1041 1041
 		if ($globalDBdriver == 'mysql') {
@@ -1043,14 +1043,14 @@  discard block
 block discarded – undo
1043 1043
 		} else {
1044 1044
 			$query = "UPDATE stats_airline SET cnt = cnt+:cnt WHERE airline_icao = :airline_icao AND filter_name = :filter_name; INSERT INTO stats_airline (airline_icao,airline_name,cnt,filter_name) SELECT :airline_icao,:airline_name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airline WHERE airline_icao = :airline_icao AND filter_name = :filter_name);"; 
1045 1045
 		}
1046
-                $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name);
1047
-                 try {
1048
-                        $sth = $this->db->prepare($query);
1049
-                        $sth->execute($query_values);
1050
-                } catch(PDOException $e) {
1051
-                        return "error : ".$e->getMessage();
1052
-                }
1053
-        }
1046
+				$query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name);
1047
+				 try {
1048
+						$sth = $this->db->prepare($query);
1049
+						$sth->execute($query_values);
1050
+				} catch(PDOException $e) {
1051
+						return "error : ".$e->getMessage();
1052
+				}
1053
+		}
1054 1054
 	public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '') {
1055 1055
 		global $globalDBdriver;
1056 1056
 		if ($globalDBdriver == 'mysql') {
@@ -1058,14 +1058,14 @@  discard block
 block discarded – undo
1058 1058
 		} else {
1059 1059
 			$query = "UPDATE stats_owner SET cnt = cnt+:cnt WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_owner (owner_name,cnt,stats_airline,filter_name) SELECT :owner_name,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_owner WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1060 1060
 		}
1061
-                $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1062
-                 try {
1063
-                        $sth = $this->db->prepare($query);
1064
-                        $sth->execute($query_values);
1065
-                } catch(PDOException $e) {
1066
-                        return "error : ".$e->getMessage();
1067
-                }
1068
-        }
1061
+				$query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1062
+				 try {
1063
+						$sth = $this->db->prepare($query);
1064
+						$sth->execute($query_values);
1065
+				} catch(PDOException $e) {
1066
+						return "error : ".$e->getMessage();
1067
+				}
1068
+		}
1069 1069
 	public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '',$format_source = '') {
1070 1070
 		global $globalDBdriver;
1071 1071
 		if ($globalDBdriver == 'mysql') {
@@ -1073,14 +1073,14 @@  discard block
 block discarded – undo
1073 1073
 		} else {
1074 1074
 			$query = "UPDATE stats_pilot SET cnt = cnt+:cnt, pilot_name = :pilot_name WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source; INSERT INTO stats_pilot (pilot_id,cnt,pilot_name,stats_airline,filter_name,format_source) SELECT :pilot_id,:cnt,:pilot_name,:stats_airline,:filter_name,:format_source WHERE NOT EXISTS (SELECT 1 FROM stats_pilot WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source);"; 
1075 1075
 		}
1076
-                $query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name,':format_source' => $format_source);
1077
-                 try {
1078
-                        $sth = $this->db->prepare($query);
1079
-                        $sth->execute($query_values);
1080
-                } catch(PDOException $e) {
1081
-                        return "error : ".$e->getMessage();
1082
-                }
1083
-        }
1076
+				$query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name,':format_source' => $format_source);
1077
+				 try {
1078
+						$sth = $this->db->prepare($query);
1079
+						$sth->execute($query_values);
1080
+				} catch(PDOException $e) {
1081
+						return "error : ".$e->getMessage();
1082
+				}
1083
+		}
1084 1084
 	public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') {
1085 1085
 		global $globalDBdriver;
1086 1086
 		if ($globalDBdriver == 'mysql') {
@@ -1088,14 +1088,14 @@  discard block
 block discarded – undo
1088 1088
 		} else {
1089 1089
 			$query = "UPDATE stats_airport SET departure = departure+:departure WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; 
1090 1090
 		}
1091
-                $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao,':filter_name' => $filter_name);
1092
-                 try {
1093
-                        $sth = $this->db->prepare($query);
1094
-                        $sth->execute($query_values);
1095
-                } catch(PDOException $e) {
1096
-                        return "error : ".$e->getMessage();
1097
-                }
1098
-        }
1091
+				$query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao,':filter_name' => $filter_name);
1092
+				 try {
1093
+						$sth = $this->db->prepare($query);
1094
+						$sth->execute($query_values);
1095
+				} catch(PDOException $e) {
1096
+						return "error : ".$e->getMessage();
1097
+				}
1098
+		}
1099 1099
 	public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') {
1100 1100
 		global $globalDBdriver;
1101 1101
 		if ($globalDBdriver == 'mysql') {
@@ -1103,14 +1103,14 @@  discard block
 block discarded – undo
1103 1103
 		} else {
1104 1104
 			$query = "UPDATE stats_airport SET departure = departure+:departure WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'daily',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1105 1105
 		}
1106
-                $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name);
1107
-                 try {
1108
-                        $sth = $this->db->prepare($query);
1109
-                        $sth->execute($query_values);
1110
-                } catch(PDOException $e) {
1111
-                        return "error : ".$e->getMessage();
1112
-                }
1113
-        }
1106
+				$query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name);
1107
+				 try {
1108
+						$sth = $this->db->prepare($query);
1109
+						$sth->execute($query_values);
1110
+				} catch(PDOException $e) {
1111
+						return "error : ".$e->getMessage();
1112
+				}
1113
+		}
1114 1114
 	public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') {
1115 1115
 		global $globalDBdriver;
1116 1116
 		if ($globalDBdriver == 'mysql') {
@@ -1118,14 +1118,14 @@  discard block
 block discarded – undo
1118 1118
 		} else {
1119 1119
 			$query = "UPDATE stats_airport SET arrival = arrival+:arrival WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; 
1120 1120
 		}
1121
-                $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival,':date' => date('Y').'-01-01 00:00:00',':stats_airline' => $airline_icao,':filter_name' => $filter_name);
1122
-                 try {
1123
-                        $sth = $this->db->prepare($query);
1124
-                        $sth->execute($query_values);
1125
-                } catch(PDOException $e) {
1126
-                        return "error : ".$e->getMessage();
1127
-                }
1128
-        }
1121
+				$query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival,':date' => date('Y').'-01-01 00:00:00',':stats_airline' => $airline_icao,':filter_name' => $filter_name);
1122
+				 try {
1123
+						$sth = $this->db->prepare($query);
1124
+						$sth->execute($query_values);
1125
+				} catch(PDOException $e) {
1126
+						return "error : ".$e->getMessage();
1127
+				}
1128
+		}
1129 1129
 	public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') {
1130 1130
 		global $globalDBdriver;
1131 1131
 		if ($globalDBdriver == 'mysql') {
@@ -1133,52 +1133,52 @@  discard block
 block discarded – undo
1133 1133
 		} else {
1134 1134
 			$query = "UPDATE stats_airport SET arrival = arrival+:arrival WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'daily',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1135 1135
 		}
1136
-                $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival, ':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name);
1137
-                 try {
1138
-                        $sth = $this->db->prepare($query);
1139
-                        $sth->execute($query_values);
1140
-                } catch(PDOException $e) {
1141
-                        return "error : ".$e->getMessage();
1142
-                }
1143
-        }
1136
+				$query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival, ':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name);
1137
+				 try {
1138
+						$sth = $this->db->prepare($query);
1139
+						$sth->execute($query_values);
1140
+				} catch(PDOException $e) {
1141
+						return "error : ".$e->getMessage();
1142
+				}
1143
+		}
1144 1144
 
1145 1145
 	public function deleteStat($id) {
1146
-                $query = "DELETE FROM stats WHERE stats_id = :id";
1147
-                $query_values = array(':id' => $id);
1148
-                 try {
1149
-                        $sth = $this->db->prepare($query);
1150
-                        $sth->execute($query_values);
1151
-                } catch(PDOException $e) {
1152
-                        return "error : ".$e->getMessage();
1153
-                }
1154
-        }
1146
+				$query = "DELETE FROM stats WHERE stats_id = :id";
1147
+				$query_values = array(':id' => $id);
1148
+				 try {
1149
+						$sth = $this->db->prepare($query);
1150
+						$sth->execute($query_values);
1151
+				} catch(PDOException $e) {
1152
+						return "error : ".$e->getMessage();
1153
+				}
1154
+		}
1155 1155
 	public function deleteStatFlight($type) {
1156
-                $query = "DELETE FROM stats_flight WHERE stats_type = :type";
1157
-                $query_values = array(':type' => $type);
1158
-                 try {
1159
-                        $sth = $this->db->prepare($query);
1160
-                        $sth->execute($query_values);
1161
-                } catch(PDOException $e) {
1162
-                        return "error : ".$e->getMessage();
1163
-                }
1164
-        }
1156
+				$query = "DELETE FROM stats_flight WHERE stats_type = :type";
1157
+				$query_values = array(':type' => $type);
1158
+				 try {
1159
+						$sth = $this->db->prepare($query);
1160
+						$sth->execute($query_values);
1161
+				} catch(PDOException $e) {
1162
+						return "error : ".$e->getMessage();
1163
+				}
1164
+		}
1165 1165
 	public function deleteStatAirport($type) {
1166
-                $query = "DELETE FROM stats_airport WHERE stats_type = :type";
1167
-                $query_values = array(':type' => $type);
1168
-                 try {
1169
-                        $sth = $this->db->prepare($query);
1170
-                        $sth->execute($query_values);
1171
-                } catch(PDOException $e) {
1172
-                        return "error : ".$e->getMessage();
1173
-                }
1174
-        }
1166
+				$query = "DELETE FROM stats_airport WHERE stats_type = :type";
1167
+				$query_values = array(':type' => $type);
1168
+				 try {
1169
+						$sth = $this->db->prepare($query);
1170
+						$sth->execute($query_values);
1171
+				} catch(PDOException $e) {
1172
+						return "error : ".$e->getMessage();
1173
+				}
1174
+		}
1175 1175
         
1176
-        public function addOldStats() {
1177
-    		global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats;
1178
-    		$Common = new Common();
1179
-    		$Connection = new Connection();
1180
-    		date_default_timezone_set('UTC');
1181
-    		$last_update = $this->getLastStatsUpdate('last_update_stats');
1176
+		public function addOldStats() {
1177
+			global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats;
1178
+			$Common = new Common();
1179
+			$Connection = new Connection();
1180
+			date_default_timezone_set('UTC');
1181
+			$last_update = $this->getLastStatsUpdate('last_update_stats');
1182 1182
 		//print_r($last_update);
1183 1183
 		/*
1184 1184
 		$flightsbymonth = $this->getStats('flights_by_month');
@@ -1440,24 +1440,24 @@  discard block
 block discarded – undo
1440 1440
 			if ($globalDebug) echo 'Count all departure airports...'."\n";
1441 1441
 			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
1442 1442
 			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
1443
-        		$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1443
+				$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1444 1444
 			if ($globalDebug) echo 'Order departure airports...'."\n";
1445
-	        	$alldata = array();
1445
+				$alldata = array();
1446 1446
 	        	
1447
-    			foreach ($pall as $value) {
1448
-	        		$icao = $value['airport_departure_icao'];
1449
-    				$alldata[$icao] = $value;
1450
-	        	}
1451
-	        	foreach ($dall as $value) {
1452
-    				$icao = $value['airport_departure_icao'];
1453
-        			if (isset($alldata[$icao])) {
1454
-    					$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1455
-        			} else $alldata[$icao] = $value;
1456
-			}
1457
-    			$count = array();
1458
-    			foreach ($alldata as $key => $row) {
1459
-    				$count[$key] = $row['airport_departure_icao_count'];
1460
-        		}
1447
+				foreach ($pall as $value) {
1448
+					$icao = $value['airport_departure_icao'];
1449
+					$alldata[$icao] = $value;
1450
+				}
1451
+				foreach ($dall as $value) {
1452
+					$icao = $value['airport_departure_icao'];
1453
+					if (isset($alldata[$icao])) {
1454
+						$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1455
+					} else $alldata[$icao] = $value;
1456
+			}
1457
+				$count = array();
1458
+				foreach ($alldata as $key => $row) {
1459
+					$count[$key] = $row['airport_departure_icao_count'];
1460
+				}
1461 1461
 			array_multisort($count,SORT_DESC,$alldata);
1462 1462
 			foreach ($alldata as $number) {
1463 1463
 				echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count']);
@@ -1465,25 +1465,25 @@  discard block
 block discarded – undo
1465 1465
 			if ($globalDebug) echo 'Count all arrival airports...'."\n";
1466 1466
 			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
1467 1467
 			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
1468
-        		$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1468
+				$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1469 1469
 			if ($globalDebug) echo 'Order arrival airports...'."\n";
1470
-	        	$alldata = array();
1471
-    			foreach ($pall as $value) {
1472
-	        		$icao = $value['airport_arrival_icao'];
1473
-    				$alldata[$icao] = $value;
1474
-	        	}
1475
-	        	foreach ($dall as $value) {
1476
-    				$icao = $value['airport_arrival_icao'];
1477
-        			if (isset($alldata[$icao])) {
1478
-        				$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1479
-	        		} else $alldata[$icao] = $value;
1480
-    			}
1481
-        		$count = array();
1482
-        		foreach ($alldata as $key => $row) {
1483
-        			$count[$key] = $row['airport_arrival_icao_count'];
1484
-	        	}
1485
-    			array_multisort($count,SORT_DESC,$alldata);
1486
-                        foreach ($alldata as $number) {
1470
+				$alldata = array();
1471
+				foreach ($pall as $value) {
1472
+					$icao = $value['airport_arrival_icao'];
1473
+					$alldata[$icao] = $value;
1474
+				}
1475
+				foreach ($dall as $value) {
1476
+					$icao = $value['airport_arrival_icao'];
1477
+					if (isset($alldata[$icao])) {
1478
+						$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1479
+					} else $alldata[$icao] = $value;
1480
+				}
1481
+				$count = array();
1482
+				foreach ($alldata as $key => $row) {
1483
+					$count[$key] = $row['airport_arrival_icao_count'];
1484
+				}
1485
+				array_multisort($count,SORT_DESC,$alldata);
1486
+						foreach ($alldata as $number) {
1487 1487
 				echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count']);
1488 1488
 			}
1489 1489
 			if ($Connection->tableExists('countries')) {
@@ -1543,8 +1543,8 @@  discard block
 block discarded – undo
1543 1543
 //			$pall = $Spotter->getLast7DaysAirportsDeparture();
1544 1544
   //      		$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
1545 1545
 			$pall = $Spotter->getLast7DaysAirportsDeparture();
1546
-        		$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
1547
-        		/*
1546
+				$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
1547
+				/*
1548 1548
 	        	$alldata = array();
1549 1549
     			foreach ($pall as $value) {
1550 1550
 	        		$icao = $value['departure_airport_icao'];
@@ -1563,29 +1563,29 @@  discard block
 block discarded – undo
1563 1563
 	        	}
1564 1564
     			array_multisort($count,SORT_DESC,$alldata);
1565 1565
     			*/
1566
-    			foreach ($dall as $value) {
1567
-    				$icao = $value['departure_airport_icao'];
1568
-    				$ddate = $value['date'];
1569
-    				$find = false;
1570
-    				foreach ($pall as $pvalue) {
1571
-    					if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1572
-    						$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1573
-    						$find = true;
1574
-    						break;
1575
-    					}
1576
-    				}
1577
-    				if ($find === false) {
1578
-    					$pall[] = $value;
1579
-    				}
1580
-    			}
1581
-    			$alldata = $pall;
1566
+				foreach ($dall as $value) {
1567
+					$icao = $value['departure_airport_icao'];
1568
+					$ddate = $value['date'];
1569
+					$find = false;
1570
+					foreach ($pall as $pvalue) {
1571
+						if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1572
+							$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1573
+							$find = true;
1574
+							break;
1575
+						}
1576
+					}
1577
+					if ($find === false) {
1578
+						$pall[] = $value;
1579
+					}
1580
+				}
1581
+				$alldata = $pall;
1582 1582
 			foreach ($alldata as $number) {
1583 1583
 				$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']);
1584 1584
 			}
1585 1585
 			echo '...Arrival'."\n";
1586 1586
 			$pall = $Spotter->getLast7DaysAirportsArrival();
1587
-        		$dall = $Spotter->getLast7DaysDetectedAirportsArrival();
1588
-        		/*
1587
+				$dall = $Spotter->getLast7DaysDetectedAirportsArrival();
1588
+				/*
1589 1589
 	        	$alldata = array();
1590 1590
     			foreach ($pall as $value) {
1591 1591
 	        		$icao = $value['arrival_airport_icao'];
@@ -1605,22 +1605,22 @@  discard block
 block discarded – undo
1605 1605
     			*/
1606 1606
 
1607 1607
 
1608
-    			foreach ($dall as $value) {
1609
-    				$icao = $value['arrival_airport_icao'];
1610
-    				$ddate = $value['date'];
1611
-    				$find = false;
1612
-    				foreach ($pall as $pvalue) {
1613
-    					if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1614
-    						$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1615
-    						$find = true;
1616
-    						break;
1617
-    					}
1618
-    				}
1619
-    				if ($find === false) {
1620
-    					$pall[] = $value;
1621
-    				}
1622
-    			}
1623
-    			$alldata = $pall;
1608
+				foreach ($dall as $value) {
1609
+					$icao = $value['arrival_airport_icao'];
1610
+					$ddate = $value['date'];
1611
+					$find = false;
1612
+					foreach ($pall as $pvalue) {
1613
+						if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1614
+							$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1615
+							$find = true;
1616
+							break;
1617
+						}
1618
+					}
1619
+					if ($find === false) {
1620
+						$pall[] = $value;
1621
+					}
1622
+				}
1623
+				$alldata = $pall;
1624 1624
 			foreach ($alldata as $number) {
1625 1625
 				$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']);
1626 1626
 			}
@@ -1687,51 +1687,51 @@  discard block
 block discarded – undo
1687 1687
 			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
1688 1688
 			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
1689 1689
 			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
1690
-       			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
1690
+	   			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
1691 1691
 			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
1692
-	        	//$alldata = array();
1693
-    			foreach ($dall as $value) {
1694
-    				$icao = $value['airport_departure_icao'];
1695
-    				$dicao = $value['airline_icao'];
1696
-    				$find = false;
1697
-    				foreach ($pall as $pvalue) {
1698
-    					if ($pvalue['airport_departure_icao'] == $icao && $pvalue['airline_icao'] = $dicao) {
1699
-    						$pvalue['airport_departure_icao_count'] = $pvalue['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1700
-    						$find = true;
1701
-    						break;
1702
-    					}
1703
-    				}
1704
-    				if ($find === false) {
1705
-    					$pall[] = $value;
1706
-    				}
1707
-    			}
1708
-    			$alldata = $pall;
1692
+				//$alldata = array();
1693
+				foreach ($dall as $value) {
1694
+					$icao = $value['airport_departure_icao'];
1695
+					$dicao = $value['airline_icao'];
1696
+					$find = false;
1697
+					foreach ($pall as $pvalue) {
1698
+						if ($pvalue['airport_departure_icao'] == $icao && $pvalue['airline_icao'] = $dicao) {
1699
+							$pvalue['airport_departure_icao_count'] = $pvalue['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1700
+							$find = true;
1701
+							break;
1702
+						}
1703
+					}
1704
+					if ($find === false) {
1705
+						$pall[] = $value;
1706
+					}
1707
+				}
1708
+				$alldata = $pall;
1709 1709
 			foreach ($alldata as $number) {
1710 1710
 				echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],$number['airline_icao']);
1711 1711
 			}
1712 1712
 			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
1713 1713
 			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
1714 1714
 			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
1715
-        		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
1715
+				$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
1716 1716
 			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
1717
-	        	//$alldata = array();
1718
-    			foreach ($dall as $value) {
1719
-    				$icao = $value['airport_arrival_icao'];
1720
-    				$dicao = $value['airline_icao'];
1721
-    				$find = false;
1722
-    				foreach ($pall as $pvalue) {
1723
-    					if ($pvalue['airport_arrival_icao'] == $icao && $pvalue['airline_icao'] = $dicao) {
1724
-    						$pvalue['airport_arrival_icao_count'] = $pvalue['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1725
-    						$find = true;
1726
-    						break;
1727
-    					}
1728
-    				}
1729
-    				if ($find === false) {
1730
-    					$pall[] = $value;
1731
-    				}
1732
-    			}
1733
-    			$alldata = $pall;
1734
-                        foreach ($alldata as $number) {
1717
+				//$alldata = array();
1718
+				foreach ($dall as $value) {
1719
+					$icao = $value['airport_arrival_icao'];
1720
+					$dicao = $value['airline_icao'];
1721
+					$find = false;
1722
+					foreach ($pall as $pvalue) {
1723
+						if ($pvalue['airport_arrival_icao'] == $icao && $pvalue['airline_icao'] = $dicao) {
1724
+							$pvalue['airport_arrival_icao_count'] = $pvalue['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1725
+							$find = true;
1726
+							break;
1727
+						}
1728
+					}
1729
+					if ($find === false) {
1730
+						$pall[] = $value;
1731
+					}
1732
+				}
1733
+				$alldata = $pall;
1734
+						foreach ($alldata as $number) {
1735 1735
 				echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao']);
1736 1736
 			}
1737 1737
 			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
@@ -1764,47 +1764,47 @@  discard block
 block discarded – undo
1764 1764
 			}
1765 1765
 			if ($globalDebug) echo '...Departure'."\n";
1766 1766
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
1767
-        		$dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines();
1768
-    			foreach ($dall as $value) {
1769
-    				$icao = $value['departure_airport_icao'];
1770
-    				$airline = $value['airline_icao'];
1771
-    				$ddate = $value['date'];
1772
-    				$find = false;
1773
-    				foreach ($pall as $pvalue) {
1774
-    					if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] = $airline) {
1775
-    						$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1776
-    						$find = true;
1777
-    						break;
1778
-    					}
1779
-    				}
1780
-    				if ($find === false) {
1781
-    					$pall[] = $value;
1782
-    				}
1783
-    			}
1784
-    			$alldata = $pall;
1767
+				$dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines();
1768
+				foreach ($dall as $value) {
1769
+					$icao = $value['departure_airport_icao'];
1770
+					$airline = $value['airline_icao'];
1771
+					$ddate = $value['date'];
1772
+					$find = false;
1773
+					foreach ($pall as $pvalue) {
1774
+						if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] = $airline) {
1775
+							$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1776
+							$find = true;
1777
+							break;
1778
+						}
1779
+					}
1780
+					if ($find === false) {
1781
+						$pall[] = $value;
1782
+					}
1783
+				}
1784
+				$alldata = $pall;
1785 1785
 			foreach ($alldata as $number) {
1786 1786
 				$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],$number['airline_icao']);
1787 1787
 			}
1788 1788
 			if ($globalDebug) echo '...Arrival'."\n";
1789 1789
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
1790
-        		$dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines();
1791
-    			foreach ($dall as $value) {
1792
-    				$icao = $value['arrival_airport_icao'];
1793
-    				$airline = $value['airline_icao'];
1794
-    				$ddate = $value['date'];
1795
-    				$find = false;
1796
-    				foreach ($pall as $pvalue) {
1797
-    					if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] == $airline) {
1798
-    						$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1799
-    						$find = true;
1800
-    						break;
1801
-    					}
1802
-    				}
1803
-    				if ($find === false) {
1804
-    					$pall[] = $value;
1805
-    				}
1806
-    			}
1807
-    			$alldata = $pall;
1790
+				$dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines();
1791
+				foreach ($dall as $value) {
1792
+					$icao = $value['arrival_airport_icao'];
1793
+					$airline = $value['airline_icao'];
1794
+					$ddate = $value['date'];
1795
+					$find = false;
1796
+					foreach ($pall as $pvalue) {
1797
+						if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] == $airline) {
1798
+							$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1799
+							$find = true;
1800
+							break;
1801
+						}
1802
+					}
1803
+					if ($find === false) {
1804
+						$pall[] = $value;
1805
+					}
1806
+				}
1807
+				$alldata = $pall;
1808 1808
 			foreach ($alldata as $number) {
1809 1809
 				$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],$number['airline_icao']);
1810 1810
 			}
@@ -1873,44 +1873,44 @@  discard block
 block discarded – undo
1873 1873
 					$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source']);
1874 1874
 				}
1875 1875
 				$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter);
1876
-	       			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
1877
-		        	$alldata = array();
1878
-	    			foreach ($pall as $value) {
1879
-		        		$icao = $value['airport_departure_icao'];
1880
-    					$alldata[$icao] = $value;
1881
-	    			}
1882
-		        	foreach ($dall as $value) {
1883
-	    				$icao = $value['airport_departure_icao'];
1884
-        				if (isset($alldata[$icao])) {
1885
-    						$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1886
-        				} else $alldata[$icao] = $value;
1887
-				}
1888
-	    			$count = array();
1889
-    				foreach ($alldata as $key => $row) {
1890
-    					$count[$key] = $row['airport_departure_icao_count'];
1891
-    				}
1876
+		   			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
1877
+					$alldata = array();
1878
+					foreach ($pall as $value) {
1879
+						$icao = $value['airport_departure_icao'];
1880
+						$alldata[$icao] = $value;
1881
+					}
1882
+					foreach ($dall as $value) {
1883
+						$icao = $value['airport_departure_icao'];
1884
+						if (isset($alldata[$icao])) {
1885
+							$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1886
+						} else $alldata[$icao] = $value;
1887
+				}
1888
+					$count = array();
1889
+					foreach ($alldata as $key => $row) {
1890
+						$count[$key] = $row['airport_departure_icao_count'];
1891
+					}
1892 1892
 				array_multisort($count,SORT_DESC,$alldata);
1893 1893
 				foreach ($alldata as $number) {
1894
-    					echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'',$filter_name);
1894
+						echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'',$filter_name);
1895 1895
 				}
1896 1896
 				$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,$filter);
1897
-    				$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,$filter);
1897
+					$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,$filter);
1898 1898
 				$alldata = array();
1899
-    				foreach ($pall as $value) {
1900
-		        		$icao = $value['airport_arrival_icao'];
1901
-    					$alldata[$icao] = $value;
1902
-	    			}
1903
-		        	foreach ($dall as $value) {
1904
-	    				$icao = $value['airport_arrival_icao'];
1905
-        				if (isset($alldata[$icao])) {
1906
-        					$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1907
-		        		} else $alldata[$icao] = $value;
1908
-	    			}
1909
-        			$count = array();
1910
-        			foreach ($alldata as $key => $row) {
1911
-    					$count[$key] = $row['airport_arrival_icao_count'];
1912
-		        	}
1913
-        			array_multisort($count,SORT_DESC,$alldata);
1899
+					foreach ($pall as $value) {
1900
+						$icao = $value['airport_arrival_icao'];
1901
+						$alldata[$icao] = $value;
1902
+					}
1903
+					foreach ($dall as $value) {
1904
+						$icao = $value['airport_arrival_icao'];
1905
+						if (isset($alldata[$icao])) {
1906
+							$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1907
+						} else $alldata[$icao] = $value;
1908
+					}
1909
+					$count = array();
1910
+					foreach ($alldata as $key => $row) {
1911
+						$count[$key] = $row['airport_arrival_icao_count'];
1912
+					}
1913
+					array_multisort($count,SORT_DESC,$alldata);
1914 1914
 				foreach ($alldata as $number) {
1915 1915
 					echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'',$filter_name);
1916 1916
 				}
@@ -1943,45 +1943,45 @@  discard block
 block discarded – undo
1943 1943
 				}
1944 1944
 				echo '...Departure'."\n";
1945 1945
 				$pall = $Spotter->getLast7DaysAirportsDeparture('',$filter);
1946
-        			$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter);
1946
+					$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter);
1947 1947
 				foreach ($dall as $value) {
1948
-    					$icao = $value['departure_airport_icao'];
1949
-    					$ddate = $value['date'];
1950
-    					$find = false;
1951
-    					foreach ($pall as $pvalue) {
1952
-    						if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1953
-    							$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1954
-	    						$find = true;
1955
-    							break;
1956
-    						}
1957
-    					}
1958
-    					if ($find === false) {
1959
-    						$pall[] = $value;
1960
-	    				}
1961
-    				}
1962
-	    			$alldata = $pall;
1948
+						$icao = $value['departure_airport_icao'];
1949
+						$ddate = $value['date'];
1950
+						$find = false;
1951
+						foreach ($pall as $pvalue) {
1952
+							if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1953
+								$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1954
+								$find = true;
1955
+								break;
1956
+							}
1957
+						}
1958
+						if ($find === false) {
1959
+							$pall[] = $value;
1960
+						}
1961
+					}
1962
+					$alldata = $pall;
1963 1963
 				foreach ($alldata as $number) {
1964 1964
 					$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],'',$filter_name);
1965 1965
 				}
1966 1966
 				echo '...Arrival'."\n";
1967 1967
 				$pall = $Spotter->getLast7DaysAirportsArrival('',$filter);
1968
-    				$dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter);
1968
+					$dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter);
1969 1969
 				foreach ($dall as $value) {
1970 1970
 					$icao = $value['arrival_airport_icao'];
1971 1971
 					$ddate = $value['date'];
1972
-    					$find = false;
1972
+						$find = false;
1973 1973
 					foreach ($pall as $pvalue) {
1974
-    						if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1975
-    							$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1976
-    							$find = true;
1977
-    							break;
1978
-	    					}
1979
-    					}
1980
-    					if ($find === false) {
1981
-    						$pall[] = $value;
1982
-	    				}
1983
-    				}
1984
-    				$alldata = $pall;
1974
+							if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1975
+								$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1976
+								$find = true;
1977
+								break;
1978
+							}
1979
+						}
1980
+						if ($find === false) {
1981
+							$pall[] = $value;
1982
+						}
1983
+					}
1984
+					$alldata = $pall;
1985 1985
 				foreach ($alldata as $number) {
1986 1986
 					$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],'',$filter_name);
1987 1987
 				}
Please login to merge, or discard this patch.
install/class.update_db.php 1 patch
Indentation   +404 added lines, -404 removed lines patch added patch discarded remove patch
@@ -75,38 +75,38 @@  discard block
 block discarded – undo
75 75
 		try {
76 76
 			//$Connection = new Connection();
77 77
 			$sth = $Connection->db->prepare($query);
78
-                        $sth->execute(array(':source' => $database_file));
79
-                } catch(PDOException $e) {
80
-                        return "error : ".$e->getMessage();
81
-                }
78
+						$sth->execute(array(':source' => $database_file));
79
+				} catch(PDOException $e) {
80
+						return "error : ".$e->getMessage();
81
+				}
82 82
 
83
-    		if ($globalDebug) echo " - Add routes to DB -";
84
-    		update_db::connect_sqlite($database_file);
83
+			if ($globalDebug) echo " - Add routes to DB -";
84
+			update_db::connect_sqlite($database_file);
85 85
 		//$query = 'select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID';
86 86
 		$query = "select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao, rstp.allstop AS AllStop from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID LEFT JOIN (select RouteId,GROUP_CONCAT(icao,' ') as allstop from routestop left join Airport as air ON routestop.AirportId = air.AirportID group by RouteID) AS rstp ON Route.RouteID = rstp.RouteID";
87 87
 		try {
88
-                        $sth = update_db::$db_sqlite->prepare($query);
89
-                        $sth->execute();
90
-                } catch(PDOException $e) {
91
-                        return "error : ".$e->getMessage();
92
-                }
88
+						$sth = update_db::$db_sqlite->prepare($query);
89
+						$sth->execute();
90
+				} catch(PDOException $e) {
91
+						return "error : ".$e->getMessage();
92
+				}
93 93
 		//$query_dest = 'INSERT INTO routes (`RouteID`,`CallSign`,`Operator_ICAO`,`FromAirport_ICAO`,`ToAirport_ICAO`,`RouteStop`,`Source`) VALUES (:RouteID, :CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)';
94 94
 		$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,ToAirport_ICAO,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)';
95 95
 		$Connection = new Connection();
96 96
 		$sth_dest = $Connection->db->prepare($query_dest);
97 97
 		try {
98 98
 			if ($globalTransaction) $Connection->db->beginTransaction();
99
-            		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
99
+					while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
100 100
 				//$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
101 101
 				$query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
102 102
 				$sth_dest->execute($query_dest_values);
103
-            		}
103
+					}
104 104
 			if ($globalTransaction) $Connection->db->commit();
105 105
 		} catch(PDOException $e) {
106 106
 			if ($globalTransaction) $Connection->db->rollBack(); 
107 107
 			return "error : ".$e->getMessage();
108 108
 		}
109
-                return '';
109
+				return '';
110 110
 	}
111 111
 	public static function retrieve_route_oneworld($database_file) {
112 112
 		global $globalDebug, $globalTransaction;
@@ -117,12 +117,12 @@  discard block
 block discarded – undo
117 117
 		try {
118 118
 			//$Connection = new Connection();
119 119
 			$sth = $Connection->db->prepare($query);
120
-                        $sth->execute(array(':source' => 'oneworld'));
121
-                } catch(PDOException $e) {
122
-                        return "error : ".$e->getMessage();
123
-                }
120
+						$sth->execute(array(':source' => 'oneworld'));
121
+				} catch(PDOException $e) {
122
+						return "error : ".$e->getMessage();
123
+				}
124 124
 
125
-    		if ($globalDebug) echo " - Add routes to DB -";
125
+			if ($globalDebug) echo " - Add routes to DB -";
126 126
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
127 127
 		$Spotter = new Spotter();
128 128
 		if ($fh = fopen($database_file,"r")) {
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 			}
147 147
 			if ($globalTransaction) $Connection->db->commit();
148 148
 		}
149
-                return '';
149
+				return '';
150 150
 	}
151 151
 	
152 152
 	public static function retrieve_route_skyteam($database_file) {
@@ -158,12 +158,12 @@  discard block
 block discarded – undo
158 158
 		try {
159 159
 			//$Connection = new Connection();
160 160
 			$sth = $Connection->db->prepare($query);
161
-                        $sth->execute(array(':source' => 'skyteam'));
162
-                } catch(PDOException $e) {
163
-                        return "error : ".$e->getMessage();
164
-                }
161
+						$sth->execute(array(':source' => 'skyteam'));
162
+				} catch(PDOException $e) {
163
+						return "error : ".$e->getMessage();
164
+				}
165 165
 
166
-    		if ($globalDebug) echo " - Add routes to DB -";
166
+			if ($globalDebug) echo " - Add routes to DB -";
167 167
 
168 168
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
169 169
 		$Spotter = new Spotter();
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 				return "error : ".$e->getMessage();
190 190
 			}
191 191
 		}
192
-                return '';
192
+				return '';
193 193
 	}
194 194
 	public static function retrieve_modes_sqlite_to_dest($database_file) {
195 195
 		global $globalTransaction;
@@ -198,27 +198,27 @@  discard block
 block discarded – undo
198 198
 		try {
199 199
 			$Connection = new Connection();
200 200
 			$sth = $Connection->db->prepare($query);
201
-                        $sth->execute(array(':source' => $database_file));
202
-                } catch(PDOException $e) {
203
-                        return "error : ".$e->getMessage();
204
-                }
201
+						$sth->execute(array(':source' => $database_file));
202
+				} catch(PDOException $e) {
203
+						return "error : ".$e->getMessage();
204
+				}
205 205
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source";
206 206
 		try {
207 207
 			$Connection = new Connection();
208 208
 			$sth = $Connection->db->prepare($query);
209
-                        $sth->execute(array(':source' => $database_file));
210
-                } catch(PDOException $e) {
211
-                        return "error : ".$e->getMessage();
212
-                }
209
+						$sth->execute(array(':source' => $database_file));
210
+				} catch(PDOException $e) {
211
+						return "error : ".$e->getMessage();
212
+				}
213 213
 
214
-    		update_db::connect_sqlite($database_file);
214
+			update_db::connect_sqlite($database_file);
215 215
 		$query = 'select * from Aircraft';
216 216
 		try {
217
-                        $sth = update_db::$db_sqlite->prepare($query);
218
-                        $sth->execute();
219
-                } catch(PDOException $e) {
220
-                        return "error : ".$e->getMessage();
221
-                }
217
+						$sth = update_db::$db_sqlite->prepare($query);
218
+						$sth->execute();
219
+				} catch(PDOException $e) {
220
+						return "error : ".$e->getMessage();
221
+				}
222 222
 		//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
223 223
 		$query_dest = 'INSERT INTO aircraft_modes (LastModified, ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type,:source)';
224 224
 		
@@ -229,17 +229,17 @@  discard block
 block discarded – undo
229 229
 		$sth_dest_owner = $Connection->db->prepare($query_dest_owner);
230 230
 		try {
231 231
 			if ($globalTransaction) $Connection->db->beginTransaction();
232
-            		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
232
+					while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
233 233
 			//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
234 234
 				if ($values['UserString4'] == 'M') $type = 'military';
235 235
 				else $type = null;
236 236
 				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
237 237
 				$sth_dest->execute($query_dest_values);
238 238
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
239
-				    $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']);
240
-				    $sth_dest_owner->execute($query_dest_owner_values);
239
+					$query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']);
240
+					$sth_dest_owner->execute($query_dest_owner_values);
241 241
 				}
242
-            		}
242
+					}
243 243
 			if ($globalTransaction) $Connection->db->commit();
244 244
 		} catch(PDOException $e) {
245 245
 			return "error : ".$e->getMessage();
@@ -250,10 +250,10 @@  discard block
 block discarded – undo
250 250
 		try {
251 251
 			$Connection = new Connection();
252 252
 			$sth = $Connection->db->prepare($query);
253
-                        $sth->execute(array(':source' => $database_file));
254
-                } catch(PDOException $e) {
255
-                        return "error : ".$e->getMessage();
256
-                }
253
+						$sth->execute(array(':source' => $database_file));
254
+				} catch(PDOException $e) {
255
+						return "error : ".$e->getMessage();
256
+				}
257 257
 		return '';
258 258
 	}
259 259
 
@@ -265,10 +265,10 @@  discard block
 block discarded – undo
265 265
 		try {
266 266
 			$Connection = new Connection();
267 267
 			$sth = $Connection->db->prepare($query);
268
-                        $sth->execute(array(':source' => $database_file));
269
-                } catch(PDOException $e) {
270
-                        return "error : ".$e->getMessage();
271
-                }
268
+						$sth->execute(array(':source' => $database_file));
269
+				} catch(PDOException $e) {
270
+						return "error : ".$e->getMessage();
271
+				}
272 272
 		
273 273
 		if ($fh = fopen($database_file,"r")) {
274 274
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
@@ -278,26 +278,26 @@  discard block
 block discarded – undo
278 278
 			$sth_dest = $Connection->db->prepare($query_dest);
279 279
 			try {
280 280
 				if ($globalTransaction) $Connection->db->beginTransaction();
281
-            			while (!feof($fh)) {
282
-            				$values = array();
283
-            				$line = $Common->hex2str(fgets($fh,9999));
281
+						while (!feof($fh)) {
282
+							$values = array();
283
+							$line = $Common->hex2str(fgets($fh,9999));
284 284
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
285
-            				$values['ModeS'] = substr($line,0,6);
286
-            				$values['Registration'] = trim(substr($line,69,6));
287
-            				$aircraft_name = trim(substr($line,48,6));
288
-            				// Check if we can find ICAO, else set it to GLID
289
-            				$aircraft_name_split = explode(' ',$aircraft_name);
290
-            				$search_more = '';
291
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
292
-            				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
293
-            				$sth_search = $Connection->db->prepare($query_search);
285
+							$values['ModeS'] = substr($line,0,6);
286
+							$values['Registration'] = trim(substr($line,69,6));
287
+							$aircraft_name = trim(substr($line,48,6));
288
+							// Check if we can find ICAO, else set it to GLID
289
+							$aircraft_name_split = explode(' ',$aircraft_name);
290
+							$search_more = '';
291
+							if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
292
+							$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
293
+							$sth_search = $Connection->db->prepare($query_search);
294 294
 					try {
295
-                                    		$sth_search->execute();
296
-	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
297
-	            				//if (count($result) > 0) {
298
-	            				if (isset($result['icao']) && $result['icao'] != '') {
299
-	            				    $values['ICAOTypeCode'] = $result['icao'];
300
-	            				} 
295
+											$sth_search->execute();
296
+								$result = $sth_search->fetch(PDO::FETCH_ASSOC);
297
+								//if (count($result) > 0) {
298
+								if (isset($result['icao']) && $result['icao'] != '') {
299
+									$values['ICAOTypeCode'] = $result['icao'];
300
+								} 
301 301
 					} catch(PDOException $e) {
302 302
 						return "error : ".$e->getMessage();
303 303
 					}
@@ -320,10 +320,10 @@  discard block
 block discarded – undo
320 320
 		try {
321 321
 			$Connection = new Connection();
322 322
 			$sth = $Connection->db->prepare($query);
323
-                        $sth->execute(array(':source' => $database_file));
324
-                } catch(PDOException $e) {
325
-                        return "error : ".$e->getMessage();
326
-                }
323
+						$sth->execute(array(':source' => $database_file));
324
+				} catch(PDOException $e) {
325
+						return "error : ".$e->getMessage();
326
+				}
327 327
 		return '';
328 328
 	}
329 329
 
@@ -334,10 +334,10 @@  discard block
 block discarded – undo
334 334
 		try {
335 335
 			$Connection = new Connection();
336 336
 			$sth = $Connection->db->prepare($query);
337
-                        $sth->execute(array(':source' => $database_file));
338
-                } catch(PDOException $e) {
339
-                        return "error : ".$e->getMessage();
340
-                }
337
+						$sth->execute(array(':source' => $database_file));
338
+				} catch(PDOException $e) {
339
+						return "error : ".$e->getMessage();
340
+				}
341 341
 		
342 342
 		if ($fh = fopen($database_file,"r")) {
343 343
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
@@ -348,24 +348,24 @@  discard block
 block discarded – undo
348 348
 			try {
349 349
 				if ($globalTransaction) $Connection->db->beginTransaction();
350 350
 				$tmp = fgetcsv($fh,9999,',',"'");
351
-            			while (!feof($fh)) {
352
-            				$line = fgetcsv($fh,9999,',',"'");
351
+						while (!feof($fh)) {
352
+							$line = fgetcsv($fh,9999,',',"'");
353 353
             				
354 354
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
355 355
 					//print_r($line);
356
-            				$values['ModeS'] = $line[1];
357
-            				$values['Registration'] = $line[3];
358
-            				$aircraft_name = $line[2];
359
-            				// Check if we can find ICAO, else set it to GLID
360
-            				$aircraft_name_split = explode(' ',$aircraft_name);
361
-            				$search_more = '';
362
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
363
-            				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
364
-            				$sth_search = $Connection->db->prepare($query_search);
356
+							$values['ModeS'] = $line[1];
357
+							$values['Registration'] = $line[3];
358
+							$aircraft_name = $line[2];
359
+							// Check if we can find ICAO, else set it to GLID
360
+							$aircraft_name_split = explode(' ',$aircraft_name);
361
+							$search_more = '';
362
+							if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
363
+							$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
364
+							$sth_search = $Connection->db->prepare($query_search);
365 365
 					try {
366
-                                    		$sth_search->execute();
367
-	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
368
-	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
366
+											$sth_search->execute();
367
+								$result = $sth_search->fetch(PDO::FETCH_ASSOC);
368
+								if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
369 369
 					} catch(PDOException $e) {
370 370
 						return "error : ".$e->getMessage();
371 371
 					}
@@ -388,10 +388,10 @@  discard block
 block discarded – undo
388 388
 		try {
389 389
 			$Connection = new Connection();
390 390
 			$sth = $Connection->db->prepare($query);
391
-                        $sth->execute(array(':source' => $database_file));
392
-                } catch(PDOException $e) {
393
-                        return "error : ".$e->getMessage();
394
-                }
391
+						$sth->execute(array(':source' => $database_file));
392
+				} catch(PDOException $e) {
393
+						return "error : ".$e->getMessage();
394
+				}
395 395
 		return '';
396 396
 	}
397 397
 
@@ -402,10 +402,10 @@  discard block
 block discarded – undo
402 402
 		try {
403 403
 			$Connection = new Connection();
404 404
 			$sth = $Connection->db->prepare($query);
405
-                        $sth->execute(array(':source' => $database_file));
406
-                } catch(PDOException $e) {
407
-                        return "error : ".$e->getMessage();
408
-                }
405
+						$sth->execute(array(':source' => $database_file));
406
+				} catch(PDOException $e) {
407
+						return "error : ".$e->getMessage();
408
+				}
409 409
 		
410 410
 		if ($fh = fopen($database_file,"r")) {
411 411
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
@@ -416,95 +416,95 @@  discard block
 block discarded – undo
416 416
 			try {
417 417
 				if ($globalTransaction) $Connection->db->beginTransaction();
418 418
 				$tmp = fgetcsv($fh,9999,',','"');
419
-            			while (!feof($fh)) {
420
-            				$line = fgetcsv($fh,9999,',','"');
421
-            				$values = array();
422
-            				//print_r($line);
423
-            				if ($country == 'F') {
424
-            				    $values['registration'] = $line[0];
425
-            				    $values['base'] = $line[4];
426
-            				    $values['owner'] = $line[5];
427
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
428
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
429
-					    $values['cancel'] = $line[7];
419
+						while (!feof($fh)) {
420
+							$line = fgetcsv($fh,9999,',','"');
421
+							$values = array();
422
+							//print_r($line);
423
+							if ($country == 'F') {
424
+								$values['registration'] = $line[0];
425
+								$values['base'] = $line[4];
426
+								$values['owner'] = $line[5];
427
+								if ($line[6] == '') $values['date_first_reg'] = null;
428
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
429
+						$values['cancel'] = $line[7];
430 430
 					} elseif ($country == 'EI') {
431
-					    // TODO : add modeS & reg to aircraft_modes
432
-            				    $values['registration'] = $line[0];
433
-            				    $values['base'] = $line[3];
434
-            				    $values['owner'] = $line[2];
435
-            				    if ($line[1] == '') $values['date_first_reg'] = null;
436
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
437
-					    $values['cancel'] = '';
431
+						// TODO : add modeS & reg to aircraft_modes
432
+								$values['registration'] = $line[0];
433
+								$values['base'] = $line[3];
434
+								$values['owner'] = $line[2];
435
+								if ($line[1] == '') $values['date_first_reg'] = null;
436
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
437
+						$values['cancel'] = '';
438 438
 					} elseif ($country == 'HB') {
439
-					    // TODO : add modeS & reg to aircraft_modes
440
-            				    $values['registration'] = $line[0];
441
-            				    $values['base'] = null;
442
-            				    $values['owner'] = $line[5];
443
-            				    $values['date_first_reg'] = null;
444
-					    $values['cancel'] = '';
439
+						// TODO : add modeS & reg to aircraft_modes
440
+								$values['registration'] = $line[0];
441
+								$values['base'] = null;
442
+								$values['owner'] = $line[5];
443
+								$values['date_first_reg'] = null;
444
+						$values['cancel'] = '';
445 445
 					} elseif ($country == 'OK') {
446
-					    // TODO : add modeS & reg to aircraft_modes
447
-            				    $values['registration'] = $line[3];
448
-            				    $values['base'] = null;
449
-            				    $values['owner'] = $line[5];
450
-            				    if ($line[18] == '') $values['date_first_reg'] = null;
451
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
452
-					    $values['cancel'] = '';
446
+						// TODO : add modeS & reg to aircraft_modes
447
+								$values['registration'] = $line[3];
448
+								$values['base'] = null;
449
+								$values['owner'] = $line[5];
450
+								if ($line[18] == '') $values['date_first_reg'] = null;
451
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
452
+						$values['cancel'] = '';
453 453
 					} elseif ($country == 'VH') {
454
-					    // TODO : add modeS & reg to aircraft_modes
455
-            				    $values['registration'] = $line[0];
456
-            				    $values['base'] = null;
457
-            				    $values['owner'] = $line[12];
458
-            				    if ($line[28] == '') $values['date_first_reg'] = null;
459
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
460
-
461
-					    $values['cancel'] = $line[39];
454
+						// TODO : add modeS & reg to aircraft_modes
455
+								$values['registration'] = $line[0];
456
+								$values['base'] = null;
457
+								$values['owner'] = $line[12];
458
+								if ($line[28] == '') $values['date_first_reg'] = null;
459
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
460
+
461
+						$values['cancel'] = $line[39];
462 462
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
463
-            				    $values['registration'] = $line[0];
464
-            				    $values['base'] = null;
465
-            				    $values['owner'] = $line[4];
466
-            				    $values['date_first_reg'] = null;
467
-					    $values['cancel'] = '';
463
+								$values['registration'] = $line[0];
464
+								$values['base'] = null;
465
+								$values['owner'] = $line[4];
466
+								$values['date_first_reg'] = null;
467
+						$values['cancel'] = '';
468 468
 					} elseif ($country == 'CC') {
469
-            				    $values['registration'] = $line[0];
470
-            				    $values['base'] = null;
471
-            				    $values['owner'] = $line[6];
472
-            				    $values['date_first_reg'] = null;
473
-					    $values['cancel'] = '';
469
+								$values['registration'] = $line[0];
470
+								$values['base'] = null;
471
+								$values['owner'] = $line[6];
472
+								$values['date_first_reg'] = null;
473
+						$values['cancel'] = '';
474 474
 					} elseif ($country == 'HJ') {
475
-            				    $values['registration'] = $line[0];
476
-            				    $values['base'] = null;
477
-            				    $values['owner'] = $line[8];
478
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
479
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
480
-					    $values['cancel'] = '';
475
+								$values['registration'] = $line[0];
476
+								$values['base'] = null;
477
+								$values['owner'] = $line[8];
478
+								if ($line[7] == '') $values['date_first_reg'] = null;
479
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
480
+						$values['cancel'] = '';
481 481
 					} elseif ($country == 'PP') {
482
-            				    $values['registration'] = $line[0];
483
-            				    $values['base'] = null;
484
-            				    $values['owner'] = $line[4];
485
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
486
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
487
-					    $values['cancel'] = $line[7];
482
+								$values['registration'] = $line[0];
483
+								$values['base'] = null;
484
+								$values['owner'] = $line[4];
485
+								if ($line[6] == '') $values['date_first_reg'] = null;
486
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
487
+						$values['cancel'] = $line[7];
488 488
 					} elseif ($country == 'E7') {
489
-            				    $values['registration'] = $line[0];
490
-            				    $values['base'] = null;
491
-            				    $values['owner'] = $line[4];
492
-            				    if ($line[5] == '') $values['date_first_reg'] = null;
493
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
494
-					    $values['cancel'] = '';
489
+								$values['registration'] = $line[0];
490
+								$values['base'] = null;
491
+								$values['owner'] = $line[4];
492
+								if ($line[5] == '') $values['date_first_reg'] = null;
493
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
494
+						$values['cancel'] = '';
495 495
 					} elseif ($country == '8Q') {
496
-            				    $values['registration'] = $line[0];
497
-            				    $values['base'] = null;
498
-            				    $values['owner'] = $line[3];
499
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
500
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
501
-					    $values['cancel'] = '';
496
+								$values['registration'] = $line[0];
497
+								$values['base'] = null;
498
+								$values['owner'] = $line[3];
499
+								if ($line[7] == '') $values['date_first_reg'] = null;
500
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
501
+						$values['cancel'] = '';
502 502
 					} elseif ($country == 'ZK' || $country == 'OM' || $country == 'TF') {
503
-            				    $values['registration'] = $line[0];
504
-            				    $values['base'] = null;
505
-            				    $values['owner'] = $line[3];
506
-            				    $values['date_first_reg'] = null;
507
-					    $values['cancel'] = '';
503
+								$values['registration'] = $line[0];
504
+								$values['base'] = null;
505
+								$values['owner'] = $line[3];
506
+								$values['date_first_reg'] = null;
507
+						$values['cancel'] = '';
508 508
 					}
509 509
 					if ($values['cancel'] == '' && $values['registration'] != null) {
510 510
 						$query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file);
@@ -626,20 +626,20 @@  discard block
 block discarded – undo
626 626
 		try {
627 627
 			$Connection = new Connection();
628 628
 			$sth = $Connection->db->prepare($query);
629
-                        $sth->execute();
630
-                } catch(PDOException $e) {
631
-                        return "error : ".$e->getMessage();
632
-                }
629
+						$sth->execute();
630
+				} catch(PDOException $e) {
631
+						return "error : ".$e->getMessage();
632
+				}
633 633
 
634 634
 
635 635
 		$query = 'ALTER TABLE airport DROP INDEX icaoidx';
636 636
 		try {
637 637
 			$Connection = new Connection();
638 638
 			$sth = $Connection->db->prepare($query);
639
-                        $sth->execute();
640
-                } catch(PDOException $e) {
641
-                        return "error : ".$e->getMessage();
642
-                }
639
+						$sth->execute();
640
+				} catch(PDOException $e) {
641
+						return "error : ".$e->getMessage();
642
+				}
643 643
 
644 644
 		$query_dest = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image_thumb`,`image`)
645 645
 		    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)";
@@ -705,10 +705,10 @@  discard block
 block discarded – undo
705 705
 		try {
706 706
 			$Connection = new Connection();
707 707
 			$sth = $Connection->db->prepare($query);
708
-                        $sth->execute();
709
-                } catch(PDOException $e) {
710
-                        return "error : ".$e->getMessage();
711
-                }
708
+						$sth->execute();
709
+				} catch(PDOException $e) {
710
+						return "error : ".$e->getMessage();
711
+				}
712 712
 
713 713
 
714 714
 		if ($globalDebug) echo "Insert Not available Airport...\n";
@@ -718,10 +718,10 @@  discard block
 block discarded – undo
718 718
 		try {
719 719
 			$Connection = new Connection();
720 720
 			$sth = $Connection->db->prepare($query);
721
-                        $sth->execute($query_values);
722
-                } catch(PDOException $e) {
723
-                        return "error : ".$e->getMessage();
724
-                }
721
+						$sth->execute($query_values);
722
+				} catch(PDOException $e) {
723
+						return "error : ".$e->getMessage();
724
+				}
725 725
 		$i++;
726 726
 /*
727 727
 		$query = 'DELETE FROM airport WHERE airport_id IN (SELECT * FROM (SELECT min(a.airport_id) FROM airport a GROUP BY a.icao) x)';
@@ -835,7 +835,7 @@  discard block
 block discarded – undo
835 835
 
836 836
 
837 837
 
838
-                return "success";
838
+				return "success";
839 839
 	}
840 840
 	
841 841
 	public static function translation() {
@@ -851,10 +851,10 @@  discard block
 block discarded – undo
851 851
 		try {
852 852
 			$Connection = new Connection();
853 853
 			$sth = $Connection->db->prepare($query);
854
-                        $sth->execute(array(':source' => 'translation.csv'));
855
-                } catch(PDOException $e) {
856
-                        return "error : ".$e->getMessage();
857
-                }
854
+						$sth->execute(array(':source' => 'translation.csv'));
855
+				} catch(PDOException $e) {
856
+						return "error : ".$e->getMessage();
857
+				}
858 858
 
859 859
 		
860 860
 		//update_db::unzip($out_file);
@@ -873,21 +873,21 @@  discard block
 block discarded – undo
873 873
 					$data = $row;
874 874
 					$operator = $data[2];
875 875
 					if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) {
876
-                                                $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2));
877
-                                                //echo substr($operator, 0, 2)."\n";;
878
-                                                if (count($airline_array) > 0) {
876
+												$airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2));
877
+												//echo substr($operator, 0, 2)."\n";;
878
+												if (count($airline_array) > 0) {
879 879
 							//print_r($airline_array);
880 880
 							$operator = $airline_array[0]['icao'].substr($operator,2);
881
-                                                }
882
-                                        }
881
+												}
882
+										}
883 883
 					
884 884
 					$operator_correct = $data[3];
885 885
 					if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) {
886
-                                                $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
887
-                                                if (count($airline_array) > 0) {
888
-                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
889
-                                            	}
890
-                                        }
886
+												$airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
887
+												if (count($airline_array) > 0) {
888
+													$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
889
+												}
890
+										}
891 891
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
892 892
 					try {
893 893
 						$sth = $Connection->db->prepare($query);
@@ -901,7 +901,7 @@  discard block
 block discarded – undo
901 901
 			//$Connection->db->commit();
902 902
 		}
903 903
 		return '';
904
-        }
904
+		}
905 905
 	
906 906
 	public static function translation_fam() {
907 907
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
@@ -911,10 +911,10 @@  discard block
 block discarded – undo
911 911
 		try {
912 912
 			$Connection = new Connection();
913 913
 			$sth = $Connection->db->prepare($query);
914
-                        $sth->execute(array(':source' => 'website_fam'));
915
-                } catch(PDOException $e) {
916
-                        return "error : ".$e->getMessage();
917
-                }
914
+						$sth->execute(array(':source' => 'website_fam'));
915
+				} catch(PDOException $e) {
916
+						return "error : ".$e->getMessage();
917
+				}
918 918
 
919 919
 		
920 920
 		//update_db::unzip($out_file);
@@ -943,7 +943,7 @@  discard block
 block discarded – undo
943 943
 			//$Connection->db->commit();
944 944
 		}
945 945
 		return '';
946
-        }
946
+		}
947 947
 
948 948
 	public static function modes_faa() {
949 949
 		global $tmp_dir, $globalTransaction;
@@ -951,19 +951,19 @@  discard block
 block discarded – undo
951 951
 		try {
952 952
 			$Connection = new Connection();
953 953
 			$sth = $Connection->db->prepare($query);
954
-                        $sth->execute(array(':source' => 'website_faa'));
955
-                } catch(PDOException $e) {
956
-                        return "error : ".$e->getMessage();
957
-                }
954
+						$sth->execute(array(':source' => 'website_faa'));
955
+				} catch(PDOException $e) {
956
+						return "error : ".$e->getMessage();
957
+				}
958 958
 
959 959
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source = :source";
960 960
 		try {
961 961
 			$Connection = new Connection();
962 962
 			$sth = $Connection->db->prepare($query);
963
-                        $sth->execute(array(':source' => 'website_faa'));
964
-                } catch(PDOException $e) {
965
-                        return "error : ".$e->getMessage();
966
-                }
963
+						$sth->execute(array(':source' => 'website_faa'));
964
+				} catch(PDOException $e) {
965
+						return "error : ".$e->getMessage();
966
+				}
967 967
 
968 968
 		
969 969
 		//$aircrafts_icao = array('7102811' => 'P28R',...
@@ -1001,17 +1001,17 @@  discard block
 block discarded – undo
1001 1001
 			if ($globalTransaction) $Connection->db->commit();
1002 1002
 		}
1003 1003
 		return '';
1004
-        }
1004
+		}
1005 1005
 	public static function modes_fam() {
1006 1006
 		global $tmp_dir, $globalTransaction;
1007 1007
 		$query = "DELETE FROM aircraft_modes WHERE Source = '' OR Source = :source";
1008 1008
 		try {
1009 1009
 			$Connection = new Connection();
1010 1010
 			$sth = $Connection->db->prepare($query);
1011
-                        $sth->execute(array(':source' => 'website_fam'));
1012
-                } catch(PDOException $e) {
1013
-                        return "error : ".$e->getMessage();
1014
-                }
1011
+						$sth->execute(array(':source' => 'website_fam'));
1012
+				} catch(PDOException $e) {
1013
+						return "error : ".$e->getMessage();
1014
+				}
1015 1015
 
1016 1016
 		
1017 1017
 		//update_db::unzip($out_file);
@@ -1040,7 +1040,7 @@  discard block
 block discarded – undo
1040 1040
 			if ($globalTransaction) $Connection->db->commit();
1041 1041
 		}
1042 1042
 		return '';
1043
-        }
1043
+		}
1044 1044
         
1045 1045
 	public static function owner_fam() {
1046 1046
 		global $tmp_dir, $globalTransaction;
@@ -1048,10 +1048,10 @@  discard block
 block discarded – undo
1048 1048
 		try {
1049 1049
 			$Connection = new Connection();
1050 1050
 			$sth = $Connection->db->prepare($query);
1051
-                        $sth->execute(array(':source' => 'website_fam'));
1052
-                } catch(PDOException $e) {
1053
-                        return "error : ".$e->getMessage();
1054
-                }
1051
+						$sth->execute(array(':source' => 'website_fam'));
1052
+				} catch(PDOException $e) {
1053
+						return "error : ".$e->getMessage();
1054
+				}
1055 1055
 
1056 1056
 		$delimiter = "\t";
1057 1057
 		$Connection = new Connection();
@@ -1077,7 +1077,7 @@  discard block
 block discarded – undo
1077 1077
 			if ($globalTransaction) $Connection->db->commit();
1078 1078
 		}
1079 1079
 		return '';
1080
-        }
1080
+		}
1081 1081
 
1082 1082
 	public static function routes_fam() {
1083 1083
 		global $tmp_dir, $globalTransaction;
@@ -1085,10 +1085,10 @@  discard block
 block discarded – undo
1085 1085
 		try {
1086 1086
 			$Connection = new Connection();
1087 1087
 			$sth = $Connection->db->prepare($query);
1088
-                        $sth->execute(array(':source' => 'website_fam'));
1089
-                } catch(PDOException $e) {
1090
-                        return "error : ".$e->getMessage();
1091
-                }
1088
+						$sth->execute(array(':source' => 'website_fam'));
1089
+				} catch(PDOException $e) {
1090
+						return "error : ".$e->getMessage();
1091
+				}
1092 1092
 
1093 1093
 		
1094 1094
 		//update_db::unzip($out_file);
@@ -1117,7 +1117,7 @@  discard block
 block discarded – undo
1117 1117
 			if ($globalTransaction) $Connection->db->commit();
1118 1118
 		}
1119 1119
 		return '';
1120
-        }
1120
+		}
1121 1121
 
1122 1122
 	public static function tle($filename,$tletype) {
1123 1123
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
@@ -1128,10 +1128,10 @@  discard block
 block discarded – undo
1128 1128
 		try {
1129 1129
 			$Connection = new Connection();
1130 1130
 			$sth = $Connection->db->prepare($query);
1131
-                        $sth->execute(array(':source' => $filename));
1132
-                } catch(PDOException $e) {
1133
-                        return "error : ".$e->getMessage();
1134
-                }
1131
+						$sth->execute(array(':source' => $filename));
1132
+				} catch(PDOException $e) {
1133
+						return "error : ".$e->getMessage();
1134
+				}
1135 1135
 		
1136 1136
 		$Connection = new Connection();
1137 1137
 		if (($handle = fopen($filename, 'r')) !== FALSE)
@@ -1166,54 +1166,54 @@  discard block
 block discarded – undo
1166 1166
 			//$Connection->db->commit();
1167 1167
 		}
1168 1168
 		return '';
1169
-        }
1169
+		}
1170 1170
 
1171 1171
 	/**
1172
-        * Convert a HTML table to an array
1173
-        * @param String $data HTML page
1174
-        * @return Array array of the tables in HTML page
1175
-        */
1176
-        private static function table2array($data) {
1177
-                $html = str_get_html($data);
1178
-                $tabledata=array();
1179
-                foreach($html->find('tr') as $element)
1180
-                {
1181
-                        $td = array();
1182
-                        foreach( $element->find('th') as $row)
1183
-                        {
1184
-                                $td [] = trim($row->plaintext);
1185
-                        }
1186
-                        $td=array_filter($td);
1187
-                        $tabledata[] = $td;
1188
-
1189
-                        $td = array();
1190
-                        $tdi = array();
1191
-                        foreach( $element->find('td') as $row)
1192
-                        {
1193
-                                $td [] = trim($row->plaintext);
1194
-                                $tdi [] = trim($row->innertext);
1195
-                        }
1196
-                        $td=array_filter($td);
1197
-                        $tdi=array_filter($tdi);
1198
-                    //    $tabledata[]=array_merge($td,$tdi);
1199
-                        $tabledata[]=$td;
1200
-                }
1201
-                return(array_filter($tabledata));
1202
-        }
1203
-
1204
-       /**
1205
-        * Get data from form result
1206
-        * @param String $url form URL
1207
-        * @return String the result
1208
-        */
1209
-        private static function getData($url) {
1210
-                $ch = curl_init();
1211
-                curl_setopt($ch, CURLOPT_URL, $url);
1212
-                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
1213
-                curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
1214
-                curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5');
1215
-                return curl_exec($ch);
1216
-        }
1172
+	 * Convert a HTML table to an array
1173
+	 * @param String $data HTML page
1174
+	 * @return Array array of the tables in HTML page
1175
+	 */
1176
+		private static function table2array($data) {
1177
+				$html = str_get_html($data);
1178
+				$tabledata=array();
1179
+				foreach($html->find('tr') as $element)
1180
+				{
1181
+						$td = array();
1182
+						foreach( $element->find('th') as $row)
1183
+						{
1184
+								$td [] = trim($row->plaintext);
1185
+						}
1186
+						$td=array_filter($td);
1187
+						$tabledata[] = $td;
1188
+
1189
+						$td = array();
1190
+						$tdi = array();
1191
+						foreach( $element->find('td') as $row)
1192
+						{
1193
+								$td [] = trim($row->plaintext);
1194
+								$tdi [] = trim($row->innertext);
1195
+						}
1196
+						$td=array_filter($td);
1197
+						$tdi=array_filter($tdi);
1198
+					//    $tabledata[]=array_merge($td,$tdi);
1199
+						$tabledata[]=$td;
1200
+				}
1201
+				return(array_filter($tabledata));
1202
+		}
1203
+
1204
+	   /**
1205
+	    * Get data from form result
1206
+	    * @param String $url form URL
1207
+	    * @return String the result
1208
+	    */
1209
+		private static function getData($url) {
1210
+				$ch = curl_init();
1211
+				curl_setopt($ch, CURLOPT_URL, $url);
1212
+				curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
1213
+				curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
1214
+				curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5');
1215
+				return curl_exec($ch);
1216
+		}
1217 1217
 /*
1218 1218
 	public static function waypoints() {
1219 1219
 		$data = update_db::getData('http://www.fallingrain.com/world/FR/waypoints.html');
@@ -1296,7 +1296,7 @@  discard block
 block discarded – undo
1296 1296
 			if ($globalTransaction) $Connection->db->commit();
1297 1297
 		}
1298 1298
 		return '';
1299
-        }
1299
+		}
1300 1300
 
1301 1301
 	public static function ivao_airlines($filename) {
1302 1302
 		//require_once(dirname(__FILE__).'/../require/class.Spotter.php');
@@ -1306,10 +1306,10 @@  discard block
 block discarded – undo
1306 1306
 		try {
1307 1307
 			$Connection = new Connection();
1308 1308
 			$sth = $Connection->db->prepare($query);
1309
-                        $sth->execute();
1310
-                } catch(PDOException $e) {
1311
-                        return "error : ".$e->getMessage();
1312
-                }
1309
+						$sth->execute();
1310
+				} catch(PDOException $e) {
1311
+						return "error : ".$e->getMessage();
1312
+				}
1313 1313
 
1314 1314
 		$header = NULL;
1315 1315
 		$delimiter = ':';
@@ -1333,7 +1333,7 @@  discard block
 block discarded – undo
1333 1333
 			if ($globalTransaction) $Connection->db->commit();
1334 1334
 		}
1335 1335
 		return '';
1336
-        }
1336
+		}
1337 1337
 	
1338 1338
 	public static function update_airspace() {
1339 1339
 		global $tmp_dir, $globalDBdriver;
@@ -1343,11 +1343,11 @@  discard block
 block discarded – undo
1343 1343
 			$query = 'DROP TABLE airspace';
1344 1344
 			try {
1345 1345
 				$sth = $Connection->db->prepare($query);
1346
-                    		$sth->execute();
1347
-	                } catch(PDOException $e) {
1346
+							$sth->execute();
1347
+					} catch(PDOException $e) {
1348 1348
 				return "error : ".$e->getMessage();
1349
-	                }
1350
-	        }
1349
+					}
1350
+			}
1351 1351
 
1352 1352
 
1353 1353
 		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
@@ -1402,10 +1402,10 @@  discard block
 block discarded – undo
1402 1402
 			$query = 'DROP TABLE countries';
1403 1403
 			try {
1404 1404
 				$sth = $Connection->db->prepare($query);
1405
-            	        	$sth->execute();
1406
-	                } catch(PDOException $e) {
1407
-    	                	echo "error : ".$e->getMessage();
1408
-	                }
1405
+							$sth->execute();
1406
+					} catch(PDOException $e) {
1407
+							echo "error : ".$e->getMessage();
1408
+					}
1409 1409
 		}
1410 1410
 		if ($globalDBdriver == 'mysql') {
1411 1411
 			update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql');
@@ -1865,11 +1865,11 @@  discard block
 block discarded – undo
1865 1865
 						$query = 'DROP TABLE airspace';
1866 1866
 						try {
1867 1867
 							$sth = $Connection->db->prepare($query);
1868
-    	    	    					$sth->execute();
1869
-			            		} catch(PDOException $e) {
1868
+										$sth->execute();
1869
+								} catch(PDOException $e) {
1870 1870
 							return "error : ".$e->getMessage();
1871
-		            			}
1872
-		    			}
1871
+								}
1872
+						}
1873 1873
 					$error = create_db::import_file($tmp_dir.'airspace.sql');
1874 1874
 					update_db::insert_airspace_version($airspace_md5);
1875 1875
 				} else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed.";
@@ -1989,12 +1989,12 @@  discard block
 block discarded – undo
1989 1989
 		echo $data;
1990 1990
 		*/
1991 1991
 		if (file_exists($tmp_dir.'aircrafts.html')) {
1992
-		    //var_dump(file_get_html($tmp_dir.'aircrafts.html'));
1993
-		    $fh = fopen($tmp_dir.'aircrafts.html',"r");
1994
-		    $result = fread($fh,100000000);
1995
-		    //echo $result;
1996
-		    //var_dump(str_get_html($result));
1997
-		    //print_r(self::table2array($result));
1992
+			//var_dump(file_get_html($tmp_dir.'aircrafts.html'));
1993
+			$fh = fopen($tmp_dir.'aircrafts.html',"r");
1994
+			$result = fread($fh,100000000);
1995
+			//echo $result;
1996
+			//var_dump(str_get_html($result));
1997
+			//print_r(self::table2array($result));
1998 1998
 		}
1999 1999
 
2000 2000
 	}
@@ -2008,10 +2008,10 @@  discard block
 block discarded – undo
2008 2008
 		try {
2009 2009
 			$Connection = new Connection();
2010 2010
 			$sth = $Connection->db->prepare($query);
2011
-                        $sth->execute();
2012
-                } catch(PDOException $e) {
2013
-                        return "error : ".$e->getMessage();
2014
-                }
2011
+						$sth->execute();
2012
+				} catch(PDOException $e) {
2013
+						return "error : ".$e->getMessage();
2014
+				}
2015 2015
 
2016 2016
 		$error = '';
2017 2017
 		if ($globalDebug) echo "Notam : Download...";
@@ -2067,8 +2067,8 @@  discard block
 block discarded – undo
2067 2067
 					$data['date_end'] = date("Y-m-d H:i:s",strtotime($to));
2068 2068
 					$data['permanent'] = 0;
2069 2069
 				} else {
2070
-				    $data['date_end'] = NULL;
2071
-				    $data['permanent'] = 1;
2070
+					$data['date_end'] = NULL;
2071
+					$data['permanent'] = 1;
2072 2072
 				}
2073 2073
 				$data['full_notam'] = $notam['title'].'<br>'.$notam['description'];
2074 2074
 				$NOTAM = new NOTAM();
@@ -2127,13 +2127,13 @@  discard block
 block discarded – undo
2127 2127
 		try {
2128 2128
 			$Connection = new Connection();
2129 2129
 			$sth = $Connection->db->prepare($query);
2130
-                        $sth->execute();
2131
-                } catch(PDOException $e) {
2132
-                        return "error : ".$e->getMessage();
2133
-                }
2134
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2135
-                if ($row['nb'] > 0) return false;
2136
-                else return true;
2130
+						$sth->execute();
2131
+				} catch(PDOException $e) {
2132
+						return "error : ".$e->getMessage();
2133
+				}
2134
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2135
+				if ($row['nb'] > 0) return false;
2136
+				else return true;
2137 2137
 	}
2138 2138
 
2139 2139
 	public static function insert_last_update() {
@@ -2142,10 +2142,10 @@  discard block
 block discarded – undo
2142 2142
 		try {
2143 2143
 			$Connection = new Connection();
2144 2144
 			$sth = $Connection->db->prepare($query);
2145
-                        $sth->execute();
2146
-                } catch(PDOException $e) {
2147
-                        return "error : ".$e->getMessage();
2148
-                }
2145
+						$sth->execute();
2146
+				} catch(PDOException $e) {
2147
+						return "error : ".$e->getMessage();
2148
+				}
2149 2149
 	}
2150 2150
 
2151 2151
 	public static function check_airspace_version($version) {
@@ -2153,13 +2153,13 @@  discard block
 block discarded – undo
2153 2153
 		try {
2154 2154
 			$Connection = new Connection();
2155 2155
 			$sth = $Connection->db->prepare($query);
2156
-                        $sth->execute(array(':version' => $version));
2157
-                } catch(PDOException $e) {
2158
-                        return "error : ".$e->getMessage();
2159
-                }
2160
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2161
-                if ($row['nb'] > 0) return true;
2162
-                else return false;
2156
+						$sth->execute(array(':version' => $version));
2157
+				} catch(PDOException $e) {
2158
+						return "error : ".$e->getMessage();
2159
+				}
2160
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2161
+				if ($row['nb'] > 0) return true;
2162
+				else return false;
2163 2163
 	}
2164 2164
 
2165 2165
 
@@ -2169,10 +2169,10 @@  discard block
 block discarded – undo
2169 2169
 		try {
2170 2170
 			$Connection = new Connection();
2171 2171
 			$sth = $Connection->db->prepare($query);
2172
-                        $sth->execute(array(':version' => $version));
2173
-                } catch(PDOException $e) {
2174
-                        return "error : ".$e->getMessage();
2175
-                }
2172
+						$sth->execute(array(':version' => $version));
2173
+				} catch(PDOException $e) {
2174
+						return "error : ".$e->getMessage();
2175
+				}
2176 2176
 	}
2177 2177
 
2178 2178
 	public static function check_last_notam_update() {
@@ -2185,13 +2185,13 @@  discard block
 block discarded – undo
2185 2185
 		try {
2186 2186
 			$Connection = new Connection();
2187 2187
 			$sth = $Connection->db->prepare($query);
2188
-                        $sth->execute();
2189
-                } catch(PDOException $e) {
2190
-                        return "error : ".$e->getMessage();
2191
-                }
2192
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2193
-                if ($row['nb'] > 0) return false;
2194
-                else return true;
2188
+						$sth->execute();
2189
+				} catch(PDOException $e) {
2190
+						return "error : ".$e->getMessage();
2191
+				}
2192
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2193
+				if ($row['nb'] > 0) return false;
2194
+				else return true;
2195 2195
 	}
2196 2196
 
2197 2197
 	public static function insert_last_notam_update() {
@@ -2200,10 +2200,10 @@  discard block
 block discarded – undo
2200 2200
 		try {
2201 2201
 			$Connection = new Connection();
2202 2202
 			$sth = $Connection->db->prepare($query);
2203
-                        $sth->execute();
2204
-                } catch(PDOException $e) {
2205
-                        return "error : ".$e->getMessage();
2206
-                }
2203
+						$sth->execute();
2204
+				} catch(PDOException $e) {
2205
+						return "error : ".$e->getMessage();
2206
+				}
2207 2207
 	}
2208 2208
 	public static function check_last_airspace_update() {
2209 2209
 		global $globalDBdriver;
@@ -2215,13 +2215,13 @@  discard block
 block discarded – undo
2215 2215
 		try {
2216 2216
 			$Connection = new Connection();
2217 2217
 			$sth = $Connection->db->prepare($query);
2218
-                        $sth->execute();
2219
-                } catch(PDOException $e) {
2220
-                        return "error : ".$e->getMessage();
2221
-                }
2222
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2223
-                if ($row['nb'] > 0) return false;
2224
-                else return true;
2218
+						$sth->execute();
2219
+				} catch(PDOException $e) {
2220
+						return "error : ".$e->getMessage();
2221
+				}
2222
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2223
+				if ($row['nb'] > 0) return false;
2224
+				else return true;
2225 2225
 	}
2226 2226
 
2227 2227
 	public static function insert_last_airspace_update() {
@@ -2230,10 +2230,10 @@  discard block
 block discarded – undo
2230 2230
 		try {
2231 2231
 			$Connection = new Connection();
2232 2232
 			$sth = $Connection->db->prepare($query);
2233
-                        $sth->execute();
2234
-                } catch(PDOException $e) {
2235
-                        return "error : ".$e->getMessage();
2236
-                }
2233
+						$sth->execute();
2234
+				} catch(PDOException $e) {
2235
+						return "error : ".$e->getMessage();
2236
+				}
2237 2237
 	}
2238 2238
 
2239 2239
 	public static function check_last_owner_update() {
@@ -2246,13 +2246,13 @@  discard block
 block discarded – undo
2246 2246
 		try {
2247 2247
 			$Connection = new Connection();
2248 2248
 			$sth = $Connection->db->prepare($query);
2249
-                        $sth->execute();
2250
-                } catch(PDOException $e) {
2251
-                        return "error : ".$e->getMessage();
2252
-                }
2253
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2254
-                if ($row['nb'] > 0) return false;
2255
-                else return true;
2249
+						$sth->execute();
2250
+				} catch(PDOException $e) {
2251
+						return "error : ".$e->getMessage();
2252
+				}
2253
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2254
+				if ($row['nb'] > 0) return false;
2255
+				else return true;
2256 2256
 	}
2257 2257
 
2258 2258
 	public static function insert_last_owner_update() {
@@ -2261,10 +2261,10 @@  discard block
 block discarded – undo
2261 2261
 		try {
2262 2262
 			$Connection = new Connection();
2263 2263
 			$sth = $Connection->db->prepare($query);
2264
-                        $sth->execute();
2265
-                } catch(PDOException $e) {
2266
-                        return "error : ".$e->getMessage();
2267
-                }
2264
+						$sth->execute();
2265
+				} catch(PDOException $e) {
2266
+						return "error : ".$e->getMessage();
2267
+				}
2268 2268
 	}
2269 2269
 	public static function check_last_schedules_update() {
2270 2270
 		global $globalDBdriver;
@@ -2276,13 +2276,13 @@  discard block
 block discarded – undo
2276 2276
 		try {
2277 2277
 			$Connection = new Connection();
2278 2278
 			$sth = $Connection->db->prepare($query);
2279
-                        $sth->execute();
2280
-                } catch(PDOException $e) {
2281
-                        return "error : ".$e->getMessage();
2282
-                }
2283
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2284
-                if ($row['nb'] > 0) return false;
2285
-                else return true;
2279
+						$sth->execute();
2280
+				} catch(PDOException $e) {
2281
+						return "error : ".$e->getMessage();
2282
+				}
2283
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2284
+				if ($row['nb'] > 0) return false;
2285
+				else return true;
2286 2286
 	}
2287 2287
 
2288 2288
 	public static function insert_last_schedules_update() {
@@ -2291,10 +2291,10 @@  discard block
 block discarded – undo
2291 2291
 		try {
2292 2292
 			$Connection = new Connection();
2293 2293
 			$sth = $Connection->db->prepare($query);
2294
-                        $sth->execute();
2295
-                } catch(PDOException $e) {
2296
-                        return "error : ".$e->getMessage();
2297
-                }
2294
+						$sth->execute();
2295
+				} catch(PDOException $e) {
2296
+						return "error : ".$e->getMessage();
2297
+				}
2298 2298
 	}
2299 2299
 	public static function check_last_tle_update() {
2300 2300
 		global $globalDBdriver;
@@ -2306,13 +2306,13 @@  discard block
 block discarded – undo
2306 2306
 		try {
2307 2307
 			$Connection = new Connection();
2308 2308
 			$sth = $Connection->db->prepare($query);
2309
-                        $sth->execute();
2310
-                } catch(PDOException $e) {
2311
-                        return "error : ".$e->getMessage();
2312
-                }
2313
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2314
-                if ($row['nb'] > 0) return false;
2315
-                else return true;
2309
+						$sth->execute();
2310
+				} catch(PDOException $e) {
2311
+						return "error : ".$e->getMessage();
2312
+				}
2313
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2314
+				if ($row['nb'] > 0) return false;
2315
+				else return true;
2316 2316
 	}
2317 2317
 
2318 2318
 	public static function insert_last_tle_update() {
@@ -2321,10 +2321,10 @@  discard block
 block discarded – undo
2321 2321
 		try {
2322 2322
 			$Connection = new Connection();
2323 2323
 			$sth = $Connection->db->prepare($query);
2324
-                        $sth->execute();
2325
-                } catch(PDOException $e) {
2326
-                        return "error : ".$e->getMessage();
2327
-                }
2324
+						$sth->execute();
2325
+				} catch(PDOException $e) {
2326
+						return "error : ".$e->getMessage();
2327
+				}
2328 2328
 	}
2329 2329
 	public static function delete_duplicatemodes() {
2330 2330
 		global $globalDBdriver;
@@ -2336,10 +2336,10 @@  discard block
 block discarded – undo
2336 2336
 		try {
2337 2337
 			$Connection = new Connection();
2338 2338
 			$sth = $Connection->db->prepare($query);
2339
-                        $sth->execute();
2340
-                } catch(PDOException $e) {
2341
-                        return "error : ".$e->getMessage();
2342
-                }
2339
+						$sth->execute();
2340
+				} catch(PDOException $e) {
2341
+						return "error : ".$e->getMessage();
2342
+				}
2343 2343
 	}
2344 2344
 	public static function delete_duplicateowner() {
2345 2345
 		global $globalDBdriver;
@@ -2351,10 +2351,10 @@  discard block
 block discarded – undo
2351 2351
 		try {
2352 2352
 			$Connection = new Connection();
2353 2353
 			$sth = $Connection->db->prepare($query);
2354
-                        $sth->execute();
2355
-                } catch(PDOException $e) {
2356
-                        return "error : ".$e->getMessage();
2357
-                }
2354
+						$sth->execute();
2355
+				} catch(PDOException $e) {
2356
+						return "error : ".$e->getMessage();
2357
+				}
2358 2358
 	}
2359 2359
 	
2360 2360
 	public static function update_all() {
Please login to merge, or discard this patch.
require/class.Accident.php 1 patch
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -23,10 +23,10 @@  discard block
 block discarded – undo
23 23
 	}
24 24
 	
25 25
 	/**
26
-	* Get Latest ACARS data from DB
27
-	*
28
-	* @return Array Return ACARS data in array
29
-	*/
26
+	 * Get Latest ACARS data from DB
27
+	 *
28
+	 * @return Array Return ACARS data in array
29
+	 */
30 30
 	public function getLatestAccidentData($limit = '',$type = '') {
31 31
 	global $globalURL, $globalDBdriver;
32 32
 	$Image = new Image($this->db);
@@ -37,36 +37,36 @@  discard block
 block discarded – undo
37 37
 	$limit_query = '';
38 38
 	if ($limit != "")
39 39
 	{
40
-	    $limit_array = explode(",", $limit);
40
+		$limit_array = explode(",", $limit);
41 41
 
42
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
43
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
42
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
43
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
44 44
 
45
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
46
-	    {
45
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
46
+		{
47 47
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
48
-	    }
48
+		}
49 49
 	}
50 50
 
51 51
 	if ($type != '') {
52
-	    $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type GROUP BY registration) ORDER BY date DESC".$limit_query;
53
-	    $query_values = array(':type' => $type);
52
+		$query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type GROUP BY registration) ORDER BY date DESC".$limit_query;
53
+		$query_values = array(':type' => $type);
54 54
 	} else {
55
-	    //$query = "SELECT * FROM accidents GROUP BY registration ORDER BY date DESC".$limit_query;
56
-	    $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents GROUP BY registration) ORDER BY date DESC".$limit_query;
57
-	    $query_values = array();
55
+		//$query = "SELECT * FROM accidents GROUP BY registration ORDER BY date DESC".$limit_query;
56
+		$query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents GROUP BY registration) ORDER BY date DESC".$limit_query;
57
+		$query_values = array();
58 58
 	}
59 59
 	try {
60 60
 
61
-	    $sth = $this->db->prepare($query);
62
-	    $sth->execute($query_values);
61
+		$sth = $this->db->prepare($query);
62
+		$sth->execute($query_values);
63 63
 	} catch(PDOException $e) {
64
-	    return "error : ".$e->getMessage();
64
+		return "error : ".$e->getMessage();
65 65
 	}
66 66
 	$i = 0;
67 67
 	while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
68
-	    $data = array();
69
-	    if ($row['registration'] != '') {
68
+		$data = array();
69
+		if ($row['registration'] != '') {
70 70
 //		$row['registration'] = str_replace('.','',$row['registration']);
71 71
 		$image_array = $Image->getSpotterImage($row['registration']);
72 72
 		if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
@@ -89,33 +89,33 @@  discard block
 block discarded – undo
89 89
 			$data['aircraft_base'] = $owner_data['base'];
90 90
 			$data['aircraft_date_first_reg'] = $owner_data['date_first_reg'];
91 91
 		}
92
-	    } else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
93
-	    if ($row['registration'] == '') $row['registration'] = 'NA';
94
-	    if ($row['ident'] == '') $row['ident'] = 'NA';
95
-	    $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2));
96
-	    if (isset($identicao[0])) {
92
+		} else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
93
+		if ($row['registration'] == '') $row['registration'] = 'NA';
94
+		if ($row['ident'] == '') $row['ident'] = 'NA';
95
+		$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2));
96
+		if (isset($identicao[0])) {
97 97
 		if (substr($row['ident'],0,2) == 'AF') {
98
-		    if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
99
-		    else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
98
+			if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
99
+			else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
100 100
 		} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
101 101
 
102 102
 		$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
103
-	    } else $icao = $row['ident'];
104
-	    $icao = $Translation->checkTranslation($icao,false);
105
-	    //$data = array_merge($data,array('registration' => $row['registration'], 'date' => $row['date'], 'ident' => $icao,'url' => $row['url']));
106
-	    $data = array_merge($row,$data);
107
-	    if ($data['ident'] == null) $data['ident'] = $icao;
108
-	    if ($data['title'] == null) {
103
+		} else $icao = $row['ident'];
104
+		$icao = $Translation->checkTranslation($icao,false);
105
+		//$data = array_merge($data,array('registration' => $row['registration'], 'date' => $row['date'], 'ident' => $icao,'url' => $row['url']));
106
+		$data = array_merge($row,$data);
107
+		if ($data['ident'] == null) $data['ident'] = $icao;
108
+		if ($data['title'] == null) {
109 109
 		$data['message'] = $row['type'].' of '.$row['registration'].' at '.$row['place'].','.$row['country'];
110
-	    } else $data['message'] = strtolower($data['title']);
111
-	    $result[] = $data;
112
-	    $i++;
110
+		} else $data['message'] = strtolower($data['title']);
111
+		$result[] = $data;
112
+		$i++;
113 113
 	}
114 114
 	if (isset($result)) {
115
-	    $result[0]['query_number_rows'] = $i;
116
-	    return $result;
115
+		$result[0]['query_number_rows'] = $i;
116
+		return $result;
117 117
 	}
118 118
 	else return array();
119
-    }
119
+	}
120 120
 }
121 121
 ?>
122 122
\ No newline at end of file
Please login to merge, or discard this patch.
table-output.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -388,17 +388,17 @@  discard block
 block discarded – undo
388 388
 				else {
389 389
 					$planespotter_url_array = explode("_", $spotter_item['image']);
390 390
 					$planespotter_id = str_replace(".jpg", "", $planespotter_url_array[1]);
391
-                                        $image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id;
391
+										$image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id;
392 392
 				}
393 393
 				if (isset($spotter_item['airline_name'])) {
394 394
 					print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '.$spotter_item['airline_name'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
395 395
 				} else {
396 396
 					print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '._("Not available").'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
397 397
 				}
398
-                        } else {
399
-                    		if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
400
-                    		$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
401
-                    		} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
398
+						} else {
399
+							if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
400
+							$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
401
+							} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
402 402
 				if (isset($spotter_item['airline_name'])) {
403 403
 					print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '.$spotter_item['airline_name'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
404 404
 				} else {
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
 		}
414 414
 	} elseif(strtolower($current_page) != "currently" && strtolower($current_page) != "upcoming" && strtolower($current_page) != "acars-latest" && strtolower($current_page) != "acars-archive" && strtolower($current_page) != "accident-latest" && strtolower($current_page) != "incident-latest"){
415 415
 		if (!isset($spotter_item['squawk']) || $spotter_item['squawk'] == 0) {
416
-		    $spotter_item['squawk'] = '-';
416
+			$spotter_item['squawk'] = '-';
417 417
 		}
418 418
 		if ($spotter_item['image_thumbnail'] != "")
419 419
 		{
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
 				else {
425 425
 					$planespotter_url_array = explode("_", $spotter_array[0]['image']);
426 426
 					$planespotter_id = str_replace(".jpg", "", $planespotter_url_array[1]);
427
-                                        $image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id;
427
+										$image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id;
428 428
 				}
429 429
 				if (!isset($spotter_item['airline_name']) && isset($spotter_item['aircraft_name'])) {
430 430
 					print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
@@ -436,9 +436,9 @@  discard block
 block discarded – undo
436 436
 					print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '.$spotter_item['airline_name'].'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
437 437
 				}
438 438
 			} else {
439
-                    		if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
440
-                    		$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
441
-                    		} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
439
+							if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
440
+							$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
441
+							} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
442 442
 				if (!isset($spotter_item['airline_name']) && isset($spotter_item['aircraft_name'])) {
443 443
 					print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
444 444
 				} elseif (!isset($spotter_item['aircraft_name']) && isset($spotter_item['airline_name'])) {
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
 			print '</td>'."\n";
453 453
 		} else {
454 454
 			print '<td class="aircraft_thumbnail">'."\n";
455
-       //   	 	print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$globalURL.'/images/placeholder_thumb.png" alt="Click to see more information about this flight" title="Click to see more information about this flight" width="100px" /></a>';
455
+	   //   	 	print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$globalURL.'/images/placeholder_thumb.png" alt="Click to see more information about this flight" title="Click to see more information about this flight" width="100px" /></a>';
456 456
 	//}
457 457
 			if (!isset($spotter_item['airline_name']) && !isset($spotter_item['aircraft_name'])) {
458 458
 				print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$globalURL.'/images/placeholder_thumb.png" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '._("Not available").' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n";
@@ -557,13 +557,13 @@  discard block
 block discarded – undo
557 557
 				$distance = $Spotter->getAirportDistance($spotter_item['departure_airport'],$latitude,$longitude);
558 558
 			} else $distance = '';
559 559
 			if ($distance != '') {
560
-			    if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
561
-				    echo '<br/><i>'.round($distance*0.539957).' nm</i>';
562
-			    } elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) {
563
-				    echo '<br/><i>'.round($distance*0.621371).' mi</i>';
564
-			    } elseif ((!isset($_COOKIE['unitdistance']) && ((isset($globalUnitDistance) && $globalUnitDistance == 'km') || !isset($globalUnitDistance))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) {
565
-				    echo '<br/><i>'.$distance.' km</i>';
566
-			    }
560
+				if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
561
+					echo '<br/><i>'.round($distance*0.539957).' nm</i>';
562
+				} elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) {
563
+					echo '<br/><i>'.round($distance*0.621371).' mi</i>';
564
+				} elseif ((!isset($_COOKIE['unitdistance']) && ((isset($globalUnitDistance) && $globalUnitDistance == 'km') || !isset($globalUnitDistance))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) {
565
+					echo '<br/><i>'.$distance.' km</i>';
566
+				}
567 567
 			}
568 568
 		}
569 569
 		print '</td>'."\n";
@@ -624,13 +624,13 @@  discard block
 block discarded – undo
624 624
 				$distance = $Spotter->getAirportDistance($spotter_item['arrival_airport'],$latitude,$longitude);
625 625
 			} else $distance = '';
626 626
 				if ($distance != '') {
627
-				    if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
628
-					    echo '<br/><i>'.round($distance*0.539957).' nm</i>';
629
-				    } elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) {
630
-					    echo '<br/><i>'.round($distance*0.621371).' mi</i>';
631
-				    } elseif ((!isset($_COOKIE['unitdistance']) && ((isset($globalUnitDistance) && $globalUnitDistance == 'km') || !isset($globalUnitDistance))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) {
632
-					    echo '<br/><i>'.$distance.' km</i>';
633
-				    }
627
+					if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
628
+						echo '<br/><i>'.round($distance*0.539957).' nm</i>';
629
+					} elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) {
630
+						echo '<br/><i>'.round($distance*0.621371).' mi</i>';
631
+					} elseif ((!isset($_COOKIE['unitdistance']) && ((isset($globalUnitDistance) && $globalUnitDistance == 'km') || !isset($globalUnitDistance))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) {
632
+						echo '<br/><i>'.$distance.' km</i>';
633
+					}
634 634
 				}
635 635
 			}
636 636
 			print '</td>'."\n";
Please login to merge, or discard this patch.