Completed
Push — master ( 3567d1...6c4f55 )
by Yannick
17:27 queued 06:30
created
accident.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 require_once(dirname(__FILE__).'/require/settings.php');
3 3
 $date = filter_input(INPUT_POST,'date',FILTER_SANITIZE_STRING);
4
-if ($date == '') $date = date('Y-m-d');
4
+if ($date == '') {
5
+	$date = date('Y-m-d');
6
+}
5 7
 header('Location: '.$globalURL.'/accident/'.$date);
6 8
 ?>
7 9
\ No newline at end of file
Please login to merge, or discard this patch.
statistics-route-waypoint.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,9 @@
 block discarded – undo
5 5
 $Spotter = new Spotter();
6 6
 $title = _("Statistics").' - '._("Most common Route by Waypoint");
7 7
 require_once('header.php');
8
-if (!isset($filter_name)) $filter_name = '';
8
+if (!isset($filter_name)) {
9
+	$filter_name = '';
10
+}
9 11
 include('statistics-sub-menu.php'); 
10 12
 
11 13
 print '<div class="info">
Please login to merge, or discard this patch.
statistics-route-airport.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,9 @@
 block discarded – undo
5 5
 $Spotter = new Spotter();
6 6
 $title = _("Statistics").' - '._("Most common Route by Airport");
7 7
 require_once('header.php');
8
-if (!isset($filter_name)) $filter_name = '';
8
+if (!isset($filter_name)) {
9
+	$filter_name = '';
10
+}
9 11
 include('statistics-sub-menu.php'); 
10 12
 
11 13
 print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>';
Please login to merge, or discard this patch.
statistics.php 1 patch
Braces   +103 added lines, -42 removed lines patch added patch discarded remove patch
@@ -6,11 +6,15 @@  discard block
 block discarded – undo
6 6
 $beginpage = microtime(true);
7 7
 $Stats = new Stats();
8 8
 
9
-if (!isset($filter_name)) $filter_name = '';
9
+if (!isset($filter_name)) {
10
+	$filter_name = '';
11
+}
10 12
 $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
11 13
 if ($airline_icao == '' && isset($globalFilter)) {
12
-	if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
13
-}
14
+	if (isset($globalFilter['airline'])) {
15
+		$airline_icao = $globalFilter['airline'][0];
16
+	}
17
+	}
14 18
 if ($airline_icao != '' && $airline_icao != 'all') {
15 19
 	$Spotter = new Spotter();
16 20
 	$airline_info = $Spotter->getAllAirlineInfo($airline_icao);
@@ -41,14 +45,21 @@  discard block
 block discarded – undo
41 45
 <script type="text/javascript" src="<?php echo $globalURL; ?>/js/datamaps.world.min.js"></script>
42 46
 <div class="column">
43 47
     <div class="info">
44
-            <h1><?php if (isset($airline_name)) echo _("Statistics for ").$airline_name; else echo _("Statistics"); ?></h1>
48
+            <h1><?php if (isset($airline_name)) {
49
+	echo _("Statistics for ").$airline_name;
50
+} else {
51
+	echo _("Statistics");
52
+}
53
+?></h1>
45 54
     <?php 
46 55
 	$last_update = $Stats->getLastStatsUpdate();
47 56
 	//if (isset($last_update[0]['value'])) print '<!-- Last update : '.$last_update[0]['value'].' -->';
48 57
 	if (isset($last_update[0]['value'])) {
49 58
 		date_default_timezone_set('UTC');
50 59
 		$lastupdate = strtotime($last_update[0]['value']);
51
-		if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone);
60
+		if (isset($globalTimezone) && $globalTimezone != '') {
61
+			date_default_timezone_set($globalTimezone);
62
+		}
52 63
 		print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>';
53 64
 	}
54 65
     ?>
@@ -100,8 +111,9 @@  discard block
 block discarded – undo
100 111
                 <h2><?php echo _("Top 10 Most Common Aircraft Type"); ?></h2>
101 112
                  <?php
102 113
                   $aircraft_array = $Stats->countAllAircraftTypes(true,$airline_icao,$filter_name,$year,$month);
103
-		    if (count($aircraft_array) == 0) print _("No data available");
104
-		    else {
114
+		    if (count($aircraft_array) == 0) {
115
+		    	print _("No data available");
116
+		    } else {
105 117
                     print '<div id="chart1" class="chart" width="100%"></div><script>';
106 118
                     $aircraft_data = '';
107 119
                     foreach($aircraft_array as $aircraft_item)
@@ -123,11 +135,17 @@  discard block
 block discarded – undo
123 135
             	    <?php
124 136
             		if ($year != '' && $month != '') {
125 137
             	    ?>
126
-            	    <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>
138
+            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
139
+	echo '/'.$airline_icao;
140
+}
141
+?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
127 142
             	    <?php
128 143
             		} else {
129 144
             	    ?>
130
-            	    <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>
145
+            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
146
+	echo '/'.$airline_icao;
147
+}
148
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
131 149
             	    <?php
132 150
             		}
133 151
             	    ?>
@@ -158,11 +176,15 @@  discard block
 block discarded – undo
158 176
             print '</script>';
159 177
 	    if ($year != '' && $month != '') {
160 178
 		print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
161
-		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
179
+		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
180
+			echo '/'.$airline_icao;
181
+		}
162 182
 		print '/'.$year.'/'.$month.'/" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
163 183
 	    } else {
164 184
 		print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
165
-		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
185
+		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
186
+			echo '/'.$airline_icao;
187
+		}
166 188
 		print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
167 189
 	    }
168 190
     	    print '</div>';
@@ -186,8 +208,9 @@  discard block
 block discarded – undo
186 208
                 <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2>
187 209
 <?php
188 210
 	$pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month);
189
-	if (count($pilot_array) == 0) print _("No data available");
190
-	else {
211
+	if (count($pilot_array) == 0) {
212
+		print _("No data available");
213
+	} else {
191 214
 	    print '<div id="chart7" class="chart" width="100%"></div><script>';
192 215
 	    $pilot_data = '';
193 216
 	    foreach($pilot_array as $pilot_item)
@@ -206,7 +229,9 @@  discard block
 block discarded – undo
206 229
         }
207 230
         print '<div class="more">';
208 231
 	print '<a href="'.$globalURL.'/statistics/pilot'; 
209
-	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
+	}
210 235
 	print'" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a>';
211 236
 	print '</div>';
212 237
 ?>
@@ -220,8 +245,9 @@  discard block
 block discarded – undo
220 245
                 <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
221 246
 <?php
222 247
 	$owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name,$year,$month);
223
-	if (count($owner_array) == 0) print _("No data available");
224
-	else {
248
+	if (count($owner_array) == 0) {
249
+		print _("No data available");
250
+	} else {
225 251
 	    print '<div id="chart7" class="chart" width="100%"></div><script>';
226 252
 	    $owner_data = '';
227 253
 	    foreach($owner_array as $owner_item)
@@ -240,7 +266,10 @@  discard block
 block discarded – undo
240 266
 	}
241 267
 ?>
242 268
                 <div class="more">
243
-                    <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>
269
+                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
270
+	echo '/'.$airline_icao;
271
+}
272
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
244 273
                 </div>
245 274
             </div>
246 275
         
@@ -253,8 +282,9 @@  discard block
 block discarded – undo
253 282
                 <h2><?php echo _("Top 20 Most Common Country a Flight was Over"); ?></h2>
254 283
 <?php
255 284
 	 //$flightover_array = $Stats->countAllFlightOverCountries();
256
-	if (count($flightover_array) == 0) print _("No data available");
257
-	else {
285
+	if (count($flightover_array) == 0) {
286
+		print _("No data available");
287
+	} else {
258 288
 	    print '<div id="chart10" class="chart" width="100%"></div><script>';
259 289
 	    print 'var series = [';
260 290
             $flightover_data = '';
@@ -297,7 +327,10 @@  discard block
 block discarded – undo
297 327
 	}
298 328
 ?>
299 329
                 <div class="more">
300
-                    <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>
330
+                    <a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
331
+	echo '/'.$airline_icao;
332
+}
333
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
301 334
                 </div>
302 335
             </div>
303 336
 <?php
@@ -364,7 +397,9 @@  discard block
 block discarded – undo
364 397
 	print '</script>';
365 398
 
366 399
 	print '<div class="more"><a href="'.$globalURL.'/statistics/airport-departure'; 
367
-	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
400
+	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
401
+		echo '/'.$airline_icao;
402
+	}
368 403
 	print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
369 404
     }
370 405
 ?>
@@ -427,7 +462,9 @@  discard block
 block discarded – undo
427 462
 
428 463
 
429 464
 	print '<div class="more"><a href="'.$globalURL.'/statistics/airport-arrival';
430
-	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
465
+	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
466
+		echo '/'.$airline_icao;
467
+	}
431 468
 	print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
432 469
     }
433 470
 ?>
@@ -442,8 +479,9 @@  discard block
 block discarded – undo
442 479
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
443 480
                 <?php
444 481
                   $year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
445
-		    if (count($year_array) == 0) print _("No data available");
446
-		    else {
482
+		    if (count($year_array) == 0) {
483
+		    	print _("No data available");
484
+		    } else {
447 485
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
448 486
 			$year_data = '';
449 487
 			$year_cnt = '';
@@ -463,7 +501,10 @@  discard block
 block discarded – undo
463 501
                     }
464 502
                   ?>
465 503
                 <div class="more">
466
-                    <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>
504
+                    <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
505
+	echo '/'.$airline_icao;
506
+}
507
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
467 508
                 </div>
468 509
             </div>
469 510
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -471,8 +512,9 @@  discard block
 block discarded – undo
471 512
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
472 513
                 <?php
473 514
                   $month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
474
-		    if (count($month_array) == 0) print _("No data available");
475
-		    else {
515
+		    if (count($month_array) == 0) {
516
+		    	print _("No data available");
517
+		    } else {
476 518
                 	print '<div id="chart9" class="chart" width="100%"></div><script>';
477 519
                         $month_data = '';
478 520
 			$month_cnt = '';
@@ -493,7 +535,10 @@  discard block
 block discarded – undo
493 535
                     }
494 536
                   ?>
495 537
                 <div class="more">
496
-                    <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>
538
+                    <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
539
+	echo '/'.$airline_icao;
540
+}
541
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
497 542
                 </div>
498 543
             </div>
499 544
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -502,8 +547,9 @@  discard block
 block discarded – undo
502 547
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
503 548
                 <?php
504 549
                     $date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
505
-		    if (empty($date_array)) print _("No data available");
506
-		    else {
550
+		    if (empty($date_array)) {
551
+		    	print _("No data available");
552
+		    } else {
507 553
                 	print '<div id="chart5" class="chart" width="100%"></div><script>';
508 554
                         $date_data = '';
509 555
 			$date_cnt = '';
@@ -524,7 +570,10 @@  discard block
 block discarded – undo
524 570
                     }
525 571
                   ?>
526 572
                 <div class="more">
527
-                    <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>
573
+                    <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
574
+	echo '/'.$airline_icao;
575
+}
576
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
528 577
                 </div>
529 578
             </div>
530 579
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -532,8 +581,9 @@  discard block
 block discarded – undo
532 581
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
533 582
                 <?php
534 583
                   $hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
535
-		    if (empty($hour_array)) print _("No data available");
536
-		    else {
584
+		    if (empty($hour_array)) {
585
+		    	print _("No data available");
586
+		    } else {
537 587
                 	print '<div id="chart6" class="chart" width="100%"></div><script>';
538 588
                         $hour_data = '';
539 589
 			$hour_cnt = '';
@@ -554,7 +604,10 @@  discard block
 block discarded – undo
554 604
                   }
555 605
                 ?>
556 606
                 <div class="more">
557
-                    <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>
607
+                    <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
608
+	echo '/'.$airline_icao;
609
+}
610
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
558 611
                 </div>
559 612
             </div>
560 613
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -571,8 +624,9 @@  discard block
 block discarded – undo
571 624
                 <h2><?php echo _("Fatalities by Years"); ?></h2>
572 625
                 <?php
573 626
                   $year_array = $Stats->countFatalitiesByYear();
