Completed
Push — master ( 5e27ff...ea1d88 )
by Yannick
06:20
created
install/class.update_db.php 1 patch
Braces   +849 added lines, -294 removed lines patch added patch discarded remove patch
@@ -16,7 +16,9 @@  discard block
 block discarded – undo
16 16
 		curl_setopt($ch, CURLOPT_URL, $url);
17 17
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
18 18
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
19
-		if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer);
19
+		if ($referer != '') {
20
+			curl_setopt($ch, CURLOPT_REFERER, $referer);
21
+		}
20 22
 		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5');
21 23
 		curl_setopt($ch, CURLOPT_FILE, $fp);
22 24
 		curl_exec($ch);
@@ -27,12 +29,16 @@  discard block
 block discarded – undo
27 29
 	public static function gunzip($in_file,$out_file_name = '') {
28 30
 		//echo $in_file.' -> '.$out_file_name."\n";
29 31
 		$buffer_size = 4096; // read 4kb at a time
30
-		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
32
+		if ($out_file_name == '') {
33
+			$out_file_name = str_replace('.gz', '', $in_file);
34
+		}
31 35
 		if ($in_file != '' && file_exists($in_file)) {
32 36
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
33
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
34
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
35
-			else {
37
+			if (function_exists('gzopen')) {
38
+				$file = gzopen($in_file,'rb');
39
+			} elseif (function_exists('gzopen64')) {
40
+				$file = gzopen64($in_file,'rb');
41
+			} else {
36 42
 				echo 'gzopen not available';
37 43
 				die;
38 44
 			}
@@ -53,8 +59,12 @@  discard block
 block discarded – undo
53 59
 			if ($res === TRUE) {
54 60
 				$zip->extractTo($path);
55 61
 				$zip->close();
56
-			} else return false;
57
-		} else return false;
62
+			} else {
63
+				return false;
64
+			}
65
+		} else {
66
+			return false;
67
+		}
58 68
 	}
59 69
 	
60 70
 	public static function connect_sqlite($database) {
@@ -69,7 +79,9 @@  discard block
 block discarded – undo
69 79
 	public static function retrieve_route_sqlite_to_dest($database_file) {
70 80
 		global $globalDebug, $globalTransaction;
71 81
 		//$query = 'TRUNCATE TABLE routes';
72
-		if ($globalDebug) echo " - Delete previous routes from DB -";
82
+		if ($globalDebug) {
83
+			echo " - Delete previous routes from DB -";
84
+		}
73 85
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
74 86
 		$Connection = new Connection();
75 87
 		try {
@@ -80,7 +92,9 @@  discard block
 block discarded – undo
80 92
                         return "error : ".$e->getMessage();
81 93
                 }
82 94
 
83
-    		if ($globalDebug) echo " - Add routes to DB -";
95
+    		if ($globalDebug) {
96
+    			echo " - Add routes to DB -";
97
+    		}
84 98
     		update_db::connect_sqlite($database_file);
85 99
 		//$query = 'select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID';
86 100
 		$query = "select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao, rstp.allstop AS AllStop from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID LEFT JOIN (select RouteId,GROUP_CONCAT(icao,' ') as allstop from routestop left join Airport as air ON routestop.AirportId = air.AirportID group by RouteID) AS rstp ON Route.RouteID = rstp.RouteID";
@@ -95,15 +109,21 @@  discard block
 block discarded – undo
95 109
 		$Connection = new Connection();
96 110
 		$sth_dest = $Connection->db->prepare($query_dest);
97 111
 		try {
98
-			if ($globalTransaction) $Connection->db->beginTransaction();
112
+			if ($globalTransaction) {
113
+				$Connection->db->beginTransaction();
114
+			}
99 115
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
100 116
 				//$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
101 117
 				$query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
102 118
 				$sth_dest->execute($query_dest_values);
103 119
             		}
104
-			if ($globalTransaction) $Connection->db->commit();
120
+			if ($globalTransaction) {
121
+				$Connection->db->commit();
122
+			}
105 123
 		} catch(PDOException $e) {
106
-			if ($globalTransaction) $Connection->db->rollBack(); 
124
+			if ($globalTransaction) {
125
+				$Connection->db->rollBack();
126
+			}
107 127
 			return "error : ".$e->getMessage();
108 128
 		}
109 129
                 return '';
@@ -111,7 +131,9 @@  discard block
 block discarded – undo
111 131
 	public static function retrieve_route_oneworld($database_file) {
112 132
 		global $globalDebug, $globalTransaction;
113 133
 		//$query = 'TRUNCATE TABLE routes';
114
-		if ($globalDebug) echo " - Delete previous routes from DB -";
134
+		if ($globalDebug) {
135
+			echo " - Delete previous routes from DB -";
136
+		}
115 137
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
116 138
 		$Connection = new Connection();
117 139
 		try {
@@ -122,14 +144,18 @@  discard block
 block discarded – undo
122 144
                         return "error : ".$e->getMessage();
123 145
                 }
124 146
 
125
-    		if ($globalDebug) echo " - Add routes to DB -";
147
+    		if ($globalDebug) {
148
+    			echo " - Add routes to DB -";
149
+    		}
126 150
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
127 151
 		$Spotter = new Spotter();
128 152
 		if ($fh = fopen($database_file,"r")) {
129 153
 			$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)';
130 154
 			$Connection = new Connection();
131 155
 			$sth_dest = $Connection->db->prepare($query_dest);
132
-			if ($globalTransaction) $Connection->db->beginTransaction();
156
+			if ($globalTransaction) {
157
+				$Connection->db->beginTransaction();
158
+			}
133 159
 			while (!feof($fh)) {
134 160
 				$line = fgetcsv($fh,9999,',');
135 161
 				if ($line[0] != '') {
@@ -138,13 +164,17 @@  discard block
 block discarded – undo
138 164
 							$query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld');
139 165
 							$sth_dest->execute($query_dest_values);
140 166
 						} catch(PDOException $e) {
141
-							if ($globalTransaction) $Connection->db->rollBack(); 
167
+							if ($globalTransaction) {
168
+								$Connection->db->rollBack();
169
+							}
142 170
 							return "error : ".$e->getMessage();
143 171
 						}
144 172
 					}
145 173
 				}
146 174
 			}
147
-			if ($globalTransaction) $Connection->db->commit();
175
+			if ($globalTransaction) {
176
+				$Connection->db->commit();
177
+			}
148 178
 		}
149 179
                 return '';
150 180
 	}
@@ -152,7 +182,9 @@  discard block
 block discarded – undo
152 182
 	public static function retrieve_route_skyteam($database_file) {
153 183
 		global $globalDebug, $globalTransaction;
154 184
 		//$query = 'TRUNCATE TABLE routes';
155
-		if ($globalDebug) echo " - Delete previous routes from DB -";
185
+		if ($globalDebug) {
186
+			echo " - Delete previous routes from DB -";
187
+		}
156 188
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
157 189
 		$Connection = new Connection();
158 190
 		try {
@@ -163,7 +195,9 @@  discard block
 block discarded – undo
163 195
                         return "error : ".$e->getMessage();
164 196
                 }
165 197
 
166
-    		if ($globalDebug) echo " - Add routes to DB -";
198
+    		if ($globalDebug) {
199
+    			echo " - Add routes to DB -";
200
+    		}
167 201
 
168 202
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
169 203
 		$Spotter = new Spotter();
@@ -172,7 +206,9 @@  discard block
 block discarded – undo
172 206
 			$Connection = new Connection();
173 207
 			$sth_dest = $Connection->db->prepare($query_dest);
174 208
 			try {
175
-				if ($globalTransaction) $Connection->db->beginTransaction();
209
+				if ($globalTransaction) {
210
+					$Connection->db->beginTransaction();
211
+				}
176 212
 				while (!feof($fh)) {
177 213
 					$line = fgetcsv($fh,9999,',');
178 214
 					if ($line[0] != '') {
@@ -183,9 +219,13 @@  discard block
 block discarded – undo
183 219
 						}
184 220
 					}
185 221
 				}
186
-				if ($globalTransaction) $Connection->db->commit();
222
+				if ($globalTransaction) {
223
+					$Connection->db->commit();
224
+				}
187 225
 			} catch(PDOException $e) {
188
-				if ($globalTransaction) $Connection->db->rollBack(); 
226
+				if ($globalTransaction) {
227
+					$Connection->db->rollBack();
228
+				}
189 229
 				return "error : ".$e->getMessage();
190 230
 			}
191 231
 		}
@@ -228,11 +268,16 @@  discard block
 block discarded – undo
228 268
 		$sth_dest = $Connection->db->prepare($query_dest);
229 269
 		$sth_dest_owner = $Connection->db->prepare($query_dest_owner);
230 270
 		try {
231
-			if ($globalTransaction) $Connection->db->beginTransaction();
271
+			if ($globalTransaction) {
272
+				$Connection->db->beginTransaction();
273
+			}
232 274
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
233 275
 			//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
234
-				if ($values['UserString4'] == 'M') $type = 'military';
235
-				else $type = null;
276
+				if ($values['UserString4'] == 'M') {
277
+					$type = 'military';
278
+				} else {
279
+					$type = null;
280
+				}
236 281
 				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
237 282
 				$sth_dest->execute($query_dest_values);
238 283
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
@@ -240,7 +285,9 @@  discard block
 block discarded – undo
240 285
 				    $sth_dest_owner->execute($query_dest_owner_values);
241 286
 				}
242 287
             		}
243
-			if ($globalTransaction) $Connection->db->commit();
288
+			if ($globalTransaction) {
289
+				$Connection->db->commit();
290
+			}
244 291
 		} catch(PDOException $e) {
245 292
 			return "error : ".$e->getMessage();
246 293
 		}
@@ -277,7 +324,9 @@  discard block
 block discarded – undo
277 324
 			$Connection = new Connection();
278 325
 			$sth_dest = $Connection->db->prepare($query_dest);
279 326
 			try {
280
-				if ($globalTransaction) $Connection->db->beginTransaction();
327
+				if ($globalTransaction) {
328
+					$Connection->db->beginTransaction();
329
+				}
281 330
             			while (!feof($fh)) {
282 331
             				$values = array();
283 332
             				$line = $Common->hex2str(fgets($fh,9999));
@@ -288,7 +337,9 @@  discard block
 block discarded – undo
288 337
             				// Check if we can find ICAO, else set it to GLID
289 338
             				$aircraft_name_split = explode(' ',$aircraft_name);
290 339
             				$search_more = '';
291
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
340
+            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) {
341
+            					$search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
342
+            				}
292 343
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
293 344
             				$sth_search = $Connection->db->prepare($query_search);
294 345
 					try {
@@ -301,7 +352,9 @@  discard block
 block discarded – undo
301 352
 					} catch(PDOException $e) {
302 353
 						return "error : ".$e->getMessage();
303 354
 					}
304
-					if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
355
+					if (!isset($values['ICAOTypeCode'])) {
356
+						$values['ICAOTypeCode'] = 'GLID';
357
+					}
305 358
 					// Add data to db
306 359
 					if ($values['Registration'] != '' && $values['Registration'] != '0000') {
307 360
 						//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
@@ -310,7 +363,9 @@  discard block
 block discarded – undo
310 363
 						$sth_dest->execute($query_dest_values);
311 364
 					}
312 365
 				}
313
-				if ($globalTransaction) $Connection->db->commit();
366
+				if ($globalTransaction) {
367
+					$Connection->db->commit();
368
+				}
314 369
 			} catch(PDOException $e) {
315 370
 				return "error : ".$e->getMessage();
316 371
 			}
@@ -346,7 +401,9 @@  discard block
 block discarded – undo
346 401
 			$Connection = new Connection();
347 402
 			$sth_dest = $Connection->db->prepare($query_dest);
348 403
 			try {
349
-				if ($globalTransaction) $Connection->db->beginTransaction();
404
+				if ($globalTransaction) {
405
+					$Connection->db->beginTransaction();
406
+				}
350 407
 				$tmp = fgetcsv($fh,9999,',',"'");
351 408
             			while (!feof($fh)) {
352 409
             				$line = fgetcsv($fh,9999,',',"'");
@@ -359,13 +416,17 @@  discard block
 block discarded – undo
359 416
             				// Check if we can find ICAO, else set it to GLID
360 417
             				$aircraft_name_split = explode(' ',$aircraft_name);
361 418
             				$search_more = '';
362
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
419
+            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) {
420
+            					$search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
421
+            				}
363 422
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
364 423
             				$sth_search = $Connection->db->prepare($query_search);
365 424
 					try {
366 425
                                     		$sth_search->execute();
367 426
 	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
368
-	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
427
+	            				if (isset($result['icao']) && $result['icao'] != '') {
428
+	            					$values['ICAOTypeCode'] = $result['icao'];
429
+	            				}
369 430
 					} catch(PDOException $e) {
370 431
 						return "error : ".$e->getMessage();
371 432
 					}
@@ -378,7 +439,9 @@  discard block
 block discarded – undo
378 439
 						$sth_dest->execute($query_dest_values);
379 440
 					}
380 441
 				}
381
-				if ($globalTransaction) $Connection->db->commit();
442
+				if ($globalTransaction) {
443
+					$Connection->db->commit();
444
+				}
382 445
 			} catch(PDOException $e) {
383 446
 				return "error : ".$e->getMessage();
384 447
 			}
@@ -414,7 +477,9 @@  discard block
 block discarded – undo
414 477
 			$Connection = new Connection();
415 478
 			$sth_dest = $Connection->db->prepare($query_dest);
416 479
 			try {
417
-				if ($globalTransaction) $Connection->db->beginTransaction();
480
+				if ($globalTransaction) {
481
+					$Connection->db->beginTransaction();
482
+				}
418 483
 				$tmp = fgetcsv($fh,9999,',','"');
419 484
             			while (!feof($fh)) {
420 485
             				$line = fgetcsv($fh,9999,',','"');
@@ -424,16 +489,22 @@  discard block
 block discarded – undo
424 489
             				    $values['registration'] = $line[0];
425 490
             				    $values['base'] = $line[4];
426 491
             				    $values['owner'] = $line[5];
427
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
428
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
492
+            				    if ($line[6] == '') {
493
+            				    	$values['date_first_reg'] = null;
494
+            				    } else {
495
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
496
+					    }
429 497
 					    $values['cancel'] = $line[7];
430 498
 					} elseif ($country == 'EI') {
431 499
 					    // TODO : add modeS & reg to aircraft_modes
432 500
             				    $values['registration'] = $line[0];
433 501
             				    $values['base'] = $line[3];
434 502
             				    $values['owner'] = $line[2];
435
-            				    if ($line[1] == '') $values['date_first_reg'] = null;
436
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
503
+            				    if ($line[1] == '') {
504
+            				    	$values['date_first_reg'] = null;
505
+            				    } else {
506
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
507
+					    }
437 508
 					    $values['cancel'] = '';
438 509
 					} elseif ($country == 'HB') {
439 510
 					    // TODO : add modeS & reg to aircraft_modes
@@ -447,16 +518,22 @@  discard block
 block discarded – undo
447 518
             				    $values['registration'] = $line[3];
448 519
             				    $values['base'] = null;
449 520
             				    $values['owner'] = $line[5];
450
-            				    if ($line[18] == '') $values['date_first_reg'] = null;
451
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
521
+            				    if ($line[18] == '') {
522
+            				    	$values['date_first_reg'] = null;
523
+            				    } else {
524
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
525
+					    }
452 526
 					    $values['cancel'] = '';
453 527
 					} elseif ($country == 'VH') {
454 528
 					    // TODO : add modeS & reg to aircraft_modes
455 529
             				    $values['registration'] = $line[0];
456 530
             				    $values['base'] = null;
457 531
             				    $values['owner'] = $line[12];
458
-            				    if ($line[28] == '') $values['date_first_reg'] = null;
459
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
532
+            				    if ($line[28] == '') {
533
+            				    	$values['date_first_reg'] = null;
534
+            				    } else {
535
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
536
+					    }
460 537
 
461 538
 					    $values['cancel'] = $line[39];
462 539
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
@@ -475,29 +552,41 @@  discard block
 block discarded – undo
475 552
             				    $values['registration'] = $line[0];
476 553
             				    $values['base'] = null;
477 554
             				    $values['owner'] = $line[8];
478
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
479
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
555
+            				    if ($line[7] == '') {
556
+            				    	$values['date_first_reg'] = null;
557
+            				    } else {
558
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
559
+					    }
480 560
 					    $values['cancel'] = '';
481 561
 					} elseif ($country == 'PP') {
482 562
             				    $values['registration'] = $line[0];
483 563
             				    $values['base'] = null;
484 564
             				    $values['owner'] = $line[4];
485
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
486
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
565
+            				    if ($line[6] == '') {
566
+            				    	$values['date_first_reg'] = null;
567
+            				    } else {
568
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
569
+					    }
487 570
 					    $values['cancel'] = $line[7];
488 571
 					} elseif ($country == 'E7') {
489 572
             				    $values['registration'] = $line[0];
490 573
             				    $values['base'] = null;
491 574
             				    $values['owner'] = $line[4];
492
-            				    if ($line[5] == '') $values['date_first_reg'] = null;
493
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
575
+            				    if ($line[5] == '') {
576
+            				    	$values['date_first_reg'] = null;
577
+            				    } else {
578
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
579
+					    }
494 580
 					    $values['cancel'] = '';
495 581
 					} elseif ($country == '8Q') {
496 582
             				    $values['registration'] = $line[0];
497 583
             				    $values['base'] = null;
498 584
             				    $values['owner'] = $line[3];
499
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
500
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
585
+            				    if ($line[7] == '') {
586
+            				    	$values['date_first_reg'] = null;
587
+            				    } else {
588
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
589
+					    }
501 590
 					    $values['cancel'] = '';
502 591
 					} elseif ($country == 'ZK' || $country == 'OM' || $country == 'TF') {
503 592
             				    $values['registration'] = $line[0];
@@ -511,7 +600,9 @@  discard block
 block discarded – undo
511 600
 						$sth_dest->execute($query_dest_values);
512 601
 					}
513 602
 				}
514
-				if ($globalTransaction) $Connection->db->commit();
603
+				if ($globalTransaction) {
604
+					$Connection->db->commit();
605
+				}
515 606
 			} catch(PDOException $e) {
516 607
 				return "error : ".$e->getMessage();
517 608
 			}
@@ -645,25 +736,45 @@  discard block
 block discarded – undo
645 736
 		    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)";
646 737
 		$Connection = new Connection();
647 738
 		$sth_dest = $Connection->db->prepare($query_dest);
648
-		if ($globalTransaction) $Connection->db->beginTransaction();
739
+		if ($globalTransaction) {
740
+			$Connection->db->beginTransaction();
741
+		}
649 742
   
650 743
 		$i = 0;
651 744
 		while($row = sparql_fetch_array($result))
