Completed
Push — master ( 84a1ce...088ca9 )
by Yannick
05:27
created
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.
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.
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.
require/class.ATC.php 1 patch
Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -10,100 +10,100 @@
 block discarded – undo
10 10
 	}
11 11
 	
12 12
 	
13
-    /**
14
-    * Get SQL query part for filter used
15
-    * @param Array $filter the filter
16
-    * @return Array the SQL part
17
-    */
18
-    public function getFilter($filter = array(),$where = false,$and = false) {
13
+	/**
14
+	 * Get SQL query part for filter used
15
+	 * @param Array $filter the filter
16
+	 * @return Array the SQL part
17
+	 */
18
+	public function getFilter($filter = array(),$where = false,$and = false) {
19 19
 	global $globalFilter, $globalStatsFilters, $globalFilterName;
20 20
 	if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
21
-	    if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
21
+		if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
22 22
 		foreach($globalStatsFilters[$globalFilterName] as $source) {
23 23
 			if (isset($source['source'])) $filter['source'][] = $source['source'];
24 24
 		}
25
-	    } else {
25
+		} else {
26 26
 		$filter = $globalStatsFilters[$globalFilterName];
27
-	    }
27
+		}
28 28
 	}
29 29
 	if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
30 30
 	$filter_query_join = '';
31 31
 	$filter_query_where = '';
32 32
 	if (isset($filter['source']) && !empty($filter['source'])) {
33
-	    $filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')";
33
+		$filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')";
34 34
 	}
35 35
 	if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
36 36
 	elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
37 37
 	$filter_query = $filter_query_join.$filter_query_where;
38 38
 	return $filter_query;
39
-    }
39
+	}
40 40
 
41
-       public function getAll() {
42
-    		$filter_query = $this->getFilter(array());
43
-                $query = "SELECT * FROM atc".$filter_query;
44
-                $query_values = array();
45
-                 try {
46
-                        $sth = $this->db->prepare($query);
47
-                        $sth->execute($query_values);
48
-                } catch(PDOException $e) {
49
-                        return "error : ".$e->getMessage();
50
-                }
51
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
52
-                return $all;
53
-        }
41
+	   public function getAll() {
42
+			$filter_query = $this->getFilter(array());
43
+				$query = "SELECT * FROM atc".$filter_query;
44
+				$query_values = array();
45
+				 try {
46
+						$sth = $this->db->prepare($query);
47
+						$sth->execute($query_values);
48
+				} catch(PDOException $e) {
49
+						return "error : ".$e->getMessage();
50
+				}
51
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
52
+				return $all;
53
+		}
54 54
 
55
-       public function add($ident,$frequency,$latitude,$longitude,$range,$info,$date,$type = '',$ivao_id = '',$ivao_name = '',$format_source = '',$source_name = '') {
56
-    		$info = preg_replace('/[^(\x20-\x7F)]*/','',$info);
57
-    		$info = str_replace('^','<br />',$info);
58
-    		$info = str_replace('&amp;sect;','',$info);
59
-    		$info = str_replace('"','',$info);
60
-    		if ($type == '') $type = NULL;
61
-                $query = "INSERT INTO atc (ident,frequency,latitude,longitude,atc_range,info,atc_lastseen,type,ivao_id,ivao_name,format_source,source_name) VALUES (:ident,:frequency,:latitude,:longitude,:range,:info,:date,:type,:ivao_id,:ivao_name,:format_source,:source_name)";
62
-                $query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type,':format_source' => $format_source,':source_name' => $source_name);
63
-                 try {
64
-                        $sth = $this->db->prepare($query);
65
-                        $sth->execute($query_values);
66
-                } catch(PDOException $e) {
67
-                        return "error : ".$e->getMessage();
68
-                }
69
-        }
55
+	   public function add($ident,$frequency,$latitude,$longitude,$range,$info,$date,$type = '',$ivao_id = '',$ivao_name = '',$format_source = '',$source_name = '') {
56
+			$info = preg_replace('/[^(\x20-\x7F)]*/','',$info);
57
+			$info = str_replace('^','<br />',$info);
58
+			$info = str_replace('&amp;sect;','',$info);
59
+			$info = str_replace('"','',$info);
60
+			if ($type == '') $type = NULL;
61
+				$query = "INSERT INTO atc (ident,frequency,latitude,longitude,atc_range,info,atc_lastseen,type,ivao_id,ivao_name,format_source,source_name) VALUES (:ident,:frequency,:latitude,:longitude,:range,:info,:date,:type,:ivao_id,:ivao_name,:format_source,:source_name)";
62
+				$query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type,':format_source' => $format_source,':source_name' => $source_name);
63
+				 try {
64
+						$sth = $this->db->prepare($query);
65
+						$sth->execute($query_values);
66
+				} catch(PDOException $e) {
67
+						return "error : ".$e->getMessage();
68
+				}
69
+		}
70 70
 
71
-       public function deleteById($id) {
72
-                $query = "DELETE FROM atc WHERE atc_id = :id";
73
-                $query_values = array(':id' => $id);
74
-                 try {
75
-                        $sth = $this->db->prepare($query);
76
-                        $sth->execute($query_values);
77
-                } catch(PDOException $e) {
78
-                        return "error : ".$e->getMessage();
79
-                }
80
-        }
71
+	   public function deleteById($id) {
72
+				$query = "DELETE FROM atc WHERE atc_id = :id";
73
+				$query_values = array(':id' => $id);
74
+				 try {
75
+						$sth = $this->db->prepare($query);
76
+						$sth->execute($query_values);
77
+				} catch(PDOException $e) {
78
+						return "error : ".$e->getMessage();
79
+				}
80
+		}
81 81
 
82
-       public function deleteAll() {
83
-                $query = "DELETE FROM atc";
84
-                $query_values = array();
85
-                 try {
86
-                        $sth = $this->db->prepare($query);
87
-                        $sth->execute($query_values);
88
-                } catch(PDOException $e) {
89
-                        return "error : ".$e->getMessage();
90
-                }
91
-        }
82
+	   public function deleteAll() {
83
+				$query = "DELETE FROM atc";
84
+				$query_values = array();
85
+				 try {
86
+						$sth = $this->db->prepare($query);
87
+						$sth->execute($query_values);
88
+				} catch(PDOException $e) {
89
+						return "error : ".$e->getMessage();
90
+				}
91
+		}
92 92
 
93 93
 	public function deleteOldATC() {
94
-                global $globalDBdriver;
95
-                if ($globalDBdriver == 'mysql') {
96
-                        $query  = "DELETE FROM atc WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= atc.atc_lastseen";
97
-                } else {
98
-                        $query  = "DELETE FROM atc WHERE NOW() AT TIME ZONE 'UTC' - '1 HOUR'->INTERVAL >= atc.atc_lastseen";
99
-                }
100
-                try {
101
-                        $sth = $this->db->prepare($query);
102
-                        $sth->execute();
103
-                } catch(PDOException $e) {
104
-                        return "error";
105
-                }
106
-                return "success";
107
-        }
94
+				global $globalDBdriver;
95
+				if ($globalDBdriver == 'mysql') {
96
+						$query  = "DELETE FROM atc WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= atc.atc_lastseen";
97
+				} else {
98
+						$query  = "DELETE FROM atc WHERE NOW() AT TIME ZONE 'UTC' - '1 HOUR'->INTERVAL >= atc.atc_lastseen";
99
+				}
100
+				try {
101
+						$sth = $this->db->prepare($query);
102
+						$sth->execute();
103
+				} catch(PDOException $e) {
104
+						return "error";
105
+				}
106
+				return "success";
107
+		}
108 108
 }
109 109
 ?>
110 110
\ No newline at end of file
Please login to merge, or discard this patch.
header.php 1 patch
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 // When button "Remove all filters" is clicked
29 29
 if (isset($_POST['removefilters'])) {
30 30
 	$allfilters = array_filter(array_keys($_COOKIE),function($key) {
31
-	    return strpos($key,'filter_') === 0;
31
+		return strpos($key,'filter_') === 0;
32 32
 	});
33 33
 	foreach ($allfilters as $filt) {
34 34
 		unset($_COOKIE[$filt]);
@@ -167,16 +167,16 @@  discard block
 block discarded – undo
167 167
 	}
168 168
 ?>
169 169
 <?php 
170
-    if (isset($_POST['archive'])) {
170
+	if (isset($_POST['archive'])) {
171 171
 ?>
172 172
 <?php 
173
-	    if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
173
+		if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
174 174
 ?>
175 175
 
176 176
 <script src="<?php print $globalURL; ?>/js/map.js.php?<?php print time(); ?>&archive&begindate=<?php print strtotime($_POST['start_date']); ?>&enddate=<?php print strtotime($_POST['end_date']); ?>&archivespeed=<?php print $_POST['archivespeed']; ?>"></script>
177 177
 <?php    
178
-	    }
179
-    } else {
178
+		}
179
+	} else {
180 180
 ?>
181 181
 <?php
182 182
 /*	if (isset($globalBeta) && $globalBeta) {
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 */
189 189
 ?>
190 190
 <?php 
191
-	    if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
191
+		if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
192 192
 ?>
193 193
 <?php
194 194
 //		if (isset($globalBeta) && $globalBeta) {
@@ -199,13 +199,13 @@  discard block
 block discarded – undo
199 199
 ?>
200 200
 <script src="<?php print $globalURL; ?>/js/map.js.php?<?php print time(); ?>"></script>
201 201
 <?php
202
-	    }
202
+		}
203 203
 ?>