574
-		    if (count($year_array) == 0) print _("No data available");
575
-		    else {
627
+		    if (count($year_array) == 0) {
628
+		    	print _("No data available");
629
+		    } else {
576 630
 			print '<div id="chart32" class="chart" width="100%"></div><script>';
577 631
                         $year_data = '';
578 632
 			$year_cnt = '';
@@ -603,8 +657,9 @@  discard block
 block discarded – undo
603 657
                 <h2><?php echo _("Fatalities last 12 Months"); ?></h2>
604 658
                 <?php
605 659
                   $year_array = $Stats->countFatalitiesLast12Months();
606
-		    if (count($year_array) == 0) print _("No data available");
607
-		    else {
660
+		    if (count($year_array) == 0) {
661
+		    	print _("No data available");
662
+		    } else {
608 663
 			print '<div id="chart33" class="chart" width="100%"></div><script>';
609 664
                         $year_data = '';
610 665
 			$year_cnt = '';
@@ -664,8 +719,11 @@  discard block
 block discarded – undo
664 719
 					$distance = $distance;
665 720
 					$unit = 'km';
666 721
 				}
667
-        			if (!isset($polar_data)) $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
668
-        	    		else $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
722
+        			if (!isset($polar_data)) {
723
+        				$polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
724
+        			} else {
725
+        	    			$polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
726
+        	    		}
669 727
         		    }
670 728
         	?>
671 729
             <div class="col-md-6">
@@ -717,8 +775,11 @@  discard block
 block discarded – undo
717 775
         		foreach ($msg as $eachmsg) {
718 776
         		    //$eachmsg = $msg[0];
719 777
         		    $data = $eachmsg['source_data'];
720
-        		    if ($data > 500) $max = (round(($data+100)/100))*100;
721
-        		    else $max = 500;
778
+        		    if ($data > 500) {
779
+        		    	$max = (round(($data+100)/100))*100;
780
+        		    } else {
781
+        		    	$max = 500;
782
+        		    }
722 783
         	?>
723 784
         	<div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
724 785
         	<script>
Please login to merge, or discard this patch.
require/class.Stats.php 1 patch
Braces   +482 added lines, -167 removed lines patch added patch discarded remove patch
@@ -13,7 +13,9 @@  discard block
 block discarded – undo
13 13
 	
14 14
 	public function __construct($dbc = null) {
15 15
 		global $globalFilterName;
16
-		if (isset($globalFilterName)) $this->filter_name = $globalFilterName;
16
+		if (isset($globalFilterName)) {
17
+			$this->filter_name = $globalFilterName;
18
+		}
17 19
 		$Connection = new Connection($dbc);
18 20
 		$this->db = $Connection->db();
19 21
         }
@@ -81,7 +83,9 @@  discard block
 block discarded – undo
81 83
                 }
82 84
         }
83 85
 	public function getAllAirlineNames($filter_name = '') {
84
-		if ($filter_name == '') $filter_name = $this->filter_name;
86
+		if ($filter_name == '') {
87
+			$filter_name = $this->filter_name;
88
+		}
85 89
                 $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC";
86 90
                  try {
87 91
                         $sth = $this->db->prepare($query);
@@ -93,7 +97,9 @@  discard block
 block discarded – undo
93 97
                 return $all;
94 98
         }
95 99
 	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
96
-		if ($filter_name == '') $filter_name = $this->filter_name;
100
+		if ($filter_name == '') {
101
+			$filter_name = $this->filter_name;
102
+		}
97 103
                 $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
98 104
                  try {
99 105
                         $sth = $this->db->prepare($query);
@@ -105,7 +111,9 @@  discard block
 block discarded – undo
105 111
                 return $all;
106 112
         }
107 113
 	public function getAllManufacturers($stats_airline = '',$filter_name = '') {
108
-		if ($filter_name == '') $filter_name = $this->filter_name;
114
+		if ($filter_name == '') {
115
+			$filter_name = $this->filter_name;
116
+		}
109 117
                 $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";
110 118
                  try {
111 119
                         $sth = $this->db->prepare($query);
@@ -117,7 +125,9 @@  discard block
 block discarded – undo
117 125
                 return $all;
118 126
         }
119 127
 	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
120
-		if ($filter_name == '') $filter_name = $this->filter_name;
128
+		if ($filter_name == '') {
129
+			$filter_name = $this->filter_name;
130
+		}
121 131
                 $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";
122 132
                  try {
123 133
                         $sth = $this->db->prepare($query);
@@ -130,7 +140,9 @@  discard block
 block discarded – undo
130 140
         }
131 141
 
132 142
 	public function getAllOwnerNames($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 owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name 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 getAllPilotNames($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 pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC";
148 162
                  try {
149 163
                         $sth = $this->db->prepare($query);
@@ -158,10 +172,15 @@  discard block
 block discarded – undo
158 172
 
159 173
 	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
160 174
 		global $globalStatsFilters;
161
-		if ($filter_name == '') $filter_name = $this->filter_name;
175
+		if ($filter_name == '') {
176
+			$filter_name = $this->filter_name;
177
+		}
162 178
 		if ($year == '' && $month == '') {
163
-			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 stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
164
-			else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
179
+			if ($limit) {
180
+				$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
181
+			} else {
182
+				$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
183
+			}
165 184
 			try {
166 185
 				$sth = $this->db->prepare($query);
167 186
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -169,7 +188,9 @@  discard block
 block discarded – undo
169 188
 				echo "error : ".$e->getMessage();
170 189
 			}
171 190
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
172
-		} else $all = array();
191
+		} else {
192
+			$all = array();
193
+		}
173 194
                 if (empty($all)) {
174 195
             	    $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
175 196
             	    if ($filter_name != '') {
@@ -183,10 +204,15 @@  discard block
 block discarded – undo
183 204
 	}
184 205
 	public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') {
185 206
 		global $globalStatsFilters;
186
-		if ($filter_name == '') $filter_name = $this->filter_name;
207
+		if ($filter_name == '') {
208
+			$filter_name = $this->filter_name;
209
+		}
187 210
 		if ($year == '' && $month == '') {
188
-			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";
189
-			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";
211
+			if ($limit) {
212
+				$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";
213
+			} else {
214
+				$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";
215
+			}
190 216
 			try {
191 217
 				$sth = $this->db->prepare($query);
192 218
 				$sth->execute(array(':filter_name' => $filter_name));
@@ -194,7 +220,9 @@  discard block
 block discarded – undo
194 220
 				echo "error : ".$e->getMessage();
195 221
 			}
196 222
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
197
-		} else $all = array();
223
+		} else {
224
+			$all = array();
225
+		}
198 226
                 if (empty($all)) {
199 227
             		$Spotter = new Spotter($this->db);
200 228
             		$filters = array();
@@ -209,10 +237,15 @@  discard block
 block discarded – undo
209 237
 	}
210 238
 	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') {
211 239
 		global $globalStatsFilters;
212
-		if ($filter_name == '') $filter_name = $this->filter_name;
240
+		if ($filter_name == '') {
241
+			$filter_name = $this->filter_name;
242
+		}
213 243
 		if ($year == '' && $month == '') {
214
-			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";
215
-			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";
244
+			if ($limit) {
245
+				$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";
246
+			} else {
247
+				$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";
248
+			}
216 249
 			try {
217 250
 				$sth = $this->db->prepare($query);
218 251
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -220,7 +253,9 @@  discard block
 block discarded – undo
220 253
 				echo "error : ".$e->getMessage();
221 254
 			}
222 255
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
223
-		} else $all = array();
256
+		} else {
257
+			$all = array();
258
+		}
224 259
 		if (empty($all)) {
225 260
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
226 261
 			if ($filter_name != '') {
@@ -235,10 +270,15 @@  discard block
 block discarded – undo
235 270
 
236 271
 	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
237 272
 		global $globalStatsFilters;
238
-		if ($filter_name == '') $filter_name = $this->filter_name;
273
+		if ($filter_name == '') {
274
+			$filter_name = $this->filter_name;
275
+		}
239 276
 		if ($year == '' && $month == '') {
240
-			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";
241
-			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";
277
+			if ($limit) {
278
+				$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";
279
+			} else {
280
+				$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";
281
+			}
242 282
 			try {
243 283
 				$sth = $this->db->prepare($query);
244 284
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -246,7 +286,9 @@  discard block
 block discarded – undo
246 286
 				echo "error : ".$e->getMessage();
247 287
 			}
248 288
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
249
-		} else $all = array();
289
+		} else {
290
+			$all = array();
291
+		}
250 292
                 if (empty($all)) {
251 293
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
252 294
 			if ($filter_name != '') {
@@ -260,9 +302,14 @@  discard block
 block discarded – undo
260 302
 	}
261 303
 	public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
262 304
 		global $globalStatsFilters;
263
-		if ($filter_name == '') $filter_name = $this->filter_name;
264
-		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";
265
-		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";
305
+		if ($filter_name == '') {
306
+			$filter_name = $this->filter_name;
307
+		}
308
+		if ($limit) {
309
+			$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";
310
+		} else {
311
+			$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";
312
+		}
266 313
                  try {
267 314
                         $sth = $this->db->prepare($query);
268 315
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -284,17 +331,29 @@  discard block
 block discarded – undo
284 331
 
285 332
 	public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') {
286 333
 		global $globalStatsFilters, $globalVATSIM, $globalIVAO;
287
-		if ($filter_name == '') $filter_name = $this->filter_name;
334
+		if ($filter_name == '') {
335
+			$filter_name = $this->filter_name;
336
+		}
288 337
 		if ($year == '' && $month == '') {
289
-			if ($globalVATSIM) $forsource = 'vatsim';
290
-			if ($globalIVAO) $forsource = 'ivao';
338
+			if ($globalVATSIM) {
339
+				$forsource = 'vatsim';
340
+			}
341
+			if ($globalIVAO) {
342
+				$forsource = 'ivao';
343
+			}
291 344
 			if (isset($forsource)) {
292
-				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";
293
-				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";
345
+				if ($limit) {
346
+					$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";
347
+				} else {
348
+					$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";
349
+				}
294 350
 				$query_values = array(':filter_name' => $filter_name,':forsource' => $forsource);
295 351
 			} else {
296
-				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";
297
-				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";
352
+				if ($limit) {
353
+					$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";
354
+				} else {
355
+					$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";
356
+				}
298 357
 				$query_values = array(':filter_name' => $filter_name);
299 358
 			}
300 359
 			try {
@@ -304,7 +363,9 @@  discard block
 block discarded – undo
304 363
 				echo "error : ".$e->getMessage();
305 364
 			}
306 365
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
307
-		} else $all = array();
366
+		} else {
367
+			$all = array();
368
+		}
308 369
                 if (empty($all)) {
309 370
 	                $Spotter = new Spotter($this->db);
310 371
             		$filters = array();
@@ -319,10 +380,15 @@  discard block
 block discarded – undo
319 380
 	}
320 381
 	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
321 382
 		global $globalStatsFilters;
322
-		if ($filter_name == '') $filter_name = $this->filter_name;
383
+		if ($filter_name == '') {
384
+			$filter_name = $this->filter_name;
385
+		}
323 386
 		if ($year == '' && $month == '') {
324
-			if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0";
325
-			else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC";
387
+			if ($limit) {
388
+				$query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0";
389
+			} else {
390
+				$query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC";
391
+			}
326 392
 			try {
327 393
 				$sth = $this->db->prepare($query);
328 394
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -330,7 +396,9 @@  discard block
 block discarded – undo
330 396
 				echo "error : ".$e->getMessage();
331 397
 			}
332 398
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
333
-		} else $all = array();
399
+		} else {
400
+			$all = array();
401
+		}
334 402
                 if (empty($all)) {
335 403
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
336 404
 			if ($filter_name != '') {
@@ -344,10 +412,15 @@  discard block
 block discarded – undo
344 412
 	}
345 413
 	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
346 414
 		global $globalStatsFilters;
347
-		if ($filter_name == '') $filter_name = $this->filter_name;
415
+		if ($filter_name == '') {
416
+			$filter_name = $this->filter_name;
417
+		}
348 418
 		if ($year == '' && $month == '') {
349
-			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";
350
-			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";
419
+			if ($limit) {
420
+				$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";
421
+			} else {
422
+				$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";
423
+			}
351 424
 			 try {
352 425
 				$sth = $this->db->prepare($query);
353 426
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -355,7 +428,9 @@  discard block
 block discarded – undo
355 428
 				echo "error : ".$e->getMessage();
356 429
 			}
357 430
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
358
-		} else $all = array();
431
+		} else {
432
+			$all = array();
433
+		}
359 434
 		if (empty($all)) {
360 435
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
361 436
 			if ($filter_name != '') {
@@ -369,11 +444,16 @@  discard block
 block discarded – undo
369 444
 	}
370 445
 	public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') {
371 446
 		$Connection = new Connection();
372
-		if ($filter_name == '') $filter_name = $this->filter_name;
447
+		if ($filter_name == '') {
448
+			$filter_name = $this->filter_name;
449
+		}
373 450
 		if ($Connection->tableExists('countries')) {
374 451
 			if ($year == '' && $month == '') {
375
-				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";
376
-				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";
452
+				if ($limit) {
453
+					$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";
454
+				} else {
455
+					$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";
456
+				}
377 457
 				 try {
378 458
 					$sth = $this->db->prepare($query);
379 459
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -388,17 +468,24 @@  discard block
 block discarded – undo
388 468
                 }
389 469
                 */
390 470
 				return $all;
391
-			} else return array();
471
+			} else {
472
+				return array();
473
+			}
392 474
 		} else {
393 475
 			return array();
394 476
 		}
395 477
 	}
396 478
 	public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') {
397 479
 		global $globalStatsFilters;
398
-		if ($filter_name == '') $filter_name = $this->filter_name;
480
+		if ($filter_name == '') {
481
+			$filter_name = $this->filter_name;
482
+		}
399 483
 		if ($year == '' && $month == '') {
400
-			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";
401
-			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";
484
+			if ($limit) {
485
+				$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";
486
+			} else {
487
+				$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";
488
+			}
402 489
 			try {
403 490
 				$sth = $this->db->prepare($query);
404 491
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -406,7 +493,9 @@  discard block
 block discarded – undo
406 493
 				echo "error : ".$e->getMessage();
407 494
 			}
408 495
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
409
-		} else $all = array();
496
+		} else {
497
+			$all = array();
498
+		}
410 499
 		if (empty($all)) {
411 500
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
412 501
 			if ($filter_name != '') {
@@ -421,10 +510,15 @@  discard block
 block discarded – undo
421 510
 
422 511
 	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') {
423 512
 		global $globalStatsFilters;
424
-		if ($filter_name == '') $filter_name = $this->filter_name;
513
+		if ($filter_name == '') {
514
+			$filter_name = $this->filter_name;
515
+		}
425 516
 		if ($year == '' && $month == '') {
426
-			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";
427
-			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";
517
+			if ($limit) {
518
+				$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";
519
+			} else {
520
+				$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";
521
+			}
428 522
 			try {
429 523
 				$sth = $this->db->prepare($query);
430 524
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -432,7 +526,9 @@  discard block
 block discarded – undo
432 526
 				echo "error : ".$e->getMessage();
433 527
 			}
434 528
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
435
-		} else $all = array();
529
+		} else {
530
+			$all = array();
531
+		}
436 532
                 if (empty($all)) {
437 533
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
438 534
 			if ($filter_name != '') {
@@ -446,10 +542,15 @@  discard block
 block discarded – undo
446 542
 	}
447 543
 	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
448 544
 		global $globalStatsFilters;
449
-		if ($filter_name == '') $filter_name = $this->filter_name;
545
+		if ($filter_name == '') {
546
+			$filter_name = $this->filter_name;
547
+		}
450 548
 		if ($year == '' && $month == '') {
451
-			if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, 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";
452
-			else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, 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";
549
+			if ($limit) {
550
+				$query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, 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";
551
+			} else {
552
+				$query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, 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";
553
+			}
453 554
 			try {
454 555
 				$sth = $this->db->prepare($query);
455 556
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -457,7 +558,9 @@  discard block
 block discarded – undo
457 558
 				echo "error : ".$e->getMessage();
458 559
 			}
459 560
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
460
-		} else $all = array();
561
+		} else {
562
+			$all = array();
563
+		}
461 564
                 if (empty($all)) {
462 565
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
463 566
             		if ($filter_name != '') {
@@ -478,7 +581,9 @@  discard block
 block discarded – undo
478 581
         			$icao = $value['airport_departure_icao'];
479 582
         			if (isset($all[$icao])) {
480 583
         				$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
481
-        			} else $all[$icao] = $value;
584
+        			} else {
585
+        				$all[$icao] = $value;
586
+        			}
482 587
         		}
483 588
         		$count = array();
484 589
         		foreach ($all as $key => $row) {
@@ -490,10 +595,15 @@  discard block
 block discarded – undo
490 595
 	}
491 596
 	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
492 597
 		global $globalStatsFilters;
493
-		if ($filter_name == '') $filter_name = $this->filter_name;
598
+		if ($filter_name == '') {
599
+			$filter_name = $this->filter_name;
600
+		}
494 601
 		if ($year == '' && $month == '') {
495
-			if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,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";
496
-			else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,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";
602
+			if ($limit) {
603
+				$query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,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";
604
+			} else {
605
+				$query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,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";
606
+			}
497 607
 			try {
498 608
 				$sth = $this->db->prepare($query);
499 609
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -501,7 +611,9 @@  discard block
 block discarded – undo
501 611
 				echo "error : ".$e->getMessage();
502 612
 			}
503 613
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
504
-		} else $all = array();
614
+		} else {
615
+			$all = array();
616
+		}
505 617
 		if (empty($all)) {
506 618
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
507 619
 			if ($filter_name != '') {
@@ -522,7 +634,9 @@  discard block
 block discarded – undo
522 634
         			$icao = $value['airport_arrival_icao'];
523 635
         			if (isset($all[$icao])) {
524 636
         				$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
525
-        			} else $all[$icao] = $value;
637
+        			} else {
638
+        				$all[$icao] = $value;
639
+        			}
526 640
         		}
527 641
         		$count = array();
528 642
         		foreach ($all as $key => $row) {
@@ -535,13 +649,21 @@  discard block
 block discarded – undo
535 649
 	}
536 650
 	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
537 651
 		global $globalDBdriver, $globalStatsFilters;
538
-		if ($filter_name == '') $filter_name = $this->filter_name;
652
+		if ($filter_name == '') {
653
+			$filter_name = $this->filter_name;
654
+		}
539 655
 		if ($globalDBdriver == 'mysql') {
540
-			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";
541
-			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";
656
+			if ($limit) {
657
+				$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";
658
+			} else {
659
+				$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";
660
+			}
542 661
 		} else {
543
-			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";
544
-			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";
662
+			if ($limit) {
663
+				$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";
664
+			} else {
665
+				$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";
666
+			}
545 667
 		}
546 668
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
547 669
                  try {
@@ -565,7 +687,9 @@  discard block
 block discarded – undo
565 687
 	
566 688
 	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
567 689
 		global $globalStatsFilters;
568
-		if ($filter_name == '') $filter_name = $this->filter_name;
690
+		if ($filter_name == '') {
691
+			$filter_name = $this->filter_name;
692
+		}
569 693
 		$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline = :stats_airline AND filter_name = :filter_name";
570 694
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
571 695
                  try {
@@ -587,7 +711,9 @@  discard block
 block discarded – undo
587 711
 	}
588 712
 	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
589 713
 		global $globalDBdriver, $globalStatsFilters;
590
-		if ($filter_name == '') $filter_name = $this->filter_name;
714
+		if ($filter_name == '') {
715
+			$filter_name = $this->filter_name;
716
+		}
591 717
 		if ($globalDBdriver == 'mysql') {
592 718
 			$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND stats_airline = :stats_airline AND filter_name = :filter_name";
593 719
 		} else {
@@ -613,7 +739,9 @@  discard block
 block discarded – undo
613 739
 	}
614 740
 	public function countAllDates($stats_airline = '',$filter_name = '') {
615 741
 		global $globalStatsFilters;
616
-		if ($filter_name == '') $filter_name = $this->filter_name;
742
+		if ($filter_name == '') {
743
+			$filter_name = $this->filter_name;
744
+		}
617 745
 		$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline = :stats_airline AND filter_name = :filter_name";
618 746
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
619 747
                  try {
@@ -635,7 +763,9 @@  discard block
 block discarded – undo
635 763
 	}
636 764
 	public function countAllDatesByAirlines($filter_name = '') {
637 765
 		global $globalStatsFilters;
638
-		if ($filter_name == '') $filter_name = $this->filter_name;
766
+		if ($filter_name == '') {
767
+			$filter_name = $this->filter_name;
768
+		}
639 769
 		$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";
640 770
 		$query_data = array('filter_name' => $filter_name);
641 771
                  try {
@@ -657,7 +787,9 @@  discard block
 block discarded – undo
657 787
 	}
658 788
 	public function countAllMonths($stats_airline = '',$filter_name = '') {
659 789
 		global $globalStatsFilters, $globalDBdriver;
660
-		if ($filter_name == '') $filter_name = $this->filter_name;
790
+		if ($filter_name == '') {
791
+			$filter_name = $this->filter_name;
792
+		}
661 793
 		if ($globalDBdriver == 'mysql') {
662 794
 			$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
663 795
 		} else {
@@ -726,7 +858,9 @@  discard block
 block discarded – undo
726 858
 	}
727 859
 	public function countAllMilitaryMonths($filter_name = '') {
728 860
 		global $globalStatsFilters;
729
-		if ($filter_name == '') $filter_name = $this->filter_name;
861
+		if ($filter_name == '') {
862
+			$filter_name = $this->filter_name;
863
+		}
730 864
 	    	$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";
731 865
                  try {
732 866
                         $sth = $this->db->prepare($query);
@@ -747,9 +881,14 @@  discard block
 block discarded – undo
747 881
 	}
748 882
 	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
749 883
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
750
-		if ($filter_name == '') $filter_name = $this->filter_name;
751
-		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";
752
-		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";
884
+		if ($filter_name == '') {
885
+			$filter_name = $this->filter_name;
886
+		}
887
+		if ($limit) {
888
+			$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";
889
+		} else {
890
+			$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";
891
+		}
753 892
 		if ($orderby == 'hour') {
754 893
 			if ($globalDBdriver == 'mysql') {
755 894
 				//$query .= " ORDER BY flight_date ASC";
@@ -758,7 +897,9 @@  discard block
 block discarded – undo
758 897
 				$query .= " ORDER BY CAST(flight_date AS integer) ASC";
759 898
 			}
760 899
 		}
761
-		if ($orderby == 'count') $query .= " ORDER BY hour_count DESC";
900
+		if ($orderby == 'count') {
901
+			$query .= " ORDER BY hour_count DESC";
902
+		}
762 903
                  try {
763 904
                         $sth = $this->db->prepare($query);
764 905
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
@@ -779,8 +920,12 @@  discard block
 block discarded – undo
779 920
 	
780 921
 	public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') {
781 922
 		global $globalStatsFilters;
782
-		if ($filter_name == '') $filter_name = $this->filter_name;
783
-		if ($year == '') $year = date('Y');
923
+		if ($filter_name == '') {
924
+			$filter_name = $this->filter_name;
925
+		}
926
+		if ($year == '') {
927
+			$year = date('Y');
928
+		}
784 929
 		$all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month);
785 930
 		if (empty($all)) {
786 931
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
@@ -795,8 +940,12 @@  discard block
 block discarded – undo
795 940
 	}
796 941
 	public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') {
797 942
 		global $globalStatsFilters;
798
-		if ($filter_name == '') $filter_name = $this->filter_name;
799
-		if ($year == '') $year = date('Y');
943
+		if ($filter_name == '') {
944
+			$filter_name = $this->filter_name;
945
+		}
946
+		if ($year == '') {
947
+			$year = date('Y');
948
+		}
800 949
 		$all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month);
801 950
 		if (empty($all)) {
802 951
 		        $filters = array();
@@ -812,8 +961,12 @@  discard block
 block discarded – undo
812 961
 	}
813 962
 	public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') {
814 963
 		global $globalStatsFilters;
815
-		if ($filter_name == '') $filter_name = $this->filter_name;
816
-		if ($year == '') $year = date('Y');
964
+		if ($filter_name == '') {
965
+			$filter_name = $this->filter_name;
966
+		}
967
+		if ($year == '') {
968
+			$year = date('Y');
969
+		}
817 970
 		$all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month);
818 971
 		if (empty($all)) {
819 972
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
@@ -828,7 +981,9 @@  discard block
 block discarded – undo
828 981
 	}
829 982
 	public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') {
830 983
 		global $globalStatsFilters;
831
-		if ($filter_name == '') $filter_name = $this->filter_name;
984
+		if ($filter_name == '') {
985
+			$filter_name = $this->filter_name;
986
+		}
832 987
 		if ($year == '' && $month == '') {
833 988
 			$query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
834 989
 			try {
@@ -839,7 +994,9 @@  discard block
 block discarded – undo
839 994
 			}
840 995
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
841 996
 			$all = $result[0]['nb'];
842
-		} else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
997
+		} else {
998
+			$all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
999
+		}
843 1000
 		if (empty($all)) {
844 1001
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
845 1002
 			if ($filter_name != '') {
@@ -853,7 +1010,9 @@  discard block
 block discarded – undo
853 1010
 	}
854 1011
 	public function countOverallAirlines($filter_name = '',$year = '',$month = '') {
855 1012
 		global $globalStatsFilters;
856
-		if ($filter_name == '') $filter_name = $this->filter_name;
1013
+		if ($filter_name == '') {
1014
+			$filter_name = $this->filter_name;
1015
+		}
857 1016
 		if ($year == '' && $month == '') {
858 1017
 			$query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name";
859 1018
 			try {
@@ -864,7 +1023,9 @@  discard block
 block discarded – undo
864 1023
 			}
865 1024
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
866 1025
 			$all = $result[0]['nb_airline'];
867
-		} else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
1026
+		} else {
1027
+			$all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
1028
+		}
868 1029
 		if (empty($all)) {
869 1030
             		$filters = array();
870 1031
 			$filters = array('year' => $year,'month' => $month);
@@ -879,7 +1040,9 @@  discard block
 block discarded – undo
879 1040
 	}
880 1041
 	public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') {
881 1042
 		global $globalStatsFilters;
882
-		if ($filter_name == '') $filter_name = $this->filter_name;
1043
+		if ($filter_name == '') {
1044
+			$filter_name = $this->filter_name;
1045
+		}
883 1046
 		if ($year == '' && $month == '') {
884 1047
 			$query = "SELECT count(*) as nb FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
885 1048
 			$query_values = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
@@ -907,7 +1070,9 @@  discard block
 block discarded – undo
907 1070
 	}
908 1071
 	public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') {
909 1072
 		global $globalStatsFilters;
910
-		if ($filter_name == '') $filter_name = $this->filter_name;
1073
+		if ($filter_name == '') {
1074
+			$filter_name = $this->filter_name;
1075
+		}
911 1076
 		//if ($year == '') $year = date('Y');
912 1077
 		if ($year == '' && $month == '') {
913 1078
 			$query = "SELECT count(*) as nb FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
@@ -936,7 +1101,9 @@  discard block
 block discarded – undo
936 1101
 	}
937 1102
 
938 1103
 	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') {
939
-		if ($filter_name == '') $filter_name = $this->filter_name;
1104
+		if ($filter_name == '') {
1105
+			$filter_name = $this->filter_name;
1106
+		}
940 1107
 		$query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date";
941 1108
 		$query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
942 1109
                  try {
@@ -949,7 +1116,9 @@  discard block
 block discarded – undo
949 1116
                 return $all;
950 1117
 	}
951 1118
 	public function getStats($type,$stats_airline = '', $filter_name = '') {
952
-		if ($filter_name == '') $filter_name = $this->filter_name;
1119
+		if ($filter_name == '') {
1120
+			$filter_name = $this->filter_name;
1121
+		}
953 1122
                 $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
954 1123
                 $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
955 1124
                  try {
@@ -962,7 +1131,9 @@  discard block
 block discarded – undo
962 1131
                 return $all;
963 1132
         }
964 1133
 	public function deleteStatsByType($type,$stats_airline = '', $filter_name = '') {
965
-		if ($filter_name == '') $filter_name = $this->filter_name;
1134
+		if ($filter_name == '') {
1135
+			$filter_name = $this->filter_name;
1136
+		}
966 1137
                 $query = "DELETE FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name";
967 1138
                 $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
968 1139
                  try {
@@ -973,7 +1144,9 @@  discard block
 block discarded – undo
973 1144
                 }
974 1145
         }
975 1146
 	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') {
976
-		if ($filter_name == '') $filter_name = $this->filter_name;
1147
+		if ($filter_name == '') {
1148
+			$filter_name = $this->filter_name;
1149
+		}
977 1150
     		global $globalArchiveMonths, $globalDBdriver;
978 1151
     		if ($globalDBdriver == 'mysql') {
979 1152
     			if ($month == '') {
@@ -1003,7 +1176,9 @@  discard block
 block discarded – undo
1003 1176
         }
1004 1177
 	public function getStatsTotal($type, $stats_airline = '', $filter_name = '') {
1005 1178
     		global $globalArchiveMonths, $globalDBdriver;
1006
-		if ($filter_name == '') $filter_name = $this->filter_name;
1179
+		if ($filter_name == '') {
1180
+			$filter_name = $this->filter_name;
1181
+		}
1007 1182
     		if ($globalDBdriver == 'mysql') {
1008 1183
 			$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL ".$globalArchiveMonths." MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name";
1009 1184
 		} else {
@@ -1021,7 +1196,9 @@  discard block
 block discarded – undo
1021 1196
         }
1022 1197
 	public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') {
1023 1198
     		global $globalArchiveMonths, $globalDBdriver;
1024
-		if ($filter_name == '') $filter_name = $this->filter_name;
1199
+		if ($filter_name == '') {
1200
+			$filter_name = $this->filter_name;
1201
+		}
1025 1202
     		if ($globalDBdriver == 'mysql') {
1026 1203
 			$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
1027 1204
                 } else {
@@ -1038,7 +1215,9 @@  discard block
 block discarded – undo
1038 1215
         }
1039 1216
 	public function getStatsAirlineTotal($filter_name = '') {
1040 1217
     		global $globalArchiveMonths, $globalDBdriver;
1041
-		if ($filter_name == '') $filter_name = $this->filter_name;
1218
+		if ($filter_name == '') {
1219
+			$filter_name = $this->filter_name;
1220
+		}
1042 1221
     		if ($globalDBdriver == 'mysql') {
1043 1222
 			$query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name";
1044 1223
                 } else {
@@ -1055,7 +1234,9 @@  discard block
 block discarded – undo
1055 1234
         }
1056 1235
 	public function getStatsOwnerTotal($filter_name = '') {
1057 1236
     		global $globalArchiveMonths, $globalDBdriver;
1058
-		if ($filter_name == '') $filter_name = $this->filter_name;
1237
+		if ($filter_name == '') {
1238
+			$filter_name = $this->filter_name;
1239
+		}
1059 1240
     		if ($globalDBdriver == 'mysql') {
1060 1241
 			$query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name";
1061 1242
 		} else {
@@ -1072,7 +1253,9 @@  discard block
 block discarded – undo
1072 1253
         }
1073 1254
 	public function getStatsOwner($owner_name,$filter_name = '') {
1074 1255
     		global $globalArchiveMonths, $globalDBdriver;
1075
-		if ($filter_name == '') $filter_name = $this->filter_name;
1256
+		if ($filter_name == '') {
1257
+			$filter_name = $this->filter_name;
1258
+		}
1076 1259
 		$query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name";
1077 1260
                  try {
1078 1261
                         $sth = $this->db->prepare($query);
@@ -1081,12 +1264,17 @@  discard block
 block discarded – undo
1081 1264
                         echo "error : ".$e->getMessage();
1082 1265
                 }
1083 1266
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
1084
-                if (isset($all[0]['cnt'])) return $all[0]['cnt'];
1085
-                else return 0;
1267
+                if (isset($all[0]['cnt'])) {
1268
+                	return $all[0]['cnt'];
1269
+                } else {
1270
+                	return 0;
1271
+                }
1086 1272
         }
1087 1273
 	public function getStatsPilotTotal($filter_name = '') {
1088 1274
     		global $globalArchiveMonths, $globalDBdriver;
1089
-		if ($filter_name == '') $filter_name = $this->filter_name;
1275
+		if ($filter_name == '') {
1276
+			$filter_name = $this->filter_name;
1277
+		}
1090 1278
     		if ($globalDBdriver == 'mysql') {
1091 1279
             		$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
1092 1280
             	} else {
@@ -1103,7 +1291,9 @@  discard block
 block discarded – undo
1103 1291
         }
1104 1292
 	public function getStatsPilot($pilot,$filter_name = '') {
1105 1293
     		global $globalArchiveMonths, $globalDBdriver;
1106
-		if ($filter_name == '') $filter_name = $this->filter_name;
1294
+		if ($filter_name == '') {
1295
+			$filter_name = $this->filter_name;
1296
+		}
1107 1297
 		$query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)";
1108 1298
                  try {
1109 1299
                         $sth = $this->db->prepare($query);
@@ -1112,13 +1302,18 @@  discard block
 block discarded – undo
1112 1302
                         echo "error : ".$e->getMessage();
1113 1303
                 }
1114 1304
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
1115
-                if (isset($all[0]['cnt'])) return $all[0]['cnt'];
1116
-                else return 0;
1305
+                if (isset($all[0]['cnt'])) {
1306
+                	return $all[0]['cnt'];
1307
+                } else {
1308
+                	return 0;
1309
+                }
1117 1310
         }
1118 1311
 
1119 1312
 	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1120 1313
 		global $globalDBdriver;
1121
-		if ($filter_name == '') $filter_name = $this->filter_name;
1314
+		if ($filter_name == '') {
1315
+			$filter_name = $this->filter_name;
1316
+		}
1122 1317
 		if ($globalDBdriver == 'mysql') {
1123 1318
 			$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";
1124 1319
                 } else {
@@ -1134,7 +1329,9 @@  discard block
 block discarded – undo
1134 1329
         }
1135 1330
 	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1136 1331
 		global $globalDBdriver;
1137
-		if ($filter_name == '') $filter_name = $this->filter_name;
1332
+		if ($filter_name == '') {
1333
+			$filter_name = $this->filter_name;
1334
+		}
1138 1335
 		if ($globalDBdriver == 'mysql') {
1139 1336
 			$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";
1140 1337
 		} else {
@@ -1520,10 +1717,14 @@  discard block
 block discarded – undo
1520 1717
     		$Connection = new Connection();
1521 1718
     		date_default_timezone_set('UTC');
1522 1719
     		$last_update = $this->getLastStatsUpdate('last_update_stats');
1523
-			if ($globalDebug) echo 'Update stats !'."\n";
1720
+			if ($globalDebug) {
1721
+				echo 'Update stats !'."\n";
1722
+			}
1524 1723
 			if (isset($last_update[0]['value'])) {
1525 1724
 				$last_update_day = $last_update[0]['value'];
1526
-			} else $last_update_day = '2012-12-12 12:12:12';
1725
+			} else {
1726
+				$last_update_day = '2012-12-12 12:12:12';
1727
+			}
1527 1728
 			$reset = false;
1528 1729
 			//if ($globalStatsResetYear && date('Y',strtotime($last_update_day)) != date('Y')) {
1529 1730
 			if ($globalStatsResetYear) {
@@ -1532,42 +1733,60 @@  discard block
 block discarded – undo
1532 1733
 			}
1533 1734
 			$Spotter = new Spotter($this->db);
1534 1735
 
1535
-			if ($globalDebug) echo 'Count all aircraft types...'."\n";
1736
+			if ($globalDebug) {
1737
+				echo 'Count all aircraft types...'."\n";
1738
+			}
1536 1739
 			$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);
1537 1740
 			foreach ($alldata as $number) {
1538 1741
 				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset);
1539 1742
 			}
1540
-			if ($globalDebug) echo 'Count all airlines...'."\n";
1743
+			if ($globalDebug) {
1744
+				echo 'Count all airlines...'."\n";
1745
+			}
1541 1746
 			$alldata = $Spotter->countAllAirlines(false,0,$last_update_day);
1542 1747
 			foreach ($alldata as $number) {
1543 1748
 				$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset);
1544 1749
 			}
1545
-			if ($globalDebug) echo 'Count all registrations...'."\n";
1750
+			if ($globalDebug) {
1751
+				echo 'Count all registrations...'."\n";
1752
+			}
1546 1753
 			$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day);
1547 1754
 			foreach ($alldata as $number) {
1548 1755
 				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset);
1549 1756
 			}
1550
-			if ($globalDebug) echo 'Count all callsigns...'."\n";
1757
+			if ($globalDebug) {
1758
+				echo 'Count all callsigns...'."\n";
1759
+			}
1551 1760
 			$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day);
1552 1761
 			foreach ($alldata as $number) {
1553 1762
 				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
1554 1763
 			}
1555
-			if ($globalDebug) echo 'Count all owners...'."\n";
1764
+			if ($globalDebug) {
1765
+				echo 'Count all owners...'."\n";
1766
+			}
1556 1767
 			$alldata = $Spotter->countAllOwners(false,0,$last_update_day);
1557 1768
 			foreach ($alldata as $number) {
1558 1769
 				$this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset);
1559 1770
 			}
1560
-			if ($globalDebug) echo 'Count all pilots...'."\n";
1771
+			if ($globalDebug) {
1772
+				echo 'Count all pilots...'."\n";
1773
+			}
1561 1774
 			$alldata = $Spotter->countAllPilots(false,0,$last_update_day);
1562 1775
 			foreach ($alldata as $number) {
1563 1776
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset);
1564 1777
 			}
1565 1778
 			
1566
-			if ($globalDebug) echo 'Count all departure airports...'."\n";
1779
+			if ($globalDebug) {
1780
+				echo 'Count all departure airports...'."\n";
1781
+			}
1567 1782
 			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
1568
-			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
1783
+			if ($globalDebug) {
1784
+				echo 'Count all detected departure airports...'."\n";
1785
+			}
1569 1786
         		$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1570
-			if ($globalDebug) echo 'Order departure airports...'."\n";
1787
+			if ($globalDebug) {
1788
+				echo 'Order departure airports...'."\n";
1789
+			}
1571 1790
 	        	$alldata = array();
1572 1791
 	        	
1573 1792
     			foreach ($pall as $value) {
@@ -1578,7 +1797,9 @@  discard block
 block discarded – undo
1578 1797
     				$icao = $value['airport_departure_icao'];
1579 1798
         			if (isset($alldata[$icao])) {
1580 1799
     					$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1581
-        			} else $alldata[$icao] = $value;
1800
+        			} else {
1801
+        				$alldata[$icao] = $value;
1802
+        			}
1582 1803
 			}
1583 1804
     			$count = array();
1584 1805
     			foreach ($alldata as $key => $row) {
@@ -1588,11 +1809,17 @@  discard block
 block discarded – undo
1588 1809
 			foreach ($alldata as $number) {
1589 1810
 				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);
1590 1811
 			}
1591
-			if ($globalDebug) echo 'Count all arrival airports...'."\n";
1812
+			if ($globalDebug) {
1813
+				echo 'Count all arrival airports...'."\n";
1814
+			}
1592 1815
 			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
1593
-			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
1816
+			if ($globalDebug) {
1817
+				echo 'Count all detected arrival airports...'."\n";
1818
+			}
1594 1819
         		$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1595
-			if ($globalDebug) echo 'Order arrival airports...'."\n";
1820
+			if ($globalDebug) {
1821
+				echo 'Order arrival airports...'."\n";
1822
+			}
1596 1823
 	        	$alldata = array();
1597 1824
     			foreach ($pall as $value) {
1598 1825
 	        		$icao = $value['airport_arrival_icao'];
@@ -1602,7 +1829,9 @@  discard block
 block discarded – undo
1602 1829
     				$icao = $value['airport_arrival_icao'];
1603 1830
         			if (isset($alldata[$icao])) {
1604 1831
         				$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1605
-	        		} else $alldata[$icao] = $value;
1832
+	        		} else {
1833
+	        			$alldata[$icao] = $value;
1834
+	        		}
1606 1835
     			}
1607 1836
         		$count = array();
1608 1837
         		foreach ($alldata as $key => $row) {
@@ -1613,7 +1842,9 @@  discard block
 block discarded – undo
1613 1842
 				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);
1614 1843
 			}