652 745
 		{
653 746
 			if ($i >= 1) {
654 747
 			//print_r($row);
655
-			if (!isset($row['iata'])) $row['iata'] = '';
656
-			if (!isset($row['icao'])) $row['icao'] = '';
657
-			if (!isset($row['type'])) $row['type'] = '';
658
-			if (!isset($row['altitude'])) $row['altitude'] = '';
748
+			if (!isset($row['iata'])) {
749
+				$row['iata'] = '';
750
+			}
751
+			if (!isset($row['icao'])) {
752
+				$row['icao'] = '';
753
+			}
754
+			if (!isset($row['type'])) {
755
+				$row['type'] = '';
756
+			}
757
+			if (!isset($row['altitude'])) {
758
+				$row['altitude'] = '';
759
+			}
659 760
 			if (isset($row['city_bis'])) {
660 761
 				$row['city'] = $row['city_bis'];
661 762
 			}
662
-			if (!isset($row['city'])) $row['city'] = '';
663
-			if (!isset($row['country'])) $row['country'] = '';
664
-			if (!isset($row['homepage'])) $row['homepage'] = '';
665
-			if (!isset($row['wikipedia_page'])) $row['wikipedia_page'] = '';
666
-			if (!isset($row['name'])) continue;
763
+			if (!isset($row['city'])) {
764
+				$row['city'] = '';
765
+			}
766
+			if (!isset($row['country'])) {
767
+				$row['country'] = '';
768
+			}
769
+			if (!isset($row['homepage'])) {
770
+				$row['homepage'] = '';
771
+			}
772
+			if (!isset($row['wikipedia_page'])) {
773
+				$row['wikipedia_page'] = '';
774
+			}
775
+			if (!isset($row['name'])) {
776
+				continue;
777
+			}
667 778
 			if (!isset($row['image'])) {
668 779
 				$row['image'] = '';
669 780
 				$row['image_thumb'] = '';
@@ -699,7 +810,9 @@  discard block
 block discarded – undo
699 810
 
700 811
 			$i++;
701 812
 		}
702
-		if ($globalTransaction) $Connection->db->commit();
813
+		if ($globalTransaction) {
814
+			$Connection->db->commit();
815
+		}
703 816
 		echo "Delete duplicate rows...\n";
704 817
 		$query = 'ALTER IGNORE TABLE airport ADD UNIQUE INDEX icaoidx (icao)';
705 818
 		try {
@@ -711,7 +824,9 @@  discard block
 block discarded – undo
711 824
                 }
712 825
 
713 826
 
714
-		if ($globalDebug) echo "Insert Not available Airport...\n";
827
+		if ($globalDebug) {
828
+			echo "Insert Not available Airport...\n";
829
+		}
715 830
 		$query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image`,`image_thumb`)
716 831
 		    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image, :image_thumb)";
717 832
 		$query_values = array(':airport_id' => $i, ':name' => 'Not available',':iata' => 'NA',':icao' => 'NA',':latitude' => '0',':longitude' => '0',':altitude' => '0',':type' => 'NA',':city' => 'N/A',':country' => 'N/A',':home_link' => '',':wikipedia_link' => '',':image' => '',':image_thumb' => '');
@@ -738,7 +853,9 @@  discard block
 block discarded – undo
738 853
 		$delimiter = ',';
739 854
 		$out_file = $tmp_dir.'airports.csv';
740 855
 		update_db::download('http://ourairports.com/data/airports.csv',$out_file);
741
-		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
856
+		if (!file_exists($out_file) || !is_readable($out_file)) {
857
+			return FALSE;
858
+		}
742 859
 		echo "Add data from ourairports.com...\n";
743 860
 
744 861
 		$header = NULL;
@@ -748,8 +865,9 @@  discard block
 block discarded – undo
748 865
 			//$Connection->db->beginTransaction();
749 866
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
750 867
 			{
751
-				if(!$header) $header = $row;
752
-				else {
868
+				if(!$header) {
869
+					$header = $row;
870
+				} else {
753 871
 					$data = array();
754 872
 					$data = array_combine($header, $row);
755 873
 					try {
@@ -787,7 +905,9 @@  discard block
 block discarded – undo
787 905
 		echo "Download data from another free database...\n";
788 906
 		$out_file = $tmp_dir.'GlobalAirportDatabase.zip';
789 907
 		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file);
790
-		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
908
+		if (!file_exists($out_file) || !is_readable($out_file)) {
909
+			return FALSE;
910
+		}
791 911
 		update_db::unzip($out_file);
792 912
 		$header = NULL;
793 913
 		echo "Add data from another free database...\n";
@@ -798,8 +918,9 @@  discard block
 block discarded – undo
798 918
 			//$Connection->db->beginTransaction();
799 919
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
800 920
 			{
801
-				if(!$header) $header = $row;
802
-				else {
921
+				if(!$header) {
922
+					$header = $row;
923
+				} else {
803 924
 					$data = $row;
804 925
 
805 926
 					$query = 'UPDATE airport SET `city` = :city, `country` = :country WHERE icao = :icao';
@@ -975,7 +1096,9 @@  discard block
 block discarded – undo
975 1096
 		if (($handle = fopen($tmp_dir.'MASTER.txt', 'r')) !== FALSE)
976 1097
 		{
977 1098
 			$i = 0;
978
-			if ($globalTransaction) $Connection->db->beginTransaction();
1099
+			if ($globalTransaction) {
1100
+				$Connection->db->beginTransaction();
1101
+			}
979 1102
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
980 1103
 			{
981 1104
 				if ($i > 0) {
@@ -988,7 +1111,9 @@  discard block
 block discarded – undo
988 1111
 					}
989 1112
 					$result_search = $sths->fetchAll(PDO::FETCH_ASSOC);
990 1113
 					if (!empty($result_search)) {
991
-						if ($globalDebug) echo '.';
1114
+						if ($globalDebug) {
1115
+							echo '.';
1116
+						}
992 1117
 							//if ($globalDBdriver == 'mysql') {
993 1118
 							//	$queryi = 'INSERT INTO faamfr (mfr,icao) VALUES (:mfr,:icao) ON DUPLICATE KEY UPDATE icao = :icao';
994 1119
 							//} else {
@@ -1010,8 +1135,12 @@  discard block
 block discarded – undo
1010 1135
 						}
1011 1136
 						$result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC);
1012 1137
 						if (!empty($result_search_mfr)) {
1013
-							if (trim($data[16]) == '' && trim($data[23]) != '') $data[16] = $data[23];
1014
-							if (trim($data[16]) == '' && trim($data[15]) != '') $data[16] = $data[15];
1138
+							if (trim($data[16]) == '' && trim($data[23]) != '') {
1139
+								$data[16] = $data[23];
1140
+							}
1141
+							if (trim($data[16]) == '' && trim($data[15]) != '') {
1142
+								$data[16] = $data[15];
1143
+							}
1015 1144
 							$queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)';
1016 1145
 							try {
1017 1146
 								$sthf = $Connection->db->prepare($queryf);
@@ -1022,7 +1151,9 @@  discard block
 block discarded – undo
1022 1151
 						}
1023 1152
 					}
1024 1153
 					if (strtotime($data[29]) > time()) {
1025
-						if ($globalDebug) echo 'i';
1154
+						if ($globalDebug) {
1155
+							echo 'i';
1156
+						}
1026 1157
 						$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
1027 1158
 						try {
1028 1159
 							$sth = $Connection->db->prepare($query);
@@ -1033,13 +1164,19 @@  discard block
 block discarded – undo
1033 1164
 					}
1034 1165
 				}
1035 1166
 				if ($i % 90 == 0) {
1036
-					if ($globalTransaction) $Connection->db->commit();
1037
-					if ($globalTransaction) $Connection->db->beginTransaction();
1167
+					if ($globalTransaction) {
1168
+						$Connection->db->commit();
1169
+					}
1170
+					if ($globalTransaction) {
1171
+						$Connection->db->beginTransaction();
1172
+					}
1038 1173
 				}
1039 1174
 				$i++;
1040 1175
 			}
1041 1176
 			fclose($handle);
1042
-			if ($globalTransaction) $Connection->db->commit();
1177
+			if ($globalTransaction) {
1178
+				$Connection->db->commit();
1179
+			}
1043 1180
 		}
1044 1181
 		print_r($mfr);
1045 1182
 		return '';
@@ -1064,11 +1201,15 @@  discard block
 block discarded – undo
1064 1201
 			$i = 0;
1065 1202
 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
1066 1203
 			//$Connection->db->beginTransaction();
1067
-			if ($globalTransaction) $Connection->db->beginTransaction();
1204
+			if ($globalTransaction) {
1205
+				$Connection->db->beginTransaction();
1206
+			}
1068 1207
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1069 1208
 			{
1070 1209
 				if ($i > 0) {
1071
-					if ($data[1] == 'NULL') $data[1] = $data[0];
1210
+					if ($data[1] == 'NULL') {
1211
+						$data[1] = $data[0];
1212
+					}
1072 1213
 					$query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)';
1073 1214
 					try {
1074 1215
 						$sth = $Connection->db->prepare($query);
@@ -1080,7 +1221,9 @@  discard block
 block discarded – undo
1080 1221
 				$i++;
1081 1222
 			}
1082 1223
 			fclose($handle);
1083
-			if ($globalTransaction) $Connection->db->commit();
1224
+			if ($globalTransaction) {
1225
+				$Connection->db->commit();
1226
+			}
1084 1227
 		}
1085 1228
 		return '';
1086 1229
         }
@@ -1101,7 +1244,9 @@  discard block
 block discarded – undo
1101 1244
 		if (($handle = fopen($tmp_dir.'owners.tsv', 'r')) !== FALSE)
1102 1245
 		{
1103 1246
 			$i = 0;
1104
-			if ($globalTransaction) $Connection->db->beginTransaction();
1247
+			if ($globalTransaction) {
1248
+				$Connection->db->beginTransaction();
1249
+			}
1105 1250
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1106 1251
 			{
1107 1252
 				if ($i > 0) {
@@ -1117,7 +1262,9 @@  discard block
 block discarded – undo
1117 1262
 				$i++;
1118 1263
 			}
1119 1264
 			fclose($handle);
1120
-			if ($globalTransaction) $Connection->db->commit();
1265
+			if ($globalTransaction) {
1266
+				$Connection->db->commit();
1267
+			}
1121 1268
 		}
1122 1269
 		return '';
1123 1270
         }
@@ -1142,7 +1289,9 @@  discard block
 block discarded – undo
1142 1289
 			$i = 0;
1143 1290
 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
1144 1291
 			//$Connection->db->beginTransaction();
1145
-			if ($globalTransaction) $Connection->db->beginTransaction();
1292
+			if ($globalTransaction) {
1293
+				$Connection->db->beginTransaction();
1294
+			}
1146 1295
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1147 1296
 			{
1148 1297
 				if ($i > 0) {
@@ -1157,7 +1306,9 @@  discard block
 block discarded – undo
1157 1306
 				$i++;
1158 1307
 			}
1159 1308
 			fclose($handle);
1160
-			if ($globalTransaction) $Connection->db->commit();
1309
+			if ($globalTransaction) {
1310
+				$Connection->db->commit();
1311
+			}
1161 1312
 		}
1162 1313
 		return '';
1163 1314
         }
@@ -1176,7 +1327,9 @@  discard block
 block discarded – undo
1176 1327
 		$Connection = new Connection();
1177 1328
 		if (($handle = fopen($tmp_dir.'ban_eu.csv', 'r')) !== FALSE)
1178 1329
 		{
1179
-			if ($globalTransaction) $Connection->db->beginTransaction();
1330
+			if ($globalTransaction) {
1331
+				$Connection->db->beginTransaction();
1332
+			}
1180 1333
 			while (($data = fgetcsv($handle, 1000)) !== FALSE)
1181 1334
 			{
1182 1335
 				$query = 'UPDATE airlines SET ban_eu = 1 WHERE icao = :icao AND forsource IS NULL';
@@ -1191,7 +1344,9 @@  discard block
 block discarded – undo
1191 1344
 				}
1192 1345
 			}
1193 1346
 			fclose($handle);
1194
-			if ($globalTransaction) $Connection->db->commit();
1347
+			if ($globalTransaction) {
1348
+				$Connection->db->commit();
1349
+			}
1195 1350
 		}
1196 1351
 		return '';
1197 1352
         }
@@ -1342,7 +1497,9 @@  discard block
 block discarded – undo
1342 1497
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1343 1498
 		{
1344 1499
 			$i = 0;
1345
-			if ($globalTransaction) $Connection->db->beginTransaction();
1500
+			if ($globalTransaction) {
1501
+				$Connection->db->beginTransaction();
1502
+			}
1346 1503
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1347 1504
 			{
1348 1505
 				$i++;
@@ -1370,7 +1527,9 @@  discard block
 block discarded – undo
1370 1527
 				}
1371 1528
 			}
1372 1529
 			fclose($handle);
1373
-			if ($globalTransaction) $Connection->db->commit();
1530
+			if ($globalTransaction) {
1531
+				$Connection->db->commit();
1532
+			}
1374 1533
 		}
1375 1534
 		return '';
1376 1535
         }
@@ -1393,7 +1552,9 @@  discard block
 block discarded – undo
1393 1552
 		$Connection = new Connection();
1394 1553
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1395 1554
 		{
1396
-			if ($globalTransaction) $Connection->db->beginTransaction();
1555
+			if ($globalTransaction) {
1556
+				$Connection->db->beginTransaction();
1557
+			}
1397 1558
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1398 1559
 			{
1399 1560
 				if(count($row) > 1) {
@@ -1407,7 +1568,9 @@  discard block
 block discarded – undo
1407 1568
 				}
1408 1569
 			}
1409 1570
 			fclose($handle);
1410
-			if ($globalTransaction) $Connection->db->commit();
1571
+			if ($globalTransaction) {
1572
+				$Connection->db->commit();
1573
+			}
1411 1574
 		}
1412 1575
 		return '';
1413 1576
         }
@@ -1427,8 +1590,9 @@  discard block
 block discarded – undo
1427 1590
 	        }
1428 1591
 
1429 1592
 
1430
-		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1431
-		else {
1593
+		if ($globalDBdriver == 'mysql') {
1594
+			update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1595
+		} else {
1432 1596
 			update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql');
1433 1597
 			$query = "CREATE EXTENSION postgis";
1434 1598
 			$Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']);
@@ -1447,20 +1611,30 @@  discard block
 block discarded – undo
1447 1611
 		global $tmp_dir, $globalDebug;
1448 1612
 		include_once('class.create_db.php');
1449 1613
 		require_once(dirname(__FILE__).'/../require/class.NOTAM.php');
1450
-		if ($globalDebug) echo "NOTAM from FlightAirMap website : Download...";
1614
+		if ($globalDebug) {
1615
+			echo "NOTAM from FlightAirMap website : Download...";
1616
+		}
1451 1617
 		update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz');
1452 1618
 		$error = '';
1453 1619
 		if (file_exists($tmp_dir.'notam.txt.gz')) {
1454
-			if ($globalDebug) echo "Gunzip...";
1620
+			if ($globalDebug) {
1621
+				echo "Gunzip...";
1622
+			}
1455 1623
 			update_db::gunzip($tmp_dir.'notam.txt.gz');
1456
-			if ($globalDebug) echo "Add to DB...";
1624
+			if ($globalDebug) {
1625
+				echo "Add to DB...";
1626
+			}
1457 1627
 			//$error = create_db::import_file($tmp_dir.'notam.sql');
1458 1628
 			$NOTAM = new NOTAM();
1459 1629
 			$NOTAM->updateNOTAMfromTextFile($tmp_dir.'notam.txt');
1460
-		} else $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";
1630
+		} else {
1631
+			$error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";
1632
+		}
1461 1633
 		if ($error != '') {
1462 1634
 			return $error;
1463
-		} elseif ($globalDebug) echo "Done\n";
1635
+		} elseif ($globalDebug) {
1636
+			echo "Done\n";
1637
+		}
1464 1638
 		return '';
1465 1639
 	}
1466 1640
 
@@ -1514,67 +1688,111 @@  discard block
 block discarded – undo
1514 1688
 		//if ($globalDebug) echo "IVAO : Download...";
1515 1689
 		//update_db::download('http://fr.mirror.ivao.aero/software/ivae_feb2013.zip',$tmp_dir.'ivae_feb2013.zip');
1516 1690
 		if (file_exists($tmp_dir.'ivae_feb2013.zip')) {
1517
-			if ($globalDebug) echo "Unzip...";
1691
+			if ($globalDebug) {
1692
+				echo "Unzip...";
1693
+			}
1518 1694
 			update_db::unzip($tmp_dir.'ivae_feb2013.zip');
1519
-			if ($globalDebug) echo "Add to DB...";
1695
+			if ($globalDebug) {
1696
+				echo "Add to DB...";
1697
+			}
1520 1698
 			update_db::ivao_airlines($tmp_dir.'data/airlines.dat');
1521
-			if ($globalDebug) echo "Copy airlines logos to airlines images directory...";
1699
+			if ($globalDebug) {
1700
+				echo "Copy airlines logos to airlines images directory...";
1701
+			}
1522 1702
 			if (is_writable(dirname(__FILE__).'/../images/airlines')) {
1523
-				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
1524
-			} else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
1525
-		} else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
1703
+				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) {
1704
+					$error = "Failed to copy airlines logo.";
1705
+				}
1706
+			} else {
1707
+				$error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
1708
+			}
1709
+		} else {
1710
+			$error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
1711
+		}
1526 1712
 		if ($error != '') {
1527 1713
 			return $error;
1528
-		} elseif ($globalDebug) echo "Done\n";
1714
+		} elseif ($globalDebug) {
1715
+			echo "Done\n";
1716
+		}
1529 1717
 		return '';
1530 1718
 	}
1531 1719
 
1532 1720
 	public static function update_routes() {
1533 1721
 		global $tmp_dir, $globalDebug;
1534 1722
 		$error = '';
1535
-		if ($globalDebug) echo "Routes : Download...";
1723
+		if ($globalDebug) {
1724
+			echo "Routes : Download...";
1725
+		}
1536 1726
 		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz');
1537 1727
 		if (file_exists($tmp_dir.'StandingData.sqb.gz')) {
1538
-			if ($globalDebug) echo "Gunzip...";
1728
+			if ($globalDebug) {
1729
+				echo "Gunzip...";
1730
+			}
1539 1731
 			update_db::gunzip($tmp_dir.'StandingData.sqb.gz');
1540
-			if ($globalDebug) echo "Add to DB...";
1732
+			if ($globalDebug) {
1733
+				echo "Add to DB...";
1734
+			}
1541 1735
 			$error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb');
1542
-		} else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
1736
+		} else {
1737
+			$error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
1738
+		}
1543 1739
 		if ($error != '') {
1544 1740
 			return $error;
1545
-		} elseif ($globalDebug) echo "Done\n";
1741
+		} elseif ($globalDebug) {
1742
+			echo "Done\n";
1743
+		}
1546 1744
 		return '';
1547 1745
 	}
1548 1746
 	public static function update_oneworld() {
1549 1747
 		global $tmp_dir, $globalDebug;
1550 1748
 		$error = '';
1551
-		if ($globalDebug) echo "Schedules Oneworld : Download...";
1749
+		if ($globalDebug) {
1750
+			echo "Schedules Oneworld : Download...";
1751
+		}
1552 1752
 		update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz');
1553 1753
 		if (file_exists($tmp_dir.'oneworld.csv.gz')) {
1554
-			if ($globalDebug) echo "Gunzip...";
1754
+			if ($globalDebug) {
1755
+				echo "Gunzip...";
1756
+			}
1555 1757
 			update_db::gunzip($tmp_dir.'oneworld.csv.gz');
1556
-			if ($globalDebug) echo "Add to DB...";
1758
+			if ($globalDebug) {
1759
+				echo "Add to DB...";
1760
+			}
1557 1761
 			$error = update_db::retrieve_route_oneworld($tmp_dir.'oneworld.csv');
1558
-		} else $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
1762
+		} else {
1763
+			$error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
1764
+		}
1559 1765
 		if ($error != '') {
1560 1766
 			return $error;
1561
-		} elseif ($globalDebug) echo "Done\n";
1767
+		} elseif ($globalDebug) {
1768
+			echo "Done\n";
1769
+		}
1562 1770
 		return '';
1563 1771
 	}
1564 1772
 	public static function update_skyteam() {
1565 1773
 		global $tmp_dir, $globalDebug;
1566 1774
 		$error = '';
1567
-		if ($globalDebug) echo "Schedules Skyteam : Download...";
1775
+		if ($globalDebug) {
1776
+			echo "Schedules Skyteam : Download...";
1777
+		}
1568 1778
 		update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz');
1569 1779
 		if (file_exists($tmp_dir.'skyteam.csv.gz')) {
1570
-			if ($globalDebug) echo "Gunzip...";
1780
+			if ($globalDebug) {
1781
+				echo "Gunzip...";
1782
+			}
1571 1783
 			update_db::gunzip($tmp_dir.'skyteam.csv.gz');
1572
-			if ($globalDebug) echo "Add to DB...";
1784
+			if ($globalDebug) {
1785
+				echo "Add to DB...";
1786
+			}
1573 1787
 			$error = update_db::retrieve_route_skyteam($tmp_dir.'skyteam.csv');
1574
-		} else $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
1788
+		} else {
1789
+			$error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
1790
+		}
1575 1791
 		if ($error != '') {
1576 1792
 			return $error;
1577
-		} elseif ($globalDebug) echo "Done\n";
1793
+		} elseif ($globalDebug) {
1794
+			echo "Done\n";
1795
+		}
1578 1796
 		return '';
1579 1797
 	}
1580 1798
 	public static function update_ModeS() {
@@ -1591,341 +1809,587 @@  discard block
 block discarded – undo
1591 1809
 			exit;
1592 1810
 		} elseif ($globalDebug) echo "Done\n";
1593 1811
 */
1594
-		if ($globalDebug) echo "Modes : Download...";
1595
-//		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
1812
+		if ($globalDebug) {
1813
+			echo "Modes : Download...";
1814
+		}
1815
+		//		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
1596 1816
 		update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz');
1597 1817
 
1598 1818
 //		if (file_exists($tmp_dir.'basestation_latest.zip')) {
1599 1819
 		if (file_exists($tmp_dir.'BaseStation.sqb.gz')) {
1600
-			if ($globalDebug) echo "Unzip...";
1601
-//			update_db::unzip($tmp_dir.'basestation_latest.zip');
1820
+			if ($globalDebug) {
1821
+				echo "Unzip...";
1822
+			}
1823
+			//			update_db::unzip($tmp_dir.'basestation_latest.zip');
1602 1824
 			update_db::gunzip($tmp_dir.'BaseStation.sqb.gz');
1603
-			if ($globalDebug) echo "Add to DB...";
1825
+			if ($globalDebug) {
1826
+				echo "Add to DB...";
1827
+			}
1604 1828
 			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb');
1605 1829
 //			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'basestation.sqb');
1606
-		} else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
1830
+		} else {
1831
+			$error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
1832
+		}
1607 1833
 		if ($error != '') {
1608 1834
 			return $error;
1609
-		} elseif ($globalDebug) echo "Done\n";
1835
+		} elseif ($globalDebug) {
1836
+			echo "Done\n";
1837
+		}
1610 1838
 		return '';
1611 1839
 	}
1612 1840
 
1613 1841
 	public static function update_ModeS_faa() {
1614 1842
 		global $tmp_dir, $globalDebug;
1615
-		if ($globalDebug) echo "Modes FAA: Download...";
1843
+		if ($globalDebug) {
1844
+			echo "Modes FAA: Download...";
1845
+		}
1616 1846
 		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip');
1617 1847
 		if (file_exists($tmp_dir.'ReleasableAircraft.zip')) {
1618
-			if ($globalDebug) echo "Unzip...";
1848
+			if ($globalDebug) {
1849
+				echo "Unzip...";
1850
+			}
1619 1851
 			update_db::unzip($tmp_dir.'ReleasableAircraft.zip');
1620
-			if ($globalDebug) echo "Add to DB...";
1852
+			if ($globalDebug) {
1853
+				echo "Add to DB...";
1854
+			}
1621 1855
 			$error = update_db::modes_faa();
1622
-		} else $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed.";
1856
+		} else {
1857
+			$error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed.";
1858
+		}
1623 1859
 		if ($error != '') {
1624 1860
 			return $error;
1625
-		} elseif ($globalDebug) echo "Done\n";
1861
+		} elseif ($globalDebug) {
1862
+			echo "Done\n";
1863
+		}
1626 1864
 		return '';
1627 1865
 	}
1628 1866
 
1629 1867
 	public static function update_ModeS_flarm() {
1630 1868
 		global $tmp_dir, $globalDebug;
1631
-		if ($globalDebug) echo "Modes Flarmnet: Download...";
1869
+		if ($globalDebug) {
1870
+			echo "Modes Flarmnet: Download...";
1871
+		}
1632 1872
 		update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln');
1633 1873
 		if (file_exists($tmp_dir.'data.fln')) {
1634
-			if ($globalDebug) echo "Add to DB...";
1874
+			if ($globalDebug) {
1875
+				echo "Add to DB...";
1876
+			}
1635 1877
 			$error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln');
1636
-		} else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";
1878
+		} else {
1879
+			$error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";
1880
+		}
1637 1881
 		if ($error != '') {
1638 1882
 			return $error;
1639
-		} elseif ($globalDebug) echo "Done\n";
1883
+		} elseif ($globalDebug) {
1884
+			echo "Done\n";
1885
+		}
1640 1886
 		return '';
1641 1887
 	}
1642 1888
 
1643 1889
 	public static function update_ModeS_ogn() {
1644 1890
 		global $tmp_dir, $globalDebug;
1645
-		if ($globalDebug) echo "Modes OGN: Download...";
1891
+		if ($globalDebug) {
1892
+			echo "Modes OGN: Download...";
1893
+		}
1646 1894
 		update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv');
1647 1895
 		if (file_exists($tmp_dir.'ogn.csv')) {
1648
-			if ($globalDebug) echo "Add to DB...";
1896
+			if ($globalDebug) {
1897
+				echo "Add to DB...";
1898
+			}
1649 1899
 			$error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv');
1650
-		} else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";
1900
+		} else {
1901
+			$error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";
1902
+		}
1651 1903
 		if ($error != '') {
1652 1904
 			return $error;
1653
-		} elseif ($globalDebug) echo "Done\n";
1905
+		} elseif ($globalDebug) {
1906
+			echo "Done\n";
1907
+		}
1654 1908
 		return '';
1655 1909
 	}
1656 1910
 
1657 1911
 	public static function update_owner() {
1658 1912
 		global $tmp_dir, $globalDebug;
1659 1913
 		
1660
-		if ($globalDebug) echo "Owner France: Download...";
1914
+		if ($globalDebug) {
1915
+			echo "Owner France: Download...";
1916
+		}
1661 1917
 		update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv');
1662 1918
 		if (file_exists($tmp_dir.'owner_f.csv')) {
1663
-			if ($globalDebug) echo "Add to DB...";
1919
+			if ($globalDebug) {
1920
+				echo "Add to DB...";
1921
+			}
1664 1922
 			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F');
1665
-		} else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
1923
+		} else {
1924
+			$error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
1925
+		}
1666 1926
 		if ($error != '') {
1667 1927
 			return $error;
1668
-		} elseif ($globalDebug) echo "Done\n";
1928
+		} elseif ($globalDebug) {
1929
+			echo "Done\n";
1930
+		}
1669 1931
 		
1670
-		if ($globalDebug) echo "Owner Ireland: Download...";
1932
+		if ($globalDebug) {
1933
+			echo "Owner Ireland: Download...";
1934
+		}
1671 1935
 		update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv');
1672 1936
 		if (file_exists($tmp_dir.'owner_ei.csv')) {
1673
-			if ($globalDebug) echo "Add to DB...";
1937
+			if ($globalDebug) {
1938
+				echo "Add to DB...";
1939
+			}
1674 1940
 			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI');
1675
-		} else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
1941
+		} else {
1942
+			$error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
1943
+		}
1676 1944
 		if ($error != '') {
1677 1945
 			return $error;
1678
-		} elseif ($globalDebug) echo "Done\n";
1679
-		if ($globalDebug) echo "Owner Switzerland: Download...";
1946
+		} elseif ($globalDebug) {
1947
+			echo "Done\n";
1948
+		}
1949
+		if ($globalDebug) {
1950
+			echo "Owner Switzerland: Download...";
1951
+		}
1680 1952
 		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv');
1681 1953
 		if (file_exists($tmp_dir.'owner_hb.csv')) {
1682
-			if ($globalDebug) echo "Add to DB...";
1954
+			if ($globalDebug) {
1955
+				echo "Add to DB...";
1956
+			}
1683 1957
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB');
1684
-		} else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
1958
+		} else {
1959
+			$error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
1960
+		}
1685 1961
 		if ($error != '') {
1686 1962
 			return $error;
1687
-		} elseif ($globalDebug) echo "Done\n";
1688
-		if ($globalDebug) echo "Owner Czech Republic: Download...";
1963
+		} elseif ($globalDebug) {
1964
+			echo "Done\n";
1965
+		}
1966
+		if ($globalDebug) {
1967
+			echo "Owner Czech Republic: Download...";
1968
+		}
1689 1969
 		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv');
1690 1970
 		if (file_exists($tmp_dir.'owner_ok.csv')) {
1691
-			if ($globalDebug) echo "Add to DB...";
1971
+			if ($globalDebug) {
1972
+				echo "Add to DB...";
1973
+			}
1692 1974
 			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK');
1693
-		} else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
1975
+		} else {
1976
+			$error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
1977
+		}
1694 1978
 		if ($error != '') {
1695 1979
 			return $error;
1696
-		} elseif ($globalDebug) echo "Done\n";
1697
-		if ($globalDebug) echo "Owner Australia: Download...";
1980
+		} elseif ($globalDebug) {
1981
+			echo "Done\n";
1982
+		}
1983
+		if ($globalDebug) {
1984
+			echo "Owner Australia: Download...";
1985
+		}
1698 1986
 		update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv');
1699 1987
 		if (file_exists($tmp_dir.'owner_vh.csv')) {
1700
-			if ($globalDebug) echo "Add to DB...";
1988
+			if ($globalDebug) {
1989
+				echo "Add to DB...";
1990
+			}
1701 1991
 			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH');
1702
-		} else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
1992
+		} else {
1993
+			$error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
1994
+		}
1703 1995
 		if ($error != '') {
1704 1996
 			return $error;
1705
-		} elseif ($globalDebug) echo "Done\n";
1706
-		if ($globalDebug) echo "Owner Austria: Download...";
1997
+		} elseif ($globalDebug) {
1998
+			echo "Done\n";
1999
+		}
2000
+		if ($globalDebug) {
2001
+			echo "Owner Austria: Download...";
2002
+		}
1707 2003
 		update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv');
1708 2004
 		if (file_exists($tmp_dir.'owner_oe.csv')) {
1709
-			if ($globalDebug) echo "Add to DB...";
2005
+			if ($globalDebug) {
2006
+				echo "Add to DB...";
2007
+			}
1710 2008
 			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE');
1711
-		} else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
2009
+		} else {
2010
+			$error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
2011
+		}
1712 2012
 		if ($error != '') {
1713 2013
 			return $error;
1714
-		} elseif ($globalDebug) echo "Done\n";
1715
-		if ($globalDebug) echo "Owner Chile: Download...";
2014
+		} elseif ($globalDebug) {
2015
+			echo "Done\n";
2016
+		}
2017
+		if ($globalDebug) {
2018
+			echo "Owner Chile: Download...";
2019
+		}
1716 2020
 		update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv');
1717 2021
 		if (file_exists($tmp_dir.'owner_cc.csv')) {
1718
-			if ($globalDebug) echo "Add to DB...";
2022
+			if ($globalDebug) {
2023
+				echo "Add to DB...";
2024
+			}
1719 2025
 			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC');
1720
-		} else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
2026
+		} else {
2027
+			$error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
2028
+		}
1721 2029
 		if ($error != '') {
1722 2030
 			return $error;
1723
-		} elseif ($globalDebug) echo "Done\n";
1724
-		if ($globalDebug) echo "Owner Colombia: Download...";
2031
+		} elseif ($globalDebug) {
2032
+			echo "Done\n";
2033
+		}
2034
+		if ($globalDebug) {
2035
+			echo "Owner Colombia: Download...";
2036
+		}
1725 2037
 		update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv');
1726 2038
 		if (file_exists($tmp_dir.'owner_hj.csv')) {
1727
-			if ($globalDebug) echo "Add to DB...";
2039
+			if ($globalDebug) {
2040
+				echo "Add to DB...";
2041
+			}
1728 2042
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ');
1729
-		} else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
2043
+		} else {
2044
+			$error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
2045
+		}
1730 2046
 		if ($error != '') {
1731 2047
 			return $error;
1732
-		} elseif ($globalDebug) echo "Done\n";
1733
-		if ($globalDebug) echo "Owner Bosnia Herzegobina: Download...";
2048
+		} elseif ($globalDebug) {
2049
+			echo "Done\n";
2050
+		}
2051
+		if ($globalDebug) {
2052
+			echo "Owner Bosnia Herzegobina: Download...";
2053
+		}
1734 2054
 		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv');
1735 2055
 		if (file_exists($tmp_dir.'owner_e7.csv')) {
1736
-			if ($globalDebug) echo "Add to DB...";
2056
+			if ($globalDebug) {
2057
+				echo "Add to DB...";
2058
+			}
1737 2059
 			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7');
1738
-		} else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
2060
+		} else {
2061
+			$error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
2062
+		}
1739 2063
 		if ($error != '') {
1740 2064
 			return $error;
1741
-		} elseif ($globalDebug) echo "Done\n";
1742
-		if ($globalDebug) echo "Owner Brazil: Download...";
2065
+		} elseif ($globalDebug) {
2066
+			echo "Done\n";
2067
+		}
2068
+		if ($globalDebug) {
2069
+			echo "Owner Brazil: Download...";
2070
+		}
1743 2071
 		update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv');
1744 2072
 		if (file_exists($tmp_dir.'owner_pp.csv')) {
1745
-			if ($globalDebug) echo "Add to DB...";
2073
+			if ($globalDebug) {
2074
+				echo "Add to DB...";
2075
+			}
1746 2076
 			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP');
1747
-		} else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
2077
+		} else {
2078
+			$error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
2079
+		}
1748 2080
 		if ($error != '') {
1749 2081
 			return $error;
1750
-		} elseif ($globalDebug) echo "Done\n";
1751
-		if ($globalDebug) echo "Owner Cayman Islands: Download...";
2082
+		} elseif ($globalDebug) {
2083
+			echo "Done\n";
2084
+		}
2085
+		if ($globalDebug) {
2086
+			echo "Owner Cayman Islands: Download...";
2087
+		}
1752 2088
 		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv');
1753 2089
 		if (file_exists($tmp_dir.'owner_vp.csv')) {
1754
-			if ($globalDebug) echo "Add to DB...";
2090
+			if ($globalDebug) {
2091
+				echo "Add to DB...";
2092
+			}
1755 2093
 			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP');
1756
-		} else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
2094
+		} else {
2095
+			$error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
2096
+		}
1757 2097
 		if ($error != '') {
1758 2098
 			return $error;
1759
-		} elseif ($globalDebug) echo "Done\n";
1760
-		if ($globalDebug) echo "Owner Croatia: Download...";
2099
+		} elseif ($globalDebug) {
2100
+			echo "Done\n";
2101
+		}
2102
+		if ($globalDebug) {
2103
+			echo "Owner Croatia: Download...";
2104
+		}
1761 2105
 		update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv');
1762 2106
 		if (file_exists($tmp_dir.'owner_9a.csv')) {
1763
-			if ($globalDebug) echo "Add to DB...";
2107
+			if ($globalDebug) {
2108
+				echo "Add to DB...";
2109
+			}
1764 2110
 			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A');
1765
-		} else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
2111
+		} else {
2112
+			$error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
2113
+		}
1766 2114
 		if ($error != '') {
1767 2115
 			return $error;
1768
-		} elseif ($globalDebug) echo "Done\n";
1769
-		if ($globalDebug) echo "Owner Luxembourg: Download...";
2116
+		} elseif ($globalDebug) {
2117
+			echo "Done\n";
2118
+		}
2119
+		if ($globalDebug) {
2120
+			echo "Owner Luxembourg: Download...";
2121
+		}
1770 2122
 		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv');
1771 2123
 		if (file_exists($tmp_dir.'owner_lx.csv')) {
1772
-			if ($globalDebug) echo "Add to DB...";
2124
+			if ($globalDebug) {
2125
+				echo "Add to DB...";
2126
+			}
1773 2127
 			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX');
1774
-		} else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
2128
+		} else {
2129
+			$error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
2130
+		}
1775 2131
 		if ($error != '') {
1776 2132
 			return $error;
1777
-		} elseif ($globalDebug) echo "Done\n";
1778
-		if ($globalDebug) echo "Owner Maldives: Download...";
2133
+		} elseif ($globalDebug) {
2134
+			echo "Done\n";
2135
+		}
2136
+		if ($globalDebug) {
2137
+			echo "Owner Maldives: Download...";
2138
+		}
1779 2139
 		update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv');
1780 2140
 		if (file_exists($tmp_dir.'owner_8q.csv')) {
1781
-			if ($globalDebug) echo "Add to DB...";
2141
+			if ($globalDebug) {
2142
+				echo "Add to DB...";
2143
+			}
1782 2144
 			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q');
1783
-		} else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
2145
+		} else {
2146
+			$error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
2147
+		}
1784 2148
 		if ($error != '') {
1785 2149
 			return $error;
1786
-		} elseif ($globalDebug) echo "Done\n";
1787
-		if ($globalDebug) echo "Owner New Zealand: Download...";
2150
+		} elseif ($globalDebug) {
2151
+			echo "Done\n";
2152
+		}
2153
+		if ($globalDebug) {
2154
+			echo "Owner New Zealand: Download...";
2155
+		}
1788 2156
 		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv');
1789 2157
 		if (file_exists($tmp_dir.'owner_zk.csv')) {
1790
-			if ($globalDebug) echo "Add to DB...";
2158
+			if ($globalDebug) {
2159
+				echo "Add to DB...";
2160
+			}
1791 2161
 			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK');
1792
-		} else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
2162
+		} else {
2163
+			$error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
2164
+		}
1793 2165
 		if ($error != '') {
1794 2166
 			return $error;
1795
-		} elseif ($globalDebug) echo "Done\n";
1796
-		if ($globalDebug) echo "Owner Papua New Guinea: Download...";
2167
+		} elseif ($globalDebug) {
2168
+			echo "Done\n";
2169
+		}
2170
+		if ($globalDebug) {
2171
+			echo "Owner Papua New Guinea: Download...";
2172
+		}
1797 2173
 		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv');
1798 2174
 		if (file_exists($tmp_dir.'owner_p2.csv')) {
1799
-			if ($globalDebug) echo "Add to DB...";
2175
+			if ($globalDebug) {
2176
+				echo "Add to DB...";
2177
+			}
1800 2178
 			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2');
1801
-		} else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
2179
+		} else {
2180
+			$error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
2181
+		}
1802 2182
 		if ($error != '') {
1803 2183
 			return $error;
1804
-		} elseif ($globalDebug) echo "Done\n";
1805
-		if ($globalDebug) echo "Owner Slovakia: Download...";
2184
+		} elseif ($globalDebug) {
2185
+			echo "Done\n";
2186
+		}
2187
+		if ($globalDebug) {
2188
+			echo "Owner Slovakia: Download...";
2189
+		}
1806 2190
 		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv');
1807 2191
 		if (file_exists($tmp_dir.'owner_om.csv')) {
1808
-			if ($globalDebug) echo "Add to DB...";
2192
+			if ($globalDebug) {
2193
+				echo "Add to DB...";
2194
+			}
1809 2195
 			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM');
1810
-		} else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
2196
+		} else {
2197
+			$error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
2198
+		}
1811 2199
 		if ($error != '') {
1812 2200
 			return $error;
1813
-		} elseif ($globalDebug) echo "Done\n";
1814
-		if ($globalDebug) echo "Owner Ecuador: Download...";
2201
+		} elseif ($globalDebug) {
2202
+			echo "Done\n";
2203
+		}
2204
+		if ($globalDebug) {
2205
+			echo "Owner Ecuador: Download...";
2206
+		}
1815 2207
 		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv');
1816 2208
 		if (file_exists($tmp_dir.'owner_hc.csv')) {
1817
-			if ($globalDebug) echo "Add to DB...";
2209
+			if ($globalDebug) {
2210
+				echo "Add to DB...";
2211
+			}
1818 2212
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC');
1819
-		} else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
2213
+		} else {
2214
+			$error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
2215
+		}
1820 2216
 		if ($error != '') {
1821 2217
 			return $error;
1822
-		} elseif ($globalDebug) echo "Done\n";
1823
-		if ($globalDebug) echo "Owner Iceland: Download...";
2218
+		} elseif ($globalDebug) {
2219
+			echo "Done\n";
2220
+		}
2221
+		if ($globalDebug) {
2222
+			echo "Owner Iceland: Download...";
2223
+		}
1824 2224
 		update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv');
1825 2225
 		if (file_exists($tmp_dir.'owner_tf.csv')) {
1826
-			if ($globalDebug) echo "Add to DB...";
2226
+			if ($globalDebug) {
2227
+				echo "Add to DB...";
2228
+			}
1827 2229
 			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF');
1828
-		} else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2230
+		} else {
2231
+			$error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2232
+		}
1829 2233
 		if ($error != '') {
1830 2234
 			return $error;
1831
-		} elseif ($globalDebug) echo "Done\n";
2235
+		} elseif ($globalDebug) {
2236
+			echo "Done\n";
2237
+		}
1832 2238
 		return '';
1833 2239
 	}
1834 2240
 
1835 2241
 	public static function update_translation() {
1836 2242
 		global $tmp_dir, $globalDebug;
1837 2243
 		$error = '';
1838
-		if ($globalDebug) echo "Translation : Download...";
2244
+		if ($globalDebug) {
2245
+			echo "Translation : Download...";
2246
+		}
1839 2247
 		update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip');
1840 2248
 		if (file_exists($tmp_dir.'translation.zip')) {
1841
-			if ($globalDebug) echo "Unzip...";
2249
+			if ($globalDebug) {
2250
+				echo "Unzip...";
2251
+			}
1842 2252
 			update_db::unzip($tmp_dir.'translation.zip');
1843
-			if ($globalDebug) echo "Add to DB...";
2253
+			if ($globalDebug) {
2254
+				echo "Add to DB...";
2255
+			}
1844 2256
 			$error = update_db::translation();
1845
-		} else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
2257
+		} else {
2258
+			$error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
2259
+		}
1846 2260
 		if ($error != '') {
1847 2261
 			return $error;
1848
-		} elseif ($globalDebug) echo "Done\n";
2262
+		} elseif ($globalDebug) {
2263
+			echo "Done\n";
2264
+		}
1849 2265
 		return '';
1850 2266
 	}
1851 2267
 
1852 2268
 	public static function update_translation_fam() {
1853 2269
 		global $tmp_dir, $globalDebug;
1854
-		if ($globalDebug) echo "Translation from FlightAirMap website : Download...";
2270
+		if ($globalDebug) {
2271
+			echo "Translation from FlightAirMap website : Download...";
2272
+		}
1855 2273
 		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz');
1856 2274
 		if (file_exists($tmp_dir.'translation.tsv.gz')) {
1857
-			if ($globalDebug) echo "Gunzip...";
2275
+			if ($globalDebug) {
2276
+				echo "Gunzip...";
2277
+			}
1858 2278
 			update_db::gunzip($tmp_dir.'translation.tsv.gz');
1859
-			if ($globalDebug) echo "Add to DB...";
2279
+			if ($globalDebug) {
2280
+				echo "Add to DB...";
2281
+			}
1860 2282
 			$error = update_db::translation_fam();
1861
-		} else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
2283
+		} else {
2284
+			$error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
2285
+		}
1862 2286
 		if ($error != '') {
1863 2287
 			return $error;
1864
-		} elseif ($globalDebug) echo "Done\n";
2288
+		} elseif ($globalDebug) {
2289
+			echo "Done\n";
2290
+		}
1865 2291
 		return '';
1866 2292
 	}
1867 2293
 	public static function update_ModeS_fam() {
1868 2294
 		global $tmp_dir, $globalDebug;
1869
-		if ($globalDebug) echo "ModeS from FlightAirMap website : Download...";
2295
+		if ($globalDebug) {
2296
+			echo "ModeS from FlightAirMap website : Download...";
2297
+		}
1870 2298
 		update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz');
1871 2299
 		if (file_exists($tmp_dir.'modes.tsv.gz')) {
1872
-			if ($globalDebug) echo "Gunzip...";
2300
+			if ($globalDebug) {
2301
+				echo "Gunzip...";
2302
+			}
1873 2303
 			update_db::gunzip($tmp_dir.'modes.tsv.gz');
1874
-			if ($globalDebug) echo "Add to DB...";
2304
+			if ($globalDebug) {
2305
+				echo "Add to DB...";
2306
+			}
1875 2307
 			$error = update_db::modes_fam();
1876
-		} else $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed.";
2308
+		} else {
2309
+			$error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed.";
2310
+		}
1877 2311
 		if ($error != '') {
1878 2312
 			return $error;
1879
-		} elseif ($globalDebug) echo "Done\n";
2313
+		} elseif ($globalDebug) {
2314
+			echo "Done\n";
2315
+		}
1880 2316
 		return '';
1881 2317
 	}
1882 2318
 	public static function update_owner_fam() {
1883 2319
 		global $tmp_dir, $globalDebug, $globalOwner;
1884
-		if ($globalDebug) echo "owner from FlightAirMap website : Download...";
2320
+		if ($globalDebug) {
2321
+			echo "owner from FlightAirMap website : Download...";
2322
+		}
1885 2323
 		if ($globalOwner === TRUE) {
1886 2324
 			update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz');
1887 2325
 		} else {
1888 2326
 			update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz',$tmp_dir.'owners.tsv.gz');
1889 2327
 		}
1890 2328
 		if (file_exists($tmp_dir.'owners.tsv.gz')) {
1891
-			if ($globalDebug) echo "Gunzip...";
2329
+			if ($globalDebug) {
2330
+				echo "Gunzip...";
2331
+			}
1892 2332
 			update_db::gunzip($tmp_dir.'owners.tsv.gz');
1893
-			if ($globalDebug) echo "Add to DB...";
2333
+			if ($globalDebug) {
2334
+				echo "Add to DB...";
2335
+			}
1894 2336
 			$error = update_db::owner_fam();
1895
-		} else $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed.";
2337
+		} else {
2338
+			$error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed.";
2339
+		}
1896 2340
 		if ($error != '') {
1897 2341
 			return $error;
1898
-		} elseif ($globalDebug) echo "Done\n";
2342
+		} elseif ($globalDebug) {
2343
+			echo "Done\n";
2344
+		}
1899 2345
 		return '';
1900 2346
 	}
1901 2347
 	public static function update_routes_fam() {
1902 2348
 		global $tmp_dir, $globalDebug;
1903
-		if ($globalDebug) echo "Routes from FlightAirMap website : Download...";
2349
+		if ($globalDebug) {
2350
+			echo "Routes from FlightAirMap website : Download...";
2351
+		}
1904 2352
 		update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz');
1905 2353
 		if (file_exists($tmp_dir.'routes.tsv.gz')) {
1906
-			if ($globalDebug) echo "Gunzip...";
2354
+			if ($globalDebug) {
2355
+				echo "Gunzip...";
2356
+			}
1907 2357
 			update_db::gunzip($tmp_dir.'routes.tsv.gz');
1908
-			if ($globalDebug) echo "Add to DB...";
2358
+			if ($globalDebug) {
2359
+				echo "Add to DB...";
2360
+			}
1909 2361
 			$error = update_db::routes_fam();
1910
-		} else $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed.";
2362
+		} else {
2363
+			$error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed.";
2364
+		}
1911 2365
 		if ($error != '') {
1912 2366
 			return $error;
1913
-		} elseif ($globalDebug) echo "Done\n";
2367
+		} elseif ($globalDebug) {
2368
+			echo "Done\n";
2369
+		}
1914 2370
 		return '';
1915 2371
 	}
1916 2372
 	public static function update_banned_fam() {
1917 2373
 		global $tmp_dir, $globalDebug;
1918
-		if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download...";
2374
+		if ($globalDebug) {
2375
+			echo "Banned airlines in Europe from FlightAirMap website : Download...";
2376
+		}
1919 2377
 		update_db::download('http://data.flightairmap.fr/data/ban_eu.csv',$tmp_dir.'ban_eu.csv');
1920 2378
 		if (file_exists($tmp_dir.'ban_eu.csv')) {
1921 2379
 			//if ($globalDebug) echo "Gunzip...";
1922 2380
 			//update_db::gunzip($tmp_dir.'ban_ue.csv');
1923
-			if ($globalDebug) echo "Add to DB...";
2381
+			if ($globalDebug) {
2382
+				echo "Add to DB...";
2383
+			}
1924 2384
 			$error = update_db::banned_fam();
1925
-		} else $error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed.";
2385
+		} else {
2386
+			$error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed.";
2387
+		}
1926 2388
 		if ($error != '') {
1927 2389
 			return $error;
1928
-		} elseif ($globalDebug) echo "Done\n";
2390
+		} elseif ($globalDebug) {
2391
+			echo "Done\n";
2392
+		}
1929 2393
 		return '';
1930 2394
 	}
1931 2395
 
@@ -1933,7 +2397,9 @@  discard block
 block discarded – undo
1933 2397
 		global $tmp_dir, $globalDebug, $globalDBdriver;
1934 2398
 		include_once('class.create_db.php');
1935 2399
 		$error = '';
1936
-		if ($globalDebug) echo "Airspace from FlightAirMap website : Download...";
2400
+		if ($globalDebug) {
2401
+			echo "Airspace from FlightAirMap website : Download...";
2402
+		}
1937 2403
 		if ($globalDBdriver == 'mysql') {
1938 2404
 			update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
1939 2405
 		} else {
@@ -1949,9 +2415,13 @@  discard block
 block discarded – undo
1949 2415
 					update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz');
1950 2416
 				}
1951 2417
 				if (file_exists($tmp_dir.'airspace.sql.gz')) {
1952
-					if ($globalDebug) echo "Gunzip...";
2418
+					if ($globalDebug) {
2419
+						echo "Gunzip...";
2420
+					}
1953 2421
 					update_db::gunzip($tmp_dir.'airspace.sql.gz');
1954
-					if ($globalDebug) echo "Add to DB...";
2422
+					if ($globalDebug) {
2423
+						echo "Add to DB...";
2424
+					}
1955 2425
 					$Connection = new Connection();
1956 2426
 					if ($Connection->tableExists('airspace')) {
1957 2427
 						$query = 'DROP TABLE airspace';
@@ -1964,31 +2434,47 @@  discard block
 block discarded – undo
1964 2434
 		    			}
1965 2435
 					$error = create_db::import_file($tmp_dir.'airspace.sql');
1966 2436
 					update_db::insert_airspace_version($airspace_md5);
1967
-				} else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed.";
2437
+				} else {
2438
+					$error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed.";
2439
+				}
1968 2440
 			}
1969
-		} else $error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed.";
2441
+		} else {
2442
+			$error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed.";
2443
+		}
1970 2444
 		if ($error != '') {
1971 2445
 			return $error;
1972
-		} elseif ($globalDebug) echo "Done\n";
2446
+		} elseif ($globalDebug) {
2447
+			echo "Done\n";
2448
+		}
1973 2449
 		return '';
1974 2450
 	}
1975 2451
 
1976 2452
 	public static function update_tle() {
1977 2453
 		global $tmp_dir, $globalDebug;
1978
-		if ($globalDebug) echo "Download TLE : Download...";
2454
+		if ($globalDebug) {
2455
+			echo "Download TLE : Download...";
2456
+		}
1979 2457
 		$alltle = array('stations.txt','gps-ops.txt','glo-ops.txt','galileo.txt','weather.txt','noaa.txt','goes.txt','resource.txt','dmc.txt','tdrss.txt','geo.txt','intelsat.txt','gorizont.txt',
1980 2458
 		'raduga.txt','molniya.txt','iridium.txt','orbcomm.txt','globalstar.txt','amateur.txt','x-comm.txt','other-comm.txt','sbas.txt','nnss.txt','musson.txt','science.txt','geodetic.txt',
1981 2459
 		'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt');
1982 2460
 		foreach ($alltle as $filename) {
1983
-			if ($globalDebug) echo "downloading ".$filename.'...';
2461
+			if ($globalDebug) {
2462
+				echo "downloading ".$filename.'...';
2463
+			}
1984 2464
 			update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename);
1985 2465
 			if (file_exists($tmp_dir.$filename)) {
1986
-				if ($globalDebug) echo "Add to DB ".$filename."...";
2466
+				if ($globalDebug) {
2467
+					echo "Add to DB ".$filename."...";
2468
+				}
1987 2469
 				$error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename));
1988
-			} else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
2470
+			} else {
2471
+				$error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
2472
+			}
1989 2473
 			if ($error != '') {
1990 2474
 				echo $error."\n";
1991
-			} elseif ($globalDebug) echo "Done\n";
2475
+			} elseif ($globalDebug) {
2476
+				echo "Done\n";
2477
+			}
1992 2478
 		}
1993 2479
 		return '';
1994 2480
 	}
@@ -1996,10 +2482,14 @@  discard block
 block discarded – undo
1996 2482
 	public static function update_models() {
1997 2483
 		global $tmp_dir, $globalDebug;
1998 2484
 		$error = '';
1999
-		if ($globalDebug) echo "Models from FlightAirMap website : Download...";
2485
+		if ($globalDebug) {
2486
+			echo "Models from FlightAirMap website : Download...";
2487
+		}
2000 2488
 		update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum');
2001 2489
 		if (file_exists($tmp_dir.'models.md5sum')) {
2002
-			if ($globalDebug) echo "Check files...\n";
2490
+			if ($globalDebug) {
2491
+				echo "Check files...\n";
2492
+			}
2003 2493
 			$newmodelsdb = array();
2004 2494
 			if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) {
2005 2495
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2018,25 +2508,35 @@  discard block
 block discarded – undo
2018 2508
 			}
2019 2509
 			$diff = array_diff($newmodelsdb,$modelsdb);
2020 2510
 			foreach ($diff as $key => $value) {
2021
-				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
2511
+				if ($globalDebug) {
2512
+					echo 'Downloading model '.$key.' ...'."\n";
2513
+				}
2022 2514
 				update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key);
2023 2515
 				
2024 2516
 			}
2025 2517
 			update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum');
2026
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2518
+		} else {
2519
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2520
+		}
2027 2521
 		if ($error != '') {
2028 2522
 			return $error;
2029
-		} elseif ($globalDebug) echo "Done\n";
2523
+		} elseif ($globalDebug) {
2524
+			echo "Done\n";
2525
+		}
2030 2526
 		return '';
2031 2527
 	}
2032 2528
 
2033 2529
 	public static function update_space_models() {
2034 2530
 		global $tmp_dir, $globalDebug;
2035 2531
 		$error = '';
2036
-		if ($globalDebug) echo "Space models from FlightAirMap website : Download...";
2532
+		if ($globalDebug) {
2533
+			echo "Space models from FlightAirMap website : Download...";
2534
+		}
2037 2535
 		update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum');
2038 2536
 		if (file_exists($tmp_dir.'space_models.md5sum')) {
2039
-			if ($globalDebug) echo "Check files...\n";
2537
+			if ($globalDebug) {
2538
+				echo "Check files...\n";
2539
+			}
2040 2540
 			$newmodelsdb = array();
2041 2541
 			if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) {
2042 2542
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2055,15 +2555,21 @@  discard block
 block discarded – undo
2055 2555
 			}
2056 2556
 			$diff = array_diff($newmodelsdb,$modelsdb);
2057 2557
 			foreach ($diff as $key => $value) {
2058
-				if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n";
2558
+				if ($globalDebug) {
2559
+					echo 'Downloading space model '.$key.' ...'."\n";
2560
+				}
2059 2561
 				update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key);
2060 2562
 				
2061 2563
 			}
2062 2564
 			update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum');
2063
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2565
+		} else {
2566
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2567
+		}
2064 2568
 		if ($error != '') {
2065 2569
 			return $error;
2066
-		} elseif ($globalDebug) echo "Done\n";
2570
+		} elseif ($globalDebug) {
2571
+			echo "Done\n";
2572
+		}
2067 2573
 		return '';
2068 2574
 	}
2069 2575
 
@@ -2106,7 +2612,9 @@  discard block
 block discarded – undo
2106 2612
                 }
2107 2613
 
2108 2614
 		$error = '';
2109
-		if ($globalDebug) echo "Notam : Download...";
2615
+		if ($globalDebug) {
2616
+			echo "Notam : Download...";
2617
+		}
2110 2618
 		update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss');
2111 2619
 		if (file_exists($tmp_dir.'notam.rss')) {
2112 2620
 			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true);
@@ -2121,14 +2629,30 @@  discard block
 block discarded – undo
2121 2629
 				$data['fir'] = $q[0];
2122 2630
 				$data['code'] = $q[1];
2123 2631
 				$ifrvfr = $q[2];
2124
-				if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR';
2125
-				if ($ifrvfr == 'I') $data['rules'] = 'IFR';
2126
-				if ($ifrvfr == 'V') $data['rules'] = 'VFR';
2127
-				if ($q[4] == 'A') $data['scope'] = 'Airport warning';
2128
-				if ($q[4] == 'E') $data['scope'] = 'Enroute warning';
2129
-				if ($q[4] == 'W') $data['scope'] = 'Navigation warning';
2130
-				if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning';
2131
-				if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning';
2632
+				if ($ifrvfr == 'IV') {
2633
+					$data['rules'] = 'IFR/VFR';
2634
+				}
2635
+				if ($ifrvfr == 'I') {
2636
+					$data['rules'] = 'IFR';
2637
+				}
2638
+				if ($ifrvfr == 'V') {
2639
+					$data['rules'] = 'VFR';
2640
+				}
2641
+				if ($q[4] == 'A') {
2642
+					$data['scope'] = 'Airport warning';
2643
+				}
2644
+				if ($q[4] == 'E') {
2645
+					$data['scope'] = 'Enroute warning';
2646
+				}
2647
+				if ($q[4] == 'W') {
2648
+					$data['scope'] = 'Navigation warning';
2649
+				}
2650
+				if ($q[4] == 'AE') {
2651
+					$data['scope'] = 'Airport/Enroute warning';
2652
+				}
2653
+				if ($q[4] == 'AW') {
2654
+					$data['scope'] = 'Airport/Navigation warning';
2655
+				}
2132 2656
 				//$data['scope'] = $q[4];
2133 2657
 				$data['lower_limit'] = $q[5];
2134 2658
 				$data['upper_limit'] = $q[6];
@@ -2136,8 +2660,12 @@  discard block
 block discarded – undo
2136 2660
 				sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius);
2137 2661
 				$latitude = $Common->convertDec($las,'latitude');
2138 2662
 				$longitude = $Common->convertDec($lns,'longitude');
2139
-				if ($lac == 'S') $latitude = '-'.$latitude;
2140
-				if ($lnc == 'W') $longitude = '-'.$longitude;
2663
+				if ($lac == 'S') {
2664
+					$latitude = '-'.$latitude;
2665
+				}
2666
+				if ($lnc == 'W') {
2667
+					$longitude = '-'.$longitude;
2668
+				}
2141 2669
 				$data['center_latitude'] = $latitude;
2142 2670
 				$data['center_longitude'] = $longitude;
2143 2671
 				$data['radius'] = intval($radius);
@@ -2167,10 +2695,14 @@  discard block
 block discarded – undo
2167 2695
 				$NOTAM->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['center_latitude'],$data['center_longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']);
2168 2696
 				unset($data);
2169 2697
 			} 
2170
-		} else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
2698
+		} else {
2699
+			$error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
2700
+		}
2171 2701
 		if ($error != '') {
2172 2702
 			return $error;
2173
-		} elseif ($globalDebug) echo "Done\n";
2703
+		} elseif ($globalDebug) {
2704
+			echo "Done\n";
2705
+		}
2174 2706
 		return '';
2175 2707
 	}
2176 2708
 	
@@ -2195,7 +2727,9 @@  discard block
 block discarded – undo
2195 2727
 		$airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json');
2196 2728
 		$airspace_json = json_decode($airspace_lst,true);
2197 2729
 		foreach ($airspace_json['records'] as $airspace) {
2198
-			if ($globalDebug) echo $airspace['name']."...\n";
2730
+			if ($globalDebug) {
2731
+				echo $airspace['name']."...\n";
2732
+			}
2199 2733
 			update_db::download($airspace['uri'],$tmp_dir.$airspace['name']);
2200 2734
 			if (file_exists($tmp_dir.$airspace['name'])) {
2201 2735
 				file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name'])));
@@ -2239,8 +2773,11 @@  discard block
 block discarded – undo
2239 2773
                         return "error : ".$e->getMessage();
2240 2774
                 }
2241 2775
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2242
-                if ($row['nb'] > 0) return false;
2243
-                else return true;
2776
+                if ($row['nb'] > 0) {
2777
+                	return false;
2778
+                } else {
2779
+                	return true;
2780
+                }
2244 2781
 	}
2245 2782
 
2246 2783
 	public static function insert_last_update() {
@@ -2265,8 +2802,11 @@  discard block
 block discarded – undo
2265 2802
                         return "error : ".$e->getMessage();
2266 2803
                 }
2267 2804
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2268
-                if ($row['nb'] > 0) return true;
2269
-                else return false;
2805
+                if ($row['nb'] > 0) {
2806
+                	return true;
2807
+                } else {
2808
+                	return false;
2809
+                }
2270 2810
 	}
2271 2811
 
2272 2812
 
@@ -2297,8 +2837,11 @@  discard block
 block discarded – undo
2297 2837
                         return "error : ".$e->getMessage();
2298 2838
                 }
2299 2839
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2300
-                if ($row['nb'] > 0) return false;
2301
-                else return true;
2840
+                if ($row['nb'] > 0) {
2841
+                	return false;
2842
+                } else {
2843
+                	return true;
2844
+                }
2302 2845
 	}
2303 2846
 
2304 2847
 	public static function insert_last_notam_update() {
@@ -2327,8 +2870,11 @@  discard block
 block discarded – undo
2327 2870
                         return "error : ".$e->getMessage();
2328 2871
                 }
2329 2872
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2330
-                if ($row['nb'] > 0) return false;
2331
-                else return true;
2873
+                if ($row['nb'] > 0) {
2874
+                	return false;
2875
+                } else {
2876
+                	return true;
2877
+                }
2332 2878
 	}
2333 2879
 
2334 2880
 	public static function insert_last_airspace_update() {
@@ -2358,8 +2904,11 @@  discard block
 block discarded – undo
2358 2904
                         return "error : ".$e->getMessage();
2359 2905
                 }
2360 2906
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2361
-                if ($row['nb'] > 0) return false;
2362
-                else return true;
2907
+                if ($row['nb'] > 0) {
2908
+                	return false;
2909
+                } else {
2910
+                	return true;
2911
+                }
2363 2912
 	}
2364 2913
 
2365 2914
 	public static function insert_last_owner_update() {
@@ -2388,8 +2937,11 @@  discard block
 block discarded – undo
2388 2937
                         return "error : ".$e->getMessage();
2389 2938
                 }
2390 2939
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2391
-                if ($row['nb'] > 0) return false;
2392
-                else return true;
2940
+                if ($row['nb'] > 0) {
2941
+                	return false;
2942
+                } else {
2943
+                	return true;
2944
+                }
2393 2945
 	}
2394 2946
 
2395 2947
 	public static function insert_last_schedules_update() {
@@ -2418,8 +2970,11 @@  discard block
 block discarded – undo
2418 2970
                         return "error : ".$e->getMessage();
2419 2971
                 }
2420 2972
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2421
-                if ($row['nb'] > 0) return false;
2422
-                else return true;
2973
+                if ($row['nb'] > 0) {
2974
+                	return false;
2975
+                } else {
2976
+                	return true;
2977
+                }
2423 2978
 	}
2424 2979
 
2425 2980
 	public static function insert_last_tle_update() {
Please login to merge, or discard this patch.
require/class.Stats.php 3 patches
Indentation   +833 added lines, -833 removed lines patch added patch discarded remove patch
@@ -15,33 +15,33 @@  discard block
 block discarded – undo
15 15
 		if (isset($globalFilterName)) $this->filter_name = $globalFilterName;
16 16
 		$Connection = new Connection($dbc);
17 17
 		$this->db = $Connection->db();
18
-        }
18
+		}
19 19
               
20 20
 	public function addLastStatsUpdate($type,$stats_date) {
21
-                $query = "DELETE FROM config WHERE name = :type;
21
+				$query = "DELETE FROM config WHERE name = :type;
22 22
             		INSERT INTO config (name,value) VALUES (:type,:stats_date);";
23
-                $query_values = array('type' => $type,':stats_date' => $stats_date);
24
-                 try {
25
-                        $sth = $this->db->prepare($query);
26
-                        $sth->execute($query_values);
27
-                } catch(PDOException $e) {
28
-                        return "error : ".$e->getMessage();
29
-                }
30
-        }
23
+				$query_values = array('type' => $type,':stats_date' => $stats_date);
24
+				 try {
25
+						$sth = $this->db->prepare($query);
26
+						$sth->execute($query_values);
27
+				} catch(PDOException $e) {
28
+						return "error : ".$e->getMessage();
29
+				}
30
+		}
31 31
 
32 32
 	public function getLastStatsUpdate($type = 'last_update_stats') {
33
-                $query = "SELECT value FROM config WHERE name = :type";
34
-                 try {
35
-                        $sth = $this->db->prepare($query);
36
-                        $sth->execute(array(':type' => $type));
37
-                } catch(PDOException $e) {
38
-                        echo "error : ".$e->getMessage();
39
-                }
40
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
41
-                return $all;
42
-        }
43
-        public function deleteStats($filter_name = '') {
44
-        	/*
33
+				$query = "SELECT value FROM config WHERE name = :type";
34
+				 try {
35
+						$sth = $this->db->prepare($query);
36
+						$sth->execute(array(':type' => $type));
37
+				} catch(PDOException $e) {
38
+						echo "error : ".$e->getMessage();
39
+				}
40
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
41
+				return $all;
42
+		}
43
+		public function deleteStats($filter_name = '') {
44
+			/*
45 45
         	$query = "DELETE FROM config WHERE name = 'last_update_stats'";
46 46
                  try {
47 47
                         $sth = $this->db->prepare($query);
@@ -50,80 +50,80 @@  discard block
 block discarded – undo
50 50
                         return "error : ".$e->getMessage();
51 51
                 }
52 52
                 */
53
-        	$query = "DELETE FROM stats WHERE filter_name = :filter_name;DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_airport WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_flight WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;";
54
-                 try {
55
-                        $sth = $this->db->prepare($query);
56
-                        $sth->execute(array(':filter_name' => $filter_name));
57
-                } catch(PDOException $e) {
58
-                        return "error : ".$e->getMessage();
59
-                }
60
-        }
61
-        public function deleteOldStats($filter_name = '') {
53
+			$query = "DELETE FROM stats WHERE filter_name = :filter_name;DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_airport WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_flight WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;";
54
+				 try {
55
+						$sth = $this->db->prepare($query);
56
+						$sth->execute(array(':filter_name' => $filter_name));
57
+				} catch(PDOException $e) {
58
+						return "error : ".$e->getMessage();
59
+				}
60
+		}
61
+		public function deleteOldStats($filter_name = '') {
62 62
         	
63
-        	$query = "DELETE FROM config WHERE name = 'last_update_stats'";
64
-                 try {
65
-                        $sth = $this->db->prepare($query);
66
-                        $sth->execute();
67
-                } catch(PDOException $e) {
68
-                        return "error : ".$e->getMessage();
69
-                }
63
+			$query = "DELETE FROM config WHERE name = 'last_update_stats'";
64
+				 try {
65
+						$sth = $this->db->prepare($query);
66
+						$sth->execute();
67
+				} catch(PDOException $e) {
68
+						return "error : ".$e->getMessage();
69
+				}
70 70
                 
71
-        	$query = "DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;";
72
-                 try {
73
-                        $sth = $this->db->prepare($query);
74
-                        $sth->execute(array(':filter_name' => $filter_name));
75
-                } catch(PDOException $e) {
76
-                        return "error : ".$e->getMessage();
77
-                }
78
-        }
71
+			$query = "DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;";
72
+				 try {
73
+						$sth = $this->db->prepare($query);
74
+						$sth->execute(array(':filter_name' => $filter_name));
75
+				} catch(PDOException $e) {
76
+						return "error : ".$e->getMessage();
77
+				}
78
+		}
79 79
 	public function getAllAirlineNames($filter_name = '') {
80 80
 		if ($filter_name == '') $filter_name = $this->filter_name;
81
-                $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC";
82
-                 try {
83
-                        $sth = $this->db->prepare($query);
84
-                        $sth->execute(array(':filter_name' => $filter_name));
85
-                } catch(PDOException $e) {
86
-                        echo "error : ".$e->getMessage();
87
-                }
88
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
89
-                return $all;
90
-        }
81
+				$query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC";
82
+				 try {
83
+						$sth = $this->db->prepare($query);
84
+						$sth->execute(array(':filter_name' => $filter_name));
85
+				} catch(PDOException $e) {
86
+						echo "error : ".$e->getMessage();
87
+				}
88
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
89
+				return $all;
90
+		}
91 91
 	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
92 92
 		if ($filter_name == '') $filter_name = $this->filter_name;
93
-                $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
94
-                 try {
95
-                        $sth = $this->db->prepare($query);
96
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
97
-                } catch(PDOException $e) {
98
-                        echo "error : ".$e->getMessage();
99
-                }
100
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
101
-                return $all;
102
-        }
93
+				$query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
94
+				 try {
95
+						$sth = $this->db->prepare($query);
96
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
97
+				} catch(PDOException $e) {
98
+						echo "error : ".$e->getMessage();
99
+				}
100
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
101
+				return $all;
102
+		}
103 103
 	public function getAllManufacturers($stats_airline = '',$filter_name = '') {
104 104
 		if ($filter_name == '') $filter_name = $this->filter_name;
105
-                $query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC";
106
-                 try {
107
-                        $sth = $this->db->prepare($query);
108
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
109
-                } catch(PDOException $e) {
110
-                        echo "error : ".$e->getMessage();
111
-                }
112
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
113
-                return $all;
114
-        }
105
+				$query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC";
106
+				 try {
107
+						$sth = $this->db->prepare($query);
108
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
109
+				} catch(PDOException $e) {
110
+						echo "error : ".$e->getMessage();
111
+				}
112
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
113
+				return $all;
114
+		}
115 115
 	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
116 116
 		if ($filter_name == '') $filter_name = $this->filter_name;
117
-                $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC";
118
-                 try {
119
-                        $sth = $this->db->prepare($query);
120
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
121
-                } catch(PDOException $e) {
122
-                        echo "error : ".$e->getMessage();
123
-                }
124
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
125
-                return $all;
126
-        }
117
+				$query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC";
118
+				 try {
119
+						$sth = $this->db->prepare($query);
120
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
121
+				} catch(PDOException $e) {
122
+						echo "error : ".$e->getMessage();
123
+				}
124
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
125
+				return $all;
126
+		}
127 127
 
128 128
 
129 129
 	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '') {
@@ -131,66 +131,66 @@  discard block
 block discarded – undo
131 131
 		if ($filter_name == '') $filter_name = $this->filter_name;
132 132
 		if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
133 133
 		else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
134
-                 try {
135
-                        $sth = $this->db->prepare($query);
136
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
137
-                } catch(PDOException $e) {
138
-                        echo "error : ".$e->getMessage();
139
-                }
140
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
141
-                if (empty($all)) {
142
-            	    $filters = array('airlines' => array($stats_airline));
143
-            	    if ($filter_name != '') {
144
-            		    $filters = array_merge($filters,$globalStatsFilters[$filter_name]);
145
-            	    }
146
-            	    $Spotter = new Spotter($this->db);
147
-            	    $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters);
148
-                }
149
-                return $all;
134
+				 try {
135
+						$sth = $this->db->prepare($query);
136
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
137
+				} catch(PDOException $e) {
138
+						echo "error : ".$e->getMessage();
139
+				}
140
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
141
+				if (empty($all)) {
142
+					$filters = array('airlines' => array($stats_airline));
143
+					if ($filter_name != '') {
144
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
145
+					}
146
+					$Spotter = new Spotter($this->db);
147
+					$all = $Spotter->countAllAircraftTypes($limit,0,'',$filters);
148
+				}
149
+				return $all;
150 150
 	}
151 151
 	public function countAllAirlineCountries($limit = true,$filter_name = '') {
152 152
 		global $globalStatsFilters;
153 153
 		if ($filter_name == '') $filter_name = $this->filter_name;
154 154
 		if ($limit) $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0";
155 155
 		else $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC";
156
-                 try {
157
-                        $sth = $this->db->prepare($query);
158
-                        $sth->execute(array(':filter_name' => $filter_name));
159
-                } catch(PDOException $e) {
160
-                        echo "error : ".$e->getMessage();
161
-                }
162
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
163
-                if (empty($all)) {
164
-            		$Spotter = new Spotter($this->db);
165
-            		$filters = array();
166
-            		if ($filter_name != '') {
167
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
168
-			}
169
-            		$all = $Spotter->countAllAirlineCountries($limit,$filters);
170
-                }
171
-                return $all;
156
+				 try {
157
+						$sth = $this->db->prepare($query);
158
+						$sth->execute(array(':filter_name' => $filter_name));
159
+				} catch(PDOException $e) {
160
+						echo "error : ".$e->getMessage();
161
+				}
162
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
163
+				if (empty($all)) {
164
+					$Spotter = new Spotter($this->db);
165
+					$filters = array();
166
+					if ($filter_name != '') {
167
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
168
+			}
169
+					$all = $Spotter->countAllAirlineCountries($limit,$filters);
170
+				}
171
+				return $all;
172 172
 	}
173 173
 	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '') {
174 174
 		global $globalStatsFilters;
175 175
 		if ($filter_name == '') $filter_name = $this->filter_name;
176 176
 		if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
177 177
 		else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
178
-                 try {
179
-                        $sth = $this->db->prepare($query);
180
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
181
-                } catch(PDOException $e) {
182
-                        echo "error : ".$e->getMessage();
183
-                }
184
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
185
-                if (empty($all)) {
186
-            		$filters = array('airlines' => array($stats_airline));
187
-            		if ($filter_name != '') {
188
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
178
+				 try {
179
+						$sth = $this->db->prepare($query);
180
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
181
+				} catch(PDOException $e) {
182
+						echo "error : ".$e->getMessage();
183
+				}
184
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
185
+				if (empty($all)) {
186
+					$filters = array('airlines' => array($stats_airline));
187
+					if ($filter_name != '') {
188
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
189 189
 			}
190
-            		$Spotter = new Spotter($this->db);
190
+					$Spotter = new Spotter($this->db);
191 191
 			$all = $Spotter->countAllAircraftManufacturers($filters);
192
-                }
193
-                return $all;
192
+				}
193
+				return $all;
194 194
 	}
195 195
 
196 196
 	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '') {
@@ -198,44 +198,44 @@  discard block
 block discarded – undo
198 198
 		if ($filter_name == '') $filter_name = $this->filter_name;
199 199
 		if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
200 200
 		else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC";
201
-                 try {
202
-                        $sth = $this->db->prepare($query);
203
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
204
-                } catch(PDOException $e) {
205
-                        echo "error : ".$e->getMessage();
206
-                }
207
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
208
-                if (empty($all)) {
201
+				 try {
202
+						$sth = $this->db->prepare($query);
203
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
204
+				} catch(PDOException $e) {
205
+						echo "error : ".$e->getMessage();
206
+				}
207
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
208
+				if (empty($all)) {
209 209
 			$filters = array('airlines' => array($stats_airline));
210 210
 			if ($filter_name != '') {
211
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
211
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
212 212
 			}
213 213
 			$Spotter = new Spotter($this->db);
214 214
 			$all = $Spotter->countAllArrivalCountries($limit,$filters);
215
-                }
216
-                return $all;
215
+				}
216
+				return $all;
217 217
 	}
218 218
 	public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '') {
219 219
 		global $globalStatsFilters;
220 220
 		if ($filter_name == '') $filter_name = $this->filter_name;
221 221
 		if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
222 222
 		else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC";
223
-                 try {
224
-                        $sth = $this->db->prepare($query);
225
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
226
-                } catch(PDOException $e) {
227
-                        echo "error : ".$e->getMessage();
228
-                }
229
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
230
-                if (empty($all)) {
223
+				 try {
224
+						$sth = $this->db->prepare($query);
225
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
226
+				} catch(PDOException $e) {
227
+						echo "error : ".$e->getMessage();
228
+				}
229
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
230
+				if (empty($all)) {
231 231
 			$filters = array('airlines' => array($stats_airline));
232 232
 			if ($filter_name != '') {
233
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
233
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
234 234
 			}
235 235
 			$Spotter = new Spotter($this->db);
236 236
 			$all = $Spotter->countAllDepartureCountries($filters);
237
-                }
238
-                return $all;
237
+				}
238
+				return $all;
239 239
 	}
240 240
 
241 241
 	public function countAllAirlines($limit = true,$filter_name = '') {
@@ -243,45 +243,45 @@  discard block
 block discarded – undo
243 243
 		if ($filter_name == '') $filter_name = $this->filter_name;
244 244
 		if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
245 245
 		else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC";
246
-                 try {
247
-                        $sth = $this->db->prepare($query);
248
-                        $sth->execute(array(':filter_name' => $filter_name));
249
-                } catch(PDOException $e) {
250
-                        echo "error : ".$e->getMessage();
251
-                }
252
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
253
-                if (empty($all)) {
254
-	                $Spotter = new Spotter($this->db);
255
-            		$filters = array();
256
-            		if ($filter_name != '') {
257
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
246
+				 try {
247
+						$sth = $this->db->prepare($query);
248
+						$sth->execute(array(':filter_name' => $filter_name));
249
+				} catch(PDOException $e) {
250
+						echo "error : ".$e->getMessage();
251
+				}
252
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
253
+				if (empty($all)) {
254
+					$Spotter = new Spotter($this->db);
255
+					$filters = array();
256
+					if ($filter_name != '') {
257
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
258 258
 			}
259 259
 
260
-    		        $all = $Spotter->countAllAirlines($limit,0,'',$filters);
261
-                }
262
-                return $all;
260
+					$all = $Spotter->countAllAirlines($limit,0,'',$filters);
261
+				}
262
+				return $all;
263 263
 	}
264 264
 	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '') {
265 265
 		global $globalStatsFilters;
266 266
 		if ($filter_name == '') $filter_name = $this->filter_name;
267 267
 		if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0";
268 268
 		else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC";
269
-                 try {
270
-                        $sth = $this->db->prepare($query);
271
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
272
-                } catch(PDOException $e) {
273
-                        echo "error : ".$e->getMessage();
274
-                }
275
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
276
-                if (empty($all)) {
269
+				 try {
270
+						$sth = $this->db->prepare($query);
271
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
272
+				} catch(PDOException $e) {
273
+						echo "error : ".$e->getMessage();
274
+				}
275
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
276
+				if (empty($all)) {
277 277
 			$filters = array('airlines' => array($stats_airline));
278 278
 			if ($filter_name != '') {
279 279
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
280 280
 			}
281
-	                $Spotter = new Spotter($this->db);
282
-    		        $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters);
283
-                }
284
-                return $all;
281
+					$Spotter = new Spotter($this->db);
282
+					$all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters);
283
+				}
284
+				return $all;
285 285
 	}
286 286
 	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '') {
287 287
 		global $globalStatsFilters;
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
 				echo "error : ".$e->getMessage();
319 319
 			}
320 320
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
321
-                /*
321
+				/*
322 322
                 if (empty($all)) {
323 323
 	                $Spotter = new Spotter($this->db);
324 324
     		        $all = $Spotter->countAllFlightOverCountries($limit);
@@ -334,84 +334,84 @@  discard block
 block discarded – undo
334 334
 		if ($filter_name == '') $filter_name = $this->filter_name;
335 335
 		if ($limit) $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0";
336 336
 		else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC";
337
-                 try {
338
-                        $sth = $this->db->prepare($query);
339
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
340
-                } catch(PDOException $e) {
341
-                        echo "error : ".$e->getMessage();
342
-                }
343
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
344
-                if (empty($all)) {
337
+				 try {
338
+						$sth = $this->db->prepare($query);
339
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
340
+				} catch(PDOException $e) {
341
+						echo "error : ".$e->getMessage();
342
+				}
343
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
344
+				if (empty($all)) {
345 345
 			$filters = array('airlines' => array($stats_airline));
346 346
 			if ($filter_name != '') {
347 347
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
348 348
 			}
349
-            		$Spotter = new Spotter($this->db);
350
-            		$all = $Spotter->countAllPilots($limit,0,'',$filters);
351
-                }
352
-                return $all;
349
+					$Spotter = new Spotter($this->db);
350
+					$all = $Spotter->countAllPilots($limit,0,'',$filters);
351
+				}
352
+				return $all;
353 353
 	}
354 354
 	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '') {
355 355
 		global $globalStatsFilters;
356 356
 		if ($filter_name == '') $filter_name = $this->filter_name;
357 357
 		if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
358 358
 		else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC";
359
-                 try {
360
-                        $sth = $this->db->prepare($query);
361
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
362
-                } catch(PDOException $e) {
363
-                        echo "error : ".$e->getMessage();
364
-                }
365
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
366
-                if (empty($all)) {
359
+				 try {
360
+						$sth = $this->db->prepare($query);
361
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
362
+				} catch(PDOException $e) {
363
+						echo "error : ".$e->getMessage();
364
+				}
365
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
366
+				if (empty($all)) {
367 367
 			$filters = array('airlines' => array($stats_airline));
368 368
 			if ($filter_name != '') {
369 369
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
370 370
 			}
371
-            		$Spotter = new Spotter($this->db);
372
-            		$all = $Spotter->countAllOwners($limit,0,'',$filters);
373
-                }
374
-                return $all;
371
+					$Spotter = new Spotter($this->db);
372
+					$all = $Spotter->countAllOwners($limit,0,'',$filters);
373
+				}
374
+				return $all;
375 375
 	}
376 376
 	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '') {
377 377
 		global $globalStatsFilters;
378 378
 		if ($filter_name == '') $filter_name = $this->filter_name;
379 379
 		if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
380 380
 		else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
381
-                 try {
382
-                        $sth = $this->db->prepare($query);
383
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
384
-                } catch(PDOException $e) {
385
-                        echo "error : ".$e->getMessage();
386
-                }
387
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
388
-                if (empty($all)) {
381
+				 try {
382
+						$sth = $this->db->prepare($query);
383
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
384
+				} catch(PDOException $e) {
385
+						echo "error : ".$e->getMessage();
386
+				}
387
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
388
+				if (empty($all)) {
389 389
 			$filters = array('airlines' => array($stats_airline));
390
-            		if ($filter_name != '') {
391
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
392
-			}
393
-            		$Spotter = new Spotter($this->db);
394
-            		$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters);
395
-        		$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters);
396
-        		$all = array();
397
-        		foreach ($pall as $value) {
398
-        			$icao = $value['airport_departure_icao'];
399
-        			$all[$icao] = $value;
400
-        		}
390
+					if ($filter_name != '') {
391
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
392
+			}
393
+					$Spotter = new Spotter($this->db);
394
+					$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters);
395
+				$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters);
396
+				$all = array();
397
+				foreach ($pall as $value) {
398
+					$icao = $value['airport_departure_icao'];
399
+					$all[$icao] = $value;
400
+				}
401 401
         		
402
-        		foreach ($dall as $value) {
403
-        			$icao = $value['airport_departure_icao'];
404
-        			if (isset($all[$icao])) {
405
-        				$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
406
-        			} else $all[$icao] = $value;
407
-        		}
408
-        		$count = array();
409
-        		foreach ($all as $key => $row) {
410
-        			$count[$key] = $row['airport_departure_icao_count'];
411
-        		}
412
-        		array_multisort($count,SORT_DESC,$all);
413
-                }
414
-                return $all;
402
+				foreach ($dall as $value) {
403
+					$icao = $value['airport_departure_icao'];
404
+					if (isset($all[$icao])) {
405
+						$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
406
+					} else $all[$icao] = $value;
407
+				}
408
+				$count = array();
409
+				foreach ($all as $key => $row) {
410
+					$count[$key] = $row['airport_departure_icao_count'];
411
+				}
412
+				array_multisort($count,SORT_DESC,$all);
413
+				}
414
+				return $all;
415 415
 	}
416 416
 	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '') {
417 417
 		global $globalStatsFilters;
@@ -433,26 +433,26 @@  discard block
 block discarded – undo
433 433
 			$Spotter = new Spotter($this->db);
434 434
 			$pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters);
435 435
 			$dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters);
436
-        		$all = array();
437
-        		foreach ($pall as $value) {
438
-        			$icao = $value['airport_arrival_icao'];
439
-        			$all[$icao] = $value;
440
-        		}
436
+				$all = array();
437
+				foreach ($pall as $value) {
438
+					$icao = $value['airport_arrival_icao'];
439
+					$all[$icao] = $value;
440
+				}
441 441
         		
442
-        		foreach ($dall as $value) {
443
-        			$icao = $value['airport_arrival_icao'];
444
-        			if (isset($all[$icao])) {
445
-        				$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
446
-        			} else $all[$icao] = $value;
447
-        		}
448
-        		$count = array();
449
-        		foreach ($all as $key => $row) {
450
-        			$count[$key] = $row['airport_arrival_icao_count'];
451
-        		}
452
-        		array_multisort($count,SORT_DESC,$all);
453
-                }
442
+				foreach ($dall as $value) {
443
+					$icao = $value['airport_arrival_icao'];
444
+					if (isset($all[$icao])) {
445
+						$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
446
+					} else $all[$icao] = $value;
447
+				}
448
+				$count = array();
449
+				foreach ($all as $key => $row) {
450
+					$count[$key] = $row['airport_arrival_icao_count'];
451
+				}
452
+				array_multisort($count,SORT_DESC,$all);
453
+				}
454 454
  
455
-                return $all;
455
+				return $all;
456 456
 	}
457 457
 	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
458 458
 		global $globalDBdriver, $globalStatsFilters;
@@ -465,23 +465,23 @@  discard block
 block discarded – undo
465 465
 			else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
466 466
 		}
467 467
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
468
-                 try {
469
-                        $sth = $this->db->prepare($query);
470
-                        $sth->execute($query_data);
471
-                } catch(PDOException $e) {
472
-                        echo "error : ".$e->getMessage();
473
-                }
474
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
475
-                if (empty($all)) {
468
+				 try {
469
+						$sth = $this->db->prepare($query);
470
+						$sth->execute($query_data);
471
+				} catch(PDOException $e) {
472
+						echo "error : ".$e->getMessage();
473
+				}
474
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
475
+				if (empty($all)) {
476 476
 			$filters = array('airlines' => array($stats_airline));
477 477
 			if ($filter_name != '') {
478 478
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
479 479
 			}
480
-            		$Spotter = new Spotter($this->db);
481
-            		$all = $Spotter->countAllMonthsLastYear($filters);
482
-                }
480
+					$Spotter = new Spotter($this->db);
481
+					$all = $Spotter->countAllMonthsLastYear($filters);
482
+				}
483 483
                 
484
-                return $all;
484
+				return $all;
485 485
 	}
486 486
 	
487 487
 	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
@@ -489,22 +489,22 @@  discard block
 block discarded – undo
489 489
 		if ($filter_name == '') $filter_name = $this->filter_name;
490 490
 		$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline = :stats_airline AND filter_name = :filter_name";
491 491
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
492
-                 try {
493
-                        $sth = $this->db->prepare($query);
494
-                        $sth->execute($query_data);
495
-                } catch(PDOException $e) {
496
-                        echo "error : ".$e->getMessage();
497
-                }
498
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
499
-                if (empty($all)) {
492
+				 try {
493
+						$sth = $this->db->prepare($query);
494
+						$sth->execute($query_data);
495
+				} catch(PDOException $e) {
496
+						echo "error : ".$e->getMessage();
497
+				}
498
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
499
+				if (empty($all)) {
500 500
 			$filters = array('airlines' => array($stats_airline));
501 501
 			if ($filter_name != '') {
502 502
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
503 503
 			}
504
-            		$Spotter = new Spotter($this->db);
505
-            		$all = $Spotter->countAllDatesLastMonth($filters);
506
-                }
507
-                return $all;
504
+					$Spotter = new Spotter($this->db);
505
+					$all = $Spotter->countAllDatesLastMonth($filters);
506
+				}
507
+				return $all;
508 508
 	}
509 509
 	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
510 510
 		global $globalDBdriver, $globalStatsFilters;
@@ -515,108 +515,108 @@  discard block
 block discarded – undo
515 515
 			$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
516 516
 		}
517 517
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
518
-                 try {
519
-                        $sth = $this->db->prepare($query);
520
-                        $sth->execute($query_data);
521
-                } catch(PDOException $e) {
522
-                        echo "error : ".$e->getMessage();
523
-                }
524
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
525
-                if (empty($all)) {
518
+				 try {
519
+						$sth = $this->db->prepare($query);
520
+						$sth->execute($query_data);
521
+				} catch(PDOException $e) {
522
+						echo "error : ".$e->getMessage();
523
+				}
524
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
525
+				if (empty($all)) {
526 526
 			$filters = array('airlines' => array($stats_airline));
527 527
 			if ($filter_name != '') {
528 528
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
529 529
 			}
530
-            		$Spotter = new Spotter($this->db);
531
-            		$all = $Spotter->countAllDatesLast7Days($filters);
532
-                }
533
-                return $all;
530
+					$Spotter = new Spotter($this->db);
531
+					$all = $Spotter->countAllDatesLast7Days($filters);
532
+				}
533
+				return $all;
534 534
 	}
535 535
 	public function countAllDates($stats_airline = '',$filter_name = '') {
536 536
 		global $globalStatsFilters;
537 537
 		if ($filter_name == '') $filter_name = $this->filter_name;
538 538
 		$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline = :stats_airline AND filter_name = :filter_name";
539 539
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
540
-                 try {
541
-                        $sth = $this->db->prepare($query);
542
-                        $sth->execute($query_data);
543
-                } catch(PDOException $e) {
544
-                        echo "error : ".$e->getMessage();
545
-                }
546
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
547
-                if (empty($all)) {
540
+				 try {
541
+						$sth = $this->db->prepare($query);
542
+						$sth->execute($query_data);
543
+				} catch(PDOException $e) {
544
+						echo "error : ".$e->getMessage();
545
+				}
546
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
547
+				if (empty($all)) {
548 548
 			$filters = array('airlines' => array($stats_airline));
549 549
 			if ($filter_name != '') {
550
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
550
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
551 551
 			}
552
-            		$Spotter = new Spotter($this->db);
553
-            		$all = $Spotter->countAllDates($filters);
554
-                }
555
-                return $all;
552
+					$Spotter = new Spotter($this->db);
553
+					$all = $Spotter->countAllDates($filters);
554
+				}
555
+				return $all;
556 556
 	}
557 557
 	public function countAllDatesByAirlines($filter_name = '') {
558 558
 		global $globalStatsFilters;
559 559
 		if ($filter_name == '') $filter_name = $this->filter_name;
560 560
 		$query = "SELECT stats_airline as airline_icao, flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND filter_name = :filter_name";
561 561
 		$query_data = array('filter_name' => $filter_name);
562
-                 try {
563
-                        $sth = $this->db->prepare($query);
564
-                        $sth->execute($query_data);
565
-                } catch(PDOException $e) {
566
-                        echo "error : ".$e->getMessage();
567
-                }
568
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
569
-                if (empty($all)) {
570
-            		$filters = array();
571
-            		if ($filter_name != '') {
572
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
573
-			}
574
-            		$Spotter = new Spotter($this->db);
575
-            		$all = $Spotter->countAllDatesByAirlines($filters);
576
-                }
577
-                return $all;
562
+				 try {
563
+						$sth = $this->db->prepare($query);
564
+						$sth->execute($query_data);
565
+				} catch(PDOException $e) {
566
+						echo "error : ".$e->getMessage();
567
+				}
568
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
569
+				if (empty($all)) {
570
+					$filters = array();
571
+					if ($filter_name != '') {
572
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
573
+			}
574
+					$Spotter = new Spotter($this->db);
575
+					$all = $Spotter->countAllDatesByAirlines($filters);
576
+				}
577
+				return $all;
578 578
 	}
579 579
 	public function countAllMonths($stats_airline = '',$filter_name = '') {
580 580
 		global $globalStatsFilters;
581 581
 		if ($filter_name == '') $filter_name = $this->filter_name;
582
-	    	$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
583
-                 try {
584
-                        $sth = $this->db->prepare($query);
585
-                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
586
-                } catch(PDOException $e) {
587
-                        echo "error : ".$e->getMessage();
588
-                }
589
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
590
-                if (empty($all)) {
582
+			$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
583
+				 try {
584
+						$sth = $this->db->prepare($query);
585
+						$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
586
+				} catch(PDOException $e) {
587
+						echo "error : ".$e->getMessage();
588
+				}
589
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
590
+				if (empty($all)) {
591 591
 			$filters = array('airlines' => array($stats_airline));
592 592
 			if ($filter_name != '') {
593 593
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
594 594
 			}
595
-            		$Spotter = new Spotter($this->db);
596
-            		$all = $Spotter->countAllMonths($filters);
597
-                }
598
-                return $all;
595
+					$Spotter = new Spotter($this->db);
596
+					$all = $Spotter->countAllMonths($filters);
597
+				}
598
+				return $all;
599 599
 	}
600 600
 	public function countAllMilitaryMonths($filter_name = '') {
601 601
 		global $globalStatsFilters;
602 602
 		if ($filter_name == '') $filter_name = $this->filter_name;
603
-	    	$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'military_flights_bymonth' AND filter_name = :filter_name";
604
-                 try {
605
-                        $sth = $this->db->prepare($query);
606
-                        $sth->execute(array(':filter_name' => $filter_name));
607
-                } catch(PDOException $e) {
608
-                        echo "error : ".$e->getMessage();
609
-                }
610
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
611
-                if (empty($all)) {
612
-            		$filters = array();
613
-            		if ($filter_name != '') {
614
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
615
-			}
616
-            		$Spotter = new Spotter($this->db);
617
-            		$all = $Spotter->countAllMilitaryMonths($filters);
618
-                }
619
-                return $all;
603
+			$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'military_flights_bymonth' AND filter_name = :filter_name";
604
+				 try {
605
+						$sth = $this->db->prepare($query);
606
+						$sth->execute(array(':filter_name' => $filter_name));
607
+				} catch(PDOException $e) {
608
+						echo "error : ".$e->getMessage();
609
+				}
610
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
611
+				if (empty($all)) {
612
+					$filters = array();
613
+					if ($filter_name != '') {
614
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
615
+			}
616
+					$Spotter = new Spotter($this->db);
617
+					$all = $Spotter->countAllMilitaryMonths($filters);
618
+				}
619
+				return $all;
620 620
 	}
621 621
 	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
622 622
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
@@ -632,22 +632,22 @@  discard block
 block discarded – undo
632 632
 			$query .= " ORDER BY CAST(flight_date AS integer) ASC";
633 633
 		}
634 634
 		if ($orderby == 'count') $query .= " ORDER BY hour_count DESC";
635
-                 try {
636
-                        $sth = $this->db->prepare($query);
637
-                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
638
-                } catch(PDOException $e) {
639
-                        echo "error : ".$e->getMessage();
640
-                }
641
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
642
-                if (empty($all)) {
635
+				 try {
636
+						$sth = $this->db->prepare($query);
637
+						$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
638
+				} catch(PDOException $e) {
639
+						echo "error : ".$e->getMessage();
640
+				}
641
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
642
+				if (empty($all)) {
643 643
 			$filters = array('airlines' => array($stats_airline));
644 644
 			if ($filter_name != '') {
645
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
645
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
646 646
 			}
647
-            		$Spotter = new Spotter($this->db);
648
-            		$all = $Spotter->countAllHours($orderby,$filters);
649
-                }
650
-                return $all;
647
+					$Spotter = new Spotter($this->db);
648
+					$all = $Spotter->countAllHours($orderby,$filters);
649
+				}
650
+				return $all;
651 651
 	}
652 652
 	
653 653
 	public function countOverallFlights($stats_airline = '', $filter_name = '') {
@@ -669,9 +669,9 @@  discard block
 block discarded – undo
669 669
 		if ($filter_name == '') $filter_name = $this->filter_name;
670 670
 		$all = $this->getSumStats('military_flights_bymonth',date('Y'),'',$filter_name);
671 671
 		if (empty($all)) {
672
-		        $filters = array();
673
-            		if ($filter_name != '') {
674
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
672
+				$filters = array();
673
+					if ($filter_name != '') {
674
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
675 675
 			}
676 676
 			$Spotter = new Spotter($this->db);
677 677
 			$all = $Spotter->countOverallMilitaryFlights($filters);
@@ -710,19 +710,19 @@  discard block
 block discarded – undo
710 710
 		global $globalStatsFilters;
711 711
 		if ($filter_name == '') $filter_name = $this->filter_name;
712 712
 		$query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name";
713
-                 try {
714
-                        $sth = $this->db->prepare($query);
715
-                        $sth->execute(array(':filter_name' => $filter_name));
716
-                } catch(PDOException $e) {
717
-                        echo "error : ".$e->getMessage();
718
-                }
719
-                $result = $sth->fetchAll(PDO::FETCH_ASSOC);
720
-                $all = $result[0]['nb_airline'];
713
+				 try {
714
+						$sth = $this->db->prepare($query);
715
+						$sth->execute(array(':filter_name' => $filter_name));
716
+				} catch(PDOException $e) {
717
+						echo "error : ".$e->getMessage();
718
+				}
719
+				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
720
+				$all = $result[0]['nb_airline'];
721 721
 		//$all = $this->getSumStats('airlines_bymonth',date('Y'));
722 722
 		if (empty($all)) {
723
-            		$filters = array();
724
-            		if ($filter_name != '') {
725
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
723
+					$filters = array();
724
+					if ($filter_name != '') {
725
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
726 726
 			}
727 727
 			$Spotter = new Spotter($this->db);
728 728
 			$all = $Spotter->countOverallAirlines($filters);
@@ -773,166 +773,166 @@  discard block
 block discarded – undo
773 773
 		if ($filter_name == '') $filter_name = $this->filter_name;
774 774
 		$query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date";
775 775
 		$query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
776
-                 try {
777
-                        $sth = $this->db->prepare($query);
778
-                        $sth->execute($query_values);
779
-                } catch(PDOException $e) {
780
-                        echo "error : ".$e->getMessage();
781
-                }
782
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
783
-                return $all;
776
+				 try {
777
+						$sth = $this->db->prepare($query);
778
+						$sth->execute($query_values);
779
+				} catch(PDOException $e) {
780
+						echo "error : ".$e->getMessage();
781
+				}
782
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
783
+				return $all;
784 784
 	}
785 785
 	public function getStats($type,$stats_airline = '', $filter_name = '') {
786 786
 		if ($filter_name == '') $filter_name = $this->filter_name;
787
-                $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
788
-                $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
789
-                 try {
790
-                        $sth = $this->db->prepare($query);
791
-                        $sth->execute($query_values);
792
-                } catch(PDOException $e) {
793
-                        echo "error : ".$e->getMessage();
794
-                }
795
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
796
-                return $all;
797
-        }
787
+				$query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
788
+				$query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
789
+				 try {
790
+						$sth = $this->db->prepare($query);
791
+						$sth->execute($query_values);
792
+				} catch(PDOException $e) {
793
+						echo "error : ".$e->getMessage();
794
+				}
795
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
796
+				return $all;
797
+		}
798 798
 	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '') {
799 799
 		if ($filter_name == '') $filter_name = $this->filter_name;
800
-    		global $globalArchiveMonths, $globalDBdriver;
801
-    		if ($globalDBdriver == 'mysql') {
802
-	                $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name";
803
-	        } else {
804
-            		$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name";
805
-                }
806
-                $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
807
-                 try {
808
-                        $sth = $this->db->prepare($query);
809
-                        $sth->execute($query_values);
810
-                } catch(PDOException $e) {
811
-                        echo "error : ".$e->getMessage();
812
-                }
813
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
814
-                return $all[0]['total'];
815
-        }
800
+			global $globalArchiveMonths, $globalDBdriver;
801
+			if ($globalDBdriver == 'mysql') {
802
+					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name";
803
+			} else {
804
+					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name";
805
+				}
806
+				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
807
+				 try {
808
+						$sth = $this->db->prepare($query);
809
+						$sth->execute($query_values);
810
+				} catch(PDOException $e) {
811
+						echo "error : ".$e->getMessage();
812
+				}
813
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
814
+				return $all[0]['total'];
815
+		}
816 816
 	public function getStatsTotal($type, $stats_airline = '', $filter_name = '') {
817
-    		global $globalArchiveMonths, $globalDBdriver;
817
+			global $globalArchiveMonths, $globalDBdriver;
818 818
 		if ($filter_name == '') $filter_name = $this->filter_name;
819
-    		if ($globalDBdriver == 'mysql') {
819
+			if ($globalDBdriver == 'mysql') {
820 820
 			$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL ".$globalArchiveMonths." MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name";
821 821
 		} else {
822 822
 			$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveMonths." MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
823
-                }
824
-                $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
825
-                 try {
826
-                        $sth = $this->db->prepare($query);
827
-                        $sth->execute($query_values);
828
-                } catch(PDOException $e) {
829
-                        echo "error : ".$e->getMessage();
830
-                }
831
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
832
-                return $all[0]['total'];
833
-        }
823
+				}
824
+				$query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
825
+				 try {
826
+						$sth = $this->db->prepare($query);
827
+						$sth->execute($query_values);
828
+				} catch(PDOException $e) {
829
+						echo "error : ".$e->getMessage();
830
+				}
831
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
832
+				return $all[0]['total'];
833
+		}
834 834
 	public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') {
835
-    		global $globalArchiveMonths, $globalDBdriver;
835
+			global $globalArchiveMonths, $globalDBdriver;
836 836
 		if ($filter_name == '') $filter_name = $this->filter_name;
837
-    		if ($globalDBdriver == 'mysql') {
837
+			if ($globalDBdriver == 'mysql') {
838 838
 			$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
839
-                } else {
839
+				} else {
840 840
 			$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
841
-                }
842
-                 try {
843
-                        $sth = $this->db->prepare($query);
844
-                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
845
-                } catch(PDOException $e) {
846
-                        echo "error : ".$e->getMessage();
847
-                }
848
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
849
-                return $all[0]['total'];
850
-        }
841
+				}
842
+				 try {
843
+						$sth = $this->db->prepare($query);
844
+						$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
845
+				} catch(PDOException $e) {
846
+						echo "error : ".$e->getMessage();
847
+				}
848
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
849
+				return $all[0]['total'];
850
+		}
851 851
 	public function getStatsAirlineTotal($filter_name = '') {
852
-    		global $globalArchiveMonths, $globalDBdriver;
852
+			global $globalArchiveMonths, $globalDBdriver;
853 853
 		if ($filter_name == '') $filter_name = $this->filter_name;
854
-    		if ($globalDBdriver == 'mysql') {
854
+			if ($globalDBdriver == 'mysql') {
855 855
 			$query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name";
856
-                } else {
856
+				} else {
857 857
 			$query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name";
858
-                }
859
-                 try {
860
-                        $sth = $this->db->prepare($query);
861
-                        $sth->execute(array(':filter_name' => $filter_name));
862
-                } catch(PDOException $e) {
863
-                        echo "error : ".$e->getMessage();
864
-                }
865
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
866
-                return $all[0]['total'];
867
-        }
858
+				}
859
+				 try {
860
+						$sth = $this->db->prepare($query);
861
+						$sth->execute(array(':filter_name' => $filter_name));
862
+				} catch(PDOException $e) {
863
+						echo "error : ".$e->getMessage();
864
+				}
865
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
866
+				return $all[0]['total'];
867
+		}
868 868
 	public function getStatsOwnerTotal($filter_name = '') {
869
-    		global $globalArchiveMonths, $globalDBdriver;
869
+			global $globalArchiveMonths, $globalDBdriver;
870 870
 		if ($filter_name == '') $filter_name = $this->filter_name;
871
-    		if ($globalDBdriver == 'mysql') {
871
+			if ($globalDBdriver == 'mysql') {
872 872
 			$query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name";
873 873
 		} else {
874 874
 			$query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name";
875
-                }
876
-                 try {
877
-                        $sth = $this->db->prepare($query);
878
-                        $sth->execute(array(':filter_name' => $filter_name));
879
-                } catch(PDOException $e) {
880
-                        echo "error : ".$e->getMessage();
881
-                }
882
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
883
-                return $all[0]['total'];
884
-        }
875
+				}
876
+				 try {
877
+						$sth = $this->db->prepare($query);
878
+						$sth->execute(array(':filter_name' => $filter_name));
879
+				} catch(PDOException $e) {
880
+						echo "error : ".$e->getMessage();
881
+				}
882
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
883
+				return $all[0]['total'];
884
+		}
885 885
 	public function getStatsPilotTotal($filter_name = '') {
886
-    		global $globalArchiveMonths, $globalDBdriver;
886
+			global $globalArchiveMonths, $globalDBdriver;
887 887
 		if ($filter_name == '') $filter_name = $this->filter_name;
888
-    		if ($globalDBdriver == 'mysql') {
889
-            		$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
890
-            	} else {
891
-            		$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
892
-            	}
893
-                 try {
894
-                        $sth = $this->db->prepare($query);
895
-                        $sth->execute(array(':filter_name' => $filter_name));
896
-                } catch(PDOException $e) {
897
-                        echo "error : ".$e->getMessage();
898
-                }
899
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
900
-                return $all[0]['total'];
901
-        }
888
+			if ($globalDBdriver == 'mysql') {
889
+					$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
890
+				} else {
891
+					$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
892
+				}
893
+				 try {
894
+						$sth = $this->db->prepare($query);
895
+						$sth->execute(array(':filter_name' => $filter_name));
896
+				} catch(PDOException $e) {
897
+						echo "error : ".$e->getMessage();
898
+				}
899
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
900
+				return $all[0]['total'];
901
+		}
902 902
 
903 903
 	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
904 904
 		global $globalDBdriver;
905 905
 		if ($filter_name == '') $filter_name = $this->filter_name;
906 906
 		if ($globalDBdriver == 'mysql') {
907 907
 			$query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = :cnt";
908
-                } else {
908
+				} else {
909 909
 			$query = "UPDATE stats SET cnt = :cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE  stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
910 910
 		}
911
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
912
-                 try {
913
-                        $sth = $this->db->prepare($query);
914
-                        $sth->execute($query_values);
915
-                } catch(PDOException $e) {
916
-                        return "error : ".$e->getMessage();
917
-                }
918
-        }
911
+				$query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
912
+				 try {
913
+						$sth = $this->db->prepare($query);
914
+						$sth->execute($query_values);
915
+				} catch(PDOException $e) {
916
+						return "error : ".$e->getMessage();
917
+				}
918
+		}
919 919
 	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
920 920
 		global $globalDBdriver;
921 921
 		if ($filter_name == '') $filter_name = $this->filter_name;
922 922
 		if ($globalDBdriver == 'mysql') {
923 923
 			$query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
924 924
 		} else {
925
-            		//$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
925
+					//$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
926 926
 			$query = "UPDATE stats SET cnt = cnt+:cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE  stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
927
-                }
928
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
929
-                 try {
930
-                        $sth = $this->db->prepare($query);
931
-                        $sth->execute($query_values);
932
-                } catch(PDOException $e) {
933
-                        return "error : ".$e->getMessage();
934
-                }
935
-        }
927
+				}
928
+				$query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
929
+				 try {
930
+						$sth = $this->db->prepare($query);
931
+						$sth->execute($query_values);
932
+				} catch(PDOException $e) {
933
+						return "error : ".$e->getMessage();
934
+				}
935
+		}
936 936
 	public function getStatsSource($date,$stats_type = '') {
937 937
 		if ($stats_type == '') {
938 938
 			$query = "SELECT * FROM stats_source WHERE stats_date = :date ORDER BY source_name";
@@ -941,15 +941,15 @@  discard block
 block discarded – undo
941 941
 			$query = "SELECT * FROM stats_source WHERE stats_date = :date AND stats_type = :stats_type ORDER BY source_name";
942 942
 			$query_values = array(':date' => $date,':stats_type' => $stats_type);
943 943
 		}
944
-                 try {
945
-                        $sth = $this->db->prepare($query);
946
-                        $sth->execute($query_values);
947
-                } catch(PDOException $e) {
948
-                        echo "error : ".$e->getMessage();
949
-                }
950
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
951
-                return $all;
952
-        }
944
+				 try {
945
+						$sth = $this->db->prepare($query);
946
+						$sth->execute($query_values);
947
+				} catch(PDOException $e) {
948
+						echo "error : ".$e->getMessage();
949
+				}
950
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
951
+				return $all;
952
+		}
953 953
 
954 954
 	public function addStatSource($data,$source_name,$stats_type,$date) {
955 955
 		global $globalDBdriver;
@@ -957,25 +957,25 @@  discard block
 block discarded – undo
957 957
 			$query = "INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) VALUES (:data,:source_name,:stats_type,:stats_date) ON DUPLICATE KEY UPDATE source_data = :data";
958 958
 		} else {
959 959
 			$query = "UPDATE stats_source SET source_data = :data WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type; INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) SELECT :data,:source_name,:stats_type,:stats_date WHERE NOT EXISTS (SELECT 1 FROM stats_source WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type);"; 
960
-                }
961
-                $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type);
962
-                 try {
963
-                        $sth = $this->db->prepare($query);
964
-                        $sth->execute($query_values);
965
-                } catch(PDOException $e) {
966
-                        return "error : ".$e->getMessage();
967
-                }
968
-        }
960
+				}
961
+				$query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type);
962
+				 try {
963
+						$sth = $this->db->prepare($query);
964
+						$sth->execute($query_values);
965
+				} catch(PDOException $e) {
966
+						return "error : ".$e->getMessage();
967
+				}
968
+		}
969 969
 	public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') {
970
-                $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)";
971
-                $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
972
-                 try {
973
-                        $sth = $this->db->prepare($query);
974
-                        $sth->execute($query_values);
975
-                } catch(PDOException $e) {
976
-                        return "error : ".$e->getMessage();
977
-                }
978
-        }
970
+				$query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)";
971
+				$query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
972
+				 try {
973
+						$sth = $this->db->prepare($query);
974
+						$sth->execute($query_values);
975
+				} catch(PDOException $e) {
976
+						return "error : ".$e->getMessage();
977
+				}
978
+		}
979 979
 	public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '',$reset = false) {
980 980
 		global $globalDBdriver;
981 981
 		if ($globalDBdriver == 'mysql') {
@@ -991,14 +991,14 @@  discard block
 block discarded – undo
991 991
 				$query = "UPDATE stats_registration SET cnt = cnt+:cnt WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_registration (aircraft_icao,registration,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:registration,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_registration WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
992 992
 			}
993 993
 		}
994
-                $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
995
-                 try {
996
-                        $sth = $this->db->prepare($query);
997
-                        $sth->execute($query_values);
998
-                } catch(PDOException $e) {
999
-                        return "error : ".$e->getMessage();
1000
-                }
1001
-        }
994
+				$query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
995
+				 try {
996
+						$sth = $this->db->prepare($query);
997
+						$sth->execute($query_values);
998
+				} catch(PDOException $e) {
999
+						return "error : ".$e->getMessage();
1000
+				}
1001
+		}
1002 1002
 	public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '', $reset = false) {
1003 1003
 		global $globalDBdriver;
1004 1004
 		if ($globalDBdriver == 'mysql') {
@@ -1014,14 +1014,14 @@  discard block
 block discarded – undo
1014 1014
 				$query = "UPDATE stats_callsign SET cnt = cnt+:cnt WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name; INSERT INTO stats_callsign (callsign_icao,airline_icao,cnt,filter_name) SELECT :callsign_icao,:airline_icao,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_callsign WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name);"; 
1015 1015
 			}
1016 1016
 		}
1017
-                $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name);
1018
-                 try {
1019
-                        $sth = $this->db->prepare($query);
1020
-                        $sth->execute($query_values);
1021
-                } catch(PDOException $e) {
1022
-                        return "error : ".$e->getMessage();
1023
-                }
1024
-        }
1017
+				$query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name);
1018
+				 try {
1019
+						$sth = $this->db->prepare($query);
1020
+						$sth->execute($query_values);
1021
+				} catch(PDOException $e) {
1022
+						return "error : ".$e->getMessage();
1023
+				}
1024
+		}
1025 1025
 	public function addStatCountry($iso2,$iso3,$name,$cnt,$filter_name = '',$reset = false) {
1026 1026
 		global $globalDBdriver;
1027 1027
 		if ($globalDBdriver == 'mysql') {
@@ -1037,14 +1037,14 @@  discard block
 block discarded – undo
1037 1037
 				$query = "UPDATE stats_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name; INSERT INTO stats_country (iso2,iso3,name,cnt,filter_name) SELECT :iso2,:iso3,:name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_country WHERE iso2 = :iso2 AND filter_name = :filter_name);"; 
1038 1038
 			}
1039 1039
 		}
1040
-                $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name);
1041
-                 try {
1042
-                        $sth = $this->db->prepare($query);
1043
-                        $sth->execute($query_values);
1044
-                } catch(PDOException $e) {
1045
-                        return "error : ".$e->getMessage();
1046
-                }
1047
-        }
1040
+				$query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name);
1041
+				 try {
1042
+						$sth = $this->db->prepare($query);
1043
+						$sth->execute($query_values);
1044
+				} catch(PDOException $e) {
1045
+						return "error : ".$e->getMessage();
1046
+				}
1047
+		}
1048 1048
 	public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) {
1049 1049
 		global $globalDBdriver;
1050 1050
 		if ($globalDBdriver == 'mysql') {
@@ -1060,14 +1060,14 @@  discard block
 block discarded – undo
1060 1060
 				$query = "UPDATE stats_aircraft SET cnt = cnt+:cnt, aircraft_name = :aircraft_name, aircraft_manufacturer = :aircraft_manufacturer, filter_name = :filter_name WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_aircraft (aircraft_icao,aircraft_name,aircraft_manufacturer,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:aircraft_name,:aircraft_manufacturer,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_aircraft WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1061 1061
 			}
1062 1062
 		}
1063
-                $query_values = array(':aircraft_icao' => $aircraft_icao,':aircraft_name' => $aircraft_name,':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1064
-                 try {
1065
-                        $sth = $this->db->prepare($query);
1066
-                        $sth->execute($query_values);
1067
-                } catch(PDOException $e) {
1068
-                        return "error : ".$e->getMessage();
1069
-                }
1070
-        }
1063
+				$query_values = array(':aircraft_icao' => $aircraft_icao,':aircraft_name' => $aircraft_name,':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1064
+				 try {
1065
+						$sth = $this->db->prepare($query);
1066
+						$sth->execute($query_values);
1067
+				} catch(PDOException $e) {
1068
+						return "error : ".$e->getMessage();
1069
+				}
1070
+		}
1071 1071
 	public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '', $reset = false) {
1072 1072
 		global $globalDBdriver;
1073 1073
 		if ($globalDBdriver == 'mysql') {
@@ -1083,14 +1083,14 @@  discard block
 block discarded – undo
1083 1083
 				$query = "UPDATE stats_airline SET cnt = cnt+:cnt WHERE airline_icao = :airline_icao AND filter_name = :filter_name; INSERT INTO stats_airline (airline_icao,airline_name,cnt,filter_name) SELECT :airline_icao,:airline_name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airline WHERE airline_icao = :airline_icao AND filter_name = :filter_name);"; 
1084 1084
 			}
1085 1085
 		}
1086
-                $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name);
1087
-                 try {
1088
-                        $sth = $this->db->prepare($query);
1089
-                        $sth->execute($query_values);
1090
-                } catch(PDOException $e) {
1091
-                        return "error : ".$e->getMessage();
1092
-                }
1093
-        }
1086
+				$query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name);
1087
+				 try {
1088
+						$sth = $this->db->prepare($query);
1089
+						$sth->execute($query_values);
1090
+				} catch(PDOException $e) {
1091
+						return "error : ".$e->getMessage();
1092
+				}
1093
+		}
1094 1094
 	public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '', $reset = false) {
1095 1095
 		global $globalDBdriver;
1096 1096
 		if ($globalDBdriver == 'mysql') {
@@ -1106,14 +1106,14 @@  discard block
 block discarded – undo
1106 1106
 				$query = "UPDATE stats_owner SET cnt = cnt+:cnt WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_owner (owner_name,cnt,stats_airline,filter_name) SELECT :owner_name,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_owner WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1107 1107
 			}
1108 1108
 		}
1109
-                $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1110
-                 try {
1111
-                        $sth = $this->db->prepare($query);
1112
-                        $sth->execute($query_values);
1113
-                } catch(PDOException $e) {
1114
-                        return "error : ".$e->getMessage();
1115
-                }
1116
-        }
1109
+				$query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1110
+				 try {
1111
+						$sth = $this->db->prepare($query);
1112
+						$sth->execute($query_values);
1113
+				} catch(PDOException $e) {
1114
+						return "error : ".$e->getMessage();
1115
+				}
1116
+		}
1117 1117
 	public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '',$format_source = '',$reset = false) {
1118 1118
 		global $globalDBdriver;
1119 1119
 		if ($globalDBdriver == 'mysql') {
@@ -1129,14 +1129,14 @@  discard block
 block discarded – undo
1129 1129
 				$query = "UPDATE stats_pilot SET cnt = cnt+:cnt, pilot_name = :pilot_name WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source; INSERT INTO stats_pilot (pilot_id,cnt,pilot_name,stats_airline,filter_name,format_source) SELECT :pilot_id,:cnt,:pilot_name,:stats_airline,:filter_name,:format_source WHERE NOT EXISTS (SELECT 1 FROM stats_pilot WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source);"; 
1130 1130
 			}
1131 1131
 		}
1132
-                $query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name,':format_source' => $format_source);
1133
-                 try {
1134
-                        $sth = $this->db->prepare($query);
1135
-                        $sth->execute($query_values);
1136
-                } catch(PDOException $e) {
1137
-                        return "error : ".$e->getMessage();
1138
-                }
1139
-        }
1132
+				$query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name,':format_source' => $format_source);
1133
+				 try {
1134
+						$sth = $this->db->prepare($query);
1135
+						$sth->execute($query_values);
1136
+				} catch(PDOException $e) {
1137
+						return "error : ".$e->getMessage();
1138
+				}
1139
+		}
1140 1140
 	public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '',$reset = false) {
1141 1141
 		global $globalDBdriver;
1142 1142
 		if ($airport_icao != '') {
@@ -1160,8 +1160,8 @@  discard block
 block discarded – undo
1160 1160
 			} catch(PDOException $e) {
1161 1161
 				return "error : ".$e->getMessage();
1162 1162
 			}
1163
-                }
1164
-        }
1163
+				}
1164
+		}
1165 1165
 	public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') {
1166 1166
 		global $globalDBdriver;
1167 1167
 		if ($airport_icao != '') {
@@ -1177,8 +1177,8 @@  discard block
 block discarded – undo
1177 1177
 			} catch(PDOException $e) {
1178 1178
 				return "error : ".$e->getMessage();
1179 1179
 			}
1180
-                }
1181
-        }
1180
+				}
1181
+		}
1182 1182
 	public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '',$reset = false) {
1183 1183
 		global $globalDBdriver;
1184 1184
 		if ($airport_icao != '') {
@@ -1195,15 +1195,15 @@  discard block
 block discarded – undo
1195 1195
 					$query = "UPDATE stats_airport SET arrival = arrival+:arrival WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; 
1196 1196
 				}
1197 1197
 			}
1198
-	                $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival,':date' => date('Y').'-01-01 00:00:00',':stats_airline' => $airline_icao,':filter_name' => $filter_name);
1198
+					$query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival,':date' => date('Y').'-01-01 00:00:00',':stats_airline' => $airline_icao,':filter_name' => $filter_name);
1199 1199
 			 try {
1200
-                    		$sth = $this->db->prepare($query);
1201
-	                        $sth->execute($query_values);
1202
-    		        } catch(PDOException $e) {
1203
-            		        return "error : ".$e->getMessage();
1204
-	                }
1205
-	        }
1206
-        }
1200
+							$sth = $this->db->prepare($query);
1201
+							$sth->execute($query_values);
1202
+					} catch(PDOException $e) {
1203
+							return "error : ".$e->getMessage();
1204
+					}
1205
+			}
1206
+		}
1207 1207
 	public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') {
1208 1208
 		global $globalDBdriver;
1209 1209
 		if ($airport_icao != '') {
@@ -1219,46 +1219,46 @@  discard block
 block discarded – undo
1219 1219
 			} catch(PDOException $e) {
1220 1220
 				return "error : ".$e->getMessage();
1221 1221
 			}
1222
-                }
1223
-        }
1222
+				}
1223
+		}
1224 1224
 
1225 1225
 	public function deleteStat($id) {
1226
-                $query = "DELETE FROM stats WHERE stats_id = :id";
1227
-                $query_values = array(':id' => $id);
1228
-                 try {
1229
-                        $sth = $this->db->prepare($query);
1230
-                        $sth->execute($query_values);
1231
-                } catch(PDOException $e) {
1232
-                        return "error : ".$e->getMessage();
1233
-                }
1234
-        }
1226
+				$query = "DELETE FROM stats WHERE stats_id = :id";
1227
+				$query_values = array(':id' => $id);
1228
+				 try {
1229
+						$sth = $this->db->prepare($query);
1230
+						$sth->execute($query_values);
1231
+				} catch(PDOException $e) {
1232
+						return "error : ".$e->getMessage();
1233
+				}
1234
+		}
1235 1235
 	public function deleteStatFlight($type) {
1236
-                $query = "DELETE FROM stats_flight WHERE stats_type = :type";
1237
-                $query_values = array(':type' => $type);
1238
-                 try {
1239
-                        $sth = $this->db->prepare($query);
1240
-                        $sth->execute($query_values);
1241
-                } catch(PDOException $e) {
1242
-                        return "error : ".$e->getMessage();
1243
-                }
1244
-        }
1236
+				$query = "DELETE FROM stats_flight WHERE stats_type = :type";
1237
+				$query_values = array(':type' => $type);
1238
+				 try {
1239
+						$sth = $this->db->prepare($query);
1240
+						$sth->execute($query_values);
1241
+				} catch(PDOException $e) {
1242
+						return "error : ".$e->getMessage();
1243
+				}
1244
+		}
1245 1245
 	public function deleteStatAirport($type) {
1246
-                $query = "DELETE FROM stats_airport WHERE stats_type = :type";
1247
-                $query_values = array(':type' => $type);
1248
-                 try {
1249
-                        $sth = $this->db->prepare($query);
1250
-                        $sth->execute($query_values);
1251
-                } catch(PDOException $e) {
1252
-                        return "error : ".$e->getMessage();
1253
-                }
1254
-        }
1246
+				$query = "DELETE FROM stats_airport WHERE stats_type = :type";
1247
+				$query_values = array(':type' => $type);
1248
+				 try {
1249
+						$sth = $this->db->prepare($query);
1250
+						$sth->execute($query_values);
1251
+				} catch(PDOException $e) {
1252
+						return "error : ".$e->getMessage();
1253
+				}
1254
+		}
1255 1255
         
1256
-        public function addOldStats() {
1257
-    		global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats,$globalStatsReset,$globalStatsResetYear;
1258
-    		$Common = new Common();
1259
-    		$Connection = new Connection();
1260
-    		date_default_timezone_set('UTC');
1261
-    		$last_update = $this->getLastStatsUpdate('last_update_stats');
1256
+		public function addOldStats() {
1257
+			global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats,$globalStatsReset,$globalStatsResetYear;
1258
+			$Common = new Common();
1259
+			$Connection = new Connection();
1260
+			date_default_timezone_set('UTC');
1261
+			$last_update = $this->getLastStatsUpdate('last_update_stats');
1262 1262
 			if ($globalDebug) echo 'Update stats !'."\n";
1263 1263
 			if (isset($last_update[0]['value'])) {
1264 1264
 				$last_update_day = $last_update[0]['value'];
@@ -1304,24 +1304,24 @@  discard block
 block discarded – undo
1304 1304
 			if ($globalDebug) echo 'Count all departure airports...'."\n";
1305 1305
 			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
1306 1306
 			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
1307
-        		$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1307
+				$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1308 1308
 			if ($globalDebug) echo 'Order departure airports...'."\n";
1309
-	        	$alldata = array();
1309
+				$alldata = array();
1310 1310
 	        	
1311
-    			foreach ($pall as $value) {
1312
-	        		$icao = $value['airport_departure_icao'];
1313
-    				$alldata[$icao] = $value;
1314
-	        	}
1315
-	        	foreach ($dall as $value) {
1316
-    				$icao = $value['airport_departure_icao'];
1317
-        			if (isset($alldata[$icao])) {
1318
-    					$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1319
-        			} else $alldata[$icao] = $value;
1320
-			}
1321
-    			$count = array();
1322
-    			foreach ($alldata as $key => $row) {
1323
-    				$count[$key] = $row['airport_departure_icao_count'];
1324
-        		}
1311
+				foreach ($pall as $value) {
1312
+					$icao = $value['airport_departure_icao'];
1313
+					$alldata[$icao] = $value;
1314
+				}
1315
+				foreach ($dall as $value) {
1316
+					$icao = $value['airport_departure_icao'];
1317
+					if (isset($alldata[$icao])) {
1318
+						$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1319
+					} else $alldata[$icao] = $value;
1320
+			}
1321
+				$count = array();
1322
+				foreach ($alldata as $key => $row) {
1323
+					$count[$key] = $row['airport_departure_icao_count'];
1324
+				}
1325 1325
 			array_multisort($count,SORT_DESC,$alldata);
1326 1326
 			foreach ($alldata as $number) {
1327 1327
 				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);
@@ -1329,25 +1329,25 @@  discard block
 block discarded – undo
1329 1329
 			if ($globalDebug) echo 'Count all arrival airports...'."\n";
1330 1330
 			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
1331 1331
 			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
1332
-        		$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1332
+				$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1333 1333
 			if ($globalDebug) echo 'Order arrival airports...'."\n";
1334
-	        	$alldata = array();
1335
-    			foreach ($pall as $value) {
1336
-	        		$icao = $value['airport_arrival_icao'];
1337
-    				$alldata[$icao] = $value;
1338
-	        	}
1339
-	        	foreach ($dall as $value) {
1340
-    				$icao = $value['airport_arrival_icao'];
1341
-        			if (isset($alldata[$icao])) {
1342
-        				$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1343
-	        		} else $alldata[$icao] = $value;
1344
-    			}
1345
-        		$count = array();
1346
-        		foreach ($alldata as $key => $row) {
1347
-        			$count[$key] = $row['airport_arrival_icao_count'];
1348
-	        	}
1349
-    			array_multisort($count,SORT_DESC,$alldata);
1350
-                        foreach ($alldata as $number) {
1334
+				$alldata = array();
1335
+				foreach ($pall as $value) {
1336
+					$icao = $value['airport_arrival_icao'];
1337
+					$alldata[$icao] = $value;
1338
+				}
1339
+				foreach ($dall as $value) {
1340
+					$icao = $value['airport_arrival_icao'];
1341
+					if (isset($alldata[$icao])) {
1342
+						$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1343
+					} else $alldata[$icao] = $value;
1344
+				}
1345
+				$count = array();
1346
+				foreach ($alldata as $key => $row) {
1347
+					$count[$key] = $row['airport_arrival_icao_count'];
1348
+				}
1349
+				array_multisort($count,SORT_DESC,$alldata);
1350
+						foreach ($alldata as $number) {
1351 1351
 				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);
1352 1352
 			}
1353 1353
 			if ($Connection->tableExists('countries')) {
@@ -1407,8 +1407,8 @@  discard block
 block discarded – undo
1407 1407
 //			$pall = $Spotter->getLast7DaysAirportsDeparture();
1408 1408
   //      		$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
1409 1409
 			$pall = $Spotter->getLast7DaysAirportsDeparture();
1410
-        		$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
1411
-        		/*
1410
+				$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
1411
+				/*
1412 1412
 	        	$alldata = array();
1413 1413
     			foreach ($pall as $value) {
1414 1414
 	        		$icao = $value['departure_airport_icao'];
@@ -1427,29 +1427,29 @@  discard block
 block discarded – undo
1427 1427
 	        	}
1428 1428
     			array_multisort($count,SORT_DESC,$alldata);
1429 1429
     			*/
1430
-    			foreach ($dall as $value) {
1431
-    				$icao = $value['departure_airport_icao'];
1432
-    				$ddate = $value['date'];
1433
-    				$find = false;
1434
-    				foreach ($pall as $pvalue) {
1435
-    					if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1436
-    						$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1437
-    						$find = true;
1438
-    						break;
1439
-    					}
1440
-    				}
1441
-    				if ($find === false) {
1442
-    					$pall[] = $value;
1443
-    				}
1444
-    			}
1445
-    			$alldata = $pall;
1430
+				foreach ($dall as $value) {
1431
+					$icao = $value['departure_airport_icao'];
1432
+					$ddate = $value['date'];
1433
+					$find = false;
1434
+					foreach ($pall as $pvalue) {
1435
+						if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1436
+							$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1437
+							$find = true;
1438
+							break;
1439
+						}
1440
+					}
1441
+					if ($find === false) {
1442
+						$pall[] = $value;
1443
+					}
1444
+				}
1445
+				$alldata = $pall;
1446 1446
 			foreach ($alldata as $number) {
1447 1447
 				$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']);
1448 1448
 			}
1449 1449
 			echo '...Arrival'."\n";
1450 1450
 			$pall = $Spotter->getLast7DaysAirportsArrival();
1451
-        		$dall = $Spotter->getLast7DaysDetectedAirportsArrival();
1452
-        		/*
1451
+				$dall = $Spotter->getLast7DaysDetectedAirportsArrival();
1452
+				/*
1453 1453
 	        	$alldata = array();
1454 1454
     			foreach ($pall as $value) {
1455 1455
 	        		$icao = $value['arrival_airport_icao'];
@@ -1469,22 +1469,22 @@  discard block
 block discarded – undo
1469 1469
     			*/
1470 1470
 
1471 1471
 
1472
-    			foreach ($dall as $value) {
1473
-    				$icao = $value['arrival_airport_icao'];
1474
-    				$ddate = $value['date'];
1475
-    				$find = false;
1476
-    				foreach ($pall as $pvalue) {
1477
-    					if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1478
-    						$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1479
-    						$find = true;
1480
-    						break;
1481
-    					}
1482
-    				}
1483
-    				if ($find === false) {
1484
-    					$pall[] = $value;
1485
-    				}
1486
-    			}
1487
-    			$alldata = $pall;
1472
+				foreach ($dall as $value) {
1473
+					$icao = $value['arrival_airport_icao'];
1474
+					$ddate = $value['date'];
1475
+					$find = false;
1476
+					foreach ($pall as $pvalue) {
1477
+						if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1478
+							$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1479
+							$find = true;
1480
+							break;
1481
+						}
1482
+					}
1483
+					if ($find === false) {
1484
+						$pall[] = $value;
1485
+					}
1486
+				}
1487
+				$alldata = $pall;
1488 1488
 			foreach ($alldata as $number) {
1489 1489
 				$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']);
1490 1490
 			}
@@ -1551,51 +1551,51 @@  discard block
 block discarded – undo
1551 1551
 			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
1552 1552
 			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
1553 1553
 			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
1554
-       			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
1554
+	   			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
1555 1555
 			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
1556
-	        	//$alldata = array();
1557
-    			foreach ($dall as $value) {
1558
-    				$icao = $value['airport_departure_icao'];
1559
-    				$dicao = $value['airline_icao'];
1560
-    				$find = false;
1561
-    				foreach ($pall as $pvalue) {
1562
-    					if ($pvalue['airport_departure_icao'] == $icao && $pvalue['airline_icao'] = $dicao) {
1563
-    						$pvalue['airport_departure_icao_count'] = $pvalue['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1564
-    						$find = true;
1565
-    						break;
1566
-    					}
1567
-    				}
1568
-    				if ($find === false) {
1569
-    					$pall[] = $value;
1570
-    				}
1571
-    			}
1572
-    			$alldata = $pall;
1556
+				//$alldata = array();
1557
+				foreach ($dall as $value) {
1558
+					$icao = $value['airport_departure_icao'];
1559
+					$dicao = $value['airline_icao'];
1560
+					$find = false;
1561
+					foreach ($pall as $pvalue) {
1562
+						if ($pvalue['airport_departure_icao'] == $icao && $pvalue['airline_icao'] = $dicao) {
1563
+							$pvalue['airport_departure_icao_count'] = $pvalue['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1564
+							$find = true;
1565
+							break;
1566
+						}
1567
+					}
1568
+					if ($find === false) {
1569
+						$pall[] = $value;
1570
+					}
1571
+				}
1572
+				$alldata = $pall;
1573 1573
 			foreach ($alldata as $number) {
1574 1574
 				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);
1575 1575
 			}
1576 1576
 			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
1577 1577
 			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
1578 1578
 			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
1579
-        		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
1579
+				$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
1580 1580
 			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
1581
-	        	//$alldata = array();
1582
-    			foreach ($dall as $value) {
1583
-    				$icao = $value['airport_arrival_icao'];
1584
-    				$dicao = $value['airline_icao'];
1585
-    				$find = false;
1586
-    				foreach ($pall as $pvalue) {
1587
-    					if ($pvalue['airport_arrival_icao'] == $icao && $pvalue['airline_icao'] = $dicao) {
1588
-    						$pvalue['airport_arrival_icao_count'] = $pvalue['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1589
-    						$find = true;
1590
-    						break;
1591
-    					}
1592
-    				}
1593
-    				if ($find === false) {
1594
-    					$pall[] = $value;
1595
-    				}
1596
-    			}
1597
-    			$alldata = $pall;
1598
-                        foreach ($alldata as $number) {
1581
+				//$alldata = array();
1582
+				foreach ($dall as $value) {
1583
+					$icao = $value['airport_arrival_icao'];
1584
+					$dicao = $value['airline_icao'];
1585
+					$find = false;
1586
+					foreach ($pall as $pvalue) {
1587
+						if ($pvalue['airport_arrival_icao'] == $icao && $pvalue['airline_icao'] = $dicao) {
1588
+							$pvalue['airport_arrival_icao_count'] = $pvalue['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1589
+							$find = true;
1590
+							break;
1591
+						}
1592
+					}
1593
+					if ($find === false) {
1594
+						$pall[] = $value;
1595
+					}
1596
+				}
1597
+				$alldata = $pall;
1598
+						foreach ($alldata as $number) {
1599 1599
 				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);
1600 1600
 			}
1601 1601
 			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
@@ -1628,47 +1628,47 @@  discard block
 block discarded – undo
1628 1628
 			}
1629 1629
 			if ($globalDebug) echo '...Departure'."\n";
1630 1630
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
1631
-        		$dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines();
1632
-    			foreach ($dall as $value) {
1633
-    				$icao = $value['departure_airport_icao'];
1634
-    				$airline = $value['airline_icao'];
1635
-    				$ddate = $value['date'];
1636
-    				$find = false;
1637
-    				foreach ($pall as $pvalue) {
1638
-    					if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] = $airline) {
1639
-    						$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1640
-    						$find = true;
1641
-    						break;
1642
-    					}
1643
-    				}
1644
-    				if ($find === false) {
1645
-    					$pall[] = $value;
1646
-    				}
1647
-    			}
1648
-    			$alldata = $pall;
1631
+				$dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines();
1632
+				foreach ($dall as $value) {
1633
+					$icao = $value['departure_airport_icao'];
1634
+					$airline = $value['airline_icao'];
1635
+					$ddate = $value['date'];
1636
+					$find = false;
1637
+					foreach ($pall as $pvalue) {
1638
+						if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] = $airline) {
1639
+							$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1640
+							$find = true;
1641
+							break;
1642
+						}
1643
+					}
1644
+					if ($find === false) {
1645
+						$pall[] = $value;
1646
+					}
1647
+				}
1648
+				$alldata = $pall;
1649 1649
 			foreach ($alldata as $number) {
1650 1650
 				$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']);
1651 1651
 			}
1652 1652
 			if ($globalDebug) echo '...Arrival'."\n";
1653 1653
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
1654
-        		$dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines();
1655
-    			foreach ($dall as $value) {
1656
-    				$icao = $value['arrival_airport_icao'];
1657
-    				$airline = $value['airline_icao'];
1658
-    				$ddate = $value['date'];
1659
-    				$find = false;
1660
-    				foreach ($pall as $pvalue) {
1661
-    					if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] == $airline) {
1662
-    						$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1663
-    						$find = true;
1664
-    						break;
1665
-    					}
1666
-    				}
1667
-    				if ($find === false) {
1668
-    					$pall[] = $value;
1669
-    				}
1670
-    			}
1671
-    			$alldata = $pall;
1654
+				$dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines();
1655
+				foreach ($dall as $value) {
1656
+					$icao = $value['arrival_airport_icao'];
1657
+					$airline = $value['airline_icao'];
1658
+					$ddate = $value['date'];
1659
+					$find = false;
1660
+					foreach ($pall as $pvalue) {
1661
+						if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] == $airline) {
1662
+							$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1663
+							$find = true;
1664
+							break;
1665
+						}
1666
+					}
1667
+					if ($find === false) {
1668
+						$pall[] = $value;
1669
+					}
1670
+				}
1671
+				$alldata = $pall;
1672 1672
 			foreach ($alldata as $number) {
1673 1673
 				$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']);
1674 1674
 			}
@@ -1739,44 +1739,44 @@  discard block
 block discarded – undo
1739 1739
 					$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source'],$reset);
1740 1740
 				}
1741 1741
 				$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter);
1742
-	       			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
1743
-		        	$alldata = array();
1744
-	    			foreach ($pall as $value) {
1745
-		        		$icao = $value['airport_departure_icao'];
1746
-    					$alldata[$icao] = $value;
1747
-	    			}
1748
-		        	foreach ($dall as $value) {
1749
-	    				$icao = $value['airport_departure_icao'];
1750
-        				if (isset($alldata[$icao])) {
1751
-    						$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1752
-        				} else $alldata[$icao] = $value;
1753
-				}
1754
-	    			$count = array();
1755
-    				foreach ($alldata as $key => $row) {
1756
-    					$count[$key] = $row['airport_departure_icao_count'];
1757
-    				}
1742
+		   			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
1743
+					$alldata = array();
1744
+					foreach ($pall as $value) {
1745
+						$icao = $value['airport_departure_icao'];
1746
+						$alldata[$icao] = $value;
1747
+					}
1748
+					foreach ($dall as $value) {
1749
+						$icao = $value['airport_departure_icao'];
1750
+						if (isset($alldata[$icao])) {
1751
+							$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1752
+						} else $alldata[$icao] = $value;
1753
+				}
1754
+					$count = array();
1755
+					foreach ($alldata as $key => $row) {
1756
+						$count[$key] = $row['airport_departure_icao_count'];
1757
+					}
1758 1758
 				array_multisort($count,SORT_DESC,$alldata);
1759 1759
 				foreach ($alldata as $number) {
1760
-    					echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'',$filter_name,$reset);
1760
+						echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'',$filter_name,$reset);
1761 1761
 				}
1762 1762
 				$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter);
1763
-    				$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter);
1763
+					$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter);
1764 1764
 				$alldata = array();
1765
-    				foreach ($pall as $value) {
1766
-		        		$icao = $value['airport_arrival_icao'];
1767
-    					$alldata[$icao] = $value;
1768
-	    			}
1769
-		        	foreach ($dall as $value) {
1770
-	    				$icao = $value['airport_arrival_icao'];
1771
-        				if (isset($alldata[$icao])) {
1772
-        					$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1773
-		        		} else $alldata[$icao] = $value;
1774
-	    			}
1775
-        			$count = array();
1776
-        			foreach ($alldata as $key => $row) {
1777
-    					$count[$key] = $row['airport_arrival_icao_count'];
1778
-		        	}
1779
-        			array_multisort($count,SORT_DESC,$alldata);
1765
+					foreach ($pall as $value) {
1766
+						$icao = $value['airport_arrival_icao'];
1767
+						$alldata[$icao] = $value;
1768
+					}
1769
+					foreach ($dall as $value) {
1770
+						$icao = $value['airport_arrival_icao'];
1771
+						if (isset($alldata[$icao])) {
1772
+							$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1773
+						} else $alldata[$icao] = $value;
1774
+					}
1775
+					$count = array();
1776
+					foreach ($alldata as $key => $row) {
1777
+						$count[$key] = $row['airport_arrival_icao_count'];
1778
+					}
1779
+					array_multisort($count,SORT_DESC,$alldata);
1780 1780
 				foreach ($alldata as $number) {
1781 1781
 					echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'',$filter_name,$reset);
1782 1782
 				}
@@ -1809,45 +1809,45 @@  discard block
 block discarded – undo
1809 1809
 				}
1810 1810
 				echo '...Departure'."\n";
1811 1811
 				$pall = $Spotter->getLast7DaysAirportsDeparture('',$filter);
1812
-        			$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter);
1812
+					$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter);
1813 1813
 				foreach ($dall as $value) {
1814
-    					$icao = $value['departure_airport_icao'];
1815
-    					$ddate = $value['date'];
1816
-    					$find = false;
1817
-    					foreach ($pall as $pvalue) {
1818
-    						if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1819
-    							$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1820
-	    						$find = true;
1821
-    							break;
1822
-    						}
1823
-    					}
1824
-    					if ($find === false) {
1825
-    						$pall[] = $value;
1826
-	    				}
1827
-    				}
1828
-	    			$alldata = $pall;
1814
+						$icao = $value['departure_airport_icao'];
1815
+						$ddate = $value['date'];
1816
+						$find = false;
1817
+						foreach ($pall as $pvalue) {
1818
+							if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1819
+								$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1820
+								$find = true;
1821
+								break;
1822
+							}
1823
+						}
1824
+						if ($find === false) {
1825
+							$pall[] = $value;
1826
+						}
1827
+					}
1828
+					$alldata = $pall;
1829 1829
 				foreach ($alldata as $number) {
1830 1830
 					$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],'',$filter_name);
1831 1831
 				}
1832 1832
 				echo '...Arrival'."\n";
1833 1833
 				$pall = $Spotter->getLast7DaysAirportsArrival('',$filter);
1834
-    				$dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter);
1834
+					$dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter);
1835 1835
 				foreach ($dall as $value) {
1836 1836
 					$icao = $value['arrival_airport_icao'];
1837 1837
 					$ddate = $value['date'];
1838
-    					$find = false;
1838
+						$find = false;
1839 1839
 					foreach ($pall as $pvalue) {
1840
-    						if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1841
-    							$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1842
-    							$find = true;
1843
-    							break;
1844
-	    					}
1845
-    					}
1846
-    					if ($find === false) {
1847
-    						$pall[] = $value;
1848
-	    				}
1849
-    				}
1850
-    				$alldata = $pall;
1840
+							if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1841
+								$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1842
+								$find = true;
1843
+								break;
1844
+							}
1845
+						}
1846
+						if ($find === false) {
1847
+							$pall[] = $value;
1848
+						}
1849
+					}
1850
+					$alldata = $pall;
1851 1851
 				foreach ($alldata as $number) {
1852 1852
 					$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],'',$filter_name);
1853 1853
 				}
Please login to merge, or discard this patch.
Spacing   +312 added lines, -312 removed lines patch added patch discarded remove patch
@@ -17,14 +17,14 @@  discard block
 block discarded – undo
17 17
 		$this->db = $Connection->db();
18 18
         }
19 19
               
20
-	public function addLastStatsUpdate($type,$stats_date) {
20
+	public function addLastStatsUpdate($type, $stats_date) {
21 21
                 $query = "DELETE FROM config WHERE name = :type;
22 22
             		INSERT INTO config (name,value) VALUES (:type,:stats_date);";
23
-                $query_values = array('type' => $type,':stats_date' => $stats_date);
23
+                $query_values = array('type' => $type, ':stats_date' => $stats_date);
24 24
                  try {
25 25
                         $sth = $this->db->prepare($query);
26 26
                         $sth->execute($query_values);
27
-                } catch(PDOException $e) {
27
+                } catch (PDOException $e) {
28 28
                         return "error : ".$e->getMessage();
29 29
                 }
30 30
         }
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
                  try {
35 35
                         $sth = $this->db->prepare($query);
36 36
                         $sth->execute(array(':type' => $type));
37
-                } catch(PDOException $e) {
37
+                } catch (PDOException $e) {
38 38
                         echo "error : ".$e->getMessage();
39 39
                 }
40 40
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
                  try {
55 55
                         $sth = $this->db->prepare($query);
56 56
                         $sth->execute(array(':filter_name' => $filter_name));
57
-                } catch(PDOException $e) {
57
+                } catch (PDOException $e) {
58 58
                         return "error : ".$e->getMessage();
59 59
                 }
60 60
         }
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
                  try {
65 65
                         $sth = $this->db->prepare($query);
66 66
                         $sth->execute();
67
-                } catch(PDOException $e) {
67
+                } catch (PDOException $e) {
68 68
                         return "error : ".$e->getMessage();
69 69
                 }
70 70
                 
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
                  try {
73 73
                         $sth = $this->db->prepare($query);
74 74
                         $sth->execute(array(':filter_name' => $filter_name));
75
-                } catch(PDOException $e) {
75
+                } catch (PDOException $e) {
76 76
                         return "error : ".$e->getMessage();
77 77
                 }
78 78
         }
@@ -82,43 +82,43 @@  discard block
 block discarded – undo
82 82
                  try {
83 83
                         $sth = $this->db->prepare($query);
84 84
                         $sth->execute(array(':filter_name' => $filter_name));
85
-                } catch(PDOException $e) {
85
+                } catch (PDOException $e) {
86 86
                         echo "error : ".$e->getMessage();
87 87
                 }
88 88
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
89 89
                 return $all;
90 90
         }
91
-	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
91
+	public function getAllAircraftTypes($stats_airline = '', $filter_name = '') {
92 92
 		if ($filter_name == '') $filter_name = $this->filter_name;
93 93
                 $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
94 94
                  try {
95 95
                         $sth = $this->db->prepare($query);
96
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
97
-                } catch(PDOException $e) {
96
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
97
+                } catch (PDOException $e) {
98 98
                         echo "error : ".$e->getMessage();
99 99
                 }
100 100
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
101 101
                 return $all;
102 102
         }
103
-	public function getAllManufacturers($stats_airline = '',$filter_name = '') {
103
+	public function getAllManufacturers($stats_airline = '', $filter_name = '') {
104 104
 		if ($filter_name == '') $filter_name = $this->filter_name;
105 105
                 $query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC";
106 106
                  try {
107 107
                         $sth = $this->db->prepare($query);
108
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
109
-                } catch(PDOException $e) {
108
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
109
+                } catch (PDOException $e) {
110 110
                         echo "error : ".$e->getMessage();
111 111
                 }
112 112
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
113 113
                 return $all;
114 114
         }
115
-	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
115
+	public function getAllAirportNames($stats_airline = '', $filter_name = '') {
116 116
 		if ($filter_name == '') $filter_name = $this->filter_name;
117 117
                 $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC";
118 118
                  try {
119 119
                         $sth = $this->db->prepare($query);
120
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
121
-                } catch(PDOException $e) {
120
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
121
+                } catch (PDOException $e) {
122 122
                         echo "error : ".$e->getMessage();
123 123
                 }
124 124
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -133,22 +133,22 @@  discard block
 block discarded – undo
133 133
 		else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
134 134
                  try {
135 135
                         $sth = $this->db->prepare($query);
136
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
137
-                } catch(PDOException $e) {
136
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
137
+                } catch (PDOException $e) {
138 138
                         echo "error : ".$e->getMessage();
139 139
                 }
140 140
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
141 141
                 if (empty($all)) {
142 142
             	    $filters = array('airlines' => array($stats_airline));
143 143
             	    if ($filter_name != '') {
144
-            		    $filters = array_merge($filters,$globalStatsFilters[$filter_name]);
144
+            		    $filters = array_merge($filters, $globalStatsFilters[$filter_name]);
145 145
             	    }
146 146
             	    $Spotter = new Spotter($this->db);
147
-            	    $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters);
147
+            	    $all = $Spotter->countAllAircraftTypes($limit, 0, '', $filters);
148 148
                 }
149 149
                 return $all;
150 150
 	}
151
-	public function countAllAirlineCountries($limit = true,$filter_name = '') {
151
+	public function countAllAirlineCountries($limit = true, $filter_name = '') {
152 152
 		global $globalStatsFilters;
153 153
 		if ($filter_name == '') $filter_name = $this->filter_name;
154 154
 		if ($limit) $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0";
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
                  try {
157 157
                         $sth = $this->db->prepare($query);
158 158
                         $sth->execute(array(':filter_name' => $filter_name));
159
-                } catch(PDOException $e) {
159
+                } catch (PDOException $e) {
160 160
                         echo "error : ".$e->getMessage();
161 161
                 }
162 162
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -164,28 +164,28 @@  discard block
 block discarded – undo
164 164
             		$Spotter = new Spotter($this->db);
165 165
             		$filters = array();
166 166
             		if ($filter_name != '') {
167
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
167
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
168 168
 			}
169
-            		$all = $Spotter->countAllAirlineCountries($limit,$filters);
169
+            		$all = $Spotter->countAllAirlineCountries($limit, $filters);
170 170
                 }
171 171
                 return $all;
172 172
 	}
173
-	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '') {
173
+	public function countAllAircraftManufacturers($limit = true, $stats_airline = '', $filter_name = '') {
174 174
 		global $globalStatsFilters;
175 175
 		if ($filter_name == '') $filter_name = $this->filter_name;
176 176
 		if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
177 177
 		else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
178 178
                  try {
179 179
                         $sth = $this->db->prepare($query);
180
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
181
-                } catch(PDOException $e) {
180
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
181
+                } catch (PDOException $e) {
182 182
                         echo "error : ".$e->getMessage();
183 183
                 }
184 184
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
185 185
                 if (empty($all)) {
186 186
             		$filters = array('airlines' => array($stats_airline));
187 187
             		if ($filter_name != '') {
188
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
188
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
189 189
 			}
190 190
             		$Spotter = new Spotter($this->db);
191 191
 			$all = $Spotter->countAllAircraftManufacturers($filters);
@@ -200,18 +200,18 @@  discard block
 block discarded – undo
200 200
 		else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC";
201 201
                  try {
202 202
                         $sth = $this->db->prepare($query);
203
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
204
-                } catch(PDOException $e) {
203
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
204
+                } catch (PDOException $e) {
205 205
                         echo "error : ".$e->getMessage();
206 206
                 }
207 207
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
208 208
                 if (empty($all)) {
209 209
 			$filters = array('airlines' => array($stats_airline));
210 210
 			if ($filter_name != '') {
211
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
211
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
212 212
 			}
213 213
 			$Spotter = new Spotter($this->db);
214
-			$all = $Spotter->countAllArrivalCountries($limit,$filters);
214
+			$all = $Spotter->countAllArrivalCountries($limit, $filters);
215 215
                 }
216 216
                 return $all;
217 217
 	}
@@ -222,15 +222,15 @@  discard block
 block discarded – undo
222 222
 		else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC";
223 223
                  try {
224 224
                         $sth = $this->db->prepare($query);
225
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
226
-                } catch(PDOException $e) {
225
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
226
+                } catch (PDOException $e) {
227 227
                         echo "error : ".$e->getMessage();
228 228
                 }
229 229
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
230 230
                 if (empty($all)) {
231 231
 			$filters = array('airlines' => array($stats_airline));
232 232
 			if ($filter_name != '') {
233
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
233
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
234 234
 			}
235 235
 			$Spotter = new Spotter($this->db);
236 236
 			$all = $Spotter->countAllDepartureCountries($filters);
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
                 return $all;
239 239
 	}
240 240
 
241
-	public function countAllAirlines($limit = true,$filter_name = '') {
241
+	public function countAllAirlines($limit = true, $filter_name = '') {
242 242
 		global $globalStatsFilters;
243 243
 		if ($filter_name == '') $filter_name = $this->filter_name;
244 244
 		if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
                  try {
247 247
                         $sth = $this->db->prepare($query);
248 248
                         $sth->execute(array(':filter_name' => $filter_name));
249
-                } catch(PDOException $e) {
249
+                } catch (PDOException $e) {
250 250
                         echo "error : ".$e->getMessage();
251 251
                 }
252 252
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -254,58 +254,58 @@  discard block
 block discarded – undo
254 254
 	                $Spotter = new Spotter($this->db);
255 255
             		$filters = array();
256 256
             		if ($filter_name != '') {
257
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
257
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
258 258
 			}
259 259
 
260
-    		        $all = $Spotter->countAllAirlines($limit,0,'',$filters);
260
+    		        $all = $Spotter->countAllAirlines($limit, 0, '', $filters);
261 261
                 }
262 262
                 return $all;
263 263
 	}
264
-	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '') {
264
+	public function countAllAircraftRegistrations($limit = true, $stats_airline = '', $filter_name = '') {
265 265
 		global $globalStatsFilters;
266 266
 		if ($filter_name == '') $filter_name = $this->filter_name;
267 267
 		if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0";
268 268
 		else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC";
269 269
                  try {
270 270
                         $sth = $this->db->prepare($query);
271
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
272
-                } catch(PDOException $e) {
271
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
272
+                } catch (PDOException $e) {
273 273
                         echo "error : ".$e->getMessage();
274 274
                 }
275 275
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
276 276
                 if (empty($all)) {
277 277
 			$filters = array('airlines' => array($stats_airline));
278 278
 			if ($filter_name != '') {
279
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
279
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
280 280
 			}
281 281
 	                $Spotter = new Spotter($this->db);
282
-    		        $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters);
282
+    		        $all = $Spotter->countAllAircraftRegistrations($limit, 0, '', $filters);
283 283
                 }
284 284
                 return $all;
285 285
 	}
286
-	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '') {
286
+	public function countAllCallsigns($limit = true, $stats_airline = '', $filter_name = '') {
287 287
 		global $globalStatsFilters;
288 288
 		if ($filter_name == '') $filter_name = $this->filter_name;
289 289
 		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";
290 290
 		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";
291 291
 		 try {
292 292
 			$sth = $this->db->prepare($query);
293
-			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
294
-		} catch(PDOException $e) {
293
+			$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
294
+		} catch (PDOException $e) {
295 295
 			echo "error : ".$e->getMessage();
296 296
 		}
297 297
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
298 298
 		if (empty($all)) {
299 299
 			$filters = array('airlines' => array($stats_airline));
300 300
 			if ($filter_name != '') {
301
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
301
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
302 302
 			}
303 303
 			$Spotter = new Spotter($this->db);
304
-			$all = $Spotter->countAllCallsigns($limit,0,'',$filters);
304
+			$all = $Spotter->countAllCallsigns($limit, 0, '', $filters);
305 305
 		}
306 306
 		return $all;
307 307
 	}
308
-	public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '') {
308
+	public function countAllFlightOverCountries($limit = true, $stats_airline = '', $filter_name = '') {
309 309
 		$Connection = new Connection();
310 310
 		if ($filter_name == '') $filter_name = $this->filter_name;
311 311
 		if ($Connection->tableExists('countries')) {
@@ -313,8 +313,8 @@  discard block
 block discarded – undo
313 313
 			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";
314 314
 			 try {
315 315
 				$sth = $this->db->prepare($query);
316
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
317
-			} catch(PDOException $e) {
316
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
317
+			} catch (PDOException $e) {
318 318
 				echo "error : ".$e->getMessage();
319 319
 			}
320 320
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -329,70 +329,70 @@  discard block
 block discarded – undo
329 329
 			return array();
330 330
 		}
331 331
 	}
332
-	public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '') {
332
+	public function countAllPilots($limit = true, $stats_airline = '', $filter_name = '') {
333 333
 		global $globalStatsFilters;
334 334
 		if ($filter_name == '') $filter_name = $this->filter_name;
335 335
 		if ($limit) $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0";
336 336
 		else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC";
337 337
                  try {
338 338
                         $sth = $this->db->prepare($query);
339
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
340
-                } catch(PDOException $e) {
339
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
340
+                } catch (PDOException $e) {
341 341
                         echo "error : ".$e->getMessage();
342 342
                 }
343 343
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
344 344
                 if (empty($all)) {
345 345
 			$filters = array('airlines' => array($stats_airline));
346 346
 			if ($filter_name != '') {
347
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
347
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
348 348
 			}
349 349
             		$Spotter = new Spotter($this->db);
350
-            		$all = $Spotter->countAllPilots($limit,0,'',$filters);
350
+            		$all = $Spotter->countAllPilots($limit, 0, '', $filters);
351 351
                 }
352 352
                 return $all;
353 353
 	}
354
-	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '') {
354
+	public function countAllOwners($limit = true, $stats_airline = '', $filter_name = '') {
355 355
 		global $globalStatsFilters;
356 356
 		if ($filter_name == '') $filter_name = $this->filter_name;
357 357
 		if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
358 358
 		else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC";
359 359
                  try {
360 360
                         $sth = $this->db->prepare($query);
361
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
362
-                } catch(PDOException $e) {
361
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
362
+                } catch (PDOException $e) {
363 363
                         echo "error : ".$e->getMessage();
364 364
                 }
365 365
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
366 366
                 if (empty($all)) {
367 367
 			$filters = array('airlines' => array($stats_airline));
368 368
 			if ($filter_name != '') {
369
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
369
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
370 370
 			}
371 371
             		$Spotter = new Spotter($this->db);
372
-            		$all = $Spotter->countAllOwners($limit,0,'',$filters);
372
+            		$all = $Spotter->countAllOwners($limit, 0, '', $filters);
373 373
                 }
374 374
                 return $all;
375 375
 	}
376
-	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '') {
376
+	public function countAllDepartureAirports($limit = true, $stats_airline = '', $filter_name = '') {
377 377
 		global $globalStatsFilters;
378 378
 		if ($filter_name == '') $filter_name = $this->filter_name;
379 379
 		if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
380 380
 		else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
381 381
                  try {
382 382
                         $sth = $this->db->prepare($query);
383
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
384
-                } catch(PDOException $e) {
383
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
384
+                } catch (PDOException $e) {
385 385
                         echo "error : ".$e->getMessage();
386 386
                 }
387 387
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
388 388
                 if (empty($all)) {
389 389
 			$filters = array('airlines' => array($stats_airline));
390 390
             		if ($filter_name != '') {
391
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
391
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
392 392
 			}
393 393
             		$Spotter = new Spotter($this->db);
394
-            		$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters);
395
-        		$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters);
394
+            		$pall = $Spotter->countAllDepartureAirports($limit, 0, '', $filters);
395
+        		$dall = $Spotter->countAllDetectedDepartureAirports($limit, 0, '', $filters);
396 396
         		$all = array();
397 397
         		foreach ($pall as $value) {
398 398
         			$icao = $value['airport_departure_icao'];
@@ -409,30 +409,30 @@  discard block
 block discarded – undo
409 409
         		foreach ($all as $key => $row) {
410 410
         			$count[$key] = $row['airport_departure_icao_count'];
411 411
         		}
412
-        		array_multisort($count,SORT_DESC,$all);
412
+        		array_multisort($count, SORT_DESC, $all);
413 413
                 }
414 414
                 return $all;
415 415
 	}
416
-	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '') {
416
+	public function countAllArrivalAirports($limit = true, $stats_airline = '', $filter_name = '') {
417 417
 		global $globalStatsFilters;
418 418
 		if ($filter_name == '') $filter_name = $this->filter_name;
419 419
 		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 FROM stats_airport WHERE 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";
420 420
 		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 FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
421 421
 		try {
422 422
 			$sth = $this->db->prepare($query);
423
-			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
424
-		} catch(PDOException $e) {
423
+			$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
424
+		} catch (PDOException $e) {
425 425
 			echo "error : ".$e->getMessage();
426 426
 		}
427 427
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
428 428
 		if (empty($all)) {
429 429
 			$filters = array('airlines' => array($stats_airline));
430 430
 			if ($filter_name != '') {
431
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
431
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
432 432
 			}
433 433
 			$Spotter = new Spotter($this->db);
434
-			$pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters);
435
-			$dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters);
434
+			$pall = $Spotter->countAllArrivalAirports($limit, 0, '', false, $filters);
435
+			$dall = $Spotter->countAllDetectedArrivalAirports($limit, 0, '', false, $filters);
436 436
         		$all = array();
437 437
         		foreach ($pall as $value) {
438 438
         			$icao = $value['airport_arrival_icao'];
@@ -449,12 +449,12 @@  discard block
 block discarded – undo
449 449
         		foreach ($all as $key => $row) {
450 450
         			$count[$key] = $row['airport_arrival_icao_count'];
451 451
         		}
452
-        		array_multisort($count,SORT_DESC,$all);
452
+        		array_multisort($count, SORT_DESC, $all);
453 453
                 }
454 454
  
455 455
                 return $all;
456 456
 	}
457
-	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
457
+	public function countAllMonthsLastYear($limit = true, $stats_airline = '', $filter_name = '') {
458 458
 		global $globalDBdriver, $globalStatsFilters;
459 459
 		if ($filter_name == '') $filter_name = $this->filter_name;
460 460
 		if ($globalDBdriver == 'mysql') {
@@ -464,18 +464,18 @@  discard block
 block discarded – undo
464 464
 			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";
465 465
 			else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
466 466
 		}
467
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
467
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
468 468
                  try {
469 469
                         $sth = $this->db->prepare($query);
470 470
                         $sth->execute($query_data);
471
-                } catch(PDOException $e) {
471
+                } catch (PDOException $e) {
472 472
                         echo "error : ".$e->getMessage();
473 473
                 }
474 474
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
475 475
                 if (empty($all)) {
476 476
 			$filters = array('airlines' => array($stats_airline));
477 477
 			if ($filter_name != '') {
478
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
478
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
479 479
 			}
480 480
             		$Spotter = new Spotter($this->db);
481 481
             		$all = $Spotter->countAllMonthsLastYear($filters);
@@ -484,29 +484,29 @@  discard block
 block discarded – undo
484 484
                 return $all;
485 485
 	}
486 486
 	
487
-	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
487
+	public function countAllDatesLastMonth($stats_airline = '', $filter_name = '') {
488 488
 		global $globalStatsFilters;
489 489
 		if ($filter_name == '') $filter_name = $this->filter_name;
490 490
 		$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline = :stats_airline AND filter_name = :filter_name";
491
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
491
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
492 492
                  try {
493 493
                         $sth = $this->db->prepare($query);
494 494
                         $sth->execute($query_data);
495
-                } catch(PDOException $e) {
495
+                } catch (PDOException $e) {
496 496
                         echo "error : ".$e->getMessage();
497 497
                 }
498 498
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
499 499
                 if (empty($all)) {
500 500
 			$filters = array('airlines' => array($stats_airline));
501 501
 			if ($filter_name != '') {
502
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
502
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
503 503
 			}
504 504
             		$Spotter = new Spotter($this->db);
505 505
             		$all = $Spotter->countAllDatesLastMonth($filters);
506 506
                 }
507 507
                 return $all;
508 508
 	}
509
-	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
509
+	public function countAllDatesLast7Days($stats_airline = '', $filter_name = '') {
510 510
 		global $globalDBdriver, $globalStatsFilters;
511 511
 		if ($filter_name == '') $filter_name = $this->filter_name;
512 512
 		if ($globalDBdriver == 'mysql') {
@@ -514,40 +514,40 @@  discard block
 block discarded – undo
514 514
 		} else {
515 515
 			$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
516 516
 		}
517
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
517
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
518 518
                  try {
519 519
                         $sth = $this->db->prepare($query);
520 520
                         $sth->execute($query_data);
521
-                } catch(PDOException $e) {
521
+                } catch (PDOException $e) {
522 522
                         echo "error : ".$e->getMessage();
523 523
                 }
524 524
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
525 525
                 if (empty($all)) {
526 526
 			$filters = array('airlines' => array($stats_airline));
527 527
 			if ($filter_name != '') {
528
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
528
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
529 529
 			}
530 530
             		$Spotter = new Spotter($this->db);
531 531
             		$all = $Spotter->countAllDatesLast7Days($filters);
532 532
                 }
533 533
                 return $all;
534 534
 	}
535
-	public function countAllDates($stats_airline = '',$filter_name = '') {
535
+	public function countAllDates($stats_airline = '', $filter_name = '') {
536 536
 		global $globalStatsFilters;
537 537
 		if ($filter_name == '') $filter_name = $this->filter_name;
538 538
 		$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline = :stats_airline AND filter_name = :filter_name";
539
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
539
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
540 540
                  try {
541 541
                         $sth = $this->db->prepare($query);
542 542
                         $sth->execute($query_data);
543
-                } catch(PDOException $e) {
543
+                } catch (PDOException $e) {
544 544
                         echo "error : ".$e->getMessage();
545 545
                 }
546 546
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
547 547
                 if (empty($all)) {
548 548
 			$filters = array('airlines' => array($stats_airline));
549 549
 			if ($filter_name != '') {
550
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
550
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
551 551
 			}
552 552
             		$Spotter = new Spotter($this->db);
553 553
             		$all = $Spotter->countAllDates($filters);
@@ -562,35 +562,35 @@  discard block
 block discarded – undo
562 562
                  try {
563 563
                         $sth = $this->db->prepare($query);
564 564
                         $sth->execute($query_data);
565
-                } catch(PDOException $e) {
565
+                } catch (PDOException $e) {
566 566
                         echo "error : ".$e->getMessage();
567 567
                 }
568 568
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
569 569
                 if (empty($all)) {
570 570
             		$filters = array();
571 571
             		if ($filter_name != '') {
572
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
572
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
573 573
 			}
574 574
             		$Spotter = new Spotter($this->db);
575 575
             		$all = $Spotter->countAllDatesByAirlines($filters);
576 576
                 }
577 577
                 return $all;
578 578
 	}
579
-	public function countAllMonths($stats_airline = '',$filter_name = '') {
579
+	public function countAllMonths($stats_airline = '', $filter_name = '') {
580 580
 		global $globalStatsFilters;
581 581
 		if ($filter_name == '') $filter_name = $this->filter_name;
582 582
 	    	$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
583 583
                  try {
584 584
                         $sth = $this->db->prepare($query);
585 585
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
586
-                } catch(PDOException $e) {
586
+                } catch (PDOException $e) {
587 587
                         echo "error : ".$e->getMessage();
588 588
                 }
589 589
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
590 590
                 if (empty($all)) {
591 591
 			$filters = array('airlines' => array($stats_airline));
592 592
 			if ($filter_name != '') {
593
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
593
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
594 594
 			}
595 595
             		$Spotter = new Spotter($this->db);
596 596
             		$all = $Spotter->countAllMonths($filters);
@@ -604,21 +604,21 @@  discard block
 block discarded – undo
604 604
                  try {
605 605
                         $sth = $this->db->prepare($query);
606 606
                         $sth->execute(array(':filter_name' => $filter_name));
607
-                } catch(PDOException $e) {
607
+                } catch (PDOException $e) {
608 608
                         echo "error : ".$e->getMessage();
609 609
                 }
610 610
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
611 611
                 if (empty($all)) {
612 612
             		$filters = array();
613 613
             		if ($filter_name != '') {
614
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
614
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
615 615
 			}
616 616
             		$Spotter = new Spotter($this->db);
617 617
             		$all = $Spotter->countAllMilitaryMonths($filters);
618 618
                 }
619 619
                 return $all;
620 620
 	}
621
-	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
621
+	public function countAllHours($orderby = 'hour', $limit = true, $stats_airline = '', $filter_name = '') {
622 622
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
623 623
 		if ($filter_name == '') $filter_name = $this->filter_name;
624 624
 		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";
@@ -635,17 +635,17 @@  discard block
 block discarded – undo
635 635
                  try {
636 636
                         $sth = $this->db->prepare($query);
637 637
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
638
-                } catch(PDOException $e) {
638
+                } catch (PDOException $e) {
639 639
                         echo "error : ".$e->getMessage();
640 640
                 }
641 641
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
642 642
                 if (empty($all)) {
643 643
 			$filters = array('airlines' => array($stats_airline));
644 644
 			if ($filter_name != '') {
645
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
645
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
646 646
 			}
647 647
             		$Spotter = new Spotter($this->db);
648
-            		$all = $Spotter->countAllHours($orderby,$filters);
648
+            		$all = $Spotter->countAllHours($orderby, $filters);
649 649
                 }
650 650
                 return $all;
651 651
 	}
@@ -653,11 +653,11 @@  discard block
 block discarded – undo
653 653
 	public function countOverallFlights($stats_airline = '', $filter_name = '') {
654 654
 		global $globalStatsFilters;
655 655
 		if ($filter_name == '') $filter_name = $this->filter_name;
656
-		$all = $this->getSumStats('flights_bymonth',date('Y'),$stats_airline,$filter_name);
656
+		$all = $this->getSumStats('flights_bymonth', date('Y'), $stats_airline, $filter_name);
657 657
 		if (empty($all)) {
658 658
 			$filters = array('airlines' => array($stats_airline));
659 659
 			if ($filter_name != '') {
660
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
660
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
661 661
 			}
662 662
 			$Spotter = new Spotter($this->db);
663 663
 			$all = $Spotter->countOverallFlights($filters);
@@ -667,39 +667,39 @@  discard block
 block discarded – undo
667 667
 	public function countOverallMilitaryFlights($filter_name = '') {
668 668
 		global $globalStatsFilters;
669 669
 		if ($filter_name == '') $filter_name = $this->filter_name;
670
-		$all = $this->getSumStats('military_flights_bymonth',date('Y'),'',$filter_name);
670
+		$all = $this->getSumStats('military_flights_bymonth', date('Y'), '', $filter_name);
671 671
 		if (empty($all)) {
672 672
 		        $filters = array();
673 673
             		if ($filter_name != '') {
674
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
674
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
675 675
 			}
676 676
 			$Spotter = new Spotter($this->db);
677 677
 			$all = $Spotter->countOverallMilitaryFlights($filters);
678 678
 		}
679 679
 		return $all;
680 680
 	}
681
-	public function countOverallArrival($stats_airline = '',$filter_name = '') {
681
+	public function countOverallArrival($stats_airline = '', $filter_name = '') {
682 682
 		global $globalStatsFilters;
683 683
 		if ($filter_name == '') $filter_name = $this->filter_name;
684
-		$all = $this->getSumStats('realarrivals_bymonth',date('Y'),$stats_airline,$filter_name);
684
+		$all = $this->getSumStats('realarrivals_bymonth', date('Y'), $stats_airline, $filter_name);
685 685
 		if (empty($all)) {
686 686
 			$filters = array('airlines' => array($stats_airline));
687 687
 			if ($filter_name != '') {
688
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
688
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
689 689
 			}
690 690
 			$Spotter = new Spotter($this->db);
691 691
 			$all = $Spotter->countOverallArrival($filters);
692 692
 		}
693 693
 		return $all;
694 694
 	}
695
-	public function countOverallAircrafts($stats_airline = '',$filter_name = '') {
695
+	public function countOverallAircrafts($stats_airline = '', $filter_name = '') {
696 696
 		global $globalStatsFilters;
697 697
 		if ($filter_name == '') $filter_name = $this->filter_name;
698
-		$all = $this->getSumStats('aircrafts_bymonth',date('Y'),$stats_airline,$filter_name);
698
+		$all = $this->getSumStats('aircrafts_bymonth', date('Y'), $stats_airline, $filter_name);
699 699
 		if (empty($all)) {
700 700
 			$filters = array('airlines' => array($stats_airline));
701 701
 			if ($filter_name != '') {
702
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
702
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
703 703
 			}
704 704
 			$Spotter = new Spotter($this->db);
705 705
 			$all = $Spotter->countOverallAircrafts($filters);
@@ -713,7 +713,7 @@  discard block
 block discarded – undo
713 713
                  try {
714 714
                         $sth = $this->db->prepare($query);
715 715
                         $sth->execute(array(':filter_name' => $filter_name));
716
-                } catch(PDOException $e) {
716
+                } catch (PDOException $e) {
717 717
                         echo "error : ".$e->getMessage();
718 718
                 }
719 719
                 $result = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -722,14 +722,14 @@  discard block
 block discarded – undo
722 722
 		if (empty($all)) {
723 723
             		$filters = array();
724 724
             		if ($filter_name != '') {
725
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
725
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
726 726
 			}
727 727
 			$Spotter = new Spotter($this->db);
728 728
 			$all = $Spotter->countOverallAirlines($filters);
729 729
 		}
730 730
 		return $all;
731 731
 	}
732
-	public function countOverallOwners($stats_airline = '',$filter_name = '') {
732
+	public function countOverallOwners($stats_airline = '', $filter_name = '') {
733 733
 		global $globalStatsFilters;
734 734
 		if ($filter_name == '') $filter_name = $this->filter_name;
735 735
 		/*
@@ -743,25 +743,25 @@  discard block
 block discarded – undo
743 743
                 $result = $sth->fetchAll(PDO::FETCH_ASSOC);
744 744
                 $all = $result[0]['nb_owner'];
745 745
                 */
746
-		$all = $this->getSumStats('owners_bymonth',date('Y'),$stats_airline,$filter_name);
746
+		$all = $this->getSumStats('owners_bymonth', date('Y'), $stats_airline, $filter_name);
747 747
 		if (empty($all)) {
748 748
 			$filters = array('airlines' => array($stats_airline));
749 749
 			if ($filter_name != '') {
750
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
750
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
751 751
 			}
752 752
 			$Spotter = new Spotter($this->db);
753 753
 			$all = $Spotter->countOverallOwners($filters);
754 754
 		}
755 755
 		return $all;
756 756
 	}
757
-	public function countOverallPilots($stats_airline = '',$filter_name = '') {
757
+	public function countOverallPilots($stats_airline = '', $filter_name = '') {
758 758
 		global $globalStatsFilters;
759 759
 		if ($filter_name == '') $filter_name = $this->filter_name;
760
-		$all = $this->getSumStats('pilots_bymonth',date('Y'),$stats_airline,$filter_name);
760
+		$all = $this->getSumStats('pilots_bymonth', date('Y'), $stats_airline, $filter_name);
761 761
 		if (empty($all)) {
762 762
 			$filters = array('airlines' => array($stats_airline));
763 763
 			if ($filter_name != '') {
764
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
764
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
765 765
 			}
766 766
 			$Spotter = new Spotter($this->db);
767 767
 			$all = $Spotter->countOverallPilots($filters);
@@ -769,33 +769,33 @@  discard block
 block discarded – undo
769 769
 		return $all;
770 770
 	}
771 771
 
772
-	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') {
772
+	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '', $filter_name = '') {
773 773
 		if ($filter_name == '') $filter_name = $this->filter_name;
774 774
 		$query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date";
775
-		$query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
775
+		$query_values = array(':airport_icao' => $airport_icao, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
776 776
                  try {
777 777
                         $sth = $this->db->prepare($query);
778 778
                         $sth->execute($query_values);
779
-                } catch(PDOException $e) {
779
+                } catch (PDOException $e) {
780 780
                         echo "error : ".$e->getMessage();
781 781
                 }
782 782
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
783 783
                 return $all;
784 784
 	}
785
-	public function getStats($type,$stats_airline = '', $filter_name = '') {
785
+	public function getStats($type, $stats_airline = '', $filter_name = '') {
786 786
 		if ($filter_name == '') $filter_name = $this->filter_name;
787 787
                 $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
788
-                $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
788
+                $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
789 789
                  try {
790 790
                         $sth = $this->db->prepare($query);
791 791
                         $sth->execute($query_values);
792
-                } catch(PDOException $e) {
792
+                } catch (PDOException $e) {
793 793
                         echo "error : ".$e->getMessage();
794 794
                 }
795 795
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
796 796
                 return $all;
797 797
         }
798
-	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '') {
798
+	public function getSumStats($type, $year, $stats_airline = '', $filter_name = '') {
799 799
 		if ($filter_name == '') $filter_name = $this->filter_name;
800 800
     		global $globalArchiveMonths, $globalDBdriver;
801 801
     		if ($globalDBdriver == 'mysql') {
@@ -803,11 +803,11 @@  discard block
 block discarded – undo
803 803
 	        } else {
804 804
             		$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name";
805 805
                 }
806
-                $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
806
+                $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
807 807
                  try {
808 808
                         $sth = $this->db->prepare($query);
809 809
                         $sth->execute($query_values);
810
-                } catch(PDOException $e) {
810
+                } catch (PDOException $e) {
811 811
                         echo "error : ".$e->getMessage();
812 812
                 }
813 813
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -825,7 +825,7 @@  discard block
 block discarded – undo
825 825
                  try {
826 826
                         $sth = $this->db->prepare($query);
827 827
                         $sth->execute($query_values);
828
-                } catch(PDOException $e) {
828
+                } catch (PDOException $e) {
829 829
                         echo "error : ".$e->getMessage();
830 830
                 }
831 831
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -842,7 +842,7 @@  discard block
 block discarded – undo
842 842
                  try {
843 843
                         $sth = $this->db->prepare($query);
844 844
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
845
-                } catch(PDOException $e) {
845
+                } catch (PDOException $e) {
846 846
                         echo "error : ".$e->getMessage();
847 847
                 }
848 848
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -859,7 +859,7 @@  discard block
 block discarded – undo
859 859
                  try {
860 860
                         $sth = $this->db->prepare($query);
861 861
                         $sth->execute(array(':filter_name' => $filter_name));
862
-                } catch(PDOException $e) {
862
+                } catch (PDOException $e) {
863 863
                         echo "error : ".$e->getMessage();
864 864
                 }
865 865
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -876,7 +876,7 @@  discard block
 block discarded – undo
876 876
                  try {
877 877
                         $sth = $this->db->prepare($query);
878 878
                         $sth->execute(array(':filter_name' => $filter_name));
879
-                } catch(PDOException $e) {
879
+                } catch (PDOException $e) {
880 880
                         echo "error : ".$e->getMessage();
881 881
                 }
882 882
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -893,14 +893,14 @@  discard block
 block discarded – undo
893 893
                  try {
894 894
                         $sth = $this->db->prepare($query);
895 895
                         $sth->execute(array(':filter_name' => $filter_name));
896
-                } catch(PDOException $e) {
896
+                } catch (PDOException $e) {
897 897
                         echo "error : ".$e->getMessage();
898 898
                 }
899 899
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
900 900
                 return $all[0]['total'];
901 901
         }
902 902
 
903
-	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
903
+	public function addStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') {
904 904
 		global $globalDBdriver;
905 905
 		if ($filter_name == '') $filter_name = $this->filter_name;
906 906
 		if ($globalDBdriver == 'mysql') {
@@ -908,15 +908,15 @@  discard block
 block discarded – undo
908 908
                 } else {
909 909
 			$query = "UPDATE stats SET cnt = :cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE  stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
910 910
 		}
911
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
911
+                $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
912 912
                  try {
913 913
                         $sth = $this->db->prepare($query);
914 914
                         $sth->execute($query_values);
915
-                } catch(PDOException $e) {
915
+                } catch (PDOException $e) {
916 916
                         return "error : ".$e->getMessage();
917 917
                 }
918 918
         }
919
-	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
919
+	public function updateStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') {
920 920
 		global $globalDBdriver;
921 921
 		if ($filter_name == '') $filter_name = $this->filter_name;
922 922
 		if ($globalDBdriver == 'mysql') {
@@ -925,58 +925,58 @@  discard block
 block discarded – undo
925 925
             		//$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
926 926
 			$query = "UPDATE stats SET cnt = cnt+:cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE  stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
927 927
                 }
928
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
928
+                $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
929 929
                  try {
930 930
                         $sth = $this->db->prepare($query);
931 931
                         $sth->execute($query_values);
932
-                } catch(PDOException $e) {
932
+                } catch (PDOException $e) {
933 933
                         return "error : ".$e->getMessage();
934 934
                 }
935 935
         }
936
-	public function getStatsSource($date,$stats_type = '') {
936
+	public function getStatsSource($date, $stats_type = '') {
937 937
 		if ($stats_type == '') {
938 938
 			$query = "SELECT * FROM stats_source WHERE stats_date = :date ORDER BY source_name";
939 939
 			$query_values = array(':date' => $date);
940 940
 		} else {
941 941
 			$query = "SELECT * FROM stats_source WHERE stats_date = :date AND stats_type = :stats_type ORDER BY source_name";
942
-			$query_values = array(':date' => $date,':stats_type' => $stats_type);
942
+			$query_values = array(':date' => $date, ':stats_type' => $stats_type);
943 943
 		}
944 944
                  try {
945 945
                         $sth = $this->db->prepare($query);
946 946
                         $sth->execute($query_values);
947
-                } catch(PDOException $e) {
947
+                } catch (PDOException $e) {
948 948
                         echo "error : ".$e->getMessage();
949 949
                 }
950 950
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
951 951
                 return $all;
952 952
         }
953 953
 
954
-	public function addStatSource($data,$source_name,$stats_type,$date) {
954
+	public function addStatSource($data, $source_name, $stats_type, $date) {
955 955
 		global $globalDBdriver;
956 956
 		if ($globalDBdriver == 'mysql') {
957 957
 			$query = "INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) VALUES (:data,:source_name,:stats_type,:stats_date) ON DUPLICATE KEY UPDATE source_data = :data";
958 958
 		} else {
959 959
 			$query = "UPDATE stats_source SET source_data = :data WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type; INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) SELECT :data,:source_name,:stats_type,:stats_date WHERE NOT EXISTS (SELECT 1 FROM stats_source WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type);"; 
960 960
                 }
961
-                $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type);
961
+                $query_values = array(':data' => $data, ':stats_date' => $date, ':source_name' => $source_name, ':stats_type' => $stats_type);
962 962
                  try {
963 963
                         $sth = $this->db->prepare($query);
964 964
                         $sth->execute($query_values);
965
-                } catch(PDOException $e) {
965
+                } catch (PDOException $e) {
966 966
                         return "error : ".$e->getMessage();
967 967
                 }
968 968
         }
969
-	public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') {
969
+	public function addStatFlight($type, $date_name, $cnt, $stats_airline = '', $filter_name = '') {
970 970
                 $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)";
971
-                $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
971
+                $query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
972 972
                  try {
973 973
                         $sth = $this->db->prepare($query);
974 974
                         $sth->execute($query_values);
975
-                } catch(PDOException $e) {
975
+                } catch (PDOException $e) {
976 976
                         return "error : ".$e->getMessage();
977 977
                 }
978 978
         }
979
-	public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '',$reset = false) {
979
+	public function addStatAircraftRegistration($registration, $cnt, $aircraft_icao = '', $airline_icao = '', $filter_name = '', $reset = false) {
980 980
 		global $globalDBdriver;
981 981
 		if ($globalDBdriver == 'mysql') {
982 982
 			if ($reset) {
@@ -991,15 +991,15 @@  discard block
 block discarded – undo
991 991
 				$query = "UPDATE stats_registration SET cnt = cnt+:cnt WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_registration (aircraft_icao,registration,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:registration,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_registration WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
992 992
 			}
993 993
 		}
994
-                $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
994
+                $query_values = array(':aircraft_icao' => $aircraft_icao, ':registration' => $registration, ':cnt' => $cnt, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
995 995
                  try {
996 996
                         $sth = $this->db->prepare($query);
997 997
                         $sth->execute($query_values);
998
-                } catch(PDOException $e) {
998
+                } catch (PDOException $e) {
999 999
                         return "error : ".$e->getMessage();
1000 1000
                 }
1001 1001
         }
1002
-	public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '', $reset = false) {
1002
+	public function addStatCallsign($callsign_icao, $cnt, $airline_icao = '', $filter_name = '', $reset = false) {
1003 1003
 		global $globalDBdriver;
1004 1004
 		if ($globalDBdriver == 'mysql') {
1005 1005
 			if ($reset) {
@@ -1014,15 +1014,15 @@  discard block
 block discarded – undo
1014 1014
 				$query = "UPDATE stats_callsign SET cnt = cnt+:cnt WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name; INSERT INTO stats_callsign (callsign_icao,airline_icao,cnt,filter_name) SELECT :callsign_icao,:airline_icao,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_callsign WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name);"; 
1015 1015
 			}
1016 1016
 		}
1017
-                $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name);
1017
+                $query_values = array(':callsign_icao' => $callsign_icao, ':airline_icao' => $airline_icao, ':cnt' => $cnt, ':filter_name' => $filter_name);
1018 1018
                  try {
1019 1019
                         $sth = $this->db->prepare($query);
1020 1020
                         $sth->execute($query_values);
1021
-                } catch(PDOException $e) {
1021
+                } catch (PDOException $e) {
1022 1022
                         return "error : ".$e->getMessage();
1023 1023
                 }
1024 1024
         }
1025
-	public function addStatCountry($iso2,$iso3,$name,$cnt,$filter_name = '',$reset = false) {
1025
+	public function addStatCountry($iso2, $iso3, $name, $cnt, $filter_name = '', $reset = false) {
1026 1026
 		global $globalDBdriver;
1027 1027
 		if ($globalDBdriver == 'mysql') {
1028 1028
 			if ($reset) {
@@ -1037,15 +1037,15 @@  discard block
 block discarded – undo
1037 1037
 				$query = "UPDATE stats_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name; INSERT INTO stats_country (iso2,iso3,name,cnt,filter_name) SELECT :iso2,:iso3,:name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_country WHERE iso2 = :iso2 AND filter_name = :filter_name);"; 
1038 1038
 			}
1039 1039
 		}
1040
-                $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name);
1040
+                $query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt, ':filter_name' => $filter_name);
1041 1041
                  try {
1042 1042
                         $sth = $this->db->prepare($query);
1043 1043
                         $sth->execute($query_values);
1044
-                } catch(PDOException $e) {
1044
+                } catch (PDOException $e) {
1045 1045
                         return "error : ".$e->getMessage();
1046 1046
                 }
1047 1047
         }
1048
-	public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) {
1048
+	public function addStatAircraft($aircraft_icao, $cnt, $aircraft_name = '', $aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) {
1049 1049
 		global $globalDBdriver;
1050 1050
 		if ($globalDBdriver == 'mysql') {
1051 1051
 			if ($reset) {
@@ -1060,15 +1060,15 @@  discard block
 block discarded – undo
1060 1060
 				$query = "UPDATE stats_aircraft SET cnt = cnt+:cnt, aircraft_name = :aircraft_name, aircraft_manufacturer = :aircraft_manufacturer, filter_name = :filter_name WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_aircraft (aircraft_icao,aircraft_name,aircraft_manufacturer,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:aircraft_name,:aircraft_manufacturer,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_aircraft WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1061 1061
 			}
1062 1062
 		}
1063
-                $query_values = array(':aircraft_icao' => $aircraft_icao,':aircraft_name' => $aircraft_name,':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1063
+                $query_values = array(':aircraft_icao' => $aircraft_icao, ':aircraft_name' => $aircraft_name, ':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1064 1064
                  try {
1065 1065
                         $sth = $this->db->prepare($query);
1066 1066
                         $sth->execute($query_values);
1067
-                } catch(PDOException $e) {
1067
+                } catch (PDOException $e) {
1068 1068
                         return "error : ".$e->getMessage();
1069 1069
                 }
1070 1070
         }
1071
-	public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '', $reset = false) {
1071
+	public function addStatAirline($airline_icao, $cnt, $airline_name = '', $filter_name = '', $reset = false) {
1072 1072
 		global $globalDBdriver;
1073 1073
 		if ($globalDBdriver == 'mysql') {
1074 1074
 			if ($reset) {
@@ -1083,15 +1083,15 @@  discard block
 block discarded – undo
1083 1083
 				$query = "UPDATE stats_airline SET cnt = cnt+:cnt WHERE airline_icao = :airline_icao AND filter_name = :filter_name; INSERT INTO stats_airline (airline_icao,airline_name,cnt,filter_name) SELECT :airline_icao,:airline_name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airline WHERE airline_icao = :airline_icao AND filter_name = :filter_name);"; 
1084 1084
 			}
1085 1085
 		}
1086
-                $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name);
1086
+                $query_values = array(':airline_icao' => $airline_icao, ':airline_name' => $airline_name, ':cnt' => $cnt, ':filter_name' => $filter_name);
1087 1087
                  try {
1088 1088
                         $sth = $this->db->prepare($query);
1089 1089
                         $sth->execute($query_values);
1090
-                } catch(PDOException $e) {
1090
+                } catch (PDOException $e) {
1091 1091
                         return "error : ".$e->getMessage();
1092 1092
                 }
1093 1093
         }
1094
-	public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '', $reset = false) {
1094
+	public function addStatOwner($owner_name, $cnt, $stats_airline = '', $filter_name = '', $reset = false) {
1095 1095
 		global $globalDBdriver;
1096 1096
 		if ($globalDBdriver == 'mysql') {
1097 1097
 			if ($reset) {
@@ -1106,15 +1106,15 @@  discard block
 block discarded – undo
1106 1106
 				$query = "UPDATE stats_owner SET cnt = cnt+:cnt WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_owner (owner_name,cnt,stats_airline,filter_name) SELECT :owner_name,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_owner WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1107 1107
 			}
1108 1108
 		}
1109
-                $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1109
+                $query_values = array(':owner_name' => $owner_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1110 1110
                  try {
1111 1111
                         $sth = $this->db->prepare($query);
1112 1112
                         $sth->execute($query_values);
1113
-                } catch(PDOException $e) {
1113
+                } catch (PDOException $e) {
1114 1114
                         return "error : ".$e->getMessage();
1115 1115
                 }
1116 1116
         }
1117
-	public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '',$format_source = '',$reset = false) {
1117
+	public function addStatPilot($pilot_id, $cnt, $pilot_name, $stats_airline = '', $filter_name = '', $format_source = '', $reset = false) {
1118 1118
 		global $globalDBdriver;
1119 1119
 		if ($globalDBdriver == 'mysql') {
1120 1120
 			if ($reset) {
@@ -1129,15 +1129,15 @@  discard block
 block discarded – undo
1129 1129
 				$query = "UPDATE stats_pilot SET cnt = cnt+:cnt, pilot_name = :pilot_name WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source; INSERT INTO stats_pilot (pilot_id,cnt,pilot_name,stats_airline,filter_name,format_source) SELECT :pilot_id,:cnt,:pilot_name,:stats_airline,:filter_name,:format_source WHERE NOT EXISTS (SELECT 1 FROM stats_pilot WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source);"; 
1130 1130
 			}
1131 1131
 		}
1132
-                $query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name,':format_source' => $format_source);
1132
+                $query_values = array(':pilot_id' => $pilot_id, ':cnt' => $cnt, ':pilot_name' => $pilot_name, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':format_source' => $format_source);
1133 1133
                  try {
1134 1134
                         $sth = $this->db->prepare($query);
1135 1135
                         $sth->execute($query_values);
1136
-                } catch(PDOException $e) {
1136
+                } catch (PDOException $e) {
1137 1137
                         return "error : ".$e->getMessage();
1138 1138
                 }
1139 1139
         }
1140
-	public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '',$reset = false) {
1140
+	public function addStatDepartureAirports($airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '', $reset = false) {
1141 1141
 		global $globalDBdriver;
1142 1142
 		if ($airport_icao != '') {
1143 1143
 			if ($globalDBdriver == 'mysql') {
@@ -1153,16 +1153,16 @@  discard block
 block discarded – undo
1153 1153
 					$query = "UPDATE stats_airport SET departure = departure+:departure WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; 
1154 1154
 				}
1155 1155
 			}
1156
-			$query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao,':filter_name' => $filter_name);
1156
+			$query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':departure' => $departure, ':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1157 1157
 			try {
1158 1158
 				$sth = $this->db->prepare($query);
1159 1159
 				$sth->execute($query_values);
1160
-			} catch(PDOException $e) {
1160
+			} catch (PDOException $e) {
1161 1161
 				return "error : ".$e->getMessage();
1162 1162
 			}
1163 1163
                 }
1164 1164
         }
1165
-	public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') {
1165
+	public function addStatDepartureAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '') {
1166 1166
 		global $globalDBdriver;
1167 1167
 		if ($airport_icao != '') {
1168 1168
 			if ($globalDBdriver == 'mysql') {
@@ -1170,16 +1170,16 @@  discard block
 block discarded – undo
1170 1170
 			} else {
1171 1171
 				$query = "UPDATE stats_airport SET departure = :departure WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'daily',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1172 1172
 			}
1173
-			$query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name);
1173
+			$query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':departure' => $departure, ':date' => $date, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1174 1174
 			 try {
1175 1175
 				$sth = $this->db->prepare($query);
1176 1176
 				$sth->execute($query_values);
1177
-			} catch(PDOException $e) {
1177
+			} catch (PDOException $e) {
1178 1178
 				return "error : ".$e->getMessage();
1179 1179
 			}
1180 1180
                 }
1181 1181
         }
1182
-	public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '',$reset = false) {
1182
+	public function addStatArrivalAirports($airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '', $reset = false) {
1183 1183
 		global $globalDBdriver;
1184 1184
 		if ($airport_icao != '') {
1185 1185
 			if ($globalDBdriver == 'mysql') {
@@ -1195,16 +1195,16 @@  discard block
 block discarded – undo
1195 1195
 					$query = "UPDATE stats_airport SET arrival = arrival+:arrival WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; 
1196 1196
 				}
1197 1197
 			}
1198
-	                $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival,':date' => date('Y').'-01-01 00:00:00',':stats_airline' => $airline_icao,':filter_name' => $filter_name);
1198
+	                $query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':arrival' => $arrival, ':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1199 1199
 			 try {
1200 1200
                     		$sth = $this->db->prepare($query);
1201 1201
 	                        $sth->execute($query_values);
1202
-    		        } catch(PDOException $e) {
1202
+    		        } catch (PDOException $e) {
1203 1203
             		        return "error : ".$e->getMessage();
1204 1204
 	                }
1205 1205
 	        }
1206 1206
         }
1207
-	public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') {
1207
+	public function addStatArrivalAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '') {
1208 1208
 		global $globalDBdriver;
1209 1209
 		if ($airport_icao != '') {
1210 1210
 			if ($globalDBdriver == 'mysql') {
@@ -1212,11 +1212,11 @@  discard block
 block discarded – undo
1212 1212
 			} else {
1213 1213
 				$query = "UPDATE stats_airport SET arrival = :arrival WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'daily',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1214 1214
 			}
1215
-			$query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival, ':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name);
1215
+			$query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':arrival' => $arrival, ':date' => $date, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1216 1216
 			try {
1217 1217
 				$sth = $this->db->prepare($query);
1218 1218
 				$sth->execute($query_values);
1219
-			} catch(PDOException $e) {
1219
+			} catch (PDOException $e) {
1220 1220
 				return "error : ".$e->getMessage();
1221 1221
 			}
1222 1222
                 }
@@ -1228,7 +1228,7 @@  discard block
 block discarded – undo
1228 1228
                  try {
1229 1229
                         $sth = $this->db->prepare($query);
1230 1230
                         $sth->execute($query_values);
1231
-                } catch(PDOException $e) {
1231
+                } catch (PDOException $e) {
1232 1232
                         return "error : ".$e->getMessage();
1233 1233
                 }
1234 1234
         }
@@ -1238,7 +1238,7 @@  discard block
 block discarded – undo
1238 1238
                  try {
1239 1239
                         $sth = $this->db->prepare($query);
1240 1240
                         $sth->execute($query_values);
1241
-                } catch(PDOException $e) {
1241
+                } catch (PDOException $e) {
1242 1242
                         return "error : ".$e->getMessage();
1243 1243
                 }
1244 1244
         }
@@ -1248,13 +1248,13 @@  discard block
 block discarded – undo
1248 1248
                  try {
1249 1249
                         $sth = $this->db->prepare($query);
1250 1250
                         $sth->execute($query_values);
1251
-                } catch(PDOException $e) {
1251
+                } catch (PDOException $e) {
1252 1252
                         return "error : ".$e->getMessage();
1253 1253
                 }
1254 1254
         }
1255 1255
         
1256 1256
         public function addOldStats() {
1257
-    		global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats,$globalStatsReset,$globalStatsResetYear;
1257
+    		global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters, $globalDeleteLastYearStats, $globalStatsReset, $globalStatsResetYear;
1258 1258
     		$Common = new Common();
1259 1259
     		$Connection = new Connection();
1260 1260
     		date_default_timezone_set('UTC');
@@ -1271,40 +1271,40 @@  discard block
 block discarded – undo
1271 1271
 			$Spotter = new Spotter($this->db);
1272 1272
 
1273 1273
 			if ($globalDebug) echo 'Count all aircraft types...'."\n";
1274
-			$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);
1274
+			$alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day);
1275 1275
 			foreach ($alldata as $number) {
1276
-				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','','',$reset);
1276
+				$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', '', '', $reset);
1277 1277
 			}
1278 1278
 			if ($globalDebug) echo 'Count all airlines...'."\n";
1279
-			$alldata = $Spotter->countAllAirlines(false,0,$last_update_day);
1279
+			$alldata = $Spotter->countAllAirlines(false, 0, $last_update_day);
1280 1280
 			foreach ($alldata as $number) {
1281
-				$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset);
1281
+				$this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], '', $reset);
1282 1282
 			}
1283 1283
 			if ($globalDebug) echo 'Count all registrations...'."\n";
1284
-			$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day);
1284
+			$alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day);
1285 1285
 			foreach ($alldata as $number) {
1286
-				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset);
1286
+				$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', '', $reset);
1287 1287
 			}
1288 1288
 			if ($globalDebug) echo 'Count all callsigns...'."\n";
1289
-			$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day);
1289
+			$alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day);
1290 1290
 			foreach ($alldata as $number) {
1291
-				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
1291
+				$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao'], '', $reset);
1292 1292
 			}
1293 1293
 			if ($globalDebug) echo 'Count all owners...'."\n";
1294
-			$alldata = $Spotter->countAllOwners(false,0,$last_update_day);
1294
+			$alldata = $Spotter->countAllOwners(false, 0, $last_update_day);
1295 1295
 			foreach ($alldata as $number) {
1296
-				$this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset);
1296
+				$this->addStatOwner($number['owner_name'], $number['owner_count'], '', '', $reset);
1297 1297
 			}
1298 1298
 			if ($globalDebug) echo 'Count all pilots...'."\n";
1299
-			$alldata = $Spotter->countAllPilots(false,0,$last_update_day);
1299
+			$alldata = $Spotter->countAllPilots(false, 0, $last_update_day);
1300 1300
 			foreach ($alldata as $number) {
1301
-				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset);
1301
+				$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', '', $number['format_source'], $reset);
1302 1302
 			}
1303 1303
 			
1304 1304
 			if ($globalDebug) echo 'Count all departure airports...'."\n";
1305
-			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
1305
+			$pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day);
1306 1306
 			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
1307
-        		$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1307
+        		$dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day);
1308 1308
 			if ($globalDebug) echo 'Order departure airports...'."\n";
1309 1309
 	        	$alldata = array();
1310 1310
 	        	
@@ -1322,14 +1322,14 @@  discard block
 block discarded – undo
1322 1322
     			foreach ($alldata as $key => $row) {
1323 1323
     				$count[$key] = $row['airport_departure_icao_count'];
1324 1324
         		}
1325
-			array_multisort($count,SORT_DESC,$alldata);
1325
+			array_multisort($count, SORT_DESC, $alldata);
1326 1326
 			foreach ($alldata as $number) {
1327
-				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);
1327
+				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);
1328 1328
 			}
1329 1329
 			if ($globalDebug) echo 'Count all arrival airports...'."\n";
1330
-			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
1330
+			$pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day);
1331 1331
 			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
1332
-        		$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1332
+        		$dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day);
1333 1333
 			if ($globalDebug) echo 'Order arrival airports...'."\n";
1334 1334
 	        	$alldata = array();
1335 1335
     			foreach ($pall as $value) {
@@ -1346,16 +1346,16 @@  discard block
 block discarded – undo
1346 1346
         		foreach ($alldata as $key => $row) {
1347 1347
         			$count[$key] = $row['airport_arrival_icao_count'];
1348 1348
 	        	}
1349
-    			array_multisort($count,SORT_DESC,$alldata);
1349
+    			array_multisort($count, SORT_DESC, $alldata);
1350 1350
                         foreach ($alldata as $number) {
1351
-				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);
1351
+				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);
1352 1352
 			}
1353 1353
 			if ($Connection->tableExists('countries')) {
1354 1354
 				if ($globalDebug) echo 'Count all flights by countries...'."\n";
1355 1355
 				$SpotterArchive = new SpotterArchive();
1356
-				$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day);
1356
+				$alldata = $SpotterArchive->countAllFlightOverCountries(false, 0, $last_update_day);
1357 1357
 				foreach ($alldata as $number) {
1358
-					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],'',$reset);
1358
+					$this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count'], '', $reset);
1359 1359
 				}
1360 1360
 			}
1361 1361
 			
@@ -1369,37 +1369,37 @@  discard block
 block discarded – undo
1369 1369
 			$lastyear = false;
1370 1370
 			foreach ($alldata as $number) {
1371 1371
 				if ($number['year_name'] != date('Y')) $lastyear = true;
1372
-				$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'])));
1372
+				$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'])));
1373 1373
 			}
1374 1374
 			if ($globalDebug) echo 'Count all military flights by months...'."\n";
1375 1375
 			$alldata = $Spotter->countAllMilitaryMonths();
1376 1376
 			foreach ($alldata as $number) {
1377
-				$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'])));
1377
+				$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'])));
1378 1378
 			}
1379 1379
 			if ($globalDebug) echo 'Count all owners by months...'."\n";
1380 1380
 			$alldata = $Spotter->countAllMonthsOwners();
1381 1381
 			foreach ($alldata as $number) {
1382
-				$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'])));
1382
+				$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'])));
1383 1383
 			}
1384 1384
 			if ($globalDebug) echo 'Count all pilots by months...'."\n";
1385 1385
 			$alldata = $Spotter->countAllMonthsPilots();
1386 1386
 			foreach ($alldata as $number) {
1387
-				$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'])));
1387
+				$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'])));
1388 1388
 			}
1389 1389
 			if ($globalDebug) echo 'Count all airlines by months...'."\n";
1390 1390
 			$alldata = $Spotter->countAllMonthsAirlines();
1391 1391
 			foreach ($alldata as $number) {
1392
-				$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'])));
1392
+				$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'])));
1393 1393
 			}
1394 1394
 			if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
1395 1395
 			$alldata = $Spotter->countAllMonthsAircrafts();
1396 1396
 			foreach ($alldata as $number) {
1397
-				$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'])));
1397
+				$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'])));
1398 1398
 			}
1399 1399
 			if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
1400 1400
 			$alldata = $Spotter->countAllMonthsRealArrivals();
1401 1401
 			foreach ($alldata as $number) {
1402
-				$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'])));
1402
+				$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'])));
1403 1403
 			}
1404 1404
 			if ($globalDebug) echo 'Airports data...'."\n";
1405 1405
 			if ($globalDebug) echo '...Departure'."\n";
@@ -1444,7 +1444,7 @@  discard block
 block discarded – undo
1444 1444
     			}
1445 1445
     			$alldata = $pall;
1446 1446
 			foreach ($alldata as $number) {
1447
-				$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']);
1447
+				$this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count']);
1448 1448
 			}
1449 1449
 			echo '...Arrival'."\n";
1450 1450
 			$pall = $Spotter->getLast7DaysAirportsArrival();
@@ -1486,7 +1486,7 @@  discard block
 block discarded – undo
1486 1486
     			}
1487 1487
     			$alldata = $pall;
1488 1488
 			foreach ($alldata as $number) {
1489
-				$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']);
1489
+				$this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count']);
1490 1490
 			}
1491 1491
 
1492 1492
 			echo 'Flights data...'."\n";
@@ -1494,28 +1494,28 @@  discard block
 block discarded – undo
1494 1494
 			echo '-> countAllDatesLastMonth...'."\n";
1495 1495
 			$alldata = $Spotter->countAllDatesLastMonth();
1496 1496
 			foreach ($alldata as $number) {
1497
-				$this->addStatFlight('month',$number['date_name'],$number['date_count']);
1497
+				$this->addStatFlight('month', $number['date_name'], $number['date_count']);
1498 1498
 			}
1499 1499
 			echo '-> countAllDates...'."\n";
1500 1500
 			$previousdata = $this->countAllDates();
1501 1501
 			$previousdatabyairlines = $this->countAllDatesByAirlines();
1502 1502
 			$this->deleteStatFlight('date');
1503
-			$alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates());
1503
+			$alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates());
1504 1504
 			$values = array();
1505 1505
 			foreach ($alldata as $cnt) {
1506 1506
 				$values[] = $cnt['date_count'];
1507 1507
 			}
1508
-			array_multisort($values,SORT_DESC,$alldata);
1509
-			array_splice($alldata,11);
1508
+			array_multisort($values, SORT_DESC, $alldata);
1509
+			array_splice($alldata, 11);
1510 1510
 			foreach ($alldata as $number) {
1511
-				$this->addStatFlight('date',$number['date_name'],$number['date_count']);
1511
+				$this->addStatFlight('date', $number['date_name'], $number['date_count']);
1512 1512
 			}
1513 1513
 			
1514 1514
 			$this->deleteStatFlight('hour');
1515 1515
 			echo '-> countAllHours...'."\n";
1516 1516
 			$alldata = $Spotter->countAllHours('hour');
1517 1517
 			foreach ($alldata as $number) {
1518
-				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count']);
1518
+				$this->addStatFlight('hour', $number['hour_name'], $number['hour_count']);
1519 1519
 			}
1520 1520
 
1521 1521
 
@@ -1524,34 +1524,34 @@  discard block
 block discarded – undo
1524 1524
 			echo '--- Stats by airlines ---'."\n";
1525 1525
 			if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n";
1526 1526
 			$Spotter = new Spotter($this->db);
1527
-			$alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day);
1527
+			$alldata = $Spotter->countAllAircraftTypesByAirlines(false, 0, $last_update_day);
1528 1528
 			foreach ($alldata as $number) {
1529
-				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset);
1529
+				$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], $number['airline_icao'], '', $reset);
1530 1530
 			}
1531 1531
 			if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n";
1532
-			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day);
1532
+			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false, 0, $last_update_day);
1533 1533
 			foreach ($alldata as $number) {
1534
-				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset);
1534
+				$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], $number['airline_icao'], '', $reset);
1535 1535
 			}
1536 1536
 			if ($globalDebug) echo 'Count all callsigns by airlines...'."\n";
1537
-			$alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day);
1537
+			$alldata = $Spotter->countAllCallsignsByAirlines(false, 0, $last_update_day);
1538 1538
 			foreach ($alldata as $number) {
1539
-				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
1539
+				$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao'], '', $reset);
1540 1540
 			}
1541 1541
 			if ($globalDebug) echo 'Count all owners by airlines...'."\n";
1542
-			$alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day);
1542
+			$alldata = $Spotter->countAllOwnersByAirlines(false, 0, $last_update_day);
1543 1543
 			foreach ($alldata as $number) {
1544
-				$this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset);
1544
+				$this->addStatOwner($number['owner_name'], $number['owner_count'], $number['airline_icao'], '', $reset);
1545 1545
 			}
1546 1546
 			if ($globalDebug) echo 'Count all pilots by airlines...'."\n";
1547
-			$alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day);
1547
+			$alldata = $Spotter->countAllPilotsByAirlines(false, 0, $last_update_day);
1548 1548
 			foreach ($alldata as $number) {
1549
-				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset);
1549
+				$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], $number['airline_icao'], '', $number['format_source'], $reset);
1550 1550
 			}
1551 1551
 			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
1552
-			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
1552
+			$pall = $Spotter->countAllDepartureAirportsByAirlines(false, 0, $last_update_day);
1553 1553
 			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
1554
-       			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
1554
+       			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false, 0, $last_update_day);
1555 1555
 			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
1556 1556
 	        	//$alldata = array();
1557 1557
     			foreach ($dall as $value) {
@@ -1571,12 +1571,12 @@  discard block
 block discarded – undo
1571 1571
     			}
1572 1572
     			$alldata = $pall;
1573 1573
 			foreach ($alldata as $number) {
1574
-				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);
1574
+				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);
1575 1575
 			}
1576 1576
 			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
1577
-			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
1577
+			$pall = $Spotter->countAllArrivalAirportsByAirlines(false, 0, $last_update_day);
1578 1578
 			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
1579
-        		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
1579
+        		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false, 0, $last_update_day);
1580 1580
 			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
1581 1581
 	        	//$alldata = array();
1582 1582
     			foreach ($dall as $value) {
@@ -1596,7 +1596,7 @@  discard block
 block discarded – undo
1596 1596
     			}
1597 1597
     			$alldata = $pall;
1598 1598
                         foreach ($alldata as $number) {
1599
-				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);
1599
+				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);
1600 1600
 			}
1601 1601
 			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
1602 1602
 			$Spotter = new Spotter($this->db);
@@ -1604,27 +1604,27 @@  discard block
 block discarded – undo
1604 1604
 			$lastyear = false;
1605 1605
 			foreach ($alldata as $number) {
1606 1606
 				if ($number['year_name'] != date('Y')) $lastyear = true;
1607
-				$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']);
1607
+				$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']);
1608 1608
 			}
1609 1609
 			if ($globalDebug) echo 'Count all owners by months by airlines...'."\n";
1610 1610
 			$alldata = $Spotter->countAllMonthsOwnersByAirlines();
1611 1611
 			foreach ($alldata as $number) {
1612
-				$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']);
1612
+				$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']);
1613 1613
 			}
1614 1614
 			if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n";
1615 1615
 			$alldata = $Spotter->countAllMonthsPilotsByAirlines();
1616 1616
 			foreach ($alldata as $number) {
1617
-				$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']);
1617
+				$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']);
1618 1618
 			}
1619 1619
 			if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n";
1620 1620
 			$alldata = $Spotter->countAllMonthsAircraftsByAirlines();
1621 1621
 			foreach ($alldata as $number) {
1622
-				$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']);
1622
+				$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']);
1623 1623
 			}
1624 1624
 			if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n";
1625 1625
 			$alldata = $Spotter->countAllMonthsRealArrivalsByAirlines();
1626 1626
 			foreach ($alldata as $number) {
1627
-				$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']);
1627
+				$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']);
1628 1628
 			}
1629 1629
 			if ($globalDebug) echo '...Departure'."\n";
1630 1630
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
@@ -1647,7 +1647,7 @@  discard block
 block discarded – undo
1647 1647
     			}
1648 1648
     			$alldata = $pall;
1649 1649
 			foreach ($alldata as $number) {
1650
-				$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']);
1650
+				$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']);
1651 1651
 			}
1652 1652
 			if ($globalDebug) echo '...Arrival'."\n";
1653 1653
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
@@ -1670,32 +1670,32 @@  discard block
 block discarded – undo
1670 1670
     			}
1671 1671
     			$alldata = $pall;
1672 1672
 			foreach ($alldata as $number) {
1673
-				$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']);
1673
+				$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']);
1674 1674
 			}
1675 1675
 
1676 1676
 			if ($globalDebug) echo 'Flights data...'."\n";
1677 1677
 			if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n";
1678 1678
 			$alldata = $Spotter->countAllDatesLastMonthByAirlines();
1679 1679
 			foreach ($alldata as $number) {
1680
-				$this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']);
1680
+				$this->addStatFlight('month', $number['date_name'], $number['date_count'], $number['airline_icao']);
1681 1681
 			}
1682 1682
 			if ($globalDebug) echo '-> countAllDates...'."\n";
1683 1683
 			//$previousdata = $this->countAllDatesByAirlines();
1684
-			$alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines());
1684
+			$alldata = $Common->array_merge_noappend($previousdatabyairlines, $Spotter->countAllDatesByAirlines());
1685 1685
 			$values = array();
1686 1686
 			foreach ($alldata as $cnt) {
1687 1687
 				$values[] = $cnt['date_count'];
1688 1688
 			}
1689
-			array_multisort($values,SORT_DESC,$alldata);
1690
-			array_splice($alldata,11);
1689
+			array_multisort($values, SORT_DESC, $alldata);
1690
+			array_splice($alldata, 11);
1691 1691
 			foreach ($alldata as $number) {
1692
-				$this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']);
1692
+				$this->addStatFlight('date', $number['date_name'], $number['date_count'], $number['airline_icao']);
1693 1693
 			}
1694 1694
 			
1695 1695
 			if ($globalDebug) echo '-> countAllHours...'."\n";
1696 1696
 			$alldata = $Spotter->countAllHoursByAirlines('hour');
1697 1697
 			foreach ($alldata as $number) {
1698
-				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']);
1698
+				$this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], $number['airline_icao']);
1699 1699
 			}
1700 1700
 			
1701 1701
 
@@ -1714,32 +1714,32 @@  discard block
 block discarded – undo
1714 1714
 				// Count by filter
1715 1715
 				if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n";
1716 1716
 				$Spotter = new Spotter($this->db);
1717
-				$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter);
1717
+				$alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day, $filter);
1718 1718
 				foreach ($alldata as $number) {
1719
-					$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'',$filter_name,$reset);
1719
+					$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', $filter_name, $reset);
1720 1720
 				}
1721
-				$alldata = $Spotter->countAllAirlines(false,0,$last_update_day,$filter);
1721
+				$alldata = $Spotter->countAllAirlines(false, 0, $last_update_day, $filter);
1722 1722
 				foreach ($alldata as $number) {
1723
-					$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],$filter_name,$reset);
1723
+					$this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], $filter_name, $reset);
1724 1724
 				}
1725
-				$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day,$filter);
1725
+				$alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day, $filter);
1726 1726
 				foreach ($alldata as $number) {
1727
-					$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'',$filter_name,$reset);
1727
+					$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', $filter_name, $reset);
1728 1728
 				}
1729
-				$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day,$filter);
1729
+				$alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day, $filter);
1730 1730
 				foreach ($alldata as $number) {
1731
-					$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],'',$filter_name,$reset);
1731
+					$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], '', $filter_name, $reset);
1732 1732
 				}
1733
-				$alldata = $Spotter->countAllOwners(false,0,$last_update_day,$filter);
1733
+				$alldata = $Spotter->countAllOwners(false, 0, $last_update_day, $filter);
1734 1734
 				foreach ($alldata as $number) {
1735
-					$this->addStatOwner($number['owner_name'],$number['owner_count'],'',$filter_name,$reset);
1735
+					$this->addStatOwner($number['owner_name'], $number['owner_count'], '', $filter_name, $reset);
1736 1736
 				}
1737
-				$alldata = $Spotter->countAllPilots(false,0,$last_update_day,$filter);
1737
+				$alldata = $Spotter->countAllPilots(false, 0, $last_update_day, $filter);
1738 1738
 				foreach ($alldata as $number) {
1739
-					$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source'],$reset);
1739
+					$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', $filter_name, $number['format_source'], $reset);
1740 1740
 				}
1741
-				$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter);
1742
-	       			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
1741
+				$pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day, $filter);
1742
+	       			$dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day, $filter);
1743 1743
 		        	$alldata = array();
1744 1744
 	    			foreach ($pall as $value) {
1745 1745
 		        		$icao = $value['airport_departure_icao'];
@@ -1755,12 +1755,12 @@  discard block
 block discarded – undo
1755 1755
     				foreach ($alldata as $key => $row) {
1756 1756
     					$count[$key] = $row['airport_departure_icao_count'];
1757 1757
     				}
1758
-				array_multisort($count,SORT_DESC,$alldata);
1758
+				array_multisort($count, SORT_DESC, $alldata);
1759 1759
 				foreach ($alldata as $number) {
1760
-    					echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'',$filter_name,$reset);
1760
+    					echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count'], '', $filter_name, $reset);
1761 1761
 				}
1762
-				$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter);
1763
-    				$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter);
1762
+				$pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day, false, $filter);
1763
+    				$dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day, false, $filter);
1764 1764
 				$alldata = array();
1765 1765
     				foreach ($pall as $value) {
1766 1766
 		        		$icao = $value['airport_arrival_icao'];
@@ -1776,40 +1776,40 @@  discard block
 block discarded – undo
1776 1776
         			foreach ($alldata as $key => $row) {
1777 1777
     					$count[$key] = $row['airport_arrival_icao_count'];
1778 1778
 		        	}
1779
-        			array_multisort($count,SORT_DESC,$alldata);
1779
+        			array_multisort($count, SORT_DESC, $alldata);
1780 1780
 				foreach ($alldata as $number) {
1781
-					echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'',$filter_name,$reset);
1781
+					echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count'], '', $filter_name, $reset);
1782 1782
 				}
1783 1783
 				$Spotter = new Spotter($this->db);
1784 1784
 				$alldata = $Spotter->countAllMonths($filter);
1785 1785
 				$lastyear = false;
1786 1786
 				foreach ($alldata as $number) {
1787 1787
 					if ($number['year_name'] != date('Y')) $lastyear = true;
1788
-					$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);
1788
+					$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);
1789 1789
 				}
1790 1790
 				$alldata = $Spotter->countAllMonthsOwners($filter);
1791 1791
 				foreach ($alldata as $number) {
1792
-					$this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
1792
+					$this->addStat('owners_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
1793 1793
 				}
1794 1794
 				$alldata = $Spotter->countAllMonthsPilots($filter);
1795 1795
 				foreach ($alldata as $number) {
1796
-					$this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
1796
+					$this->addStat('pilots_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
1797 1797
 				}
1798 1798
 				$alldata = $Spotter->countAllMilitaryMonths($filter);
1799 1799
 				foreach ($alldata as $number) {
1800
-					$this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
1800
+					$this->addStat('military_flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
1801 1801
 				}
1802 1802
 				$alldata = $Spotter->countAllMonthsAircrafts($filter);
1803 1803
 				foreach ($alldata as $number) {
1804
-					$this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
1804
+					$this->addStat('aircrafts_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
1805 1805
 				}
1806 1806
 				$alldata = $Spotter->countAllMonthsRealArrivals($filter);
1807 1807
 				foreach ($alldata as $number) {
1808
-					$this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
1808
+					$this->addStat('realarrivals_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
1809 1809
 				}
1810 1810
 				echo '...Departure'."\n";
1811
-				$pall = $Spotter->getLast7DaysAirportsDeparture('',$filter);
1812
-        			$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter);
1811
+				$pall = $Spotter->getLast7DaysAirportsDeparture('', $filter);
1812
+        			$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('', $filter);
1813 1813
 				foreach ($dall as $value) {
1814 1814
     					$icao = $value['departure_airport_icao'];
1815 1815
     					$ddate = $value['date'];
@@ -1827,11 +1827,11 @@  discard block
 block discarded – undo
1827 1827
     				}
1828 1828
 	    			$alldata = $pall;
1829 1829
 				foreach ($alldata as $number) {
1830
-					$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],'',$filter_name);
1830
+					$this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count'], '', $filter_name);
1831 1831
 				}
1832 1832
 				echo '...Arrival'."\n";
1833
-				$pall = $Spotter->getLast7DaysAirportsArrival('',$filter);
1834
-    				$dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter);
1833
+				$pall = $Spotter->getLast7DaysAirportsArrival('', $filter);
1834
+    				$dall = $Spotter->getLast7DaysDetectedAirportsArrival('', $filter);
1835 1835
 				foreach ($dall as $value) {
1836 1836
 					$icao = $value['arrival_airport_icao'];
1837 1837
 					$ddate = $value['date'];
@@ -1849,40 +1849,40 @@  discard block
 block discarded – undo
1849 1849
     				}
1850 1850
     				$alldata = $pall;
1851 1851
 				foreach ($alldata as $number) {
1852
-					$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],'',$filter_name);
1852
+					$this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count'], '', $filter_name);
1853 1853
 				}
1854 1854
     
1855 1855
 				echo 'Flights data...'."\n";
1856 1856
 				echo '-> countAllDatesLastMonth...'."\n";
1857 1857
 				$alldata = $Spotter->countAllDatesLastMonth($filter);
1858 1858
 				foreach ($alldata as $number) {
1859
-					$this->addStatFlight('month',$number['date_name'],$number['date_count'], '',$filter_name);
1859
+					$this->addStatFlight('month', $number['date_name'], $number['date_count'], '', $filter_name);
1860 1860
 				}
1861 1861
 				echo '-> countAllDates...'."\n";
1862
-				$previousdata = $this->countAllDates('',$filter_name);
1863
-				$alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates($filter));
1862
+				$previousdata = $this->countAllDates('', $filter_name);
1863
+				$alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates($filter));
1864 1864
 				$values = array();
1865 1865
 				foreach ($alldata as $cnt) {
1866 1866
 					$values[] = $cnt['date_count'];
1867 1867
 				}
1868
-				array_multisort($values,SORT_DESC,$alldata);
1869
-				array_splice($alldata,11);
1868
+				array_multisort($values, SORT_DESC, $alldata);
1869
+				array_splice($alldata, 11);
1870 1870
 				foreach ($alldata as $number) {
1871
-					$this->addStatFlight('date',$number['date_name'],$number['date_count'],'',$filter_name);
1871
+					$this->addStatFlight('date', $number['date_name'], $number['date_count'], '', $filter_name);
1872 1872
 				}
1873 1873
 				
1874 1874
 				echo '-> countAllHours...'."\n";
1875
-				$alldata = $Spotter->countAllHours('hour',$filter);
1875
+				$alldata = $Spotter->countAllHours('hour', $filter);
1876 1876
 				foreach ($alldata as $number) {
1877
-					$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],'',$filter_name);
1877
+					$this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], '', $filter_name);
1878 1878
 				}
1879 1879
 				echo 'Insert last stats update date...'."\n";
1880 1880
 				date_default_timezone_set('UTC');
1881
-				$this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y-m-d G:i:s'));
1881
+				$this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y-m-d G:i:s'));
1882 1882
 				if (isset($filter['DeleteLastYearStats']) && $filter['DeleteLastYearStats'] == true) {
1883
-					if (date('Y',strtotime($last_update_day)) != date('Y')) {
1883
+					if (date('Y', strtotime($last_update_day)) != date('Y')) {
1884 1884
 						$this->deleteOldStats($filter_name);
1885
-						$this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y').'-01-01 00:00:00');
1885
+						$this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y').'-01-01 00:00:00');
1886 1886
 					}
1887 1887
 				}
1888 1888
 
@@ -1895,16 +1895,16 @@  discard block
 block discarded – undo
1895 1895
 				// SUM all previous month to put as year
1896 1896
 				$previous_year = date('Y');
1897 1897
 				$previous_year--;
1898
-				$this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
1899
-				$this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
1900
-				$this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
1901
-				$this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
1898
+				$this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
1899
+				$this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
1900
+				$this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
1901
+				$this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
1902 1902
 				$allairlines = $this->getAllAirlineNames();
1903 1903
 				foreach ($allairlines as $data) {
1904
-					$this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
1905
-					$this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
1906
-					$this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
1907
-					$this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
1904
+					$this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
1905
+					$this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
1906
+					$this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
1907
+					$this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
1908 1908
 				}
1909 1909
 				
1910 1910
 				if (isset($globalArchiveYear) && $globalArchiveYear) {
@@ -1913,7 +1913,7 @@  discard block
 block discarded – undo
1913 1913
 						try {
1914 1914
 							$sth = $this->db->prepare($query);
1915 1915
 							$sth->execute();
1916
-						} catch(PDOException $e) {
1916
+						} catch (PDOException $e) {
1917 1917
 							return "error : ".$e->getMessage().' - query : '.$query."\n";
1918 1918
 						}
1919 1919
 					}
@@ -1922,15 +1922,15 @@  discard block
 block discarded – undo
1922 1922
 					try {
1923 1923
 						$sth = $this->db->prepare($query);
1924 1924
 						$sth->execute();
1925
-					} catch(PDOException $e) {
1925
+					} catch (PDOException $e) {
1926 1926
 						return "error : ".$e->getMessage().' - query : '.$query."\n";
1927 1927
 					}
1928 1928
 				}
1929 1929
 				if (isset($globalDeleteLastYearStats) && $globalDeleteLastYearStats) {
1930 1930
 					$last_update = $this->getLastStatsUpdate('last_update_stats');
1931
-					if (date('Y',strtotime($last_update[0]['value'])) != date('Y')) {
1931
+					if (date('Y', strtotime($last_update[0]['value'])) != date('Y')) {
1932 1932
 						$this->deleteOldStats();
1933
-						$this->addLastStatsUpdate('last_update_stats',date('Y').'-01-01 00:00:00');
1933
+						$this->addLastStatsUpdate('last_update_stats', date('Y').'-01-01 00:00:00');
1934 1934
 						$lastyearupdate = true;
1935 1935
 					}
1936 1936
 				}
@@ -1952,7 +1952,7 @@  discard block
 block discarded – undo
1952 1952
 					try {
1953 1953
 						$sth = $this->db->prepare($query);
1954 1954
 						$sth->execute();
1955
-					} catch(PDOException $e) {
1955
+					} catch (PDOException $e) {
1956 1956
 						return "error : ".$e->getMessage();
1957 1957
 					}
1958 1958
 				}
@@ -1966,14 +1966,14 @@  discard block
 block discarded – undo
1966 1966
 				try {
1967 1967
 					$sth = $this->db->prepare($query);
1968 1968
 					$sth->execute();
1969
-				} catch(PDOException $e) {
1969
+				} catch (PDOException $e) {
1970 1970
 					return "error : ".$e->getMessage();
1971 1971
 				}
1972 1972
 			}
1973 1973
 			if (!isset($lastyearupdate)) {
1974 1974
 				echo 'Insert last stats update date...'."\n";
1975 1975
 				date_default_timezone_set('UTC');
1976
-				$this->addLastStatsUpdate('last_update_stats',date('Y-m-d G:i:s'));
1976
+				$this->addLastStatsUpdate('last_update_stats', date('Y-m-d G:i:s'));
1977 1977
 			}
1978 1978
 		//}
1979 1979
 	}
Please login to merge, or discard this patch.
Braces   +389 added lines, -135 removed lines patch added patch discarded remove patch
@@ -12,7 +12,9 @@  discard block
 block discarded – undo
12 12
 	
13 13
 	public function __construct($dbc = null) {
14 14
 		global $globalFilterName;
15
-		if (isset($globalFilterName)) $this->filter_name = $globalFilterName;
15
+		if (isset($globalFilterName)) {
16
+			$this->filter_name = $globalFilterName;
17
+		}
16 18
 		$Connection = new Connection($dbc);
17 19
 		$this->db = $Connection->db();
18 20
         }
@@ -77,7 +79,9 @@  discard block
 block discarded – undo
77 79
                 }
78 80
         }
79 81
 	public function getAllAirlineNames($filter_name = '') {
80
-		if ($filter_name == '') $filter_name = $this->filter_name;
82
+		if ($filter_name == '') {
83
+			$filter_name = $this->filter_name;
84
+		}
81 85
                 $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC";
82 86
                  try {
83 87
                         $sth = $this->db->prepare($query);
@@ -89,7 +93,9 @@  discard block
 block discarded – undo
89 93
                 return $all;
90 94
         }
91 95
 	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
92
-		if ($filter_name == '') $filter_name = $this->filter_name;
96
+		if ($filter_name == '') {
97
+			$filter_name = $this->filter_name;
98
+		}
93 99
                 $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
94 100
                  try {
95 101
                         $sth = $this->db->prepare($query);
@@ -101,7 +107,9 @@  discard block
 block discarded – undo
101 107
                 return $all;
102 108
         }
103 109
 	public function getAllManufacturers($stats_airline = '',$filter_name = '') {
104
-		if ($filter_name == '') $filter_name = $this->filter_name;
110
+		if ($filter_name == '') {
111
+			$filter_name = $this->filter_name;
112
+		}
105 113
                 $query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC";
106 114
                  try {
107 115
                         $sth = $this->db->prepare($query);
@@ -113,7 +121,9 @@  discard block
 block discarded – undo
113 121
                 return $all;
114 122
         }
115 123
 	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
116
-		if ($filter_name == '') $filter_name = $this->filter_name;
124
+		if ($filter_name == '') {
125
+			$filter_name = $this->filter_name;
126
+		}
117 127
                 $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC";
118 128
                  try {
119 129
                         $sth = $this->db->prepare($query);
@@ -128,9 +138,14 @@  discard block
 block discarded – undo
128 138
 
129 139
 	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '') {
130 140
 		global $globalStatsFilters;
131
-		if ($filter_name == '') $filter_name = $this->filter_name;
132
-		if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
133
-		else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
141
+		if ($filter_name == '') {
142
+			$filter_name = $this->filter_name;
143
+		}
144
+		if ($limit) {
145
+			$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
146
+		} else {
147
+			$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
148
+		}
134 149
                  try {
135 150
                         $sth = $this->db->prepare($query);
136 151
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -150,9 +165,14 @@  discard block
 block discarded – undo
150 165
 	}
151 166
 	public function countAllAirlineCountries($limit = true,$filter_name = '') {
152 167
 		global $globalStatsFilters;
153
-		if ($filter_name == '') $filter_name = $this->filter_name;
154
-		if ($limit) $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0";
155
-		else $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC";
168
+		if ($filter_name == '') {
169
+			$filter_name = $this->filter_name;
170
+		}
171
+		if ($limit) {
172
+			$query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0";
173
+		} else {
174
+			$query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC";
175
+		}
156 176
                  try {
157 177
                         $sth = $this->db->prepare($query);
158 178
                         $sth->execute(array(':filter_name' => $filter_name));
@@ -172,9 +192,14 @@  discard block
 block discarded – undo
172 192
 	}
173 193
 	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '') {
174 194
 		global $globalStatsFilters;
175
-		if ($filter_name == '') $filter_name = $this->filter_name;
176
-		if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
177
-		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";
195
+		if ($filter_name == '') {
196
+			$filter_name = $this->filter_name;
197
+		}
198
+		if ($limit) {
199
+			$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";
200
+		} else {
201
+			$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";
202
+		}
178 203
                  try {
179 204
                         $sth = $this->db->prepare($query);
180 205
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -195,9 +220,14 @@  discard block
 block discarded – undo
195 220
 
196 221
 	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '') {
197 222
 		global $globalStatsFilters;
198
-		if ($filter_name == '') $filter_name = $this->filter_name;
199
-		if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
200
-		else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC";
223
+		if ($filter_name == '') {
224
+			$filter_name = $this->filter_name;
225
+		}
226
+		if ($limit) {
227
+			$query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
228
+		} else {
229
+			$query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC";
230
+		}
201 231
                  try {
202 232
                         $sth = $this->db->prepare($query);
203 233
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -217,9 +247,14 @@  discard block
 block discarded – undo
217 247
 	}
218 248
 	public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '') {
219 249
 		global $globalStatsFilters;
220
-		if ($filter_name == '') $filter_name = $this->filter_name;
221
-		if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
222
-		else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC";
250
+		if ($filter_name == '') {
251
+			$filter_name = $this->filter_name;
252
+		}
253
+		if ($limit) {
254
+			$query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
255
+		} else {
256
+			$query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC";
257
+		}
223 258
                  try {
224 259
                         $sth = $this->db->prepare($query);
225 260
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -240,9 +275,14 @@  discard block
 block discarded – undo
240 275
 
241 276
 	public function countAllAirlines($limit = true,$filter_name = '') {
242 277
 		global $globalStatsFilters;
243
-		if ($filter_name == '') $filter_name = $this->filter_name;
244
-		if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
245
-		else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC";
278
+		if ($filter_name == '') {
279
+			$filter_name = $this->filter_name;
280
+		}
281
+		if ($limit) {
282
+			$query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
283
+		} else {
284
+			$query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC";
285
+		}
246 286
                  try {
247 287
                         $sth = $this->db->prepare($query);
248 288
                         $sth->execute(array(':filter_name' => $filter_name));
@@ -263,9 +303,14 @@  discard block
 block discarded – undo
263 303
 	}
264 304
 	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '') {
265 305
 		global $globalStatsFilters;
266
-		if ($filter_name == '') $filter_name = $this->filter_name;
267
-		if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0";
268
-		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";
306
+		if ($filter_name == '') {
307
+			$filter_name = $this->filter_name;
308
+		}
309
+		if ($limit) {
310
+			$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";
311
+		} else {
312
+			$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";
313
+		}
269 314
                  try {
270 315
                         $sth = $this->db->prepare($query);
271 316
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -285,9 +330,14 @@  discard block
 block discarded – undo
285 330
 	}
286 331
 	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '') {
287 332
 		global $globalStatsFilters;
288
-		if ($filter_name == '') $filter_name = $this->filter_name;
289
-		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";
290
-		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";
333
+		if ($filter_name == '') {
334
+			$filter_name = $this->filter_name;
335
+		}
336
+		if ($limit) {
337
+			$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";
338
+		} else {
339
+			$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";
340
+		}
291 341
 		 try {
292 342
 			$sth = $this->db->prepare($query);
293 343
 			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -307,10 +357,15 @@  discard block
 block discarded – undo
307 357
 	}
308 358
 	public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '') {
309 359
 		$Connection = new Connection();
310
-		if ($filter_name == '') $filter_name = $this->filter_name;
360
+		if ($filter_name == '') {
361
+			$filter_name = $this->filter_name;
362
+		}
311 363
 		if ($Connection->tableExists('countries')) {
312
-			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";
313
-			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";
364
+			if ($limit) {
365
+				$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";
366
+			} else {
367
+				$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";
368
+			}
314 369
 			 try {
315 370
 				$sth = $this->db->prepare($query);
316 371
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -331,9 +386,14 @@  discard block
 block discarded – undo
331 386
 	}
332 387
 	public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '') {
333 388
 		global $globalStatsFilters;
334
-		if ($filter_name == '') $filter_name = $this->filter_name;
335
-		if ($limit) $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0";
336
-		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";
389
+		if ($filter_name == '') {
390
+			$filter_name = $this->filter_name;
391
+		}
392
+		if ($limit) {
393
+			$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";
394
+		} else {
395
+			$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";
396
+		}
337 397
                  try {
338 398
                         $sth = $this->db->prepare($query);
339 399
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -353,9 +413,14 @@  discard block
 block discarded – undo
353 413
 	}
354 414
 	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '') {
355 415
 		global $globalStatsFilters;
356
-		if ($filter_name == '') $filter_name = $this->filter_name;
357
-		if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
358
-		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";
416
+		if ($filter_name == '') {
417
+			$filter_name = $this->filter_name;
418
+		}
419
+		if ($limit) {
420
+			$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";
421
+		} else {
422
+			$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";
423
+		}
359 424
                  try {
360 425
                         $sth = $this->db->prepare($query);
361 426
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -375,9 +440,14 @@  discard block
 block discarded – undo
375 440
 	}
376 441
 	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '') {
377 442
 		global $globalStatsFilters;
378
-		if ($filter_name == '') $filter_name = $this->filter_name;
379
-		if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
380
-		else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
443
+		if ($filter_name == '') {
444
+			$filter_name = $this->filter_name;
445
+		}
446
+		if ($limit) {
447
+			$query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
448
+		} else {
449
+			$query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
450
+		}
381 451
                  try {
382 452
                         $sth = $this->db->prepare($query);
383 453
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -403,7 +473,9 @@  discard block
 block discarded – undo
403 473
         			$icao = $value['airport_departure_icao'];
404 474
         			if (isset($all[$icao])) {
405 475
         				$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
406
-        			} else $all[$icao] = $value;
476
+        			} else {
477
+        				$all[$icao] = $value;
478
+        			}
407 479
         		}
408 480
         		$count = array();
409 481
         		foreach ($all as $key => $row) {
@@ -415,9 +487,14 @@  discard block
 block discarded – undo
415 487
 	}
416 488
 	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '') {
417 489
 		global $globalStatsFilters;
418
-		if ($filter_name == '') $filter_name = $this->filter_name;
419
-		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 FROM stats_airport WHERE 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";
420
-		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 FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
490
+		if ($filter_name == '') {
491
+			$filter_name = $this->filter_name;
492
+		}
493
+		if ($limit) {
494
+			$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 FROM stats_airport WHERE 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";
495
+		} else {
496
+			$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 FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
497
+		}
421 498
 		try {
422 499
 			$sth = $this->db->prepare($query);
423 500
 			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -443,7 +520,9 @@  discard block
 block discarded – undo
443 520
         			$icao = $value['airport_arrival_icao'];
444 521
         			if (isset($all[$icao])) {
445 522
         				$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
446
-        			} else $all[$icao] = $value;
523
+        			} else {
524
+        				$all[$icao] = $value;
525
+        			}
447 526
         		}
448 527
         		$count = array();
449 528
         		foreach ($all as $key => $row) {
@@ -456,13 +535,21 @@  discard block
 block discarded – undo
456 535
 	}
457 536
 	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
458 537
 		global $globalDBdriver, $globalStatsFilters;
459
-		if ($filter_name == '') $filter_name = $this->filter_name;
538
+		if ($filter_name == '') {
539
+			$filter_name = $this->filter_name;
540
+		}
460 541
 		if ($globalDBdriver == 'mysql') {
461
-			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";
462
-			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";
542
+			if ($limit) {
543
+				$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";
544
+			} else {
545
+				$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";
546
+			}
463 547
 		} else {
464
-			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";
465
-			else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
548
+			if ($limit) {
549
+				$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";
550
+			} else {
551
+				$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";
552
+			}
466 553
 		}
467 554
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
468 555
                  try {
@@ -486,7 +573,9 @@  discard block
 block discarded – undo
486 573
 	
487 574
 	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
488 575
 		global $globalStatsFilters;
489
-		if ($filter_name == '') $filter_name = $this->filter_name;
576
+		if ($filter_name == '') {
577
+			$filter_name = $this->filter_name;
578
+		}
490 579
 		$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline = :stats_airline AND filter_name = :filter_name";
491 580
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
492 581
                  try {
@@ -508,7 +597,9 @@  discard block
 block discarded – undo
508 597
 	}
509 598
 	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
510 599
 		global $globalDBdriver, $globalStatsFilters;
511
-		if ($filter_name == '') $filter_name = $this->filter_name;
600
+		if ($filter_name == '') {
601
+			$filter_name = $this->filter_name;
602
+		}
512 603
 		if ($globalDBdriver == 'mysql') {
513 604
 			$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND stats_airline = :stats_airline AND filter_name = :filter_name";
514 605
 		} else {
@@ -534,7 +625,9 @@  discard block
 block discarded – undo
534 625
 	}
535 626
 	public function countAllDates($stats_airline = '',$filter_name = '') {
536 627
 		global $globalStatsFilters;
537
-		if ($filter_name == '') $filter_name = $this->filter_name;
628
+		if ($filter_name == '') {
629
+			$filter_name = $this->filter_name;
630
+		}
538 631
 		$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline = :stats_airline AND filter_name = :filter_name";
539 632
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
540 633
                  try {
@@ -556,7 +649,9 @@  discard block
 block discarded – undo
556 649
 	}
557 650
 	public function countAllDatesByAirlines($filter_name = '') {
558 651
 		global $globalStatsFilters;
559
-		if ($filter_name == '') $filter_name = $this->filter_name;
652
+		if ($filter_name == '') {
653
+			$filter_name = $this->filter_name;
654
+		}
560 655
 		$query = "SELECT stats_airline as airline_icao, flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND filter_name = :filter_name";
561 656
 		$query_data = array('filter_name' => $filter_name);
562 657
                  try {
@@ -578,7 +673,9 @@  discard block
 block discarded – undo
578 673
 	}
579 674
 	public function countAllMonths($stats_airline = '',$filter_name = '') {
580 675
 		global $globalStatsFilters;
581
-		if ($filter_name == '') $filter_name = $this->filter_name;
676
+		if ($filter_name == '') {
677
+			$filter_name = $this->filter_name;
678
+		}
582 679
 	    	$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
583 680
                  try {
584 681
                         $sth = $this->db->prepare($query);
@@ -599,7 +696,9 @@  discard block
 block discarded – undo
599 696
 	}
600 697
 	public function countAllMilitaryMonths($filter_name = '') {
601 698
 		global $globalStatsFilters;
602
-		if ($filter_name == '') $filter_name = $this->filter_name;
699
+		if ($filter_name == '') {
700
+			$filter_name = $this->filter_name;
701
+		}
603 702
 	    	$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'military_flights_bymonth' AND filter_name = :filter_name";
604 703
                  try {
605 704
                         $sth = $this->db->prepare($query);
@@ -620,9 +719,14 @@  discard block
 block discarded – undo
620 719
 	}
621 720
 	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
622 721
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
623
-		if ($filter_name == '') $filter_name = $this->filter_name;
624
-		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";
625
-		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";
722
+		if ($filter_name == '') {
723
+			$filter_name = $this->filter_name;
724
+		}
725
+		if ($limit) {
726
+			$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";
727
+		} else {
728
+			$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";
729
+		}
626 730
 		if ($orderby == 'hour') {
627 731
 			/*
628 732
 			if ($globalDBdriver == 'mysql') {
@@ -631,7 +735,9 @@  discard block
 block discarded – undo
631 735
 			*/
632 736
 			$query .= " ORDER BY CAST(flight_date AS integer) ASC";
633 737
 		}
634
-		if ($orderby == 'count') $query .= " ORDER BY hour_count DESC";
738
+		if ($orderby == 'count') {
739
+			$query .= " ORDER BY hour_count DESC";
740
+		}
635 741
                  try {
636 742
                         $sth = $this->db->prepare($query);
637 743
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
@@ -652,7 +758,9 @@  discard block
 block discarded – undo
652 758
 	
653 759
 	public function countOverallFlights($stats_airline = '', $filter_name = '') {
654 760
 		global $globalStatsFilters;
655
-		if ($filter_name == '') $filter_name = $this->filter_name;
761
+		if ($filter_name == '') {
762
+			$filter_name = $this->filter_name;
763
+		}
656 764
 		$all = $this->getSumStats('flights_bymonth',date('Y'),$stats_airline,$filter_name);
657 765
 		if (empty($all)) {
658 766
 			$filters = array('airlines' => array($stats_airline));
@@ -666,7 +774,9 @@  discard block
 block discarded – undo
666 774
 	}
667 775
 	public function countOverallMilitaryFlights($filter_name = '') {
668 776
 		global $globalStatsFilters;
669
-		if ($filter_name == '') $filter_name = $this->filter_name;
777
+		if ($filter_name == '') {
778
+			$filter_name = $this->filter_name;
779
+		}
670 780
 		$all = $this->getSumStats('military_flights_bymonth',date('Y'),'',$filter_name);
671 781
 		if (empty($all)) {
672 782
 		        $filters = array();
@@ -680,7 +790,9 @@  discard block
 block discarded – undo
680 790
 	}
681 791
 	public function countOverallArrival($stats_airline = '',$filter_name = '') {
682 792
 		global $globalStatsFilters;
683
-		if ($filter_name == '') $filter_name = $this->filter_name;
793
+		if ($filter_name == '') {
794
+			$filter_name = $this->filter_name;
795
+		}
684 796
 		$all = $this->getSumStats('realarrivals_bymonth',date('Y'),$stats_airline,$filter_name);
685 797
 		if (empty($all)) {
686 798
 			$filters = array('airlines' => array($stats_airline));
@@ -694,7 +806,9 @@  discard block
 block discarded – undo
694 806
 	}
695 807
 	public function countOverallAircrafts($stats_airline = '',$filter_name = '') {
696 808
 		global $globalStatsFilters;
697
-		if ($filter_name == '') $filter_name = $this->filter_name;
809
+		if ($filter_name == '') {
810
+			$filter_name = $this->filter_name;
811
+		}
698 812
 		$all = $this->getSumStats('aircrafts_bymonth',date('Y'),$stats_airline,$filter_name);
699 813
 		if (empty($all)) {
700 814
 			$filters = array('airlines' => array($stats_airline));
@@ -708,7 +822,9 @@  discard block
 block discarded – undo
708 822
 	}
709 823
 	public function countOverallAirlines($filter_name = '') {
710 824
 		global $globalStatsFilters;
711
-		if ($filter_name == '') $filter_name = $this->filter_name;
825
+		if ($filter_name == '') {
826
+			$filter_name = $this->filter_name;
827
+		}
712 828
 		$query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name";
713 829
                  try {
714 830
                         $sth = $this->db->prepare($query);
@@ -731,7 +847,9 @@  discard block
 block discarded – undo
731 847
 	}
732 848
 	public function countOverallOwners($stats_airline = '',$filter_name = '') {
733 849
 		global $globalStatsFilters;
734
-		if ($filter_name == '') $filter_name = $this->filter_name;
850
+		if ($filter_name == '') {
851
+			$filter_name = $this->filter_name;
852
+		}
735 853
 		/*
736 854
 		$query = "SELECT COUNT(*) AS nb_owner FROM stats_owner";
737 855
                  try {
@@ -756,7 +874,9 @@  discard block
 block discarded – undo
756 874
 	}
757 875
 	public function countOverallPilots($stats_airline = '',$filter_name = '') {
758 876
 		global $globalStatsFilters;
759
-		if ($filter_name == '') $filter_name = $this->filter_name;
877
+		if ($filter_name == '') {
878
+			$filter_name = $this->filter_name;
879
+		}
760 880
 		$all = $this->getSumStats('pilots_bymonth',date('Y'),$stats_airline,$filter_name);
761 881
 		if (empty($all)) {
762 882
 			$filters = array('airlines' => array($stats_airline));
@@ -770,7 +890,9 @@  discard block
 block discarded – undo
770 890
 	}
771 891
 
772 892
 	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') {
773
-		if ($filter_name == '') $filter_name = $this->filter_name;
893
+		if ($filter_name == '') {
894
+			$filter_name = $this->filter_name;
895
+		}
774 896
 		$query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date";
775 897
 		$query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
776 898
                  try {
@@ -783,7 +905,9 @@  discard block
 block discarded – undo
783 905
                 return $all;
784 906
 	}
785 907
 	public function getStats($type,$stats_airline = '', $filter_name = '') {
786
-		if ($filter_name == '') $filter_name = $this->filter_name;
908
+		if ($filter_name == '') {
909
+			$filter_name = $this->filter_name;
910
+		}
787 911
                 $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
788 912
                 $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
789 913
                  try {
@@ -796,7 +920,9 @@  discard block
 block discarded – undo
796 920
                 return $all;
797 921
         }
798 922
 	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '') {
799
-		if ($filter_name == '') $filter_name = $this->filter_name;
923
+		if ($filter_name == '') {
924
+			$filter_name = $this->filter_name;
925
+		}
800 926
     		global $globalArchiveMonths, $globalDBdriver;
801 927
     		if ($globalDBdriver == 'mysql') {
802 928
 	                $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name";
@@ -815,7 +941,9 @@  discard block
 block discarded – undo
815 941
         }
816 942
 	public function getStatsTotal($type, $stats_airline = '', $filter_name = '') {
817 943
     		global $globalArchiveMonths, $globalDBdriver;
818
-		if ($filter_name == '') $filter_name = $this->filter_name;
944
+		if ($filter_name == '') {
945
+			$filter_name = $this->filter_name;
946
+		}
819 947
     		if ($globalDBdriver == 'mysql') {
820 948
 			$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL ".$globalArchiveMonths." MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name";
821 949
 		} else {
@@ -833,7 +961,9 @@  discard block
 block discarded – undo
833 961
         }
834 962
 	public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') {
835 963
     		global $globalArchiveMonths, $globalDBdriver;
836
-		if ($filter_name == '') $filter_name = $this->filter_name;
964
+		if ($filter_name == '') {
965
+			$filter_name = $this->filter_name;
966
+		}
837 967
     		if ($globalDBdriver == 'mysql') {
838 968
 			$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
839 969
                 } else {
@@ -850,7 +980,9 @@  discard block
 block discarded – undo
850 980
         }
851 981
 	public function getStatsAirlineTotal($filter_name = '') {
852 982
     		global $globalArchiveMonths, $globalDBdriver;
853
-		if ($filter_name == '') $filter_name = $this->filter_name;
983
+		if ($filter_name == '') {
984
+			$filter_name = $this->filter_name;
985
+		}
854 986
     		if ($globalDBdriver == 'mysql') {
855 987
 			$query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name";
856 988
                 } else {
@@ -867,7 +999,9 @@  discard block
 block discarded – undo
867 999
         }
868 1000
 	public function getStatsOwnerTotal($filter_name = '') {
869 1001
     		global $globalArchiveMonths, $globalDBdriver;
870
-		if ($filter_name == '') $filter_name = $this->filter_name;
1002
+		if ($filter_name == '') {
1003
+			$filter_name = $this->filter_name;
1004
+		}
871 1005
     		if ($globalDBdriver == 'mysql') {
872 1006
 			$query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name";
873 1007
 		} else {
@@ -884,7 +1018,9 @@  discard block
 block discarded – undo
884 1018
         }
885 1019
 	public function getStatsPilotTotal($filter_name = '') {
886 1020
     		global $globalArchiveMonths, $globalDBdriver;
887
-		if ($filter_name == '') $filter_name = $this->filter_name;
1021
+		if ($filter_name == '') {
1022
+			$filter_name = $this->filter_name;
1023
+		}
888 1024
     		if ($globalDBdriver == 'mysql') {
889 1025
             		$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
890 1026
             	} else {
@@ -902,7 +1038,9 @@  discard block
 block discarded – undo
902 1038
 
903 1039
 	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
904 1040
 		global $globalDBdriver;
905
-		if ($filter_name == '') $filter_name = $this->filter_name;
1041
+		if ($filter_name == '') {
1042
+			$filter_name = $this->filter_name;
1043
+		}
906 1044
 		if ($globalDBdriver == 'mysql') {
907 1045
 			$query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = :cnt";
908 1046
                 } else {
@@ -918,7 +1056,9 @@  discard block
 block discarded – undo
918 1056
         }
919 1057
 	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
920 1058
 		global $globalDBdriver;
921
-		if ($filter_name == '') $filter_name = $this->filter_name;
1059
+		if ($filter_name == '') {
1060
+			$filter_name = $this->filter_name;
1061
+		}
922 1062
 		if ($globalDBdriver == 'mysql') {
923 1063
 			$query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
924 1064
 		} else {
@@ -1259,10 +1399,14 @@  discard block
 block discarded – undo
1259 1399
     		$Connection = new Connection();
1260 1400
     		date_default_timezone_set('UTC');
1261 1401
     		$last_update = $this->getLastStatsUpdate('last_update_stats');
1262
-			if ($globalDebug) echo 'Update stats !'."\n";
1402
+			if ($globalDebug) {
1403
+				echo 'Update stats !'."\n";
1404
+			}
1263 1405
 			if (isset($last_update[0]['value'])) {
1264 1406
 				$last_update_day = $last_update[0]['value'];
1265
-			} else $last_update_day = '2012-12-12 12:12:12';
1407
+			} else {
1408
+				$last_update_day = '2012-12-12 12:12:12';
1409
+			}
1266 1410
 			$reset = false;
1267 1411
 			if ($globalStatsResetYear) {
1268 1412
 				$reset = true;
@@ -1270,42 +1414,60 @@  discard block
 block discarded – undo
1270 1414
 			}
1271 1415
 			$Spotter = new Spotter($this->db);
1272 1416
 
1273
-			if ($globalDebug) echo 'Count all aircraft types...'."\n";
1417
+			if ($globalDebug) {
1418
+				echo 'Count all aircraft types...'."\n";
1419
+			}
1274 1420
 			$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);
1275 1421
 			foreach ($alldata as $number) {
1276 1422
 				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','','',$reset);
1277 1423
 			}
1278
-			if ($globalDebug) echo 'Count all airlines...'."\n";
1424
+			if ($globalDebug) {
1425
+				echo 'Count all airlines...'."\n";
1426
+			}
1279 1427
 			$alldata = $Spotter->countAllAirlines(false,0,$last_update_day);
1280 1428
 			foreach ($alldata as $number) {
1281 1429
 				$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset);
1282 1430
 			}
1283
-			if ($globalDebug) echo 'Count all registrations...'."\n";
1431
+			if ($globalDebug) {
1432
+				echo 'Count all registrations...'."\n";
1433
+			}
1284 1434
 			$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day);
1285 1435
 			foreach ($alldata as $number) {
1286 1436
 				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset);
1287 1437
 			}
1288
-			if ($globalDebug) echo 'Count all callsigns...'."\n";
1438
+			if ($globalDebug) {
1439
+				echo 'Count all callsigns...'."\n";
1440
+			}
1289 1441
 			$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day);
1290 1442
 			foreach ($alldata as $number) {
1291 1443
 				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
1292 1444
 			}
1293
-			if ($globalDebug) echo 'Count all owners...'."\n";
1445
+			if ($globalDebug) {
1446
+				echo 'Count all owners...'."\n";
1447
+			}
1294 1448
 			$alldata = $Spotter->countAllOwners(false,0,$last_update_day);
1295 1449
 			foreach ($alldata as $number) {
1296 1450
 				$this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset);
1297 1451
 			}
1298
-			if ($globalDebug) echo 'Count all pilots...'."\n";
1452
+			if ($globalDebug) {
1453
+				echo 'Count all pilots...'."\n";
1454
+			}
1299 1455
 			$alldata = $Spotter->countAllPilots(false,0,$last_update_day);
1300 1456
 			foreach ($alldata as $number) {
1301 1457
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset);
1302 1458
 			}
1303 1459
 			
1304
-			if ($globalDebug) echo 'Count all departure airports...'."\n";
1460
+			if ($globalDebug) {
1461
+				echo 'Count all departure airports...'."\n";
1462
+			}
1305 1463
 			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
1306
-			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
1464
+			if ($globalDebug) {
1465
+				echo 'Count all detected departure airports...'."\n";
1466
+			}
1307 1467
         		$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1308
-			if ($globalDebug) echo 'Order departure airports...'."\n";
1468
+			if ($globalDebug) {
1469
+				echo 'Order departure airports...'."\n";
1470
+			}
1309 1471
 	        	$alldata = array();
1310 1472
 	        	
1311 1473
     			foreach ($pall as $value) {
@@ -1316,7 +1478,9 @@  discard block
 block discarded – undo
1316 1478
     				$icao = $value['airport_departure_icao'];
1317 1479
         			if (isset($alldata[$icao])) {
1318 1480
     					$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1319
-        			} else $alldata[$icao] = $value;
1481
+        			} else {
1482
+        				$alldata[$icao] = $value;
1483
+        			}
1320 1484
 			}
1321 1485
     			$count = array();
1322 1486
     			foreach ($alldata as $key => $row) {
@@ -1326,11 +1490,17 @@  discard block
 block discarded – undo
1326 1490
 			foreach ($alldata as $number) {
1327 1491
 				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);
1328 1492
 			}
1329
-			if ($globalDebug) echo 'Count all arrival airports...'."\n";
1493
+			if ($globalDebug) {
1494
+				echo 'Count all arrival airports...'."\n";
1495
+			}
1330 1496
 			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
1331
-			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
1497
+			if ($globalDebug) {
1498
+				echo 'Count all detected arrival airports...'."\n";
1499
+			}
1332 1500
         		$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1333
-			if ($globalDebug) echo 'Order arrival airports...'."\n";
1501
+			if ($globalDebug) {
1502
+				echo 'Order arrival airports...'."\n";
1503
+			}
1334 1504
 	        	$alldata = array();
1335 1505
     			foreach ($pall as $value) {
1336 1506
 	        		$icao = $value['airport_arrival_icao'];
@@ -1340,7 +1510,9 @@  discard block
 block discarded – undo
1340 1510
     				$icao = $value['airport_arrival_icao'];
1341 1511
         			if (isset($alldata[$icao])) {
1342 1512
         				$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1343
-	        		} else $alldata[$icao] = $value;
1513
+	        		} else {
1514
+	        			$alldata[$icao] = $value;
1515
+	        		}
1344 1516
     			}
1345 1517
         		$count = array();
1346 1518
         		foreach ($alldata as $key => $row) {
@@ -1351,7 +1523,9 @@  discard block
 block discarded – undo
1351 1523
 				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);
1352 1524
 			}
1353 1525
 			if ($Connection->tableExists('countries')) {
1354
-				if ($globalDebug) echo 'Count all flights by countries...'."\n";
1526
+				if ($globalDebug) {
1527
+					echo 'Count all flights by countries...'."\n";
1528
+				}
1355 1529
 				$SpotterArchive = new SpotterArchive();
1356 1530
 				$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day);
1357 1531
 				foreach ($alldata as $number) {
@@ -1363,46 +1537,66 @@  discard block
 block discarded – undo
1363 1537
 			// Add by month using getstat if month finish...
1364 1538
 
1365 1539
 			//if (date('m',strtotime($last_update_day)) != date('m')) {
1366
-			if ($globalDebug) echo 'Count all flights by months...'."\n";
1540
+			if ($globalDebug) {
1541
+				echo 'Count all flights by months...'."\n";
1542
+			}
1367 1543
 			$Spotter = new Spotter($this->db);
1368 1544
 			$alldata = $Spotter->countAllMonths();
1369 1545
 			$lastyear = false;
1370 1546
 			foreach ($alldata as $number) {
1371
-				if ($number['year_name'] != date('Y')) $lastyear = true;
1547
+				if ($number['year_name'] != date('Y')) {
1548
+					$lastyear = true;
1549
+				}
1372 1550
 				$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'])));
1373 1551
 			}
1374
-			if ($globalDebug) echo 'Count all military flights by months...'."\n";
1552
+			if ($globalDebug) {
1553
+				echo 'Count all military flights by months...'."\n";
1554
+			}
1375 1555
 			$alldata = $Spotter->countAllMilitaryMonths();
1376 1556
 			foreach ($alldata as $number) {
1377 1557
 				$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'])));
1378 1558
 			}
1379
-			if ($globalDebug) echo 'Count all owners by months...'."\n";
1559
+			if ($globalDebug) {
1560
+				echo 'Count all owners by months...'."\n";
1561
+			}
1380 1562
 			$alldata = $Spotter->countAllMonthsOwners();
1381 1563
 			foreach ($alldata as $number) {
1382 1564
 				$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'])));
1383 1565
 			}
1384
-			if ($globalDebug) echo 'Count all pilots by months...'."\n";
1566
+			if ($globalDebug) {
1567
+				echo 'Count all pilots by months...'."\n";
1568
+			}
1385 1569
 			$alldata = $Spotter->countAllMonthsPilots();
1386 1570
 			foreach ($alldata as $number) {
1387 1571
 				$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'])));
1388 1572
 			}
1389
-			if ($globalDebug) echo 'Count all airlines by months...'."\n";
1573
+			if ($globalDebug) {
1574
+				echo 'Count all airlines by months...'."\n";
1575
+			}
1390 1576
 			$alldata = $Spotter->countAllMonthsAirlines();
1391 1577
 			foreach ($alldata as $number) {
1392 1578
 				$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'])));
1393 1579
 			}
1394
-			if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
1580
+			if ($globalDebug) {
1581
+				echo 'Count all aircrafts by months...'."\n";
1582
+			}
1395 1583
 			$alldata = $Spotter->countAllMonthsAircrafts();
1396 1584
 			foreach ($alldata as $number) {
1397 1585
 				$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'])));
1398 1586
 			}
1399
-			if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
1587
+			if ($globalDebug) {
1588
+				echo 'Count all real arrivals by months...'."\n";
1589
+			}
1400 1590
 			$alldata = $Spotter->countAllMonthsRealArrivals();
1401 1591
 			foreach ($alldata as $number) {
1402 1592
 				$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'])));
1403 1593
 			}
1404
-			if ($globalDebug) echo 'Airports data...'."\n";
1405
-			if ($globalDebug) echo '...Departure'."\n";
1594
+			if ($globalDebug) {
1595
+				echo 'Airports data...'."\n";
1596
+			}
1597
+			if ($globalDebug) {
1598
+				echo '...Departure'."\n";
1599
+			}
1406 1600
 			$this->deleteStatAirport('daily');
1407 1601
 //			$pall = $Spotter->getLast7DaysAirportsDeparture();
1408 1602
   //      		$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
@@ -1522,37 +1716,53 @@  discard block
 block discarded – undo
1522 1716
 
1523 1717
 			// Count by airlines
1524 1718
 			echo '--- Stats by airlines ---'."\n";
1525
-			if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n";
1719
+			if ($globalDebug) {
1720
+				echo 'Count all aircraft types by airlines...'."\n";
1721
+			}
1526 1722
 			$Spotter = new Spotter($this->db);
1527 1723
 			$alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day);
1528 1724
 			foreach ($alldata as $number) {
1529 1725
 				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset);
1530 1726
 			}
1531
-			if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n";
1727
+			if ($globalDebug) {
1728
+				echo 'Count all aircraft registrations by airlines...'."\n";
1729
+			}
1532 1730
 			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day);
1533 1731
 			foreach ($alldata as $number) {
1534 1732
 				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset);
1535 1733
 			}
1536
-			if ($globalDebug) echo 'Count all callsigns by airlines...'."\n";
1734
+			if ($globalDebug) {
1735
+				echo 'Count all callsigns by airlines...'."\n";
1736
+			}
1537 1737
 			$alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day);
1538 1738
 			foreach ($alldata as $number) {
1539 1739
 				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
1540 1740
 			}
1541
-			if ($globalDebug) echo 'Count all owners by airlines...'."\n";
1741
+			if ($globalDebug) {
1742
+				echo 'Count all owners by airlines...'."\n";
1743
+			}
1542 1744
 			$alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day);
1543 1745
 			foreach ($alldata as $number) {
1544 1746
 				$this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset);
1545 1747
 			}
1546
-			if ($globalDebug) echo 'Count all pilots by airlines...'."\n";
1748
+			if ($globalDebug) {
1749
+				echo 'Count all pilots by airlines...'."\n";
1750
+			}
1547 1751
 			$alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day);
1548 1752
 			foreach ($alldata as $number) {
1549 1753
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset);
1550 1754
 			}
1551
-			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
1755
+			if ($globalDebug) {
1756
+				echo 'Count all departure airports by airlines...'."\n";
1757
+			}
1552 1758
 			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
1553
-			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
1759
+			if ($globalDebug) {
1760
+				echo 'Count all detected departure airports by airlines...'."\n";
1761
+			}
1554 1762
        			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
1555
-			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
1763
+			if ($globalDebug) {
1764
+				echo 'Order detected departure airports by airlines...'."\n";
1765
+			}
1556 1766
 	        	//$alldata = array();
1557 1767
     			foreach ($dall as $value) {
1558 1768
     				$icao = $value['airport_departure_icao'];
@@ -1573,11 +1783,17 @@  discard block
 block discarded – undo
1573 1783
 			foreach ($alldata as $number) {
1574 1784
 				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);
1575 1785
 			}
1576
-			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
1786
+			if ($globalDebug) {
1787
+				echo 'Count all arrival airports by airlines...'."\n";
1788
+			}
1577 1789
 			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
1578
-			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
1790
+			if ($globalDebug) {
1791
+				echo 'Count all detected arrival airports by airlines...'."\n";
1792
+			}
1579 1793
         		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
1580
-			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
1794
+			if ($globalDebug) {
1795
+				echo 'Order arrival airports by airlines...'."\n";
1796
+			}
1581 1797
 	        	//$alldata = array();
1582 1798
     			foreach ($dall as $value) {
1583 1799
     				$icao = $value['airport_arrival_icao'];
@@ -1596,37 +1812,53 @@  discard block
 block discarded – undo
1596 1812
     			}
1597 1813
     			$alldata = $pall;
1598 1814
                         foreach ($alldata as $number) {
1599
-				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);
1815
+				if ($number['airline_icao'] != '') {
1816
+					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);
1817
+				}
1818
+			}
1819
+			if ($globalDebug) {
1820
+				echo 'Count all flights by months by airlines...'."\n";
1600 1821
 			}
1601
-			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
1602 1822
 			$Spotter = new Spotter($this->db);
1603 1823
 			$alldata = $Spotter->countAllMonthsByAirlines();
1604 1824
 			$lastyear = false;
1605 1825
 			foreach ($alldata as $number) {
1606
-				if ($number['year_name'] != date('Y')) $lastyear = true;
1826
+				if ($number['year_name'] != date('Y')) {
1827
+					$lastyear = true;
1828
+				}
1607 1829
 				$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']);
1608 1830
 			}
1609
-			if ($globalDebug) echo 'Count all owners by months by airlines...'."\n";
1831
+			if ($globalDebug) {
1832
+				echo 'Count all owners by months by airlines...'."\n";
1833
+			}
1610 1834
 			$alldata = $Spotter->countAllMonthsOwnersByAirlines();
1611 1835
 			foreach ($alldata as $number) {
1612 1836
 				$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']);
1613 1837
 			}
1614
-			if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n";
1838
+			if ($globalDebug) {
1839
+				echo 'Count all pilots by months by airlines...'."\n";
1840
+			}
1615 1841
 			$alldata = $Spotter->countAllMonthsPilotsByAirlines();
1616 1842
 			foreach ($alldata as $number) {
1617 1843
 				$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']);
1618 1844
 			}
1619
-			if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n";
1845
+			if ($globalDebug) {
1846
+				echo 'Count all aircrafts by months by airlines...'."\n";
1847
+			}
1620 1848
 			$alldata = $Spotter->countAllMonthsAircraftsByAirlines();
1621 1849
 			foreach ($alldata as $number) {
1622 1850
 				$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']);
1623 1851
 			}
1624
-			if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n";
1852
+			if ($globalDebug) {
1853
+				echo 'Count all real arrivals by months by airlines...'."\n";
1854
+			}
1625 1855
 			$alldata = $Spotter->countAllMonthsRealArrivalsByAirlines();
1626 1856
 			foreach ($alldata as $number) {
1627 1857
 				$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']);
1628 1858
 			}
1629
-			if ($globalDebug) echo '...Departure'."\n";
1859
+			if ($globalDebug) {
1860
+				echo '...Departure'."\n";
1861
+			}
1630 1862
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
1631 1863
         		$dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines();
1632 1864
     			foreach ($dall as $value) {
@@ -1649,7 +1881,9 @@  discard block
 block discarded – undo
1649 1881
 			foreach ($alldata as $number) {
1650 1882
 				$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']);
1651 1883
 			}
1652
-			if ($globalDebug) echo '...Arrival'."\n";
1884
+			if ($globalDebug) {
1885
+				echo '...Arrival'."\n";
1886
+			}
1653 1887
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
1654 1888
         		$dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines();
1655 1889
     			foreach ($dall as $value) {
@@ -1673,13 +1907,19 @@  discard block
 block discarded – undo
1673 1907
 				$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']);
1674 1908
 			}
1675 1909
 
1676
-			if ($globalDebug) echo 'Flights data...'."\n";
1677
-			if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n";
1910
+			if ($globalDebug) {
1911
+				echo 'Flights data...'."\n";
1912
+			}
1913
+			if ($globalDebug) {
1914
+				echo '-> countAllDatesLastMonth...'."\n";
1915
+			}
1678 1916
 			$alldata = $Spotter->countAllDatesLastMonthByAirlines();
1679 1917
 			foreach ($alldata as $number) {
1680 1918
 				$this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']);
1681 1919
 			}
1682
-			if ($globalDebug) echo '-> countAllDates...'."\n";
1920
+			if ($globalDebug) {
1921
+				echo '-> countAllDates...'."\n";
1922
+			}
1683 1923
 			//$previousdata = $this->countAllDatesByAirlines();
1684 1924
 			$alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines());
1685 1925
 			$values = array();
@@ -1692,7 +1932,9 @@  discard block
 block discarded – undo
1692 1932
 				$this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']);
1693 1933
 			}
1694 1934
 			
1695
-			if ($globalDebug) echo '-> countAllHours...'."\n";
1935
+			if ($globalDebug) {
1936
+				echo '-> countAllHours...'."\n";
1937
+			}
1696 1938
 			$alldata = $Spotter->countAllHoursByAirlines('hour');
1697 1939
 			foreach ($alldata as $number) {
1698 1940
 				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']);
@@ -1700,7 +1942,9 @@  discard block
 block discarded – undo
1700 1942
 			
1701 1943
 
1702 1944
 			// Stats by filters
1703
-			if (!isset($globalStatsFilters) || $globalStatsFilters == '') $globalStatsFilters = array();
1945
+			if (!isset($globalStatsFilters) || $globalStatsFilters == '') {
1946
+				$globalStatsFilters = array();
1947
+			}
1704 1948
 			foreach ($globalStatsFilters as $name => $filter) {
1705 1949
 				//$filter_name = $filter['name'];
1706 1950
 				$filter_name = $name;
@@ -1708,11 +1952,15 @@  discard block
 block discarded – undo
1708 1952
 				$last_update = $this->getLastStatsUpdate('last_update_stats_'.$filter_name);
1709 1953
 				if (isset($last_update[0]['value'])) {
1710 1954
 					$last_update_day = $last_update[0]['value'];
1711
-				} else $last_update_day = '2012-12-12 12:12:12';
1955
+				} else {
1956
+					$last_update_day = '2012-12-12 12:12:12';
1957
+				}
1712 1958
 				$reset = false;
1713 1959
 
1714 1960
 				// Count by filter
1715
-				if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n";
1961
+				if ($globalDebug) {
1962
+					echo '--- Stats for filter '.$filter_name.' ---'."\n";
1963
+				}
1716 1964
 				$Spotter = new Spotter($this->db);
1717 1965
 				$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter);
1718 1966
 				foreach ($alldata as $number) {
@@ -1749,7 +1997,9 @@  discard block
 block discarded – undo
1749 1997
 	    				$icao = $value['airport_departure_icao'];
1750 1998
         				if (isset($alldata[$icao])) {
1751 1999
     						$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1752
-        				} else $alldata[$icao] = $value;
2000
+        				} else {
2001
+        					$alldata[$icao] = $value;
2002
+        				}
1753 2003
 				}
1754 2004
 	    			$count = array();
1755 2005
     				foreach ($alldata as $key => $row) {
@@ -1770,7 +2020,9 @@  discard block
 block discarded – undo
1770 2020
 	    				$icao = $value['airport_arrival_icao'];
1771 2021
         				if (isset($alldata[$icao])) {
1772 2022
         					$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1773
-		        		} else $alldata[$icao] = $value;
2023
+		        		} else {
2024
+		        			$alldata[$icao] = $value;
2025
+		        		}
1774 2026
 	    			}
1775 2027
         			$count = array();
1776 2028
         			foreach ($alldata as $key => $row) {
@@ -1784,7 +2036,9 @@  discard block
 block discarded – undo
1784 2036
 				$alldata = $Spotter->countAllMonths($filter);
1785 2037
 				$lastyear = false;
1786 2038
 				foreach ($alldata as $number) {
1787
-					if ($number['year_name'] != date('Y')) $lastyear = true;
2039
+					if ($number['year_name'] != date('Y')) {
2040
+						$lastyear = true;
2041
+					}
1788 2042
 					$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);
1789 2043
 				}
1790 2044
 				$alldata = $Spotter->countAllMonthsOwners($filter);
Please login to merge, or discard this patch.