204 204
 <?php
205 205
 //	}
206 206
 ?>
207 207
 <?php
208
-    }
208
+	}
209 209
 }
210 210
 ?>
211 211
 <?php
@@ -365,32 +365,32 @@  discard block
 block discarded – undo
365 365
             <li><a href="<?php print $globalURL; ?>/date/<?php print date("Y-m-d"); ?>"><?php echo _("Today's Activity"); ?></a></li>
366 366
             <li><a href="<?php print $globalURL; ?>/newest"><?php echo _("Newest by Category"); ?></a></li>
367 367
             <?php
368
-        	if ($globalACARS) {
369
-        	    if (isset($globalDemo) && $globalDemo) {
370
-    	    ?>
368
+			if ($globalACARS) {
369
+				if (isset($globalDemo) && $globalDemo) {
370
+			?>
371 371
             <li><hr /></li>
372 372
             <li><i><?php echo _('ACARS data not available publicly'); ?></i></li>
373 373
             <li><a href=""><?php echo _('Latest ACARS messages'); ?></a></li>
374 374
             <li><a href=""><?php echo _('Archive ACARS messages'); ?></a></li>
375 375
             <?php
376
-        	    } else {
377
-    	    ?>
376
+				} else {
377
+			?>
378 378
             <li><hr /></li>
379 379
             <li><a href="<?php print $globalURL; ?>/acars-latest"><?php echo _("Latest ACARS messages"); ?></a></li>
380 380
             <li><a href="<?php print $globalURL; ?>/acars-archive"><?php echo _("Archive ACARS messages"); ?></a></li>
381 381
             <?php
382
-        	    }
383
-        	}
384
-    	    ?>
382
+				}
383
+			}
384
+			?>
385 385
     	    <?php
386
-    	        if (isset($globalAccidents) && $globalAccidents) {
387
-    	    ?>
386
+				if (isset($globalAccidents) && $globalAccidents) {
387
+			?>
388 388
             <li><hr /></li>
389 389
             <li><a href="<?php print $globalURL; ?>/accident-latest"><?php echo _("Latest accident messages"); ?></a></li>
390 390
             <li><a href="<?php print $globalURL; ?>/incident-latest"><?php echo _("Latest incident messages"); ?></a></li>
391 391
             <?php
392
-        	}
393
-    	    ?>
392
+			}
393
+			?>
394 394
             <li><hr /></li>
395 395
             <li><a href="<?php print $globalURL; ?>/highlights/table"><?php echo _("Special Highlights"); ?></a></li>
396 396
             <li><a href="<?php print $globalURL; ?>/upcoming"><?php echo _("Upcoming Flights"); ?></a></li>
@@ -432,14 +432,14 @@  discard block
 block discarded – undo
432 432
   	    <form>
433 433
   		<select class="selectpicker" data-width="120px" onchange="language(this);">
434 434
   		    <?php
435
-  		        $Language = new Language();
436
-  		        $alllang = $Language->getLanguages();
437
-  		        foreach ($alllang as $key => $lang) {
438
-  		            print '<option value="'.$key.'"';
439
-  		            if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) print ' selected ';
440
-  		            print '>'.$lang[0].'</option>';
441
-  		        }
442
-  		    ?>
435
+  				$Language = new Language();
436
+  				$alllang = $Language->getLanguages();
437
+  				foreach ($alllang as $key => $lang) {
438
+  					print '<option value="'.$key.'"';
439
+  					if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) print ' selected ';
440
+  					print '>'.$lang[0].'</option>';
441
+  				}
442
+  			?>
443 443
   		</select>
444 444
   	    </form>
445 445
   	</div>
@@ -470,18 +470,18 @@  discard block
 block discarded – undo
470 470
 ?>
471 471
     <div class="top-header clear" role="main">
472 472
 <?php
473
-    if (isset($longitude) && isset($latitude) && $longitude != 0 && $latitude != 0) {
473
+	if (isset($longitude) && isset($latitude) && $longitude != 0 && $latitude != 0) {
474 474
 ?>
475 475
     <div id="archive-map"></div>
476 476
 <?php
477
-    }
477
+	}
478 478
 ?>
479 479
     </div>
480 480
 <?php
481 481
 }
482 482
 if ((strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) || (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false))
483 483
 {
484
-    ?>
484
+	?>
485 485
     <div class="top-header clear" role="main">
486 486
         <div id="map"></div>
487 487
 	<link rel="stylesheet" href="<?php print $globalURL; ?>/css/leaflet.css" />
@@ -492,15 +492,15 @@  discard block
 block discarded – undo
492 492
         var zoom = 13;
493 493
 //create the map
494 494
 <?php
495
-    if (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($airport_array[0]['latitude'])) {
495
+	if (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($airport_array[0]['latitude'])) {
496 496
 ?>
497 497
   map = L.map('map', { zoomControl:true }).setView([<?php print $airport_array[0]['latitude']; ?>,<?php print $airport_array[0]['longitude']; ?>], zoom);
498 498
 <?php
499
-    } elseif (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) {
499
+	} elseif (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) {
500 500
 ?>
501 501
   map = L.map('map', { zoomControl:true });
502 502
 <?php
503
-    } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) {
503
+	} elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) {
504 504
 ?>
505 505
   map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['departure_airport_latitude']; ?>,<?php print $spotter_array[0]['arrival_airport_longitude']; ?>]);
506 506
     var line = L.polyline([[<?php print $spotter_array[0]['departure_airport_latitude']; ?>, <?php print $spotter_array[0]['departure_airport_longitude']; ?>],[<?php print $spotter_array[0]['arrival_airport_latitude']; ?>, <?php print $spotter_array[0]['arrival_airport_longitude']; ?>]]).addTo(map);
@@ -508,22 +508,22 @@  discard block
 block discarded – undo
508 508
     var departure_airport = L.marker([<?php print $spotter_array[0]['departure_airport_latitude']; ?>, <?php print $spotter_array[0]['departure_airport_longitude']; ?>], {icon: L.icon({iconUrl: '<?php print $globalURL; ?>/images/departure_airport.png',iconSize: [16,18],iconAnchor: [8,16]})}).addTo(map);
509 509
     var arrival_airport = L.marker([<?php print $spotter_array[0]['arrival_airport_latitude']; ?>, <?php print $spotter_array[0]['arrival_airport_longitude']; ?>], {icon: L.icon({iconUrl: '<?php print $globalURL; ?>/images/arrival_airport.png',iconSize: [16,18],iconAnchor: [8,16]})}).addTo(map);
510 510
 <?php
511
-    } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude'])) {
511
+	} elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude'])) {
512 512
 ?>
513 513
   map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['latitude']; ?>,<?php print $spotter_array[0]['longitude']; ?>]);
514 514
 <?php
515
-    } elseif (!isset($spotter_array[0]['latitude']) && !isset($spotter_array[0]['longitude'])) {
515
+	} elseif (!isset($spotter_array[0]['latitude']) && !isset($spotter_array[0]['longitude'])) {
516 516
 ?>
517 517
   map = L.map('map', { zoomControl:true });
518 518
 <?php
519
-    }
519
+	}
520 520
 ?>
521 521
   //initialize the layer group for the aircrft markers
522 522
   var layer_data = L.layerGroup();
523 523
 
524 524
   //a few title layers
525 525
 <?php
526
-    if ($globalMapProvider == 'Mapbox') {
526
+	if ($globalMapProvider == 'Mapbox') {
527 527
 ?>
528 528
   L.tileLayer('https://{s}.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={token}', {
529 529
     maxZoom: 18,
@@ -534,7 +534,7 @@  discard block
 block discarded – undo
534 534
     token : '<?php print $globalMapboxToken; ?>'
535 535
   }).addTo(map);
536 536
 <?php
537
-    } elseif ($globalMapProvider == 'OpenStreetMap') {
537
+	} elseif ($globalMapProvider == 'OpenStreetMap') {
538 538
 ?>
539 539
   L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
540 540
     maxZoom: 18,
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
       '<a href="http://www.openstreetmap.org/copyright">Open Database Licence</a>'
543 543
   }).addTo(map);
544 544
 <?php