1615 1844
 			if ($Connection->tableExists('countries')) {
1616
-				if ($globalDebug) echo 'Count all flights by countries...'."\n";
1845
+				if ($globalDebug) {
1846
+					echo 'Count all flights by countries...'."\n";
1847
+				}
1617 1848
 				$SpotterArchive = new SpotterArchive();
1618 1849
 				$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day);
1619 1850
 				foreach ($alldata as $number) {
@@ -1621,7 +1852,9 @@  discard block
 block discarded – undo
1621 1852
 				}
1622 1853
 			}
1623 1854
 			
1624
-			if ($globalDebug) echo 'Count fatalities stats...'."\n";
1855
+			if ($globalDebug) {
1856
+				echo 'Count fatalities stats...'."\n";
1857
+			}
1625 1858
 			$Accident = new Accident();
1626 1859
 			$this->deleteStatsByType('fatalities_byyear');
1627 1860
 			$alldata = $Accident->countFatalitiesByYear();
@@ -1638,46 +1871,66 @@  discard block
 block discarded – undo
1638 1871
 			// Add by month using getstat if month finish...
1639 1872
 
1640 1873
 			//if (date('m',strtotime($last_update_day)) != date('m')) {
1641
-			if ($globalDebug) echo 'Count all flights by months...'."\n";
1874
+			if ($globalDebug) {
1875
+				echo 'Count all flights by months...'."\n";
1876
+			}
1642 1877
 			$Spotter = new Spotter($this->db);
