Completed
Push — master ( 79cbb4...2c41c0 )
by Yannick
30:50
created
require/class.AIS.php 1 patch
Braces   +176 added lines, -65 removed lines patch added patch discarded remove patch
@@ -123,7 +123,9 @@  discard block
 block discarded – undo
123 123
 			$temp += 1;
124 124
 			$flat = (float)($temp / (60.0 * 10000.0));
125 125
 			$flat *= -1.0;
126
-		} else $flat = (float)($temp / (60.0 * 10000.0));
126
+		} else {
127
+			$flat = (float)($temp / (60.0 * 10000.0));
128
+		}
127 129
 		return $flat; // float
128 130
 	}
129 131
 
@@ -135,7 +137,9 @@  discard block
 block discarded – undo
135 137
 			$temp += 1;
136 138
 			$flon = (float)($temp / (60.0 * 10000.0));
137 139
 			$flon *= -1.0;
138
-		} else $flon = (float)($temp / (60.0 * 10000.0));
140
+		} else {
141
+			$flon = (float)($temp / (60.0 * 10000.0));
142
+		}
139 143
 		return $flon;
140 144
 	}
141 145
 
@@ -158,10 +162,8 @@  discard block
 block discarded – undo
158 162
     */
159 163
 	private function asciidec_2_8bit($ascii) {
160 164
 		//only process in the following range: 48-87, 96-119
161
-		if ($ascii < 48) { }
162
-		else {
163
-			if($ascii>119) { }
164
-			else {
165
+		if ($ascii < 48) { } else {
166
+			if($ascii>119) { } else {
165 167
 				if ($ascii>87 && $ascii<96) ;
166 168
 				else {
167 169
 					$ascii=$ascii+40;
@@ -263,7 +265,9 @@  discard block
 block discarded – undo
263 265
 			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,57,28)));
264 266
 			$ro->lat = $this->make_latf(bindec(substr($_aisdata,85,27)));
265 267
 			$ro->heading = bindec(substr($_aisdata,124,9));
266
-			if ($ro->heading == 511) $ro->heading = '';
268
+			if ($ro->heading == 511) {
269
+				$ro->heading = '';
270
+			}
267 271
 			$ro->cls = 2; // class B
268 272
 		} else if ($ro->id == 19) {
269 273
 			$ro->cog = bindec(substr($_aisdata,112,12))/10;
@@ -273,7 +277,9 @@  discard block
 block discarded – undo
273 277
 			$ro->name = $this->binchar($_aisdata,143,120);
274 278
 			$ro->cls = 2; // class B
275 279
 			$ro->heading = bindec(substr($_aisdata,124,9));
276
-			if ($ro->heading == 511) $ro->heading = '';
280
+			if ($ro->heading == 511) {
281
+				$ro->heading = '';
282
+			}
277 283
 			$ro->typeid = bindec(substr($_aisdata,263,8));
278 284
 			$ro->type = $this->getShipType($ro->typeid);
279 285
 			//$ro->to_bow = bindec(substr($_aisdata,271,9));
@@ -304,9 +310,13 @@  discard block
 block discarded – undo
304 310
 			$ro->cls = 2; // class B
305 311
 		} else if ($ro->id == 27) {
306 312
 			$ro->cog = bindec(substr($_aisdata,85,9));
307
-			if ($ro->cog == 511) $ro->cog = 0.0;
313
+			if ($ro->cog == 511) {
314
+				$ro->cog = 0.0;
315
+			}
308 316
 			$ro->sog = bindec(substr($_aisdata,79,6));
309
-			if ($ro->sog == 63) $ro->sog = 0.0;
317
+			if ($ro->sog == 63) {
318
+				$ro->sog = 0.0;
319
+			}
310 320
 			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,44,18))*10);
311 321
 			$ro->lat = $this->make_latf(bindec(substr($_aisdata,62,17))*10);
312 322
 			$ro->cls = 1; // class A
@@ -354,14 +364,20 @@  discard block
 block discarded – undo
354 364
 	}
355 365
 	
356 366
 	public function getShipType($code) {
357
-		if (isset($this->shiptype[$code])) return $this->shiptype[$code];
358
-		else return '';
367
+		if (isset($this->shiptype[$code])) {
368
+			return $this->shiptype[$code];
369
+		} else {
370
+			return '';
371
+		}
359 372
 	}
360 373
 
361 374
 	public function getShipTypeID($type) {
362 375
 		$typeid = array_search($type,$this->shiptype);
363
-		if ($typeid !== FALSE) return $typeid;
364
-		else return '';
376
+		if ($typeid !== FALSE) {
377
+			return $typeid;
378
+		} else {
379
+			return '';
380
+		}
365 381
 	}
366 382
 
367 383
 	public function process_ais_itu($_itu, $_len, $_filler, $aux /*, $ais_ch*/) {
@@ -398,11 +414,20 @@  discard block
 block discarded – undo
398 414
 		// assume 1st ! is valid
399 415
 		// find * ensure that it is at correct position
400 416
 		$end = strrpos ( $rawdata , '*' );
401
-		if ($end === FALSE) return -1; // check for NULLS!!!
417
+		if ($end === FALSE) {
418
+			return -1;
419
+		}
420
+		// check for NULLS!!!
402 421
 		$cs = substr( $rawdata, $end + 1 );
403
-		if ( strlen($cs) != 2 ) return -1; // correct cs length
422
+		if ( strlen($cs) != 2 ) {
423
+			return -1;
424
+		}
425
+		// correct cs length
404 426
 		$dcs = (int)hexdec( $cs );
405
-		for ( $alias=1; $alias<$end; $alias++) $chksum ^= ord( $rawdata[$alias] ); // perform XOR for NMEA checksum
427
+		for ( $alias=1; $alias<$end; $alias++) {
428
+			$chksum ^= ord( $rawdata[$alias] );
429
+		}
430
+		// perform XOR for NMEA checksum
406 431
 		if ( $chksum == $dcs ) { // NMEA checksum pass
407 432
 			$pcs = explode(',', $rawdata);
408 433
 			// !AI??? identifier
@@ -413,8 +438,14 @@  discard block
 block discarded – undo
413 438
 			$num_seq = (int)$pcs[1]; // number of sequences
414 439
 			$seq = (int)$pcs[2]; // get sequence
415 440
 			// get msg sequence id
416
-			if ($pcs[3] == '') $msg_sid = -1; // non-multipart message, set to -1
417
-			else $msg_sid = (int)$pcs[3]; // multipart message
441
+			if ($pcs[3] == '') {
442
+				$msg_sid = -1;
443
+			}
444
+			// non-multipart message, set to -1
445
+			else {
446
+				$msg_sid = (int)$pcs[3];
447
+			}
448
+			// multipart message
418 449
 			$ais_ch = $pcs[4]; // get AIS channel
419 450
 			// message sequence checking
420 451
 			if ($num_seq < 1 || $num_seq > 9) {
@@ -477,10 +508,18 @@  discard block
 block discarded – undo
477 508
 				//DEBUG echo "[$start $end $tst]\n";
478 509
 				$result = $this->process_ais_raw( $tst, "" );
479 510
 				$last_pos = $end + 1;
480
-			} else break;
511
+			} else {
512
+				break;
513
+			}
514
+		}
515
+		if ($last_pos > 0) {
516
+			$cbuf = substr($cbuf, $last_pos);
481 517
 		}
482
-		if ($last_pos > 0) $cbuf = substr($cbuf, $last_pos); // move...
483
-		if (strlen($cbuf) > 1024) $cbuf = ""; // prevent overflow simple mode...
518
+		// move...
519
+		if (strlen($cbuf) > 1024) {
520
+			$cbuf = "";
521
+		}
522
+		// prevent overflow simple mode...
484 523
 		return $result;
485 524
 	}
486 525
 
@@ -500,7 +539,9 @@  discard block
 block discarded – undo
500 539
 		if ($lat<0.0) {
501 540
 			$lat = -$lat;
502 541
 			$neg=true;
503
-		} else $neg=false;
542
+		} else {
543
+			$neg=false;
544
+		}
504 545
 		$latd = 0x00000000;
505 546
 		$latd = intval ($lat * 600000.0);
506 547
 		if ($neg==true) {
@@ -516,7 +557,9 @@  discard block
 block discarded – undo
516 557
 		if ($lon<0.0) {
517 558
 			$lon = -$lon;
518 559
 			$neg=true;
519
-		} else $neg=false;
560
+		} else {
561
+			$neg=false;
562
+		}
520 563
 		$lond = 0x00000000;
521 564
 		$lond = intval ($lon * 600000.0);
