Completed
Push — master ( adb4a8...c8a161 )
by Yannick
28:16
created
statistics-sub-menu.php 1 patch
Braces   +110 added lines, -27 removed lines patch added patch discarded remove patch
@@ -4,7 +4,13 @@  discard block
 block discarded – undo
4 4
 	<div class="stats_airline">
5 5
 	
6 6
 		<form id="changedate" method="post">
7
-			<input type="month" name="date" onchange="statsdatechange(this);" value="<?php if (isset($year) && $year != '') echo $year.'-'; ?><?php if (isset($month) && $month != '') echo $month; ?>" />
7
+			<input type="month" name="date" onchange="statsdatechange(this);" value="<?php if (isset($year) && $year != '') {
8
+	echo $year.'-';
9
+}
10
+?><?php if (isset($month) && $month != '') {
11
+	echo $month;
12
+}
13
+?>" />
8 14
 		</form>
9 15
 <?php
10 16
 	if (!isset($type) || $type == 'aircraft') {
@@ -33,7 +39,9 @@  discard block
 block discarded – undo
33 39
 						print '<option disabled>──────────</option>';
34 40
 					}
35 41
 					$Stats = new Stats();
36
-					if (!isset($filter_name)) $filter_name = '';
42
+					if (!isset($filter_name)) {
43
+						$filter_name = '';
44
+					}
37 45
 					$airlines = $Stats->getAllAirlineNames($filter_name);
38 46
 					foreach($airlines as $airline) {
39 47
 						if (isset($airline_icao) && $airline_icao == $airline['airline_icao']) {
@@ -62,10 +70,22 @@  discard block
 block discarded – undo
62 70
 		      <?php echo _("Aircraft"); ?> <span class="caret"></span>
63 71
 		    </a>
64 72
 		    <ul class="dropdown-menu">
65
-			<li><a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Aircraft"); ?></a></li>
66
-			<li><a href="<?php print $globalURL; ?>/statistics/registration<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Registration"); ?></a></li>
67
-			<li><a href="<?php print $globalURL; ?>/statistics/manufacturer<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Manufacturer"); ?></a></li>
68
-			<li><a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Country"); ?></a></li>
73
+			<li><a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
74
+	echo '/'.$airline_icao;
75
+}
76
+?>"><?php echo _("Aircraft"); ?></a></li>
77
+			<li><a href="<?php print $globalURL; ?>/statistics/registration<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
78
+	echo '/'.$airline_icao;
79
+}
80
+?>"><?php echo _("Registration"); ?></a></li>
81
+			<li><a href="<?php print $globalURL; ?>/statistics/manufacturer<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
82
+	echo '/'.$airline_icao;
83
+}
84
+?>"><?php echo _("Manufacturer"); ?></a></li>
85
+			<li><a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
86
+	echo '/'.$airline_icao;
87
+}
88
+?>"><?php echo _("Country"); ?></a></li>
69 89
 		    </ul>
70 90
 		</li>
71 91
 		<li class="dropdown">
@@ -76,12 +96,21 @@  discard block
 block discarded – undo
76 96
 <?php
77 97
 		if (!isset($airline_icao) || $airline_icao == 'all') {
78 98
 ?>
79
-		      <li><a href="<?php print $globalURL; ?>/statistics/airline<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Airline"); ?></a></li>
80
-		      <li><a href="<?php print $globalURL; ?>/statistics/airline-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Airline by Country"); ?></a></li>
99
+		      <li><a href="<?php print $globalURL; ?>/statistics/airline<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
100
+	echo '/'.$airline_icao;
101
+}
102
+?>"><?php echo _("Airline"); ?></a></li>
103
+		      <li><a href="<?php print $globalURL; ?>/statistics/airline-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
104
+	echo '/'.$airline_icao;
105
+}
106
+?>"><?php echo _("Airline by Country"); ?></a></li>
81 107
 <?php
82 108
 		}
83 109
 ?>
84
-		      <li><a href="<?php print $globalURL; ?>/statistics/callsign<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Callsign"); ?></a></li>
110
+		      <li><a href="<?php print $globalURL; ?>/statistics/callsign<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
111
+	echo '/'.$airline_icao;
112
+}
113
+?>"><?php echo _("Callsign"); ?></a></li>
85 114
 		    </ul>
86 115
 		</li>
87 116
 		<li class="dropdown">
@@ -89,10 +118,22 @@  discard block
 block discarded – undo
89 118
 		      <?php echo _("Airport"); ?> <span class="caret"></span>
90 119
 		    </a>
91 120
 		    <ul class="dropdown-menu" role="menu">
92
-		      <li><a href="<?php print $globalURL; ?>/statistics/airport-departure<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Departure Airport"); ?></a></li>
93
-		      <li><a href="<?php print $globalURL; ?>/statistics/airport-departure-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Departure Airport by Country"); ?></a></li>
94
-		      <li><a href="<?php print $globalURL; ?>/statistics/airport-arrival<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Arrival Airport"); ?></a></li>
95
-		      <li><a href="<?php print $globalURL; ?>/statistics/airport-arrival-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Arrival Airport by Country"); ?></a></li>
121
+		      <li><a href="<?php print $globalURL; ?>/statistics/airport-departure<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
122
+	echo '/'.$airline_icao;
123
+}
124
+?>"><?php echo _("Departure Airport"); ?></a></li>
125
+		      <li><a href="<?php print $globalURL; ?>/statistics/airport-departure-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
126
+	echo '/'.$airline_icao;
127
+}
128
+?>"><?php echo _("Departure Airport by Country"); ?></a></li>
129
+		      <li><a href="<?php print $globalURL; ?>/statistics/airport-arrival<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
130
+	echo '/'.$airline_icao;
131
+}
132
+?>"><?php echo _("Arrival Airport"); ?></a></li>
133
+		      <li><a href="<?php print $globalURL; ?>/statistics/airport-arrival-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
134
+	echo '/'.$airline_icao;
135
+}
136
+?>"><?php echo _("Arrival Airport by Country"); ?></a></li>
96 137
 		    </ul>
97 138
 		</li>
98 139
 		<li class="dropdown">
@@ -100,8 +141,14 @@  discard block
 block discarded – undo
100 141
 		      <?php echo _("Route"); ?> <span class="caret"></span>
101 142
 		    </a>
102 143
 		    <ul class="dropdown-menu" role="menu">
103
-		      <li><a href="<?php print $globalURL; ?>/statistics/route-airport<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Route by Airport"); ?></a></li>
104
-		      <li><a href="<?php print $globalURL; ?>/statistics/route-waypoint<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Route by Waypoint"); ?></a></li>
144
+		      <li><a href="<?php print $globalURL; ?>/statistics/route-airport<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
145
+	echo '/'.$airline_icao;
146
+}
147
+?>"><?php echo _("Route by Airport"); ?></a></li>
148
+		      <li><a href="<?php print $globalURL; ?>/statistics/route-waypoint<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
149
+	echo '/'.$airline_icao;
150
+}
151
+?>"><?php echo _("Route by Waypoint"); ?></a></li>
105 152
 		    </ul>
106 153
 		</li>
107 154
 		<li class="dropdown">
@@ -109,8 +156,14 @@  discard block
 block discarded – undo
109 156
 		      <?php echo _("Date &amp; Time"); ?> <span class="caret"></span>
110 157
 		    </a>
111 158
 		    <ul class="dropdown-menu" role="menu">
112
-		      <li><a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Date"); ?></a></li>
113
-			  <li><a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Time"); ?></a></li>
159
+		      <li><a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
160
+	echo '/'.$airline_icao;
161
+}
162
+?>"><?php echo _("Date"); ?></a></li>
163
+			  <li><a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
164
+	echo '/'.$airline_icao;
165
+}
166
+?>"><?php echo _("Time"); ?></a></li>
114 167
 		    </ul>
115 168
 		</li>
116 169
 		<?php
@@ -158,9 +211,18 @@  discard block
 block discarded – undo
158 211
 		      <?php echo _("Aircraft"); ?> <span class="caret"></span>
159 212
 		    </a>
160 213
 		    <ul class="dropdown-menu">
161
-			<li><a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Aircraft"); ?></a></li>
162
-			<li><a href="<?php print $globalURL; ?>/statistics/registration<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Registration"); ?></a></li>
163
-			<li><a href="<?php print $globalURL; ?>/statistics/manufacturer<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Manufacturer"); ?></a></li>
214
+			<li><a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
215
+	echo '/'.$airline_icao;
216
+}
217
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Aircraft"); ?></a></li>
218
+			<li><a href="<?php print $globalURL; ?>/statistics/registration<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
219
+	echo '/'.$airline_icao;
220
+}
221
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Registration"); ?></a></li>
222
+			<li><a href="<?php print $globalURL; ?>/statistics/manufacturer<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
223
+	echo '/'.$airline_icao;
224
+}
225
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Manufacturer"); ?></a></li>
164 226
 			<!-- <li><a href="<?php print $globalURL; ?>/statistics/country"><?php echo _("Country"); ?></a></li> -->
165 227
 		    </ul>
166 228
 		</li>
@@ -172,12 +234,21 @@  discard block
 block discarded – undo
172 234
 <?php
173 235
 		if (!isset($airline_icao) || $airline_icao == 'all') {
174 236
 ?>
175
-		      <li><a href="<?php print $globalURL; ?>/statistics/airline<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Airline"); ?></a></li>
176
-		      <li><a href="<?php print $globalURL; ?>/statistics/airline-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Airline by Country"); ?></a></li>
237
+		      <li><a href="<?php print $globalURL; ?>/statistics/airline<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
238
+	echo '/'.$airline_icao;
239
+}
240
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Airline"); ?></a></li>
241
+		      <li><a href="<?php print $globalURL; ?>/statistics/airline-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
242
+	echo '/'.$airline_icao;
243
+}
244
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Airline by Country"); ?></a></li>
177 245
 <?php
178 246
 		}
179 247
 ?>
180
-		      <li><a href="<?php print $globalURL; ?>/statistics/callsign<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Callsign"); ?></a></li>
248
+		      <li><a href="<?php print $globalURL; ?>/statistics/callsign<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
249
+	echo '/'.$airline_icao;
250
+}
251
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Callsign"); ?></a></li>
181 252
 		    </ul>
182 253
 		</li>
183 254
 		<li class="dropdown">
@@ -185,10 +256,22 @@  discard block
 block discarded – undo
185 256
 		      <?php echo _("Airport"); ?> <span class="caret"></span>
186 257
 		    </a>
187 258
 		    <ul class="dropdown-menu" role="menu">
188
-		      <li><a href="<?php print $globalURL; ?>/statistics/airport-departure<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Departure Airport"); ?></a></li>
189
-		      <li><a href="<?php print $globalURL; ?>/statistics/airport-departure-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Departure Airport by Country"); ?></a></li>
190
-		      <li><a href="<?php print $globalURL; ?>/statistics/airport-arrival<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Arrival Airport"); ?></a></li>
191
-		      <li><a href="<?php print $globalURL; ?>/statistics/airport-arrival-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Arrival Airport by Country"); ?></a></li>
259
+		      <li><a href="<?php print $globalURL; ?>/statistics/airport-departure<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
260
+	echo '/'.$airline_icao;
261
+}
262
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Departure Airport"); ?></a></li>
263
+		      <li><a href="<?php print $globalURL; ?>/statistics/airport-departure-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
264
+	echo '/'.$airline_icao;
265
+}
266
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Departure Airport by Country"); ?></a></li>
267
+		      <li><a href="<?php print $globalURL; ?>/statistics/airport-arrival<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
268
+	echo '/'.$airline_icao;
269
+}
270
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Arrival Airport"); ?></a></li>
271
+		      <li><a href="<?php print $globalURL; ?>/statistics/airport-arrival-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
272
+	echo '/'.$airline_icao;
273
+}
274
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Arrival Airport by Country"); ?></a></li>
192 275
 		    </ul>
193 276
 		</li>
194 277
 		<!--