1643 1878
 			$alldata = $Spotter->countAllMonths();
1644 1879
 			$lastyear = false;
1645 1880
 			foreach ($alldata as $number) {
1646
-				if ($number['year_name'] != date('Y')) $lastyear = true;
1881
+				if ($number['year_name'] != date('Y')) {
1882
+					$lastyear = true;
1883
+				}
1647 1884
 				$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'])));
1648 1885
 			}
1649
-			if ($globalDebug) echo 'Count all military flights by months...'."\n";
1886
+			if ($globalDebug) {
1887
+				echo 'Count all military flights by months...'."\n";
1888
+			}
1650 1889
 			$alldata = $Spotter->countAllMilitaryMonths();
1651 1890
 			foreach ($alldata as $number) {
1652 1891
 				$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'])));
1653 1892
 			}
1654
-			if ($globalDebug) echo 'Count all owners by months...'."\n";
1893
+			if ($globalDebug) {
1894
+				echo 'Count all owners by months...'."\n";
1895
+			}
1655 1896
 			$alldata = $Spotter->countAllMonthsOwners();
1656 1897
 			foreach ($alldata as $number) {
1657 1898
 				$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'])));
1658 1899
 			}
1659
-			if ($globalDebug) echo 'Count all pilots by months...'."\n";
1900
+			if ($globalDebug) {
1901
+				echo 'Count all pilots by months...'."\n";
1902
+			}
1660 1903
 			$alldata = $Spotter->countAllMonthsPilots();
1661 1904
 			foreach ($alldata as $number) {
1662 1905
 				$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'])));
1663 1906
 			}
1664
-			if ($globalDebug) echo 'Count all airlines by months...'."\n";
1907
+			if ($globalDebug) {
1908
+				echo 'Count all airlines by months...'."\n";
1909
+			}
1665 1910
 			$alldata = $Spotter->countAllMonthsAirlines();
1666 1911
 			foreach ($alldata as $number) {
1667 1912
 				$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'])));
1668 1913
 			}