545
-    } elseif ($globalMapProvider == 'MapQuest-OSM') {
545
+	} elseif ($globalMapProvider == 'MapQuest-OSM') {
546 546
 ?>
547 547
   L.tileLayer('http://otile1.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.png', {
548 548
     maxZoom: 18,
@@ -551,7 +551,7 @@  discard block
 block discarded – undo
551 551
       'Tiles Courtesy of <a href="http://www.mapquest.com">MapQuest</a>'
552 552
   }).addTo(map);
553 553
 <?php
554
-    } elseif ($globalMapProvider == 'MapQuest-Aerial') {
554
+	} elseif ($globalMapProvider == 'MapQuest-Aerial') {
555 555
 ?>
556 556
   L.tileLayer('http://otile1.mqcdn.com/tiles/1.0.0/sat/{z}/{x}/{y}.png', {
557 557
     maxZoom: 18,
@@ -560,27 +560,27 @@  discard block
 block discarded – undo
560 560
       'Tiles Courtesy of <a href="http://www.mapquest.com">MapQuest</a>, Portions Courtesy NASA/JPL-Caltech and U.S. Depart. of Agriculture, Farm Service Agency"'
561 561
   }).addTo(map);
562 562
 <?php
563
-    } elseif ($globalMapProvider == 'Google-Roadmap') {
563
+	} elseif ($globalMapProvider == 'Google-Roadmap') {
564 564
 ?>
565 565
     var googleLayer = new L.Google('ROADMAP');
566 566
     map.addLayer(googleLayer);
567 567
 <?php
568
-    } elseif ($globalMapProvider == 'Google-Satellite') {
568
+	} elseif ($globalMapProvider == 'Google-Satellite') {
569 569
 ?>
570 570
     var googleLayer = new L.Google('SATELLITE');
571 571
     map.addLayer(googleLayer);
572 572
 <?php
573
-    } elseif ($globalMapProvider == 'Google-Hybrid') {
573
+	} elseif ($globalMapProvider == 'Google-Hybrid') {
574 574
 ?>
575 575
     var googleLayer = new L.Google('HYBRID');
576 576
     map.addLayer(googleLayer);
577 577
 <?php
578
-    } elseif ($globalMapProvider == 'Google-Terrain') {
578
+	} elseif ($globalMapProvider == 'Google-Terrain') {
579 579
 ?>
580 580
     var googleLayer = new L.Google('Terrain');
581 581
     map.addLayer(googleLayer);
582 582
 <?php
583
-    }
583
+	}
584 584
 ?>
585 585
         </script>
586 586
     </div>
Please login to merge, or discard this patch.
require/class.METAR.php 1 patch
Indentation   +261 added lines, -261 removed lines patch added patch discarded remove patch
@@ -7,109 +7,109 @@  discard block
 block discarded – undo
7 7
 	public $db;
8 8
 	
9 9
 	protected $texts = Array(
10
-	    'MI' => 'Shallow',
11
-	    'PR' => 'Partial',
12
-	    'BC' => 'Low drifting',
13
-	    'BL' => 'Blowing',
14
-	    'SH' => 'Showers',
15
-	    'TS' => 'Thunderstorm',
16
-	    'FZ' => 'Freezing',
17
-	    'DZ' => 'Drizzle',
18
-	    'RA' => 'Rain',
19
-	    'SN' => 'Snow',
20
-	    'SG' => 'Snow Grains',
21
-	    'IC' => 'Ice crystals',
22
-	    'PL' => 'Ice pellets',
23
-	    'GR' => 'Hail',
24
-	    'GS' => 'Small hail',
25
-	    'UP' => 'Unknown',
26
-	    'BR' => 'Mist',
27
-	    'FG' => 'Fog',
28
-	    'FU' => 'Smoke',
29
-	    'VA' => 'Volcanic ash',
30
-	    'DU' => 'Widespread dust',
31
-	    'SA' => 'Sand',
32
-	    'HZ' => 'Haze',
33
-	    'PY' => 'Spray',
34
-	    'PO' => 'Well developed dust / sand whirls',
35
-	    'SQ' => 'Squalls',
36
-	    'FC' => 'Funnel clouds inc tornadoes or waterspouts',
37
-	    'SS' => 'Sandstorm',
38
-	    'DS' => 'Duststorm'
10
+		'MI' => 'Shallow',
11
+		'PR' => 'Partial',
12
+		'BC' => 'Low drifting',
13
+		'BL' => 'Blowing',
14
+		'SH' => 'Showers',
15
+		'TS' => 'Thunderstorm',
16
+		'FZ' => 'Freezing',
17
+		'DZ' => 'Drizzle',
18
+		'RA' => 'Rain',
19
+		'SN' => 'Snow',
20
+		'SG' => 'Snow Grains',
21
+		'IC' => 'Ice crystals',
22
+		'PL' => 'Ice pellets',
23
+		'GR' => 'Hail',
24
+		'GS' => 'Small hail',
25
+		'UP' => 'Unknown',
26
+		'BR' => 'Mist',
27
+		'FG' => 'Fog',
28
+		'FU' => 'Smoke',
29
+		'VA' => 'Volcanic ash',
30
+		'DU' => 'Widespread dust',
31
+		'SA' => 'Sand',
32
+		'HZ' => 'Haze',
33
+		'PY' => 'Spray',
34
+		'PO' => 'Well developed dust / sand whirls',
35
+		'SQ' => 'Squalls',
36
+		'FC' => 'Funnel clouds inc tornadoes or waterspouts',
37
+		'SS' => 'Sandstorm',
38
+		'DS' => 'Duststorm'
39 39
 	);
40 40
 	
41 41
 	public function __construct($dbc = null) {
42
-                $Connection = new Connection($dbc);
43
-                $this->db = $Connection->db;
44
-        }
42
+				$Connection = new Connection($dbc);
43
+				$this->db = $Connection->db;
44
+		}
45 45
 
46
-       public static function check_last_update() {
47
-    		global $globalDBdriver;
48
-    		if ($globalDBdriver == 'mysql') {
46
+	   public static function check_last_update() {
47
+			global $globalDBdriver;
48
+			if ($globalDBdriver == 'mysql') {
49 49
 			$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_metar' AND value > DATE_SUB(NOW(), INTERVAL 20 MINUTE)";
50 50
 		} else {
51 51
 			$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_metar' AND value::timestamp > CURRENT_TIMESTAMP - INTERVAL '20 MINUTES'";
52 52
 		}
53
-                try {
54
-                        $Connection = new Connection();
55
-                        $sth = $Connection->db->prepare($query);
56
-                        $sth->execute();
57
-                } catch(PDOException $e) {
58
-                        return "error : ".$e->getMessage();
59
-                }
60
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
61
-                $sth->closeCursor();
62
-                if ($row['nb'] > 0) return false;
63
-                else return true;
64
-        }
53
+				try {
54
+						$Connection = new Connection();
55
+						$sth = $Connection->db->prepare($query);
56
+						$sth->execute();
57
+				} catch(PDOException $e) {
58
+						return "error : ".$e->getMessage();
59
+				}
60
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
61
+				$sth->closeCursor();
62
+				if ($row['nb'] > 0) return false;
63
+				else return true;
64
+		}
65 65
 
66
-        public static function insert_last_update() {
67
-                $query = "DELETE FROM config WHERE name = 'last_update_metar';
66
+		public static function insert_last_update() {
67
+				$query = "DELETE FROM config WHERE name = 'last_update_metar';
68 68
                         INSERT INTO config (name,value) VALUES ('last_update_metar',NOW());";
69
-                try {
70
-                        $Connection = new Connection();
71
-                        $sth = $Connection->db->prepare($query);
72
-                        $sth->execute();
73
-                } catch(PDOException $e) {
74
-                        return "error : ".$e->getMessage();
75
-                }
76
-        }
69
+				try {
70
+						$Connection = new Connection();
71
+						$sth = $Connection->db->prepare($query);
72
+						$sth->execute();
73
+				} catch(PDOException $e) {
74
+						return "error : ".$e->getMessage();
75
+				}
76
+		}
77 77
 
78 78
 
79 79
         
80
-        public function parse($data) {
81
-    		//$data = str_replace(array('\n','\r','\r','\n'),'',$data);
82
-    		$codes = implode('|', array_keys($this->texts));
83
-    		$regWeather = '#^(\+|\-|VC)?(' . $codes . ')(' . $codes . ')?$#';
84
-    		//$pieces = explode(' ',$data);
85
-    		$pieces = preg_split('/\s/',$data);
86
-    		$pos = 0;
87
-    		if ($pieces[0] == 'METAR') $pos++;
88
-    		elseif ($pieces[0] == 'SPECI') $pos++;
89
-    		if (strlen($pieces[$pos]) != 4) $pos++;
90
-    		$result = array();
91
-    		$result['location'] = $pieces[$pos];
92
-    		$pos++;
93
-    		$result['dayofmonth'] = substr($pieces[$pos],0,2);
94
-    		$result['time'] = substr($pieces[$pos],2,4);
95
-    		$c = count($pieces);
96
-    		for($pos++; $pos < $c; $pos++) {
97
-    			$piece = $pieces[$pos];
98
-    			if ($piece == 'RMK') break;
99
-    			if ($piece == 'AUTO') $result['auto'] = true;
100
-    			if ($piece == 'COR') $result['correction'] = true;
101
-    			// Wind Speed
102
-    			if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) {
103
-    				$result['wind']['direction'] = (float)$matches[1];
80
+		public function parse($data) {
81
+			//$data = str_replace(array('\n','\r','\r','\n'),'',$data);
82
+			$codes = implode('|', array_keys($this->texts));
83
+			$regWeather = '#^(\+|\-|VC)?(' . $codes . ')(' . $codes . ')?$#';
84
+			//$pieces = explode(' ',$data);
85
+			$pieces = preg_split('/\s/',$data);
86
+			$pos = 0;
87
+			if ($pieces[0] == 'METAR') $pos++;
88
+			elseif ($pieces[0] == 'SPECI') $pos++;
89
+			if (strlen($pieces[$pos]) != 4) $pos++;
90
+			$result = array();
91
+			$result['location'] = $pieces[$pos];
92
+			$pos++;
93
+			$result['dayofmonth'] = substr($pieces[$pos],0,2);
94
+			$result['time'] = substr($pieces[$pos],2,4);
95
+			$c = count($pieces);
96
+			for($pos++; $pos < $c; $pos++) {
97
+				$piece = $pieces[$pos];
98
+				if ($piece == 'RMK') break;
99
+				if ($piece == 'AUTO') $result['auto'] = true;
100
+				if ($piece == 'COR') $result['correction'] = true;
101
+				// Wind Speed
102
+				if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) {
103
+					$result['wind']['direction'] = (float)$matches[1];
104 104
 				$result['wind']['unit'] = $matches[4];
105
-    				if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2);
106
-    				elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2);
107
-    				elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2);
105
+					if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2);
106
+					elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2);
107
+					elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2);
108 108
 				$result['wind']['gust'] = (float)$matches[3];