Please login to merge, or discard this patch.
require/class.Stats.php 1 patch
Braces   +580 added lines, -204 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);
@@ -101,7 +105,9 @@  discard block
 block discarded – undo
101 105
 		return $all;
102 106
 	}
103 107
 	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
104
-		if ($filter_name == '') $filter_name = $this->filter_name;
108
+		if ($filter_name == '') {
109
+			$filter_name = $this->filter_name;
110
+		}
105 111
 		$query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
106 112
 		try {
107 113
 			$sth = $this->db->prepare($query);
@@ -113,7 +119,9 @@  discard block
 block discarded – undo
113 119
 		return $all;
114 120
 	}
115 121
 	public function getAllManufacturers($stats_airline = '',$filter_name = '') {
116
-		if ($filter_name == '') $filter_name = $this->filter_name;
122
+		if ($filter_name == '') {
123
+			$filter_name = $this->filter_name;
124
+		}
117 125
 		$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";
118 126
 		try {
119 127
 			$sth = $this->db->prepare($query);
@@ -125,7 +133,9 @@  discard block
 block discarded – undo
125 133
 		return $all;
126 134
 	}
127 135
 	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
128
-		if ($filter_name == '') $filter_name = $this->filter_name;
136
+		if ($filter_name == '') {
137
+			$filter_name = $this->filter_name;
138
+		}
129 139
 		$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";
130 140
 		try {
131 141
 			$sth = $this->db->prepare($query);
@@ -138,7 +148,9 @@  discard block
 block discarded – undo
138 148
 	}
139 149
 
140 150
 	public function getAllOwnerNames($stats_airline = '',$filter_name = '') {
141
-		if ($filter_name == '') $filter_name = $this->filter_name;
151
+		if ($filter_name == '') {
152
+			$filter_name = $this->filter_name;
153
+		}
142 154
 		$query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC";
143 155
 		try {
144 156
 			$sth = $this->db->prepare($query);
@@ -151,7 +163,9 @@  discard block
 block discarded – undo
151 163
 	}
152 164
 
153 165
 	public function getAllPilotNames($stats_airline = '',$filter_name = '') {
154
-		if ($filter_name == '') $filter_name = $this->filter_name;
166
+		if ($filter_name == '') {
167
+			$filter_name = $this->filter_name;
168
+		}
155 169
 		$query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC";
156 170
 		try {
157 171
 			$sth = $this->db->prepare($query);
@@ -166,7 +180,9 @@  discard block
 block discarded – undo
166 180
 
167 181
 	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
168 182
 		global $globalStatsFilters;
169
-		if ($filter_name == '') $filter_name = $this->filter_name;
183
+		if ($filter_name == '') {
184
+			$filter_name = $this->filter_name;
185
+		}
170 186
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
171 187
 			$Spotter = new Spotter($this->db);
172 188
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -175,8 +191,11 @@  discard block
 block discarded – undo
175 191
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
176 192
 			}
177 193
 			if ($year == '' && $month == '') {
178
-				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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
179
-				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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
194
+				if ($limit) {
195
+					$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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
196
+				} else {
197
+					$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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
198
+				}
180 199
 				try {
181 200
 					$sth = $this->db->prepare($query);
182 201
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -184,11 +203,16 @@  discard block
 block discarded – undo
184 203
 					echo "error : ".$e->getMessage();
185 204
 				}
186 205
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
187
-			} else $all = array();
206
+			} else {
207
+				$all = array();
208
+			}
188 209
 		} else {
189 210
 			if ($year == '' && $month == '') {
190
-				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";
191
-				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";
211
+				if ($limit) {
212
+					$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";
213
+				} else {
214
+					$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";
215
+				}
192 216
 				try {
193 217
 					$sth = $this->db->prepare($query);
194 218
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -196,7 +220,9 @@  discard block
 block discarded – undo
196 220
 					echo "error : ".$e->getMessage();
197 221
 				}
198 222
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
199
-			} else $all = array();
223
+			} else {
224
+				$all = array();
225
+			}
200 226
 		}
201 227
 		if (empty($all)) {
202 228
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -215,10 +241,15 @@  discard block
 block discarded – undo
215 241
 	}
216 242
 	public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') {
217 243
 		global $globalStatsFilters;
218
-		if ($filter_name == '') $filter_name = $this->filter_name;
244
+		if ($filter_name == '') {
245
+			$filter_name = $this->filter_name;
246
+		}
219 247
 		if ($year == '' && $month == '') {
220
-			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";
221
-			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";
248
+			if ($limit) {
249
+				$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";
250
+			} else {
251
+				$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";
252
+			}
222 253
 			try {
223 254
 				$sth = $this->db->prepare($query);
224 255
 				$sth->execute(array(':filter_name' => $filter_name));
@@ -226,7 +257,9 @@  discard block
 block discarded – undo
226 257
 				echo "error : ".$e->getMessage();
227 258
 			}
228 259
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
229
-		} else $all = array();
260
+		} else {
261
+			$all = array();
262
+		}
230 263
                 if (empty($all)) {
231 264
             		$Spotter = new Spotter($this->db);
232 265
             		$filters = array();
@@ -241,7 +274,9 @@  discard block
 block discarded – undo
241 274
 	}
242 275
 	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') {
243 276
 		global $globalStatsFilters;
244
-		if ($filter_name == '') $filter_name = $this->filter_name;
277
+		if ($filter_name == '') {
278
+			$filter_name = $this->filter_name;
279
+		}
245 280
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
246 281
 			$Spotter = new Spotter($this->db);
247 282
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -250,8 +285,11 @@  discard block
 block discarded – undo
250 285
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
251 286
 			}
252 287
 			if ($year == '' && $month == '') {
253
-				if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
254
-				else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
288
+				if ($limit) {
289
+					$query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
290
+				} else {
291
+					$query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
292
+				}
255 293
 				try {
256 294
 					$sth = $this->db->prepare($query);
257 295
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -259,11 +297,16 @@  discard block
 block discarded – undo
259 297
 					echo "error : ".$e->getMessage();
260 298
 				}
261 299
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
262
-			} else $all = array();
300
+			} else {
301
+				$all = array();
302
+			}
263 303
 		} else {
264 304
 			if ($year == '' && $month == '') {
265
-				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";
266
-				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";
305
+				if ($limit) {
306
+					$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";
307
+				} else {
308
+					$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";
309
+				}
267 310
 				try {
268 311
 					$sth = $this->db->prepare($query);
269 312
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -271,7 +314,9 @@  discard block
 block discarded – undo
271 314
 					echo "error : ".$e->getMessage();
272 315
 				}
273 316
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
274
-			} else $all = array();
317
+			} else {
318
+				$all = array();
319
+			}
275 320
 		}
276 321
 		if (empty($all)) {
277 322
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -291,7 +336,9 @@  discard block
 block discarded – undo
291 336
 
292 337
 	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
293 338
 		global $globalStatsFilters;
294
-		if ($filter_name == '') $filter_name = $this->filter_name;
339
+		if ($filter_name == '') {
340
+			$filter_name = $this->filter_name;
341
+		}
295 342
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
296 343
 			$Spotter = new Spotter($this->db);
297 344
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -300,8 +347,11 @@  discard block
 block discarded – undo
300 347
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
301 348
 			}
302 349
 			if ($year == '' && $month == '') {
303
-				if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
304
-				else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC";
350
+				if ($limit) {
351
+					$query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
352
+				} else {
353
+					$query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC";
354
+				}
305 355
 				try {
306 356
 					$sth = $this->db->prepare($query);
307 357
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -309,11 +359,16 @@  discard block
 block discarded – undo
309 359
 					echo "error : ".$e->getMessage();
310 360
 				}
311 361
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
312
-			} else $all = array();
362
+			} else {
363
+				$all = array();
364
+			}
313 365
 		} else {
314 366
 			if ($year == '' && $month == '') {
315
-				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";
316
-				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";
367
+				if ($limit) {
368
+					$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";
369
+				} else {
370
+					$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";
371
+				}
317 372
 				try {
318 373
 					$sth = $this->db->prepare($query);
319 374
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -321,7 +376,9 @@  discard block
 block discarded – undo
321 376
 					echo "error : ".$e->getMessage();
322 377
 				}
323 378
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
324
-			} else $all = array();
379
+			} else {
380
+				$all = array();
381
+			}
325 382
 		}
326 383
 		if (empty($all)) {
327 384
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -340,7 +397,9 @@  discard block
 block discarded – undo
340 397
 	}
341 398
 	public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
342 399
 		global $globalStatsFilters;
343
-		if ($filter_name == '') $filter_name = $this->filter_name;
400
+		if ($filter_name == '') {
401
+			$filter_name = $this->filter_name;
402
+		}
344 403
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
345 404
 			$Spotter = new Spotter($this->db);
346 405
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -348,12 +407,18 @@  discard block
 block discarded – undo
348 407
 			foreach ($airlines as $airline) {
349 408
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
350 409
 			}
351
-			if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
352
-			else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC";
410
+			if ($limit) {
411
+				$query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
412
+			} else {
413
+				$query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC";
414
+			}
353 415
 			$query_values = array(':filter_name' => $filter_name);
354 416
 		} else {
355
-			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";
356
-			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";
417
+			if ($limit) {
418
+				$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";
419
+			} else {
420
+				$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";
421
+			}
357 422
 			$query_values = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
358 423
 		}
359 424
 		try {
@@ -381,17 +446,29 @@  discard block
 block discarded – undo
381 446
 
382 447
 	public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') {
383 448
 		global $globalStatsFilters, $globalVATSIM, $globalIVAO;
384
-		if ($filter_name == '') $filter_name = $this->filter_name;
449
+		if ($filter_name == '') {
450
+			$filter_name = $this->filter_name;
451
+		}
385 452
 		if ($year == '' && $month == '') {
386
-			if ($globalVATSIM) $forsource = 'vatsim';
387
-			if ($globalIVAO) $forsource = 'ivao';
453
+			if ($globalVATSIM) {
454
+				$forsource = 'vatsim';
455
+			}
456
+			if ($globalIVAO) {
457
+				$forsource = 'ivao';
458
+			}
388 459
 			if (isset($forsource)) {
389
-				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";
390
-				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";
460
+				if ($limit) {
461
+					$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";
462
+				} else {
463
+					$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";
464
+				}
391 465
 				$query_values = array(':filter_name' => $filter_name,':forsource' => $forsource);
392 466
 			} else {
393
-				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";
394
-				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";
467
+				if ($limit) {
468
+					$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";
469
+				} else {
470
+					$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";
471
+				}
395 472
 				$query_values = array(':filter_name' => $filter_name);
396 473
 			}
397 474
 			try {
@@ -401,7 +478,9 @@  discard block
 block discarded – undo
401 478
 				echo "error : ".$e->getMessage();
402 479
 			}
403 480
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
404
-		} else $all = array();
481
+		} else {
482
+			$all = array();
483
+		}
405 484
                 if (empty($all)) {
406 485
 	                $Spotter = new Spotter($this->db);
407 486
             		$filters = array();
@@ -416,7 +495,9 @@  discard block
 block discarded – undo
416 495
 	}
417 496
 	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
418 497
 		global $globalStatsFilters;
419
-		if ($filter_name == '') $filter_name = $this->filter_name;
498
+		if ($filter_name == '') {
499
+			$filter_name = $this->filter_name;
500
+		}
420 501
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
421 502
 			$Spotter = new Spotter($this->db);
422 503
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -425,8 +506,11 @@  discard block
 block discarded – undo
425 506
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
426 507
 			}