1669
-			if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
1914
+			if ($globalDebug) {
1915
+				echo 'Count all aircrafts by months...'."\n";
1916
+			}
1670 1917
 			$alldata = $Spotter->countAllMonthsAircrafts();
1671 1918
 			foreach ($alldata as $number) {
1672 1919
 				$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'])));
1673 1920
 			}
1674
-			if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
1921
+			if ($globalDebug) {
1922
+				echo 'Count all real arrivals by months...'."\n";
1923
+			}
1675 1924
 			$alldata = $Spotter->countAllMonthsRealArrivals();
1676 1925
 			foreach ($alldata as $number) {
1677 1926
 				$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'])));
1678 1927
 			}
1679
-			if ($globalDebug) echo 'Airports data...'."\n";
1680
-			if ($globalDebug) echo '...Departure'."\n";
1928
+			if ($globalDebug) {
1929
+				echo 'Airports data...'."\n";
1930
+			}
1931
+			if ($globalDebug) {
1932
+				echo '...Departure'."\n";
1933
+			}
1681 1934
 			$this->deleteStatAirport('daily');
1682 1935
 //			$pall = $Spotter->getLast7DaysAirportsDeparture();
1683 1936
   //      		$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
@@ -1798,44 +2051,62 @@  discard block
 block discarded – undo
1798 2051
 			// Count by airlines
1799 2052
 			echo '--- Stats by airlines ---'."\n";
1800 2053
 			if ($Connection->tableExists('countries')) {
1801
-				if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n";
2054
+				if ($globalDebug) {
2055
+					echo 'Count all flights by countries by airlines...'."\n";
2056
+				}
1802 2057
 				$SpotterArchive = new SpotterArchive();
1803 2058
 				$alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day);
1804 2059
 				foreach ($alldata as $number) {
1805 2060
 					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset);
1806 2061
 				}
1807 2062
 			}
1808
-			if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n";
2063
+			if ($globalDebug) {
2064
+				echo 'Count all aircraft types by airlines...'."\n";
2065
+			}
1809 2066
 			$Spotter = new Spotter($this->db);
1810 2067
 			$alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day);
1811 2068
 			foreach ($alldata as $number) {
1812 2069
 				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset);
1813 2070
 			}
1814
-			if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n";
2071
+			if ($globalDebug) {
2072
+				echo 'Count all aircraft registrations by airlines...'."\n";
2073
+			}
1815 2074
 			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day);
1816 2075
 			foreach ($alldata as $number) {
1817 2076
 				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset);
1818 2077
 			}
1819
-			if ($globalDebug) echo 'Count all callsigns by airlines...'."\n";
2078
+			if ($globalDebug) {
2079
+				echo 'Count all callsigns by airlines...'."\n";
2080
+			}
1820 2081
 			$alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day);
1821 2082
 			foreach ($alldata as $number) {
1822 2083
 				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
1823 2084
 			}
1824
-			if ($globalDebug) echo 'Count all owners by airlines...'."\n";
2085
+			if ($globalDebug) {
2086
+				echo 'Count all owners by airlines...'."\n";
2087
+			}
1825 2088
 			$alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day);
1826 2089
 			foreach ($alldata as $number) {
1827 2090
 				$this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset);
1828 2091
 			}
1829
-			if ($globalDebug) echo 'Count all pilots by airlines...'."\n";
2092
+			if ($globalDebug) {
2093
+				echo 'Count all pilots by airlines...'."\n";
2094
+			}
1830 2095
 			$alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day);
1831 2096
 			foreach ($alldata as $number) {
1832 2097
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset);
1833 2098
 			}
1834
-			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
2099
+			if ($globalDebug) {
2100
+				echo 'Count all departure airports by airlines...'."\n";
2101
+			}
1835 2102
 			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
1836
-			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
2103
+			if ($globalDebug) {
2104
+				echo 'Count all detected departure airports by airlines...'."\n";
2105
+			}
1837 2106
        			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
1838
-			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
2107
+			if ($globalDebug) {
2108
+				echo 'Order detected departure airports by airlines...'."\n";
2109
+			}
1839 2110
 	        	//$alldata = array();
1840 2111
     			foreach ($dall as $value) {
1841 2112
     				$icao = $value['airport_departure_icao'];
@@ -1856,11 +2127,17 @@  discard block
 block discarded – undo
1856 2127
 			foreach ($alldata as $number) {
1857 2128
 				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);
1858 2129
 			}
1859
-			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
2130
+			if ($globalDebug) {
2131
+				echo 'Count all arrival airports by airlines...'."\n";
2132
+			}
1860 2133
 			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
1861
-			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
2134
+			if ($globalDebug) {
2135
+				echo 'Count all detected arrival airports by airlines...'."\n";
2136
+			}
1862 2137
         		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
1863
-			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
2138
+			if ($globalDebug) {
2139
+				echo 'Order arrival airports by airlines...'."\n";
2140
+			}
1864 2141
 	        	//$alldata = array();
1865 2142
     			foreach ($dall as $value) {
1866 2143
     				$icao = $value['airport_arrival_icao'];
@@ -1879,37 +2156,53 @@  discard block
 block discarded – undo
1879 2156
     			}
1880 2157
     			$alldata = $pall;
1881 2158
                         foreach ($alldata as $number) {
1882
-				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);
2159
+				if ($number['airline_icao'] != '') {
2160
+					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);
2161
+				}
2162
+			}
2163
+			if ($globalDebug) {
2164
+				echo 'Count all flights by months by airlines...'."\n";
1883 2165
 			}
1884
-			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
1885 2166
 			$Spotter = new Spotter($this->db);
1886 2167
 			$alldata = $Spotter->countAllMonthsByAirlines();
1887 2168
 			$lastyear = false;
1888 2169
 			foreach ($alldata as $number) {
1889
-				if ($number['year_name'] != date('Y')) $lastyear = true;
2170
+				if ($number['year_name'] != date('Y')) {
2171
+					$lastyear = true;
2172
+				}
1890 2173
 				$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']);
1891 2174
 			}
1892
-			if ($globalDebug) echo 'Count all owners by months by airlines...'."\n";
2175
+			if ($globalDebug) {
2176
+				echo 'Count all owners by months by airlines...'."\n";
2177
+			}
1893 2178
 			$alldata = $Spotter->countAllMonthsOwnersByAirlines();
1894 2179
 			foreach ($alldata as $number) {
1895 2180
 				$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']);
1896 2181
 			}
1897
-			if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n";
2182
+			if ($globalDebug) {
2183
+				echo 'Count all pilots by months by airlines...'."\n";
2184
+			}
1898 2185
 			$alldata = $Spotter->countAllMonthsPilotsByAirlines();
1899 2186
 			foreach ($alldata as $number) {
1900 2187
 				$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']);
1901 2188
 			}
1902
-			if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n";
2189
+			if ($globalDebug) {
2190
+				echo 'Count all aircrafts by months by airlines...'."\n";
2191
+			}
1903 2192
 			$alldata = $Spotter->countAllMonthsAircraftsByAirlines();
1904 2193
 			foreach ($alldata as $number) {
1905 2194
 				$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']);
1906 2195
 			}
1907
-			if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n";
2196
+			if ($globalDebug) {
2197
+				echo 'Count all real arrivals by months by airlines...'."\n";
2198
+			}
1908 2199
 			$alldata = $Spotter->countAllMonthsRealArrivalsByAirlines();
1909 2200
 			foreach ($alldata as $number) {
1910 2201
 				$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']);
1911 2202
 			}
1912
-			if ($globalDebug) echo '...Departure'."\n";
2203
+			if ($globalDebug) {
2204
+				echo '...Departure'."\n";
2205
+			}
1913 2206
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
1914 2207
         		$dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines();
1915 2208
     			foreach ($dall as $value) {
@@ -1932,7 +2225,9 @@  discard block
 block discarded – undo
1932 2225
 			foreach ($alldata as $number) {
1933 2226
 				$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']);
1934 2227
 			}
1935
-			if ($globalDebug) echo '...Arrival'."\n";
2228
+			if ($globalDebug) {
2229
+				echo '...Arrival'."\n";
2230
+			}
1936 2231
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
1937 2232
         		$dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines();
1938 2233
     			foreach ($dall as $value) {
@@ -1956,13 +2251,19 @@  discard block
 block discarded – undo
1956 2251
 				$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']);
1957 2252
 			}
1958 2253
 
1959
-			if ($globalDebug) echo 'Flights data...'."\n";
1960
-			if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n";
2254
+			if ($globalDebug) {
2255
+				echo 'Flights data...'."\n";
2256
+			}
2257
+			if ($globalDebug) {
2258
+				echo '-> countAllDatesLastMonth...'."\n";
2259
+			}
1961 2260
 			$alldata = $Spotter->countAllDatesLastMonthByAirlines();
1962 2261
 			foreach ($alldata as $number) {
1963 2262
 				$this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']);
1964 2263
 			}
1965
-			if ($globalDebug) echo '-> countAllDates...'."\n";
2264
+			if ($globalDebug) {
2265
+				echo '-> countAllDates...'."\n";
2266
+			}
1966 2267
 			//$previousdata = $this->countAllDatesByAirlines();
1967 2268
 			$alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines());
1968 2269
 			$values = array();
@@ -1975,7 +2276,9 @@  discard block
 block discarded – undo
1975 2276
 				$this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']);
1976 2277
 			}
1977 2278
 			
1978
-			if ($globalDebug) echo '-> countAllHours...'."\n";
2279
+			if ($globalDebug) {
2280
+				echo '-> countAllHours...'."\n";
2281
+			}
1979 2282
 			$alldata = $Spotter->countAllHoursByAirlines('hour');
1980 2283
 			foreach ($alldata as $number) {
1981 2284
 				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']);
@@ -1983,14 +2286,18 @@  discard block
 block discarded – undo
1983 2286
 			
1984 2287
 
1985 2288
 			// Stats by filters
1986
-			if (!isset($globalStatsFilters) || $globalStatsFilters == '') $globalStatsFilters = array();
2289
+			if (!isset($globalStatsFilters) || $globalStatsFilters == '') {
2290
+				$globalStatsFilters = array();
2291
+			}
1987 2292
 			foreach ($globalStatsFilters as $name => $filter) {
1988 2293
 				//$filter_name = $filter['name'];
1989 2294
 				$filter_name = $name;
1990 2295
 				$reset = false;
1991 2296
 				$last_update = $this->getLastStatsUpdate('last_update_stats_'.$filter_name);
1992 2297
 				if (isset($filter['resetall']) && isset($last_update[0]['value']) && strtotime($filter['resetall']) > strtotime($last_update[0]['value'])) {
1993
-					if ($globalDebug) echo '!!! Delete stats for filter '.$filter_name.' !!!'."\n";
2298
+					if ($globalDebug) {
2299
+						echo '!!! Delete stats for filter '.$filter_name.' !!!'."\n";
2300
+					}
1994 2301
 					$this->deleteOldStats($filter_name);
1995 2302
 					unset($last_update);
1996 2303
 				}
@@ -2009,7 +2316,9 @@  discard block
 block discarded – undo
2009 2316
 				
2010 2317
 
2011 2318
 				// Count by filter
2012
-				if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n";
2319
+				if ($globalDebug) {
2320
+					echo '--- Stats for filter '.$filter_name.' ---'."\n";
2321
+				}
2013 2322
 				$Spotter = new Spotter($this->db);
2014 2323
 				$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter);
2015 2324
 				foreach ($alldata as $number) {
@@ -2046,7 +2355,9 @@  discard block
 block discarded – undo
2046 2355
 	    				$icao = $value['airport_departure_icao'];
2047 2356
         				if (isset($alldata[$icao])) {
2048 2357
     						$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
2049
-        				} else $alldata[$icao] = $value;
2358
+        				} else {
2359
+        					$alldata[$icao] = $value;
2360
+        				}
2050 2361
 				}
2051 2362
 	    			$count = array();
2052 2363
     				foreach ($alldata as $key => $row) {
@@ -2067,7 +2378,9 @@  discard block
 block discarded – undo
2067 2378
 	    				$icao = $value['airport_arrival_icao'];
2068 2379
         				if (isset($alldata[$icao])) {
2069 2380
         					$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
2070
-		        		} else $alldata[$icao] = $value;
2381
+		        		} else {
2382
+		        			$alldata[$icao] = $value;
2383
+		        		}
2071 2384
 	    			}
2072 2385
         			$count = array();
2073 2386
         			foreach ($alldata as $key => $row) {
@@ -2081,7 +2394,9 @@  discard block
 block discarded – undo
2081 2394
 				$alldata = $Spotter->countAllMonths($filter);
2082 2395
 				$lastyear = false;
2083 2396
 				foreach ($alldata as $number) {
2084
-					if ($number['year_name'] != date('Y')) $lastyear = true;
2397
+					if ($number['year_name'] != date('Y')) {
2398
+						$lastyear = true;
2399
+					}
2085 2400
 					$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);
2086 2401
 				}
2087 2402
 				$alldata = $Spotter->countAllMonthsOwners($filter);
Please login to merge, or discard this patch.
require/class.Connection.php 1 patch
Braces   +80 added lines, -31 removed lines patch added patch discarded remove patch
@@ -72,8 +72,11 @@  discard block
 block discarded – undo
72 72
 				$globalDBSname = $globalDBname;
73 73
 				$globalDBSuser = $globalDBuser;
74 74
 				$globalDBSpass = $globalDBpass;
75
-				if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') $globalDBSport = 3306;
76
-				else $globalDBSport = $globalDBport;
75
+				if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') {
76
+					$globalDBSport = 3306;
77
+				} else {
78
+					$globalDBSport = $globalDBport;
79
+				}
77 80
 			} else {
78 81
 				$DBname = 'default';
79 82
 				$globalDBSdriver = $globalDBdriver;
@@ -81,8 +84,11 @@  discard block
 block discarded – undo
81 84
 				$globalDBSname = $globalDBname;
82 85
 				$globalDBSuser = $user;
83 86
 				$globalDBSpass = $pass;
84
-				if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') $globalDBSport = 3306;
85
-				else $globalDBSport = $globalDBport;
87
+				if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') {
88
+					$globalDBSport = 3306;
89
+				} else {
90
+					$globalDBSport = $globalDBport;
91
+				}
86 92
 			}