522 565
 		if ($neg==true) {
@@ -529,9 +572,14 @@  discard block
 block discarded – undo
529 572
 
530 573
 	private function char2bin($name, $max_len) {
531 574
 		$len = strlen($name);
532
-		if ($len > $max_len) $name = substr($name,0,$max_len);
533
-		if ($len < $max_len) $pad = str_repeat('0', ($max_len - $len) * 6);
534
-		else $pad = '';
575
+		if ($len > $max_len) {
576
+			$name = substr($name,0,$max_len);
577
+		}
578
+		if ($len < $max_len) {
579
+			$pad = str_repeat('0', ($max_len - $len) * 6);
580
+		} else {
581
+			$pad = '';
582
+		}
535 583
 		$rv = '';
536 584
 		$ais_chars = array(
537 585
 		    '@'=>0, 'A'=>1, 'B'=>2, 'C'=>3, 'D'=>4, 'E'=>5, 'F'=>6, 'G'=>7, 'H'=>8, 'I'=>9,
@@ -544,9 +592,12 @@  discard block
 block discarded – undo
544 592
 		);
545 593
 		// "
546 594
 		$_a = str_split($name);
547
-		if ($_a) foreach ($_a as $_1) {
595
+		if ($_a) {
596
+			foreach ($_a as $_1) {
548 597
 			if (isset($ais_chars[$_1])) $dec = $ais_chars[$_1];
549
-			else $dec = 0;
598
+		} else {
599
+				$dec = 0;
600
+			}
550 601
 			$bin = str_pad(decbin( $dec ), 6, '0', STR_PAD_LEFT);
551 602
 			$rv .= $bin;
552 603
 			//echo "$_1 $dec ($bin)<br/>";
@@ -558,7 +609,9 @@  discard block
 block discarded – undo
558 609
 		$len_bit = strlen($_enc);
559 610
 		$rem6 = $len_bit % 6;
560 611
 		$pad6_len = 0;
561
-		if ($rem6) $pad6_len = 6 - $rem6;
612
+		if ($rem6) {
613
+			$pad6_len = 6 - $rem6;
614
+		}
562 615
 		//echo  $pad6_len.'<br>';
563 616
 		$_enc .= str_repeat("0", $pad6_len); // pad the text...
564 617
 		$len_enc = strlen($_enc) / 6;
@@ -567,8 +620,11 @@  discard block
 block discarded – undo
567 620
 		for ($i=0; $i<$len_enc; $i++) {
568 621
 			$offset = $i * 6;
569 622
 			$dec = bindec(substr($_enc,$offset,6));
570
-			if ($dec < 40) $dec += 48;
571
-			else $dec += 56;
623
+			if ($dec < 40) {
624
+				$dec += 48;
625
+			} else {
626
+				$dec += 56;
627
+			}
572 628
 			//echo chr($dec)." $dec<br/>";
573 629
 			$itu .= chr($dec);
574 630
 		}
@@ -581,26 +637,42 @@  discard block
 block discarded – undo
581 637
 		}
582 638
 		$hex_arr = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
583 639
 		$lsb = $chksum & 0x0F;
584
-		if ($lsb >=0 && $lsb <= 15 ) $lsbc = $hex_arr[$lsb];
585
-		else $lsbc = '0';
640
+		if ($lsb >=0 && $lsb <= 15 ) {
641
+			$lsbc = $hex_arr[$lsb];
642
+		} else {
643
+			$lsbc = '0';
644
+		}
586 645
 		$msb = (($chksum & 0xF0) >> 4) & 0x0F;
587
-		if ($msb >=0 && $msb <= 15 ) $msbc = $hex_arr[$msb];
588
-		else $msbc = '0';
646
+		if ($msb >=0 && $msb <= 15 ) {
647
+			$msbc = $hex_arr[$msb];
648
+		} else {
649
+			$msbc = '0';
650
+		}
589 651
 		$itu = '!'.$itu."*{$msbc}{$lsbc}\r\n";
590 652
 		return $itu;
591 653
 	}
592 654
 
593 655
 	public function parse($buffer) {
594 656
 		$data = $this->process_ais_buf($buffer);
595
-		if (!is_object($data)) return array();
657
+		if (!is_object($data)) {
658
+			return array();
659
+		}
596 660
 		$result = array();
597
-		if ($data->lon != 0) $result['longitude'] = $data->lon;
598
-		if ($data->lat != 0) $result['latitude'] = $data->lat;
661
+		if ($data->lon != 0) {
662
+			$result['longitude'] = $data->lon;
663
+		}
664
+		if ($data->lat != 0) {
665
+			$result['latitude'] = $data->lat;
666
+		}
599 667
 		$result['ident'] = trim($data->name);
600 668
 		$result['timestamp'] = $data->ts;
601 669
 		$result['mmsi'] = $data->mmsi;
602
-		if ($data->sog != -1.0) $result['speed'] = $data->sog;
603
-		if ($data->cog != 0) $result['heading'] = $data->cog;
670
+		if ($data->sog != -1.0) {
671
+			$result['speed'] = $data->sog;
672
+		}
673
+		if ($data->cog != 0) {
674
+			$result['heading'] = $data->cog;
675
+		}
604 676
 		/*
605 677
 		    $ro->cls = 0; // AIS class undefined, also indicate unparsed msg
606 678
 		    $ro->id = bindec(substr($_aisdata,0,6));
@@ -610,15 +682,25 @@  discard block
 block discarded – undo
610 682
 
611 683
 	public function mmsitype($mmsi) {
612 684
 		if (strlen($mmsi) == 9) {
613
-			if (substr($mmsi,0,3) == '974') return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS';
614
-			elseif (substr($mmsi,0,3) == '972') return 'MOB (Man Overboard) device';
615
-			elseif (substr($mmsi,0,3) == '970') return 'AIS SART (Search and Rescue Transmitter)';
616
-			elseif (substr($mmsi,0,3) == '111') return 'SAR (Search and Rescue) aircraft';
617
-			elseif (substr($mmsi,0,2) == '98') return 'Auxiliary craft associated with a parent ship';
618
-			elseif (substr($mmsi,0,2) == '99') return 'Aids to Navigation';
619
-			elseif (substr($mmsi,0,2) == '00') return 'Coastal stations';
620
-			elseif (substr($mmsi,0,1) == '0') return 'Group of ships';
621
-			else return 'Ship';
685
+			if (substr($mmsi,0,3) == '974') {
686
+				return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS';
687
+			} elseif (substr($mmsi,0,3) == '972') {
688
+				return 'MOB (Man Overboard) device';
689
+			} elseif (substr($mmsi,0,3) == '970') {
690
+				return 'AIS SART (Search and Rescue Transmitter)';
691
+			} elseif (substr($mmsi,0,3) == '111') {
692
+				return 'SAR (Search and Rescue) aircraft';
693
+			} elseif (substr($mmsi,0,2) == '98') {
694
+				return 'Auxiliary craft associated with a parent ship';
695
+			} elseif (substr($mmsi,0,2) == '99') {
696
+				return 'Aids to Navigation';
697
+			} elseif (substr($mmsi,0,2) == '00') {
698
+				return 'Coastal stations';
699
+			} elseif (substr($mmsi,0,1) == '0') {
700
+				return 'Group of ships';
701
+			} else {
702
+				return 'Ship';
703
+			}
622 704
 		}
623 705
 
624 706
 	
@@ -634,32 +716,61 @@  discard block
 block discarded – undo
634 716
 			//if ($globalDebug) echo '==== Line format not supported : '.$buffer."\n";
635 717
 			return array();
636 718
 		}
637
-		if ($data->lon != 0) $result['longitude'] = $data->lon;
638
-		if ($data->lat != 0) $result['latitude'] = $data->lat;
719
+		if ($data->lon != 0) {
720
+			$result['longitude'] = $data->lon;
721
+		}
722
+		if ($data->lat != 0) {
723
+			$result['latitude'] = $data->lat;
724
+		}
639 725
 		$result['ident'] = trim(str_replace('@','',$data->name));
640 726
 		$result['timestamp'] = $data->ts;
641 727
 		$result['mmsi'] = $data->mmsi;
642
-		if (strlen($result['mmsi']) == 8 && substr($result['mmsi'],0,3) == '669') $result['mmsi'] = '3'.$result['mmsi'];
728
+		if (strlen($result['mmsi']) == 8 && substr($result['mmsi'],0,3) == '669') {
729
+			$result['mmsi'] = '3'.$result['mmsi'];
730
+		}
643 731
 		$result['mmsi_type'] = $this->mmsitype($result['mmsi']);
644
-		if ($data->sog != -1.0) $result['speed'] = $data->sog;
645
-		if ($data->heading !== '') $result['heading'] = $data->heading;
646
-		elseif ($data->cog != 0) $result['heading'] = $data->cog;
647
-		if ($data->status != '') $result['status'] = $data->status;
648
-		if ($data->statusid !== '') $result['statusid'] = $data->statusid;
649
-		if ($data->type !== '') $result['type'] = $data->type;
650
-		if ($data->typeid !== '') $result['typeid'] = $data->typeid;
651
-		if ($data->imo !== '') $result['imo'] = $data->imo;
652
-		if ($data->callsign !== '') $result['callsign'] = trim(str_replace('@','',$data->callsign));
732
+		if ($data->sog != -1.0) {
733
+			$result['speed'] = $data->sog;
734
+		}
735
+		if ($data->heading !== '') {
736
+			$result['heading'] = $data->heading;
737
+		} elseif ($data->cog != 0) {
738
+			$result['heading'] = $data->cog;
739
+		}
740
+		if ($data->status != '') {
741
+			$result['status'] = $data->status;
742
+		}
743
+		if ($data->statusid !== '') {
744
+			$result['statusid'] = $data->statusid;
745
+		}
746
+		if ($data->type !== '') {
747
+			$result['type'] = $data->type;
748
+		}
749
+		if ($data->typeid !== '') {
750
+			$result['typeid'] = $data->typeid;
751
+		}
752
+		if ($data->imo !== '') {
753
+			$result['imo'] = $data->imo;
754
+		}
755
+		if ($data->callsign !== '') {
756
+			$result['callsign'] = trim(str_replace('@','',$data->callsign));
757
+		}
653 758
 		if (is_numeric($data->eta_month) && $data->eta_month != 0 && is_numeric($data->eta_day) && $data->eta_day != 0 && $data->eta_hour !== '' && $data->eta_minute !== '') {
654 759
 			$eta_ts = strtotime(date('Y').'-'.sprintf("%02d",$data->eta_month).'-'.sprintf("%02d",$data->eta_day).' '.sprintf("%02d",$data->eta_hour).':'.sprintf("%02d",$data->eta_minute).':00');
655
-			if ($eta_ts != '') $result['eta_ts'] = $eta_ts;
760
+			if ($eta_ts != '') {
761
+				$result['eta_ts'] = $eta_ts;
762
+			}
656 763
 		} elseif (is_numeric($data->eta_hour) && is_numeric($data->eta_minute)) {
657 764
 			$eta_ts = strtotime(date('Y-m-d').' '.sprintf("%02d",$data->eta_hour).':'.sprintf("%02d",$data->eta_minute).':00');
658
-			if ($eta_ts != '') $result['eta_ts'] = $eta_ts;
765
+			if ($eta_ts != '') {
766
+				$result['eta_ts'] = $eta_ts;
767
+			}
659 768
 		}
660 769
 		if ($data->destination != '') {
661 770
 			$dest = trim(str_replace('@','',$data->destination));
662
-			if ($dest != '') $result['destination'] = $dest;
771
+			if ($dest != '') {
772
+				$result['destination'] = $dest;
773
+			}
663 774
 		}
664 775
 		$result['all'] = (array) $data;
665 776
 		/*
Please login to merge, or discard this patch.
require/class.Stats.php 1 patch
Braces   +715 added lines, -250 removed lines patch added patch discarded remove patch
@@ -15,10 +15,14 @@  discard block
 block discarded – undo
15 15
 	
16 16
 	public function __construct($dbc = null) {
17 17
 		global $globalFilterName;
18
-		if (isset($globalFilterName)) $this->filter_name = $globalFilterName;
18
+		if (isset($globalFilterName)) {
19
+			$this->filter_name = $globalFilterName;
20
+		}
19 21
 		$Connection = new Connection($dbc);
20 22
 		$this->db = $Connection->db();
21
-		if ($this->db === null) die('Error: No DB connection. (Stats)');
23
+		if ($this->db === null) {
24
+			die('Error: No DB connection. (Stats)');
25
+		}
22 26
 	}
23 27
 
24 28
 	public function addLastStatsUpdate($type,$stats_date) {
@@ -86,7 +90,9 @@  discard block
 block discarded – undo
86 90
 
87 91
 	public function getAllAirlineNames($filter_name = '') {
88 92
 		global $globalStatsFilters;
89
-		if ($filter_name == '') $filter_name = $this->filter_name;
93
+		if ($filter_name == '') {
94
+			$filter_name = $this->filter_name;
95
+		}
90 96
 		$query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC";
91 97
 		 try {
92 98
 			$sth = $this->db->prepare($query);
@@ -106,7 +112,9 @@  discard block
 block discarded – undo
106 112
 		return $all;
107 113
 	}
108 114
 	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
109
-		if ($filter_name == '') $filter_name = $this->filter_name;
115
+		if ($filter_name == '') {
116
+			$filter_name = $this->filter_name;
117
+		}
110 118
 		$query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
111 119
 		try {
112 120
 			$sth = $this->db->prepare($query);
@@ -118,7 +126,9 @@  discard block
 block discarded – undo
118 126
 		return $all;
119 127
 	}
120 128
 	public function getAllManufacturers($stats_airline = '',$filter_name = '') {
121
-		if ($filter_name == '') $filter_name = $this->filter_name;
129
+		if ($filter_name == '') {
130
+			$filter_name = $this->filter_name;
131
+		}
122 132
 		$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";
123 133
 		try {
124 134
 			$sth = $this->db->prepare($query);
@@ -130,7 +140,9 @@  discard block
 block discarded – undo
130 140
 		return $all;
131 141
 	}
132 142
 	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
133
-		if ($filter_name == '') $filter_name = $this->filter_name;
143
+		if ($filter_name == '') {
144
+			$filter_name = $this->filter_name;
145
+		}
134 146
 		$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";
135 147
 		try {
136 148
 			$sth = $this->db->prepare($query);
@@ -143,7 +155,9 @@  discard block
 block discarded – undo
143 155
 	}
144 156
 
145 157
 	public function getAllOwnerNames($stats_airline = '',$filter_name = '') {
146
-		if ($filter_name == '') $filter_name = $this->filter_name;
158
+		if ($filter_name == '') {
159
+			$filter_name = $this->filter_name;
160
+		}
147 161
 		$query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC";
148 162
 		try {
149 163
 			$sth = $this->db->prepare($query);
@@ -156,7 +170,9 @@  discard block
 block discarded – undo
156 170
 	}
157 171
 
158 172
 	public function getAllPilotNames($stats_airline = '',$filter_name = '') {
159
-		if ($filter_name == '') $filter_name = $this->filter_name;
173
+		if ($filter_name == '') {
174
+			$filter_name = $this->filter_name;
175
+		}
160 176
 		$query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC";
161 177
 		try {
162 178
 			$sth = $this->db->prepare($query);
@@ -171,7 +187,9 @@  discard block
 block discarded – undo
171 187
 
172 188
 	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
173 189
 		global $globalStatsFilters;
174
-		if ($filter_name == '') $filter_name = $this->filter_name;
190
+		if ($filter_name == '') {
191
+			$filter_name = $this->filter_name;
192
+		}
175 193
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
176 194
 			$Spotter = new Spotter($this->db);
177 195
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -180,8 +198,11 @@  discard block
 block discarded – undo
180 198
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
181 199
 			}
182 200
 			if ($year == '' && $month == '') {
183
-				if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
184
-				else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> ''  AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
201
+				if ($limit) {
202
+					$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
203
+				} else {
204
+					$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> ''  AND aircraft_icao <> 'NA' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
205
+				}
185 206
 				try {
186 207
 					$sth = $this->db->prepare($query);
187 208
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -189,11 +210,16 @@  discard block
 block discarded – undo
189 210
 					echo "error : ".$e->getMessage();
190 211
 				}
191 212
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
192
-			} else $all = array();
213
+			} else {
214
+				$all = array();
215
+			}
193 216
 		} else {
194 217
 			if ($year == '' && $month == '') {
195
-				if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
196
-				else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
218
+				if ($limit) {
219
+					$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
220
+				} else {
221
+					$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND aircraft_icao <> 'NA' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
222
+				}
197 223
 				try {
198 224
 					$sth = $this->db->prepare($query);
199 225
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -201,7 +227,9 @@  discard block
 block discarded – undo
201 227
 					echo "error : ".$e->getMessage();
202 228
 				}
203 229
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
204
-			} else $all = array();
230
+			} else {
231
+				$all = array();
232
+			}
205 233
 		}
206 234
 		if (empty($all)) {
207 235
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -220,10 +248,15 @@  discard block
 block discarded – undo
220 248
 	}
221 249
 	public function countAllMarineTypes($limit = true, $filter_name = '',$year = '', $month = '') {
222 250
 		global $globalStatsFilters;
223
-		if ($filter_name == '') $filter_name = $this->filter_name;
251
+		if ($filter_name == '') {
252
+			$filter_name = $this->filter_name;
253
+		}
224 254
 		if ($year == '' && $month == '') {
225
-			if ($limit) $query = "SELECT type AS marine_type, cnt AS marine_type_count, type_id AS marine_type_id FROM stats_marine_type WHERE filter_name = :filter_name ORDER BY marine_type_count DESC LIMIT 10 OFFSET 0";
226
-			else $query = "SELECT type AS marine_type, cnt AS marine_type_count, type_id AS marine_type_id FROM stats_marine_type WHERE filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
255
+			if ($limit) {
256
+				$query = "SELECT type AS marine_type, cnt AS marine_type_count, type_id AS marine_type_id FROM stats_marine_type WHERE filter_name = :filter_name ORDER BY marine_type_count DESC LIMIT 10 OFFSET 0";
257
+			} else {
258
+				$query = "SELECT type AS marine_type, cnt AS marine_type_count, type_id AS marine_type_id FROM stats_marine_type WHERE filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
259
+			}
227 260
 			try {
228 261
 				$sth = $this->db->prepare($query);
229 262
 				$sth->execute(array(':filter_name' => $filter_name));
@@ -231,7 +264,9 @@  discard block
 block discarded – undo
231 264
 				echo "error : ".$e->getMessage();
232 265
 			}
233 266
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
234
-		} else $all = array();
267
+		} else {
268
+			$all = array();
269
+		}
235 270
 		if (empty($all)) {
236 271
 			$filters = array('year' => $year,'month' => $month);
237 272
 			if ($filter_name != '') {
@@ -245,10 +280,15 @@  discard block
 block discarded – undo
245 280
 	}
246 281
 	public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') {
247 282
 		global $globalStatsFilters;
248
-		if ($filter_name == '') $filter_name = $this->filter_name;
283
+		if ($filter_name == '') {
284
+			$filter_name = $this->filter_name;
285
+		}
249 286
 		if ($year == '' && $month == '') {
250
-			if ($limit) $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0";
251
-			else $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC";
287
+			if ($limit) {
288
+				$query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0";
289
+			} else {
290
+				$query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC";
291
+			}
252 292
 			try {
253 293
 				$sth = $this->db->prepare($query);
254 294
 				$sth->execute(array(':filter_name' => $filter_name));
@@ -256,7 +296,9 @@  discard block
 block discarded – undo
256 296
 				echo "error : ".$e->getMessage();
257 297
 			}
258 298
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
259
-		} else $all = array();
299
+		} else {
300
+			$all = array();
301
+		}
260 302
 		if (empty($all)) {
261 303
 			$Spotter = new Spotter($this->db);
262 304
 			$filters = array();
@@ -271,7 +313,9 @@  discard block
 block discarded – undo
271 313
 	}
272 314
 	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') {
273 315
 		global $globalStatsFilters;
274
-		if ($filter_name == '') $filter_name = $this->filter_name;
316
+		if ($filter_name == '') {
317
+			$filter_name = $this->filter_name;
318
+		}
275 319
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
276 320
 			$Spotter = new Spotter($this->db);
277 321
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -280,8 +324,11 @@  discard block
 block discarded – undo
280 324
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
281 325
 			}
282 326
 			if ($year == '' && $month == '') {
283
-				if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
284
-				else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
327
+				if ($limit) {
328
+					$query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
329
+				} else {
330
+					$query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
331
+				}
285 332
 				try {
286 333
 					$sth = $this->db->prepare($query);
287 334
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -289,11 +336,16 @@  discard block
 block discarded – undo
289 336
 					echo "error : ".$e->getMessage();
290 337
 				}
291 338
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
292
-			} else $all = array();
339
+			} else {
340
+				$all = array();
341
+			}
293 342
 		} else {
294 343
 			if ($year == '' && $month == '') {
295
-				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";
296
-				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";
344
+				if ($limit) {
345
+					$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";
346
+				} else {
347
+					$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";
348
+				}
297 349
 				try {
298 350
 					$sth = $this->db->prepare($query);
299 351
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -301,7 +353,9 @@  discard block
 block discarded – undo
301 353
 					echo "error : ".$e->getMessage();
302 354
 				}
303 355
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
304
-			} else $all = array();
356
+			} else {
357
+				$all = array();
358
+			}
305 359
 		}
306 360
 		if (empty($all)) {
307 361
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -321,7 +375,9 @@  discard block
 block discarded – undo
321 375
 
322 376
 	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
323 377
 		global $globalStatsFilters;
324
-		if ($filter_name == '') $filter_name = $this->filter_name;
378
+		if ($filter_name == '') {
379
+			$filter_name = $this->filter_name;
380
+		}
325 381
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
326 382
 			$Spotter = new Spotter($this->db);
327 383
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -330,8 +386,11 @@  discard block
 block discarded – undo
330 386
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
331 387
 			}
332 388
 			if ($year == '' && $month == '') {
333
-				if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
334
-				else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC";
389
+				if ($limit) {
390
+					$query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
391
+				} else {
392
+					$query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC";
393
+				}
335 394
 				try {
336 395
 					$sth = $this->db->prepare($query);
337 396
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -339,11 +398,16 @@  discard block
 block discarded – undo
339 398
 					echo "error : ".$e->getMessage();
340 399
 				}
341 400
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
342
-			} else $all = array();
401
+			} else {
402
+				$all = array();
403
+			}
343 404
 		} else {
344 405
 			if ($year == '' && $month == '') {
345
-				if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
346
-				else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC";
406
+				if ($limit) {
407
+					$query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
408
+				} else {
409
+					$query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC";
410
+				}
347 411
 				try {
348 412
 					$sth = $this->db->prepare($query);
349 413
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -351,7 +415,9 @@  discard block
 block discarded – undo
351 415
 					echo "error : ".$e->getMessage();
352 416
 				}
353 417
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
354
-			} else $all = array();
418
+			} else {
419
+				$all = array();
420
+			}
355 421
 		}
356 422
 		if (empty($all)) {
357 423
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -370,7 +436,9 @@  discard block
 block discarded – undo
370 436
 	}
371 437
 	public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
372 438
 		global $globalStatsFilters;
373
-		if ($filter_name == '') $filter_name = $this->filter_name;
439
+		if ($filter_name == '') {
440
+			$filter_name = $this->filter_name;
441
+		}
374 442
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
375 443
 			$Spotter = new Spotter($this->db);
376 444
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -378,12 +446,18 @@  discard block
 block discarded – undo
378 446
 			foreach ($airlines as $airline) {
379 447
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
380 448
 			}
381
-			if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
382
-			else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC";
449
+			if ($limit) {
450
+				$query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
451
+			} else {
452
+				$query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC";
453
+			}
383 454
 			$query_values = array(':filter_name' => $filter_name);
384 455
 		} else {
385
-			if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
386
-			else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC";
456
+			if ($limit) {
457
+				$query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
458
+			} else {
459
+				$query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC";
460
+			}
387 461
 			$query_values = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
388 462
 		}
389 463
 		try {
@@ -411,17 +485,29 @@  discard block
 block discarded – undo
411 485
 
412 486
 	public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') {
413 487
 		global $globalStatsFilters, $globalVATSIM, $globalIVAO;
414
-		if ($filter_name == '') $filter_name = $this->filter_name;
488
+		if ($filter_name == '') {
489
+			$filter_name = $this->filter_name;
490
+		}
415 491
 		if ($year == '' && $month == '') {
416
-			if ($globalVATSIM) $forsource = 'vatsim';
417
-			if ($globalIVAO) $forsource = 'ivao';
492
+			if ($globalVATSIM) {
493
+				$forsource = 'vatsim';
494
+			}
495
+			if ($globalIVAO) {
496
+				$forsource = 'ivao';
497
+			}
418 498
 			if (isset($forsource)) {
419
-				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 AND airlines.forsource = :forsource ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
420
-				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 AND airlines.forsource = :forsource ORDER BY airline_count DESC";
499
+				if ($limit) {
500
+					$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 AND airlines.forsource = :forsource ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
501
+				} else {
502
+					$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 AND airlines.forsource = :forsource ORDER BY airline_count DESC";
503
+				}
421 504
 				$query_values = array(':filter_name' => $filter_name,':forsource' => $forsource);
422 505
 			} else {
423
-				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 AND airlines.forsource IS NULL ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
424
-				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 AND airlines.forsource IS NULL ORDER BY airline_count DESC";
506
+				if ($limit) {
507
+					$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 AND airlines.forsource IS NULL ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
508
+				} else {
509
+					$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 AND airlines.forsource IS NULL ORDER BY airline_count DESC";
510
+				}
425 511
 				$query_values = array(':filter_name' => $filter_name);
426 512
 			}
427 513
 			try {
@@ -431,7 +517,9 @@  discard block
 block discarded – undo
431 517
 				echo "error : ".$e->getMessage();
432 518
 			}
433 519
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
434
-		} else $all = array();
520
+		} else {
521
+			$all = array();
522
+		}
435 523
                 if (empty($all)) {
436 524
 	                $Spotter = new Spotter($this->db);
437 525
             		$filters = array();
@@ -446,7 +534,9 @@  discard block
 block discarded – undo
446 534
 	}
447 535
 	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
448 536
 		global $globalStatsFilters;
449
-		if ($filter_name == '') $filter_name = $this->filter_name;
537
+		if ($filter_name == '') {
538
+			$filter_name = $this->filter_name;
539
+		}
450 540
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
451 541
 			$Spotter = new Spotter($this->db);
452 542
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -455,8 +545,11 @@  discard block
 block discarded – undo
455 545
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
456 546
 			}
457 547
 			if ($year == '' && $month == '') {
458
-				if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS 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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY registration_count DESC LIMIT 10 OFFSET 0";
459
-				else $query = "SELECT s.aircraft_icao, s.cnt AS 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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY registration_count DESC";
548
+				if ($limit) {
549
+					$query = "SELECT s.aircraft_icao, s.cnt AS 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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY registration_count DESC LIMIT 10 OFFSET 0";
550
+				} else {
551
+					$query = "SELECT s.aircraft_icao, s.cnt AS 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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY registration_count DESC";
552
+				}
460 553
 				try {
461 554
 					$sth = $this->db->prepare($query);
462 555
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -464,11 +557,16 @@  discard block
 block discarded – undo
464 557
 					echo "error : ".$e->getMessage();
465 558
 				}
466 559
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
467
-			} else $all = array();
560
+			} else {
561
+				$all = array();
562
+			}
468 563
 		} else {
469 564
 			if ($year == '' && $month == '') {
470
-				if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS 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 registration_count DESC LIMIT 10 OFFSET 0";
471
-				else $query = "SELECT s.aircraft_icao, s.cnt AS 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 registration_count DESC";
565
+				if ($limit) {
566
+					$query = "SELECT s.aircraft_icao, s.cnt AS 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 registration_count DESC LIMIT 10 OFFSET 0";
567
+				} else {
568
+					$query = "SELECT s.aircraft_icao, s.cnt AS 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 registration_count DESC";
569
+				}
472 570
 				try {
473 571
 					$sth = $this->db->prepare($query);
474 572
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -476,7 +574,9 @@  discard block
 block discarded – undo
476 574
 					echo "error : ".$e->getMessage();
477 575
 				}
478 576
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
479
-			} else $all = array();
577
+			} else {
578
+				$all = array();
579
+			}
480 580
 		}
481 581
 		if (empty($all)) {
482 582
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -495,7 +595,9 @@  discard block
 block discarded – undo
495 595
 	}
496 596
 	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
497 597
 		global $globalStatsFilters;
498
-		if ($filter_name == '') $filter_name = $this->filter_name;
598
+		if ($filter_name == '') {
599
+			$filter_name = $this->filter_name;
600
+		}
499 601
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
500 602
 			$Spotter = new Spotter($this->db);
501 603
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -504,8 +606,11 @@  discard block
 block discarded – undo
504 606
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
505 607
 			}
506 608
 			if ($year == '' && $month == '') {
507
-				if ($limit) $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
508
-				else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
609
+				if ($limit) {
610
+					$query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
611
+				} else {
612
+					$query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
613
+				}
509 614
 				 try {
510 615
 					$sth = $this->db->prepare($query);
511 616
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -513,11 +618,16 @@  discard block
 block discarded – undo
513 618
 					echo "error : ".$e->getMessage();
514 619
 				}
515 620
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
516
-			} else $all = array();
621
+			} else {
622
+				$all = array();
623
+			}
517 624
 		} else {
518 625
 			if ($year == '' && $month == '') {
519
-				if ($limit) $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
520
-				else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
626
+				if ($limit) {
627
+					$query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
628
+				} else {
629
+					$query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
630
+				}
521 631
 				 try {
522 632
 					$sth = $this->db->prepare($query);
523 633
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -525,7 +635,9 @@  discard block
 block discarded – undo
525 635
 					echo "error : ".$e->getMessage();
526 636
 				}
527 637
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
528
-			} else $all = array();
638
+			} else {
639
+				$all = array();
640
+			}
529 641
 		}
530 642
 		if (empty($all)) {
531 643
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -544,7 +656,9 @@  discard block
 block discarded – undo
544 656
 	}
545 657
 	public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') {
546 658
 		$Connection = new Connection($this->db);
547
-		if ($filter_name == '') $filter_name = $this->filter_name;
659
+		if ($filter_name == '') {
660
+			$filter_name = $this->filter_name;
661
+		}
548 662
 		if ($Connection->tableExists('countries')) {
549 663
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
550 664
 				$Spotter = new Spotter($this->db);
@@ -554,8 +668,11 @@  discard block
 block discarded – undo
554 668
 					foreach ($airlines as $airline) {
555 669
 						$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
556 670
 					}
557
-					if ($limit) $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0";
558
-					else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC";
671
+					if ($limit) {
672
+						$query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0";
673
+					} else {
674
+						$query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC";
675
+					}
559 676
 					 try {
560 677
 						$sth = $this->db->prepare($query);
561 678
 						$sth->execute(array(':filter_name' => $filter_name));
@@ -564,11 +681,16 @@  discard block
 block discarded – undo
564 681
 					}
565 682
 					$all = $sth->fetchAll(PDO::FETCH_ASSOC);
566 683
 					return $all;
567
-				} else return array();
684
+				} else {
685
+					return array();
686
+				}
568 687
 			} else {
569 688
 				if ($year == '' && $month == '') {
570
-					if ($limit) $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0";
571
-					else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC";
689
+					if ($limit) {
690
+						$query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0";
691
+					} else {
692
+						$query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC";
693
+					}
572 694
 					 try {
573 695
 						$sth = $this->db->prepare($query);
574 696
 						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -577,20 +699,29 @@  discard block
 block discarded – undo
577 699
 					}
578 700
 					$all = $sth->fetchAll(PDO::FETCH_ASSOC);
579 701
 					return $all;
580
-				} else return array();
702
+				} else {
703
+					return array();
704
+				}
581 705
 			}
582 706
 			$Spotter = new Spotter($this->db);
583 707
 			return $Spotter->countAllFlightOverCountries($limit);
584
-		} else return array();
708
+		} else {
709
+			return array();
710
+		}
585 711
 	}
586 712
 	public function countAllMarineOverCountries($limit = true, $filter_name = '',$year = '',$month = '') {
587 713
 		$Connection = new Connection($this->db);
588
-		if ($filter_name == '') $filter_name = $this->filter_name;
714
+		if ($filter_name == '') {
715
+			$filter_name = $this->filter_name;
716
+		}
589 717
 		if ($Connection->tableExists('countries')) {
590 718
 			$all = array();
591 719
 			if ($year == '' && $month == '') {
592
-				if ($limit) $query = "SELECT countries.iso3 as marine_country_iso3, countries.iso2 as marine_country_iso2, countries.name as marine_country, cnt as marine_count, lat as marine_country_latitude, lon as marine_country_longitude FROM stats_marine_country, countries WHERE stats_marine_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY marine_count DESC LIMIT 20 OFFSET 0";
593
-				else $query = "SELECT countries.iso3 as marine_country_iso3, countries.iso2 as marine_country_iso2, countries.name as marine_country, cnt as marine_count, lat as marine_country_latitude, lon as marine_country_longitude FROM stats_marine_country, countries WHERE stats_marine_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY marine_count DESC";
720
+				if ($limit) {
721
+					$query = "SELECT countries.iso3 as marine_country_iso3, countries.iso2 as marine_country_iso2, countries.name as marine_country, cnt as marine_count, lat as marine_country_latitude, lon as marine_country_longitude FROM stats_marine_country, countries WHERE stats_marine_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY marine_count DESC LIMIT 20 OFFSET 0";
722
+				} else {
723
+					$query = "SELECT countries.iso3 as marine_country_iso3, countries.iso2 as marine_country_iso2, countries.name as marine_country, cnt as marine_count, lat as marine_country_latitude, lon as marine_country_longitude FROM stats_marine_country, countries WHERE stats_marine_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY marine_count DESC";
724
+				}
594 725
 				 try {
595 726
 					$sth = $this->db->prepare($query);
596 727
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -608,16 +739,23 @@  discard block
 block discarded – undo
608 739
 				$all = $Marine->countAllMarineOverCountries($limit,0,'',$filters);
609 740
 			}
610 741
 			return $all;
611
-		} else return array();
742
+		} else {
743
+			return array();
744
+		}
612 745
 	}
613 746
 	public function countAllTrackerOverCountries($limit = true, $filter_name = '',$year = '',$month = '') {
614 747
 		$Connection = new Connection($this->db);
615
-		if ($filter_name == '') $filter_name = $this->filter_name;
748
+		if ($filter_name == '') {
749
+			$filter_name = $this->filter_name;
750
+		}
616 751
 		if ($Connection->tableExists('countries')) {
617 752
 			$all = array();
618 753
 			if ($year == '' && $month == '') {
619
-				if ($limit) $query = "SELECT countries.iso3 as tracker_country_iso3, countries.iso2 as tracker_country_iso2, countries.name as tracker_country, cnt as tracker_count, lat as tracker_country_latitude, lon as tracker_country_longitude FROM stats_tracker_country, countries WHERE stats_tracker_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY tracker_count DESC LIMIT 20 OFFSET 0";
620
-				else $query = "SELECT countries.iso3 as tracker_country_iso3, countries.iso2 as tracker_country_iso2, countries.name as tracker_country, cnt as tracker_count, lat as tracker_country_latitude, lon as tracker_country_longitude FROM stats_tracker_country, countries WHERE stats_tracker_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY tracker_count DESC";
754
+				if ($limit) {
755
+					$query = "SELECT countries.iso3 as tracker_country_iso3, countries.iso2 as tracker_country_iso2, countries.name as tracker_country, cnt as tracker_count, lat as tracker_country_latitude, lon as tracker_country_longitude FROM stats_tracker_country, countries WHERE stats_tracker_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY tracker_count DESC LIMIT 20 OFFSET 0";
756
+				} else {
757
+					$query = "SELECT countries.iso3 as tracker_country_iso3, countries.iso2 as tracker_country_iso2, countries.name as tracker_country, cnt as tracker_count, lat as tracker_country_latitude, lon as tracker_country_longitude FROM stats_tracker_country, countries WHERE stats_tracker_country.iso2 = countries.iso2 AND filter_name = :filter_name ORDER BY tracker_count DESC";
758
+				}
621 759
 				 try {
622 760
 					$sth = $this->db->prepare($query);
623 761
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -636,14 +774,21 @@  discard block
 block discarded – undo
636 774
 				$all = $Tracker->countAllTrackerOverCountries($limit,0,'',$filters);
637 775
 			}
638 776
 			return $all;
639
-		} else return array();
777
+		} else {
778
+			return array();
779
+		}
640 780
 	}
641 781
 	public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') {
642 782
 		global $globalStatsFilters;
643
-		if ($filter_name == '') $filter_name = $this->filter_name;
783
+		if ($filter_name == '') {
784
+			$filter_name = $this->filter_name;
785
+		}
644 786
 		if ($year == '' && $month == '') {
645
-			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";
646
-			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";
787
+			if ($limit) {
788
+				$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";
789
+			} else {
790
+				$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";
791
+			}
647 792
 			try {
648 793
 				$sth = $this->db->prepare($query);
649 794
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -651,7 +796,9 @@  discard block
 block discarded – undo
651 796
 				echo "error : ".$e->getMessage();
652 797
 			}
653 798
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
654
-		} else $all = array();
799
+		} else {
800
+			$all = array();
801
+		}
655 802
 		if (empty($all)) {
656 803
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
657 804
 			if ($filter_name != '') {
@@ -666,7 +813,9 @@  discard block
 block discarded – undo
666 813
 
667 814
 	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') {
668 815
 		global $globalStatsFilters;
669
-		if ($filter_name == '') $filter_name = $this->filter_name;
816
+		if ($filter_name == '') {
817
+			$filter_name = $this->filter_name;
818
+		}
670 819
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
671 820
 			$Spotter = new Spotter($this->db);
672 821
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -675,8 +824,11 @@  discard block
 block discarded – undo
675 824
 				foreach ($airlines as $airline) {
676 825
 					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
677 826
 				}
678
-				if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
679
-				else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC";
827
+				if ($limit) {
828
+					$query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
829
+				} else {
830
+					$query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC";
831
+				}
680 832
 				try {
681 833
 					$sth = $this->db->prepare($query);
682 834
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -684,11 +836,16 @@  discard block
 block discarded – undo
684 836
 					echo "error : ".$e->getMessage();
685 837
 				}
686 838
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
687
-			} else $all = array();
839
+			} else {
840
+				$all = array();
841
+			}
688 842
 		} else {
689 843
 			if ($year == '' && $month == '') {
690
-				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";
691
-				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";
844
+				if ($limit) {
845
+					$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";
846
+				} else {
847
+					$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";
848
+				}
692 849
 				try {
693 850
 					$sth = $this->db->prepare($query);
694 851
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -696,7 +853,9 @@  discard block
 block discarded – undo
696 853
 					echo "error : ".$e->getMessage();
697 854
 				}
698 855
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
699
-			} else $all = array();
856
+			} else {
857
+				$all = array();
858
+			}
700 859
 		}
701 860
 		if (empty($all)) {
702 861
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -715,7 +874,9 @@  discard block
 block discarded – undo
715 874
 	}
716 875
 	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
717 876
 		global $globalStatsFilters;
718
-		if ($filter_name == '') $filter_name = $this->filter_name;
877
+		if ($filter_name == '') {
878
+			$filter_name = $this->filter_name;
879
+		}
719 880
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
720 881
 			$Spotter = new Spotter($this->db);
721 882
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -724,8 +885,11 @@  discard block
 block discarded – undo
724 885
 				foreach ($airlines as $airline) {
725 886
 					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
726 887
 				}
727
-				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
728
-				else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
888
+				if ($limit) {
889
+					$query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
890
+				} else {
891
+					$query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
892
+				}
729 893
 				try {
730 894
 					$sth = $this->db->prepare($query);
731 895
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -733,11 +897,16 @@  discard block
 block discarded – undo
733 897
 					echo "error : ".$e->getMessage();
734 898
 				}
735 899
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
736
-			} else $all = array();
900
+			} else {
901
+				$all = array();
902
+			}
737 903
 		} else {
738 904
 			if ($year == '' && $month == '') {
739
-				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND 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";
740
-				else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
905
+				if ($limit) {
906
+					$query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND 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";
907
+				} else {
908
+					$query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport.name AS airport_departure_name,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
909
+				}
741 910
 				try {
742 911
 					$sth = $this->db->prepare($query);
743 912
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -745,7 +914,9 @@  discard block
 block discarded – undo
745 914
 					echo "error : ".$e->getMessage();
746 915
 				}
747 916
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
748
-			} else $all = array();
917
+			} else {
918
+				$all = array();
919
+			}
749 920
 		}
750 921
 		if (empty($all)) {
751 922
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -770,7 +941,9 @@  discard block
 block discarded – undo
770 941
 				$icao = $value['airport_departure_icao'];
771 942
 				if (isset($all[$icao])) {
772 943
 					$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
773
-				} else $all[$icao] = $value;
944
+				} else {
945
+					$all[$icao] = $value;
946
+				}
774 947
 			}
775 948
 			$count = array();
776 949
 			foreach ($all as $key => $row) {
@@ -782,7 +955,9 @@  discard block
 block discarded – undo
782 955
 	}
783 956
 	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
784 957
 		global $globalStatsFilters;
785
-		if ($filter_name == '') $filter_name = $this->filter_name;
958
+		if ($filter_name == '') {
959
+			$filter_name = $this->filter_name;
960
+		}
786 961
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
787 962
 			$Spotter = new Spotter($this->db);
788 963
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -791,8 +966,11 @@  discard block
 block discarded – undo
791 966
 				foreach ($airlines as $airline) {
792 967
 					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
793 968
 				}
794
-				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
795
-				else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
969
+				if ($limit) {
970
+					$query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
971
+				} else {
972
+					$query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
973
+				}
796 974
 				try {
797 975
 					$sth = $this->db->prepare($query);
798 976
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -800,11 +978,16 @@  discard block
 block discarded – undo
800 978
 					echo "error : ".$e->getMessage();
801 979
 				}
802 980
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
803
-			} else $all = array();
981
+			} else {
982
+				$all = array();
983
+			}
804 984
 		} else {
805 985
 			if ($year == '' && $month == '') {
806
-				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
807
-				else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
986
+				if ($limit) {
987
+					$query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
988
+				} else {
989
+					$query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport.name AS airport_arrival_name, airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
990
+				}
808 991
 				try {
809 992
 					$sth = $this->db->prepare($query);
810 993
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -812,7 +995,9 @@  discard block
 block discarded – undo
812 995
 					echo "error : ".$e->getMessage();
813 996
 				}
814 997
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
815
-			} else $all = array();
998
+			} else {
999
+				$all = array();
1000
+			}
816 1001
 		}
817 1002
 		if (empty($all)) {
818 1003
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -837,7 +1022,9 @@  discard block
 block discarded – undo
837 1022
 				$icao = $value['airport_arrival_icao'];
838 1023
 				if (isset($all[$icao])) {
839 1024
 					$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
840
-				} else $all[$icao] = $value;
1025
+				} else {
1026
+					$all[$icao] = $value;
1027
+				}
841 1028
 			}
842 1029
 			$count = array();
843 1030
 			foreach ($all as $key => $row) {
@@ -849,7 +1036,9 @@  discard block
 block discarded – undo
849 1036
 	}
850 1037
 	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
851 1038
 		global $globalDBdriver, $globalStatsFilters;
852
-		if ($filter_name == '') $filter_name = $this->filter_name;
1039
+		if ($filter_name == '') {
1040
+			$filter_name = $this->filter_name;
1041
+		}
853 1042
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
854 1043
 			$Spotter = new Spotter($this->db);
855 1044
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -858,20 +1047,32 @@  discard block
 block discarded – undo
858 1047
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
859 1048
 			}
860 1049
 			if ($globalDBdriver == 'mysql') {
861
-				if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
862
-				else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
1050
+				if ($limit) {
1051
+					$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
1052
+				} else {
1053
+					$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
1054
+				}
863 1055
 			} else {
864
-				if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
865
-				else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
1056
+				if ($limit) {
1057
+					$query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
1058
+				} else {
1059
+					$query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
1060
+				}
866 1061
 			}
867 1062
 			$query_data = array(':filter_name' => $filter_name);
868 1063
 		} else {
869 1064
 			if ($globalDBdriver == 'mysql') {
870
-				if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name";
871
-				else $query = "SELECT MONTH(stats_date) as month_name, YEAR(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";
1065
+				if ($limit) {
1066
+					$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name";
1067
+				} else {
1068
+					$query = "SELECT MONTH(stats_date) as month_name, YEAR(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";
1069
+				}
872 1070
 			} else {
873
-				if ($limit) $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_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
874
-				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";
1071
+				if ($limit) {
1072
+					$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_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
1073
+				} else {
1074
+					$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";
1075
+				}
875 1076
 			}
876 1077
 			$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
877 1078
 		}
@@ -899,7 +1100,9 @@  discard block
 block discarded – undo
899 1100
 	
900 1101
 	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
901 1102
 		global $globalStatsFilters;
902
-		if ($filter_name == '') $filter_name = $this->filter_name;
1103
+		if ($filter_name == '') {
1104
+			$filter_name = $this->filter_name;
1105
+		}
903 1106
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
904 1107
 			$Spotter = new Spotter($this->db);
905 1108
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -936,7 +1139,9 @@  discard block
 block discarded – undo
936 1139
 	}
937 1140
 	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
938 1141
 		global $globalDBdriver, $globalStatsFilters;
939
-		if ($filter_name == '') $filter_name = $this->filter_name;
1142
+		if ($filter_name == '') {
1143
+			$filter_name = $this->filter_name;
1144
+		}
940 1145
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
941 1146
 			$Spotter = new Spotter($this->db);
942 1147
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -981,7 +1186,9 @@  discard block
 block discarded – undo
981 1186
 	}
982 1187
 	public function countAllDates($stats_airline = '',$filter_name = '') {
983 1188
 		global $globalStatsFilters;
984
-		if ($filter_name == '') $filter_name = $this->filter_name;
1189
+		if ($filter_name == '') {
1190
+			$filter_name = $this->filter_name;
1191
+		}
985 1192
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
986 1193
 			$Spotter = new Spotter($this->db);
987 1194
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1018,7 +1225,9 @@  discard block
 block discarded – undo
1018 1225
 	}
1019 1226
 	public function countAllDatesMarine($filter_name = '') {
1020 1227
 		global $globalStatsFilters;
1021
-		if ($filter_name == '') $filter_name = $this->filter_name;
1228
+		if ($filter_name == '') {
1229
+			$filter_name = $this->filter_name;
1230
+		}
1022 1231
 		$query = "SELECT marine_date as date_name, cnt as date_count FROM stats_marine WHERE stats_type = 'date' AND filter_name = :filter_name ORDER BY date_count DESC";
1023 1232
 		$query_data = array(':filter_name' => $filter_name);
1024 1233
 		try {
@@ -1040,7 +1249,9 @@  discard block
 block discarded – undo
1040 1249
 	}
1041 1250
 	public function countAllDatesTracker($filter_name = '') {
1042 1251
 		global $globalStatsFilters;
1043
-		if ($filter_name == '') $filter_name = $this->filter_name;
1252
+		if ($filter_name == '') {
1253
+			$filter_name = $this->filter_name;
1254
+		}
1044 1255
 		$query = "SELECT tracker_date as date_name, cnt as date_count FROM stats_tracker WHERE stats_type = 'date' AND filter_name = :filter_name ORDER BY date_count DESC";
1045 1256
 		$query_data = array(':filter_name' => $filter_name);
1046 1257
 		try {
@@ -1062,7 +1273,9 @@  discard block
 block discarded – undo
1062 1273
 	}
1063 1274
 	public function countAllDatesByAirlines($filter_name = '') {
1064 1275
 		global $globalStatsFilters;
1065
-		if ($filter_name == '') $filter_name = $this->filter_name;
1276
+		if ($filter_name == '') {
1277
+			$filter_name = $this->filter_name;
1278
+		}
1066 1279
 		$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";
1067 1280
 		$query_data = array('filter_name' => $filter_name);
1068 1281
 		try {
@@ -1084,7 +1297,9 @@  discard block
 block discarded – undo
1084 1297
 	}
1085 1298
 	public function countAllMonths($stats_airline = '',$filter_name = '') {
1086 1299
 		global $globalStatsFilters, $globalDBdriver;
1087
-		if ($filter_name == '') $filter_name = $this->filter_name;
1300
+		if ($filter_name == '') {
1301
+			$filter_name = $this->filter_name;
1302
+		}
1088 1303
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1089 1304
 			$Spotter = new Spotter($this->db);
1090 1305
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1169,7 +1384,9 @@  discard block
 block discarded – undo
1169 1384
 	}
1170 1385
 	public function countAllMilitaryMonths($filter_name = '') {
1171 1386
 		global $globalStatsFilters;
1172
-		if ($filter_name == '') $filter_name = $this->filter_name;
1387
+		if ($filter_name == '') {
1388
+			$filter_name = $this->filter_name;
1389
+		}
1173 1390
 		$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";
1174 1391
 		try {
1175 1392
 			$sth = $this->db->prepare($query);
@@ -1190,7 +1407,9 @@  discard block
 block discarded – undo
1190 1407
 	}
1191 1408
 	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
1192 1409
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
1193
-		if ($filter_name == '') $filter_name = $this->filter_name;
1410
+		if ($filter_name == '') {
1411
+			$filter_name = $this->filter_name;
1412
+		}
1194 1413
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1195 1414
 			$Spotter = new Spotter($this->db);
1196 1415
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1198,12 +1417,18 @@  discard block
 block discarded – undo
1198 1417
 			foreach ($airlines as $airline) {
1199 1418
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1200 1419
 			}
1201
-			if ($limit) $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1202
-			else $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1420
+			if ($limit) {
1421
+				$query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1422
+			} else {
1423
+				$query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1424
+			}
1203 1425
 			$query_data = array(':filter_name' => $filter_name);
1204 1426
 		} else {
1205
-			if ($limit) $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name";
1206
-			else $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name";
1427
+			if ($limit) {
1428
+				$query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name";
1429
+			} else {
1430
+				$query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name";
1431
+			}
1207 1432
 			$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1208 1433
 		}
1209 1434
 		if ($orderby == 'hour') {
@@ -1213,7 +1438,9 @@  discard block
 block discarded – undo
1213 1438
 				$query .= " ORDER BY CAST(flight_date AS integer) ASC";
1214 1439
 			}
1215 1440
 		}
1216
-		if ($orderby == 'count') $query .= " ORDER BY hour_count DESC";
1441
+		if ($orderby == 'count') {
1442
+			$query .= " ORDER BY hour_count DESC";
1443
+		}
1217 1444
 		try {
1218 1445
 			$sth = $this->db->prepare($query);
1219 1446
 			$sth->execute($query_data);
@@ -1237,8 +1464,12 @@  discard block
 block discarded – undo
1237 1464
 	}
1238 1465
 	public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') {
1239 1466
 		global $globalStatsFilters;
1240
-		if ($filter_name == '') $filter_name = $this->filter_name;
1241
-		if ($year == '') $year = date('Y');
1467
+		if ($filter_name == '') {
1468
+			$filter_name = $this->filter_name;
1469
+		}
1470
+		if ($year == '') {
1471
+			$year = date('Y');
1472
+		}
1242 1473
 		$all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month);
1243 1474
 		if (empty($all)) {
1244 1475
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -1257,8 +1488,12 @@  discard block
 block discarded – undo
1257 1488
 	}
1258 1489
 	public function countOverallMarine($filter_name = '',$year = '',$month = '') {
1259 1490
 		global $globalStatsFilters;
1260
-		if ($filter_name == '') $filter_name = $this->filter_name;
1261
-		if ($year == '') $year = date('Y');
1491
+		if ($filter_name == '') {
1492
+			$filter_name = $this->filter_name;
1493
+		}
1494
+		if ($year == '') {
1495
+			$year = date('Y');
1496
+		}
1262 1497
 		$all = $this->getSumStats('marine_bymonth',$year,'',$filter_name,$month);
1263 1498
 		if (empty($all)) {
1264 1499
 			$filters = array('year' => $year,'month' => $month);
@@ -1273,8 +1508,12 @@  discard block
 block discarded – undo
1273 1508
 	}
1274 1509
 	public function countOverallTracker($filter_name = '',$year = '',$month = '') {
1275 1510
 		global $globalStatsFilters;
1276
-		if ($filter_name == '') $filter_name = $this->filter_name;
1277
-		if ($year == '') $year = date('Y');
1511
+		if ($filter_name == '') {
1512
+			$filter_name = $this->filter_name;
1513
+		}
1514
+		if ($year == '') {
1515
+			$year = date('Y');
1516
+		}
1278 1517
 		$all = $this->getSumStats('tracker_bymonth',$year,'',$filter_name,$month);
1279 1518
 		if (empty($all)) {
1280 1519
 			$filters = array('year' => $year,'month' => $month);
@@ -1289,8 +1528,12 @@  discard block
 block discarded – undo
1289 1528
 	}
1290 1529
 	public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') {
1291 1530
 		global $globalStatsFilters;
1292
-		if ($filter_name == '') $filter_name = $this->filter_name;
1293
-		if ($year == '') $year = date('Y');
1531
+		if ($filter_name == '') {
1532
+			$filter_name = $this->filter_name;
1533
+		}
1534
+		if ($year == '') {
1535
+			$year = date('Y');
1536
+		}
1294 1537
 		$all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month);
1295 1538
 		if (empty($all)) {
1296 1539
 			$filters = array();
@@ -1306,8 +1549,12 @@  discard block
 block discarded – undo
1306 1549
 	}
1307 1550
 	public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') {
1308 1551
 		global $globalStatsFilters;
1309
-		if ($filter_name == '') $filter_name = $this->filter_name;
1310
-		if ($year == '') $year = date('Y');
1552
+		if ($filter_name == '') {
1553
+			$filter_name = $this->filter_name;
1554
+		}
1555
+		if ($year == '') {
1556
+			$year = date('Y');
1557
+		}
1311 1558
 		$all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month);
1312 1559
 		if (empty($all)) {
1313 1560
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -1326,7 +1573,9 @@  discard block
 block discarded – undo
1326 1573
 	}
1327 1574
 	public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') {
1328 1575
 		global $globalStatsFilters;
1329
-		if ($filter_name == '') $filter_name = $this->filter_name;
1576
+		if ($filter_name == '') {
1577
+			$filter_name = $this->filter_name;
1578
+		}
1330 1579
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1331 1580
 			$Spotter = new Spotter($this->db);
1332 1581
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1344,7 +1593,9 @@  discard block
 block discarded – undo
1344 1593
 				}
1345 1594
 				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1346 1595
 				$all = $result[0]['nb'];
1347
-			} else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1596
+			} else {
1597
+				$all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1598
+			}
1348 1599
 		} else {
1349 1600
 			if ($year == '' && $month == '') {
1350 1601
 				$query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
@@ -1356,7 +1607,9 @@  discard block
 block discarded – undo
1356 1607
 				}
1357 1608
 				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1358 1609
 				$all = $result[0]['nb'];
1359
-			} else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1610
+			} else {
1611
+				$all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1612
+			}
1360 1613
 		}
1361 1614
 		if (empty($all)) {
1362 1615
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -1375,7 +1628,9 @@  discard block
 block discarded – undo
1375 1628
 	}
1376 1629
 	public function countOverallAirlines($filter_name = '',$year = '',$month = '') {
1377 1630
 		global $globalStatsFilters;
1378
-		if ($filter_name == '') $filter_name = $this->filter_name;
1631
+		if ($filter_name == '') {
1632
+			$filter_name = $this->filter_name;
1633
+		}
1379 1634
 		if ($year == '' && $month == '') {
1380 1635
 			$query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name";
1381 1636
 			try {
@@ -1386,7 +1641,9 @@  discard block
 block discarded – undo
1386 1641
 			}
1387 1642
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1388 1643
 			$all = $result[0]['nb_airline'];
1389
-		} else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
1644
+		} else {
1645
+			$all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
1646
+		}
1390 1647
 		if (empty($all)) {
1391 1648
 			$filters = array();
1392 1649
 			$filters = array('year' => $year,'month' => $month);
@@ -1401,7 +1658,9 @@  discard block
 block discarded – undo
1401 1658
 	}
1402 1659
 	public function countOverallMarineTypes($filter_name = '',$year = '',$month = '') {
1403 1660
 		global $globalStatsFilters;
1404
-		if ($filter_name == '') $filter_name = $this->filter_name;
1661
+		if ($filter_name == '') {
1662
+			$filter_name = $this->filter_name;
1663
+		}
1405 1664
 		$all = array();
1406 1665
 		if ($year == '' && $month == '') {
1407 1666
 			$query = "SELECT SUM(cnt) AS nb_type FROM stats_marine_type WHERE filter_name = :filter_name";
@@ -1428,7 +1687,9 @@  discard block
 block discarded – undo
1428 1687
 	}
1429 1688
 	public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') {
1430 1689
 		global $globalStatsFilters;
1431
-		if ($filter_name == '') $filter_name = $this->filter_name;
1690
+		if ($filter_name == '') {
1691
+			$filter_name = $this->filter_name;
1692
+		}
1432 1693
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1433 1694
 			$Spotter = new Spotter($this->db);
1434 1695
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1483,7 +1744,9 @@  discard block
 block discarded – undo
1483 1744
 	}
1484 1745
 	public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') {
1485 1746
 		global $globalStatsFilters;
1486
-		if ($filter_name == '') $filter_name = $this->filter_name;
1747
+		if ($filter_name == '') {
1748
+			$filter_name = $this->filter_name;
1749
+		}
1487 1750
 		//if ($year == '') $year = date('Y');
1488 1751
 		if ($year == '' && $month == '') {
1489 1752
 			$query = "SELECT count(*) as nb FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
@@ -1512,7 +1775,9 @@  discard block
 block discarded – undo
1512 1775
 	}
1513 1776
 
1514 1777
 	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') {
1515
-		if ($filter_name == '') $filter_name = $this->filter_name;
1778
+		if ($filter_name == '') {
1779
+			$filter_name = $this->filter_name;
1780
+		}
1516 1781
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1517 1782
 			$Spotter = new Spotter($this->db);
1518 1783
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1536,7 +1801,9 @@  discard block
 block discarded – undo
1536 1801
 		return $all;
1537 1802
 	}
1538 1803
 	public function getStats($type,$stats_airline = '', $filter_name = '') {
1539
-		if ($filter_name == '') $filter_name = $this->filter_name;
1804
+		if ($filter_name == '') {
1805
+			$filter_name = $this->filter_name;
1806
+		}
1540 1807
 		$query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
1541 1808
 		$query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1542 1809
 		try {
@@ -1549,7 +1816,9 @@  discard block
 block discarded – undo
1549 1816
 		return $all;
1550 1817
 	}
1551 1818
 	public function deleteStatsByType($type,$stats_airline = '', $filter_name = '') {
1552
-		if ($filter_name == '') $filter_name = $this->filter_name;
1819
+		if ($filter_name == '') {
1820
+			$filter_name = $this->filter_name;
1821
+		}
1553 1822
 		$query = "DELETE FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name";
1554 1823
 		$query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1555 1824
 		try {
@@ -1560,7 +1829,9 @@  discard block
 block discarded – undo
1560 1829
 		}
1561 1830
 	}
1562 1831
 	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') {
1563
-		if ($filter_name == '') $filter_name = $this->filter_name;
1832
+		if ($filter_name == '') {
1833
+			$filter_name = $this->filter_name;
1834
+		}
1564 1835
 		global $globalArchiveMonths, $globalDBdriver;
1565 1836
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1566 1837
 			$Spotter = new Spotter($this->db);
@@ -1616,7 +1887,9 @@  discard block
 block discarded – undo
1616 1887
 	}
1617 1888
 	public function getStatsTotal($type, $stats_airline = '', $filter_name = '') {
1618 1889
 		global $globalArchiveMonths, $globalDBdriver;
1619
-		if ($filter_name == '') $filter_name = $this->filter_name;
1890
+		if ($filter_name == '') {
1891
+			$filter_name = $this->filter_name;
1892
+		}
1620 1893
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1621 1894
 			$Spotter = new Spotter($this->db);
1622 1895
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1649,7 +1922,9 @@  discard block
 block discarded – undo
1649 1922
 	}
1650 1923
 	public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') {
1651 1924
 		global $globalArchiveMonths, $globalDBdriver;
1652
-		if ($filter_name == '') $filter_name = $this->filter_name;
1925
+		if ($filter_name == '') {
1926
+			$filter_name = $this->filter_name;
1927
+		}
1653 1928
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1654 1929
 			$Spotter = new Spotter($this->db);
1655 1930
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1680,7 +1955,9 @@  discard block
 block discarded – undo
1680 1955
 	}
1681 1956
 	public function getStatsAirlineTotal($filter_name = '') {
1682 1957
 		global $globalArchiveMonths, $globalDBdriver;
1683
-		if ($filter_name == '') $filter_name = $this->filter_name;
1958
+		if ($filter_name == '') {
1959
+			$filter_name = $this->filter_name;
1960
+		}
1684 1961
 		if ($globalDBdriver == 'mysql') {
1685 1962
 			$query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name";
1686 1963
 		} else {
@@ -1697,7 +1974,9 @@  discard block
 block discarded – undo
1697 1974
 	}
1698 1975
 	public function getStatsOwnerTotal($filter_name = '') {
1699 1976
 		global $globalArchiveMonths, $globalDBdriver;
1700
-		if ($filter_name == '') $filter_name = $this->filter_name;
1977
+		if ($filter_name == '') {
1978
+			$filter_name = $this->filter_name;
1979
+		}
1701 1980
 		if ($globalDBdriver == 'mysql') {
1702 1981
 			$query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name";
1703 1982
 		} else {
@@ -1714,7 +1993,9 @@  discard block
 block discarded – undo
1714 1993
 	}
1715 1994
 	public function getStatsOwner($owner_name,$filter_name = '') {
1716 1995
 		global $globalArchiveMonths, $globalDBdriver;
1717
-		if ($filter_name == '') $filter_name = $this->filter_name;
1996
+		if ($filter_name == '') {
1997
+			$filter_name = $this->filter_name;
1998
+		}
1718 1999
 		$query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name";
1719 2000
 		try {
1720 2001
 			$sth = $this->db->prepare($query);
@@ -1723,12 +2004,17 @@  discard block
 block discarded – undo
1723 2004
 			echo "error : ".$e->getMessage();
1724 2005
 		}
1725 2006
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1726
-		if (isset($all[0]['cnt'])) return $all[0]['cnt'];
1727
-		else return 0;
2007
+		if (isset($all[0]['cnt'])) {
2008
+			return $all[0]['cnt'];
2009
+		} else {
2010
+			return 0;
2011
+		}
1728 2012
 	}
1729 2013
 	public function getStatsPilotTotal($filter_name = '') {
1730 2014
 		global $globalArchiveMonths, $globalDBdriver;
1731
-		if ($filter_name == '') $filter_name = $this->filter_name;
2015
+		if ($filter_name == '') {
2016
+			$filter_name = $this->filter_name;
2017
+		}
1732 2018
 		if ($globalDBdriver == 'mysql') {
1733 2019
 			$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
1734 2020
 		} else {
@@ -1745,7 +2031,9 @@  discard block
 block discarded – undo
1745 2031
 	}
1746 2032
 	public function getStatsPilot($pilot,$filter_name = '') {
1747 2033
 		global $globalArchiveMonths, $globalDBdriver;
1748
-		if ($filter_name == '') $filter_name = $this->filter_name;
2034
+		if ($filter_name == '') {
2035
+			$filter_name = $this->filter_name;
2036
+		}
1749 2037
 		$query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)";
1750 2038
 		try {
1751 2039
 			$sth = $this->db->prepare($query);
@@ -1754,13 +2042,18 @@  discard block
 block discarded – undo
1754 2042
 			echo "error : ".$e->getMessage();
1755 2043
 		}
1756 2044
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1757
-		if (isset($all[0]['cnt'])) return $all[0]['cnt'];
1758
-		else return 0;
2045
+		if (isset($all[0]['cnt'])) {
2046
+			return $all[0]['cnt'];
2047
+		} else {
2048
+			return 0;
2049
+		}
1759 2050
 	}
1760 2051
 
1761 2052
 	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1762 2053
 		global $globalDBdriver;
1763
-		if ($filter_name == '') $filter_name = $this->filter_name;
2054
+		if ($filter_name == '') {
2055
+			$filter_name = $this->filter_name;
2056
+		}
1764 2057
 		if ($globalDBdriver == 'mysql') {
1765 2058
 			$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";
1766 2059
 		} else {
@@ -1776,7 +2069,9 @@  discard block
 block discarded – undo
1776 2069
 	}
1777 2070
 	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1778 2071
 		global $globalDBdriver;
1779
-		if ($filter_name == '') $filter_name = $this->filter_name;
2072
+		if ($filter_name == '') {
2073
+			$filter_name = $this->filter_name;
2074
+		}
1780 2075
 		if ($globalDBdriver == 'mysql') {
1781 2076
 			$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";
1782 2077
 		} else {
@@ -2272,27 +2567,37 @@  discard block
 block discarded – undo
2272 2567
 		date_default_timezone_set('UTC');
2273 2568
 		if ((isset($globalMarine) && $globalMarine) || (isset($globalMasterServer) && $globalMasterServer)) {
2274 2569
 			$last_update = $this->getLastStatsUpdate('last_update_stats_marine');
2275
-			if ($globalDebug) echo '!!! Update Marine stats !!!'."\n";
2570
+			if ($globalDebug) {
2571
+				echo '!!! Update Marine stats !!!'."\n";
2572
+			}
2276 2573
 			if (isset($last_update[0]['value'])) {
2277 2574
 				$last_update_day = $last_update[0]['value'];
2278
-			} else $last_update_day = '2012-12-12 12:12:12';
2575
+			} else {
2576
+				$last_update_day = '2012-12-12 12:12:12';
2577
+			}
2279 2578
 			$reset = false;
2280 2579
 			$Marine = new Marine($this->db);
2281 2580
 			$filtername = 'marine';
2282 2581
 			if ($Connection->tableExists('countries')) {
2283
-				if ($globalDebug) echo 'Count all vessels by countries...'."\n";
2582
+				if ($globalDebug) {
2583
+					echo 'Count all vessels by countries...'."\n";
2584
+				}
2284 2585
 				$alldata = $Marine->countAllMarineOverCountries(false,0,$last_update_day);
2285 2586
 				foreach ($alldata as $number) {
2286 2587
 					echo $this->addStatCountryMarine($number['marine_country_iso2'],$number['marine_country_iso3'],$number['marine_country'],$number['marine_count'],'','',$reset);
2287 2588
 				}
2288 2589
 			}
2289
-			if ($globalDebug) echo 'Count all vessels by months...'."\n";
2590
+			if ($globalDebug) {
2591
+				echo 'Count all vessels by months...'."\n";
2592
+			}
2290 2593
 			$last_month = date('Y-m-01 00:00:00', strtotime('-1 month', strtotime($last_update_day)));
2291 2594
 			$filter_last_month = array('since_date' => $last_month);
2292 2595
 			$alldata = $Marine->countAllMonths($filter_last_month);
2293 2596
 			$lastyear = false;
2294 2597
 			foreach ($alldata as $number) {
2295
-				if ($number['year_name'] != date('Y')) $lastyear = true;
2598
+				if ($number['year_name'] != date('Y')) {
2599
+					$lastyear = true;
2600
+				}
2296 2601
 				$this->addStat('marine_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2297 2602
 			}
2298 2603
 			echo 'Marine data...'."\n";
@@ -2322,7 +2627,9 @@  discard block
 block discarded – undo
2322 2627
 			foreach ($alldata as $number) {
2323 2628
 				$this->addStatMarine('hour',$number['hour_name'],$number['hour_count']);
2324 2629
 			}
2325
-			if ($globalDebug) echo 'Count all types...'."\n";
2630
+			if ($globalDebug) {
2631
+				echo 'Count all types...'."\n";
2632
+			}
2326 2633
 			$alldata = $Marine->countAllMarineTypes(false,0,$last_update_day);
2327 2634
 			foreach ($alldata as $number) {
2328 2635
 				$this->addStatMarineType($number['marine_type'],$number['marine_type_id'],$number['marine_type_count'],'',$reset);
@@ -2334,26 +2641,36 @@  discard block
 block discarded – undo
2334 2641
 		}
2335 2642
 		if ((isset($globalTracker) && $globalTracker) || (isset($globalMasterServer) && $globalMasterServer)) {
2336 2643
 			$last_update = $this->getLastStatsUpdate('last_update_stats_tracker');
2337
-			if ($globalDebug) echo '!!! Update tracker stats !!!'."\n";
2644
+			if ($globalDebug) {
2645
+				echo '!!! Update tracker stats !!!'."\n";
2646
+			}
2338 2647
 			if (isset($last_update[0]['value'])) {
2339 2648
 				$last_update_day = $last_update[0]['value'];
2340
-			} else $last_update_day = '2012-12-12 12:12:12';
2649
+			} else {
2650
+				$last_update_day = '2012-12-12 12:12:12';
2651
+			}
2341 2652
 			$reset = false;
2342 2653
 			$Tracker = new Tracker($this->db);
2343 2654
 			if ($Connection->tableExists('countries')) {
2344
-				if ($globalDebug) echo 'Count all trackers by countries...'."\n";
2655
+				if ($globalDebug) {
2656
+					echo 'Count all trackers by countries...'."\n";
2657
+				}
2345 2658
 				$alldata = $Tracker->countAllTrackerOverCountries(false,0,$last_update_day);
2346 2659
 				foreach ($alldata as $number) {
2347 2660
 					$this->addStatCountryTracker($number['tracker_country_iso2'],$number['tracker_country_iso3'],$number['tracker_country'],$number['tracker_count'],'','',$reset);
2348 2661
 				}
2349 2662
 			}
2350
-			if ($globalDebug) echo 'Count all vessels by months...'."\n";
2663
+			if ($globalDebug) {
2664
+				echo 'Count all vessels by months...'."\n";
2665
+			}
2351 2666
 			$last_month = date('Y-m-01 00:00:00', strtotime('-1 month', strtotime($last_update_day)));
2352 2667
 			$filter_last_month = array('since_date' => $last_month);
2353 2668
 			$alldata = $Tracker->countAllMonths($filter_last_month);
2354 2669
 			$lastyear = false;
2355 2670
 			foreach ($alldata as $number) {
2356
-				if ($number['year_name'] != date('Y')) $lastyear = true;
2671
+				if ($number['year_name'] != date('Y')) {
2672
+					$lastyear = true;
2673
+				}
2357 2674
 				$this->addStat('tracker_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2358 2675
 			}
2359 2676
 			echo 'Tracker data...'."\n";
@@ -2390,10 +2707,14 @@  discard block
 block discarded – undo
2390 2707
 
2391 2708
 		if (!isset($globalAircraft) || (isset($globalAircraft) && $globalAircraft) || (isset($globalMasterServer) && $globalMasterServer)) {
2392 2709
 			$last_update = $this->getLastStatsUpdate('last_update_stats');
2393
-			if ($globalDebug) echo '!!! Update aicraft stats !!!'."\n";
2710
+			if ($globalDebug) {
2711
+				echo '!!! Update aicraft stats !!!'."\n";
2712
+			}
2394 2713
 			if (isset($last_update[0]['value'])) {
2395 2714
 				$last_update_day = $last_update[0]['value'];
2396
-			} else $last_update_day = '2012-12-12 12:12:12';
2715
+			} else {
2716
+				$last_update_day = '2012-12-12 12:12:12';
2717
+			}
2397 2718
 			$reset = false;
2398 2719
 			//if ($globalStatsResetYear && date('Y',strtotime($last_update_day)) != date('Y')) {
2399 2720
 			if ($globalStatsResetYear) {
@@ -2402,43 +2723,63 @@  discard block
 block discarded – undo
2402 2723
 			}
2403 2724
 			$Spotter = new Spotter($this->db);
2404 2725
 
2405
-			if ($globalDebug) echo 'Count all aircraft types...'."\n";
2726
+			if ($globalDebug) {
2727
+				echo 'Count all aircraft types...'."\n";
2728
+			}
2406 2729
 			$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);
2407 2730
 			foreach ($alldata as $number) {
2408 2731
 				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset);
2409 2732
 			}
2410
-			if ($globalDebug) echo 'Count all airlines...'."\n";
2733
+			if ($globalDebug) {
2734
+				echo 'Count all airlines...'."\n";
2735
+			}
2411 2736
 			$alldata = $Spotter->countAllAirlines(false,0,$last_update_day);
2412 2737
 			foreach ($alldata as $number) {
2413 2738
 				$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset);
2414 2739
 			}
2415
-			if ($globalDebug) echo 'Count all registrations...'."\n";
2740
+			if ($globalDebug) {
2741
+				echo 'Count all registrations...'."\n";
2742
+			}
2416 2743
 			$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day);
2417 2744
 			foreach ($alldata as $number) {
2418 2745
 				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset);
2419 2746
 			}
2420
-			if ($globalDebug) echo 'Count all callsigns...'."\n";
2747
+			if ($globalDebug) {
2748
+				echo 'Count all callsigns...'."\n";
2749
+			}
2421 2750
 			$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day);
2422 2751
 			foreach ($alldata as $number) {
2423 2752
 				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
2424 2753
 			}
2425
-			if ($globalDebug) echo 'Count all owners...'."\n";
2754
+			if ($globalDebug) {
2755
+				echo 'Count all owners...'."\n";
2756
+			}
2426 2757
 			$alldata = $Spotter->countAllOwners(false,0,$last_update_day);
2427 2758
 			foreach ($alldata as $number) {
2428 2759
 				$this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset);
2429 2760
 			}
2430
-			if ($globalDebug) echo 'Count all pilots...'."\n";
2761
+			if ($globalDebug) {
2762
+				echo 'Count all pilots...'."\n";
2763
+			}
2431 2764
 			$alldata = $Spotter->countAllPilots(false,0,$last_update_day);
2432 2765
 			foreach ($alldata as $number) {
2433
-				if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') $number['pilot_id'] = $number['pilot_name'];
2766
+				if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') {
2767
+					$number['pilot_id'] = $number['pilot_name'];
2768
+				}
2434 2769
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset);
2435 2770
 			}
2436 2771
 			
2437
-			if ($globalDebug) echo 'Count all departure airports...'."\n";
2772
+			if ($globalDebug) {
2773
+				echo 'Count all departure airports...'."\n";
2774
+			}
2438 2775
 			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
2439
-			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
2776
+			if ($globalDebug) {
2777
+				echo 'Count all detected departure airports...'."\n";
2778
+			}
2440 2779
 			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
2441
-			if ($globalDebug) echo 'Order departure airports...'."\n";
2780
+			if ($globalDebug) {
2781
+				echo 'Order departure airports...'."\n";
2782
+			}
2442 2783
 			$alldata = array();
2443 2784
 			foreach ($pall as $value) {
2444 2785
 				$icao = $value['airport_departure_icao'];
@@ -2448,7 +2789,9 @@  discard block
 block discarded – undo
2448 2789
 				$icao = $value['airport_departure_icao'];
2449 2790
 				if (isset($alldata[$icao])) {
2450 2791
 					$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
2451
-				} else $alldata[$icao] = $value;
2792
+				} else {
2793
+					$alldata[$icao] = $value;
2794
+				}
2452 2795
 			}
2453 2796
 			$count = array();
2454 2797
 			foreach ($alldata as $key => $row) {
@@ -2458,11 +2801,17 @@  discard block
 block discarded – undo
2458 2801
 			foreach ($alldata as $number) {
2459 2802
 				echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'','',$reset);
2460 2803
 			}
2461
-			if ($globalDebug) echo 'Count all arrival airports...'."\n";
2804
+			if ($globalDebug) {
2805
+				echo 'Count all arrival airports...'."\n";
2806
+			}
2462 2807
 			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
2463
-			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
2808
+			if ($globalDebug) {
2809
+				echo 'Count all detected arrival airports...'."\n";
2810
+			}
2464 2811
 			$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
2465
-			if ($globalDebug) echo 'Order arrival airports...'."\n";
2812
+			if ($globalDebug) {
2813
+				echo 'Order arrival airports...'."\n";
2814
+			}
2466 2815
 			$alldata = array();
2467 2816
 			foreach ($pall as $value) {
2468 2817
 				$icao = $value['airport_arrival_icao'];
@@ -2472,7 +2821,9 @@  discard block
 block discarded – undo
2472 2821
 				$icao = $value['airport_arrival_icao'];
2473 2822
 				if (isset($alldata[$icao])) {
2474 2823
 					$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
2475
-				} else $alldata[$icao] = $value;
2824
+				} else {
2825
+					$alldata[$icao] = $value;
2826
+				}
2476 2827
 			}
2477 2828
 			$count = array();
2478 2829
 			foreach ($alldata as $key => $row) {
@@ -2483,7 +2834,9 @@  discard block
 block discarded – undo
2483 2834
 				echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'','',$reset);
2484 2835
 			}
2485 2836
 			if ($Connection->tableExists('countries')) {
2486
-				if ($globalDebug) echo 'Count all flights by countries...'."\n";
2837
+				if ($globalDebug) {
2838
+					echo 'Count all flights by countries...'."\n";
2839
+				}
2487 2840
 				//$SpotterArchive = new SpotterArchive();
2488 2841
 				//$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day);
2489 2842
 				$Spotter = new Spotter($this->db);
@@ -2494,7 +2847,9 @@  discard block
 block discarded – undo
2494 2847
 			}
2495 2848
 			
2496 2849
 			if (isset($globalAccidents) && $globalAccidents) {
2497
-				if ($globalDebug) echo 'Count fatalities stats...'."\n";
2850
+				if ($globalDebug) {
2851
+					echo 'Count fatalities stats...'."\n";
2852
+				}
2498 2853
 				$Accident = new Accident($this->db);
2499 2854
 				$this->deleteStatsByType('fatalities_byyear');
2500 2855
 				$alldata = $Accident->countFatalitiesByYear();
@@ -2510,48 +2865,68 @@  discard block
 block discarded – undo
2510 2865
 
2511 2866
 			// Add by month using getstat if month finish...
2512 2867
 			//if (date('m',strtotime($last_update_day)) != date('m')) {
2513
-			if ($globalDebug) echo 'Count all flights by months...'."\n";
2868
+			if ($globalDebug) {
2869
+				echo 'Count all flights by months...'."\n";
2870
+			}
2514 2871
 			$last_month = date('Y-m-01 00:00:00', strtotime('-1 month', strtotime($last_update_day)));
2515 2872
 			$filter_last_month = array('since_date' => $last_month);
2516 2873
 			$Spotter = new Spotter($this->db);
2517 2874
 			$alldata = $Spotter->countAllMonths($filter_last_month);
2518 2875
 			$lastyear = false;
2519 2876
 			foreach ($alldata as $number) {
2520
-				if ($number['year_name'] != date('Y')) $lastyear = true;
2877
+				if ($number['year_name'] != date('Y')) {
2878
+					$lastyear = true;
2879
+				}
2521 2880
 				$this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2522 2881
 			}
2523
-			if ($globalDebug) echo 'Count all military flights by months...'."\n";
2882
+			if ($globalDebug) {
2883
+				echo 'Count all military flights by months...'."\n";
2884
+			}
2524 2885
 			$alldata = $Spotter->countAllMilitaryMonths($filter_last_month);
2525 2886
 			foreach ($alldata as $number) {
2526 2887
 				$this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2527 2888
 			}
2528
-			if ($globalDebug) echo 'Count all owners by months...'."\n";
2889
+			if ($globalDebug) {
2890
+				echo 'Count all owners by months...'."\n";
2891
+			}
2529 2892
 			$alldata = $Spotter->countAllMonthsOwners($filter_last_month);
2530 2893
 			foreach ($alldata as $number) {
2531 2894
 				$this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2532 2895
 			}
2533
-			if ($globalDebug) echo 'Count all pilots by months...'."\n";
2896
+			if ($globalDebug) {
2897
+				echo 'Count all pilots by months...'."\n";
2898
+			}
2534 2899
 			$alldata = $Spotter->countAllMonthsPilots($filter_last_month);
2535 2900
 			foreach ($alldata as $number) {
2536 2901
 				$this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2537 2902
 			}
2538
-			if ($globalDebug) echo 'Count all airlines by months...'."\n";
2903
+			if ($globalDebug) {
2904
+				echo 'Count all airlines by months...'."\n";
2905
+			}
2539 2906
 			$alldata = $Spotter->countAllMonthsAirlines($filter_last_month);
2540 2907
 			foreach ($alldata as $number) {
2541 2908
 				$this->addStat('airlines_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2542 2909
 			}
2543
-			if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
2910
+			if ($globalDebug) {
2911
+				echo 'Count all aircrafts by months...'."\n";
2912
+			}
2544 2913
 			$alldata = $Spotter->countAllMonthsAircrafts($filter_last_month);
2545 2914
 			foreach ($alldata as $number) {
2546 2915
 				$this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2547 2916
 			}
2548
-			if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
2917
+			if ($globalDebug) {
2918
+				echo 'Count all real arrivals by months...'."\n";
2919
+			}
2549 2920
 			$alldata = $Spotter->countAllMonthsRealArrivals($filter_last_month);
2550 2921
 			foreach ($alldata as $number) {
2551 2922
 				$this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2552 2923
 			}
2553
-			if ($globalDebug) echo 'Airports data...'."\n";
2554
-			if ($globalDebug) echo '...Departure'."\n";
2924
+			if ($globalDebug) {
2925
+				echo 'Airports data...'."\n";
2926
+			}
2927
+			if ($globalDebug) {
2928
+				echo '...Departure'."\n";
2929
+			}
2555 2930
 			$this->deleteStatAirport('daily');
2556 2931
 //			$pall = $Spotter->getLast7DaysAirportsDeparture();
2557 2932
   //      		$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
@@ -2669,7 +3044,9 @@  discard block
 block discarded – undo
2669 3044
 			// Count by airlines
2670 3045
 			echo '--- Stats by airlines ---'."\n";
2671 3046
 			if ($Connection->tableExists('countries')) {
2672
-				if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n";
3047
+				if ($globalDebug) {
3048
+					echo 'Count all flights by countries by airlines...'."\n";
3049
+				}
2673 3050
 				$SpotterArchive = new SpotterArchive($this->db);
2674 3051
 				//$Spotter = new Spotter($this->db);
2675 3052
 				$alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day);
@@ -2678,37 +3055,53 @@  discard block
 block discarded – undo
2678 3055
 					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset);
2679 3056
 				}
2680 3057
 			}
2681
-			if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n";
3058
+			if ($globalDebug) {
3059
+				echo 'Count all aircraft types by airlines...'."\n";
3060
+			}
2682 3061
 			$Spotter = new Spotter($this->db);
2683 3062
 			$alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day);
2684 3063
 			foreach ($alldata as $number) {
2685 3064
 				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset);
2686 3065
 			}
2687
-			if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n";
3066
+			if ($globalDebug) {
3067
+				echo 'Count all aircraft registrations by airlines...'."\n";
3068
+			}
2688 3069
 			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day);
2689 3070
 			foreach ($alldata as $number) {
2690 3071
 				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset);
2691 3072
 			}
2692
-			if ($globalDebug) echo 'Count all callsigns by airlines...'."\n";
3073
+			if ($globalDebug) {
3074
+				echo 'Count all callsigns by airlines...'."\n";
3075
+			}
2693 3076
 			$alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day);
2694 3077
 			foreach ($alldata as $number) {
2695 3078
 				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
2696 3079
 			}
2697
-			if ($globalDebug) echo 'Count all owners by airlines...'."\n";
3080
+			if ($globalDebug) {
3081
+				echo 'Count all owners by airlines...'."\n";
3082
+			}
2698 3083
 			$alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day);
2699 3084
 			foreach ($alldata as $number) {
2700 3085
 				$this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset);
2701 3086
 			}
2702
-			if ($globalDebug) echo 'Count all pilots by airlines...'."\n";
3087
+			if ($globalDebug) {
3088
+				echo 'Count all pilots by airlines...'."\n";
3089
+			}
2703 3090
 			$alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day);
2704 3091
 			foreach ($alldata as $number) {
2705 3092
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset);
2706 3093
 			}
2707
-			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
3094
+			if ($globalDebug) {
3095
+				echo 'Count all departure airports by airlines...'."\n";
3096
+			}
2708 3097
 			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
2709
-			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
3098
+			if ($globalDebug) {
3099
+				echo 'Count all detected departure airports by airlines...'."\n";
3100
+			}
2710 3101
 			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
2711
-			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
3102
+			if ($globalDebug) {
3103
+				echo 'Order detected departure airports by airlines...'."\n";
3104
+			}
2712 3105
 			//$alldata = array();
2713 3106
 			foreach ($dall as $value) {
2714 3107
 				$icao = $value['airport_departure_icao'];
@@ -2729,11 +3122,17 @@  discard block
 block discarded – undo
2729 3122
 			foreach ($alldata as $number) {
2730 3123
 				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'],'',$reset);
2731 3124
 			}
2732
-			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
3125
+			if ($globalDebug) {
3126
+				echo 'Count all arrival airports by airlines...'."\n";
3127
+			}
2733 3128
 			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
2734
-			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
3129
+			if ($globalDebug) {
3130
+				echo 'Count all detected arrival airports by airlines...'."\n";
3131
+			}
2735 3132
 			$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
2736
-			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
3133
+			if ($globalDebug) {
3134
+				echo 'Order arrival airports by airlines...'."\n";
3135
+			}
2737 3136
 			//$alldata = array();
2738 3137
 			foreach ($dall as $value) {
2739 3138
 				$icao = $value['airport_arrival_icao'];
@@ -2752,37 +3151,53 @@  discard block
 block discarded – undo
2752 3151
 			}
2753 3152
 			$alldata = $pall;
2754 3153
 			foreach ($alldata as $number) {
2755
-				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'],'',$reset);
3154
+				if ($number['airline_icao'] != '') {
3155
+					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'],'',$reset);
3156
+				}
3157
+			}
3158
+			if ($globalDebug) {
3159
+				echo 'Count all flights by months by airlines...'."\n";
2756 3160
 			}
2757
-			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
2758 3161
 			$Spotter = new Spotter($this->db);
2759 3162
 			$alldata = $Spotter->countAllMonthsByAirlines($filter_last_month);
2760 3163
 			$lastyear = false;
2761 3164
 			foreach ($alldata as $number) {
2762
-				if ($number['year_name'] != date('Y')) $lastyear = true;
3165
+				if ($number['year_name'] != date('Y')) {
3166
+					$lastyear = true;
3167
+				}
2763 3168
 				$this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
2764 3169
 			}
2765
-			if ($globalDebug) echo 'Count all owners by months by airlines...'."\n";
3170
+			if ($globalDebug) {
3171
+				echo 'Count all owners by months by airlines...'."\n";
3172
+			}
2766 3173
 			$alldata = $Spotter->countAllMonthsOwnersByAirlines($filter_last_month);
2767 3174
 			foreach ($alldata as $number) {
2768 3175
 				$this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
2769 3176
 			}
2770
-			if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n";
3177
+			if ($globalDebug) {
3178
+				echo 'Count all pilots by months by airlines...'."\n";
3179
+			}
2771 3180
 			$alldata = $Spotter->countAllMonthsPilotsByAirlines($filter_last_month);
2772 3181
 			foreach ($alldata as $number) {
2773 3182
 				$this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
2774 3183
 			}
2775
-			if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n";
3184
+			if ($globalDebug) {
3185
+				echo 'Count all aircrafts by months by airlines...'."\n";
3186
+			}
2776 3187
 			$alldata = $Spotter->countAllMonthsAircraftsByAirlines($filter_last_month);
2777 3188
 			foreach ($alldata as $number) {
2778 3189
 				$this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
2779 3190
 			}
2780
-			if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n";
3191
+			if ($globalDebug) {
3192
+				echo 'Count all real arrivals by months by airlines...'."\n";
3193
+			}
2781 3194
 			$alldata = $Spotter->countAllMonthsRealArrivalsByAirlines($filter_last_month);
2782 3195
 			foreach ($alldata as $number) {
2783 3196
 				$this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
2784 3197
 			}
2785
-			if ($globalDebug) echo '...Departure'."\n";
3198
+			if ($globalDebug) {
3199
+				echo '...Departure'."\n";
3200
+			}
2786 3201
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
2787 3202
 			$dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines();
2788 3203
 			foreach ($dall as $value) {
@@ -2805,7 +3220,9 @@  discard block
 block discarded – undo
2805 3220
 			foreach ($alldata as $number) {
2806 3221
 				$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']);
2807 3222
 			}
2808
-			if ($globalDebug) echo '...Arrival'."\n";
3223
+			if ($globalDebug) {
3224
+				echo '...Arrival'."\n";
3225
+			}
2809 3226
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
2810 3227
 			$dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines();
2811 3228
 			foreach ($dall as $value) {
@@ -2829,13 +3246,19 @@  discard block
 block discarded – undo
2829 3246
 				$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']);
2830 3247
 			}
2831 3248
 
2832
-			if ($globalDebug) echo 'Flights data...'."\n";
2833
-			if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n";
3249
+			if ($globalDebug) {
3250
+				echo 'Flights data...'."\n";
3251
+			}
3252
+			if ($globalDebug) {
3253
+				echo '-> countAllDatesLastMonth...'."\n";
3254
+			}
2834 3255
 			$alldata = $Spotter->countAllDatesLastMonthByAirlines($filter_last_month);
2835 3256
 			foreach ($alldata as $number) {
2836 3257
 				$this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']);
2837 3258
 			}
2838
-			if ($globalDebug) echo '-> countAllDates...'."\n";
3259
+			if ($globalDebug) {
3260
+				echo '-> countAllDates...'."\n";
3261
+			}
2839 3262
 			//$previousdata = $this->countAllDatesByAirlines();
2840 3263
 			$alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines($filter_last_month));
2841 3264
 			$values = array();
@@ -2848,14 +3271,18 @@  discard block
 block discarded – undo
2848 3271
 				$this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']);
2849 3272
 			}
2850 3273
 			
2851
-			if ($globalDebug) echo '-> countAllHours...'."\n";
3274
+			if ($globalDebug) {
3275
+				echo '-> countAllHours...'."\n";
3276
+			}
2852 3277
 			$alldata = $Spotter->countAllHoursByAirlines('hour',$filter_last_month);
2853 3278
 			foreach ($alldata as $number) {
2854 3279
 				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']);
2855 3280
 			}
2856 3281
 
2857 3282
 			// Stats by filters
2858
-			if (!isset($globalStatsFilters) || $globalStatsFilters == '') $globalStatsFilters = array();
3283
+			if (!isset($globalStatsFilters) || $globalStatsFilters == '') {
3284
+				$globalStatsFilters = array();
3285
+			}
2859 3286
 			foreach ($globalStatsFilters as $name => $filter) {
2860 3287
 				if (!empty($filter)) {
2861 3288
 					//$filter_name = $filter['name'];
@@ -2863,7 +3290,9 @@  discard block
 block discarded – undo
2863 3290
 					$reset = false;
2864 3291
 					$last_update = $this->getLastStatsUpdate('last_update_stats_'.$filter_name);
2865 3292
 					if (isset($filter['resetall']) && isset($last_update[0]['value']) && strtotime($filter['resetall']) > strtotime($last_update[0]['value'])) {
2866
-						if ($globalDebug) echo '!!! Delete stats for filter '.$filter_name.' !!!'."\n";
3293
+						if ($globalDebug) {
3294
+							echo '!!! Delete stats for filter '.$filter_name.' !!!'."\n";
3295
+						}
2867 3296
 						$this->deleteOldStats($filter_name);
2868 3297
 						unset($last_update);
2869 3298
 					}
@@ -2880,39 +3309,55 @@  discard block
 block discarded – undo
2880 3309
 						$reset = true;
2881 3310
 					}
2882 3311
 					// Count by filter
2883
-					if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n";
3312
+					if ($globalDebug) {
3313
+						echo '--- Stats for filter '.$filter_name.' ---'."\n";
3314
+					}
2884 3315
 					$Spotter = new Spotter($this->db);
2885
-					if ($globalDebug) echo 'Count all aircraft types...'."\n";
3316
+					if ($globalDebug) {
3317
+						echo 'Count all aircraft types...'."\n";
3318
+					}
2886 3319
 					$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter);
2887 3320
 					foreach ($alldata as $number) {
2888 3321
 						$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'',$filter_name,$reset);
2889 3322
 					}
2890
-					if ($globalDebug) echo 'Count all airlines...'."\n";
3323
+					if ($globalDebug) {
3324
+						echo 'Count all airlines...'."\n";
3325
+					}
2891 3326
 					$alldata = $Spotter->countAllAirlines(false,0,$last_update_day,$filter);
2892 3327
 					foreach ($alldata as $number) {
2893 3328
 						$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],$filter_name,$reset);
2894 3329
 					}
2895
-					if ($globalDebug) echo 'Count all aircraft registrations...'."\n";
3330
+					if ($globalDebug) {
3331
+						echo 'Count all aircraft registrations...'."\n";
3332
+					}
2896 3333
 					$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day,$filter);
2897 3334
 					foreach ($alldata as $number) {
2898 3335
 						$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'',$filter_name,$reset);
2899 3336
 					}
2900
-					if ($globalDebug) echo 'Count all callsigns...'."\n";
3337
+					if ($globalDebug) {
3338
+						echo 'Count all callsigns...'."\n";
3339
+					}
2901 3340
 					$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day,$filter);
2902 3341
 					foreach ($alldata as $number) {
2903 3342
 						$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],'',$filter_name,$reset);
2904 3343
 					}
2905
-					if ($globalDebug) echo 'Count all owners...'."\n";
3344
+					if ($globalDebug) {
3345
+						echo 'Count all owners...'."\n";
3346
+					}
2906 3347
 					$alldata = $Spotter->countAllOwners(false,0,$last_update_day,$filter);
2907 3348
 					foreach ($alldata as $number) {
2908 3349
 						$this->addStatOwner($number['owner_name'],$number['owner_count'],'',$filter_name,$reset);
2909 3350
 					}
2910
-					if ($globalDebug) echo 'Count all pilots...'."\n";
3351
+					if ($globalDebug) {
3352
+						echo 'Count all pilots...'."\n";
3353
+					}
2911 3354
 					$alldata = $Spotter->countAllPilots(false,0,$last_update_day,$filter);
2912 3355
 					foreach ($alldata as $number) {
2913 3356
 						$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source'],$reset);
2914 3357
 					}
2915
-					if ($globalDebug) echo 'Count departure airports...'."\n";
3358
+					if ($globalDebug) {
3359
+						echo 'Count departure airports...'."\n";
3360
+					}
2916 3361
 					$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter);
2917 3362
 					$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
2918 3363
 					$alldata = array();
@@ -2924,7 +3369,9 @@  discard block
 block discarded – undo
2924 3369
 						$icao = $value['airport_departure_icao'];
2925 3370
 						if (isset($alldata[$icao])) {
2926 3371
 							$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
2927
-						} else $alldata[$icao] = $value;
3372
+						} else {
3373
+							$alldata[$icao] = $value;
3374
+						}
2928 3375
 					}
2929 3376
 					$count = array();
2930 3377
 					foreach ($alldata as $key => $row) {
@@ -2934,7 +3381,9 @@  discard block
 block discarded – undo
2934 3381
 					foreach ($alldata as $number) {
2935 3382
 						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,$reset);
2936 3383
 					}
2937
-					if ($globalDebug) echo 'Count all arrival airports...'."\n";
3384
+					if ($globalDebug) {
3385
+						echo 'Count all arrival airports...'."\n";
3386
+					}
2938 3387
 					$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter);
2939 3388
 					$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter);
2940 3389
 					$alldata = array();
@@ -2946,7 +3395,9 @@  discard block
 block discarded – undo
2946 3395
 						$icao = $value['airport_arrival_icao'];
2947 3396
 						if (isset($alldata[$icao])) {
2948 3397
 							$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
2949
-						} else $alldata[$icao] = $value;
3398
+						} else {
3399
+							$alldata[$icao] = $value;
3400
+						}
2950 3401
 					}
2951 3402
 					$count = array();
2952 3403
 					foreach ($alldata as $key => $row) {
@@ -2956,35 +3407,49 @@  discard block
 block discarded – undo
2956 3407
 					foreach ($alldata as $number) {
2957 3408
 						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,$reset);
2958 3409
 					}
2959
-					if ($globalDebug) echo 'Count all months...'."\n";
3410
+					if ($globalDebug) {
3411
+						echo 'Count all months...'."\n";
3412
+					}
2960 3413
 					$Spotter = new Spotter($this->db);
2961 3414
 					$alldata = $Spotter->countAllMonths($filter);
2962 3415
 					$lastyear = false;
2963 3416
 					foreach ($alldata as $number) {
2964
-						if ($number['year_name'] != date('Y')) $lastyear = true;
3417
+						if ($number['year_name'] != date('Y')) {
3418
+							$lastyear = true;
3419
+						}
2965 3420
 						$this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
2966 3421
 					}
2967
-					if ($globalDebug) echo 'Count all owners by months...'."\n";
3422
+					if ($globalDebug) {
3423
+						echo 'Count all owners by months...'."\n";
3424
+					}
2968 3425
 					$alldata = $Spotter->countAllMonthsOwners($filter);
2969 3426
 					foreach ($alldata as $number) {
2970 3427
 						$this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
2971 3428
 					}
2972
-					if ($globalDebug) echo 'Count all pilots by months...'."\n";
3429
+					if ($globalDebug) {
3430
+						echo 'Count all pilots by months...'."\n";
3431
+					}
2973 3432
 					$alldata = $Spotter->countAllMonthsPilots($filter);
2974 3433
 					foreach ($alldata as $number) {
2975 3434
 						$this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
2976 3435
 					}
2977
-					if ($globalDebug) echo 'Count all military by months...'."\n";
3436
+					if ($globalDebug) {
3437
+						echo 'Count all military by months...'."\n";
3438
+					}
2978 3439
 					$alldata = $Spotter->countAllMilitaryMonths($filter);
2979 3440
 					foreach ($alldata as $number) {
2980 3441
 						$this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
2981 3442
 					}
2982
-					if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
3443
+					if ($globalDebug) {
3444
+						echo 'Count all aircrafts by months...'."\n";
3445
+					}
2983 3446
 					$alldata = $Spotter->countAllMonthsAircrafts($filter);
2984 3447
 				    	foreach ($alldata as $number) {
2985 3448
 			    			$this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
2986 3449
 					}
2987
-					if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
3450
+					if ($globalDebug) {
3451
+						echo 'Count all real arrivals by months...'."\n";
3452
+					}
2988 3453
 					$alldata = $Spotter->countAllMonthsRealArrivals($filter);
2989 3454
 					foreach ($alldata as $number) {
2990 3455
 						$this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
Please login to merge, or discard this patch.
statistics.php 1 patch
Braces   +169 added lines, -80 removed lines patch added patch discarded remove patch
@@ -22,11 +22,15 @@  discard block
 block discarded – undo
22 22
 	require_once('require/class.Spotter.php');
23 23
 }
24 24
 
25
-if (!isset($filter_name)) $filter_name = '';
25
+if (!isset($filter_name)) {
26
+	$filter_name = '';
27
+}
26 28
 $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
27 29
 if ($type == 'aircraft' && $airline_icao == '' && isset($globalFilter)) {
28
-	if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
29
-}
30
+	if (isset($globalFilter['airline'])) {
31
+		$airline_icao = $globalFilter['airline'][0];
32
+	}
33
+	}
30 34
 if ($type == 'aircraft' && $airline_icao != '' && $airline_icao != 'all') {
31 35
 	$Spotter = new Spotter();
32 36
 	$airline_info = $Spotter->getAllAirlineInfo($airline_icao);
@@ -61,7 +65,12 @@  discard block
 block discarded – undo
61 65
 <script type="text/javascript" src="<?php echo $globalURL; ?>/js/datamaps.world.min.js"></script>
62 66
 <div class="column">
63 67
     <div class="info">
64
-            <h1><?php if (isset($airline_name)) echo _("Statistics for ").$airline_name; else echo _("Statistics"); ?></h1>
68
+            <h1><?php if (isset($airline_name)) {
69
+	echo _("Statistics for ").$airline_name;
70
+} else {
71
+	echo _("Statistics");
72
+}
73
+?></h1>
65 74
 <?php 
66 75
 if ($type == 'aircraft') {
67 76
 	$last_update = $Stats->getLastStatsUpdate();
@@ -73,7 +82,9 @@  discard block
 block discarded – undo
73 82
 if (isset($last_update[0]['value'])) {
74 83
 	date_default_timezone_set('UTC');
75 84
 	$lastupdate = strtotime($last_update[0]['value']);
76
-	if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone);
85
+	if (isset($globalTimezone) && $globalTimezone != '') {
86
+		date_default_timezone_set($globalTimezone);
87
+	}
77 88
 	print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>';
78 89
 }
79 90
 
@@ -158,8 +169,11 @@  discard block
 block discarded – undo
158 169
 		print '<div id="chart1" class="chart" width="100%"></div><script>';
159 170
 		$aircraft_data = '';
160 171
 		foreach($aircraft_array as $aircraft_item) {
161
-			if ($aircraft_item['aircraft_manufacturer'] == 'Not Available') $aircraft_data .= '[" ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
162
-			else $aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
172
+			if ($aircraft_item['aircraft_manufacturer'] == 'Not Available') {
173
+				$aircraft_data .= '[" ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
174
+			} else {
175
+				$aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
176
+			}
163 177
 		}
164 178
 		$aircraft_data = substr($aircraft_data, 0, -1);
165 179
 		print 'var series = ['.$aircraft_data.'];';
@@ -176,11 +190,17 @@  discard block
 block discarded – undo
176 190
 <?php
177 191
 	if ($year != '' && $month != '') {
178 192
 ?>
179
-            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
193
+            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
194
+	echo '/'.$airline_icao;
195
+}
196
+?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
180 197
 <?php
181 198
 	} else {
182 199
 ?>
183
-            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
200
+            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
201
+	echo '/'.$airline_icao;
202
+}
203
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
184 204
 <?php
185 205
 	}
186 206
 ?>
@@ -209,11 +229,15 @@  discard block
 block discarded – undo
209 229
 			print '</script>';
210 230
 			if ($year != '' && $month != '') {
211 231
 				print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
212
-				if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
232
+				if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
233
+					echo '/'.$airline_icao;
234
+				}
213 235
 				print '/'.$year.'/'.$month.'/" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
214 236
 			} else {
215 237
 				print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
216
-				if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
238
+				if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
239
+					echo '/'.$airline_icao;
240
+				}
217 241
 				print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
218 242
 			}
219 243
 			print '</div>';
@@ -233,8 +257,9 @@  discard block
 block discarded – undo
233 257
                 <h2><?php echo _("Top 10 Most Common Vessel Type"); ?></h2>
234 258
 <?php
235 259
 	$marine_array = $Stats->countAllMarineTypes(true,0,'',$filter_name,$year,$month);
236
-	if (count($marine_array) == 0) print _("No data available");
237
-	else {
260
+	if (count($marine_array) == 0) {
261
+		print _("No data available");
262
+	} else {
238 263
 		print '<div id="chart1" class="chart" width="100%"></div><script>';
239 264
 		$marine_data = '';
240 265
 		foreach($marine_array as $marine_item) {
@@ -277,8 +302,9 @@  discard block
 block discarded – undo
277 302
                 <h2><?php echo _("Top 10 Most Common Tracker Type"); ?></h2>
278 303
 <?php
279 304
 	$tracker_array = $Tracker->countAllTrackerTypes(true,0,'',array(),$year,$month);
280
-	if (count($tracker_array) == 0) print _("No data available");
281
-	else {
305
+	if (count($tracker_array) == 0) {
306
+		print _("No data available");
307
+	} else {
282 308
 		print '<div id="chart1" class="chart" width="100%"></div><script>';
283 309
 		$tracker_data = '';
284 310
 		foreach($tracker_array as $tracker_item) {
@@ -322,8 +348,9 @@  discard block
 block discarded – undo
322 348
                 <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
323 349
 <?php
324 350
 		$owner_array = $Satellite->countAllOwners(true);
325
-		if (count($owner_array) == 0) print _("No data available");
326
-		else {
351
+		if (count($owner_array) == 0) {
352
+			print _("No data available");
353
+		} else {
327 354
 			print '<div id="chart7" class="chart" width="100%"></div><script>';
328 355
 			$owner_data = '';
329 356
 			foreach($owner_array as $owner_item) {
@@ -342,7 +369,10 @@  discard block
 block discarded – undo
342 369
 ?>
343 370
                <!--
344 371
                 <div class="more">
345
-                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
372
+                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
373
+	echo '/'.$airline_icao;
374
+}
375
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
346 376
                 </div>
347 377
                 -->
348 378
             </div>
@@ -351,8 +381,9 @@  discard block
 block discarded – undo
351 381
                 <h2><?php echo _("Top 10 Most Common Countries Owners"); ?></h2>
352 382
 <?php
353 383
 		$countries_array = $Satellite->countAllCountriesOwners(true);
354
-		if (count($countries_array) == 0) print _("No data available");
355
-		else {
384
+		if (count($countries_array) == 0) {
385
+			print _("No data available");
386
+		} else {
356 387
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
357 388
 			$owner_data = '';
358 389
 			foreach($countries_array as $owner_item) {
@@ -371,7 +402,10 @@  discard block
 block discarded – undo
371 402
 ?>
372 403
 	    <!--
373 404
                 <div class="more">
374
-                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
405
+                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
406
+	echo '/'.$airline_icao;
407
+}
408
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
375 409
                 </div>
376 410
                 -->
377 411
             </div>
@@ -383,8 +417,9 @@  discard block
 block discarded – undo
383 417
                 <h2><?php echo _("Top 10 Most Common Launch Sites"); ?></h2>
384 418
 <?php
385 419
 		$launch_site_array = $Satellite->countAllLaunchSite(true);
386
-		if (count($launch_site_array) == 0) print _("No data available");
387
-		else {
420
+		if (count($launch_site_array) == 0) {
421
+			print _("No data available");
422
+		} else {
388 423
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
389 424
 			$launch_site_data = '';
390 425
 			foreach($launch_site_array as $launch_site_item) {
@@ -403,7 +438,10 @@  discard block
 block discarded – undo
403 438
 ?>
404 439
                <!--
405 440
                 <div class="more">
406
-                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
441
+                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
442
+	echo '/'.$airline_icao;
443
+}
444
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
407 445
                 </div>
408 446
                 -->
409 447
             </div>
@@ -426,8 +464,9 @@  discard block
 block discarded – undo
426 464
                 <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2>
427 465
 <?php
428 466
 		$pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month);
429
-		if (count($pilot_array) == 0) print _("No data available");
430
-		else {
467
+		if (count($pilot_array) == 0) {
468
+			print _("No data available");
469
+		} else {
431 470
 			print '<div id="chart7" class="chart" width="100%"></div><script>';
432 471
 			$pilot_data = '';
433 472
 			foreach($pilot_array as $pilot_item) {
@@ -445,7 +484,9 @@  discard block
 block discarded – undo
445 484
 		}
446 485
 		print '<div class="more">';
447 486
 		print '<a href="'.$globalURL.'/statistics/pilot'; 
448
-		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
487
+		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
488
+			echo '/'.$airline_icao;
489
+		}
449 490
 		print'" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a>';
450 491
 		print '</div>';
451 492
 ?>
@@ -461,8 +502,9 @@  discard block
 block discarded – undo
461 502
                 <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
462 503
 <?php
463 504
 		$owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name,$year,$month);
464
-		if (count($owner_array) == 0) print _("No data available");
465
-		else {
505
+		if (count($owner_array) == 0) {
506
+			print _("No data available");
507
+		} else {
466 508
 			print '<div id="chart7" class="chart" width="100%"></div><script>';
467 509
 			$owner_data = '';
468 510
 			foreach($owner_array as $owner_item) {
@@ -480,7 +522,10 @@  discard block
 block discarded – undo
480 522
 		}
481 523
 ?>
482 524
                 <div class="more">
483
-                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
525
+                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
526
+	echo '/'.$airline_icao;
527
+}
528
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
484 529
                 </div>
485 530
             </div>
486 531
         
@@ -493,8 +538,9 @@  discard block
 block discarded – undo
493 538
                 <h2><?php echo _("Top 20 Most Common Country a Flight was Over"); ?></h2>
494 539
 <?php
495 540
 	 //$flightover_array = $Stats->countAllFlightOverCountries();
496
-		if (count($flightover_array) == 0) print _("No data available");
497
-		else {
541
+		if (count($flightover_array) == 0) {
542
+			print _("No data available");
543
+		} else {
498 544
 			print '<div id="chart10" class="chart" width="100%"></div><script>';
499 545
 			print 'var series = [';
500 546
 			$flightover_data = '';
@@ -536,7 +582,10 @@  discard block
 block discarded – undo
536 582
 		}
537 583
 ?>
538 584
                 <div class="more">
539
-                    <a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
585
+                    <a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
586
+	echo '/'.$airline_icao;
587
+}
588
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
540 589
                 </div>
541 590
             </div>
542 591
 <?php
@@ -554,8 +603,9 @@  discard block
 block discarded – undo
554 603
 	<div class="col-md-6">
555 604
             <h2><?php echo _("Top 20 Most Common Country a Vessel was inside"); ?></h2>
556 605
 <?php
557
-	if (count($flightover_array) == 0) print _("No data available");
558
-	else {
606
+	if (count($flightover_array) == 0) {
607
+		print _("No data available");
608
+	} else {
559 609
 		print '<div id="chart10" class="chart" width="100%"></div><script>';
560 610
 		print 'var series = [';
561 611
 		$flightover_data = '';
@@ -611,8 +661,9 @@  discard block
 block discarded – undo
611 661
 	<div class="col-md-6">
612 662
             <h2><?php echo _("Top 20 Most Common Country a Tracker was inside"); ?></h2>
613 663
 <?php
614
-	if (count($flightover_array) == 0) print _("No data available");
615
-	else {
664
+	if (count($flightover_array) == 0) {
665
+		print _("No data available");
666
+	} else {
616 667
 		print '<div id="chart10" class="chart" width="100%"></div><script>';
617 668
 		print 'var series = [';
618 669
 		$flightover_data = '';
@@ -718,7 +769,9 @@  discard block
 block discarded – undo
718 769
 		});";
719 770
 		print '</script>';
720 771
 		print '<div class="more"><a href="'.$globalURL.'/statistics/airport-departure'; 
721
-		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
772
+		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
773
+			echo '/'.$airline_icao;
774
+		}
722 775
 		print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
723 776
 	}
724 777
 ?>
@@ -782,7 +835,9 @@  discard block
 block discarded – undo
782 835
 		});";
783 836
 		print '</script>';
784 837
 		print '<div class="more"><a href="'.$globalURL.'/statistics/airport-arrival';
785
-		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
838
+		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
839
+			echo '/'.$airline_icao;
840
+		}
786 841
 		print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
787 842
 	}
788 843
 ?>
@@ -801,8 +856,9 @@  discard block
 block discarded – undo
801 856
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
802 857
 <?php
803 858
 		$year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
804
-		if (count($year_array) == 0) print _("No data available");
805
-		else {
859
+		if (count($year_array) == 0) {
860
+			print _("No data available");
861
+		} else {
806 862
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
807 863
 			$year_data = '';
808 864
 			$year_cnt = '';
@@ -821,7 +877,10 @@  discard block
 block discarded – undo
821 877
 		}
822 878
 ?>
823 879
                 <div class="more">
824
-                    <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
880
+                    <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
881
+	echo '/'.$airline_icao;
882
+}
883
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
825 884
                 </div>
826 885
             </div>
827 886
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -829,8 +888,9 @@  discard block
 block discarded – undo
829 888
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
830 889
 <?php
831 890
 		$month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
832
-		if (count($month_array) == 0) print _("No data available");
833
-		else {
891
+		if (count($month_array) == 0) {
892
+			print _("No data available");
893
+		} else {
834 894
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
835 895
 			$month_data = '';
836 896
 			$month_cnt = '';
@@ -849,7 +909,10 @@  discard block
 block discarded – undo
849 909
 		}
850 910
 ?>
851 911
                 <div class="more">
852
-                    <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
912
+                    <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
913
+	echo '/'.$airline_icao;
914
+}
915
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
853 916
                 </div>
854 917
             </div>
855 918
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -858,8 +921,9 @@  discard block
 block discarded – undo
858 921
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
859 922
 <?php
860 923
 		$date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
861
-		if (empty($date_array)) print _("No data available");
862
-		else {
924
+		if (empty($date_array)) {
925
+			print _("No data available");
926
+		} else {
863 927
 			print '<div id="chart5" class="chart" width="100%"></div><script>';
864 928
 			$date_data = '';
865 929
 			$date_cnt = '';
@@ -878,7 +942,10 @@  discard block
 block discarded – undo
878 942
 		}
879 943
 ?>
880 944
                 <div class="more">
881
-                    <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
945
+                    <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
946
+	echo '/'.$airline_icao;
947
+}
948
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
882 949
                 </div>
883 950
             </div>
884 951
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -886,8 +953,9 @@  discard block
 block discarded – undo
886 953
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
887 954
 <?php
888 955
 		$hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
889
-		if (empty($hour_array)) print _("No data available");
890
-		else {
956
+		if (empty($hour_array)) {
957
+			print _("No data available");
958
+		} else {
891 959
 			print '<div id="chart6" class="chart" width="100%"></div><script>';
892 960
 			$hour_data = '';
893 961
 			$hour_cnt = '';
@@ -906,7 +974,10 @@  discard block
 block discarded – undo
906 974
 		}
907 975
 ?>
908 976
                 <div class="more">
909
-                    <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
977
+                    <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
978
+	echo '/'.$airline_icao;
979
+}
980
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
910 981
                 </div>
911 982
             </div>
912 983
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -926,8 +997,9 @@  discard block
 block discarded – undo
926 997
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
927 998
 <?php
928 999
 		$year_array = $Marine->countAllMonthsLastYear(true,$airline_icao,$filter_name);
929
-		if (count($year_array) == 0) print _("No data available");
930
-		else {
1000
+		if (count($year_array) == 0) {
1001
+			print _("No data available");
1002
+		} else {
931 1003
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
932 1004
 			$year_data = '';
933 1005
 			$year_cnt = '';
@@ -955,8 +1027,9 @@  discard block
 block discarded – undo
955 1027
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
956 1028
 <?php
957 1029
 		$month_array = $Marine->countAllDatesLastMonth($airline_icao,$filter_name);
958
-		if (count($month_array) == 0) print _("No data available");
959
-		else {
1030
+		if (count($month_array) == 0) {
1031
+			print _("No data available");
1032
+		} else {
960 1033
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
961 1034
 			$month_data = '';
962 1035
 			$month_cnt = '';
@@ -984,8 +1057,9 @@  discard block
 block discarded – undo
984 1057
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
985 1058
 <?php
986 1059
 		$date_array = $Marine->countAllDatesLast7Days($airline_icao,$filter_name);
987
-		if (empty($date_array)) print _("No data available");
988
-		else {
1060
+		if (empty($date_array)) {
1061
+			print _("No data available");
1062
+		} else {
989 1063
 			print '<div id="chart5" class="chart" width="100%"></div><script>';
990 1064
 			$date_data = '';
991 1065
 			$date_cnt = '';
@@ -1012,8 +1086,9 @@  discard block
 block discarded – undo
1012 1086
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
1013 1087
 <?php
1014 1088
 		$hour_array = $Marine->countAllHours('hour',true,$airline_icao,$filter_name);
1015
-		if (empty($hour_array)) print _("No data available");
1016
-		else {
1089
+		if (empty($hour_array)) {
1090
+			print _("No data available");
1091
+		} else {
1017 1092
 			print '<div id="chart6" class="chart" width="100%"></div><script>';
1018 1093
 			$hour_data = '';
1019 1094
 			$hour_cnt = '';
@@ -1052,8 +1127,9 @@  discard block
 block discarded – undo
1052 1127
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
1053 1128
 <?php
1054 1129
 		$year_array = $Tracker->countAllMonthsLastYear(true);
1055
-		if (count($year_array) == 0) print _("No data available");
1056
-		else {
1130
+		if (count($year_array) == 0) {
1131
+			print _("No data available");
1132
+		} else {
1057 1133
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
1058 1134
 			$year_data = '';
1059 1135
 			$year_cnt = '';
@@ -1081,8 +1157,9 @@  discard block
 block discarded – undo
1081 1157
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
1082 1158
 <?php
1083 1159
 		$month_array = $Tracker->countAllDatesLastMonth();
1084
-		if (count($month_array) == 0) print _("No data available");
1085
-		else {
1160
+		if (count($month_array) == 0) {
1161
+			print _("No data available");
1162
+		} else {
1086 1163
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
1087 1164
 			$month_data = '';
1088 1165
 			$month_cnt = '';
@@ -1110,8 +1187,9 @@  discard block
 block discarded – undo
1110 1187
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
1111 1188
 <?php
1112 1189
 		$date_array = $Tracker->countAllDatesLast7Days();
1113
-		if (empty($date_array)) print _("No data available");
1114
-		else {
1190
+		if (empty($date_array)) {
1191
+			print _("No data available");
1192
+		} else {
1115 1193
 			print '<div id="chart5" class="chart" width="100%"></div><script>';
1116 1194
 			$date_data = '';
1117 1195
 			$date_cnt = '';
@@ -1138,8 +1216,9 @@  discard block
 block discarded – undo
1138 1216
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
1139 1217
 <?php
1140 1218
 		$hour_array = $Tracker->countAllHours('hour',true);
1141
-		if (empty($hour_array)) print _("No data available");
1142
-		else {
1219
+		if (empty($hour_array)) {
1220
+			print _("No data available");
1221
+		} else {
1143 1222
 			print '<div id="chart6" class="chart" width="100%"></div><script>';
1144 1223
 			$hour_data = '';
1145 1224
 			$hour_cnt = '';
@@ -1178,8 +1257,9 @@  discard block
 block discarded – undo
1178 1257
                 <h2><?php echo _("Busiest Launch Months of the last 12 Months"); ?></h2>
1179 1258
 <?php
1180 1259
 		$year_array = $Satellite->countAllMonthsLastYear();
1181
-		if (count($year_array) == 0) print _("No data available");
1182
-		else {
1260
+		if (count($year_array) == 0) {
1261
+			print _("No data available");
1262
+		} else {
1183 1263
 			print '<div id="chart21" class="chart" width="100%"></div><script>';
1184 1264
 			$year_data = '';
1185 1265
 			$year_cnt = '';
@@ -1209,8 +1289,9 @@  discard block
 block discarded – undo
1209 1289
                 <h2><?php echo _("Busiest Launch Years of the last 10 Years"); ?></h2>
1210 1290
 <?php
1211 1291
 		$year_array = $Satellite->countAllYears();
1212
-		if (count($year_array) == 0) print _("No data available");
1213
-		else {
1292
+		if (count($year_array) == 0) {
1293
+			print _("No data available");
1294
+		} else {
1214 1295
 			print '<div id="chart22" class="chart" width="100%"></div><script>';
1215 1296
 			$year_data = '';
1216 1297
 			$year_cnt = '';
@@ -1252,8 +1333,9 @@  discard block
 block discarded – undo
1252 1333
                 <h2><?php echo _("Fatalities by Years"); ?></h2>
1253 1334
 <?php
1254 1335
 		$year_array = $Stats->countFatalitiesByYear();
1255
-		if (count($year_array) == 0) print _("No data available");
1256
-		else {
1336
+		if (count($year_array) == 0) {
1337
+			print _("No data available");
1338
+		} else {
1257 1339
 			print '<div id="chart32" class="chart" width="100%"></div><script>';
1258 1340
 			$year_data = '';
1259 1341
 			$year_cnt = '';
@@ -1282,8 +1364,9 @@  discard block
 block discarded – undo
1282 1364
                 <h2><?php echo _("Fatalities last 12 Months"); ?></h2>
1283 1365
 <?php
1284 1366
 		$year_array = $Stats->countFatalitiesLast12Months();
1285
-		if (count($year_array) == 0) print _("No data available");
1286
-		else {
1367
+		if (count($year_array) == 0) {
1368
+			print _("No data available");
1369
+		} else {
1287 1370
 			print '<div id="chart33" class="chart" width="100%"></div><script>';
1288 1371
 			$year_data = '';
1289 1372
 			$year_cnt = '';
@@ -1354,8 +1437,11 @@  discard block
 block discarded – undo
1354 1437
 					$distance = $distance;
1355 1438
 					$unit = 'km';
1356 1439
 				}
1357
-				if (!isset($polar_data)) $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1358
-				else $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1440
+				if (!isset($polar_data)) {
1441
+					$polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1442
+				} else {
1443
+					$polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1444
+				}
1359 1445
 			}
1360 1446
 ?>
1361 1447
             <div class="col-md-6">
@@ -1419,9 +1505,12 @@  discard block
 block discarded – undo
1419 1505
 		foreach ($msg as $eachmsg) {
1420 1506
 			//$eachmsg = $msg[0];
1421 1507
 			$data = $eachmsg['source_data'];
1422
-			if ($data > 500) $max = (round(($data+100)/100))*100;
1423
-			else $max = 500;
1424
-?>
1508
+			if ($data > 500) {
1509
+				$max = (round(($data+100)/100))*100;
1510
+			} else {
1511
+				$max = 500;
1512
+			}
1513
+			?>
1425 1514
         	<div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
1426 1515
         	<script>
1427 1516
 		      var g = new JustGage({
Please login to merge, or discard this patch.
install/class.update_schema.php 1 patch
Braces   +468 added lines, -172 removed lines patch added patch discarded remove patch
@@ -258,7 +258,9 @@  discard block
 block discarded – undo
258 258
     		// Update table countries
259 259
     		if ($Connection->tableExists('airspace')) {
260 260
     		    $error .= update_db::update_countries();
261
-		    if ($error != '') return $error;
261
+		    if ($error != '') {
262
+		    	return $error;
263
+		    }
262 264
 		}
263 265
 		// Update schema_version to 7
264 266
 		$query = "UPDATE `config` SET `value` = '7' WHERE `name` = 'schema_version'";
@@ -314,7 +316,9 @@  discard block
 block discarded – undo
314 316
     		$error = '';
315 317
     		// Update table aircraft
316 318
 		$error .= create_db::import_file('../db/source_location.sql');
317
-		if ($error != '') return $error;
319
+		if ($error != '') {
320
+			return $error;
321
+		}
318 322
 		// Update schema_version to 6
319 323
 		$query = "UPDATE `config` SET `value` = '8' WHERE `name` = 'schema_version'";
320 324
         	try {
@@ -331,7 +335,9 @@  discard block
 block discarded – undo
331 335
     		$error = '';
332 336
     		// Update table aircraft
333 337
 		$error .= create_db::import_file('../db/notam.sql');
334
-		if ($error != '') return $error;
338
+		if ($error != '') {
339
+			return $error;
340
+		}
335 341
 		$query = "DELETE FROM config WHERE name = 'last_update_db';
336 342
                         INSERT INTO config (name,value) VALUES ('last_update_db',NOW());
337 343
                         DELETE FROM config WHERE name = 'last_update_notam_db';
@@ -365,7 +371,9 @@  discard block
 block discarded – undo
365 371
 		$error = '';
366 372
     		// Update table atc
367 373
 		$error .= create_db::import_file('../db/atc.sql');
368
-		if ($error != '') return $error;
374
+		if ($error != '') {
375
+			return $error;
376
+		}
369 377
 		
370 378
 		$query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'";
371 379
         	try {
@@ -389,13 +397,21 @@  discard block
 block discarded – undo
389 397
 		$error = '';
390 398
     		// Add tables
391 399
 		$error .= create_db::import_file('../db/aircraft_owner.sql');
392
-		if ($error != '') return $error;
400
+		if ($error != '') {
401
+			return $error;
402
+		}
393 403
 		$error .= create_db::import_file('../db/metar.sql');
394
-		if ($error != '') return $error;
404
+		if ($error != '') {
405
+			return $error;
406
+		}
395 407
 		$error .= create_db::import_file('../db/taf.sql');
396
-		if ($error != '') return $error;
408
+		if ($error != '') {
409
+			return $error;
410
+		}
397 411
 		$error .= create_db::import_file('../db/airport.sql');
398
-		if ($error != '') return $error;
412
+		if ($error != '') {
413
+			return $error;
414
+		}
399 415
 		
400 416
 		$query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'";
401 417
         	try {
@@ -469,19 +485,33 @@  discard block
 block discarded – undo
469 485
 		$error = '';
470 486
     		// Add tables
471 487
 		$error .= create_db::import_file('../db/stats.sql');
472
-		if ($error != '') return $error;
488
+		if ($error != '') {
489
+			return $error;
490
+		}
473 491
 		$error .= create_db::import_file('../db/stats_aircraft.sql');
474
-		if ($error != '') return $error;
492
+		if ($error != '') {
493
+			return $error;
494
+		}
475 495
 		$error .= create_db::import_file('../db/stats_airline.sql');
476
-		if ($error != '') return $error;
496
+		if ($error != '') {
497
+			return $error;
498
+		}
477 499
 		$error .= create_db::import_file('../db/stats_airport.sql');
478
-		if ($error != '') return $error;
500
+		if ($error != '') {
501
+			return $error;
502
+		}
479 503
 		$error .= create_db::import_file('../db/stats_owner.sql');
480
-		if ($error != '') return $error;
504
+		if ($error != '') {
505
+			return $error;
506
+		}
481 507
 		$error .= create_db::import_file('../db/stats_pilot.sql');
482
-		if ($error != '') return $error;
508
+		if ($error != '') {
509
+			return $error;
510
+		}
483 511
 		$error .= create_db::import_file('../db/spotter_archive_output.sql');
484
-		if ($error != '') return $error;
512
+		if ($error != '') {
513
+			return $error;
514
+		}
485 515
 		
486 516
 		$query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'";
487 517
         	try {
@@ -521,7 +551,9 @@  discard block
 block discarded – undo
521 551
     		// Add tables
522 552
     		if (!$Connection->tableExists('stats_flight')) {
523 553
 			$error .= create_db::import_file('../db/stats_flight.sql');
524
-			if ($error != '') return $error;
554
+			if ($error != '') {
555
+				return $error;
556
+			}
525 557
 		}
526 558
 		$query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'";
527 559
         	try {
@@ -545,7 +577,9 @@  discard block
 block discarded – undo
545 577
     		} catch(PDOException $e) {
546 578
 		    return "error (update stats) : ".$e->getMessage()."\n";
547 579
     		}
548
-		if ($error != '') return $error;
580
+		if ($error != '') {
581
+			return $error;
582
+		}
549 583
 		$query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'";
550 584
         	try {
551 585
             	    $sth = $Connection->db->prepare($query);
@@ -566,7 +600,9 @@  discard block
 block discarded – undo
566 600
     		if (!$Connection->tableExists('stats_callsign')) {
567 601
 			$error .= create_db::import_file('../db/stats_callsign.sql');
568 602
 		}
569
-		if ($error != '') return $error;
603
+		if ($error != '') {
604
+			return $error;
605
+		}
570 606
 		$query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'";
571 607
         	try {
572 608
             	    $sth = $Connection->db->prepare($query);
@@ -584,7 +620,9 @@  discard block
 block discarded – undo
584 620
     		if (!$Connection->tableExists('stats_country')) {
585 621
 			$error .= create_db::import_file('../db/stats_country.sql');
586 622
 		}
587
-		if ($error != '') return $error;
623
+		if ($error != '') {
624
+			return $error;
625
+		}
588 626
 		$query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'";
589 627
         	try {
590 628
             	    $sth = $Connection->db->prepare($query);
@@ -607,7 +645,9 @@  discard block
 block discarded – undo
607 645
 			    return "error (update stats) : ".$e->getMessage()."\n";
608 646
     			}
609 647
     		}
610
-		if ($error != '') return $error;
648
+		if ($error != '') {
649
+			return $error;
650
+		}
611 651
 		$query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'";
612 652
         	try {
613 653
             	    $sth = $Connection->db->prepare($query);
@@ -623,7 +663,9 @@  discard block
 block discarded – undo
623 663
 		$error = '';
624 664
     		// Update airport table
625 665
 		$error .= create_db::import_file('../db/airport.sql');
626
-		if ($error != '') return 'Import airport.sql : '.$error;
666
+		if ($error != '') {
667
+			return 'Import airport.sql : '.$error;
668
+		}
627 669
 		// Remove primary key on Spotter_Archive
628 670
 		$query = "alter table spotter_archive drop spotter_archive_id";
629 671
         	try {
@@ -699,7 +741,9 @@  discard block
 block discarded – undo
699 741
 				return "error (add source_name column) : ".$e->getMessage()."\n";
700 742
     			}
701 743
     		}
702
-		if ($error != '') return $error;
744
+		if ($error != '') {
745
+			return $error;
746
+		}
703 747
 		$query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'";
704 748
         	try {
705 749
             	    $sth = $Connection->db->prepare($query);
@@ -717,7 +761,9 @@  discard block
 block discarded – undo
717 761
     		// Update airline table
718 762
     		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
719 763
 			$error .= create_db::import_file('../db/airlines.sql');
720
-			if ($error != '') return 'Import airlines.sql : '.$error;
764
+			if ($error != '') {
765
+				return 'Import airlines.sql : '.$error;
766
+			}
721 767
 		}
722 768
 		if (!$Connection->checkColumnName('aircraft_modes','type_flight')) {
723 769
 			// Add column over_country
@@ -729,7 +775,9 @@  discard block
 block discarded – undo
729 775
 				return "error (add over_country) : ".$e->getMessage()."\n";
730 776
     			}
731 777
     		}
732
-		if ($error != '') return $error;
778
+		if ($error != '') {
779
+			return $error;
780
+		}
733 781
 		/*
734 782
     		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
735 783
 			// Force update ModeS (this will put type_flight data
@@ -759,7 +807,9 @@  discard block
 block discarded – undo
759 807
 			} catch(PDOException $e) {
760 808
 				return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n";
761 809
 			}
762
-			if ($error != '') return $error;
810
+			if ($error != '') {
811
+				return $error;
812
+			}
763 813
 		}
764 814
 		$query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'";
765 815
         	try {
@@ -782,7 +832,9 @@  discard block
 block discarded – undo
782 832
 			} else {
783 833
 				$error .= create_db::import_file('../db/pgsql/stats_source.sql');
784 834
 			}
785
-			if ($error != '') return $error;
835
+			if ($error != '') {
836
+				return $error;
837
+			}
786 838
 		}
787 839
 		$query = "UPDATE config SET value = '23' WHERE name = 'schema_version'";
788 840
         	try {
@@ -803,12 +855,16 @@  discard block
 block discarded – undo
803 855
 		if ($globalDBdriver == 'mysql') {
804 856
 			if (!$Connection->tableExists('tle')) {
805 857
 				$error .= create_db::import_file('../db/tle.sql');
806
-				if ($error != '') return $error;
858
+				if ($error != '') {
859
+					return $error;
860
+				}
807 861
 			}
808 862
 		} else {
809 863
 			if (!$Connection->tableExists('tle')) {
810 864
 				$error .= create_db::import_file('../db/pgsql/tle.sql');
811
-				if ($error != '') return $error;
865
+				if ($error != '') {
866
+					return $error;
867
+				}
812 868
 			}
813 869
 			$query = "create index flightaware_id_idx ON spotter_archive USING btree(flightaware_id)";
814 870
 			try {
@@ -848,7 +904,9 @@  discard block
 block discarded – undo
848 904
 		} else {
849 905
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
850 906
 		}
851
-		if ($error != '') return 'Import airlines.sql : '.$error;
907
+		if ($error != '') {
908
+			return 'Import airlines.sql : '.$error;
909
+		}
852 910
 		if (!$Connection->checkColumnName('airlines','forsource')) {
853 911
 			// Add forsource to airlines
854 912
 			$query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL";
@@ -1331,20 +1389,28 @@  discard block
 block discarded – undo
1331 1389
 		}
1332 1390
 		if ($globalDBdriver == 'mysql') {
1333 1391
 			$error .= create_db::import_file('../db/airlines.sql');
1334
-			if ($error != '') return $error;
1392
+			if ($error != '') {
1393
+				return $error;
1394
+			}
1335 1395
 		} else {
1336 1396
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
1337
-			if ($error != '') return $error;
1397
+			if ($error != '') {
1398
+				return $error;
1399
+			}
1338 1400
 		}
1339 1401
 		if ((isset($globalVATSIM) && $globalVATSIM) || (isset($globalIVAO) && $globalIVAO)) {
1340 1402
 			include_once(dirname(__FILE__).'/class.update_db.php');
1341 1403
 			if (isset($globalVATSIM) && $globalVATSIM) {
1342 1404
 				$error .= update_db::update_vatsim();
1343
-				if ($error != '') return $error;
1405
+				if ($error != '') {
1406
+					return $error;
1407
+				}
1344 1408
 			}
1345 1409
 			if (isset($globalIVAO) && $globalIVAO && file_exists('tmp/ivae_feb2013.zip')) {
1346 1410
 				$error .= update_db::update_IVAO();
1347
-				if ($error != '') return $error;
1411
+				if ($error != '') {
1412
+					return $error;
1413
+				}
1348 1414
 			}
1349 1415
 		}
1350 1416
 
@@ -1607,41 +1673,65 @@  discard block
 block discarded – undo
1607 1673
 		if ($globalDBdriver == 'mysql') {
1608 1674
 			if (!$Connection->tableExists('tracker_output')) {
1609 1675
 				$error .= create_db::import_file('../db/tracker_output.sql');
1610
-				if ($error != '') return $error;
1676
+				if ($error != '') {
1677
+					return $error;
1678
+				}
1611 1679
 			}
1612 1680
 			if (!$Connection->tableExists('tracker_live')) {
1613 1681
 				$error .= create_db::import_file('../db/tracker_live.sql');
1614
-				if ($error != '') return $error;
1682
+				if ($error != '') {
1683
+					return $error;
1684
+				}
1615 1685
 			}
1616 1686
 			if (!$Connection->tableExists('marine_output')) {
1617 1687
 				$error .= create_db::import_file('../db/marine_output.sql');
1618
-				if ($error != '') return $error;
1688
+				if ($error != '') {
1689
+					return $error;
1690
+				}
1619 1691
 			}
1620 1692
 			if (!$Connection->tableExists('marine_live')) {
1621 1693
 				$error .= create_db::import_file('../db/marine_live.sql');
1622
-				if ($error != '') return $error;
1694
+				if ($error != '') {
1695
+					return $error;
1696
+				}
1623 1697
 			}
1624 1698
 			if (!$Connection->tableExists('marine_identity')) {
1625 1699
 				$error .= create_db::import_file('../db/marine_identity.sql');
1626
-				if ($error != '') return $error;
1700
+				if ($error != '') {
1701
+					return $error;
1702
+				}
1627 1703
 			}
1628 1704
 			if (!$Connection->tableExists('marine_mid')) {
1629 1705
 				$error .= create_db::import_file('../db/marine_mid.sql');
1630
-				if ($error != '') return $error;
1706
+				if ($error != '') {
1707
+					return $error;
1708
+				}
1631 1709
 			}
1632 1710
 		} else {
1633 1711
 			$error .= create_db::import_file('../db/pgsql/tracker_output.sql');
1634
-			if ($error != '') return $error;
1712
+			if ($error != '') {
1713
+				return $error;
1714
+			}
1635 1715
 			$error .= create_db::import_file('../db/pgsql/tracker_live.sql');
1636
-			if ($error != '') return $error;
1716
+			if ($error != '') {
1717
+				return $error;
1718
+			}
1637 1719
 			$error .= create_db::import_file('../db/pgsql/marine_output.sql');
1638
-			if ($error != '') return $error;
1720
+			if ($error != '') {
1721
+				return $error;
1722
+			}
1639 1723
 			$error .= create_db::import_file('../db/pgsql/marine_live.sql');
1640
-			if ($error != '') return $error;
1724
+			if ($error != '') {
1725
+				return $error;
1726
+			}
1641 1727
 			$error .= create_db::import_file('../db/pgsql/marine_identity.sql');
1642
-			if ($error != '') return $error;
1728
+			if ($error != '') {
1729
+				return $error;
1730
+			}
1643 1731
 			$error .= create_db::import_file('../db/pgsql/marine_mid.sql');
1644
-			if ($error != '') return $error;
1732
+			if ($error != '') {
1733
+				return $error;
1734
+			}
1645 1735
 		}
1646 1736
 		$query = "UPDATE config SET value = '37' WHERE name = 'schema_version'";
1647 1737
 		try {
@@ -1660,39 +1750,61 @@  discard block
 block discarded – undo
1660 1750
 		if ($globalDBdriver == 'mysql') {
1661 1751
 			if (!$Connection->tableExists('marine_image')) {
1662 1752
 				$error .= create_db::import_file('../db/marine_image.sql');
1663
-				if ($error != '') return $error;
1753
+				if ($error != '') {
1754
+					return $error;
1755
+				}
1664 1756
 			}
1665 1757
 			if (!$Connection->tableExists('marine_archive')) {
1666 1758
 				$error .= create_db::import_file('../db/marine_archive.sql');
1667
-				if ($error != '') return $error;
1759
+				if ($error != '') {
1760
+					return $error;
1761
+				}
1668 1762
 			}
1669 1763
 			if (!$Connection->tableExists('marine_archive_output')) {
1670 1764
 				$error .= create_db::import_file('../db/marine_archive_output.sql');
1671
-				if ($error != '') return $error;
1765
+				if ($error != '') {
1766
+					return $error;
1767
+				}
1672 1768
 			}
1673 1769
 			if (!$Connection->tableExists('tracker_archive')) {
1674 1770
 				$error .= create_db::import_file('../db/tracker_archive.sql');
1675
-				if ($error != '') return $error;
1771
+				if ($error != '') {
1772
+					return $error;
1773
+				}
1676 1774
 			}
1677 1775
 			if (!$Connection->tableExists('tracker_archive_output')) {
1678 1776
 				$error .= create_db::import_file('../db/tracker_archive_output.sql');
1679
-				if ($error != '') return $error;
1777
+				if ($error != '') {
1778
+					return $error;
1779
+				}
1680 1780
 			}
1681 1781
 			if (!$Connection->tableExists('marine_archive_output')) {
1682 1782
 				$error .= create_db::import_file('../db/tracker_archive_output.sql');
1683
-				if ($error != '') return $error;
1783
+				if ($error != '') {
1784
+					return $error;
1785
+				}
1684 1786
 			}
1685 1787
 		} else {
1686 1788
 			$error .= create_db::import_file('../db/pgsql/marine_image.sql');
1687
-			if ($error != '') return $error;
1789
+			if ($error != '') {
1790
+				return $error;
1791
+			}
1688 1792
 			$error .= create_db::import_file('../db/pgsql/marine_archive.sql');
1689
-			if ($error != '') return $error;
1793
+			if ($error != '') {
1794
+				return $error;
1795
+			}
1690 1796
 			$error .= create_db::import_file('../db/pgsql/marine_archive_output.sql');
1691
-			if ($error != '') return $error;
1797
+			if ($error != '') {
1798
+				return $error;
1799
+			}
1692 1800
 			$error .= create_db::import_file('../db/pgsql/tracker_archive.sql');
1693
-			if ($error != '') return $error;
1801
+			if ($error != '') {
1802
+				return $error;
1803
+			}
1694 1804
 			$error .= create_db::import_file('../db/pgsql/tracker_archive_output.sql');
1695
-			if ($error != '') return $error;
1805
+			if ($error != '') {
1806
+				return $error;
1807
+			}
1696 1808
 		}
1697 1809
 		if ($globalDBdriver == 'mysql') {
1698 1810
 			$query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
@@ -2063,7 +2175,9 @@  discard block
 block discarded – undo
2063 2175
 		if ($globalDBdriver == 'mysql') {
2064 2176
 			if (!$Connection->tableExists('tracker_archive_output')) {
2065 2177
 				$error .= create_db::import_file('../db/tracker_archive_output.sql');
2066
-				if ($error != '') return $error;
2178
+				if ($error != '') {
2179
+					return $error;
2180
+				}
2067 2181
 			}
2068 2182
 			$query = "ALTER TABLE tracker_live MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN last_altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_archive MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_archive_output MODIFY COLUMN last_altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN altitude float DEFAULT NULL;";
2069 2183
 		} else {
@@ -2091,14 +2205,22 @@  discard block
 block discarded – undo
2091 2205
 		$error = '';
2092 2206
 		if ($globalDBdriver == 'mysql') {
2093 2207
 			$error .= create_db::import_file('../db/airport.sql');
2094
-			if ($error != '') return $error;
2208
+			if ($error != '') {
2209
+				return $error;
2210
+			}
2095 2211
 			$error .= create_db::import_file('../db/airlines.sql');
2096
-			if ($error != '') return $error;
2212
+			if ($error != '') {
2213
+				return $error;
2214
+			}
2097 2215
 		} else {
2098 2216
 			$error .= create_db::import_file('../db/pgsql/airport.sql');
2099
-			if ($error != '') return $error;
2217
+			if ($error != '') {
2218
+				return $error;
2219
+			}
2100 2220
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
2101
-			if ($error != '') return $error;
2221
+			if ($error != '') {
2222
+				return $error;
2223
+			}
2102 2224
 		}
2103 2225
 		if ((isset($globalVATSIM) && $globalVATSIM) && (isset($globalIVAO) && $globalIVAO)) {
2104 2226
 			if (file_exists('tmp/ivae_feb2013.zip')) {
@@ -2115,7 +2237,9 @@  discard block
 block discarded – undo
2115 2237
 				$error .= update_db::update_vatsim();
2116 2238
 			}
2117 2239
 		}
2118
-		if ($error != '') return $error;
2240
+		if ($error != '') {
2241
+			return $error;
2242
+		}
2119 2243
 		$query = "UPDATE config SET value = '45' WHERE name = 'schema_version'";
2120 2244
 		try {
2121 2245
 			$sth = $Connection->db->prepare($query);
@@ -2133,10 +2257,14 @@  discard block
 block discarded – undo
2133 2257
 		if (!$Connection->tableExists('satellite')) {
2134 2258
 			if ($globalDBdriver == 'mysql') {
2135 2259
 				$error .= create_db::import_file('../db/satellite.sql');
2136
-				if ($error != '') return $error;
2260
+				if ($error != '') {
2261
+					return $error;
2262
+				}
2137 2263
 			} else {
2138 2264
 				$error .= create_db::import_file('../db/pgsql/satellite.sql');
2139
-				if ($error != '') return $error;
2265
+				if ($error != '') {
2266
+					return $error;
2267
+				}
2140 2268
 			}
2141 2269
 		}
2142 2270
 		$query = "UPDATE config SET value = '46' WHERE name = 'schema_version'";
@@ -2156,37 +2284,53 @@  discard block
 block discarded – undo
2156 2284
 		if (!$Connection->tableExists('stats_marine')) {
2157 2285
 			if ($globalDBdriver == 'mysql') {
2158 2286
 				$error .= create_db::import_file('../db/stats_marine.sql');
2159
-				if ($error != '') return $error;
2287
+				if ($error != '') {
2288
+					return $error;
2289
+				}
2160 2290
 			} else {
2161 2291
 				$error .= create_db::import_file('../db/pgsql/stats_marine.sql');
2162
-				if ($error != '') return $error;
2292
+				if ($error != '') {
2293
+					return $error;
2294
+				}
2163 2295
 			}
2164 2296
 		}
2165 2297
 		if (!$Connection->tableExists('stats_marine_country')) {
2166 2298
 			if ($globalDBdriver == 'mysql') {
2167 2299
 				$error .= create_db::import_file('../db/stats_marine_country.sql');
2168
-				if ($error != '') return $error;
2300
+				if ($error != '') {
2301
+					return $error;
2302
+				}
2169 2303
 			} else {
2170 2304
 				$error .= create_db::import_file('../db/pgsql/stats_marine_country.sql');
2171
-				if ($error != '') return $error;
2305
+				if ($error != '') {
2306
+					return $error;
2307
+				}
2172 2308
 			}
2173 2309
 		}
2174 2310
 		if (!$Connection->tableExists('stats_tracker')) {
2175 2311
 			if ($globalDBdriver == 'mysql') {
2176 2312
 				$error .= create_db::import_file('../db/stats_tracker.sql');
2177
-				if ($error != '') return $error;
2313
+				if ($error != '') {
2314
+					return $error;
2315
+				}
2178 2316
 			} else {
2179 2317
 				$error .= create_db::import_file('../db/pgsql/stats_tracker.sql');
2180
-				if ($error != '') return $error;
2318
+				if ($error != '') {
2319
+					return $error;
2320
+				}
2181 2321
 			}
2182 2322
 		}
2183 2323
 		if (!$Connection->tableExists('stats_tracker_country')) {
2184 2324
 			if ($globalDBdriver == 'mysql') {
2185 2325
 				$error .= create_db::import_file('../db/stats_tracker_country.sql');
2186
-				if ($error != '') return $error;
2326
+				if ($error != '') {
2327
+					return $error;
2328
+				}
2187 2329
 			} else {
2188 2330
 				$error .= create_db::import_file('../db/pgsql/stats_tracker_country.sql');
2189
-				if ($error != '') return $error;
2331
+				if ($error != '') {
2332
+					return $error;
2333
+				}
2190 2334
 			}
2191 2335
 		}
2192 2336
 		$query = "UPDATE config SET value = '47' WHERE name = 'schema_version'";
@@ -2206,10 +2350,14 @@  discard block
 block discarded – undo
2206 2350
 		if (!$Connection->tableExists('stats_marine_type')) {
2207 2351
 			if ($globalDBdriver == 'mysql') {
2208 2352
 				$error .= create_db::import_file('../db/stats_marine_type.sql');
2209
-				if ($error != '') return $error;
2353
+				if ($error != '') {
2354
+					return $error;
2355
+				}
2210 2356
 			} else {
2211 2357
 				$error .= create_db::import_file('../db/pgsql/stats_marine_type.sql');
2212
-				if ($error != '') return $error;
2358
+				if ($error != '') {
2359
+					return $error;
2360
+				}
2213 2361
 			}
2214 2362
 		}
2215 2363
 		$query = "UPDATE config SET value = '48' WHERE name = 'schema_version'";
@@ -2232,8 +2380,11 @@  discard block
 block discarded – undo
2232 2380
 			if ($Connection->tableExists('aircraft')) {
2233 2381
 				if (!$Connection->tableExists('config')) {
2234 2382
 					$version = '1';
2235
-					if ($update) return self::update_from_1();
2236
-					else return $version;
2383
+					if ($update) {
2384
+						return self::update_from_1();
2385
+					} else {
2386
+						return $version;
2387
+					}
2237 2388
 				} else {
2238 2389
 					$query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
2239 2390
 					try {
@@ -2246,195 +2397,340 @@  discard block
 block discarded – undo
2246 2397
 					if ($update) {
2247 2398
 						if ($result['value'] == '2') {
2248 2399
 							$error = self::update_from_2();
2249
-							if ($error != '') return $error;
2250
-							else return self::check_version(true);
2400
+							if ($error != '') {
2401
+								return $error;
2402
+							} else {
2403
+								return self::check_version(true);
2404
+							}
2251 2405
 						} elseif ($result['value'] == '3') {
2252 2406
 							$error = self::update_from_3();
2253
-							if ($error != '') return $error;
2254
-							else return self::check_version(true);
2407
+							if ($error != '') {
2408
+								return $error;
2409
+							} else {
2410
+								return self::check_version(true);
2411
+							}
2255 2412
 						} elseif ($result['value'] == '4') {
2256 2413
 							$error = self::update_from_4();
2257
-							if ($error != '') return $error;
2258
-							else return self::check_version(true);
2414
+							if ($error != '') {
2415
+								return $error;
2416
+							} else {
2417
+								return self::check_version(true);
2418
+							}
2259 2419
 						} elseif ($result['value'] == '5') {
2260 2420
 							$error = self::update_from_5();
2261
-							if ($error != '') return $error;
2262
-							else return self::check_version(true);
2421
+							if ($error != '') {
2422
+								return $error;
2423
+							} else {
2424
+								return self::check_version(true);
2425
+							}
2263 2426
 						} elseif ($result['value'] == '6') {
2264 2427
 							$error = self::update_from_6();
2265
-							if ($error != '') return $error;
2266
-							else return self::check_version(true);
2428
+							if ($error != '') {
2429
+								return $error;
2430
+							} else {
2431
+								return self::check_version(true);
2432
+							}
2267 2433
 						} elseif ($result['value'] == '7') {
2268 2434
 							$error = self::update_from_7();
2269
-							if ($error != '') return $error;
2270
-							else return self::check_version(true);
2435
+							if ($error != '') {
2436
+								return $error;
2437
+							} else {
2438
+								return self::check_version(true);
2439
+							}
2271 2440
 						} elseif ($result['value'] == '8') {
2272 2441
 							$error = self::update_from_8();
2273
-							if ($error != '') return $error;
2274
-							else return self::check_version(true);
2442
+							if ($error != '') {
2443
+								return $error;
2444
+							} else {
2445
+								return self::check_version(true);
2446
+							}
2275 2447
 						} elseif ($result['value'] == '9') {
2276 2448
 							$error = self::update_from_9();
2277
-							if ($error != '') return $error;
2278
-							else return self::check_version(true);
2449
+							if ($error != '') {
2450
+								return $error;
2451
+							} else {
2452
+								return self::check_version(true);
2453
+							}
2279 2454
 						} elseif ($result['value'] == '10') {
2280 2455
 							$error = self::update_from_10();
2281
-							if ($error != '') return $error;
2282
-							else return self::check_version(true);
2456
+							if ($error != '') {
2457
+								return $error;
2458
+							} else {
2459
+								return self::check_version(true);
2460
+							}
2283 2461
 						} elseif ($result['value'] == '11') {
2284 2462
 							$error = self::update_from_11();
2285
-							if ($error != '') return $error;
2286
-							else return self::check_version(true);
2463
+							if ($error != '') {
2464
+								return $error;
2465
+							} else {
2466
+								return self::check_version(true);
2467
+							}
2287 2468
 						} elseif ($result['value'] == '12') {
2288 2469
 							$error = self::update_from_12();
2289
-							if ($error != '') return $error;
2290
-							else return self::check_version(true);
2470
+							if ($error != '') {
2471
+								return $error;
2472
+							} else {
2473
+								return self::check_version(true);
2474
+							}
2291 2475
 						} elseif ($result['value'] == '13') {
2292 2476
 							$error = self::update_from_13();
2293
-							if ($error != '') return $error;
2294
-							else return self::check_version(true);
2477
+							if ($error != '') {
2478
+								return $error;
2479
+							} else {
2480
+								return self::check_version(true);
2481
+							}
2295 2482
 						} elseif ($result['value'] == '14') {
2296 2483
 							$error = self::update_from_14();
2297
-							if ($error != '') return $error;
2298
-							else return self::check_version(true);
2484
+							if ($error != '') {
2485
+								return $error;
2486
+							} else {
2487
+								return self::check_version(true);
2488
+							}
2299 2489
 						} elseif ($result['value'] == '15') {
2300 2490
 							$error = self::update_from_15();
2301
-							if ($error != '') return $error;
2302
-							else return self::check_version(true);
2491
+							if ($error != '') {
2492
+								return $error;
2493
+							} else {
2494
+								return self::check_version(true);
2495
+							}
2303 2496
 						} elseif ($result['value'] == '16') {
2304 2497
 							$error = self::update_from_16();
2305
-							if ($error != '') return $error;
2306
-							else return self::check_version(true);
2498
+							if ($error != '') {
2499
+								return $error;
2500
+							} else {
2501
+								return self::check_version(true);
2502
+							}
2307 2503
 						} elseif ($result['value'] == '17') {
2308 2504
 							$error = self::update_from_17();
2309
-							if ($error != '') return $error;
2310
-							else return self::check_version(true);
2505
+							if ($error != '') {
2506
+								return $error;
2507
+							} else {
2508
+								return self::check_version(true);
2509
+							}
2311 2510
 						} elseif ($result['value'] == '18') {
2312 2511
 							$error = self::update_from_18();
2313
-							if ($error != '') return $error;
2314
-							else return self::check_version(true);
2512
+							if ($error != '') {
2513
+								return $error;
2514
+							} else {
2515
+								return self::check_version(true);
2516
+							}
2315 2517
 						} elseif ($result['value'] == '19') {
2316 2518
 							$error = self::update_from_19();
2317
-							if ($error != '') return $error;
2318
-							else return self::check_version(true);
2519
+							if ($error != '') {
2520
+								return $error;
2521
+							} else {
2522
+								return self::check_version(true);
2523
+							}
2319 2524
 						} elseif ($result['value'] == '20') {
2320 2525
 							$error = self::update_from_20();
2321
-							if ($error != '') return $error;
2322
-							else return self::check_version(true);
2526
+							if ($error != '') {
2527
+								return $error;
2528
+							} else {
2529
+								return self::check_version(true);
2530
+							}
2323 2531
 						} elseif ($result['value'] == '21') {
2324 2532
 							$error = self::update_from_21();
2325
-							if ($error != '') return $error;
2326
-							else return self::check_version(true);
2533
+							if ($error != '') {
2534
+								return $error;
2535
+							} else {
2536
+								return self::check_version(true);
2537
+							}
2327 2538
 						} elseif ($result['value'] == '22') {
2328 2539
 							$error = self::update_from_22();
2329
-							if ($error != '') return $error;
2330
-							else return self::check_version(true);
2540
+							if ($error != '') {
2541
+								return $error;
2542
+							} else {
2543
+								return self::check_version(true);
2544
+							}
2331 2545
 						} elseif ($result['value'] == '23') {
2332 2546
 							$error = self::update_from_23();
2333
-							if ($error != '') return $error;
2334
-							else return self::check_version(true);
2547
+							if ($error != '') {
2548
+								return $error;
2549
+							} else {
2550
+								return self::check_version(true);
2551
+							}
2335 2552
 						} elseif ($result['value'] == '24') {
2336 2553
 							$error = self::update_from_24();
2337
-							if ($error != '') return $error;
2338
-							else return self::check_version(true);
2554
+							if ($error != '') {
2555
+								return $error;
2556
+							} else {
2557
+								return self::check_version(true);
2558
+							}
2339 2559
 						} elseif ($result['value'] == '25') {
2340 2560
 							$error = self::update_from_25();
2341
-							if ($error != '') return $error;
2342
-							else return self::check_version(true);
2561
+							if ($error != '') {
2562
+								return $error;
2563
+							} else {
2564
+								return self::check_version(true);
2565
+							}
2343 2566
 						} elseif ($result['value'] == '26') {
2344 2567
 							$error = self::update_from_26();
2345
-							if ($error != '') return $error;
2346
-							else return self::check_version(true);
2568
+							if ($error != '') {
2569
+								return $error;
2570
+							} else {
2571
+								return self::check_version(true);
2572
+							}
2347 2573
 						} elseif ($result['value'] == '27') {
2348 2574
 							$error = self::update_from_27();
2349
-							if ($error != '') return $error;
2350
-							else return self::check_version(true);
2575
+							if ($error != '') {
2576
+								return $error;
2577
+							} else {
2578
+								return self::check_version(true);
2579
+							}
2351 2580
 						} elseif ($result['value'] == '28') {
2352 2581
 							$error = self::update_from_28();
2353
-							if ($error != '') return $error;
2354
-							else return self::check_version(true);
2582
+							if ($error != '') {
2583
+								return $error;
2584
+							} else {
2585
+								return self::check_version(true);
2586
+							}
2355 2587
 						} elseif ($result['value'] == '29') {
2356 2588
 							$error = self::update_from_29();
2357
-							if ($error != '') return $error;
2358
-							else return self::check_version(true);
2589
+							if ($error != '') {
2590
+								return $error;
2591
+							} else {
2592
+								return self::check_version(true);
2593
+							}
2359 2594
 						} elseif ($result['value'] == '30') {
2360 2595
 							$error = self::update_from_30();
2361
-							if ($error != '') return $error;
2362
-							else return self::check_version(true);
2596
+							if ($error != '') {
2597
+								return $error;
2598
+							} else {
2599
+								return self::check_version(true);
2600
+							}
2363 2601
 						} elseif ($result['value'] == '31') {
2364 2602
 							$error = self::update_from_31();
2365
-							if ($error != '') return $error;
2366
-							else return self::check_version(true);
2603
+							if ($error != '') {
2604
+								return $error;
2605
+							} else {
2606
+								return self::check_version(true);
2607
+							}
2367 2608
 						} elseif ($result['value'] == '32') {
2368 2609
 							$error = self::update_from_32();
2369
-							if ($error != '') return $error;
2370
-							else return self::check_version(true);
2610
+							if ($error != '') {
2611
+								return $error;
2612
+							} else {
2613
+								return self::check_version(true);
2614
+							}
2371 2615
 						} elseif ($result['value'] == '33') {
2372 2616
 							$error = self::update_from_33();
2373
-							if ($error != '') return $error;
2374
-							else return self::check_version(true);
2617
+							if ($error != '') {
2618
+								return $error;
2619
+							} else {
2620
+								return self::check_version(true);
2621
+							}
2375 2622
 						} elseif ($result['value'] == '34') {
2376 2623
 							$error = self::update_from_34();
2377
-							if ($error != '') return $error;
2378
-							else return self::check_version(true);
2624
+							if ($error != '') {
2625
+								return $error;
2626
+							} else {
2627
+								return self::check_version(true);
2628
+							}
2379 2629
 						} elseif ($result['value'] == '35') {
2380 2630
 							$error = self::update_from_35();
2381
-							if ($error != '') return $error;
2382
-							else return self::check_version(true);
2631
+							if ($error != '') {
2632
+								return $error;
2633
+							} else {
2634
+								return self::check_version(true);
2635
+							}
2383 2636
 						} elseif ($result['value'] == '36') {
2384 2637
 							$error = self::update_from_36();
2385
-							if ($error != '') return $error;
2386
-							else return self::check_version(true);
2638
+							if ($error != '') {
2639
+								return $error;
2640
+							} else {
2641
+								return self::check_version(true);
2642
+							}
2387 2643
 						} elseif ($result['value'] == '37') {
2388 2644
 							$error = self::update_from_37();
2389
-							if ($error != '') return $error;
2390
-							else return self::check_version(true);
2645
+							if ($error != '') {
2646
+								return $error;
2647
+							} else {
2648
+								return self::check_version(true);
2649
+							}
2391 2650
 						} elseif ($result['value'] == '38') {
2392 2651
 							$error = self::update_from_38();
2393
-							if ($error != '') return $error;
2394
-							else return self::check_version(true);
2652
+							if ($error != '') {
2653
+								return $error;
2654
+							} else {
2655
+								return self::check_version(true);
2656
+							}
2395 2657
 						} elseif ($result['value'] == '39') {
2396 2658
 							$error = self::update_from_39();
2397
-							if ($error != '') return $error;
2398
-							else return self::check_version(true);
2659
+							if ($error != '') {
2660
+								return $error;
2661
+							} else {
2662
+								return self::check_version(true);
2663
+							}
2399 2664
 						} elseif ($result['value'] == '40') {
2400 2665
 							$error = self::update_from_40();
2401
-							if ($error != '') return $error;
2402
-							else return self::check_version(true);
2666
+							if ($error != '') {
2667
+								return $error;
2668
+							} else {
2669
+								return self::check_version(true);
2670
+							}
2403 2671
 						} elseif ($result['value'] == '41') {
2404 2672
 							$error = self::update_from_41();
2405
-							if ($error != '') return $error;
2406
-							else return self::check_version(true);
2673
+							if ($error != '') {
2674
+								return $error;
2675
+							} else {
2676
+								return self::check_version(true);
2677
+							}
2407 2678
 						} elseif ($result['value'] == '42') {
2408 2679
 							$error = self::update_from_42();
2409
-							if ($error != '') return $error;
2410
-							else return self::check_version(true);
2680
+							if ($error != '') {
2681
+								return $error;
2682
+							} else {
2683
+								return self::check_version(true);
2684
+							}
2411 2685
 						} elseif ($result['value'] == '43') {
2412 2686
 							$error = self::update_from_43();
2413
-							if ($error != '') return $error;
2414
-							else return self::check_version(true);
2687
+							if ($error != '') {
2688
+								return $error;
2689
+							} else {
2690
+								return self::check_version(true);
2691
+							}
2415 2692
 						} elseif ($result['value'] == '44') {
2416 2693
 							$error = self::update_from_44();
2417
-							if ($error != '') return $error;
2418
-							else return self::check_version(true);
2694
+							if ($error != '') {
2695
+								return $error;
2696
+							} else {
2697
+								return self::check_version(true);
2698
+							}
2419 2699
 						} elseif ($result['value'] == '45') {
2420 2700
 							$error = self::update_from_45();
2421
-							if ($error != '') return $error;
2422
-							else return self::check_version(true);
2701
+							if ($error != '') {
2702
+								return $error;
2703
+							} else {
2704
+								return self::check_version(true);
2705
+							}
2423 2706
 						} elseif ($result['value'] == '46') {
2424 2707
 							$error = self::update_from_46();
2425
-							if ($error != '') return $error;
2426
-							else return self::check_version(true);
2708
+							if ($error != '') {
2709
+								return $error;
2710
+							} else {
2711
+								return self::check_version(true);
2712
+							}
2427 2713
 						} elseif ($result['value'] == '47') {
2428 2714
 							$error = self::update_from_47();
2429
-							if ($error != '') return $error;
2430
-							else return self::check_version(true);
2431
-						} else return '';
2715
+							if ($error != '') {
2716
+								return $error;
2717
+							} else {
2718
+								return self::check_version(true);
2719
+							}
2720
+						} else {
2721
+							return '';
2722
+						}
2432 2723
 					} else {
2433
-						if (isset($result['value']) && $result['value'] != '') return $result['value'];
2434
-						else return 0;
2724
+						if (isset($result['value']) && $result['value'] != '') {
2725
+							return $result['value'];
2726
+						} else {
2727
+							return 0;
2728
+						}
2435 2729
 					}
2436 2730
 				}
2437
-			} else return $version;
2731
+			} else {
2732
+				return $version;
2733
+			}
2438 2734
 		}
2439 2735
 	}
2440 2736
 }
Please login to merge, or discard this patch.