427 508
 			if ($year == '' && $month == '') {
428
-				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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0";
429
-				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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC";
509
+				if ($limit) {
510
+					$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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0";
511
+				} else {
512
+					$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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC";
513
+				}
430 514
 				try {
431 515
 					$sth = $this->db->prepare($query);
432 516
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -434,11 +518,16 @@  discard block
 block discarded – undo
434 518
 					echo "error : ".$e->getMessage();
435 519
 				}
436 520
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
437
-			} else $all = array();
521
+			} else {
522
+				$all = array();
523
+			}
438 524
 		} else {
439 525
 			if ($year == '' && $month == '') {
440
-				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";
441
-				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";
526
+				if ($limit) {
527
+					$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";
528
+				} else {
529
+					$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";
530
+				}
442 531
 				try {
443 532
 					$sth = $this->db->prepare($query);
444 533
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -446,7 +535,9 @@  discard block
 block discarded – undo
446 535
 					echo "error : ".$e->getMessage();
447 536
 				}
448 537
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
449
-			} else $all = array();
538
+			} else {
539
+				$all = array();
540
+			}
450 541
 		}
451 542
 		if (empty($all)) {
452 543
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -465,7 +556,9 @@  discard block
 block discarded – undo
465 556
 	}
466 557
 	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
467 558
 		global $globalStatsFilters;
468
-		if ($filter_name == '') $filter_name = $this->filter_name;
559
+		if ($filter_name == '') {
560
+			$filter_name = $this->filter_name;
561
+		}
469 562
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
470 563
 			$Spotter = new Spotter($this->db);
471 564
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -474,8 +567,11 @@  discard block
 block discarded – undo
474 567
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
475 568
 			}
476 569
 			if ($year == '' && $month == '') {
477
-				if ($limit) $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
478
-				else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
570
+				if ($limit) {
571
+					$query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
572
+				} else {
573
+					$query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
574
+				}
479 575
 				 try {
480 576
 					$sth = $this->db->prepare($query);
481 577
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -483,11 +579,16 @@  discard block
 block discarded – undo
483 579
 					echo "error : ".$e->getMessage();
484 580
 				}
485 581
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
486
-			} else $all = array();
582
+			} else {
583
+				$all = array();
584
+			}
487 585
 		} else {
488 586
 			if ($year == '' && $month == '') {
489
-				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";
490
-				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";
587
+				if ($limit) {
588
+					$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";
589
+				} else {
590
+					$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";
591
+				}
491 592
 				 try {
492 593
 					$sth = $this->db->prepare($query);
493 594
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -495,7 +596,9 @@  discard block
 block discarded – undo
495 596
 					echo "error : ".$e->getMessage();
496 597
 				}
497 598
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
498
-			} else $all = array();
599
+			} else {
600
+				$all = array();
601
+			}
499 602
 		}
500 603
 		if (empty($all)) {
501 604
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -514,7 +617,9 @@  discard block
 block discarded – undo
514 617
 	}
515 618
 	public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') {
516 619
 		$Connection = new Connection();
517
-		if ($filter_name == '') $filter_name = $this->filter_name;
620
+		if ($filter_name == '') {
621
+			$filter_name = $this->filter_name;
622
+		}
518 623
 		if ($Connection->tableExists('countries')) {
519 624
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
520 625
 				$Spotter = new Spotter($this->db);
@@ -524,8 +629,11 @@  discard block
 block discarded – undo
524 629
 					foreach ($airlines as $airline) {
525 630
 						$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
526 631
 					}
527
-					if ($limit) $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0";
528
-					else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC";
632
+					if ($limit) {
633
+						$query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0";
634
+					} else {
635
+						$query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC";
636
+					}
529 637
 					 try {
530 638
 						$sth = $this->db->prepare($query);
531 639
 						$sth->execute(array(':filter_name' => $filter_name));
@@ -534,11 +642,16 @@  discard block
 block discarded – undo
534 642
 					}
535 643
 					$all = $sth->fetchAll(PDO::FETCH_ASSOC);
536 644
 					return $all;
537
-				} else return array();
645
+				} else {
646
+					return array();
647
+				}
538 648
 			} else {
539 649
 				if ($year == '' && $month == '') {
540
-					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";
541
-					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";
650
+					if ($limit) {
651
+						$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";
652
+					} else {
653
+						$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";
654
+					}
542 655
 					 try {
543 656
 						$sth = $this->db->prepare($query);
544 657
 						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -547,7 +660,9 @@  discard block
 block discarded – undo
547 660
 					}
548 661
 					$all = $sth->fetchAll(PDO::FETCH_ASSOC);
549 662
 					return $all;
550
-				} else return array();
663
+				} else {
664
+					return array();
665
+				}
551 666
 			}