87 93
 		} else {
88 94
 			$globalDBSdriver = $globalDB[$DBname]['driver'];
@@ -90,11 +96,16 @@  discard block
 block discarded – undo
90 96
 			$globalDBSname = $globalDB[$DBname]['name'];
91 97
 			$globalDBSuser = $globalDB[$DBname]['user'];
92 98
 			$globalDBSpass = $globalDB[$DBname]['pass'];
93
-			if (isset($globalDB[$DBname]['port'])) $globalDBSport = $globalDB[$DBname]['port'];
94
-			else $globalDBSport = 3306;
99
+			if (isset($globalDB[$DBname]['port'])) {
100
+				$globalDBSport = $globalDB[$DBname]['port'];
101
+			} else {
102
+				$globalDBSport = 3306;
103
+			}
95 104
 		}
96 105
 		// Set number of try to connect to DB
97
-		if (!isset($globalDBretry) || $globalDBretry == '' || $globalDBretry === NULL) $globalDBretry = 5;
106
+		if (!isset($globalDBretry) || $globalDBretry == '' || $globalDBretry === NULL) {
107
+			$globalDBretry = 5;
108
+		}
98 109
 		$i = 0;
99 110
 		while (true) {
100 111
 			try {
@@ -103,10 +114,16 @@  discard block
 block discarded – undo
103 114
 					$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'");
104 115
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
105 116
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER);
106
-					if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,500);
107
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut);
108
-					if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true);
109
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent);
117
+					if (!isset($globalDBTimeOut)) {
118
+						$this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,500);
119
+					} else {
120
+						$this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut);
121
+					}
122
+					if (!isset($globalDBPersistent)) {
123
+						$this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true);
124
+					} else {
125
+						$this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent);
126
+					}
110 127
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
111 128
 					$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
112 129
 					// Workaround against "ONLY_FULL_GROUP_BY" mode
@@ -120,23 +137,35 @@  discard block
 block discarded – undo
120 137
 					//$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'");
121 138
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
122 139
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER);
123
-					if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200);
124
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut);
125
-					if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true);
126
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent);
140
+					if (!isset($globalDBTimeOut)) {
141
+						$this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200);
142
+					} else {
143
+						$this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut);
144
+					}
145
+					if (!isset($globalDBPersistent)) {
146
+						$this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true);
147
+					} else {
148
+						$this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent);
149
+					}
127 150
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
128 151
 					$this->dbs[$DBname]->exec('SET timezone="UTC"');
129 152
 				}
130 153
 				break;
131 154
 			} catch(PDOException $e) {
132 155
 				$i++;
133
-				if (isset($globalDebug) && $globalDebug) echo 'Error connecting to DB: '.$globalDBSname.' - Error: '.$e->getMessage()."\n";
156
+				if (isset($globalDebug) && $globalDebug) {
157
+					echo 'Error connecting to DB: '.$globalDBSname.' - Error: '.$e->getMessage()."\n";
158
+				}
134 159
 				//exit;
135
-				if ($i > $globalDBretry) return false;
160
+				if ($i > $globalDBretry) {
161
+					return false;
162
+				}
136 163
 				//return false;
137 164
 			}
138 165
 		}
139
-		if ($DBname === 'default') $this->db = $this->dbs['default'];
166
+		if ($DBname === 'default') {
167
+			$this->db = $this->dbs['default'];
168
+		}
140 169
 		return true;
141 170
 	}
142 171
 
@@ -148,7 +177,9 @@  discard block
 block discarded – undo
148 177
 		} else {
149 178
 			$query = "SELECT * FROM pg_catalog.pg_tables WHERE tablename = '".$table."'";
150 179
 		}
151
-		if ($this->db == NULL) return false;
180
+		if ($this->db == NULL) {
181
+			return false;
182
+		}
152 183
 		try {
153 184
 			//$Connection = new Connection();
154 185
 			$results = $this->db->query($query);
@@ -157,21 +188,28 @@  discard block
 block discarded – undo
157 188
 		}
158 189
 		if($results->rowCount()>0) {
159 190
 		    return true; 
191
+		} else {
192
+			return false;
160 193
 		}
161
-		else return false;
162 194
 	}
163 195
 
164 196
 	public function connectionExists()
165 197
 	{
166 198
 		global $globalDBdriver, $globalDBCheckConnection;
167
-		if (isset($globalDBCheckConnection) && $globalDBCheckConnection === FALSE) return true;
199
+		if (isset($globalDBCheckConnection) && $globalDBCheckConnection === FALSE) {
200
+			return true;
201
+		}
168 202
 		$query = "SELECT 1 + 1";
169
-		if ($this->db === null) return false;
203
+		if ($this->db === null) {
204
+			return false;
205
+		}
170 206
 		try {
171 207
 			$sum = @$this->db->query($query);
172 208
 			if ($sum instanceof \PDOStatement) {
173 209
 				$sum = $sum->fetchColumn(0);
174
-			} else $sum = 0;
210
+			} else {
211
+				$sum = 0;
212
+			}
175 213
 			if (intval($sum) !== 2) {
176 214
 			     return false;
177 215
 			}
@@ -206,8 +244,9 @@  discard block
 block discarded – undo
206 244
 		$nb = $results->fetchAll(PDO::FETCH_ASSOC);
207 245
 		if($nb[0]['nb'] > 0) {
208 246
 			return true; 
247
+		} else {
248
+			return false;
209 249
 		}
210
-		else return false;
211 250
 	}
212 251
 
213 252
 	/*
@@ -257,9 +296,12 @@  discard block
 block discarded – undo
257 296
 			}
258 297
 			$result = $sth->fetch(PDO::FETCH_ASSOC);
259 298
 			$sth->closeCursor();
260
-			if ($result['nb'] > 0) return true;
261
-			else return false;
262
-/*		} else {
299
+			if ($result['nb'] > 0) {
300
+				return true;
301
+			} else {
302
+				return false;
303
+			}
304
+			/*		} else {
263 305
 			$query = "SELECT * FROM ".$table." LIMIT 0";
264 306
 			try {
265 307
 				$results = $this->db->query($query);
@@ -298,7 +340,9 @@  discard block
 block discarded – undo
298 340
 				$sth->closeCursor();
299 341
 				return $result['value'];
300 342
 			}
301
-		} else return $version;
343
+		} else {
344
+			return $version;
345
+		}
302 346
 	}
303 347
 	
304 348
 	/*
@@ -307,9 +351,14 @@  discard block
 block discarded – undo
307 351
 	*/
308 352
 	public function latest() {
309 353
 	    global $globalNoDB;
310
-	    if (isset($globalNoDB) && $globalNoDB === TRUE) return true;
311
-	    if ($this->check_schema_version() == $this->latest_schema) return true;
312
-	    else return false;
354
+	    if (isset($globalNoDB) && $globalNoDB === TRUE) {
355
+	    	return true;
356
+	    }
357
+	    if ($this->check_schema_version() == $this->latest_schema) {
358
+	    	return true;
359
+	    } else {
360
+	    	return false;
361
+	    }
313 362
 	}
314 363
 
315 364
 }
Please login to merge, or discard this patch.
incident.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 require_once(dirname(__FILE__).'/require/settings.php');
3 3
 $date = filter_input(INPUT_POST,'date',FILTER_SANITIZE_STRING);
4
-if ($date == '') $date = date('Y-m-d');
4
+if ($date == '') {
5
+	$date = date('Y-m-d');
6
+}
5 7
 header('Location: '.$globalURL.'/incident/'.$date);
6 8
 ?>