109 109
 				$result['wind']['unit'] = $matches[4];
110 110
 				$result['wind']['min_variation'] = array_key_exists(5,$matches) ? $matches[5] : 0;
111 111
 				$result['wind']['max_variation'] = array_key_exists(6,$matches) ? $matches[6] : 0;
112
-    			}
112
+				}
113 113
 
114 114
 /*    			if (preg_match('#^([0-9]{3})([0-9]{2})(G([0-9]{2}))?(KT|MPS)$#', $piece, $matches)) {
115 115
     				$result['wind_direction'] = (float)$matches[1];
@@ -126,35 +126,35 @@  discard block
 block discarded – undo
126 126
     				}
127 127
     			}
128 128
     			*/
129
-    			// Temperature
130
-    			if (preg_match('#^(M?[0-9]{2,})/(M?[0-9]{2,})$#', $piece, $matches)) {
131
-    				$temp = (float)$matches[1];
129
+				// Temperature
130
+				if (preg_match('#^(M?[0-9]{2,})/(M?[0-9]{2,})$#', $piece, $matches)) {
131
+					$temp = (float)$matches[1];
132 132
 				if ($matches[1]{0} == 'M') {
133 133
 					$temp = ((float)substr($matches[1], 1)) * -1;
134 134
 				}
135
-    				$result['temperature'] = $temp;
136
-    				$dew = (float)$matches[2];
135
+					$result['temperature'] = $temp;
136
+					$dew = (float)$matches[2];
137 137
 				if ($matches[2]{0} == 'M') {
138 138
 					$dew = ((float)substr($matches[2], 1)) * -1;
139 139
 				}
140 140
 				$result['dew'] = $dew;
141
-    			}
142
-    			// QNH
143
-    			if (preg_match('#^(A|Q)([0-9]{4})$#', $piece, $matches)) {
144
-    			// #^(Q|A)(////|[0-9]{4})( )#
145
-    				if ($matches[1] == 'Q') {
146
-    					// hPa
147
-    					$result['QNH'] = $matches[2];
148
-    				} else {
149
-    					// inHg
150
-    					$result['QNH'] = round(($matches[2] / 100)*33.86389,2);
151 141
 				}
152
-    				/*
142
+				// QNH
143
+				if (preg_match('#^(A|Q)([0-9]{4})$#', $piece, $matches)) {
144
+				// #^(Q|A)(////|[0-9]{4})( )#
145
+					if ($matches[1] == 'Q') {
146
+						// hPa
147
+						$result['QNH'] = $matches[2];
148
+					} else {
149
+						// inHg
150
+						$result['QNH'] = round(($matches[2] / 100)*33.86389,2);
151
+				}
152
+					/*
153 153
     				$result['QNH'] = $matches[1] == 'Q' ? $matches[2] : ($matches[2] / 100);
154 154
     				$result['QNH_format'] = $matches[1] == 'Q' ? 'hPa' : 'inHg';
155 155
     				*/
156
-    			}
157
-                     /*
156
+				}
157
+					 /*
158 158
     			// Wind Direction
159 159
     			if (preg_match('#^([0-9]{3})V([0-9]{3})$#', $piece, $matches)) {
160 160
     				$result['wind_direction'] = $matches[1];
@@ -165,9 +165,9 @@  discard block
 block discarded – undo
165 165
     				$result['speed_variable'] = $matches[1];
166 166
     			}
167 167
     			*/
168
-    			// Visibility
169
-    			if (preg_match('#^([0-9]{4})|(([0-9]{1,4})SM)$#', $piece, $matches)) {
170
-    				if (isset($matches[3]) && strlen($matches[3]) > 0) {
168
+				// Visibility
169
+				if (preg_match('#^([0-9]{4})|(([0-9]{1,4})SM)$#', $piece, $matches)) {
170
+					if (isset($matches[3]) && strlen($matches[3]) > 0) {
171 171
 					$result['visibility'] = (float)$matches[3] * 1609.34;
172 172
 				} else {
173 173
 					if ($matches[1] == '9999') {
@@ -180,28 +180,28 @@  discard block
 block discarded – undo
180 180
 					$result['visibility'] = '> 10000';
181 181
 					$result['weather'] = "CAVOK";
182 182
 				}
183
-    			}
184
-    			// Cloud Coverage
185
-    			if (preg_match('#^(SKC|CLR|FEW|SCT|BKN|OVC|VV)([0-9]{3})(CB|TCU|CU|CI)?$#', $piece, $matches)) {
186
-    				//$this->addCloudCover($matches[1], ((float)$matches[2]) * 100, isset($matches[3]) ? $matches[3] : '');
187
-    				$type = $matches[1];
188
-    				$cloud = array();
189
-    				if ($type == 'SKC') $cloud['type'] = 'No cloud/Sky clear';
190
-    				elseif ($type == 'CLR') $cloud['type'] = 'No cloud below 12,000ft (3700m)';
191
-    				elseif ($type == 'NSC') $cloud['type'] = 'No significant cloud';
192
-    				elseif ($type == 'FEW') $cloud['type'] = 'Few';
193
-    				elseif ($type == 'SCT') $cloud['type'] = 'Scattered';
194
-    				elseif ($type == 'BKN') $cloud['type'] = 'Broken';
195
-    				elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage';
196
-    				elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility';
197
-    				$cloud['type_code'] = $type;
198
-    				$cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048);
199
-    				$cloud['significant'] = isset($matches[3]) ? $matches[3] : '';
200
-    				$result['cloud'][] = $cloud;
201
-    			}
202
-    			// RVR
203
-    			 if (preg_match('#^(R.+)/([M|P])?(\d{4})(?:V(\d+)|[UDN])?(FT)?$#', $piece, $matches)) {
204
-    				$rvr = array();
183
+				}
184
+				// Cloud Coverage
185
+				if (preg_match('#^(SKC|CLR|FEW|SCT|BKN|OVC|VV)([0-9]{3})(CB|TCU|CU|CI)?$#', $piece, $matches)) {
186
+					//$this->addCloudCover($matches[1], ((float)$matches[2]) * 100, isset($matches[3]) ? $matches[3] : '');
187
+					$type = $matches[1];
188
+					$cloud = array();
189
+					if ($type == 'SKC') $cloud['type'] = 'No cloud/Sky clear';
190
+					elseif ($type == 'CLR') $cloud['type'] = 'No cloud below 12,000ft (3700m)';
191
+					elseif ($type == 'NSC') $cloud['type'] = 'No significant cloud';
192
+					elseif ($type == 'FEW') $cloud['type'] = 'Few';
193
+					elseif ($type == 'SCT') $cloud['type'] = 'Scattered';
194
+					elseif ($type == 'BKN') $cloud['type'] = 'Broken';
195
+					elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage';
196
+					elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility';
197
+					$cloud['type_code'] = $type;
198
+					$cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048);
199
+					$cloud['significant'] = isset($matches[3]) ? $matches[3] : '';
200
+					$result['cloud'][] = $cloud;
201
+				}
202
+				// RVR
203
+				 if (preg_match('#^(R.+)/([M|P])?(\d{4})(?:V(\d+)|[UDN])?(FT)?$#', $piece, $matches)) {
204
+					$rvr = array();
205 205
 				$rvr['runway'] = $matches[1];
206 206
 				$rvr['assessment'] = $matches[2];
207 207
 				$rvr['rvr'] = $matches[3];
@@ -210,33 +210,33 @@  discard block
 block discarded – undo
210 210
 				$result['RVR'] = $rvr;
211 211
 			}
212 212
     			
213
-    			//if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
214
-    			if (preg_match('#^R(\d{2}[LRC]?)/([\d/])([\d/])([\d/]{2})([\d/]{2})$#', $piece, $matches)) {
215
-    				//print_r($matches);
216
-    				// https://github.com/davidmegginson/metar-taf/blob/master/Metar.php
217
-    				$result['RVR']['runway'] = $matches[1];
218
-        			$result['RVR']['deposits'] = $matches[2];
219
-        			$result['RVR']['extent'] = $matches[3];
220
-        			$result['RVR']['depth'] = $matches[4];
221
-        			$result['RVR']['friction'] = $matches[5];
222
-    			}
223
-    			if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
224
-    				//echo $piece;
225
-    				//print_r($matches);
226
-    				if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
227
-    				else $range = array('exact' => (float)$matches[2], 'unit' => 'M');
213
+				//if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
214
+				if (preg_match('#^R(\d{2}[LRC]?)/([\d/])([\d/])([\d/]{2})([\d/]{2})$#', $piece, $matches)) {
215
+					//print_r($matches);
216
+					// https://github.com/davidmegginson/metar-taf/blob/master/Metar.php
217
+					$result['RVR']['runway'] = $matches[1];
218
+					$result['RVR']['deposits'] = $matches[2];
219
+					$result['RVR']['extent'] = $matches[3];
220
+					$result['RVR']['depth'] = $matches[4];
221
+					$result['RVR']['friction'] = $matches[5];
222
+				}
223
+				if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
224
+					//echo $piece;
225
+					//print_r($matches);
226
+					if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
227
+					else $range = array('exact' => (float)$matches[2], 'unit' => 'M');
228 228
 				if (isset($matches[3])) {
229 229
 					$range = Array(
230
-					    'from' => (float)$matches[2],
231
-					    'to'   => (float)$matches[4],
232
-					    'unit' => $matches[5] ? 'FT' : 'M'
230
+						'from' => (float)$matches[2],
231
+						'to'   => (float)$matches[4],
232
+						'unit' => $matches[5] ? 'FT' : 'M'
233 233
 					);
234 234
 				}
235 235
 				$result['RVR'] = $matches[1];
236 236
 				$result['RVR_range'] = $range;
237
-    			}
238
-    			// Weather
239
-    			if (preg_match($regWeather, $piece, $matches)) {
237
+				}
238
+				// Weather
239
+				if (preg_match($regWeather, $piece, $matches)) {
240 240
 				$text = Array();
241 241
 				switch ($matches[1]) {
242 242
 					case '+':
@@ -259,35 +259,35 @@  discard block
 block discarded – undo
259 259
 				}
260 260
 				if (!isset($result['weather'])) $result['weather'] = implode(' ', $text);
261 261
 				else $result['weather'] = $result['weather'].' / '.implode(' ', $text);
262
-    			}
263
-    		}
264
-    		return $result;
262
+				}
263
+			}
264
+			return $result;
265 265
         