552 667
 		} else {
553 668
 			/*
@@ -561,10 +676,15 @@  discard block
 block discarded – undo
561 676
 	}
562 677
 	public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') {
563 678
 		global $globalStatsFilters;
564
-		if ($filter_name == '') $filter_name = $this->filter_name;
679
+		if ($filter_name == '') {
680
+			$filter_name = $this->filter_name;
681
+		}
565 682
 		if ($year == '' && $month == '') {
566
-			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";
567
-			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";
683
+			if ($limit) {
684
+				$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";
685
+			} else {
686
+				$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";
687
+			}
568 688
 			try {
569 689
 				$sth = $this->db->prepare($query);
570 690
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -572,7 +692,9 @@  discard block
 block discarded – undo
572 692
 				echo "error : ".$e->getMessage();
573 693
 			}
574 694
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
575
-		} else $all = array();
695
+		} else {
696
+			$all = array();
697
+		}
576 698
 		if (empty($all)) {
577 699
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
578 700
 			if ($filter_name != '') {
@@ -587,7 +709,9 @@  discard block
 block discarded – undo
587 709
 
588 710
 	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') {
589 711
 		global $globalStatsFilters;
590
-		if ($filter_name == '') $filter_name = $this->filter_name;
712
+		if ($filter_name == '') {
713
+			$filter_name = $this->filter_name;
714
+		}
591 715
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
592 716
 			$Spotter = new Spotter($this->db);
593 717
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -596,8 +720,11 @@  discard block
 block discarded – undo
596 720
 				foreach ($airlines as $airline) {
597 721
 					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
598 722
 				}
599
-				if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
600
-				else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC";
723
+				if ($limit) {
724
+					$query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
725
+				} else {
726
+					$query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC";
727
+				}
601 728
 				try {
602 729
 					$sth = $this->db->prepare($query);
603 730
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -605,11 +732,16 @@  discard block
 block discarded – undo
605 732
 					echo "error : ".$e->getMessage();
606 733
 				}
607 734
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
608
-			} else $all = array();
735
+			} else {
736
+				$all = array();
737
+			}
609 738
 		} else {
610 739
 			if ($year == '' && $month == '') {
611
-				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";
612
-				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";
740
+				if ($limit) {
741
+					$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";
742
+				} else {
743
+					$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";
744
+				}
613 745
 				try {
614 746
 					$sth = $this->db->prepare($query);
615 747
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -617,7 +749,9 @@  discard block
 block discarded – undo
617 749
 					echo "error : ".$e->getMessage();
618 750
 				}
619 751
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
620
-			} else $all = array();
752
+			} else {
753
+				$all = array();
754
+			}
621 755
 		}
622 756
 		if (empty($all)) {
623 757
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -636,7 +770,9 @@  discard block
 block discarded – undo
636 770
 	}
637 771
 	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
638 772
 		global $globalStatsFilters;
639
-		if ($filter_name == '') $filter_name = $this->filter_name;
773
+		if ($filter_name == '') {
774
+			$filter_name = $this->filter_name;
775
+		}
640 776
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
641 777
 			$Spotter = new Spotter($this->db);
642 778
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -645,8 +781,11 @@  discard block
 block discarded – undo
645 781
 				foreach ($airlines as $airline) {
646 782
 					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
647 783
 				}
648
-				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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
649
-				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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
784
+				if ($limit) {
785
+					$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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
786
+				} else {
787
+					$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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
788
+				}
650 789
 				try {
651 790
 					$sth = $this->db->prepare($query);
652 791
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -654,11 +793,16 @@  discard block
 block discarded – undo
654 793
 					echo "error : ".$e->getMessage();
655 794
 				}
656 795
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
657
-			} else $all = array();
796
+			} else {
797
+				$all = array();
798
+			}
658 799
 		} else {
659 800
 			if ($year == '' && $month == '') {
660
-				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";
661
-				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";
801
+				if ($limit) {
802
+					$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";
803
+				} else {
804
+					$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";
805
+				}
662 806
 				try {
663 807
 					$sth = $this->db->prepare($query);
664 808
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -666,7 +810,9 @@  discard block
 block discarded – undo
666 810
 					echo "error : ".$e->getMessage();
667 811
 				}
668 812
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
669
-			} else $all = array();
813
+			} else {
814
+				$all = array();
815
+			}
670 816
 		}
671 817
 		if (empty($all)) {
672 818
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -691,7 +837,9 @@  discard block
 block discarded – undo
691 837
 				$icao = $value['airport_departure_icao'];
692 838
 				if (isset($all[$icao])) {
693 839
 					$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
694
-				} else $all[$icao] = $value;
840
+				} else {
841
+					$all[$icao] = $value;
842
+				}
695 843
 			}
696 844
 			$count = array();
697 845
 			foreach ($all as $key => $row) {
@@ -703,7 +851,9 @@  discard block
 block discarded – undo
703 851
 	}
704 852
 	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
705 853
 		global $globalStatsFilters;
706
-		if ($filter_name == '') $filter_name = $this->filter_name;
854
+		if ($filter_name == '') {
855
+			$filter_name = $this->filter_name;
856
+		}
707 857
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
708 858
 			$Spotter = new Spotter($this->db);
709 859
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -712,8 +862,11 @@  discard block
 block discarded – undo
712 862
 				foreach ($airlines as $airline) {
713 863
 					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
714 864
 				}
715
-				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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
716
-				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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
865
+				if ($limit) {
866
+					$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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
867
+				} else {
868
+					$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 IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
869
+				}
717 870
 				try {
718 871
 					$sth = $this->db->prepare($query);
719 872
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -721,11 +874,16 @@  discard block
 block discarded – undo
721 874
 					echo "error : ".$e->getMessage();
722 875
 				}
723 876
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
724
-			} else $all = array();
877
+			} else {
878
+				$all = array();
879
+			}
725 880
 		} else {
726 881
 			if ($year == '' && $month == '') {
727
-				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";
728
-				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";
882
+				if ($limit) {
883
+					$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";
884
+				} else {
885
+					$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";
886
+				}
729 887
 				try {
730 888
 					$sth = $this->db->prepare($query);
731 889
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -733,7 +891,9 @@  discard block
 block discarded – undo
733 891
 					echo "error : ".$e->getMessage();
734 892
 				}
735 893
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
736
-			} else $all = array();
894
+			} else {
895
+				$all = array();
896
+			}
737 897
 		}
738 898
 		if (empty($all)) {
739 899
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -758,7 +918,9 @@  discard block
 block discarded – undo
758 918
 				$icao = $value['airport_arrival_icao'];
759 919
 				if (isset($all[$icao])) {
760 920
 					$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
761
-				} else $all[$icao] = $value;
921
+				} else {
922
+					$all[$icao] = $value;
923
+				}
762 924
 			}
763 925
 			$count = array();
764 926
 			foreach ($all as $key => $row) {
@@ -770,7 +932,9 @@  discard block
 block discarded – undo
770 932
 	}
771 933
 	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
772 934
 		global $globalDBdriver, $globalStatsFilters;
773
-		if ($filter_name == '') $filter_name = $this->filter_name;
935
+		if ($filter_name == '') {
936
+			$filter_name = $this->filter_name;
937
+		}
774 938
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
775 939
 			$Spotter = new Spotter($this->db);
776 940
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -779,20 +943,32 @@  discard block
 block discarded – undo
779 943
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
780 944
 			}
781 945
 			if ($globalDBdriver == 'mysql') {
782
-				if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
783
-				else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
946
+				if ($limit) {
947
+					$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
948
+				} else {
949
+					$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
950
+				}
784 951
 			} else {
785
-				if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
786
-				else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
952
+				if ($limit) {
953
+					$query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
954
+				} else {
955
+					$query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
956
+				}
787 957
 			}
788 958
 			$query_data = array(':filter_name' => $filter_name);
789 959
 		} else {
790 960
 			if ($globalDBdriver == 'mysql') {
791
-				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";
792
-				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";
961
+				if ($limit) {
962
+					$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";
963
+				} else {
964
+					$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";
965
+				}
793 966
 			} else {
794
-				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";
795
-				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";
967
+				if ($limit) {
968
+					$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";
969
+				} else {
970
+					$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";
971
+				}
796 972
 			}
797 973
 			$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
798 974
 		}
@@ -820,7 +996,9 @@  discard block
 block discarded – undo
820 996
 	
821 997
 	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
822 998
 		global $globalStatsFilters;
823
-		if ($filter_name == '') $filter_name = $this->filter_name;
999
+		if ($filter_name == '') {
1000
+			$filter_name = $this->filter_name;
1001
+		}
824 1002
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
825 1003
 			$Spotter = new Spotter($this->db);
826 1004
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -857,7 +1035,9 @@  discard block
 block discarded – undo
857 1035
 	}
858 1036
 	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
859 1037
 		global $globalDBdriver, $globalStatsFilters;
860
-		if ($filter_name == '') $filter_name = $this->filter_name;
1038
+		if ($filter_name == '') {
1039
+			$filter_name = $this->filter_name;
1040
+		}
861 1041
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
862 1042
 			$Spotter = new Spotter($this->db);
863 1043
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -902,7 +1082,9 @@  discard block
 block discarded – undo
902 1082
 	}
903 1083
 	public function countAllDates($stats_airline = '',$filter_name = '') {
904 1084
 		global $globalStatsFilters;
905
-		if ($filter_name == '') $filter_name = $this->filter_name;
1085
+		if ($filter_name == '') {
1086
+			$filter_name = $this->filter_name;
1087
+		}
906 1088
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
907 1089
 			$Spotter = new Spotter($this->db);
908 1090
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -939,7 +1121,9 @@  discard block
 block discarded – undo
939 1121
 	}
940 1122
 	public function countAllDatesByAirlines($filter_name = '') {
941 1123
 		global $globalStatsFilters;
942
-		if ($filter_name == '') $filter_name = $this->filter_name;
1124
+		if ($filter_name == '') {
1125
+			$filter_name = $this->filter_name;
1126
+		}
943 1127
 		$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";
944 1128
 		$query_data = array('filter_name' => $filter_name);
945 1129
                  try {
@@ -961,7 +1145,9 @@  discard block
 block discarded – undo
961 1145
 	}
962 1146
 	public function countAllMonths($stats_airline = '',$filter_name = '') {
963 1147
 		global $globalStatsFilters, $globalDBdriver;
964
-		if ($filter_name == '') $filter_name = $this->filter_name;
1148
+		if ($filter_name == '') {
1149
+			$filter_name = $this->filter_name;
1150
+		}
965 1151
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
966 1152
 			$Spotter = new Spotter($this->db);
967 1153
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1048,7 +1234,9 @@  discard block
 block discarded – undo
1048 1234
 	}
1049 1235
 	public function countAllMilitaryMonths($filter_name = '') {
1050 1236
 		global $globalStatsFilters;
1051
-		if ($filter_name == '') $filter_name = $this->filter_name;
1237
+		if ($filter_name == '') {
1238
+			$filter_name = $this->filter_name;
1239
+		}
1052 1240
 	    	$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";
1053 1241
                  try {
1054 1242
                         $sth = $this->db->prepare($query);
@@ -1069,7 +1257,9 @@  discard block
 block discarded – undo
1069 1257
 	}
1070 1258
 	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
1071 1259
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
1072
-		if ($filter_name == '') $filter_name = $this->filter_name;
1260
+		if ($filter_name == '') {
1261
+			$filter_name = $this->filter_name;
1262
+		}
1073 1263
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1074 1264
 			$Spotter = new Spotter($this->db);
1075 1265
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1077,12 +1267,18 @@  discard block
 block discarded – undo
1077 1267
 			foreach ($airlines as $airline) {
1078 1268
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1079 1269
 			}
1080
-			if ($limit) $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1081
-			else $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1270
+			if ($limit) {
1271
+				$query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1272
+			} else {
1273
+				$query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1274
+			}
1082 1275
 			$query_data = array(':filter_name' => $filter_name);
1083 1276
 		} else {
1084
-			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";
1085
-			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";
1277
+			if ($limit) {
1278
+				$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";
1279
+			} else {
1280
+				$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";
1281
+			}
1086 1282
 			$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1087 1283
 		}
1088 1284
 		if ($orderby == 'hour') {
@@ -1092,7 +1288,9 @@  discard block
 block discarded – undo
1092 1288
 				$query .= " ORDER BY CAST(flight_date AS integer) ASC";
1093 1289
 			}
1094 1290
 		}
1095
-		if ($orderby == 'count') $query .= " ORDER BY hour_count DESC";
1291
+		if ($orderby == 'count') {
1292
+			$query .= " ORDER BY hour_count DESC";
1293
+		}
1096 1294
 		try {
1097 1295
 			$sth = $this->db->prepare($query);
1098 1296
 			$sth->execute($query_data);
@@ -1116,8 +1314,12 @@  discard block
 block discarded – undo
1116 1314
 	}
1117 1315
 	public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') {
1118 1316
 		global $globalStatsFilters;
1119
-		if ($filter_name == '') $filter_name = $this->filter_name;
1120
-		if ($year == '') $year = date('Y');
1317
+		if ($filter_name == '') {
1318
+			$filter_name = $this->filter_name;
1319
+		}
1320
+		if ($year == '') {
1321
+			$year = date('Y');
1322
+		}
1121 1323
 		$all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month);
1122 1324
 		if (empty($all)) {
1123 1325
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -1136,8 +1338,12 @@  discard block
 block discarded – undo
1136 1338
 	}
1137 1339
 	public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') {
1138 1340
 		global $globalStatsFilters;
1139
-		if ($filter_name == '') $filter_name = $this->filter_name;
1140
-		if ($year == '') $year = date('Y');
1341
+		if ($filter_name == '') {
1342
+			$filter_name = $this->filter_name;
1343
+		}
1344
+		if ($year == '') {
1345
+			$year = date('Y');
1346
+		}
1141 1347
 		$all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month);
1142 1348
 		if (empty($all)) {
1143 1349
 		        $filters = array();
@@ -1153,8 +1359,12 @@  discard block
 block discarded – undo
1153 1359
 	}
1154 1360
 	public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') {
1155 1361
 		global $globalStatsFilters;
1156
-		if ($filter_name == '') $filter_name = $this->filter_name;
1157
-		if ($year == '') $year = date('Y');
1362
+		if ($filter_name == '') {
1363
+			$filter_name = $this->filter_name;
1364
+		}
1365
+		if ($year == '') {
1366
+			$year = date('Y');
1367
+		}
1158 1368
 		$all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month);
1159 1369
 		if (empty($all)) {
1160 1370
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -1173,7 +1383,9 @@  discard block
 block discarded – undo
1173 1383
 	}
1174 1384
 	public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') {
1175 1385
 		global $globalStatsFilters;
1176
-		if ($filter_name == '') $filter_name = $this->filter_name;
1386
+		if ($filter_name == '') {
1387
+			$filter_name = $this->filter_name;
1388
+		}
1177 1389
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1178 1390
 			$Spotter = new Spotter($this->db);
1179 1391
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1191,7 +1403,9 @@  discard block
 block discarded – undo
1191 1403
 				}
1192 1404
 				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1193 1405
 				$all = $result[0]['nb'];
1194
-			} else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1406
+			} else {
1407
+				$all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1408
+			}
1195 1409
 		} else {
1196 1410
 			if ($year == '' && $month == '') {
1197 1411
 				$query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
@@ -1203,7 +1417,9 @@  discard block
 block discarded – undo
1203 1417
 				}
1204 1418
 				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1205 1419
 				$all = $result[0]['nb'];
1206
-			} else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1420
+			} else {
1421
+				$all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1422
+			}
1207 1423
 		}
1208 1424
 		if (empty($all)) {
1209 1425
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -1222,7 +1438,9 @@  discard block
 block discarded – undo
1222 1438
 	}
1223 1439
 	public function countOverallAirlines($filter_name = '',$year = '',$month = '') {
1224 1440
 		global $globalStatsFilters;
1225
-		if ($filter_name == '') $filter_name = $this->filter_name;
1441
+		if ($filter_name == '') {
1442
+			$filter_name = $this->filter_name;
1443
+		}
1226 1444
 		if ($year == '' && $month == '') {
1227 1445
 			$query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name";
1228 1446
 			try {
@@ -1233,7 +1451,9 @@  discard block
 block discarded – undo
1233 1451
 			}
1234 1452
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1235 1453
 			$all = $result[0]['nb_airline'];
1236
-		} else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
1454
+		} else {
1455
+			$all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
1456
+		}
1237 1457
 		if (empty($all)) {
1238 1458
             		$filters = array();
1239 1459
 			$filters = array('year' => $year,'month' => $month);
@@ -1248,7 +1468,9 @@  discard block
 block discarded – undo
1248 1468
 	}
1249 1469
 	public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') {
1250 1470
 		global $globalStatsFilters;
1251
-		if ($filter_name == '') $filter_name = $this->filter_name;
1471
+		if ($filter_name == '') {
1472
+			$filter_name = $this->filter_name;
1473
+		}
1252 1474
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1253 1475
 			$Spotter = new Spotter($this->db);
1254 1476
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1303,7 +1525,9 @@  discard block
 block discarded – undo
1303 1525
 	}
1304 1526
 	public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') {
1305 1527
 		global $globalStatsFilters;
1306
-		if ($filter_name == '') $filter_name = $this->filter_name;
1528
+		if ($filter_name == '') {
1529
+			$filter_name = $this->filter_name;
1530
+		}
1307 1531
 		//if ($year == '') $year = date('Y');
1308 1532
 		if ($year == '' && $month == '') {
1309 1533
 			$query = "SELECT count(*) as nb FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
@@ -1332,7 +1556,9 @@  discard block
 block discarded – undo
1332 1556
 	}
1333 1557
 
1334 1558
 	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') {
1335
-		if ($filter_name == '') $filter_name = $this->filter_name;
1559
+		if ($filter_name == '') {
1560
+			$filter_name = $this->filter_name;
1561
+		}
1336 1562
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1337 1563
 			$Spotter = new Spotter($this->db);
1338 1564
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1356,7 +1582,9 @@  discard block
 block discarded – undo
1356 1582
 		return $all;
1357 1583
 	}
1358 1584
 	public function getStats($type,$stats_airline = '', $filter_name = '') {
1359
-		if ($filter_name == '') $filter_name = $this->filter_name;
1585
+		if ($filter_name == '') {
1586
+			$filter_name = $this->filter_name;
1587
+		}
1360 1588
 		$query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
1361 1589
 		$query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1362 1590
 		try {
@@ -1369,7 +1597,9 @@  discard block
 block discarded – undo
1369 1597
 		return $all;
1370 1598
 	}
1371 1599
 	public function deleteStatsByType($type,$stats_airline = '', $filter_name = '') {
1372
-		if ($filter_name == '') $filter_name = $this->filter_name;
1600
+		if ($filter_name == '') {
1601
+			$filter_name = $this->filter_name;
1602
+		}
1373 1603
 		$query = "DELETE FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name";
1374 1604
 		$query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1375 1605
 		try {
@@ -1380,7 +1610,9 @@  discard block
 block discarded – undo
1380 1610
 		}
1381 1611
 	}
1382 1612
 	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') {
1383
-		if ($filter_name == '') $filter_name = $this->filter_name;
1613
+		if ($filter_name == '') {
1614
+			$filter_name = $this->filter_name;
1615
+		}
1384 1616
 		global $globalArchiveMonths, $globalDBdriver;
1385 1617
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1386 1618
 			$Spotter = new Spotter($this->db);
@@ -1436,7 +1668,9 @@  discard block
 block discarded – undo
1436 1668
 	}
1437 1669
 	public function getStatsTotal($type, $stats_airline = '', $filter_name = '') {
1438 1670
 		global $globalArchiveMonths, $globalDBdriver;
1439
-		if ($filter_name == '') $filter_name = $this->filter_name;
1671
+		if ($filter_name == '') {
1672
+			$filter_name = $this->filter_name;
1673
+		}
1440 1674
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1441 1675
 			$Spotter = new Spotter($this->db);
1442 1676
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1469,7 +1703,9 @@  discard block
 block discarded – undo
1469 1703
 	}
1470 1704
 	public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') {
1471 1705
 		global $globalArchiveMonths, $globalDBdriver;
1472
-		if ($filter_name == '') $filter_name = $this->filter_name;
1706
+		if ($filter_name == '') {
1707
+			$filter_name = $this->filter_name;
1708
+		}
1473 1709
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1474 1710
 			$Spotter = new Spotter($this->db);
1475 1711
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1500,7 +1736,9 @@  discard block
 block discarded – undo
1500 1736
 	}
1501 1737
 	public function getStatsAirlineTotal($filter_name = '') {
1502 1738
     		global $globalArchiveMonths, $globalDBdriver;
1503
-		if ($filter_name == '') $filter_name = $this->filter_name;
1739
+		if ($filter_name == '') {
1740
+			$filter_name = $this->filter_name;
1741
+		}
1504 1742
     		if ($globalDBdriver == 'mysql') {
1505 1743
 			$query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name";
1506 1744
                 } else {
@@ -1517,7 +1755,9 @@  discard block
 block discarded – undo
1517 1755
         }
1518 1756
 	public function getStatsOwnerTotal($filter_name = '') {
1519 1757
     		global $globalArchiveMonths, $globalDBdriver;
1520
-		if ($filter_name == '') $filter_name = $this->filter_name;
1758
+		if ($filter_name == '') {
1759
+			$filter_name = $this->filter_name;
1760
+		}
1521 1761
     		if ($globalDBdriver == 'mysql') {
1522 1762
 			$query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name";
1523 1763
 		} else {
@@ -1534,7 +1774,9 @@  discard block
 block discarded – undo
1534 1774
         }
1535 1775
 	public function getStatsOwner($owner_name,$filter_name = '') {
1536 1776
     		global $globalArchiveMonths, $globalDBdriver;
1537
-		if ($filter_name == '') $filter_name = $this->filter_name;
1777
+		if ($filter_name == '') {
1778
+			$filter_name = $this->filter_name;
1779
+		}
1538 1780
 		$query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name";
1539 1781
                  try {
1540 1782
                         $sth = $this->db->prepare($query);
@@ -1543,12 +1785,17 @@  discard block
 block discarded – undo
1543 1785
                         echo "error : ".$e->getMessage();
1544 1786
                 }
1545 1787
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
1546
-                if (isset($all[0]['cnt'])) return $all[0]['cnt'];
1547
-                else return 0;
1788
+                if (isset($all[0]['cnt'])) {
1789
+                	return $all[0]['cnt'];
1790
+                } else {
1791
+                	return 0;
1792
+                }
1548 1793
         }
1549 1794
 	public function getStatsPilotTotal($filter_name = '') {
1550 1795
     		global $globalArchiveMonths, $globalDBdriver;
1551
-		if ($filter_name == '') $filter_name = $this->filter_name;
1796
+		if ($filter_name == '') {
1797
+			$filter_name = $this->filter_name;
1798
+		}
1552 1799
     		if ($globalDBdriver == 'mysql') {
1553 1800
             		$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
1554 1801
             	} else {
@@ -1565,7 +1812,9 @@  discard block
 block discarded – undo
1565 1812
         }
1566 1813
 	public function getStatsPilot($pilot,$filter_name = '') {
1567 1814
     		global $globalArchiveMonths, $globalDBdriver;
1568
-		if ($filter_name == '') $filter_name = $this->filter_name;
1815
+		if ($filter_name == '') {
1816
+			$filter_name = $this->filter_name;
1817
+		}
1569 1818
 		$query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)";
1570 1819
                  try {
1571 1820
                         $sth = $this->db->prepare($query);
@@ -1574,13 +1823,18 @@  discard block
 block discarded – undo
1574 1823
                         echo "error : ".$e->getMessage();
1575 1824
                 }
1576 1825
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
1577
-                if (isset($all[0]['cnt'])) return $all[0]['cnt'];
1578
-                else return 0;
1826
+                if (isset($all[0]['cnt'])) {
1827
+                	return $all[0]['cnt'];
1828
+                } else {
1829
+                	return 0;
1830
+                }
1579 1831
         }
1580 1832
 
1581 1833
 	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1582 1834
 		global $globalDBdriver;
1583
-		if ($filter_name == '') $filter_name = $this->filter_name;
1835
+		if ($filter_name == '') {
1836
+			$filter_name = $this->filter_name;
1837
+		}
1584 1838
 		if ($globalDBdriver == 'mysql') {
1585 1839
 			$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";
1586 1840
                 } else {
@@ -1596,7 +1850,9 @@  discard block
 block discarded – undo
1596 1850
         }
1597 1851
 	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1598 1852
 		global $globalDBdriver;
1599
-		if ($filter_name == '') $filter_name = $this->filter_name;
1853
+		if ($filter_name == '') {
1854
+			$filter_name = $this->filter_name;
1855
+		}
1600 1856
 		if ($globalDBdriver == 'mysql') {
1601 1857
 			$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";
1602 1858
 		} else {
@@ -1982,10 +2238,14 @@  discard block
 block discarded – undo
1982 2238
     		$Connection = new Connection();
1983 2239
     		date_default_timezone_set('UTC');
1984 2240
     		$last_update = $this->getLastStatsUpdate('last_update_stats');
1985
-			if ($globalDebug) echo 'Update stats !'."\n";
2241
+			if ($globalDebug) {
2242
+				echo 'Update stats !'."\n";
2243
+			}
1986 2244
 			if (isset($last_update[0]['value'])) {
1987 2245
 				$last_update_day = $last_update[0]['value'];
1988
-			} else $last_update_day = '2012-12-12 12:12:12';
2246
+			} else {
2247
+				$last_update_day = '2012-12-12 12:12:12';
2248
+			}
1989 2249
 			$reset = false;
1990 2250
 			//if ($globalStatsResetYear && date('Y',strtotime($last_update_day)) != date('Y')) {
1991 2251
 			if ($globalStatsResetYear) {
@@ -1994,43 +2254,63 @@  discard block
 block discarded – undo
1994 2254
 			}
1995 2255
 			$Spotter = new Spotter($this->db);
1996 2256
 
1997
-			if ($globalDebug) echo 'Count all aircraft types...'."\n";
2257
+			if ($globalDebug) {
2258
+				echo 'Count all aircraft types...'."\n";
2259
+			}
1998 2260
 			$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);
1999 2261
 			foreach ($alldata as $number) {
2000 2262
 				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset);
2001 2263
 			}
2002
-			if ($globalDebug) echo 'Count all airlines...'."\n";
2264
+			if ($globalDebug) {
2265
+				echo 'Count all airlines...'."\n";
2266
+			}
2003 2267
 			$alldata = $Spotter->countAllAirlines(false,0,$last_update_day);
2004 2268
 			foreach ($alldata as $number) {
2005 2269
 				$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset);
2006 2270
 			}
2007
-			if ($globalDebug) echo 'Count all registrations...'."\n";
2271
+			if ($globalDebug) {
2272
+				echo 'Count all registrations...'."\n";
2273
+			}
2008 2274
 			$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day);
2009 2275
 			foreach ($alldata as $number) {
2010 2276
 				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset);
2011 2277
 			}
2012
-			if ($globalDebug) echo 'Count all callsigns...'."\n";
2278
+			if ($globalDebug) {
2279
+				echo 'Count all callsigns...'."\n";
2280
+			}
2013 2281
 			$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day);
2014 2282
 			foreach ($alldata as $number) {
2015 2283
 				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
2016 2284
 			}
2017
-			if ($globalDebug) echo 'Count all owners...'."\n";
2285
+			if ($globalDebug) {
2286
+				echo 'Count all owners...'."\n";
2287
+			}
2018 2288
 			$alldata = $Spotter->countAllOwners(false,0,$last_update_day);
2019 2289
 			foreach ($alldata as $number) {
2020 2290
 				$this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset);
2021 2291
 			}
2022
-			if ($globalDebug) echo 'Count all pilots...'."\n";
2292
+			if ($globalDebug) {
2293
+				echo 'Count all pilots...'."\n";
2294
+			}
2023 2295
 			$alldata = $Spotter->countAllPilots(false,0,$last_update_day);
2024 2296
 			foreach ($alldata as $number) {
2025
-				if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') $number['pilot_id'] = $number['pilot_name'];
2297
+				if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') {
2298
+					$number['pilot_id'] = $number['pilot_name'];
2299
+				}
2026 2300
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset);
2027 2301
 			}
2028 2302
 			
2029
-			if ($globalDebug) echo 'Count all departure airports...'."\n";
2303
+			if ($globalDebug) {
2304
+				echo 'Count all departure airports...'."\n";
2305
+			}
2030 2306
 			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
2031
-			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
2307
+			if ($globalDebug) {
2308
+				echo 'Count all detected departure airports...'."\n";
2309
+			}
2032 2310
         		$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
2033
-			if ($globalDebug) echo 'Order departure airports...'."\n";
2311
+			if ($globalDebug) {
2312
+				echo 'Order departure airports...'."\n";
2313
+			}
2034 2314
 	        	$alldata = array();
2035 2315
 	        	
2036 2316
     			foreach ($pall as $value) {
@@ -2041,7 +2321,9 @@  discard block
 block discarded – undo
2041 2321
     				$icao = $value['airport_departure_icao'];
2042 2322
         			if (isset($alldata[$icao])) {
2043 2323
     					$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
2044
-        			} else $alldata[$icao] = $value;
2324
+        			} else {
2325
+        				$alldata[$icao] = $value;
2326
+        			}
2045 2327
 			}
2046 2328
     			$count = array();
2047 2329
     			foreach ($alldata as $key => $row) {
@@ -2051,11 +2333,17 @@  discard block
 block discarded – undo
2051 2333
 			foreach ($alldata as $number) {
2052 2334
 				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);
2053 2335
 			}
2054
-			if ($globalDebug) echo 'Count all arrival airports...'."\n";
2336
+			if ($globalDebug) {
2337
+				echo 'Count all arrival airports...'."\n";
2338
+			}
2055 2339
 			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
2056
-			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
2340
+			if ($globalDebug) {
2341
+				echo 'Count all detected arrival airports...'."\n";
2342
+			}
2057 2343
         		$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
2058
-			if ($globalDebug) echo 'Order arrival airports...'."\n";
2344
+			if ($globalDebug) {
2345
+				echo 'Order arrival airports...'."\n";
2346
+			}
2059 2347
 	        	$alldata = array();
2060 2348
     			foreach ($pall as $value) {
2061 2349
 	        		$icao = $value['airport_arrival_icao'];
@@ -2065,7 +2353,9 @@  discard block
 block discarded – undo
2065 2353
     				$icao = $value['airport_arrival_icao'];
2066 2354
         			if (isset($alldata[$icao])) {
2067 2355
         				$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
2068
-	        		} else $alldata[$icao] = $value;
2356
+	        		} else {
2357
+	        			$alldata[$icao] = $value;
2358
+	        		}
2069 2359
     			}
2070 2360
         		$count = array();
2071 2361
         		foreach ($alldata as $key => $row) {
@@ -2076,7 +2366,9 @@  discard block
 block discarded – undo
2076 2366
 				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);
2077 2367
 			}
2078 2368
 			if ($Connection->tableExists('countries')) {
2079
-				if ($globalDebug) echo 'Count all flights by countries...'."\n";
2369
+				if ($globalDebug) {
2370
+					echo 'Count all flights by countries...'."\n";
2371
+				}
2080 2372
 				//$SpotterArchive = new SpotterArchive();
2081 2373
 				//$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day);
2082 2374
 				$Spotter = new Spotter($this->db);
@@ -2087,7 +2379,9 @@  discard block
 block discarded – undo
2087 2379
 			}
2088 2380
 			
2089 2381
 			if (isset($globalAccidents) && $globalAccidents) {
2090
-				if ($globalDebug) echo 'Count fatalities stats...'."\n";
2382
+				if ($globalDebug) {
2383
+					echo 'Count fatalities stats...'."\n";
2384
+				}
2091 2385
 				$Accident = new Accident();
2092 2386
 				$this->deleteStatsByType('fatalities_byyear');
2093 2387
 				$alldata = $Accident->countFatalitiesByYear();
@@ -2105,48 +2399,68 @@  discard block
 block discarded – undo
2105 2399
 			// Add by month using getstat if month finish...
2106 2400
 
2107 2401
 			//if (date('m',strtotime($last_update_day)) != date('m')) {
2108
-			if ($globalDebug) echo 'Count all flights by months...'."\n";
2402
+			if ($globalDebug) {
2403
+				echo 'Count all flights by months...'."\n";
2404
+			}
2109 2405
 			$last_month = date('Y-m-01 00:00:00', strtotime('-1 month', strtotime($last_update_day)));
2110 2406
 			$filter_last_month = array('since_date' => $last_month);
2111 2407
 			$Spotter = new Spotter($this->db);
2112 2408
 			$alldata = $Spotter->countAllMonths($filter_last_month);
2113 2409
 			$lastyear = false;
2114 2410
 			foreach ($alldata as $number) {
2115
-				if ($number['year_name'] != date('Y')) $lastyear = true;
2411
+				if ($number['year_name'] != date('Y')) {
2412
+					$lastyear = true;
2413
+				}
2116 2414
 				$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'])));
2117 2415
 			}
2118
-			if ($globalDebug) echo 'Count all military flights by months...'."\n";
2416
+			if ($globalDebug) {
2417
+				echo 'Count all military flights by months...'."\n";
2418
+			}
2119 2419
 			$alldata = $Spotter->countAllMilitaryMonths($filter_last_month);
2120 2420
 			foreach ($alldata as $number) {
2121 2421
 				$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'])));
2122 2422
 			}
2123
-			if ($globalDebug) echo 'Count all owners by months...'."\n";
2423
+			if ($globalDebug) {
2424
+				echo 'Count all owners by months...'."\n";
2425
+			}
2124 2426
 			$alldata = $Spotter->countAllMonthsOwners($filter_last_month);
2125 2427
 			foreach ($alldata as $number) {
2126 2428
 				$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'])));
2127 2429
 			}
2128
-			if ($globalDebug) echo 'Count all pilots by months...'."\n";
2430
+			if ($globalDebug) {
2431
+				echo 'Count all pilots by months...'."\n";
2432
+			}
2129 2433
 			$alldata = $Spotter->countAllMonthsPilots($filter_last_month);
2130 2434
 			foreach ($alldata as $number) {
2131 2435
 				$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'])));
2132 2436
 			}
2133
-			if ($globalDebug) echo 'Count all airlines by months...'."\n";
2437
+			if ($globalDebug) {
2438
+				echo 'Count all airlines by months...'."\n";
2439
+			}
2134 2440
 			$alldata = $Spotter->countAllMonthsAirlines($filter_last_month);
2135 2441
 			foreach ($alldata as $number) {
2136 2442
 				$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'])));
2137 2443
 			}
2138
-			if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
2444
+			if ($globalDebug) {
2445
+				echo 'Count all aircrafts by months...'."\n";
2446
+			}
2139 2447
 			$alldata = $Spotter->countAllMonthsAircrafts($filter_last_month);
2140 2448
 			foreach ($alldata as $number) {
2141 2449
 				$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'])));
2142 2450
 			}
2143
-			if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
2451
+			if ($globalDebug) {
2452
+				echo 'Count all real arrivals by months...'."\n";
2453
+			}
2144 2454
 			$alldata = $Spotter->countAllMonthsRealArrivals($filter_last_month);
2145 2455
 			foreach ($alldata as $number) {
2146 2456
 				$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'])));
2147 2457
 			}
2148
-			if ($globalDebug) echo 'Airports data...'."\n";
2149
-			if ($globalDebug) echo '...Departure'."\n";
2458
+			if ($globalDebug) {
2459
+				echo 'Airports data...'."\n";
2460
+			}
2461
+			if ($globalDebug) {
2462
+				echo '...Departure'."\n";
2463
+			}
2150 2464
 			$this->deleteStatAirport('daily');
2151 2465
 //			$pall = $Spotter->getLast7DaysAirportsDeparture();
2152 2466
   //      		$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
@@ -2267,7 +2581,9 @@  discard block
 block discarded – undo
2267 2581
 			// Count by airlines
2268 2582
 			echo '--- Stats by airlines ---'."\n";
2269 2583
 			if ($Connection->tableExists('countries')) {
2270
-				if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n";
2584
+				if ($globalDebug) {
2585
+					echo 'Count all flights by countries by airlines...'."\n";
2586
+				}
2271 2587
 				$SpotterArchive = new SpotterArchive();
2272 2588
 				//$Spotter = new Spotter($this->db);
2273 2589
 				$alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day);
@@ -2276,37 +2592,53 @@  discard block
 block discarded – undo
2276 2592
 					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset);
2277 2593
 				}
2278 2594
 			}
2279
-			if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n";
2595
+			if ($globalDebug) {
2596
+				echo 'Count all aircraft types by airlines...'."\n";
2597
+			}
2280 2598
 			$Spotter = new Spotter($this->db);
2281 2599
 			$alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day);
2282 2600
 			foreach ($alldata as $number) {
2283 2601
 				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset);
2284 2602
 			}
2285
-			if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n";
2603
+			if ($globalDebug) {
2604
+				echo 'Count all aircraft registrations by airlines...'."\n";
2605
+			}
2286 2606
 			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day);
2287 2607
 			foreach ($alldata as $number) {
2288 2608
 				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset);
2289 2609
 			}
2290
-			if ($globalDebug) echo 'Count all callsigns by airlines...'."\n";
2610
+			if ($globalDebug) {
2611
+				echo 'Count all callsigns by airlines...'."\n";
2612
+			}
2291 2613
 			$alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day);
2292 2614
 			foreach ($alldata as $number) {
2293 2615
 				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
2294 2616
 			}
2295
-			if ($globalDebug) echo 'Count all owners by airlines...'."\n";
2617
+			if ($globalDebug) {
2618
+				echo 'Count all owners by airlines...'."\n";
2619
+			}
2296 2620
 			$alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day);
2297 2621
 			foreach ($alldata as $number) {
2298 2622
 				$this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset);
2299 2623
 			}
2300
-			if ($globalDebug) echo 'Count all pilots by airlines...'."\n";
2624
+			if ($globalDebug) {
2625
+				echo 'Count all pilots by airlines...'."\n";
2626
+			}
2301 2627
 			$alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day);
2302 2628
 			foreach ($alldata as $number) {
2303 2629
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset);
2304 2630
 			}
2305
-			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
2631
+			if ($globalDebug) {
2632
+				echo 'Count all departure airports by airlines...'."\n";
2633
+			}
2306 2634
 			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
2307
-			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
2635
+			if ($globalDebug) {
2636
+				echo 'Count all detected departure airports by airlines...'."\n";
2637
+			}
2308 2638
        			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
2309
-			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
2639
+			if ($globalDebug) {
2640
+				echo 'Order detected departure airports by airlines...'."\n";
2641
+			}
2310 2642
 	        	//$alldata = array();
2311 2643
     			foreach ($dall as $value) {
2312 2644
     				$icao = $value['airport_departure_icao'];
@@ -2327,11 +2659,17 @@  discard block
 block discarded – undo
2327 2659
 			foreach ($alldata as $number) {
2328 2660
 				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);
2329 2661
 			}
2330
-			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
2662
+			if ($globalDebug) {
2663
+				echo 'Count all arrival airports by airlines...'."\n";
2664
+			}
2331 2665
 			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
2332
-			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
2666
+			if ($globalDebug) {
2667
+				echo 'Count all detected arrival airports by airlines...'."\n";
2668
+			}
2333 2669
         		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
2334
-			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
2670
+			if ($globalDebug) {
2671
+				echo 'Order arrival airports by airlines...'."\n";
2672
+			}
2335 2673
 	        	//$alldata = array();
2336 2674
     			foreach ($dall as $value) {
2337 2675
     				$icao = $value['airport_arrival_icao'];
@@ -2350,37 +2688,53 @@  discard block
 block discarded – undo
2350 2688
     			}
2351 2689
     			$alldata = $pall;
2352 2690
                         foreach ($alldata as $number) {
2353
-				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);
2691
+				if ($number['airline_icao'] != '') {
2692
+					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);
2693
+				}
2694
+			}
2695
+			if ($globalDebug) {
2696
+				echo 'Count all flights by months by airlines...'."\n";
2354 2697
 			}
2355
-			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
2356 2698
 			$Spotter = new Spotter($this->db);
2357 2699
 			$alldata = $Spotter->countAllMonthsByAirlines($filter_last_month);
2358 2700
 			$lastyear = false;
2359 2701
 			foreach ($alldata as $number) {
2360
-				if ($number['year_name'] != date('Y')) $lastyear = true;
2702
+				if ($number['year_name'] != date('Y')) {
2703
+					$lastyear = true;
2704
+				}
2361 2705
 				$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']);
2362 2706
 			}
2363
-			if ($globalDebug) echo 'Count all owners by months by airlines...'."\n";
2707
+			if ($globalDebug) {
2708
+				echo 'Count all owners by months by airlines...'."\n";
2709
+			}
2364 2710
 			$alldata = $Spotter->countAllMonthsOwnersByAirlines($filter_last_month);
2365 2711
 			foreach ($alldata as $number) {
2366 2712
 				$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']);
2367 2713
 			}
2368
-			if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n";
2714
+			if ($globalDebug) {
2715
+				echo 'Count all pilots by months by airlines...'."\n";
2716
+			}
2369 2717
 			$alldata = $Spotter->countAllMonthsPilotsByAirlines($filter_last_month);
2370 2718
 			foreach ($alldata as $number) {
2371 2719
 				$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']);
2372 2720
 			}
2373
-			if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n";
2721
+			if ($globalDebug) {
2722
+				echo 'Count all aircrafts by months by airlines...'."\n";
2723
+			}
2374 2724
 			$alldata = $Spotter->countAllMonthsAircraftsByAirlines($filter_last_month);
2375 2725
 			foreach ($alldata as $number) {
2376 2726
 				$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']);
2377 2727
 			}
2378
-			if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n";
2728
+			if ($globalDebug) {
2729
+				echo 'Count all real arrivals by months by airlines...'."\n";
2730
+			}
2379 2731
 			$alldata = $Spotter->countAllMonthsRealArrivalsByAirlines($filter_last_month);
2380 2732
 			foreach ($alldata as $number) {
2381 2733
 				$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']);
2382 2734
 			}
2383
-			if ($globalDebug) echo '...Departure'."\n";
2735
+			if ($globalDebug) {
2736
+				echo '...Departure'."\n";
2737
+			}
2384 2738
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
2385 2739
         		$dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines();
2386 2740
     			foreach ($dall as $value) {
@@ -2403,7 +2757,9 @@  discard block
 block discarded – undo
2403 2757
 			foreach ($alldata as $number) {
2404 2758
 				$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']);
2405 2759
 			}
2406
-			if ($globalDebug) echo '...Arrival'."\n";
2760
+			if ($globalDebug) {
2761
+				echo '...Arrival'."\n";
2762
+			}
2407 2763
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
2408 2764
         		$dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines();
2409 2765
     			foreach ($dall as $value) {
@@ -2427,13 +2783,19 @@  discard block
 block discarded – undo
2427 2783
 				$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']);
2428 2784
 			}
2429 2785
 
2430
-			if ($globalDebug) echo 'Flights data...'."\n";
2431
-			if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n";
2786
+			if ($globalDebug) {
2787
+				echo 'Flights data...'."\n";
2788
+			}
2789
+			if ($globalDebug) {
2790
+				echo '-> countAllDatesLastMonth...'."\n";
2791
+			}
2432 2792
 			$alldata = $Spotter->countAllDatesLastMonthByAirlines($filter_last_month);
2433 2793
 			foreach ($alldata as $number) {
2434 2794
 				$this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']);
2435 2795
 			}
2436
-			if ($globalDebug) echo '-> countAllDates...'."\n";
2796
+			if ($globalDebug) {
2797
+				echo '-> countAllDates...'."\n";
2798
+			}
2437 2799
 			//$previousdata = $this->countAllDatesByAirlines();
2438 2800
 			$alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines($filter_last_month));
2439 2801
 			$values = array();
@@ -2446,7 +2808,9 @@  discard block
 block discarded – undo
2446 2808
 				$this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']);
2447 2809
 			}
2448 2810
 			
2449
-			if ($globalDebug) echo '-> countAllHours...'."\n";
2811
+			if ($globalDebug) {
2812
+				echo '-> countAllHours...'."\n";
2813
+			}
2450 2814
 			$alldata = $Spotter->countAllHoursByAirlines('hour',$filter_last_month);
2451 2815
 			foreach ($alldata as $number) {
2452 2816
 				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']);
@@ -2454,14 +2818,18 @@  discard block
 block discarded – undo
2454 2818
 			
2455 2819
 
2456 2820
 			// Stats by filters
2457
-			if (!isset($globalStatsFilters) || $globalStatsFilters == '') $globalStatsFilters = array();
2821
+			if (!isset($globalStatsFilters) || $globalStatsFilters == '') {
2822
+				$globalStatsFilters = array();
2823
+			}
2458 2824
 			foreach ($globalStatsFilters as $name => $filter) {
2459 2825
 				//$filter_name = $filter['name'];
2460 2826
 				$filter_name = $name;
2461 2827
 				$reset = false;
2462 2828
 				$last_update = $this->getLastStatsUpdate('last_update_stats_'.$filter_name);
2463 2829
 				if (isset($filter['resetall']) && isset($last_update[0]['value']) && strtotime($filter['resetall']) > strtotime($last_update[0]['value'])) {
2464
-					if ($globalDebug) echo '!!! Delete stats for filter '.$filter_name.' !!!'."\n";
2830
+					if ($globalDebug) {
2831
+						echo '!!! Delete stats for filter '.$filter_name.' !!!'."\n";
2832
+					}
2465 2833
 					$this->deleteOldStats($filter_name);
2466 2834
 					unset($last_update);
2467 2835
 				}
@@ -2480,7 +2848,9 @@  discard block
 block discarded – undo
2480 2848
 				
2481 2849
 
2482 2850
 				// Count by filter
2483
-				if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n";
2851
+				if ($globalDebug) {
2852
+					echo '--- Stats for filter '.$filter_name.' ---'."\n";
2853
+				}
2484 2854
 				$Spotter = new Spotter($this->db);
2485 2855
 				$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter);
2486 2856
 				foreach ($alldata as $number) {
@@ -2517,7 +2887,9 @@  discard block
 block discarded – undo
2517 2887
 	    				$icao = $value['airport_departure_icao'];
2518 2888
         				if (isset($alldata[$icao])) {
2519 2889
     						$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
2520
-        				} else $alldata[$icao] = $value;
2890
+        				} else {
2891
+        					$alldata[$icao] = $value;
2892
+        				}
2521 2893
 				}
2522 2894
 	    			$count = array();
2523 2895
     				foreach ($alldata as $key => $row) {
@@ -2538,7 +2910,9 @@  discard block
 block discarded – undo
2538 2910
 	    				$icao = $value['airport_arrival_icao'];
2539 2911
         				if (isset($alldata[$icao])) {
2540 2912
         					$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
2541
-		        		} else $alldata[$icao] = $value;
2913
+		        		} else {
2914
+		        			$alldata[$icao] = $value;
2915
+		        		}
2542 2916
 	    			}
2543 2917
         			$count = array();
2544 2918
         			foreach ($alldata as $key => $row) {
@@ -2552,7 +2926,9 @@  discard block
 block discarded – undo
2552 2926
 				$alldata = $Spotter->countAllMonths($filter);
2553 2927
 				$lastyear = false;
2554 2928
 				foreach ($alldata as $number) {
2555
-					if ($number['year_name'] != date('Y')) $lastyear = true;
2929
+					if ($number['year_name'] != date('Y')) {
2930
+						$lastyear = true;
2931
+					}
2556 2932
 					$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);
2557 2933
 				}
2558 2934
 				$alldata = $Spotter->countAllMonthsOwners($filter);
Please login to merge, or discard this patch.
statistics.php 1 patch
Braces   +142 added lines, -67 removed lines patch added patch discarded remove patch
@@ -18,11 +18,15 @@  discard block
 block discarded – undo
18 18
 	require_once('require/class.Spotter.php');
19 19
 }
20 20
 
21
-if (!isset($filter_name)) $filter_name = '';
21
+if (!isset($filter_name)) {
22
+	$filter_name = '';
23
+}
22 24
 $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
23 25
 if ($type == 'aircraft' && $airline_icao == '' && isset($globalFilter)) {
24
-	if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
25
-}
26
+	if (isset($globalFilter['airline'])) {
27
+		$airline_icao = $globalFilter['airline'][0];
28
+	}
29
+	}
26 30
 if ($type == 'aircraft' && $airline_icao != '' && $airline_icao != 'all') {
27 31
 	$Spotter = new Spotter();
28 32
 	$airline_info = $Spotter->getAllAirlineInfo($airline_icao);
@@ -61,7 +65,12 @@  discard block
 block discarded – undo
61 65
 <script type="text/javascript" src="<?php echo $globalURL; ?>/js/datamaps.world.min.js"></script>
62 66
 <div class="column">
63 67
     <div class="info">
64
-            <h1><?php if (isset($airline_name)) echo _("Statistics for ").$airline_name; else echo _("Statistics"); ?></h1>
68
+            <h1><?php if (isset($airline_name)) {
69
+	echo _("Statistics for ").$airline_name;
70
+} else {
71
+	echo _("Statistics");
72
+}
73
+?></h1>
65 74
 <?php 
66 75
 if ($type == 'aircraft') {
67 76
 	$last_update = $Stats->getLastStatsUpdate();
@@ -69,7 +78,9 @@  discard block
 block discarded – undo
69 78
 	if (isset($last_update[0]['value'])) {
70 79
 		date_default_timezone_set('UTC');
71 80
 		$lastupdate = strtotime($last_update[0]['value']);
72
-		if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone);
81
+		if (isset($globalTimezone) && $globalTimezone != '') {
82
+			date_default_timezone_set($globalTimezone);
83
+		}
73 84
 		print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>';
74 85
 	}
75 86
 }
@@ -154,8 +165,11 @@  discard block
 block discarded – undo
154 165
 		print '<div id="chart1" class="chart" width="100%"></div><script>';
155 166
 		$aircraft_data = '';
156 167
 		foreach($aircraft_array as $aircraft_item) {
157
-			if ($aircraft_item['aircraft_manufacturer'] == 'Not Available') $aircraft_data .= '[" ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
158
-			else $aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
168
+			if ($aircraft_item['aircraft_manufacturer'] == 'Not Available') {
169
+				$aircraft_data .= '[" ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
170
+			} else {
171
+				$aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
172
+			}
159 173
 		}
160 174
 		$aircraft_data = substr($aircraft_data, 0, -1);
161 175
 		print 'var series = ['.$aircraft_data.'];';
@@ -172,11 +186,17 @@  discard block
 block discarded – undo
172 186
 <?php
173 187
 	if ($year != '' && $month != '') {
174 188
 ?>
175
-            	    <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>
189
+            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
190
+	echo '/'.$airline_icao;
191
+}
192
+?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
176 193
 <?php
177 194
 	} else {
178 195
 ?>
179
-            	    <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>
196
+            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
197
+	echo '/'.$airline_icao;
198
+}
199
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
180 200
 <?php
181 201
 	}
182 202
 ?>
@@ -205,11 +225,15 @@  discard block
 block discarded – undo
205 225
 			print '</script>';
206 226
 			if ($year != '' && $month != '') {
207 227
 				print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
208
-				if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
228
+				if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
229
+					echo '/'.$airline_icao;
230
+				}
209 231
 				print '/'.$year.'/'.$month.'/" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
210 232
 			} else {
211 233
 				print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
212
-				if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
234
+				if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
235
+					echo '/'.$airline_icao;
236
+				}
213 237
 				print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
214 238
 			}
215 239
 			print '</div>';
@@ -229,8 +253,9 @@  discard block
 block discarded – undo
229 253
                 <h2><?php echo _("Top 10 Most Common Vessel Type"); ?></h2>
230 254
 <?php
231 255
 	$marine_array = $Marine->countAllMarineTypes(true,0,'',array(),$year,$month);
232
-	if (count($marine_array) == 0) print _("No data available");
233
-	else {
256
+	if (count($marine_array) == 0) {
257
+		print _("No data available");
258
+	} else {
234 259
 		print '<div id="chart1" class="chart" width="100%"></div><script>';
235 260
 		$marine_data = '';
236 261
 		foreach($marine_array as $marine_item) {
@@ -274,8 +299,9 @@  discard block
 block discarded – undo
274 299
                 <h2><?php echo _("Top 10 Most Common Tracker Type"); ?></h2>
275 300
 <?php
276 301
 	$tracker_array = $Tracker->countAllTrackerTypes(true,0,'',array(),$year,$month);
277
-	if (count($tracker_array) == 0) print _("No data available");
278
-	else {
302
+	if (count($tracker_array) == 0) {
303
+		print _("No data available");
304
+	} else {
279 305
 		print '<div id="chart1" class="chart" width="100%"></div><script>';
280 306
 		$tracker_data = '';
281 307
 		foreach($tracker_array as $tracker_item) {
@@ -328,8 +354,9 @@  discard block
 block discarded – undo
328 354
                 <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2>
329 355
 <?php
330 356
 		$pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month);
331
-		if (count($pilot_array) == 0) print _("No data available");
332
-		else {
357
+		if (count($pilot_array) == 0) {
358
+			print _("No data available");
359
+		} else {
333 360
 			print '<div id="chart7" class="chart" width="100%"></div><script>';
334 361
 			$pilot_data = '';
335 362
 			foreach($pilot_array as $pilot_item) {
@@ -347,7 +374,9 @@  discard block
 block discarded – undo
347 374
 		}
348 375
 		print '<div class="more">';
349 376
 		print '<a href="'.$globalURL.'/statistics/pilot'; 
350
-		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
377
+		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
378
+			echo '/'.$airline_icao;
379
+		}
351 380
 		print'" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a>';
352 381
 		print '</div>';
353 382
 ?>
@@ -363,8 +392,9 @@  discard block
 block discarded – undo
363 392
                 <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
364 393
 <?php
365 394
 		$owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name,$year,$month);
366
-		if (count($owner_array) == 0) print _("No data available");
367
-		else {
395
+		if (count($owner_array) == 0) {
396
+			print _("No data available");
397
+		} else {
368 398
 			print '<div id="chart7" class="chart" width="100%"></div><script>';
369 399
 			$owner_data = '';
370 400
 			foreach($owner_array as $owner_item) {
@@ -382,7 +412,10 @@  discard block
 block discarded – undo
382 412
 		}
383 413
 ?>
384 414
                 <div class="more">
385
-                    <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>
415
+                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
416
+	echo '/'.$airline_icao;
417
+}
418
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
386 419
                 </div>
387 420
             </div>
388 421
         
@@ -395,8 +428,9 @@  discard block
 block discarded – undo
395 428
                 <h2><?php echo _("Top 20 Most Common Country a Flight was Over"); ?></h2>
396 429
 <?php
397 430
 	 //$flightover_array = $Stats->countAllFlightOverCountries();
398
-		if (count($flightover_array) == 0) print _("No data available");
399
-		else {
431
+		if (count($flightover_array) == 0) {
432
+			print _("No data available");
433
+		} else {
400 434
 			print '<div id="chart10" class="chart" width="100%"></div><script>';
401 435
 			print 'var series = [';
402 436
 			$flightover_data = '';
@@ -438,7 +472,10 @@  discard block
 block discarded – undo
438 472
 		}
439 473
 ?>
440 474
                 <div class="more">
441
-                    <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>
475
+                    <a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
476
+	echo '/'.$airline_icao;
477
+}
478
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
442 479
                 </div>
443 480
             </div>
444 481
 <?php
@@ -456,8 +493,9 @@  discard block
 block discarded – undo
456 493
 	<div class="col-md-6">
457 494
             <h2><?php echo _("Top 20 Most Common Country a Vessel was inside"); ?></h2>
458 495
 <?php
459
-	if (count($flightover_array) == 0) print _("No data available");
460
-	else {
496
+	if (count($flightover_array) == 0) {
497
+		print _("No data available");
498
+	} else {
461 499
 		print '<div id="chart10" class="chart" width="100%"></div><script>';
462 500
 		print 'var series = [';
463 501
 		$flightover_data = '';
@@ -513,8 +551,9 @@  discard block
 block discarded – undo
513 551
 	<div class="col-md-6">
514 552
             <h2><?php echo _("Top 20 Most Common Country a Tracker was inside"); ?></h2>
515 553
 <?php
516
-	if (count($flightover_array) == 0) print _("No data available");
517
-	else {
554
+	if (count($flightover_array) == 0) {
555
+		print _("No data available");
556
+	} else {
518 557
 		print '<div id="chart10" class="chart" width="100%"></div><script>';
519 558
 		print 'var series = [';
520 559
 		$flightover_data = '';
@@ -620,7 +659,9 @@  discard block
 block discarded – undo
620 659
 		});";
621 660
 		print '</script>';
622 661
 		print '<div class="more"><a href="'.$globalURL.'/statistics/airport-departure'; 
623
-		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
662
+		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
663
+			echo '/'.$airline_icao;
664
+		}
624 665
 		print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
625 666
 	}
626 667
 ?>
@@ -682,7 +723,9 @@  discard block
 block discarded – undo
682 723
 		});";
683 724
 		print '</script>';
684 725
 		print '<div class="more"><a href="'.$globalURL.'/statistics/airport-arrival';
685
-		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
726
+		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
727
+			echo '/'.$airline_icao;
728
+		}
686 729
 		print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
687 730
 	}
688 731
 ?>
@@ -701,8 +744,9 @@  discard block
 block discarded – undo
701 744
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
702 745
 <?php
703 746
 		$year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
704
-		if (count($year_array) == 0) print _("No data available");
705
-		else {
747
+		if (count($year_array) == 0) {
748
+			print _("No data available");
749
+		} else {
706 750
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
707 751
 			$year_data = '';
708 752
 			$year_cnt = '';
@@ -721,7 +765,10 @@  discard block
 block discarded – undo
721 765
 		}
722 766
 ?>
723 767
                 <div class="more">
724
-                    <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>
768
+                    <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
769
+	echo '/'.$airline_icao;
770
+}
771
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
725 772
                 </div>
726 773
             </div>
727 774
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -729,8 +776,9 @@  discard block
 block discarded – undo
729 776
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
730 777
 <?php
731 778
 		$month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
732
-		if (count($month_array) == 0) print _("No data available");
733
-		else {
779
+		if (count($month_array) == 0) {
780
+			print _("No data available");
781
+		} else {
734 782
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
735 783
 			$month_data = '';
736 784
 			$month_cnt = '';
@@ -749,7 +797,10 @@  discard block
 block discarded – undo
749 797
 		}
750 798
 ?>
751 799
                 <div class="more">
752
-                    <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>
800
+                    <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
801
+	echo '/'.$airline_icao;
802
+}
803
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
753 804
                 </div>
754 805
             </div>
755 806
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -758,8 +809,9 @@  discard block
 block discarded – undo
758 809
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
759 810
 <?php
760 811
 		$date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
761
-		if (empty($date_array)) print _("No data available");
762
-		else {
812
+		if (empty($date_array)) {
813
+			print _("No data available");
814
+		} else {
763 815
 			print '<div id="chart5" class="chart" width="100%"></div><script>';
764 816
 			$date_data = '';
765 817
 			$date_cnt = '';
@@ -778,7 +830,10 @@  discard block
 block discarded – undo
778 830
 		}
779 831
 ?>
780 832
                 <div class="more">
781
-                    <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>
833
+                    <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
834
+	echo '/'.$airline_icao;
835
+}
836
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
782 837
                 </div>
783 838
             </div>
784 839
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -786,8 +841,9 @@  discard block
 block discarded – undo
786 841
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
787 842
 <?php
788 843
 		$hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
789
-		if (empty($hour_array)) print _("No data available");
790
-		else {
844
+		if (empty($hour_array)) {
845
+			print _("No data available");
846
+		} else {
791 847
 			print '<div id="chart6" class="chart" width="100%"></div><script>';
792 848
 			$hour_data = '';
793 849
 			$hour_cnt = '';
@@ -806,7 +862,10 @@  discard block
 block discarded – undo
806 862
 		}
807 863
 ?>
808 864
                 <div class="more">
809
-                    <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>
865
+                    <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
866
+	echo '/'.$airline_icao;
867
+}
868
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
810 869
                 </div>
811 870
             </div>
812 871
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -826,8 +885,9 @@  discard block
 block discarded – undo
826 885
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
827 886
 <?php
828 887
 		$year_array = $Marine->countAllMonthsLastYear(true,$airline_icao,$filter_name);
829
-		if (count($year_array) == 0) print _("No data available");
830
-		else {
888
+		if (count($year_array) == 0) {
889
+			print _("No data available");
890
+		} else {
831 891
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
832 892
 			$year_data = '';
833 893
 			$year_cnt = '';
@@ -855,8 +915,9 @@  discard block
 block discarded – undo
855 915
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
856 916
 <?php
857 917
 		$month_array = $Marine->countAllDatesLastMonth($airline_icao,$filter_name);
858
-		if (count($month_array) == 0) print _("No data available");
859
-		else {
918
+		if (count($month_array) == 0) {
919
+			print _("No data available");
920
+		} else {
860 921
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
861 922
 			$month_data = '';
862 923
 			$month_cnt = '';
@@ -884,8 +945,9 @@  discard block
 block discarded – undo
884 945
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
885 946
 <?php
886 947
 		$date_array = $Marine->countAllDatesLast7Days($airline_icao,$filter_name);
887
-		if (empty($date_array)) print _("No data available");
888
-		else {
948
+		if (empty($date_array)) {
949
+			print _("No data available");
950
+		} else {
889 951
 			print '<div id="chart5" class="chart" width="100%"></div><script>';
890 952
 			$date_data = '';
891 953
 			$date_cnt = '';
@@ -912,8 +974,9 @@  discard block
 block discarded – undo
912 974
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
913 975
 <?php
914 976
 		$hour_array = $Marine->countAllHours('hour',true,$airline_icao,$filter_name);
915
-		if (empty($hour_array)) print _("No data available");
916
-		else {
977
+		if (empty($hour_array)) {
978
+			print _("No data available");
979
+		} else {
917 980
 			print '<div id="chart6" class="chart" width="100%"></div><script>';
918 981
 			$hour_data = '';
919 982
 			$hour_cnt = '';
@@ -952,8 +1015,9 @@  discard block
 block discarded – undo
952 1015
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
953 1016
 <?php
954 1017
 		$year_array = $Tracker->countAllMonthsLastYear(true);
955
-		if (count($year_array) == 0) print _("No data available");
956
-		else {
1018
+		if (count($year_array) == 0) {
1019
+			print _("No data available");
1020
+		} else {
957 1021
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
958 1022
 			$year_data = '';
959 1023
 			$year_cnt = '';
@@ -981,8 +1045,9 @@  discard block
 block discarded – undo
981 1045
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
982 1046
 <?php
983 1047
 		$month_array = $Tracker->countAllDatesLastMonth();
984
-		if (count($month_array) == 0) print _("No data available");
985
-		else {
1048
+		if (count($month_array) == 0) {
1049
+			print _("No data available");
1050
+		} else {
986 1051
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
987 1052
 			$month_data = '';
988 1053
 			$month_cnt = '';
@@ -1010,8 +1075,9 @@  discard block
 block discarded – undo
1010 1075
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
1011 1076
 <?php
1012 1077
 		$date_array = $Tracker->countAllDatesLast7Days();
1013
-		if (empty($date_array)) print _("No data available");
1014
-		else {
1078
+		if (empty($date_array)) {
1079
+			print _("No data available");
1080
+		} else {
1015 1081
 			print '<div id="chart5" class="chart" width="100%"></div><script>';
1016 1082
 			$date_data = '';
1017 1083
 			$date_cnt = '';
@@ -1038,8 +1104,9 @@  discard block
 block discarded – undo
1038 1104
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
1039 1105
 <?php
1040 1106
 		$hour_array = $Tracker->countAllHours('hour',true);
1041
-		if (empty($hour_array)) print _("No data available");
1042
-		else {
1107
+		if (empty($hour_array)) {
1108
+			print _("No data available");
1109
+		} else {
1043 1110
 			print '<div id="chart6" class="chart" width="100%"></div><script>';
1044 1111
 			$hour_data = '';
1045 1112
 			$hour_cnt = '';
@@ -1078,8 +1145,9 @@  discard block
 block discarded – undo
1078 1145
                 <h2><?php echo _("Fatalities by Years"); ?></h2>
1079 1146
 <?php
1080 1147
 		$year_array = $Stats->countFatalitiesByYear();
1081
-		if (count($year_array) == 0) print _("No data available");
1082
-		else {
1148
+		if (count($year_array) == 0) {
1149
+			print _("No data available");
1150
+		} else {
1083 1151
 			print '<div id="chart32" class="chart" width="100%"></div><script>';
1084 1152
 			$year_data = '';
1085 1153
 			$year_cnt = '';
@@ -1108,8 +1176,9 @@  discard block
 block discarded – undo
1108 1176
                 <h2><?php echo _("Fatalities last 12 Months"); ?></h2>
1109 1177
 <?php
1110 1178
 		$year_array = $Stats->countFatalitiesLast12Months();
1111
-		if (count($year_array) == 0) print _("No data available");
1112
-		else {
1179
+		if (count($year_array) == 0) {
1180
+			print _("No data available");
1181
+		} else {
1113 1182
 			print '<div id="chart33" class="chart" width="100%"></div><script>';
1114 1183
 			$year_data = '';
1115 1184
 			$year_cnt = '';
@@ -1180,8 +1249,11 @@  discard block
 block discarded – undo
1180 1249
 					$distance = $distance;
1181 1250
 					$unit = 'km';
1182 1251
 				}
1183
-				if (!isset($polar_data)) $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1184
-				else $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1252
+				if (!isset($polar_data)) {
1253
+					$polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1254
+				} else {
1255
+					$polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1256
+				}
1185 1257
 			}
1186 1258
 ?>
1187 1259
             <div class="col-md-6">
@@ -1245,9 +1317,12 @@  discard block
 block discarded – undo
1245 1317
 		foreach ($msg as $eachmsg) {
1246 1318
 			//$eachmsg = $msg[0];
1247 1319
 			$data = $eachmsg['source_data'];
1248
-			if ($data > 500) $max = (round(($data+100)/100))*100;
1249
-			else $max = 500;
1250
-?>
1320
+			if ($data > 500) {
1321
+				$max = (round(($data+100)/100))*100;
1322
+			} else {
1323
+				$max = 500;
1324
+			}
1325
+			?>
1251 1326
         	<div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
1252 1327
         	<script>
1253 1328
 		      var g = new JustGage({
Please login to merge, or discard this patch.