7 9
\ No newline at end of file
Please login to merge, or discard this patch.
install/class.update_schema.php 1 patch
Braces   +323 added lines, -120 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 {
@@ -804,12 +856,16 @@  discard block
 block discarded – undo
804 856
 		if ($globalDBdriver == 'mysql') {
805 857
 			if (!$Connection->tableExists('tle')) {
806 858
 				$error .= create_db::import_file('../db/tle.sql');
807
-				if ($error != '') return $error;
859
+				if ($error != '') {
860
+					return $error;
861
+				}
808 862
 			}
809 863
 		} else {
810 864
 			if (!$Connection->tableExists('tle')) {
811 865
 				$error .= create_db::import_file('../db/pgsql/tle.sql');
812
-				if ($error != '') return $error;
866
+				if ($error != '') {
867
+					return $error;
868
+				}
813 869
 			}
814 870
 			$query = "create index flightaware_id_idx ON spotter_archive USING btree(flightaware_id)";
815 871
 			try {
@@ -849,7 +905,9 @@  discard block
 block discarded – undo
849 905
 		} else {
850 906
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
851 907
 		}
852
-		if ($error != '') return 'Import airlines.sql : '.$error;
908
+		if ($error != '') {
909
+			return 'Import airlines.sql : '.$error;
910
+		}
853 911
 		if (!$Connection->checkColumnName('airlines','forsource')) {
854 912
 			// Add forsource to airlines
855 913
 			$query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL";
@@ -1332,20 +1390,28 @@  discard block
 block discarded – undo
1332 1390
 		}
1333 1391
 		if ($globalDBdriver == 'mysql') {
1334 1392
 			$error .= create_db::import_file('../db/airlines.sql');
1335
-			if ($error != '') return $error;
1393
+			if ($error != '') {
1394
+				return $error;
1395
+			}
1336 1396
 		} else {
1337 1397
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
1338
-			if ($error != '') return $error;
1398
+			if ($error != '') {
1399
+				return $error;
1400
+			}
1339 1401
 		}
1340 1402
 		if ((isset($globalVATSIM) && $globalVATSIM) || (isset($globalIVAO) && $globalIVAO)) {
1341 1403
 			include_once(dirname(__FILE__).'/class.update_db.php');
1342 1404
 			if (isset($globalVATSIM) && $globalVATSIM) {
1343 1405
 				$error .= update_db::update_vatsim();
1344
-				if ($error != '') return $error;
1406
+				if ($error != '') {
1407
+					return $error;
1408
+				}
1345 1409
 			}
1346 1410
 			if (isset($globalIVAO) && $globalIVAO && file_exists('tmp/ivae_feb2013.zip')) {
1347 1411
 				$error .= update_db::update_IVAO();
1348
-				if ($error != '') return $error;
1412
+				if ($error != '') {
1413
+					return $error;
1414
+				}
1349 1415
 			}
1350 1416
 		}
1351 1417
 
@@ -1608,41 +1674,65 @@  discard block
 block discarded – undo
1608 1674
 		if ($globalDBdriver == 'mysql') {
1609 1675
 			if (!$Connection->tableExists('tracker_output')) {
1610 1676
 				$error .= create_db::import_file('../db/tracker_output.sql');
1611
-				if ($error != '') return $error;
1677
+				if ($error != '') {
1678
+					return $error;
1679
+				}
1612 1680
 			}
1613 1681
 			if (!$Connection->tableExists('tracker_live')) {
1614 1682
 				$error .= create_db::import_file('../db/tracker_live.sql');
1615
-				if ($error != '') return $error;
1683
+				if ($error != '') {
1684
+					return $error;
1685
+				}
1616 1686
 			}
1617 1687
 			if (!$Connection->tableExists('marine_output')) {
1618 1688
 				$error .= create_db::import_file('../db/marine_output.sql');
1619
-				if ($error != '') return $error;
1689
+				if ($error != '') {
1690
+					return $error;
1691
+				}
1620 1692
 			}
1621 1693
 			if (!$Connection->tableExists('marine_live')) {
1622 1694
 				$error .= create_db::import_file('../db/marine_live.sql');
1623
-				if ($error != '') return $error;
1695
+				if ($error != '') {
1696
+					return $error;
1697
+				}
1624 1698
 			}
1625 1699
 			if (!$Connection->tableExists('marine_identity')) {
1626 1700
 				$error .= create_db::import_file('../db/marine_identity.sql');
1627
-				if ($error != '') return $error;
1701
+				if ($error != '') {
1702
+					return $error;
1703
+				}
1628 1704
 			}
1629 1705
 			if (!$Connection->tableExists('marine_mid')) {
1630 1706
 				$error .= create_db::import_file('../db/marine_mid.sql');
1631
-				if ($error != '') return $error;
1707
+				if ($error != '') {
1708
+					return $error;
1709
+				}
1632 1710
 			}
1633 1711
 		} else {
1634 1712
 			$error .= create_db::import_file('../db/pgsql/tracker_output.sql');
1635
-			if ($error != '') return $error;
1713
+			if ($error != '') {
1714
+				return $error;
1715
+			}
1636 1716
 			$error .= create_db::import_file('../db/pgsql/tracker_live.sql');
1637
-			if ($error != '') return $error;
1717
+			if ($error != '') {
1718
+				return $error;
1719
+			}
1638 1720
 			$error .= create_db::import_file('../db/pgsql/marine_output.sql');
1639
-			if ($error != '') return $error;
1721
+			if ($error != '') {
1722
+				return $error;
1723
+			}
1640 1724
 			$error .= create_db::import_file('../db/pgsql/marine_live.sql');
1641
-			if ($error != '') return $error;
1725
+			if ($error != '') {
1726
+				return $error;
1727
+			}
1642 1728
 			$error .= create_db::import_file('../db/pgsql/marine_identity.sql');
1643
-			if ($error != '') return $error;
1729
+			if ($error != '') {
1730
+				return $error;
1731
+			}
1644 1732
 			$error .= create_db::import_file('../db/pgsql/marine_mid.sql');
1645
-			if ($error != '') return $error;
1733
+			if ($error != '') {
1734
+				return $error;
1735
+			}
1646 1736
 		}
1647 1737
 		$query = "UPDATE config SET value = '37' WHERE name = 'schema_version'";
1648 1738
 		try {
@@ -1662,8 +1752,11 @@  discard block
 block discarded – undo
1662 1752
     	    if ($Connection->tableExists('aircraft')) {
1663 1753
     		if (!$Connection->tableExists('config')) {
1664 1754
     		    $version = '1';
1665
-    		    if ($update) return self::update_from_1();
1666
-    		    else return $version;
1755
+    		    if ($update) {
1756
+    		    	return self::update_from_1();
1757
+    		    } else {
1758
+    		    	return $version;
1759
+    		    }
1667 1760
 		} else {
1668 1761
     		    $Connection = new Connection();
1669 1762
 		    $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
@@ -1677,150 +1770,260 @@  discard block
 block discarded – undo
1677 1770
     		    if ($update) {
1678 1771
     			if ($result['value'] == '2') {
1679 1772
     			    $error = self::update_from_2();
1680
-    			    if ($error != '') return $error;
1681
-    			    else return self::check_version(true);
1773
+    			    if ($error != '') {
1774
+    			    	return $error;
1775
+    			    } else {
1776
+    			    	return self::check_version(true);
1777
+    			    }
1682 1778
     			} elseif ($result['value'] == '3') {
1683 1779
     			    $error = self::update_from_3();
1684
-    			    if ($error != '') return $error;
1685
-    			    else return self::check_version(true);
1780
+    			    if ($error != '') {
1781
+    			    	return $error;
1782
+    			    } else {
1783
+    			    	return self::check_version(true);
1784
+    			    }
1686 1785
     			} elseif ($result['value'] == '4') {
1687 1786
     			    $error = self::update_from_4();
1688
-    			    if ($error != '') return $error;
1689
-    			    else return self::check_version(true);
1787
+    			    if ($error != '') {
1788
+    			    	return $error;
1789
+    			    } else {
1790
+    			    	return self::check_version(true);
1791
+    			    }
1690 1792
     			} elseif ($result['value'] == '5') {
1691 1793
     			    $error = self::update_from_5();
1692
-    			    if ($error != '') return $error;
1693
-    			    else return self::check_version(true);
1794
+    			    if ($error != '') {
1795
+    			    	return $error;
1796
+    			    } else {
1797
+    			    	return self::check_version(true);
1798
+    			    }
1694 1799
     			} elseif ($result['value'] == '6') {
1695 1800
     			    $error = self::update_from_6();
1696
-    			    if ($error != '') return $error;
1697
-    			    else return self::check_version(true);
1801
+    			    if ($error != '') {
1802
+    			    	return $error;
1803
+    			    } else {
1804
+    			    	return self::check_version(true);
1805
+    			    }
1698 1806
     			} elseif ($result['value'] == '7') {
1699 1807
     			    $error = self::update_from_7();
1700
-    			    if ($error != '') return $error;
1701
-    			    else return self::check_version(true);
1808
+    			    if ($error != '') {
1809
+    			    	return $error;
1810
+    			    } else {
1811
+    			    	return self::check_version(true);
1812
+    			    }
1702 1813
     			} elseif ($result['value'] == '8') {
1703 1814
     			    $error = self::update_from_8();
1704
-    			    if ($error != '') return $error;
1705
-    			    else return self::check_version(true);
1815
+    			    if ($error != '') {
1816
+    			    	return $error;
1817
+    			    } else {
1818
+    			    	return self::check_version(true);
1819
+    			    }
1706 1820
     			} elseif ($result['value'] == '9') {
1707 1821
     			    $error = self::update_from_9();
1708
-    			    if ($error != '') return $error;
1709
-    			    else return self::check_version(true);
1822
+    			    if ($error != '') {
1823
+    			    	return $error;
1824
+    			    } else {
1825
+    			    	return self::check_version(true);
1826
+    			    }
1710 1827
     			} elseif ($result['value'] == '10') {
1711 1828
     			    $error = self::update_from_10();
1712
-    			    if ($error != '') return $error;
1713
-    			    else return self::check_version(true);
1829
+    			    if ($error != '') {
1830
+    			    	return $error;
1831
+    			    } else {
1832
+    			    	return self::check_version(true);
1833
+    			    }
1714 1834
     			} elseif ($result['value'] == '11') {
1715 1835
     			    $error = self::update_from_11();
1716
-    			    if ($error != '') return $error;
1717
-    			    else return self::check_version(true);
1836
+    			    if ($error != '') {
1837
+    			    	return $error;
1838
+    			    } else {
1839
+    			    	return self::check_version(true);
1840
+    			    }
1718 1841
     			} elseif ($result['value'] == '12') {
1719 1842
     			    $error = self::update_from_12();
1720
-    			    if ($error != '') return $error;
1721
-    			    else return self::check_version(true);
1843
+    			    if ($error != '') {
1844
+    			    	return $error;
1845
+    			    } else {
1846
+    			    	return self::check_version(true);
1847
+    			    }
1722 1848
     			} elseif ($result['value'] == '13') {
1723 1849
     			    $error = self::update_from_13();
1724
-    			    if ($error != '') return $error;
1725
-    			    else return self::check_version(true);
1850
+    			    if ($error != '') {
1851
+    			    	return $error;
1852
+    			    } else {
1853
+    			    	return self::check_version(true);
1854
+    			    }
1726 1855
     			} elseif ($result['value'] == '14') {
1727 1856
     			    $error = self::update_from_14();
1728
-    			    if ($error != '') return $error;
1729
-    			    else return self::check_version(true);
1857
+    			    if ($error != '') {
1858
+    			    	return $error;
1859
+    			    } else {
1860
+    			    	return self::check_version(true);
1861
+    			    }
1730 1862
     			} elseif ($result['value'] == '15') {
1731 1863
     			    $error = self::update_from_15();
1732
-    			    if ($error != '') return $error;
1733
-    			    else return self::check_version(true);
1864
+    			    if ($error != '') {
1865
+    			    	return $error;
1866
+    			    } else {
1867
+    			    	return self::check_version(true);
1868
+    			    }
1734 1869
     			} elseif ($result['value'] == '16') {
1735 1870
     			    $error = self::update_from_16();
1736
-    			    if ($error != '') return $error;
1737
-    			    else return self::check_version(true);
1871
+    			    if ($error != '') {
1872
+    			    	return $error;
1873
+    			    } else {
1874
+    			    	return self::check_version(true);
1875
+    			    }
1738 1876
     			} elseif ($result['value'] == '17') {
1739 1877
     			    $error = self::update_from_17();
1740
-    			    if ($error != '') return $error;
1741
-    			    else return self::check_version(true);
1878
+    			    if ($error != '') {
1879
+    			    	return $error;
1880
+    			    } else {
1881
+    			    	return self::check_version(true);
1882
+    			    }
1742 1883
     			} elseif ($result['value'] == '18') {
1743 1884
     			    $error = self::update_from_18();
1744
-    			    if ($error != '') return $error;
1745
-    			    else return self::check_version(true);
1885
+    			    if ($error != '') {
1886
+    			    	return $error;
1887
+    			    } else {
1888
+    			    	return self::check_version(true);
1889
+    			    }
1746 1890
     			} elseif ($result['value'] == '19') {
1747 1891
     			    $error = self::update_from_19();
1748
-    			    if ($error != '') return $error;
1749
-    			    else return self::check_version(true);
1892
+    			    if ($error != '') {
1893
+    			    	return $error;
1894
+    			    } else {
1895
+    			    	return self::check_version(true);
1896
+    			    }
1750 1897
     			} elseif ($result['value'] == '20') {
1751 1898
     			    $error = self::update_from_20();
1752
-    			    if ($error != '') return $error;
1753
-    			    else return self::check_version(true);
1899
+    			    if ($error != '') {
1900
+    			    	return $error;
1901
+    			    } else {
1902
+    			    	return self::check_version(true);
1903
+    			    }
1754 1904
     			} elseif ($result['value'] == '21') {
1755 1905
     			    $error = self::update_from_21();
1756
-    			    if ($error != '') return $error;
1757
-    			    else return self::check_version(true);
1906
+    			    if ($error != '') {
1907
+    			    	return $error;
1908
+    			    } else {
1909
+    			    	return self::check_version(true);
1910
+    			    }
1758 1911
     			} elseif ($result['value'] == '22') {
1759 1912
     			    $error = self::update_from_22();
1760
-    			    if ($error != '') return $error;
1761
-    			    else return self::check_version(true);
1913
+    			    if ($error != '') {
1914
+    			    	return $error;
1915
+    			    } else {
1916
+    			    	return self::check_version(true);
1917
+    			    }
1762 1918
     			} elseif ($result['value'] == '23') {
1763 1919
     			    $error = self::update_from_23();
1764
-    			    if ($error != '') return $error;
1765
-    			    else return self::check_version(true);
1920
+    			    if ($error != '') {
1921
+    			    	return $error;
1922
+    			    } else {
1923
+    			    	return self::check_version(true);
1924
+    			    }
1766 1925
     			} elseif ($result['value'] == '24') {
1767 1926
     			    $error = self::update_from_24();
1768
-    			    if ($error != '') return $error;
1769
-    			    else return self::check_version(true);
1927
+    			    if ($error != '') {
1928
+    			    	return $error;
1929
+    			    } else {
1930
+    			    	return self::check_version(true);
1931
+    			    }
1770 1932
     			} elseif ($result['value'] == '25') {
1771 1933
     			    $error = self::update_from_25();
1772
-    			    if ($error != '') return $error;
1773
-    			    else return self::check_version(true);
1934
+    			    if ($error != '') {
1935
+    			    	return $error;
1936
+    			    } else {
1937
+    			    	return self::check_version(true);
1938
+    			    }
1774 1939
     			} elseif ($result['value'] == '26') {
1775 1940
     			    $error = self::update_from_26();
1776
-    			    if ($error != '') return $error;
1777
-    			    else return self::check_version(true);
1941
+    			    if ($error != '') {
1942
+    			    	return $error;
1943
+    			    } else {
1944
+    			    	return self::check_version(true);
1945
+    			    }
1778 1946
     			} elseif ($result['value'] == '27') {
1779 1947
     			    $error = self::update_from_27();
1780
-    			    if ($error != '') return $error;
1781
-    			    else return self::check_version(true);
1948
+    			    if ($error != '') {
1949
+    			    	return $error;
1950
+    			    } else {
1951
+    			    	return self::check_version(true);
1952
+    			    }
1782 1953
     			} elseif ($result['value'] == '28') {
1783 1954
     			    $error = self::update_from_28();
1784
-    			    if ($error != '') return $error;
1785
-    			    else return self::check_version(true);
1955
+    			    if ($error != '') {
1956
+    			    	return $error;
1957
+    			    } else {
1958
+    			    	return self::check_version(true);
1959
+    			    }
1786 1960
     			} elseif ($result['value'] == '29') {
1787 1961
     			    $error = self::update_from_29();
1788
-    			    if ($error != '') return $error;
1789
-    			    else return self::check_version(true);
1962
+    			    if ($error != '') {
1963
+    			    	return $error;
1964
+    			    } else {
1965
+    			    	return self::check_version(true);
1966
+    			    }
1790 1967
     			} elseif ($result['value'] == '30') {
1791 1968
     			    $error = self::update_from_30();
1792
-    			    if ($error != '') return $error;
1793
-    			    else return self::check_version(true);
1969
+    			    if ($error != '') {
1970
+    			    	return $error;
1971
+    			    } else {
1972
+    			    	return self::check_version(true);
1973
+    			    }
1794 1974
     			} elseif ($result['value'] == '31') {
1795 1975
     			    $error = self::update_from_31();
1796
-    			    if ($error != '') return $error;
1797
-    			    else return self::check_version(true);
1976
+    			    if ($error != '') {
1977
+    			    	return $error;
1978
+    			    } else {
1979
+    			    	return self::check_version(true);
1980
+    			    }
1798 1981
     			} elseif ($result['value'] == '32') {
1799 1982
     			    $error = self::update_from_32();
1800
-    			    if ($error != '') return $error;
1801
-    			    else return self::check_version(true);
1983
+    			    if ($error != '') {
1984
+    			    	return $error;
1985
+    			    } else {
1986
+    			    	return self::check_version(true);
1987
+    			    }
1802 1988
     			} elseif ($result['value'] == '33') {
1803 1989
     			    $error = self::update_from_33();
1804
-    			    if ($error != '') return $error;
1805
-    			    else return self::check_version(true);
1990
+    			    if ($error != '') {
1991
+    			    	return $error;
1992
+    			    } else {
1993
+    			    	return self::check_version(true);
1994
+    			    }
1806 1995
     			} elseif ($result['value'] == '34') {
1807 1996
     			    $error = self::update_from_34();
1808
-    			    if ($error != '') return $error;
1809
-    			    else return self::check_version(true);
1997
+    			    if ($error != '') {
1998
+    			    	return $error;
1999
+    			    } else {
2000
+    			    	return self::check_version(true);
2001
+    			    }
1810 2002
     			} elseif ($result['value'] == '35') {
1811 2003
     			    $error = self::update_from_35();
1812
-    			    if ($error != '') return $error;
1813
-    			    else return self::check_version(true);
2004
+    			    if ($error != '') {
2005
+    			    	return $error;
2006
+    			    } else {
2007
+    			    	return self::check_version(true);
2008
+    			    }
1814 2009
     			} elseif ($result['value'] == '36') {
1815 2010
     			    $error = self::update_from_36();
1816
-    			    if ($error != '') return $error;
1817
-    			    else return self::check_version(true);
1818
-    			} else return '';
2011
+    			    if ($error != '') {
2012
+    			    	return $error;
2013
+    			    } else {
2014
+    			    	return self::check_version(true);
2015
+    			    }
2016
+    			} else {
2017
+    				return '';
2018
+    			}
2019
+    		    } else {
2020
+    		    	return $result['value'];
1819 2021
     		    }
1820
-    		    else return $result['value'];
1821 2022
 		}
1822 2023
 		
1823
-	    } else return $version;
2024
+	    } else {
2025
+	    	return $version;
2026
+	    }
1824 2027
     	}
1825 2028
     	
1826 2029
 }
Please login to merge, or discard this patch.
require/class.Image.php 1 patch
Braces   +138 added lines, -51 removed lines patch added patch discarded remove patch
@@ -23,7 +23,9 @@  discard block
 block discarded – undo
23 23
 		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
24 24
 		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
25 25
 		$reg = $registration;