266
-        }
266
+		}
267 267
         
268 268
 	public function getMETAR($icao) {
269
-    		global $globalMETARcycle, $globalDBdriver;
270
-    		if (isset($globalMETARcycle) && $globalMETARcycle) {
271
-            		$query = "SELECT * FROM metar WHERE metar_location = :icao";
272
-                } else {
273
-            		if ($globalDBdriver == 'mysql') $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1";
274
-            		else $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1";
275
-                }
276
-                $query_values = array(':icao' => $icao);
277
-                 try {
278
-                        $sth = $this->db->prepare($query);
279
-                        $sth->execute($query_values);
280
-                } catch(PDOException $e) {
281
-                        return "error : ".$e->getMessage();
282
-                }
283
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
284
-                if ((!isset($globalMETARcycle) || $globalMETARcycle === false) && count($all) == 0) {
285
-            		$all = $this->downloadMETAR($icao);
286
-                }
287
-                return $all;
288
-        }
269
+			global $globalMETARcycle, $globalDBdriver;
270
+			if (isset($globalMETARcycle) && $globalMETARcycle) {
271
+					$query = "SELECT * FROM metar WHERE metar_location = :icao";
272
+				} else {
273
+					if ($globalDBdriver == 'mysql') $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1";
274
+					else $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1";
275
+				}
276
+				$query_values = array(':icao' => $icao);
277
+				 try {
278
+						$sth = $this->db->prepare($query);
279
+						$sth->execute($query_values);
280
+				} catch(PDOException $e) {
281
+						return "error : ".$e->getMessage();
282
+				}
283
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
284
+				if ((!isset($globalMETARcycle) || $globalMETARcycle === false) && count($all) == 0) {
285
+					$all = $this->downloadMETAR($icao);
286
+				}
287
+				return $all;
288
+		}
289 289
 
290
-       public function addMETAR($location,$metar,$date) {
290
+	   public function addMETAR($location,$metar,$date) {
291 291
 		global $globalDBdriver;
292 292
 		$date = date('Y-m-d H:i:s',strtotime($date));
293 293
 		if ($globalDBdriver == 'mysql') {
@@ -295,104 +295,104 @@  discard block
 block discarded – undo
295 295
 		} else {
296 296
 			$query = "UPDATE metar SET metar_date = :date, metar = metar WHERE metar_location = :location;INSERT INTO metar (metar_location,metar_date,metar) SELECT :location,:date,:metar WHERE NOT EXISTS (SELECT 1 FROM metar WHERE metar_location = :location);";
297 297
 		}
298
-                $query_values = array(':location' => $location,':date' => $date,':metar' => utf8_encode($metar));
299
-                 try {
300
-                        $sth = $this->db->prepare($query);
301
-                        $sth->execute($query_values);
302
-                } catch(PDOException $e) {
303
-                        return "error : ".$e->getMessage();
304
-                }
305
-        }
298
+				$query_values = array(':location' => $location,':date' => $date,':metar' => utf8_encode($metar));
299
+				 try {
300
+						$sth = $this->db->prepare($query);
301
+						$sth->execute($query_values);
302
+				} catch(PDOException $e) {
303
+						return "error : ".$e->getMessage();
304
+				}
305
+		}
306 306
 
307
-       public function deleteMETAR($id) {
308
-                $query = "DELETE FROM metar WHERE id = :id";
309
-                $query_values = array(':id' => $id);
310
-                 try {
311
-                        $sth = $this->db->prepare($query);
312
-                        $sth->execute($query_values);
313
-                } catch(PDOException $e) {
314
-                        return "error : ".$e->getMessage();
315
-                }
316
-        }
317
-       public function deleteAllMETARLocation() {
318
-                $query = "DELETE FROM metar";
319
-                 try {
320
-                        $sth = $this->db->prepare($query);
321
-                        $sth->execute();
322
-                } catch(PDOException $e) {
323
-                        return "error : ".$e->getMessage();
324
-                }
325
-        }
307
+	   public function deleteMETAR($id) {
308
+				$query = "DELETE FROM metar WHERE id = :id";
309
+				$query_values = array(':id' => $id);
310
+				 try {
311
+						$sth = $this->db->prepare($query);
312
+						$sth->execute($query_values);
313
+				} catch(PDOException $e) {
314
+						return "error : ".$e->getMessage();
315
+				}
316
+		}
317
+	   public function deleteAllMETARLocation() {
318
+				$query = "DELETE FROM metar";
319
+				 try {
320
+						$sth = $this->db->prepare($query);
321
+						$sth->execute();
322
+				} catch(PDOException $e) {
323
+						return "error : ".$e->getMessage();
324
+				}
325
+		}
326 326
         
327
-        public function addMETARCycle() {
328
-    		global $globalDebug, $globalIVAO;
329
-    		if (isset($globalDebug) && $globalDebug) echo "Downloading METAR cycle...";
330
-    		date_default_timezone_set("UTC");
331
-    		$Common = new Common();
332
-    		if (isset($globalIVAO) && $globalIVAO) {
333
-        		//$cycle = $Common->getData('http://wx.ivao.aero/metar.php');
327
+		public function addMETARCycle() {
328
+			global $globalDebug, $globalIVAO;
329
+			if (isset($globalDebug) && $globalDebug) echo "Downloading METAR cycle...";
330
+			date_default_timezone_set("UTC");
331
+			$Common = new Common();
332
+			if (isset($globalIVAO) && $globalIVAO) {
333
+				//$cycle = $Common->getData('http://wx.ivao.aero/metar.php');
334 334
 			$Common->download('http://wx.ivao.aero/metar.php',dirname(__FILE__).'/../install/tmp/ivaometar.txt');
335
-    			$handle = fopen(dirname(__FILE__).'/../install/tmp/ivaometar.txt',"r");
336
-    		} else {
335
+				$handle = fopen(dirname(__FILE__).'/../install/tmp/ivaometar.txt',"r");
336
+			} else {
337 337
 			//$cycle = $Common->getData('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT');
338 338
 			$Common->download('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT',dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT');
339
-    			$handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT',"r");
340
-    		}
341
-    		if ($handle) {
339
+				$handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT',"r");
340
+			}
341
+			if ($handle) {
342 342
 			if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB...";
343 343
 			$date = '';
344
-    			//foreach(explode("\n",$cycle) as $line) {
345
-	    		while(($line = fgets($handle,4096)) !== false) {
344
+				//foreach(explode("\n",$cycle) as $line) {
345
+				while(($line = fgets($handle,4096)) !== false) {
346 346
 				if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
347 347
 					$date = $line;
348
-    				} elseif ($line != '') {
349
-    				    //$this->parse($line);
350
-    				    if ($date == '') $date = date('Y/m/d H:m');
351
-        			    $pos = 0;
352
-        			    $pieces = preg_split('/\s/',$line);
353
-        			    if ($pieces[0] == 'METAR') $pos++;
354
-        			    if (strlen($pieces[$pos]) != 4) $pos++;
355
-		        	    $location = $pieces[$pos];
356
-        	        	    echo $this->addMETAR($location,$line,$date);
357
-    				}
358
-    			}
359
-    			fclose($handle);
360
-    		}
361
-    		if (isset($globalDebug) && $globalDebug) echo "Done\n";
348
+					} elseif ($line != '') {
349
+						//$this->parse($line);
350
+						if ($date == '') $date = date('Y/m/d H:m');
351
+						$pos = 0;
352
+						$pieces = preg_split('/\s/',$line);
353
+						if ($pieces[0] == 'METAR') $pos++;
354
+						if (strlen($pieces[$pos]) != 4) $pos++;
355
+						$location = $pieces[$pos];
356
+							echo $this->addMETAR($location,$line,$date);
357
+					}
358
+				}
359
+				fclose($handle);
360
+			}
361
+			if (isset($globalDebug) && $globalDebug) echo "Done\n";
362 362
         
363
-        }
364
-        public function downloadMETAR($icao) {
365
-    		global $globalMETARurl;
366
-    		if ($globalMETARurl == '') return array();
367
-    		date_default_timezone_set("UTC");
368
-    		$Common = new Common();
369
-    		$url = str_replace('{icao}',$icao,$globalMETARurl);
370
-    		$cycle = $Common->getData($url);
371
-    		$date = '';
372
-    		foreach(explode("\n",$cycle) as $line) {
373
-    			if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
374
-    				//echo "date : ".$line."\n";
375
-    				$date = $line;
376
-    			} 
377
-    			if ($line != '') {
378
-    			    //$this->parse($line);
379
-    			    //echo $line;
380
-    			    if ($date == '') $date = date('Y/m/d H:m');
381
-    			    $pos = 0;
382
-    			    $pieces = preg_split('/\s/',$line);
383
-    			    if ($pieces[0] == 'METAR') $pos++;
384
-    			    if (strlen($pieces[$pos]) != 4) $pos++;
385
-	        	    $location = $pieces[$pos];
386
-	        	    if (strlen($location == 4)) {
387
-	        		$this->addMETAR($location,$line,$date);
388
-	        		return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line));
389
-	        	    } else return array();
390
-    			}
391
-    			//echo $line."\n";
392
-    		}
393
-    		return array();
363
+		}
364
+		public function downloadMETAR($icao) {
365
+			global $globalMETARurl;
366
+			if ($globalMETARurl == '') return array();
367
+			date_default_timezone_set("UTC");
368
+			$Common = new Common();
369
+			$url = str_replace('{icao}',$icao,$globalMETARurl);
370
+			$cycle = $Common->getData($url);
371
+			$date = '';
372
+			foreach(explode("\n",$cycle) as $line) {
373
+				if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
374
+					//echo "date : ".$line."\n";
375
+					$date = $line;
376
+				} 
377
+				if ($line != '') {
378
+					//$this->parse($line);
379
+					//echo $line;
380
+					if ($date == '') $date = date('Y/m/d H:m');
381
+					$pos = 0;
382
+					$pieces = preg_split('/\s/',$line);
383
+					if ($pieces[0] == 'METAR') $pos++;
384
+					if (strlen($pieces[$pos]) != 4) $pos++;
385
+					$location = $pieces[$pos];
386
+					if (strlen($location == 4)) {
387
+					$this->addMETAR($location,$line,$date);
388
+					return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line));
389
+					} else return array();
390
+				}
391
+				//echo $line."\n";
392
+			}
393
+			return array();
394 394
         