26
-		if ($reg == '' && $aircraft_icao != '') $reg = $aircraft_icao.$airline_icao;
26
+		if ($reg == '' && $aircraft_icao != '') {
27
+			$reg = $aircraft_icao.$airline_icao;
28
+		}
27 29
 		$reg = trim($reg);
28 30
 		$query  = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright, spotter_image.registration 
29 31
 			FROM spotter_image 
@@ -31,8 +33,11 @@  discard block
 block discarded – undo
31 33
 		$sth = $this->db->prepare($query);
32 34
 		$sth->execute(array(':registration' => $reg));
33 35
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
34
-		if (!empty($result)) return $result;
35
-		elseif ($registration != '') return $this->getSpotterImage('',$aircraft_icao,$airline_icao);
36
+		if (!empty($result)) {
37
+			return $result;
38
+		} elseif ($registration != '') {
39
+			return $this->getSpotterImage('',$aircraft_icao,$airline_icao);
40
+		}
36 41
 	}
37 42
 
38 43
 	/**
@@ -44,8 +49,11 @@  discard block
 block discarded – undo
44 49
 	public function getExifCopyright($url) {
45 50
 		$exif = exif_read_data($url);
46 51
 		$copyright = '';
47
-		if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright'];
48
-		elseif (isset($exif['copyright'])) $copyright = $exif['copyright'];
52
+		if (isset($exif['COMPUTED']['copyright'])) {
53
+			$copyright = $exif['COMPUTED']['copyright'];
54
+		} elseif (isset($exif['copyright'])) {
55
+			$copyright = $exif['copyright'];
56
+		}
49 57
 		if ($copyright != '') {
50 58
 			$copyright = str_replace('Copyright ','',$copyright);
51 59
 			$copyright = str_replace('© ','',$copyright);
@@ -63,18 +71,29 @@  discard block
 block discarded – undo
63 71
 	public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
64 72
 	{
65 73
 		global $globalDebug,$globalAircraftImageFetch;
66
-		if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) return '';
74
+		if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) {
75
+			return '';
76
+		}
67 77
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
68 78
 		$registration = trim($registration);
69 79
 		//getting the aircraft image
70
-		if ($globalDebug && $registration != '') echo 'Try to find an aircraft image for '.$registration.'...';
71
-		elseif ($globalDebug && $aircraft_icao != '') echo 'Try to find an aircraft image for '.$aircraft_icao.'...';
72
-		elseif ($globalDebug && $airline_icao != '') echo 'Try to find an aircraft image for '.$airline_icao.'...';
73
-		else return "success";
80
+		if ($globalDebug && $registration != '') {
81
+			echo 'Try to find an aircraft image for '.$registration.'...';
82
+		} elseif ($globalDebug && $aircraft_icao != '') {
83
+			echo 'Try to find an aircraft image for '.$aircraft_icao.'...';
84
+		} elseif ($globalDebug && $airline_icao != '') {
85
+			echo 'Try to find an aircraft image for '.$airline_icao.'...';
86
+		} else {
87
+			return "success";
88
+		}
74 89
 		$image_url = $this->findAircraftImage($registration,$aircraft_icao,$airline_icao);
75
-		if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao;
90
+		if ($registration == '' && $aircraft_icao != '') {
91
+			$registration = $aircraft_icao.$airline_icao;
92
+		}
76 93
 		if ($image_url['original'] != '') {
77
-			if ($globalDebug) echo 'Found !'."\n";
94
+			if ($globalDebug) {
95
+				echo 'Found !'."\n";
96
+			}
78 97
 			$query  = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)";
79 98
 			try {
80 99
 				$sth = $this->db->prepare($query);
@@ -83,7 +102,9 @@  discard block
 block discarded – undo
83 102
 				echo $e->getMessage()."\n";
84 103
 				return "error";
85 104
 			}
86
-		} elseif ($globalDebug) echo "Not found :'(\n";
105
+		} elseif ($globalDebug) {
106
+			echo "Not found :'(\n";
107
+		}
87 108
 		return "success";
88 109
 	}
89 110
 
@@ -98,40 +119,84 @@  discard block
 block discarded – undo
98 119
 	{
99 120
 		global $globalAircraftImageSources, $globalIVAO, $globalAircraftImageCheckICAO;
100 121
 		$Spotter = new Spotter($this->db);
101
-		if (!isset($globalIVAO)) $globalIVAO = FALSE;
122
+		if (!isset($globalIVAO)) {
123
+			$globalIVAO = FALSE;
124
+		}
102 125
 		$aircraft_registration = filter_var($aircraft_registration,FILTER_SANITIZE_STRING);
103 126
 		if ($aircraft_registration != '') {
104
-			if (strpos($aircraft_registration,'/') !== false) return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
127
+			if (strpos($aircraft_registration,'/') !== false) {
128
+				return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
129
+			}
105 130
 			$aircraft_registration = urlencode(trim($aircraft_registration));
106 131
 			$aircraft_info = $Spotter->getAircraftInfoByRegistration($aircraft_registration);
107
-			if (isset($aircraft_info[0]['aircraft_name'])) $aircraft_name = $aircraft_info[0]['aircraft_name'];
108
-			else $aircraft_name = '';
109
-			if (isset($aircraft_info[0]['aircraft_icao'])) $aircraft_name = $aircraft_info[0]['aircraft_icao'];
110
-			else $aircraft_icao = '';
111
-			if (isset($aircraft_info[0]['airline_icao'])) $airline_icao = $aircraft_info[0]['airline_icao'];
112
-			else $airline_icao = '';
132
+			if (isset($aircraft_info[0]['aircraft_name'])) {
133
+				$aircraft_name = $aircraft_info[0]['aircraft_name'];
134
+			} else {
135
+				$aircraft_name = '';
136
+			}
137
+			if (isset($aircraft_info[0]['aircraft_icao'])) {
138
+				$aircraft_name = $aircraft_info[0]['aircraft_icao'];
139
+			} else {
140
+				$aircraft_icao = '';
141
+			}
142
+			if (isset($aircraft_info[0]['airline_icao'])) {
143
+				$airline_icao = $aircraft_info[0]['airline_icao'];
144
+			} else {
145
+				$airline_icao = '';
146
+			}
113 147
 		} elseif ($aircraft_icao != '') {
114 148
 			$aircraft_info = $Spotter->getAllAircraftInfo($aircraft_icao);
115
-			if (isset($aircraft_info[0]['type'])) $aircraft_name = $aircraft_info[0]['type'];
116
-			else $aircraft_name = '';
149
+			if (isset($aircraft_info[0]['type'])) {
150
+				$aircraft_name = $aircraft_info[0]['type'];
151
+			} else {
152
+				$aircraft_name = '';
153
+			}
117 154
 			$aircraft_registration = $aircraft_icao;
118
-		} else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
119
-		if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
155
+		} else {
156
+			return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
157
+		}
158
+		if (!isset($globalAircraftImageSources)) {
159
+			$globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
160
+		}
120 161
 		foreach ($globalAircraftImageSources as $source) {
121 162
 			$source = strtolower($source);
122
-			if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl($aircraft_icao,$airline_icao);
123
-			if ($source == 'planespotters' && !$globalIVAO) $images_array = $this->fromPlanespotters($aircraft_registration,$aircraft_name);
124
-			if ($source == 'flickr') $images_array = $this->fromFlickr($aircraft_registration,$aircraft_name);
125
-			if ($source == 'bing') $images_array = $this->fromBing($aircraft_registration,$aircraft_name);
126
-			if ($source == 'deviantart') $images_array = $this->fromDeviantart($aircraft_registration,$aircraft_name);
127
-			if ($source == 'wikimedia') $images_array = $this->fromWikimedia($aircraft_registration,$aircraft_name);
128
-			if ($source == 'jetphotos' && !$globalIVAO) $images_array = $this->fromJetPhotos($aircraft_registration,$aircraft_name);
129
-			if ($source == 'planepictures' && !$globalIVAO) $images_array = $this->fromPlanePictures($aircraft_registration,$aircraft_name);
130
-			if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData($aircraft_registration,$aircraft_name);
131
-			if ($source == 'customsources') $images_array = $this->fromCustomSource($aircraft_registration,$aircraft_name);
132
-			if (isset($images_array) && $images_array['original'] != '') return $images_array;
163
+			if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') {
164
+				$images_array = $this->fromIvaoMtl($aircraft_icao,$airline_icao);
165
+			}
166
+			if ($source == 'planespotters' && !$globalIVAO) {
167
+				$images_array = $this->fromPlanespotters($aircraft_registration,$aircraft_name);
168
+			}
169
+			if ($source == 'flickr') {
170
+				$images_array = $this->fromFlickr($aircraft_registration,$aircraft_name);
171
+			}
172
+			if ($source == 'bing') {
173
+				$images_array = $this->fromBing($aircraft_registration,$aircraft_name);
174
+			}
175
+			if ($source == 'deviantart') {
176
+				$images_array = $this->fromDeviantart($aircraft_registration,$aircraft_name);
177
+			}
178
+			if ($source == 'wikimedia') {
179
+				$images_array = $this->fromWikimedia($aircraft_registration,$aircraft_name);
180
+			}
181
+			if ($source == 'jetphotos' && !$globalIVAO) {
182
+				$images_array = $this->fromJetPhotos($aircraft_registration,$aircraft_name);
183
+			}
184
+			if ($source == 'planepictures' && !$globalIVAO) {
185
+				$images_array = $this->fromPlanePictures($aircraft_registration,$aircraft_name);
186
+			}
187
+			if ($source == 'airportdata' && !$globalIVAO) {
188
+				$images_array = $this->fromAirportData($aircraft_registration,$aircraft_name);
189
+			}
190
+			if ($source == 'customsources') {
191
+				$images_array = $this->fromCustomSource($aircraft_registration,$aircraft_name);
192
+			}
193
+			if (isset($images_array) && $images_array['original'] != '') {
194
+				return $images_array;
195
+			}
196
+		}
197
+		if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) {
198
+			return $this->findAircraftImage($aircraft_icao);
133 199
 		}
134
-		if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) return $this->findAircraftImage($aircraft_icao);
135 200
 		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
136 201
 	}
137 202
 
@@ -288,8 +353,11 @@  discard block
 block discarded – undo
288 353
 	*/
289 354
 	public function fromFlickr($aircraft_registration,$aircraft_name='') {
290 355
 		$Common = new Common();
291
-		if ($aircraft_name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$aircraft_registration.','.urlencode($aircraft_name);
292
-		else $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$aircraft_registration.',aircraft';
356
+		if ($aircraft_name != '') {
357
+			$url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$aircraft_registration.','.urlencode($aircraft_name);
358
+		} else {
359
+			$url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$aircraft_registration.',aircraft';
360
+		}
293 361
 		$data = $Common->getData($url);
294 362
 		if ($xml = simplexml_load_string($data)) {
295 363
 			if (isset($xml->channel->item)) {
@@ -333,9 +401,14 @@  discard block
 block discarded – undo
333 401
 	public function fromBing($aircraft_registration,$aircraft_name='') {
334 402
 		global $globalImageBingKey;
335 403
 		$Common = new Common();
336
-		if (!isset($globalImageBingKey) || $globalImageBingKey == '') return false;
337
-		if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27';
338
-		else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27';
404
+		if (!isset($globalImageBingKey) || $globalImageBingKey == '') {
405
+			return false;
406
+		}
407
+		if ($aircraft_name != '') {
408
+			$url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27';
409
+		} else {
410
+			$url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27';
411
+		}
339 412
 		$headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey));
340 413
 		$data = $Common->getData($url,'get','',$headers);
341 414
 		$result = json_decode($data);
@@ -389,13 +462,18 @@  discard block
 block discarded – undo
389 462
 	*/
390 463
 	public function fromWikimedia($aircraft_registration,$aircraft_name='') {
391 464
 		$Common = new Common();
392
-		if ($aircraft_name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20'.urlencode($aircraft_name);
393
-		else $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20aircraft';
465
+		if ($aircraft_name != '') {
466
+			$url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20'.urlencode($aircraft_name);
467
+		} else {
468
+			$url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20aircraft';
469
+		}
394 470
 		$data = $Common->getData($url);
395 471
 		$result = json_decode($data);
396 472
 		if (isset($result->query->search[0]->title)) {
397 473
 			$fileo = $result->query->search[0]->title;
398
-			if (substr($fileo,-3) == 'pdf') return false;
474
+			if (substr($fileo,-3) == 'pdf') {
475
+				return false;
476
+			}
399 477
 			$file = urlencode($fileo);
400 478
 			$url2 = 'https://commons.wikimedia.org/w/api.php?action=query&format=json&continue&iilimit=500&prop=imageinfo&iiprop=user|url|size|mime|sha1|timestamp&iiurlwidth=200%27&titles='.$file;
401 479
 			$data2 = $Common->getData($url2);
@@ -466,18 +544,27 @@  discard block
 block discarded – undo
466 544
 					$image_url = array();
467 545
 					$image_url['thumbnail'] = $url_thumbnail;
468 546
 					$image_url['original'] = $url;
469
-					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url);
470
-					else $exifCopyright = '';
471
-					if ($exifCopyright  != '') $image_url['copyright'] = $exifCopyright;
472
-					elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright'];
473
-					else $image_url['copyright'] = $source['source_website'];
547
+					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) {
548
+						$exifCopyright = $this->getExifCopyright($url);
549
+					} else {
550
+						$exifCopyright = '';
551
+					}
552
+					if ($exifCopyright  != '') {
553
+						$image_url['copyright'] = $exifCopyright;
554
+					} elseif (isset($source['copyright'])) {
555
+						$image_url['copyright'] = $source['copyright'];
556
+					} else {
557
+						$image_url['copyright'] = $source['source_website'];
558
+					}
474 559
 					$image_url['source_website'] = $source['source_website'];
475 560
 					$image_url['source'] = $source['source'];
476 561
 					return $image_url;
477 562
 				}
478 563
 			}
479 564
 			return false;
480
-		} else return false;
565
+		} else {
566
+			return false;
567
+		}
481 568
 	}
482 569
 }
483 570
 
Please login to merge, or discard this patch.