395
-        }
395
+		}
396 396
 }
397 397
 /*
398 398
 $METAR = new METAR();
Please login to merge, or discard this patch.
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 FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND 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 FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND 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 FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND 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 FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND 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 FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND 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 FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND 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.Accident.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -22,10 +22,10 @@
 block discarded – undo
22 22
 	}
23 23
 	
24 24
 	/**
25
-	* Get Accidents data from DB
26
-	*
27
-	* @return Array Return Accidents data in array
28
-	*/
25
+	 * Get Accidents data from DB
26
+	 *
27
+	 * @return Array Return Accidents data in array
28
+	 */
29 29
 	public function getAccidentData($limit = '',$type = '',$date = '') {
30 30
 		global $globalURL, $globalDBdriver;
31 31
 		$Image = new Image($this->db);
Please login to merge, or discard this patch.
require/class.Stats.php 1 patch
Indentation   +833 added lines, -833 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 ($airport_icao != '') {
@@ -1096,8 +1096,8 @@  discard block
 block discarded – undo
1096 1096
 			} catch(PDOException $e) {
1097 1097
 				return "error : ".$e->getMessage();
1098 1098
 			}
1099
-                }
1100
-        }
1099
+				}
1100
+		}
1101 1101
 	public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') {
1102 1102
 		global $globalDBdriver;
1103 1103
 		if ($airport_icao != '') {
@@ -1113,8 +1113,8 @@  discard block
 block discarded – undo
1113 1113
 			} catch(PDOException $e) {
1114 1114
 				return "error : ".$e->getMessage();
1115 1115
 			}
1116
-                }
1117
-        }
1116
+				}
1117
+		}
1118 1118
 	public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') {
1119 1119
 		global $globalDBdriver;
1120 1120
 		if ($airport_icao != '') {
@@ -1123,15 +1123,15 @@  discard block
 block discarded – undo
1123 1123
 			} else {
1124 1124
 				$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);"; 
1125 1125
 			}
1126
-	                $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);
1126
+					$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);
1127 1127
 			 try {
1128
-                    		$sth = $this->db->prepare($query);
1129
-	                        $sth->execute($query_values);
1130
-    		        } catch(PDOException $e) {
1131
-            		        return "error : ".$e->getMessage();
1132
-	                }
1133
-	        }
1134
-        }
1128
+							$sth = $this->db->prepare($query);
1129
+							$sth->execute($query_values);
1130
+					} catch(PDOException $e) {
1131
+							return "error : ".$e->getMessage();
1132
+					}
1133
+			}
1134
+		}
1135 1135
 	public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') {
1136 1136
 		global $globalDBdriver;
1137 1137
 		if ($airport_icao != '') {
@@ -1147,46 +1147,46 @@  discard block
 block discarded – undo
1147 1147
 			} catch(PDOException $e) {
1148 1148
 				return "error : ".$e->getMessage();
1149 1149
 			}
1150
-                }
1151
-        }
1150
+				}
1151
+		}
1152 1152
 
1153 1153
 	public function deleteStat($id) {
1154
-                $query = "DELETE FROM stats WHERE stats_id = :id";
1155
-                $query_values = array(':id' => $id);
1156
-                 try {
1157
-                        $sth = $this->db->prepare($query);
1158
-                        $sth->execute($query_values);
1159
-                } catch(PDOException $e) {
1160
-                        return "error : ".$e->getMessage();
1161
-                }
1162
-        }
1154
+				$query = "DELETE FROM stats WHERE stats_id = :id";
1155
+				$query_values = array(':id' => $id);
1156
+				 try {
1157
+						$sth = $this->db->prepare($query);
1158
+						$sth->execute($query_values);
1159
+				} catch(PDOException $e) {
1160
+						return "error : ".$e->getMessage();
1161
+				}
1162
+		}
1163 1163
 	public function deleteStatFlight($type) {
1164
-                $query = "DELETE FROM stats_flight WHERE stats_type = :type";
1165
-                $query_values = array(':type' => $type);
1166
-                 try {
1167
-                        $sth = $this->db->prepare($query);
1168
-                        $sth->execute($query_values);
1169
-                } catch(PDOException $e) {
1170
-                        return "error : ".$e->getMessage();
1171
-                }
1172
-        }
1164
+				$query = "DELETE FROM stats_flight WHERE stats_type = :type";
1165
+				$query_values = array(':type' => $type);
1166
+				 try {
1167
+						$sth = $this->db->prepare($query);
1168
+						$sth->execute($query_values);
1169
+				} catch(PDOException $e) {
1170
+						return "error : ".$e->getMessage();
1171
+				}
1172
+		}
1173 1173
 	public function deleteStatAirport($type) {
1174
-                $query = "DELETE FROM stats_airport WHERE stats_type = :type";
1175
-                $query_values = array(':type' => $type);
1176
-                 try {
1177
-                        $sth = $this->db->prepare($query);
1178
-                        $sth->execute($query_values);
1179
-                } catch(PDOException $e) {
1180
-                        return "error : ".$e->getMessage();
1181
-                }
1182
-        }
1174
+				$query = "DELETE FROM stats_airport WHERE stats_type = :type";
1175
+				$query_values = array(':type' => $type);
1176
+				 try {
1177
+						$sth = $this->db->prepare($query);
1178
+						$sth->execute($query_values);
1179
+				} catch(PDOException $e) {
1180
+						return "error : ".$e->getMessage();
1181
+				}
1182
+		}
1183 1183
         
1184
-        public function addOldStats() {
1185
-    		global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats;
1186
-    		$Common = new Common();
1187
-    		$Connection = new Connection();
1188
-    		date_default_timezone_set('UTC');
1189
-    		$last_update = $this->getLastStatsUpdate('last_update_stats');
1184
+		public function addOldStats() {
1185
+			global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats;
1186
+			$Common = new Common();
1187
+			$Connection = new Connection();
1188
+			date_default_timezone_set('UTC');
1189
+			$last_update = $this->getLastStatsUpdate('last_update_stats');
1190 1190
 		//print_r($last_update);
1191 1191
 		/*
1192 1192
 		$flightsbymonth = $this->getStats('flights_by_month');
@@ -1448,24 +1448,24 @@  discard block
 block discarded – undo
1448 1448
 			if ($globalDebug) echo 'Count all departure airports...'."\n";
1449 1449
 			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
1450 1450
 			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
1451
-        		$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1451
+				$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1452 1452
 			if ($globalDebug) echo 'Order departure airports...'."\n";
1453
-	        	$alldata = array();
1453
+				$alldata = array();
1454 1454
 	        	
1455
-    			foreach ($pall as $value) {
1456
-	        		$icao = $value['airport_departure_icao'];
1457
-    				$alldata[$icao] = $value;
1458
-	        	}
1459
-	        	foreach ($dall as $value) {
1460
-    				$icao = $value['airport_departure_icao'];
1461
-        			if (isset($alldata[$icao])) {
1462
-    					$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1463
-        			} else $alldata[$icao] = $value;
1464
-			}
1465
-    			$count = array();
1466
-    			foreach ($alldata as $key => $row) {
1467
-    				$count[$key] = $row['airport_departure_icao_count'];
1468
-        		}
1455
+				foreach ($pall as $value) {
1456
+					$icao = $value['airport_departure_icao'];
1457
+					$alldata[$icao] = $value;
1458
+				}
1459
+				foreach ($dall as $value) {
1460
+					$icao = $value['airport_departure_icao'];
1461
+					if (isset($alldata[$icao])) {
1462
+						$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1463
+					} else $alldata[$icao] = $value;
1464
+			}
1465
+				$count = array();
1466
+				foreach ($alldata as $key => $row) {
1467
+					$count[$key] = $row['airport_departure_icao_count'];
1468
+				}
1469 1469
 			array_multisort($count,SORT_DESC,$alldata);
1470 1470
 			foreach ($alldata as $number) {
1471 1471
 				echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count']);
@@ -1473,25 +1473,25 @@  discard block
 block discarded – undo
1473 1473
 			if ($globalDebug) echo 'Count all arrival airports...'."\n";
1474 1474
 			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
1475 1475
 			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
1476
-        		$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1476
+				$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1477 1477
 			if ($globalDebug) echo 'Order arrival airports...'."\n";
1478
-	        	$alldata = array();
1479
-    			foreach ($pall as $value) {
1480
-	        		$icao = $value['airport_arrival_icao'];
1481
-    				$alldata[$icao] = $value;
1482
-	        	}
1483
-	        	foreach ($dall as $value) {
1484
-    				$icao = $value['airport_arrival_icao'];
1485
-        			if (isset($alldata[$icao])) {
1486
-        				$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1487
-	        		} else $alldata[$icao] = $value;
1488
-    			}
1489
-        		$count = array();
1490
-        		foreach ($alldata as $key => $row) {
1491
-        			$count[$key] = $row['airport_arrival_icao_count'];
1492
-	        	}
1493
-    			array_multisort($count,SORT_DESC,$alldata);
1494
-                        foreach ($alldata as $number) {
1478
+				$alldata = array();
1479
+				foreach ($pall as $value) {
1480
+					$icao = $value['airport_arrival_icao'];
1481
+					$alldata[$icao] = $value;
1482
+				}
1483
+				foreach ($dall as $value) {
1484
+					$icao = $value['airport_arrival_icao'];
1485
+					if (isset($alldata[$icao])) {
1486
+						$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1487
+					} else $alldata[$icao] = $value;
1488
+				}
1489
+				$count = array();
1490
+				foreach ($alldata as $key => $row) {
1491
+					$count[$key] = $row['airport_arrival_icao_count'];
1492
+				}
1493
+				array_multisort($count,SORT_DESC,$alldata);
1494
+						foreach ($alldata as $number) {
1495 1495
 				echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count']);
1496 1496
 			}
1497 1497
 			if ($Connection->tableExists('countries')) {
@@ -1551,8 +1551,8 @@  discard block
 block discarded – undo
1551 1551
 //			$pall = $Spotter->getLast7DaysAirportsDeparture();
1552 1552
   //      		$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
1553 1553
 			$pall = $Spotter->getLast7DaysAirportsDeparture();
1554
-        		$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
1555
-        		/*
1554
+				$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
1555
+				/*
1556 1556
 	        	$alldata = array();
1557 1557
     			foreach ($pall as $value) {
1558 1558
 	        		$icao = $value['departure_airport_icao'];
@@ -1571,29 +1571,29 @@  discard block
 block discarded – undo
1571 1571
 	        	}
1572 1572
     			array_multisort($count,SORT_DESC,$alldata);
1573 1573
     			*/
1574
-    			foreach ($dall as $value) {
1575
-    				$icao = $value['departure_airport_icao'];
1576
-    				$ddate = $value['date'];
1577
-    				$find = false;
1578
-    				foreach ($pall as $pvalue) {
1579
-    					if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1580
-    						$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1581
-    						$find = true;
1582
-    						break;
1583
-    					}
1584
-    				}
1585
-    				if ($find === false) {
1586
-    					$pall[] = $value;
1587
-    				}
1588
-    			}
1589
-    			$alldata = $pall;
1574
+				foreach ($dall as $value) {
1575
+					$icao = $value['departure_airport_icao'];
1576
+					$ddate = $value['date'];
1577
+					$find = false;
1578
+					foreach ($pall as $pvalue) {
1579
+						if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1580
+							$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1581
+							$find = true;
1582
+							break;
1583
+						}
1584
+					}
1585
+					if ($find === false) {
1586
+						$pall[] = $value;
1587
+					}
1588
+				}
1589
+				$alldata = $pall;
1590 1590
 			foreach ($alldata as $number) {
1591 1591
 				$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']);
1592 1592
 			}
1593 1593
 			echo '...Arrival'."\n";
1594 1594
 			$pall = $Spotter->getLast7DaysAirportsArrival();
1595
-        		$dall = $Spotter->getLast7DaysDetectedAirportsArrival();
1596
-        		/*
1595
+				$dall = $Spotter->getLast7DaysDetectedAirportsArrival();
1596
+				/*
1597 1597
 	        	$alldata = array();
1598 1598
     			foreach ($pall as $value) {
1599 1599
 	        		$icao = $value['arrival_airport_icao'];
@@ -1613,22 +1613,22 @@  discard block
 block discarded – undo
1613 1613
     			*/
1614 1614
 
1615 1615
 
1616
-    			foreach ($dall as $value) {
1617
-    				$icao = $value['arrival_airport_icao'];
1618
-    				$ddate = $value['date'];
1619
-    				$find = false;
1620
-    				foreach ($pall as $pvalue) {
1621
-    					if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1622
-    						$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1623
-    						$find = true;
1624
-    						break;
1625
-    					}
1626
-    				}
1627
-    				if ($find === false) {
1628
-    					$pall[] = $value;
1629
-    				}
1630
-    			}
1631
-    			$alldata = $pall;
1616
+				foreach ($dall as $value) {
1617
+					$icao = $value['arrival_airport_icao'];
1618
+					$ddate = $value['date'];
1619
+					$find = false;
1620
+					foreach ($pall as $pvalue) {
1621
+						if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1622
+							$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1623
+							$find = true;
1624
+							break;
1625
+						}
1626
+					}
1627
+					if ($find === false) {
1628
+						$pall[] = $value;
1629
+					}
1630
+				}
1631
+				$alldata = $pall;
1632 1632
 			foreach ($alldata as $number) {
1633 1633
 				$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']);
1634 1634
 			}
@@ -1695,51 +1695,51 @@  discard block
 block discarded – undo
1695 1695
 			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
1696 1696
 			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
1697 1697
 			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
1698
-       			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
1698
+	   			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
1699 1699
 			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
1700
-	        	//$alldata = array();
1701
-    			foreach ($dall as $value) {
1702
-    				$icao = $value['airport_departure_icao'];
1703
-    				$dicao = $value['airline_icao'];
1704
-    				$find = false;
1705
-    				foreach ($pall as $pvalue) {
1706
-    					if ($pvalue['airport_departure_icao'] == $icao && $pvalue['airline_icao'] = $dicao) {
1707
-    						$pvalue['airport_departure_icao_count'] = $pvalue['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1708
-    						$find = true;
1709
-    						break;
1710
-    					}
1711
-    				}
1712
-    				if ($find === false) {
1713
-    					$pall[] = $value;
1714
-    				}
1715
-    			}
1716
-    			$alldata = $pall;
1700
+				//$alldata = array();
1701
+				foreach ($dall as $value) {
1702
+					$icao = $value['airport_departure_icao'];
1703
+					$dicao = $value['airline_icao'];
1704
+					$find = false;
1705
+					foreach ($pall as $pvalue) {
1706
+						if ($pvalue['airport_departure_icao'] == $icao && $pvalue['airline_icao'] = $dicao) {
1707
+							$pvalue['airport_departure_icao_count'] = $pvalue['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1708
+							$find = true;
1709
+							break;
1710
+						}
1711
+					}
1712
+					if ($find === false) {
1713
+						$pall[] = $value;
1714
+					}
1715
+				}
1716
+				$alldata = $pall;
1717 1717
 			foreach ($alldata as $number) {
1718 1718
 				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']);
1719 1719
 			}
1720 1720
 			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
1721 1721
 			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
1722 1722
 			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
1723
-        		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
1723
+				$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
1724 1724
 			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
1725
-	        	//$alldata = array();
1726
-    			foreach ($dall as $value) {
1727
-    				$icao = $value['airport_arrival_icao'];
1728
-    				$dicao = $value['airline_icao'];
1729
-    				$find = false;
1730
-    				foreach ($pall as $pvalue) {
1731
-    					if ($pvalue['airport_arrival_icao'] == $icao && $pvalue['airline_icao'] = $dicao) {
1732
-    						$pvalue['airport_arrival_icao_count'] = $pvalue['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1733
-    						$find = true;
1734
-    						break;
1735
-    					}
1736
-    				}
1737
-    				if ($find === false) {
1738
-    					$pall[] = $value;
1739
-    				}
1740
-    			}
1741
-    			$alldata = $pall;
1742
-                        foreach ($alldata as $number) {
1725
+				//$alldata = array();
1726
+				foreach ($dall as $value) {
1727
+					$icao = $value['airport_arrival_icao'];
1728
+					$dicao = $value['airline_icao'];
1729
+					$find = false;
1730
+					foreach ($pall as $pvalue) {
1731
+						if ($pvalue['airport_arrival_icao'] == $icao && $pvalue['airline_icao'] = $dicao) {
1732
+							$pvalue['airport_arrival_icao_count'] = $pvalue['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1733
+							$find = true;
1734
+							break;
1735
+						}
1736
+					}
1737
+					if ($find === false) {
1738
+						$pall[] = $value;
1739
+					}
1740
+				}
1741
+				$alldata = $pall;
1742
+						foreach ($alldata as $number) {
1743 1743
 				if ($number['airline_icao'] != '') 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']);
1744 1744
 			}
1745 1745
 			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
@@ -1772,47 +1772,47 @@  discard block
 block discarded – undo
1772 1772
 			}
1773 1773
 			if ($globalDebug) echo '...Departure'."\n";
1774 1774
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
1775
-        		$dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines();
1776
-    			foreach ($dall as $value) {
1777
-    				$icao = $value['departure_airport_icao'];
1778
-    				$airline = $value['airline_icao'];
1779
-    				$ddate = $value['date'];
1780
-    				$find = false;
1781
-    				foreach ($pall as $pvalue) {
1782
-    					if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] = $airline) {
1783
-    						$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1784
-    						$find = true;
1785
-    						break;
1786
-    					}
1787
-    				}
1788
-    				if ($find === false) {
1789
-    					$pall[] = $value;
1790
-    				}
1791
-    			}
1792
-    			$alldata = $pall;
1775
+				$dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines();
1776
+				foreach ($dall as $value) {
1777
+					$icao = $value['departure_airport_icao'];
1778
+					$airline = $value['airline_icao'];
1779
+					$ddate = $value['date'];
1780
+					$find = false;
1781
+					foreach ($pall as $pvalue) {
1782
+						if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] = $airline) {
1783
+							$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1784
+							$find = true;
1785
+							break;
1786
+						}
1787
+					}
1788
+					if ($find === false) {
1789
+						$pall[] = $value;
1790
+					}
1791
+				}
1792
+				$alldata = $pall;
1793 1793
 			foreach ($alldata as $number) {
1794 1794
 				$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']);
1795 1795
 			}
1796 1796
 			if ($globalDebug) echo '...Arrival'."\n";
1797 1797
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
1798
-        		$dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines();
1799
-    			foreach ($dall as $value) {
1800
-    				$icao = $value['arrival_airport_icao'];
1801
-    				$airline = $value['airline_icao'];
1802
-    				$ddate = $value['date'];
1803
-    				$find = false;
1804
-    				foreach ($pall as $pvalue) {
1805
-    					if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] == $airline) {
1806
-    						$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1807
-    						$find = true;
1808
-    						break;
1809
-    					}
1810
-    				}
1811
-    				if ($find === false) {
1812
-    					$pall[] = $value;
1813
-    				}
1814
-    			}
1815
-    			$alldata = $pall;
1798
+				$dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines();
1799
+				foreach ($dall as $value) {
1800
+					$icao = $value['arrival_airport_icao'];
1801
+					$airline = $value['airline_icao'];
1802
+					$ddate = $value['date'];
1803
+					$find = false;
1804
+					foreach ($pall as $pvalue) {
1805
+						if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] == $airline) {
1806
+							$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1807
+							$find = true;
1808
+							break;
1809
+						}
1810
+					}
1811
+					if ($find === false) {
1812
+						$pall[] = $value;
1813
+					}
1814
+				}
1815
+				$alldata = $pall;
1816 1816
 			foreach ($alldata as $number) {
1817 1817
 				$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']);
1818 1818
 			}
@@ -1881,44 +1881,44 @@  discard block
 block discarded – undo
1881 1881
 					$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source']);
1882 1882
 				}
1883 1883
 				$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter);
1884
-	       			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
1885
-		        	$alldata = array();
1886
-	    			foreach ($pall as $value) {
1887
-		        		$icao = $value['airport_departure_icao'];
1888
-    					$alldata[$icao] = $value;
1889
-	    			}
1890
-		        	foreach ($dall as $value) {
1891
-	    				$icao = $value['airport_departure_icao'];
1892
-        				if (isset($alldata[$icao])) {
1893
-    						$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1894
-        				} else $alldata[$icao] = $value;
1895
-				}
1896
-	    			$count = array();
1897
-    				foreach ($alldata as $key => $row) {
1898
-    					$count[$key] = $row['airport_departure_icao_count'];
1899
-    				}
1884
+		   			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
1885
+					$alldata = array();
1886
+					foreach ($pall as $value) {
1887
+						$icao = $value['airport_departure_icao'];
1888
+						$alldata[$icao] = $value;
1889
+					}
1890
+					foreach ($dall as $value) {
1891
+						$icao = $value['airport_departure_icao'];
1892
+						if (isset($alldata[$icao])) {
1893
+							$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1894
+						} else $alldata[$icao] = $value;
1895
+				}
1896
+					$count = array();
1897
+					foreach ($alldata as $key => $row) {
1898
+						$count[$key] = $row['airport_departure_icao_count'];
1899
+					}
1900 1900
 				array_multisort($count,SORT_DESC,$alldata);
1901 1901
 				foreach ($alldata as $number) {
1902
-    					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);
1902
+						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);
1903 1903
 				}
1904 1904
 				$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter);
1905
-    				$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter);
1905
+					$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter);
1906 1906
 				$alldata = array();
1907
-    				foreach ($pall as $value) {
1908
-		        		$icao = $value['airport_arrival_icao'];
1909
-    					$alldata[$icao] = $value;
1910
-	    			}
1911
-		        	foreach ($dall as $value) {
1912
-	    				$icao = $value['airport_arrival_icao'];
1913
-        				if (isset($alldata[$icao])) {
1914
-        					$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1915
-		        		} else $alldata[$icao] = $value;
1916
-	    			}
1917
-        			$count = array();
1918
-        			foreach ($alldata as $key => $row) {
1919
-    					$count[$key] = $row['airport_arrival_icao_count'];
1920
-		        	}
1921
-        			array_multisort($count,SORT_DESC,$alldata);
1907
+					foreach ($pall as $value) {
1908
+						$icao = $value['airport_arrival_icao'];
1909
+						$alldata[$icao] = $value;
1910
+					}
1911
+					foreach ($dall as $value) {
1912
+						$icao = $value['airport_arrival_icao'];
1913
+						if (isset($alldata[$icao])) {
1914
+							$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1915
+						} else $alldata[$icao] = $value;
1916
+					}
1917
+					$count = array();
1918
+					foreach ($alldata as $key => $row) {
1919
+						$count[$key] = $row['airport_arrival_icao_count'];
1920
+					}
1921
+					array_multisort($count,SORT_DESC,$alldata);
1922 1922
 				foreach ($alldata as $number) {
1923 1923
 					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);
1924 1924
 				}
@@ -1951,45 +1951,45 @@  discard block
 block discarded – undo
1951 1951
 				}
1952 1952
 				echo '...Departure'."\n";
1953 1953
 				$pall = $Spotter->getLast7DaysAirportsDeparture('',$filter);
1954
-        			$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter);
1954
+					$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter);
1955 1955
 				foreach ($dall as $value) {
1956
-    					$icao = $value['departure_airport_icao'];
1957
-    					$ddate = $value['date'];
1958
-    					$find = false;
1959
-    					foreach ($pall as $pvalue) {
1960
-    						if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1961
-    							$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1962
-	    						$find = true;
1963
-    							break;
1964
-    						}
1965
-    					}
1966
-    					if ($find === false) {
1967
-    						$pall[] = $value;
1968
-	    				}
1969
-    				}
1970
-	    			$alldata = $pall;
1956
+						$icao = $value['departure_airport_icao'];
1957
+						$ddate = $value['date'];
1958
+						$find = false;
1959
+						foreach ($pall as $pvalue) {
1960
+							if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1961
+								$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1962
+								$find = true;
1963
+								break;
1964
+							}
1965
+						}
1966
+						if ($find === false) {
1967
+							$pall[] = $value;
1968
+						}
1969
+					}
1970
+					$alldata = $pall;
1971 1971
 				foreach ($alldata as $number) {
1972 1972
 					$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);
1973 1973
 				}
1974 1974
 				echo '...Arrival'."\n";
1975 1975
 				$pall = $Spotter->getLast7DaysAirportsArrival('',$filter);
1976
-    				$dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter);
1976
+					$dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter);
1977 1977
 				foreach ($dall as $value) {
1978 1978
 					$icao = $value['arrival_airport_icao'];
1979 1979
 					$ddate = $value['date'];
1980
-    					$find = false;
1980
+						$find = false;
1981 1981
 					foreach ($pall as $pvalue) {
1982
-    						if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1983
-    							$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1984
-    							$find = true;
1985
-    							break;
1986
-	    					}
1987
-    					}
1988
-    					if ($find === false) {
1989
-    						$pall[] = $value;
1990
-	    				}
1991
-    				}
1992
-    				$alldata = $pall;
1982
+							if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1983
+								$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1984
+								$find = true;
1985
+								break;
1986
+							}
1987
+						}
1988
+						if ($find === false) {
1989
+							$pall[] = $value;
1990
+						}
1991
+					}
1992
+					$alldata = $pall;
1993 1993
 				foreach ($alldata as $number) {
1994 1994
 					$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);
1995 1995
 				}
Please login to merge, or discard this patch.