Completed
Push — master ( 994fb6...2e5736 )
by Yannick
06:03
created
require/class.Spotter.php 1 patch
Braces   +664 added lines, -230 removed lines patch added patch discarded remove patch
@@ -27,7 +27,9 @@  discard block
 block discarded – undo
27 27
 				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
28 28
 			}
29 29
 		}
30
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
30
+		if (is_array($globalFilter)) {
31
+			$filter = array_merge($filter,$globalFilter);
32
+		}
31 33
 		$filter_query_join = '';
32 34
 		$filter_query_where = '';
33 35
 		foreach($filters as $flt) {
@@ -72,8 +74,11 @@  discard block
 block discarded – undo
72 74
 				$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
73 75
 			}
74 76
 		}
75
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
76
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
77
+		if ($filter_query_where == '' && $where) {
78
+			$filter_query_where = ' WHERE';
79
+		} elseif ($filter_query_where != '' && $and) {
80
+			$filter_query_where .= ' AND';
81
+		}
77 82
 		$filter_query = $filter_query_join.$filter_query_where;
78 83
 		return $filter_query;
79 84
 	}
@@ -93,10 +98,18 @@  discard block
 block discarded – undo
93 98
 		$Image = new Image($this->db);
94 99
 		$Schedule = new Schedule($this->db);
95 100
 		$ACARS = new ACARS($this->db);
96
-		if (!isset($globalIVAO)) $globalIVAO = FALSE;
97
-		if (!isset($globalVATSIM)) $globalVATSIM = FALSE;
98
-		if (!isset($globalphpVMS)) $globalphpVMS = FALSE;
99
-		if (!isset($globalVAM)) $globalVAM = FALSE;
101
+		if (!isset($globalIVAO)) {
102
+			$globalIVAO = FALSE;
103
+		}
104
+		if (!isset($globalVATSIM)) {
105
+			$globalVATSIM = FALSE;
106
+		}
107
+		if (!isset($globalphpVMS)) {
108
+			$globalphpVMS = FALSE;
109
+		}
110
+		if (!isset($globalVAM)) {
111
+			$globalVAM = FALSE;
112
+		}
100 113
 		date_default_timezone_set('UTC');
101 114
 		
102 115
 		if (!is_string($query))
@@ -143,21 +156,35 @@  discard block
 block discarded – undo
143 156
 			} else {
144 157
 				$temp_array['spotter_id'] = '';
145 158
 			}
146
-			if (isset($row['flightaware_id'])) $temp_array['flightaware_id'] = $row['flightaware_id'];
147
-			if (isset($row['modes'])) $temp_array['modes'] = $row['modes'];
159
+			if (isset($row['flightaware_id'])) {
160
+				$temp_array['flightaware_id'] = $row['flightaware_id'];
161
+			}
162
+			if (isset($row['modes'])) {
163
+				$temp_array['modes'] = $row['modes'];
164
+			}
148 165
 			$temp_array['ident'] = $row['ident'];
149 166
 			if (isset($row['registration']) && $row['registration'] != '') {
150 167
 				$temp_array['registration'] = $row['registration'];
151 168
 			} elseif (isset($temp_array['modes'])) {
152 169
 				$temp_array['registration'] = $this->getAircraftRegistrationBymodeS($temp_array['modes']);
153
-			} else $temp_array['registration'] = '';
154
-			if (isset($row['aircraft_icao'])) $temp_array['aircraft_type'] = $row['aircraft_icao'];
170
+			} else {
171
+				$temp_array['registration'] = '';
172
+			}
173
+			if (isset($row['aircraft_icao'])) {
174
+				$temp_array['aircraft_type'] = $row['aircraft_icao'];
175
+			}
155 176
 			
156 177
 			$temp_array['departure_airport'] = $row['departure_airport_icao'];
157 178
 			$temp_array['arrival_airport'] = $row['arrival_airport_icao'];
158
-			if (isset($row['real_arrival_airport_icao']) && $row['real_arrival_airport_icao'] != NULL) $temp_array['real_arrival_airport'] = $row['real_arrival_airport_icao'];
159
-			if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude'];
160
-			if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude'];
179
+			if (isset($row['real_arrival_airport_icao']) && $row['real_arrival_airport_icao'] != NULL) {
180
+				$temp_array['real_arrival_airport'] = $row['real_arrival_airport_icao'];
181
+			}
182
+			if (isset($row['latitude'])) {
183
+				$temp_array['latitude'] = $row['latitude'];
184
+			}
185
+			if (isset($row['longitude'])) {
186
+				$temp_array['longitude'] = $row['longitude'];
187
+			}
161 188
 			/*
162 189
 			if (Connection->tableExists('countries')) {
163 190
 				$country_info = $this->getCountryFromLatitudeLongitude($temp_array['latitude'],$temp_array['longitude']);
@@ -167,8 +194,12 @@  discard block
 block discarded – undo
167 194
 				}
168 195
 			}
169 196
 			*/
170
-			if (isset($row['waypoints'])) $temp_array['waypoints'] = $row['waypoints'];
171
-			if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source'];
197
+			if (isset($row['waypoints'])) {
198
+				$temp_array['waypoints'] = $row['waypoints'];
199
+			}
200
+			if (isset($row['format_source'])) {
201
+				$temp_array['format_source'] = $row['format_source'];
202
+			}
172 203
 			if (isset($row['route_stop'])) {
173 204
 				$temp_array['route_stop'] = $row['route_stop'];
174 205
 				if ($row['route_stop'] != '') {
@@ -187,13 +218,19 @@  discard block
 block discarded – undo
187 218
 					}
188 219
 				}
189 220
 			}
190
-			if (isset($row['altitude'])) $temp_array['altitude'] = $row['altitude'];
221
+			if (isset($row['altitude'])) {
222
+				$temp_array['altitude'] = $row['altitude'];
223
+			}
191 224
 			if (isset($row['heading'])) {
192 225
 				$temp_array['heading'] = $row['heading'];
193 226
 				$heading_direction = $this->parseDirection($row['heading']);
194
-				if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
227
+				if (isset($heading_direction[0]['direction_fullname'])) {
228
+					$temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
229
+				}
230
+			}
231
+			if (isset($row['ground_speed'])) {
232
+				$temp_array['ground_speed'] = $row['ground_speed'];
195 233
 			}
196
-			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];
197 234
 			$temp_array['image'] = "";
198 235
 			$temp_array['image_thumbnail'] = "";
199 236
 			$temp_array['image_source'] = "";
@@ -201,7 +238,9 @@  discard block
 block discarded – undo
201 238
  
202 239
 			if (isset($row['highlight'])) {
203 240
 				$temp_array['highlight'] = $row['highlight'];
204
-			} else $temp_array['highlight'] = '';
241
+			} else {
242
+				$temp_array['highlight'] = '';
243
+			}
205 244
 			
206 245
 			if (isset($row['date'])) {
207 246
 				$dateArray = $this->parseDateString($row['date']);
@@ -249,7 +288,9 @@  discard block
 block discarded – undo
249 288
 				
250 289
 					if ($aircraft_array[0]['aircraft_shadow'] != NULL) {
251 290
 						$temp_array['aircraft_shadow'] = $aircraft_array[0]['aircraft_shadow'];
252
-					} else $temp_array['aircraft_shadow'] = 'default.png';
291
+					} else {
292
+						$temp_array['aircraft_shadow'] = 'default.png';
293
+					}
253 294
                                 } else {
254 295
                             		$temp_array['aircraft_shadow'] = 'default.png';
255 296
 					$temp_array['aircraft_name'] = 'N/A';
@@ -257,11 +298,17 @@  discard block
 block discarded – undo
257 298
                             	}
258 299
 			}
259 300
 			$fromsource = NULL;
260
-			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
261
-			elseif (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
262
-			elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') $fromsource = 'ivao';
263
-			elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
264
-			elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
301
+			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
302
+				$fromsource = $globalAirlinesSource;
303
+			} elseif (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') {
304
+				$fromsource = 'vatsim';
305
+			} elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') {
306
+				$fromsource = 'ivao';
307
+			} elseif (isset($globalVATSIM) && $globalVATSIM) {
308
+				$fromsource = 'vatsim';
309
+			} elseif (isset($globalIVAO) && $globalIVAO) {
310
+				$fromsource = 'ivao';
311
+			}
265 312
 			if (!isset($row['airline_name']) || $row['airline_name'] == '') {
266 313
 				if (!is_numeric(substr($row['ident'], 0, 3))) {
267 314
 					if (is_numeric(substr($row['ident'], 2, 1))) {
@@ -284,12 +331,18 @@  discard block
 block discarded – undo
284 331
 				}
285 332
 			} else {
286 333
 				$temp_array['airline_icao'] = $row['airline_icao'];
287
-				if (isset($row['airline_iata'])) $temp_array['airline_iata'] = $row['airline_iata'];
288
-				else $temp_array['airline_iata'] = 'N/A';
334
+				if (isset($row['airline_iata'])) {
335
+					$temp_array['airline_iata'] = $row['airline_iata'];
336
+				} else {
337
+					$temp_array['airline_iata'] = 'N/A';
338
+				}
289 339
 				$temp_array['airline_name'] = $row['airline_name'];
290 340
 				$temp_array['airline_country'] = $row['airline_country'];
291
-				if (isset($row['airline_callsign'])) $temp_array['airline_callsign'] = $row['airline_callsign'];
292
-				else $temp_array['airline_callsign'] = 'N/A';
341
+				if (isset($row['airline_callsign'])) {
342
+					$temp_array['airline_callsign'] = $row['airline_callsign'];
343
+				} else {
344
+					$temp_array['airline_callsign'] = 'N/A';
345
+				}
293 346
 				$temp_array['airline_type'] = $row['airline_type'];
294 347
 				if ($temp_array['airline_icao'] != '' && $temp_array['airline_iata'] == 'N/A') {
295 348
 					$airline_array = $this->getAllAirlineInfo($temp_array['airline_icao']);
@@ -316,7 +369,9 @@  discard block
 block discarded – undo
316 369
 			}
317 370
 			if ($temp_array['registration'] != "" && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && !isset($temp_array['aircraft_owner'])) {
318 371
 				$owner_info = $this->getAircraftOwnerByRegistration($temp_array['registration']);
319
-				if ($owner_info['owner'] != '') $temp_array['aircraft_owner'] = ucwords(strtolower($owner_info['owner']));
372
+				if ($owner_info['owner'] != '') {
373
+					$temp_array['aircraft_owner'] = ucwords(strtolower($owner_info['owner']));
374
+				}
320 375
 				$temp_array['aircraft_base'] = $owner_info['base'];
321 376
 				$temp_array['aircraft_date_first_reg'] = $owner_info['date_first_reg'];
322 377
 			}
@@ -324,9 +379,14 @@  discard block
 block discarded – undo
324 379
 			if($temp_array['registration'] != "" || ($globalIVAO && isset($temp_array['aircraft_type']) && $temp_array['aircraft_type'] != ''))
325 380
 			{
326 381
 				if ($globalIVAO) {
327
-					if (isset($temp_array['airline_icao']))	$image_array = $Image->getSpotterImage('',$temp_array['aircraft_type'],$temp_array['airline_icao']);
328
-					else $image_array = $Image->getSpotterImage('',$temp_array['aircraft_type']);
329
-				} else $image_array = $Image->getSpotterImage($temp_array['registration']);
382
+					if (isset($temp_array['airline_icao'])) {
383
+						$image_array = $Image->getSpotterImage('',$temp_array['aircraft_type'],$temp_array['airline_icao']);
384
+					} else {
385
+						$image_array = $Image->getSpotterImage('',$temp_array['aircraft_type']);
386
+					}
387
+				} else {
388
+					$image_array = $Image->getSpotterImage($temp_array['registration']);
389
+				}
330 390
 				if (count($image_array) > 0) {
331 391
 					$temp_array['image'] = $image_array[0]['image'];
332 392
 					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -377,7 +437,9 @@  discard block
 block discarded – undo
377 437
 			//if ($row['departure_airport_icao'] != '' && $row['departure_airport_name'] == '') {
378 438
 			if ($row['departure_airport_icao'] != '') {
379 439
 				$departure_airport_array = $this->getAllAirportInfo($row['departure_airport_icao']);
380
-				if (!isset($departure_airport_array[0]['name'])) $departure_airport_array = $this->getAllAirportInfo('NA');
440
+				if (!isset($departure_airport_array[0]['name'])) {
441
+					$departure_airport_array = $this->getAllAirportInfo('NA');
442
+				}
381 443
 			/*
382 444
 			} elseif ($row['departure_airport_name'] != '') {
383 445
 				$temp_array['departure_airport_name'] = $row['departure_airport_name'];
@@ -385,7 +447,9 @@  discard block
 block discarded – undo
385 447
 				$temp_array['departure_airport_country'] = $row['departure_airport_country'];
386 448
 				$temp_array['departure_airport_icao'] = $row['departure_airport_icao'];
387 449
 			*/
388
-			} else $departure_airport_array = $this->getAllAirportInfo('NA');
450
+			} else {
451
+				$departure_airport_array = $this->getAllAirportInfo('NA');
452
+			}
389 453
 			if (isset($departure_airport_array[0]['name'])) {
390 454
 				$temp_array['departure_airport_name'] = $departure_airport_array[0]['name'];
391 455
 				$temp_array['departure_airport_city'] = $departure_airport_array[0]['city'];
@@ -405,8 +469,12 @@  discard block
 block discarded – undo
405 469
 			
406 470
 			if ($row['arrival_airport_icao'] != '') {
407 471
 				$arrival_airport_array = $this->getAllAirportInfo($row['arrival_airport_icao']);
408
-				if (count($arrival_airport_array) == 0) $arrival_airport_array = $this->getAllAirportInfo('NA');
409
-			} else $arrival_airport_array = $this->getAllAirportInfo('NA');
472
+				if (count($arrival_airport_array) == 0) {
473
+					$arrival_airport_array = $this->getAllAirportInfo('NA');
474
+				}
475
+			} else {
476
+				$arrival_airport_array = $this->getAllAirportInfo('NA');
477
+			}
410 478
 			if (isset($arrival_airport_array[0]['name'])) {
411 479
 				$temp_array['arrival_airport_name'] = $arrival_airport_array[0]['name'];
412 480
 				$temp_array['arrival_airport_city'] = $arrival_airport_array[0]['city'];
@@ -422,27 +490,45 @@  discard block
 block discarded – undo
422 490
 				$temp_array['arrival_airport_time'] = $row['arrival_airport_time'];
423 491
 			}
424 492
 			*/
425
-			if (isset($row['pilot_id']) && $row['pilot_id'] != '') $temp_array['pilot_id'] = $row['pilot_id'];
426
-			if (isset($row['pilot_name']) && $row['pilot_name'] != '') $temp_array['pilot_name'] = $row['pilot_name'];
427
-			if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name'];
428
-			if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country'];
429
-			if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance'];
493
+			if (isset($row['pilot_id']) && $row['pilot_id'] != '') {
494
+				$temp_array['pilot_id'] = $row['pilot_id'];
495
+			}
496
+			if (isset($row['pilot_name']) && $row['pilot_name'] != '') {
497
+				$temp_array['pilot_name'] = $row['pilot_name'];
498
+			}
499
+			if (isset($row['source_name']) && $row['source_name'] != '') {
500
+				$temp_array['source_name'] = $row['source_name'];
501
+			}
502
+			if (isset($row['over_country']) && $row['over_country'] != '') {
503
+				$temp_array['over_country'] = $row['over_country'];
504
+			}
505
+			if (isset($row['distance']) && $row['distance'] != '') {
506
+				$temp_array['distance'] = $row['distance'];
507
+			}
430 508
 			if (isset($row['squawk'])) {
431 509
 				$temp_array['squawk'] = $row['squawk'];
432 510
 				if ($row['squawk'] != '' && isset($temp_array['country_iso2'])) {
433 511
 					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$temp_array['country_iso2']);
434
-					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
512
+					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) {
513
+						$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
514
+					}
435 515
 				} elseif ($row['squawk'] != '' && isset($temp_array['over_country'])) {
436 516
 					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$temp_array['over_country']);
437
-					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
438
-				} elseif ($row['squawk'] != '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
517
+					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) {
518
+						$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
519
+					}
520
+				} elseif ($row['squawk'] != '' && isset($globalSquawkCountry)) {
521
+					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
522
+				}
439 523
 			}
440 524
     			
441 525
 			$temp_array['query_number_rows'] = $num_rows;
442 526
 			
443 527
 			$spotter_array[] = $temp_array;
444 528
 		}
445
-		if ($num_rows == 0) return array();
529
+		if ($num_rows == 0) {
530
+			return array();
531
+		}
446 532
 		$spotter_array[0]['query_number_rows'] = $num_rows;
447 533
 		return $spotter_array;
448 534
 	}	
@@ -475,7 +561,9 @@  discard block
 block discarded – undo
475 561
 				foreach ($q_array as $q_item){
476 562
 					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
477 563
 					$additional_query .= " AND (";
478
-					if (is_int($q_item)) $additional_query .= "(spotter_output.spotter_id like '%".$q_item."%') OR ";
564
+					if (is_int($q_item)) {
565
+						$additional_query .= "(spotter_output.spotter_id like '%".$q_item."%') OR ";
566
+					}
479 567
 					$additional_query .= "(spotter_output.aircraft_icao like '%".$q_item."%') OR ";
480 568
 					$additional_query .= "(spotter_output.aircraft_name like '%".$q_item."%') OR ";
481 569
 					$additional_query .= "(spotter_output.aircraft_manufacturer like '%".$q_item."%') OR ";
@@ -496,7 +584,9 @@  discard block
 block discarded – undo
496 584
 					$additional_query .= "(spotter_output.pilot_name like '%".$q_item."%') OR ";
497 585
 					$additional_query .= "(spotter_output.ident like '%".$q_item."%') OR ";
498 586
 					$translate = $Translation->ident2icao($q_item);
499
-					if ($translate != $q_item) $additional_query .= "(spotter_output.ident like '%".$translate."%') OR ";
587
+					if ($translate != $q_item) {
588
+						$additional_query .= "(spotter_output.ident like '%".$translate."%') OR ";
589
+					}
500 590
 					$additional_query .= "(spotter_output.highlight like '%".$q_item."%')";
501 591
 					$additional_query .= ")";
502 592
 				}
@@ -723,7 +813,9 @@  discard block
 block discarded – undo
723 813
 				date_default_timezone_set($globalTimezone);
724 814
 				$datetime = new DateTime();
725 815
 				$offset = $datetime->format('P');
726
-			} else $offset = '+00:00';
816
+			} else {
817
+				$offset = '+00:00';
818
+			}
727 819
 
728 820
 			if ($date_array[1] != "")
729 821
 			{
@@ -755,8 +847,12 @@  discard block
 block discarded – undo
755 847
 			{
756 848
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
757 849
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
758
-			} else $limit_query = "";
759
-		} else $limit_query = "";
850
+			} else {
851
+				$limit_query = "";
852
+			}
853
+		} else {
854
+			$limit_query = "";
855
+		}
760 856
 
761 857
 
762 858
 		if ($sort != "")
@@ -824,8 +920,12 @@  discard block
 block discarded – undo
824 920
 			{
825 921
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
826 922
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
827
-			} else $limit_query = "";
828
-		} else $limit_query = "";
923
+			} else {
924
+				$limit_query = "";
925
+			}
926
+		} else {
927
+			$limit_query = "";
928
+		}
829 929
 		
830 930
 		if ($sort != "")
831 931
 		{
@@ -1149,7 +1249,9 @@  discard block
 block discarded – undo
1149 1249
 		global $global_query;
1150 1250
 		
1151 1251
 		date_default_timezone_set('UTC');
1152
-		if ($id == '') return array();
1252
+		if ($id == '') {
1253
+			return array();
1254
+		}
1153 1255
 		$additional_query = "spotter_output.spotter_id = :id";
1154 1256
 		$query_values = array(':id' => $id);
1155 1257
 
@@ -1776,7 +1878,9 @@  discard block
 block discarded – undo
1776 1878
 		{
1777 1879
 			$highlight = $row['highlight'];
1778 1880
 		}
1779
-		if (isset($highlight)) return $highlight;
1881
+		if (isset($highlight)) {
1882
+			return $highlight;
1883
+		}
1780 1884
 	}
1781 1885
 
1782 1886
 	
@@ -1804,7 +1908,9 @@  discard block
 block discarded – undo
1804 1908
 		$sth->closeCursor();
1805 1909
 		if (count($row) > 0) {
1806 1910
 			return $row['usage'];
1807
-		} else return '';
1911
+		} else {
1912
+			return '';
1913
+		}
1808 1914
 	}
1809 1915
 
1810 1916
 	/**
@@ -1829,7 +1935,9 @@  discard block
 block discarded – undo
1829 1935
 		$sth->closeCursor();
1830 1936
 		if (count($row) > 0) {
1831 1937
 			return $row['icao'];
1832
-		} else return '';
1938
+		} else {
1939
+			return '';
1940
+		}
1833 1941
 	}
1834 1942
 
1835 1943
 	/**
@@ -1857,7 +1965,9 @@  discard block
 block discarded – undo
1857 1965
 			$airport_longitude = $row['longitude'];
1858 1966
 			$Common = new Common();
1859 1967
 			return $Common->distance($latitude,$longitude,$airport_latitude,$airport_longitude);
1860
-		} else return '';
1968
+		} else {
1969
+			return '';
1970
+		}
1861 1971
 	}
1862 1972
 	
1863 1973
 	/**
@@ -1969,7 +2079,9 @@  discard block
 block discarded – undo
1969 2079
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1970 2080
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1971 2081
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1972
-		} else return array();
2082
+		} else {
2083
+			return array();
2084
+		}
1973 2085
 		if ($globalDBdriver == 'mysql') {
1974 2086
 			$query  = "SELECT airport.* FROM airport WHERE airport.latitude BETWEEN ".$minlat." AND ".$maxlat." AND airport.longitude BETWEEN ".$minlong." AND ".$maxlong." AND airport.type != 'closed'";
1975 2087
 		} else {
@@ -2004,7 +2116,9 @@  discard block
 block discarded – undo
2004 2116
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2005 2117
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2006 2118
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2007
-		} else return array();
2119
+		} else {
2120
+			return array();
2121
+		}
2008 2122
 		//$query  = "SELECT waypoints.* FROM waypoints WHERE waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong;
2009 2123
 		$query  = "SELECT waypoints.* FROM waypoints WHERE (waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong.") OR (waypoints.latitude_end BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_end BETWEEN ".$minlong." AND ".$maxlong.")";
2010 2124
 		//$query  = "SELECT waypoints.* FROM waypoints";
@@ -2039,7 +2153,9 @@  discard block
 block discarded – undo
2039 2153
 	public function getAllAirlineInfo($airline_icao, $fromsource = NULL)
2040 2154
 	{
2041 2155
 		global $globalUseRealAirlines;
2042
-		if (isset($globalUseRealAirlines) && $globalUseRealAirlines) $fromsource = NULL;
2156
+		if (isset($globalUseRealAirlines) && $globalUseRealAirlines) {
2157
+			$fromsource = NULL;
2158
+		}
2043 2159
 		$airline_icao = strtoupper(filter_var($airline_icao,FILTER_SANITIZE_STRING));
2044 2160
 		if ($airline_icao == 'NA') {
2045 2161
 			$airline_array = array();
@@ -2089,7 +2205,9 @@  discard block
 block discarded – undo
2089 2205
 				$sth->execute(array(':fromsource' => $fromsource));
2090 2206
 				$row = $sth->fetch(PDO::FETCH_ASSOC);
2091 2207
 				$sth->closeCursor();
2092
-				if ($row['nb'] == 0) $result = $this->getAllAirlineInfo($airline_icao);
2208
+				if ($row['nb'] == 0) {
2209
+					$result = $this->getAllAirlineInfo($airline_icao);
2210
+				}
2093 2211
 			}
2094 2212
 			return $result;
2095 2213
 		}
@@ -2153,15 +2271,20 @@  discard block
 block discarded – undo
2153 2271
 				'A320-211' => 'A320',
2154 2272
 				'747-8i' => 'B748',
2155 2273
 				'A380' => 'A388');
2156
-		if (isset($all_aircraft[$aircraft_type])) return $all_aircraft[$aircraft_type];
2274
+		if (isset($all_aircraft[$aircraft_type])) {
2275
+			return $all_aircraft[$aircraft_type];
2276
+		}
2157 2277
 
2158 2278
 		$query  = "SELECT aircraft.icao FROM aircraft WHERE aircraft.type LIKE :saircraft_type OR aircraft.type = :aircraft_type OR aircraft.icao = :aircraft_type LIMIT 1";
2159 2279
 		$aircraft_type = strtoupper($aircraft_type);
2160 2280
 		$sth = $this->db->prepare($query);
2161 2281
 		$sth->execute(array(':saircraft_type' => '%'.$aircraft_type.'%',':aircraft_type' => $aircraft_type,));
2162 2282
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
2163
-		if (isset($result[0]['icao'])) return $result[0]['icao'];
2164
-		else return '';
2283
+		if (isset($result[0]['icao'])) {
2284
+			return $result[0]['icao'];
2285
+		} else {
2286
+			return '';
2287
+		}
2165 2288
 	}
2166 2289
 	
2167 2290
 	/**
@@ -2184,7 +2307,9 @@  discard block
 block discarded – undo
2184 2307
 		$sth->closeCursor();
2185 2308
 		if (isset($row['icaotypecode'])) {
2186 2309
 			return $row['icaotypecode'];
2187
-		} else return '';
2310
+		} else {
2311
+			return '';
2312
+		}
2188 2313
 	}
2189 2314
 
2190 2315
 	/**
@@ -2206,7 +2331,9 @@  discard block
 block discarded – undo
2206 2331
 		$sth->closeCursor();
2207 2332
 		if (isset($row['operator_correct'])) {
2208 2333
 			return $row['operator_correct'];
2209
-		} else return $operator;
2334
+		} else {
2335
+			return $operator;
2336
+		}
2210 2337
 	}
2211 2338
 
2212 2339
 	/**
@@ -2219,7 +2346,9 @@  discard block
 block discarded – undo
2219 2346
 	public function getRouteInfo($callsign)
2220 2347
 	{
2221 2348
 		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
2222
-                if ($callsign == '') return array();
2349
+                if ($callsign == '') {
2350
+                	return array();
2351
+                }
2223 2352
 		$query  = "SELECT routes.Operator_ICAO, routes.FromAirport_ICAO, routes.ToAirport_ICAO, routes.RouteStop, routes.FromAirport_Time, routes.ToAirport_Time FROM routes WHERE CallSign = :callsign LIMIT 1";
2224 2353
 		
2225 2354
 		$sth = $this->db->prepare($query);
@@ -2229,7 +2358,9 @@  discard block
 block discarded – undo
2229 2358
 		$sth->closeCursor();
2230 2359
 		if (count($row) > 0) {
2231 2360
 			return $row;
2232
-		} else return array();
2361
+		} else {
2362
+			return array();
2363
+		}
2233 2364
 	}
2234 2365
 	
2235 2366
 	/**
@@ -2282,7 +2413,9 @@  discard block
 block discarded – undo
2282 2413
 			$result = $sth->fetch(PDO::FETCH_ASSOC);
2283 2414
 			$sth->closeCursor();
2284 2415
 			return $result;
2285
-		} else return array();
2416
+		} else {
2417
+			return array();
2418
+		}
2286 2419
 	}
2287 2420
 	
2288 2421
   
@@ -2439,8 +2572,11 @@  discard block
 block discarded – undo
2439 2572
 		$query .= " ORDER BY spotter_output.source_name ASC";
2440 2573
 
2441 2574
 		$sth = $this->db->prepare($query);
2442
-		if (!empty($query_values)) $sth->execute($query_values);
2443
-		else $sth->execute();
2575
+		if (!empty($query_values)) {
2576
+			$sth->execute($query_values);
2577
+		} else {
2578
+			$sth->execute();
2579
+		}
2444 2580
 
2445 2581
 		$source_array = array();
2446 2582
 		$temp_array = array();
@@ -2473,9 +2609,13 @@  discard block
 block discarded – undo
2473 2609
 								WHERE spotter_output.airline_icao <> '' 
2474 2610
 								ORDER BY spotter_output.airline_name ASC";
2475 2611
 			*/
2476
-			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $forsource = $globalAirlinesSource;
2477
-			elseif (isset($globalVATSIM) && $globalVATSIM) $forsource = 'vatsim';
2478
-			elseif (isset($globalIVAO) && $globalIVAO) $forsource = 'ivao';
2612
+			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
2613
+				$forsource = $globalAirlinesSource;
2614
+			} elseif (isset($globalVATSIM) && $globalVATSIM) {
2615
+				$forsource = 'vatsim';
2616
+			} elseif (isset($globalIVAO) && $globalIVAO) {
2617
+				$forsource = 'ivao';
2618
+			}
2479 2619
 			if ($forsource === NULL) {
2480 2620
 				$query = "SELECT DISTINCT icao AS airline_icao, name AS airline_name, type AS airline_type FROM airlines WHERE forsource IS NULL ORDER BY name ASC";
2481 2621
 				$query_data = array();
@@ -2767,7 +2907,9 @@  discard block
 block discarded – undo
2767 2907
 			date_default_timezone_set($globalTimezone);
2768 2908
 			$datetime = new DateTime();
2769 2909
 			$offset = $datetime->format('P');
2770
-		} else $offset = '+00:00';
2910
+		} else {
2911
+			$offset = '+00:00';
2912
+		}
2771 2913
 		if ($airport_icao == '') {
2772 2914
 			if ($globalDBdriver == 'mysql') {
2773 2915
 				$query = "SELECT COUNT(departure_airport_icao) AS departure_airport_count, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output`".$filter_query." spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND departure_airport_icao <> 'NA' GROUP BY departure_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), departure_airport_name, departure_airport_city, departure_airport_country ORDER BY departure_airport_count DESC";
@@ -2799,7 +2941,9 @@  discard block
 block discarded – undo
2799 2941
 			date_default_timezone_set($globalTimezone);
2800 2942
 			$datetime = new DateTime();
2801 2943
 			$offset = $datetime->format('P');
2802
-		} else $offset = '+00:00';
2944
+		} else {
2945
+			$offset = '+00:00';
2946
+		}
2803 2947
 		if ($airport_icao == '') {
2804 2948
 			if ($globalDBdriver == 'mysql') {
2805 2949
 				$query = "SELECT spotter_output.airline_icao, COUNT(departure_airport_icao) AS departure_airport_count, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output` WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND departure_airport_icao <> 'NA' AND spotter_output.airline_icao <> '' GROUP BY spotter_output.airline_icao, departure_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), departure_airport_name, departure_airport_city, departure_airport_country ORDER BY departure_airport_count DESC";
@@ -2832,7 +2976,9 @@  discard block
 block discarded – undo
2832 2976
 			date_default_timezone_set($globalTimezone);
2833 2977
 			$datetime = new DateTime();
2834 2978
 			$offset = $datetime->format('P');
2835
-		} else $offset = '+00:00';
2979
+		} else {
2980
+			$offset = '+00:00';
2981
+		}
2836 2982
 		if ($airport_icao == '') {
2837 2983
 			if ($globalDBdriver == 'mysql') {
2838 2984
 				$query = "SELECT COUNT(real_departure_airport_icao) AS departure_airport_count, real_departure_airport_icao AS departure_airport_icao, airport.name AS departure_airport_name, airport.city AS departure_airport_city, airport.country AS departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date 
@@ -2871,7 +3017,9 @@  discard block
 block discarded – undo
2871 3017
 			date_default_timezone_set($globalTimezone);
2872 3018
 			$datetime = new DateTime();
2873 3019
 			$offset = $datetime->format('P');
2874
-		} else $offset = '+00:00';
3020
+		} else {
3021
+			$offset = '+00:00';
3022
+		}
2875 3023
 		if ($airport_icao == '') {
2876 3024
 			if ($globalDBdriver == 'mysql') {
2877 3025
 				$query = "SELECT spotter_output.airline_icao, COUNT(real_departure_airport_icao) AS departure_airport_count, real_departure_airport_icao AS departure_airport_icao, airport.name AS departure_airport_name, airport.city AS departure_airport_city, airport.country AS departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date 
@@ -2916,7 +3064,9 @@  discard block
 block discarded – undo
2916 3064
 			date_default_timezone_set($globalTimezone);
2917 3065
 			$datetime = new DateTime();
2918 3066
 			$offset = $datetime->format('P');
2919
-		} else $offset = '+00:00';
3067
+		} else {
3068
+			$offset = '+00:00';
3069
+		}
2920 3070
 		if ($airport_icao == '') {
2921 3071
 			if ($globalDBdriver == 'mysql') {
2922 3072
 				$query = "SELECT COUNT(arrival_airport_icao) AS arrival_airport_count, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output`".$filter_query." spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND arrival_airport_icao <> 'NA' GROUP BY arrival_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), arrival_airport_name, arrival_airport_city, arrival_airport_country ORDER BY arrival_airport_count DESC";
@@ -2951,7 +3101,9 @@  discard block
 block discarded – undo
2951 3101
 			date_default_timezone_set($globalTimezone);
2952 3102
 			$datetime = new DateTime();
2953 3103
 			$offset = $datetime->format('P');
2954
-		} else $offset = '+00:00';
3104
+		} else {
3105
+			$offset = '+00:00';
3106
+		}
2955 3107
 		if ($airport_icao == '') {
2956 3108
 			if ($globalDBdriver == 'mysql') {
2957 3109
 				$query = "SELECT COUNT(real_arrival_airport_icao) AS arrival_airport_count, real_arrival_airport_icao AS arrival_airport_icao, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date 
@@ -2993,7 +3145,9 @@  discard block
 block discarded – undo
2993 3145
 			date_default_timezone_set($globalTimezone);
2994 3146
 			$datetime = new DateTime();
2995 3147
 			$offset = $datetime->format('P');
2996
-		} else $offset = '+00:00';
3148
+		} else {
3149
+			$offset = '+00:00';
3150
+		}
2997 3151
 		if ($airport_icao == '') {
2998 3152
 			if ($globalDBdriver == 'mysql') {
2999 3153
 				$query = "SELECT spotter_output.airline_icao, COUNT(arrival_airport_icao) AS arrival_airport_count, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output` WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND arrival_airport_icao <> 'NA' AND spotter_output.airline_icao <> '' GROUP BY spotter_output.airline_icao, arrival_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), arrival_airport_name, arrival_airport_city, arrival_airport_country ORDER BY arrival_airport_count DESC";
@@ -3027,7 +3181,9 @@  discard block
 block discarded – undo
3027 3181
 			date_default_timezone_set($globalTimezone);
3028 3182
 			$datetime = new DateTime();
3029 3183
 			$offset = $datetime->format('P');
3030
-		} else $offset = '+00:00';
3184
+		} else {
3185
+			$offset = '+00:00';
3186
+		}
3031 3187
 		if ($airport_icao == '') {
3032 3188
 			if ($globalDBdriver == 'mysql') {
3033 3189
 				$query = "SELECT spotter_output.airline_icao, COUNT(real_arrival_airport_icao) AS arrival_airport_count, real_arrival_airport_icao AS arrival_airport_icao, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date 
@@ -3075,7 +3231,9 @@  discard block
 block discarded – undo
3075 3231
 			date_default_timezone_set($globalTimezone);
3076 3232
 			$datetime = new DateTime();
3077 3233
 			$offset = $datetime->format('P');
3078
-		} else $offset = '+00:00';
3234
+		} else {
3235
+			$offset = '+00:00';
3236
+		}
3079 3237
 
3080 3238
 		if ($globalDBdriver == 'mysql') {
3081 3239
 			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) as date
@@ -3195,7 +3353,9 @@  discard block
 block discarded – undo
3195 3353
 	*/	
3196 3354
 	public function updateLatestSpotterData($flightaware_id = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $ground = false, $groundspeed = NULL, $date = '', $arrival_airport_icao = '',$arrival_airport_time = '')
3197 3355
 	{
3198
-		if ($groundspeed == '') $groundspeed = NULL;
3356
+		if ($groundspeed == '') {
3357
+			$groundspeed = NULL;
3358
+		}
3199 3359
 		$query = 'UPDATE spotter_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_altitude = :last_altitude, last_ground = :last_ground, last_seen = :last_seen, real_arrival_airport_icao = :real_arrival_airport_icao, real_arrival_airport_time = :real_arrival_airport_time, last_ground_speed = :last_ground_speed WHERE flightaware_id = :flightaware_id';
3200 3360
                 $query_values = array(':flightaware_id' => $flightaware_id,':real_arrival_airport_icao' => $arrival_airport_icao,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_altitude' => $altitude,':last_ground_speed' => $groundspeed,':last_seen' => $date,':real_arrival_airport_time' => $arrival_airport_time, ':last_ground' => $ground, ':ident' => $ident);
3201 3361
 
@@ -3245,10 +3405,18 @@  discard block
 block discarded – undo
3245 3405
 		$Image = new Image($this->db);
3246 3406
 		$Common = new Common();
3247 3407
 		
3248
-		if (!isset($globalIVAO)) $globalIVAO = FALSE;
3249
-		if (!isset($globalVATSIM)) $globalVATSIM = FALSE;
3250
-		if (!isset($globalphpVMS)) $globalphpVMS = FALSE;
3251
-		if (!isset($globalVAM)) $globalVAM = FALSE;
3408
+		if (!isset($globalIVAO)) {
3409
+			$globalIVAO = FALSE;
3410
+		}
3411
+		if (!isset($globalVATSIM)) {
3412
+			$globalVATSIM = FALSE;
3413
+		}
3414
+		if (!isset($globalphpVMS)) {
3415
+			$globalphpVMS = FALSE;
3416
+		}
3417
+		if (!isset($globalVAM)) {
3418
+			$globalVAM = FALSE;
3419
+		}
3252 3420
 		date_default_timezone_set('UTC');
3253 3421
 		
3254 3422
 		//getting the registration
@@ -3261,23 +3429,33 @@  discard block
 block discarded – undo
3261 3429
 				if ($ModeS != '') {
3262 3430
 					$timeelapsed = microtime(true);
3263 3431
 					$registration = $this->getAircraftRegistrationBymodeS($ModeS);
3264
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3432
+					if ($globalDebugTimeElapsed) {
3433
+						echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3434
+					}
3265 3435
 				} else {
3266 3436
 					$myhex = explode('-',$flightaware_id);
3267 3437
 					if (count($myhex) > 0) {
3268 3438
 						$timeelapsed = microtime(true);
3269 3439
 						$registration = $this->getAircraftRegistrationBymodeS($myhex[0]);
3270
-						if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3440
+						if ($globalDebugTimeElapsed) {
3441
+							echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3442
+						}
3271 3443
 					}
3272 3444
 				}
3273 3445
 			}
3274 3446
 		}
3275 3447
 		$fromsource = NULL;
3276
-		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
3277
-		elseif ($format_source == 'vatsimtxt') $fromsource = 'vatsim';
3278
-		elseif ($format_source == 'whazzup') $fromsource = 'ivao';
3279
-		elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
3280
-		elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
3448
+		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
3449
+			$fromsource = $globalAirlinesSource;
3450
+		} elseif ($format_source == 'vatsimtxt') {
3451
+			$fromsource = 'vatsim';
3452
+		} elseif ($format_source == 'whazzup') {
3453
+			$fromsource = 'ivao';
3454
+		} elseif (isset($globalVATSIM) && $globalVATSIM) {
3455
+			$fromsource = 'vatsim';
3456
+		} elseif (isset($globalIVAO) && $globalIVAO) {
3457
+			$fromsource = 'ivao';
3458
+		}
3281 3459
 		//getting the airline information
3282 3460
 		if ($ident != "")
3283 3461
 		{
@@ -3301,15 +3479,21 @@  discard block
 block discarded – undo
3301 3479
 					if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == ""){
3302 3480
 						$airline_array = $this->getAllAirlineInfo("NA");
3303 3481
 					}
3304
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3482
+					if ($globalDebugTimeElapsed) {
3483
+						echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3484
+					}
3305 3485
 
3306 3486
 				} else {
3307 3487
 					$timeelapsed = microtime(true);
3308 3488
 					$airline_array = $this->getAllAirlineInfo("NA");
3309
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3489
+					if ($globalDebugTimeElapsed) {
3490
+						echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3491
+					}
3310 3492
 				}
3311 3493
 			}
3312
-		} else $airline_array = array();
3494
+		} else {
3495
+			$airline_array = array();
3496
+		}
3313 3497
 		
3314 3498
 		//getting the aircraft information
3315 3499
 		$aircraft_array = array();
@@ -3323,27 +3507,37 @@  discard block
 block discarded – undo
3323 3507
 				{
3324 3508
 					$timeelapsed = microtime(true);
3325 3509
 					$aircraft_array = $this->getAllAircraftInfo("NA");
3326
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3510
+					if ($globalDebugTimeElapsed) {
3511
+						echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3512
+					}
3327 3513
 				} else {
3328 3514
 					$timeelapsed = microtime(true);
3329 3515
 					$aircraft_array = $this->getAllAircraftInfo($aircraft_icao);
3330
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3516
+					if ($globalDebugTimeElapsed) {
3517
+						echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3518
+					}
3331 3519
 				}
3332 3520
 			}
3333 3521
 		} else {
3334 3522
 			if ($ModeS != '') {
3335 3523
 				$timeelapsed = microtime(true);
3336 3524
 				$aircraft_icao = $this->getAllAircraftType($ModeS);
3337
-				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAircraftType : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3525
+				if ($globalDebugTimeElapsed) {
3526
+					echo 'ADD SPOTTER DATA : Time elapsed for getAllAircraftType : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3527
+				}
3338 3528
 				if ($aircraft_icao == "" || $aircraft_icao == "XXXX")
3339 3529
 				{
3340 3530
 					$timeelapsed = microtime(true);
3341 3531
 					$aircraft_array = $this->getAllAircraftInfo("NA");
3342
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3532
+					if ($globalDebugTimeElapsed) {
3533
+						echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3534
+					}
3343 3535
 				} else {
3344 3536
 					$timeelapsed = microtime(true);
3345 3537
 					$aircraft_array = $this->getAllAircraftInfo($aircraft_icao);
3346
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3538
+					if ($globalDebugTimeElapsed) {
3539
+						echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3540
+					}
3347 3541
 				}
3348 3542
 			}
3349 3543
 		}
@@ -3358,7 +3552,9 @@  discard block
 block discarded – undo
3358 3552
 			} else {
3359 3553
 				$timeelapsed = microtime(true);
3360 3554
 				$departure_airport_array = $this->getAllAirportInfo($departure_airport_icao);
3361
-				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3555
+				if ($globalDebugTimeElapsed) {
3556
+					echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3557
+				}
3362 3558
 			}
3363 3559
 		}
3364 3560
 		
@@ -3372,7 +3568,9 @@  discard block
 block discarded – undo
3372 3568
 			} else {
3373 3569
 				$timeelapsed = microtime(true);
3374 3570
 				$arrival_airport_array = $this->getAllAirportInfo($arrival_airport_icao);
3375
-				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3571
+				if ($globalDebugTimeElapsed) {
3572
+					echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3573
+				}
3376 3574
 			}
3377 3575
 		}
3378 3576
 
@@ -3407,7 +3605,9 @@  discard block
 block discarded – undo
3407 3605
 			{
3408 3606
 				return false;
3409 3607
 			}
3410
-		} else $altitude = 0;
3608
+		} else {
3609
+			$altitude = 0;
3610
+		}
3411 3611
 		
3412 3612
 		if ($heading != "")
3413 3613
 		{
@@ -3436,7 +3636,9 @@  discard block
 block discarded – undo
3436 3636
 		{
3437 3637
 			$timeelapsed = microtime(true);
3438 3638
 			$image_array = $Image->getSpotterImage($registration);
3439
-			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getSpotterImage : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3639
+			if ($globalDebugTimeElapsed) {
3640
+				echo 'ADD SPOTTER DATA : Time elapsed for getSpotterImage : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3641
+			}
3440 3642
 			if (!isset($image_array[0]['registration']))
3441 3643
 			{
3442 3644
 				//echo "Add image !!!! \n";
@@ -3444,14 +3646,21 @@  discard block
 block discarded – undo
3444 3646
 			}
3445 3647
 			$timeelapsed = microtime(true);
3446 3648
 			$owner_info = $this->getAircraftOwnerByRegistration($registration);
3447
-			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftOwnerByRegistration : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3448
-			if ($owner_info['owner'] != '') $aircraft_owner = ucwords(strtolower($owner_info['owner']));
3649
+			if ($globalDebugTimeElapsed) {
3650
+				echo 'ADD SPOTTER DATA : Time elapsed for getAircraftOwnerByRegistration : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3651
+			}
3652
+			if ($owner_info['owner'] != '') {
3653
+				$aircraft_owner = ucwords(strtolower($owner_info['owner']));
3654
+			}
3449 3655
 		}
3450 3656
     
3451 3657
 		if ($globalIVAO && $aircraft_icao != '')
3452 3658
 		{
3453
-            		if (isset($airline_array[0]['icao'])) $airline_icao = $airline_array[0]['icao'];
3454
-            		else $airline_icao = '';
3659
+            		if (isset($airline_array[0]['icao'])) {
3660
+            			$airline_icao = $airline_array[0]['icao'];
3661
+            		} else {
3662
+            			$airline_icao = '';
3663
+            		}
3455 3664
 			$image_array = $Image->getSpotterImage('',$aircraft_icao,$airline_icao);
3456 3665
 			if (!isset($image_array[0]['registration']))
3457 3666
 			{
@@ -3496,16 +3705,28 @@  discard block
 block discarded – undo
3496 3705
                 {
3497 3706
                         $arrival_airport_array = $this->getAllAirportInfo('NA');
3498 3707
                 }
3499
-                if ($registration == '') $registration = 'NA';
3708
+                if ($registration == '') {
3709
+                	$registration = 'NA';
3710
+                }
3500 3711
                 if ($latitude == '' && $longitude == '') {
3501 3712
             		$latitude = 0;
3502 3713
             		$longitude = 0;
3503 3714
             	}
3504
-                if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL;
3505
-                if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL;
3506
-                if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
3507
-                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
3508
-                if (!isset($aircraft_owner)) $aircraft_owner = NULL;
3715
+                if ($squawk == '' || $Common->isInteger($squawk) === false) {
3716
+                	$squawk = NULL;
3717
+                }
3718
+                if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) {
3719
+                	$verticalrate = NULL;
3720
+                }
3721
+                if ($heading == '' || $Common->isInteger($heading) === false) {
3722
+                	$heading = 0;
3723
+                }
3724
+                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) {
3725
+                	$groundspeed = 0;
3726
+                }
3727
+                if (!isset($aircraft_owner)) {
3728
+                	$aircraft_owner = NULL;
3729
+                }
3509 3730
                 $query  = "INSERT INTO spotter_output (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop,highlight,ModeS, pilot_id, pilot_name, verticalrate, owner_name, ground, format_source, source_name) 
3510 3731
                 VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name,:departure_airport_city,:departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date, :departure_airport_time, :arrival_airport_time, :squawk, :route_stop, :highlight, :ModeS, :pilot_id, :pilot_name, :verticalrate, :owner_name,:ground, :format_source, :source_name)";
3511 3732
 
@@ -3516,9 +3737,13 @@  discard block
 block discarded – undo
3516 3737
 		if ($airline_type == '') {
3517 3738
 			$timeelapsed = microtime(true);
3518 3739
 			$airline_type = $this->getAircraftTypeBymodeS($ModeS);
3519
-			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftTypeBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3740
+			if ($globalDebugTimeElapsed) {
3741
+				echo 'ADD SPOTTER DATA : Time elapsed for getAircraftTypeBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3742
+			}
3743
+		}
3744
+		if ($airline_type == null) {
3745
+			$airline_type = '';
3520 3746
 		}
3521
-		if ($airline_type == null) $airline_type = '';
3522 3747
                 $aircraft_type = $aircraft_array[0]['type'];
3523 3748
                 $aircraft_manufacturer = $aircraft_array[0]['manufacturer'];
3524 3749
                 $departure_airport_name = $departure_airport_array[0]['name'];
@@ -3653,7 +3878,9 @@  discard block
 block discarded – undo
3653 3878
 			}
3654 3879
 		}
3655 3880
 		$query .= "GROUP BY spotter_output.airline_name,spotter_output.airline_icao, spotter_output.airline_country ORDER BY airline_count DESC";
3656
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
3881
+		if ($limit) {
3882
+			$query .= " LIMIT 10 OFFSET 0";
3883
+		}
3657 3884
 		
3658 3885
 		$sth = $this->db->prepare($query);
3659 3886
 		$sth->execute();
@@ -3698,7 +3925,9 @@  discard block
 block discarded – undo
3698 3925
 			}
3699 3926
 		}
3700 3927
 		$query .= "GROUP BY spotter_output.pilot_id,spotter_output.pilot_name ORDER BY pilot_count DESC";
3701
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
3928
+		if ($limit) {
3929
+			$query .= " LIMIT 10 OFFSET 0";
3930
+		}
3702 3931
       
3703 3932
 		
3704 3933
 		$sth = $this->db->prepare($query);
@@ -3743,7 +3972,9 @@  discard block
 block discarded – undo
3743 3972
 			}
3744 3973
 		}
3745 3974
 		$query .= "GROUP BY spotter_output.airline_icao, spotter_output.pilot_id,spotter_output.pilot_name ORDER BY pilot_count DESC";
3746
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
3975
+		if ($limit) {
3976
+			$query .= " LIMIT 10 OFFSET 0";
3977
+		}
3747 3978
       
3748 3979
 		
3749 3980
 		$sth = $this->db->prepare($query);
@@ -3790,7 +4021,9 @@  discard block
 block discarded – undo
3790 4021
 			}
3791 4022
 		}
3792 4023
 		$query .= "GROUP BY spotter_output.owner_name ORDER BY owner_count DESC";
3793
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4024
+		if ($limit) {
4025
+			$query .= " LIMIT 10 OFFSET 0";
4026
+		}
3794 4027
       
3795 4028
 		
3796 4029
 		$sth = $this->db->prepare($query);
@@ -3835,7 +4068,9 @@  discard block
 block discarded – undo
3835 4068
 			}
3836 4069
 		}
3837 4070
 		$query .= "GROUP BY spotter_output.airline_icao, spotter_output.owner_name ORDER BY owner_count DESC";
3838
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4071
+		if ($limit) {
4072
+			$query .= " LIMIT 10 OFFSET 0";
4073
+		}
3839 4074
       
3840 4075
 		
3841 4076
 		$sth = $this->db->prepare($query);
@@ -4078,7 +4313,9 @@  discard block
 block discarded – undo
4078 4313
 			date_default_timezone_set($globalTimezone);
4079 4314
 			$datetime = new DateTime($date);
4080 4315
 			$offset = $datetime->format('P');
4081
-		} else $offset = '+00:00';
4316
+		} else {
4317
+			$offset = '+00:00';
4318
+		}
4082 4319
 
4083 4320
 		if ($globalDBdriver == 'mysql') {
4084 4321
 			$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
@@ -4126,7 +4363,9 @@  discard block
 block discarded – undo
4126 4363
 			date_default_timezone_set($globalTimezone);
4127 4364
 			$datetime = new DateTime($date);
4128 4365
 			$offset = $datetime->format('P');
4129
-		} else $offset = '+00:00';
4366
+		} else {
4367
+			$offset = '+00:00';
4368
+		}
4130 4369
 		
4131 4370
 		if ($globalDBdriver == 'mysql') {
4132 4371
 			$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
@@ -4344,7 +4583,9 @@  discard block
 block discarded – undo
4344 4583
 		 			FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND spotter_output.airline_country <> 'NA' 
4345 4584
 					GROUP BY spotter_output.airline_country
4346 4585
 					ORDER BY airline_country_count DESC";
4347
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4586
+		if ($limit) {
4587
+			$query .= " LIMIT 10 OFFSET 0";
4588
+		}
4348 4589
       
4349 4590
 		$sth = $this->db->prepare($query);
4350 4591
 		$sth->execute();
@@ -4372,7 +4613,9 @@  discard block
 block discarded – undo
4372 4613
 		global $globalDBdriver;
4373 4614
 		//$filter_query = $this->getFilter($filters,true,true);
4374 4615
 		$Connection= new Connection($this->db);
4375
-		if (!$Connection->tableExists('countries')) return array();
4616
+		if (!$Connection->tableExists('countries')) {
4617
+			return array();
4618
+		}
4376 4619
 		/*
4377 4620
 		$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
4378 4621
 					FROM countries c, spotter_output s
@@ -4397,7 +4640,9 @@  discard block
 block discarded – undo
4397 4640
 		}
4398 4641
 
4399 4642
 		$query .= "GROUP BY c.name ORDER BY nb DESC";
4400
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4643
+		if ($limit) {
4644
+			$query .= " LIMIT 10 OFFSET 0";
4645
+		}
4401 4646
       
4402 4647
 		
4403 4648
 		$sth = $this->db->prepare($query);
@@ -4447,7 +4692,9 @@  discard block
 block discarded – undo
4447 4692
 		}
4448 4693
 
4449 4694
 		$query .= " GROUP BY spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer ORDER BY aircraft_icao_count DESC";
4450
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4695
+		if ($limit) {
4696
+			$query .= " LIMIT 10 OFFSET 0";
4697
+		}
4451 4698
  
4452 4699
 		$sth = $this->db->prepare($query);
4453 4700
 		$sth->execute();
@@ -4493,7 +4740,9 @@  discard block
 block discarded – undo
4493 4740
 		}
4494 4741
 
4495 4742
 		$query .= "GROUP BY spotter_output.airline_icao, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer ORDER BY aircraft_icao_count DESC";
4496
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4743
+		if ($limit) {
4744
+			$query .= " LIMIT 10 OFFSET 0";
4745
+		}
4497 4746
  
4498 4747
 		$sth = $this->db->prepare($query);
4499 4748
 		$sth->execute();
@@ -4546,7 +4795,9 @@  discard block
 block discarded – undo
4546 4795
 			if($row['registration'] != "")
4547 4796
 			{
4548 4797
 				$image_array = $Image->getSpotterImage($row['registration']);
4549
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
4798
+				if (isset($image_array[0]['image_thumbnail'])) {
4799
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
4800
+				}
4550 4801
 			}
4551 4802
 			$temp_array['registration_count'] = $row['registration_count'];
4552 4803
 
@@ -4621,7 +4872,9 @@  discard block
 block discarded – undo
4621 4872
 			if($row['registration'] != "")
4622 4873
 			{
4623 4874
 				$image_array = $Image->getSpotterImage($row['registration']);
4624
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
4875
+				if (isset($image_array[0]['image_thumbnail'])) {
4876
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
4877
+				}
4625 4878
 			}
4626 4879
 			$temp_array['registration_count'] = $row['registration_count'];
4627 4880
 
@@ -4728,7 +4981,9 @@  discard block
 block discarded – undo
4728 4981
 			if($row['registration'] != "")
4729 4982
 			{
4730 4983
 				$image_array = $Image->getSpotterImage($row['registration']);
4731
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
4984
+				if (isset($image_array[0]['image_thumbnail'])) {
4985
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
4986
+				}
4732 4987
 			}
4733 4988
 			$temp_array['registration_count'] = $row['registration_count'];
4734 4989
 			$aircraft_array[] = $temp_array;
@@ -4853,7 +5108,9 @@  discard block
 block discarded – undo
4853 5108
 			date_default_timezone_set($globalTimezone);
4854 5109
 			$datetime = new DateTime($date);
4855 5110
 			$offset = $datetime->format('P');
4856
-		} else $offset = '+00:00';
5111
+		} else {
5112
+			$offset = '+00:00';
5113
+		}
4857 5114
 
4858 5115
 		if ($globalDBdriver == 'mysql') {
4859 5116
 			$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
@@ -4900,7 +5157,9 @@  discard block
 block discarded – undo
4900 5157
 			date_default_timezone_set($globalTimezone);
4901 5158
 			$datetime = new DateTime($date);
4902 5159
 			$offset = $datetime->format('P');
4903
-		} else $offset = '+00:00';
5160
+		} else {
5161
+			$offset = '+00:00';
5162
+		}
4904 5163
 
4905 5164
 		if ($globalDBdriver == 'mysql') {
4906 5165
 			$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name 
@@ -4929,7 +5188,9 @@  discard block
 block discarded – undo
4929 5188
 			if($row['registration'] != "")
4930 5189
 			{
4931 5190
 				$image_array = $Image->getSpotterImage($row['registration']);
4932
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5191
+				if (isset($image_array[0]['image_thumbnail'])) {
5192
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5193
+				}
4933 5194
 			}
4934 5195
 			$temp_array['registration_count'] = $row['registration_count'];
4935 5196
  
@@ -4954,7 +5215,9 @@  discard block
 block discarded – undo
4954 5215
 			date_default_timezone_set($globalTimezone);
4955 5216
 			$datetime = new DateTime($date);
4956 5217
 			$offset = $datetime->format('P');
4957
-		} else $offset = '+00:00';
5218
+		} else {
5219
+			$offset = '+00:00';
5220
+		}
4958 5221
 
4959 5222
 		if ($globalDBdriver == 'mysql') {
4960 5223
 			$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
@@ -5052,8 +5315,11 @@  discard block
 block discarded – undo
5052 5315
 			if($row['registration'] != "")
5053 5316
 			{
5054 5317
 				$image_array = $Image->getSpotterImage($row['registration']);
5055
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5056
-				else $temp_array['image_thumbnail'] = '';
5318
+				if (isset($image_array[0]['image_thumbnail'])) {
5319
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5320
+				} else {
5321
+					$temp_array['image_thumbnail'] = '';
5322
+				}
5057 5323
 			}
5058 5324
 			$temp_array['registration_count'] = $row['registration_count'];
5059 5325
 			$aircraft_array[] = $temp_array;
@@ -5160,7 +5426,9 @@  discard block
 block discarded – undo
5160 5426
 			if($row['registration'] != "")
5161 5427
 			{
5162 5428
 				$image_array = $Image->getSpotterImage($row['registration']);
5163
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5429
+				if (isset($image_array[0]['image_thumbnail'])) {
5430
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5431
+				}
5164 5432
 			}
5165 5433
 			$temp_array['registration_count'] = $row['registration_count'];
5166 5434
           
@@ -5277,7 +5545,9 @@  discard block
 block discarded – undo
5277 5545
 			if($row['registration'] != "")
5278 5546
 			{
5279 5547
 				$image_array = $Image->getSpotterImage($row['registration']);
5280
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5548
+				if (isset($image_array[0]['image_thumbnail'])) {
5549
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5550
+				}
5281 5551
 			}
5282 5552
 			$temp_array['registration_count'] = $row['registration_count'];
5283 5553
           
@@ -5389,7 +5659,9 @@  discard block
 block discarded – undo
5389 5659
 		// if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
5390 5660
 		//if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
5391 5661
                 $query .= " GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name ORDER BY aircraft_registration_count DESC";
5392
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5662
+		if ($limit) {
5663
+			$query .= " LIMIT 10 OFFSET 0";
5664
+		}
5393 5665
 		
5394 5666
 		$sth = $this->db->prepare($query);
5395 5667
 		$sth->execute();
@@ -5408,7 +5680,9 @@  discard block
 block discarded – undo
5408 5680
 			if($row['registration'] != "")
5409 5681
 			{
5410 5682
 				$image_array = $Image->getSpotterImage($row['registration']);
5411
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5683
+				if (isset($image_array[0]['image_thumbnail'])) {
5684
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5685
+				}
5412 5686
 			}
5413 5687
           
5414 5688
 			$aircraft_array[] = $temp_array;
@@ -5449,7 +5723,9 @@  discard block
 block discarded – undo
5449 5723
 		// if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
5450 5724
 		//if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
5451 5725
                 $query .= "GROUP BY spotter_output.airline_icao, spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name ORDER BY aircraft_registration_count DESC";
5452
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5726
+		if ($limit) {
5727
+			$query .= " LIMIT 10 OFFSET 0";
5728
+		}
5453 5729
 		
5454 5730
 		$sth = $this->db->prepare($query);
5455 5731
 		$sth->execute();
@@ -5469,7 +5745,9 @@  discard block
 block discarded – undo
5469 5745
 			if($row['registration'] != "")
5470 5746
 			{
5471 5747
 				$image_array = $Image->getSpotterImage($row['registration']);
5472
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5748
+				if (isset($image_array[0]['image_thumbnail'])) {
5749
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5750
+				}
5473 5751
 			}
5474 5752
           
5475 5753
 			$aircraft_array[] = $temp_array;
@@ -5510,7 +5788,9 @@  discard block
 block discarded – undo
5510 5788
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
5511 5789
                 $query .= " GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
5512 5790
 				ORDER BY airport_departure_icao_count DESC";
5513
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5791
+		if ($limit) {
5792
+			$query .= " LIMIT 10 OFFSET 0";
5793
+		}
5514 5794
       
5515 5795
 		$sth = $this->db->prepare($query);
5516 5796
 		$sth->execute();
@@ -5562,7 +5842,9 @@  discard block
 block discarded – undo
5562 5842
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
5563 5843
                 $query .= "GROUP BY spotter_output.airline_icao, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
5564 5844
 				ORDER BY airport_departure_icao_count DESC";
5565
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5845
+		if ($limit) {
5846
+			$query .= " LIMIT 10 OFFSET 0";
5847
+		}
5566 5848
       
5567 5849
 		$sth = $this->db->prepare($query);
5568 5850
 		$sth->execute();
@@ -5614,7 +5896,9 @@  discard block
 block discarded – undo
5614 5896
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
5615 5897
                 $query .= " GROUP BY spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country
5616 5898
 				ORDER BY airport_departure_icao_count DESC";
5617
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5899
+		if ($limit) {
5900
+			$query .= " LIMIT 10 OFFSET 0";
5901
+		}
5618 5902
     		//echo $query;
5619 5903
 		$sth = $this->db->prepare($query);
5620 5904
 		$sth->execute();
@@ -5666,7 +5950,9 @@  discard block
 block discarded – undo
5666 5950
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
5667 5951
                 $query .= "GROUP BY spotter_output.airline_icao, spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country
5668 5952
 				ORDER BY airport_departure_icao_count DESC";
5669
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5953
+		if ($limit) {
5954
+			$query .= " LIMIT 10 OFFSET 0";
5955
+		}
5670 5956
       
5671 5957
 		$sth = $this->db->prepare($query);
5672 5958
 		$sth->execute();
@@ -6061,7 +6347,9 @@  discard block
 block discarded – undo
6061 6347
 			date_default_timezone_set($globalTimezone);
6062 6348
 			$datetime = new DateTime($date);
6063 6349
 			$offset = $datetime->format('P');
6064
-		} else $offset = '+00:00';
6350
+		} else {
6351
+			$offset = '+00:00';
6352
+		}
6065 6353
 
6066 6354
 		if ($globalDBdriver == 'mysql') {
6067 6355
 			$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
@@ -6111,7 +6399,9 @@  discard block
 block discarded – undo
6111 6399
 			date_default_timezone_set($globalTimezone);
6112 6400
 			$datetime = new DateTime($date);
6113 6401
 			$offset = $datetime->format('P');
6114
-		} else $offset = '+00:00';
6402
+		} else {
6403
+			$offset = '+00:00';
6404
+		}
6115 6405
 
6116 6406
 		if ($globalDBdriver == 'mysql') {
6117 6407
 			$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
@@ -6324,7 +6614,9 @@  discard block
 block discarded – undo
6324 6614
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6325 6615
                 $query .= " GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
6326 6616
 					ORDER BY airport_arrival_icao_count DESC";
6327
-		if ($limit) $query .= " LIMIT 10";
6617
+		if ($limit) {
6618
+			$query .= " LIMIT 10";
6619
+		}
6328 6620
       
6329 6621
 		
6330 6622
 		$sth = $this->db->prepare($query);
@@ -6344,7 +6636,9 @@  discard block
 block discarded – undo
6344 6636
 			if ($icaoaskey) {
6345 6637
 				$icao = $row['arrival_airport_icao'];
6346 6638
 				$airport_array[$icao] = $temp_array;
6347
-			} else $airport_array[] = $temp_array;
6639
+			} else {
6640
+				$airport_array[] = $temp_array;
6641
+			}
6348 6642
 		}
6349 6643
 
6350 6644
 		return $airport_array;
@@ -6386,7 +6680,9 @@  discard block
 block discarded – undo
6386 6680
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6387 6681
                 $query .= "GROUP BY spotter_output.airline_icao,spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
6388 6682
 					ORDER BY airport_arrival_icao_count DESC";
6389
-		if ($limit) $query .= " LIMIT 10";
6683
+		if ($limit) {
6684
+			$query .= " LIMIT 10";
6685
+		}
6390 6686
       
6391 6687
 		
6392 6688
 		$sth = $this->db->prepare($query);
@@ -6407,7 +6703,9 @@  discard block
 block discarded – undo
6407 6703
 			if ($icaoaskey) {
6408 6704
 				$icao = $row['arrival_airport_icao'];
6409 6705
 				$airport_array[$icao] = $temp_array;
6410
-			} else $airport_array[] = $temp_array;
6706
+			} else {
6707
+				$airport_array[] = $temp_array;
6708
+			}
6411 6709
 		}
6412 6710
 
6413 6711
 		return $airport_array;
@@ -6449,7 +6747,9 @@  discard block
 block discarded – undo
6449 6747
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6450 6748
                 $query .= " GROUP BY spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country
6451 6749
 					ORDER BY airport_arrival_icao_count DESC";
6452
-		if ($limit) $query .= " LIMIT 10";
6750
+		if ($limit) {
6751
+			$query .= " LIMIT 10";
6752
+		}
6453 6753
       
6454 6754
 		
6455 6755
 		$sth = $this->db->prepare($query);
@@ -6469,7 +6769,9 @@  discard block
 block discarded – undo
6469 6769
 			if ($icaoaskey) {
6470 6770
 				$icao = $row['arrival_airport_icao'];
6471 6771
 				$airport_array[$icao] = $temp_array;
6472
-			} else $airport_array[] = $temp_array;
6772
+			} else {
6773
+				$airport_array[] = $temp_array;
6774
+			}
6473 6775
 		}
6474 6776
 
6475 6777
 		return $airport_array;
@@ -6511,7 +6813,9 @@  discard block
 block discarded – undo
6511 6813
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6512 6814
                 $query .= "GROUP BY spotter_output.airline_icao, spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country
6513 6815
 					ORDER BY airport_arrival_icao_count DESC";
6514
-		if ($limit) $query .= " LIMIT 10";
6816
+		if ($limit) {
6817
+			$query .= " LIMIT 10";
6818
+		}
6515 6819
       
6516 6820
 		
6517 6821
 		$sth = $this->db->prepare($query);
@@ -6532,7 +6836,9 @@  discard block
 block discarded – undo
6532 6836
 			if ($icaoaskey) {
6533 6837
 				$icao = $row['arrival_airport_icao'];
6534 6838
 				$airport_array[$icao] = $temp_array;
6535
-			} else $airport_array[] = $temp_array;
6839
+			} else {
6840
+				$airport_array[] = $temp_array;
6841
+			}
6536 6842
 		}
6537 6843
 
6538 6844
 		return $airport_array;
@@ -6913,7 +7219,9 @@  discard block
 block discarded – undo
6913 7219
 			date_default_timezone_set($globalTimezone);
6914 7220
 			$datetime = new DateTime($date);
6915 7221
 			$offset = $datetime->format('P');
6916
-		} else $offset = '+00:00';
7222
+		} else {
7223
+			$offset = '+00:00';
7224
+		}
6917 7225
 
6918 7226
 		if ($globalDBdriver == 'mysql') {
6919 7227
 			$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
@@ -6963,7 +7271,9 @@  discard block
 block discarded – undo
6963 7271
 			date_default_timezone_set($globalTimezone);
6964 7272
 			$datetime = new DateTime($date);
6965 7273
 			$offset = $datetime->format('P');
6966
-		} else $offset = '+00:00';
7274
+		} else {
7275
+			$offset = '+00:00';
7276
+		}
6967 7277
 
6968 7278
 		if ($globalDBdriver == 'mysql') {
6969 7279
 			$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
@@ -7186,7 +7496,9 @@  discard block
 block discarded – undo
7186 7496
 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.arrival_airport_icao <> 'NA'";
7187 7497
 		$query .= " GROUP BY spotter_output.arrival_airport_country
7188 7498
 					ORDER BY airport_arrival_country_count DESC";
7189
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
7499
+		if ($limit) {
7500
+			$query .= " LIMIT 10 OFFSET 0";
7501
+		}
7190 7502
       
7191 7503
 		
7192 7504
 		$sth = $this->db->prepare($query);
@@ -7473,7 +7785,9 @@  discard block
 block discarded – undo
7473 7785
 			date_default_timezone_set($globalTimezone);
7474 7786
 			$datetime = new DateTime($date);
7475 7787
 			$offset = $datetime->format('P');
7476
-		} else $offset = '+00:00';
7788
+		} else {
7789
+			$offset = '+00:00';
7790
+		}
7477 7791
 		
7478 7792
 		if ($globalDBdriver == 'mysql') {
7479 7793
 			$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
@@ -7649,15 +7963,23 @@  discard block
 block discarded – undo
7649 7963
 		$query  = "SELECT DISTINCT spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name, spotter_output.airline_icao  
7650 7964
                     FROM spotter_output".$filter_query." spotter_output.ident <> '' ";
7651 7965
 		 if ($olderthanmonths > 0) {
7652
-			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
7653
-			else $query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
7966
+			if ($globalDBdriver == 'mysql') {
7967
+				$query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
7968
+			} else {
7969
+				$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
7970
+			}
7654 7971
 		}
7655 7972
 		if ($sincedate != '') {
7656
-			if ($globalDBdriver == 'mysql') $query .= " AND spotter_output.date > '".$sincedate."'";
7657
-			else $query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
7973
+			if ($globalDBdriver == 'mysql') {
7974
+				$query .= " AND spotter_output.date > '".$sincedate."'";
7975
+			} else {
7976
+				$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
7977
+			}
7658 7978
 		}
7659 7979
 		$query .= " GROUP BY spotter_output.ident, spotter_output.airline_name, spotter_output.airline_icao ORDER BY callsign_icao_count DESC";
7660
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
7980
+		if ($limit) {
7981
+			$query .= " LIMIT 10 OFFSET 0";
7982
+		}
7661 7983
       		
7662 7984
 		$sth = $this->db->prepare($query);
7663 7985
 		$sth->execute();
@@ -7691,15 +8013,23 @@  discard block
 block discarded – undo
7691 8013
 		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name  
7692 8014
                     FROM spotter_output".$filter_query." spotter_output.ident <> ''  AND spotter_output.airline_icao <> '' ";
7693 8015
 		 if ($olderthanmonths > 0) {
7694
-			if ($globalDBdriver == 'mysql') $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
7695
-			else $query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
8016
+			if ($globalDBdriver == 'mysql') {
8017
+				$query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
8018
+			} else {
8019
+				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
8020
+			}
7696 8021
 		}
7697 8022
 		if ($sincedate != '') {
7698
-			if ($globalDBdriver == 'mysql') $query .= "AND spotter_output.date > '".$sincedate."' ";
7699
-			else $query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP) ";
8023
+			if ($globalDBdriver == 'mysql') {
8024
+				$query .= "AND spotter_output.date > '".$sincedate."' ";
8025
+			} else {
8026
+				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP) ";
8027
+			}
7700 8028
 		}
7701 8029
 		$query .= "GROUP BY spotter_output.airline_icao, spotter_output.ident, spotter_output.airline_name, spotter_output.airline_icao ORDER BY callsign_icao_count DESC";
7702
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
8030
+		if ($limit) {
8031
+			$query .= " LIMIT 10 OFFSET 0";
8032
+		}
7703 8033
       		
7704 8034
 		$sth = $this->db->prepare($query);
7705 8035
 		$sth->execute();
@@ -7736,7 +8066,9 @@  discard block
 block discarded – undo
7736 8066
 			date_default_timezone_set($globalTimezone);
7737 8067
 			$datetime = new DateTime();
7738 8068
 			$offset = $datetime->format('P');
7739
-		} else $offset = '+00:00';
8069
+		} else {
8070
+			$offset = '+00:00';
8071
+		}
7740 8072
 
7741 8073
 		if ($globalDBdriver == 'mysql') {
7742 8074
 			$query  = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -7785,7 +8117,9 @@  discard block
 block discarded – undo
7785 8117
 			date_default_timezone_set($globalTimezone);
7786 8118
 			$datetime = new DateTime();
7787 8119
 			$offset = $datetime->format('P');
7788
-		} else $offset = '+00:00';
8120
+		} else {
8121
+			$offset = '+00:00';
8122
+		}
7789 8123
 		$filter_query = $this->getFilter($filters,true,true);
7790 8124
 		if ($globalDBdriver == 'mysql') {
7791 8125
 			$query  = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -7834,7 +8168,9 @@  discard block
 block discarded – undo
7834 8168
 			date_default_timezone_set($globalTimezone);
7835 8169
 			$datetime = new DateTime();
7836 8170
 			$offset = $datetime->format('P');
7837
-		} else $offset = '+00:00';
8171
+		} else {
8172
+			$offset = '+00:00';
8173
+		}
7838 8174
 		$filter_query = $this->getFilter($filters,true,true);
7839 8175
 		if ($globalDBdriver == 'mysql') {
7840 8176
 			$query  = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -7880,7 +8216,9 @@  discard block
 block discarded – undo
7880 8216
 			date_default_timezone_set($globalTimezone);
7881 8217
 			$datetime = new DateTime();
7882 8218
 			$offset = $datetime->format('P');
7883
-		} else $offset = '+00:00';
8219
+		} else {
8220
+			$offset = '+00:00';
8221
+		}
7884 8222
 		$filter_query = $this->getFilter($filters,true,true);
7885 8223
 		if ($globalDBdriver == 'mysql') {
7886 8224
 			$query  = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -7928,7 +8266,9 @@  discard block
 block discarded – undo
7928 8266
 			date_default_timezone_set($globalTimezone);
7929 8267
 			$datetime = new DateTime();
7930 8268
 			$offset = $datetime->format('P');
7931
-		} else $offset = '+00:00';
8269
+		} else {
8270
+			$offset = '+00:00';
8271
+		}
7932 8272
 		
7933 8273
 		if ($globalDBdriver == 'mysql') {
7934 8274
 			$query  = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -7976,7 +8316,9 @@  discard block
 block discarded – undo
7976 8316
 			date_default_timezone_set($globalTimezone);
7977 8317
 			$datetime = new DateTime();
7978 8318
 			$offset = $datetime->format('P');
7979
-		} else $offset = '+00:00';
8319
+		} else {
8320
+			$offset = '+00:00';
8321
+		}
7980 8322
 
7981 8323
 		if ($globalDBdriver == 'mysql') {
7982 8324
 			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
@@ -8023,7 +8365,9 @@  discard block
 block discarded – undo
8023 8365
 			date_default_timezone_set($globalTimezone);
8024 8366
 			$datetime = new DateTime();
8025 8367
 			$offset = $datetime->format('P');
8026
-		} else $offset = '+00:00';
8368
+		} else {
8369
+			$offset = '+00:00';
8370
+		}
8027 8371
 
8028 8372
 		if ($globalDBdriver == 'mysql') {
8029 8373
 			$query  = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
@@ -8071,7 +8415,9 @@  discard block
 block discarded – undo
8071 8415
 			date_default_timezone_set($globalTimezone);
8072 8416
 			$datetime = new DateTime();
8073 8417
 			$offset = $datetime->format('P');
8074
-		} else $offset = '+00:00';
8418
+		} else {
8419
+			$offset = '+00:00';
8420
+		}
8075 8421
 		$filter_query = $this->getFilter($filters,true,true);
8076 8422
 		if ($globalDBdriver == 'mysql') {
8077 8423
 			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
@@ -8116,7 +8462,9 @@  discard block
 block discarded – undo
8116 8462
 			date_default_timezone_set($globalTimezone);
8117 8463
 			$datetime = new DateTime();
8118 8464
 			$offset = $datetime->format('P');
8119
-		} else $offset = '+00:00';
8465
+		} else {
8466
+			$offset = '+00:00';
8467
+		}
8120 8468
 		$filter_query = $this->getFilter($filters,true,true);
8121 8469
 
8122 8470
 		if ($globalDBdriver == 'mysql') {
@@ -8163,7 +8511,9 @@  discard block
 block discarded – undo
8163 8511
 			date_default_timezone_set($globalTimezone);
8164 8512
 			$datetime = new DateTime();
8165 8513
 			$offset = $datetime->format('P');
8166
-		} else $offset = '+00:00';
8514
+		} else {
8515
+			$offset = '+00:00';
8516
+		}
8167 8517
 
8168 8518
 		if ($globalDBdriver == 'mysql') {
8169 8519
 			$query  = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct owner_name) as date_count
@@ -8209,7 +8559,9 @@  discard block
 block discarded – undo
8209 8559
 			date_default_timezone_set($globalTimezone);
8210 8560
 			$datetime = new DateTime();
8211 8561
 			$offset = $datetime->format('P');
8212
-		} else $offset = '+00:00';
8562
+		} else {
8563
+			$offset = '+00:00';
8564
+		}
8213 8565
 		$filter_query = $this->getFilter($filters,true,true);
8214 8566
 
8215 8567
 		if ($globalDBdriver == 'mysql') {
@@ -8256,7 +8608,9 @@  discard block
 block discarded – undo
8256 8608
 			date_default_timezone_set($globalTimezone);
8257 8609
 			$datetime = new DateTime();
8258 8610
 			$offset = $datetime->format('P');
8259
-		} else $offset = '+00:00';
8611
+		} else {
8612
+			$offset = '+00:00';
8613
+		}
8260 8614
 
8261 8615
 		if ($globalDBdriver == 'mysql') {
8262 8616
 			$query  = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct pilot_id) as date_count
@@ -8303,7 +8657,9 @@  discard block
 block discarded – undo
8303 8657
 			date_default_timezone_set($globalTimezone);
8304 8658
 			$datetime = new DateTime();
8305 8659
 			$offset = $datetime->format('P');
8306
-		} else $offset = '+00:00';
8660
+		} else {
8661
+			$offset = '+00:00';
8662
+		}
8307 8663
 
8308 8664
 		if ($globalDBdriver == 'mysql') {
8309 8665
 			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct airline_icao) as date_count
@@ -8348,7 +8704,9 @@  discard block
 block discarded – undo
8348 8704
 			date_default_timezone_set($globalTimezone);
8349 8705
 			$datetime = new DateTime();
8350 8706
 			$offset = $datetime->format('P');
8351
-		} else $offset = '+00:00';
8707
+		} else {
8708
+			$offset = '+00:00';
8709
+		}
8352 8710
 		$filter_query = $this->getFilter($filters,true,true);
8353 8711
 
8354 8712
 		if ($globalDBdriver == 'mysql') {
@@ -8396,7 +8754,9 @@  discard block
 block discarded – undo
8396 8754
 			date_default_timezone_set($globalTimezone);
8397 8755
 			$datetime = new DateTime();
8398 8756
 			$offset = $datetime->format('P');
8399
-		} else $offset = '+00:00';
8757
+		} else {
8758
+			$offset = '+00:00';
8759
+		}
8400 8760
 
8401 8761
 		if ($globalDBdriver == 'mysql') {
8402 8762
 			$query  = "SELECT spotter_output.airline_icao,YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct aircraft_icao) as date_count
@@ -8442,7 +8802,9 @@  discard block
 block discarded – undo
8442 8802
 			date_default_timezone_set($globalTimezone);
8443 8803
 			$datetime = new DateTime();
8444 8804
 			$offset = $datetime->format('P');
8445
-		} else $offset = '+00:00';
8805
+		} else {
8806
+			$offset = '+00:00';
8807
+		}
8446 8808
 		$filter_query = $this->getFilter($filters,true,true);
8447 8809
 
8448 8810
 		if ($globalDBdriver == 'mysql') {
@@ -8490,7 +8852,9 @@  discard block
 block discarded – undo
8490 8852
 			date_default_timezone_set($globalTimezone);
8491 8853
 			$datetime = new DateTime();
8492 8854
 			$offset = $datetime->format('P');
8493
-		} else $offset = '+00:00';
8855
+		} else {
8856
+			$offset = '+00:00';
8857
+		}
8494 8858
 
8495 8859
 		if ($globalDBdriver == 'mysql') {
8496 8860
 			$query  = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(real_arrival_airport_icao) as date_count
@@ -8537,7 +8901,9 @@  discard block
 block discarded – undo
8537 8901
 			date_default_timezone_set($globalTimezone);
8538 8902
 			$datetime = new DateTime();
8539 8903
 			$offset = $datetime->format('P');
8540
-		} else $offset = '+00:00';
8904
+		} else {
8905
+			$offset = '+00:00';
8906
+		}
8541 8907
 		$filter_query = $this->getFilter($filters,true,true);
8542 8908
 		if ($globalDBdriver == 'mysql') {
8543 8909
 			$query  = "SELECT MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count
@@ -8586,7 +8952,9 @@  discard block
 block discarded – undo
8586 8952
 			date_default_timezone_set($globalTimezone);
8587 8953
 			$datetime = new DateTime();
8588 8954
 			$offset = $datetime->format('P');
8589
-		} else $offset = '+00:00';
8955
+		} else {
8956
+			$offset = '+00:00';
8957
+		}
8590 8958
 
8591 8959
 		$orderby_sql = '';
8592 8960
 		if ($orderby == "hour")
@@ -8652,7 +9020,9 @@  discard block
 block discarded – undo
8652 9020
 			date_default_timezone_set($globalTimezone);
8653 9021
 			$datetime = new DateTime();
8654 9022
 			$offset = $datetime->format('P');
8655
-		} else $offset = '+00:00';
9023
+		} else {
9024
+			$offset = '+00:00';
9025
+		}
8656 9026
 
8657 9027
 		$orderby_sql = '';
8658 9028
 		if ($orderby == "hour")
@@ -8719,7 +9089,9 @@  discard block
 block discarded – undo
8719 9089
 			date_default_timezone_set($globalTimezone);
8720 9090
 			$datetime = new DateTime();
8721 9091
 			$offset = $datetime->format('P');
8722
-		} else $offset = '+00:00';
9092
+		} else {
9093
+			$offset = '+00:00';
9094
+		}
8723 9095
 
8724 9096
 		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
8725 9097
 
@@ -8770,7 +9142,9 @@  discard block
 block discarded – undo
8770 9142
 			date_default_timezone_set($globalTimezone);
8771 9143
 			$datetime = new DateTime();
8772 9144
 			$offset = $datetime->format('P');
8773
-		} else $offset = '+00:00';
9145
+		} else {
9146
+			$offset = '+00:00';
9147
+		}
8774 9148
 
8775 9149
 		if ($globalDBdriver == 'mysql') {
8776 9150
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -8817,7 +9191,9 @@  discard block
 block discarded – undo
8817 9191
 			date_default_timezone_set($globalTimezone);
8818 9192
 			$datetime = new DateTime();
8819 9193
 			$offset = $datetime->format('P');
8820
-		} else $offset = '+00:00';
9194
+		} else {
9195
+			$offset = '+00:00';
9196
+		}
8821 9197
 
8822 9198
 		if ($globalDBdriver == 'mysql') {
8823 9199
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -8864,7 +9240,9 @@  discard block
 block discarded – undo
8864 9240
 			date_default_timezone_set($globalTimezone);
8865 9241
 			$datetime = new DateTime();
8866 9242
 			$offset = $datetime->format('P');
8867
-		} else $offset = '+00:00';
9243
+		} else {
9244
+			$offset = '+00:00';
9245
+		}
8868 9246
 
8869 9247
 		if ($globalDBdriver == 'mysql') {
8870 9248
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -8912,7 +9290,9 @@  discard block
 block discarded – undo
8912 9290
 			date_default_timezone_set($globalTimezone);
8913 9291
 			$datetime = new DateTime();
8914 9292
 			$offset = $datetime->format('P');
8915
-		} else $offset = '+00:00';
9293
+		} else {
9294
+			$offset = '+00:00';
9295
+		}
8916 9296
 
8917 9297
 		if ($globalDBdriver == 'mysql') {
8918 9298
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -8960,7 +9340,9 @@  discard block
 block discarded – undo
8960 9340
 			date_default_timezone_set($globalTimezone);
8961 9341
 			$datetime = new DateTime($date);
8962 9342
 			$offset = $datetime->format('P');
8963
-		} else $offset = '+00:00';
9343
+		} else {
9344
+			$offset = '+00:00';
9345
+		}
8964 9346
 
8965 9347
 		if ($globalDBdriver == 'mysql') {
8966 9348
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -9008,7 +9390,9 @@  discard block
 block discarded – undo
9008 9390
 			date_default_timezone_set($globalTimezone);
9009 9391
 			$datetime = new DateTime();
9010 9392
 			$offset = $datetime->format('P');
9011
-		} else $offset = '+00:00';
9393
+		} else {
9394
+			$offset = '+00:00';
9395
+		}
9012 9396
 
9013 9397
 		if ($globalDBdriver == 'mysql') {
9014 9398
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -9058,7 +9442,9 @@  discard block
 block discarded – undo
9058 9442
 			date_default_timezone_set($globalTimezone);
9059 9443
 			$datetime = new DateTime();
9060 9444
 			$offset = $datetime->format('P');
9061
-		} else $offset = '+00:00';
9445
+		} else {
9446
+			$offset = '+00:00';
9447
+		}
9062 9448
 
9063 9449
 		if ($globalDBdriver == 'mysql') {
9064 9450
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -9105,7 +9491,9 @@  discard block
 block discarded – undo
9105 9491
 			date_default_timezone_set($globalTimezone);
9106 9492
 			$datetime = new DateTime();
9107 9493
 			$offset = $datetime->format('P');
9108
-		} else $offset = '+00:00';
9494
+		} else {
9495
+			$offset = '+00:00';
9496
+		}
9109 9497
 
9110 9498
 		if ($globalDBdriver == 'mysql') {
9111 9499
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -9273,7 +9661,9 @@  discard block
 block discarded – undo
9273 9661
 			date_default_timezone_set($globalTimezone);
9274 9662
 			$datetime = new DateTime();
9275 9663
 			$offset = $datetime->format('P');
9276
-		} else $offset = '+00:00';
9664
+		} else {
9665
+			$offset = '+00:00';
9666
+		}
9277 9667
 
9278 9668
 		if ($globalDBdriver == 'mysql') {
9279 9669
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -9459,7 +9849,9 @@  discard block
 block discarded – undo
9459 9849
 	*/
9460 9850
 	public function parseDirection($direction = 0)
9461 9851
 	{
9462
-		if ($direction == '') $direction = 0;
9852
+		if ($direction == '') {
9853
+			$direction = 0;
9854
+		}
9463 9855
 		$direction_array = array();
9464 9856
 		$temp_array = array();
9465 9857
 
@@ -9560,7 +9952,9 @@  discard block
 block discarded – undo
9560 9952
 		if (isset($result->AirlineFlightInfoResult))
9561 9953
 		{
9562 9954
 			$registration = $result->AirlineFlightInfoResult->tailnumber;
9563
-		} else return '';
9955
+		} else {
9956
+			return '';
9957
+		}
9564 9958
 		
9565 9959
 		$registration = $this->convertAircraftRegistration($registration);
9566 9960
 		
@@ -9589,7 +9983,9 @@  discard block
 block discarded – undo
9589 9983
 		if (count($row) > 0) {
9590 9984
 		    //return $row['Registration'];
9591 9985
 		    return $row['registration'];
9592
-		} else return '';
9986
+		} else {
9987
+			return '';
9988
+		}
9593 9989
 	
9594 9990
 	}
9595 9991
 
@@ -9612,9 +10008,14 @@  discard block
 block discarded – undo
9612 10008
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
9613 10009
 		$sth->closeCursor();
9614 10010
 		if (count($row) > 0) {
9615
-		    if ($row['type_flight'] == null) return '';
9616
-		    else return $row['type_flight'];
9617
-		} else return '';
10011
+		    if ($row['type_flight'] == null) {
10012
+		    	return '';
10013
+		    } else {
10014
+		    	return $row['type_flight'];
10015
+		    }
10016
+		} else {
10017
+			return '';
10018
+		}
9618 10019
 	
9619 10020
 	}
9620 10021
 
@@ -9632,7 +10033,9 @@  discard block
 block discarded – undo
9632 10033
 		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
9633 10034
 	
9634 10035
 		$Connection = new Connection($this->db);
9635
-		if (!$Connection->tableExists('countries')) return '';
10036
+		if (!$Connection->tableExists('countries')) {
10037
+			return '';
10038
+		}
9636 10039
 	
9637 10040
 		try {
9638 10041
 			/*
@@ -9652,9 +10055,13 @@  discard block
 block discarded – undo
9652 10055
 			$sth->closeCursor();
9653 10056
 			if (count($row) > 0) {
9654 10057
 				return $row;
9655
-			} else return '';
10058
+			} else {
10059
+				return '';
10060
+			}
9656 10061
 		} catch (PDOException $e) {
9657
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
10062
+			if (isset($globalDebug) && $globalDebug) {
10063
+				echo 'Error : '.$e->getMessage()."\n";
10064
+			}
9658 10065
 			return '';
9659 10066
 		}
9660 10067
 	
@@ -9802,7 +10209,9 @@  discard block
 block discarded – undo
9802 10209
 	{
9803 10210
 		global $globalBitlyAccessToken;
9804 10211
 		
9805
-		if ($globalBitlyAccessToken == '') return $url;
10212
+		if ($globalBitlyAccessToken == '') {
10213
+			return $url;
10214
+		}
9806 10215
         
9807 10216
 		$google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url;
9808 10217
 		
@@ -9951,7 +10360,9 @@  discard block
 block discarded – undo
9951 10360
 		
9952 10361
 
9953 10362
 		// routes
9954
-		if ($globalDebug) print "Routes...\n";
10363
+		if ($globalDebug) {
10364
+			print "Routes...\n";
10365
+		}
9955 10366
 		if ($globalDBdriver == 'mysql') {
9956 10367
 			$query = "SELECT spotter_output.spotter_id, routes.FromAirport_ICAO, routes.ToAirport_ICAO FROM spotter_output, routes WHERE spotter_output.ident = routes.CallSign AND ( spotter_output.departure_airport_icao != routes.FromAirport_ICAO OR spotter_output.arrival_airport_icao != routes.ToAirport_ICAO) AND routes.FromAirport_ICAO != '' AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 DAY)";
9957 10368
 		} else {
@@ -9970,7 +10381,9 @@  discard block
 block discarded – undo
9970 10381
 			}
9971 10382
 		}
9972 10383
 		
9973
-		if ($globalDebug) print "Airlines...\n";
10384
+		if ($globalDebug) {
10385
+			print "Airlines...\n";
10386
+		}
9974 10387
 		//airlines
9975 10388
 		if ($globalDBdriver == 'mysql') {
9976 10389
 			$query  = "SELECT spotter_output.spotter_id, spotter_output.ident FROM spotter_output WHERE (spotter_output.airline_name = '' OR spotter_output.airline_name = 'Not Available') AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 DAY)";
@@ -9984,10 +10397,15 @@  discard block
 block discarded – undo
9984 10397
 			if (is_numeric(substr($row['ident'], -1, 1)))
9985 10398
 			{
9986 10399
 				$fromsource = NULL;
9987
-				if (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
9988
-				elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') $fromsource = 'ivao';
9989
-				elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
9990
-				elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
10400
+				if (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') {
10401
+					$fromsource = 'vatsim';
10402
+				} elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') {
10403
+					$fromsource = 'ivao';
10404
+				} elseif (isset($globalVATSIM) && $globalVATSIM) {
10405
+					$fromsource = 'vatsim';
10406
+				} elseif (isset($globalIVAO) && $globalIVAO) {
10407
+					$fromsource = 'ivao';
10408
+				}
9991 10409
 				$airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 3),$fromsource);
9992 10410
 				if (isset($airline_array[0]['name'])) {
9993 10411
 					$update_query  = "UPDATE spotter_output SET spotter_output.airline_name = :airline_name, spotter_output.airline_icao = :airline_icao, spotter_output.airline_country = :airline_country, spotter_output.airline_type = :airline_type WHERE spotter_output.spotter_id = :spotter_id";
@@ -9997,13 +10415,17 @@  discard block
 block discarded – undo
9997 10415
 			}
9998 10416
 		}
9999 10417
 
10000
-		if ($globalDebug) print "Remove Duplicate in aircraft_modes...\n";
10418
+		if ($globalDebug) {
10419
+			print "Remove Duplicate in aircraft_modes...\n";
10420
+		}
10001 10421
 		//duplicate modes
10002 10422
 		$query = "DELETE aircraft_modes FROM aircraft_modes LEFT OUTER JOIN (SELECT max(`AircraftID`) as `AircraftID`,`ModeS` FROM `aircraft_modes` group by ModeS) as KeepRows ON aircraft_modes.AircraftID = KeepRows.AircraftID WHERE KeepRows.AircraftID IS NULL";
10003 10423
 		$sth = $this->db->prepare($query);
10004 10424
 		$sth->execute();
10005 10425
 		
10006
-		if ($globalDebug) print "Aircraft...\n";
10426
+		if ($globalDebug) {
10427
+			print "Aircraft...\n";
10428
+		}
10007 10429
 		//aircraft
10008 10430
 		if ($globalDBdriver == 'mysql') {
10009 10431
 			$query  = "SELECT spotter_output.spotter_id, spotter_output.aircraft_icao, spotter_output.registration FROM spotter_output WHERE (spotter_output.aircraft_name = '' OR spotter_output.aircraft_name = 'Not Available') AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)";
@@ -10046,26 +10468,38 @@  discard block
 block discarded – undo
10046 10468
 				 if (isset($closestAirports[0])) {
10047 10469
 					if ($row['arrival_airport_icao'] == $closestAirports[0]['icao']) {
10048 10470
 						$airport_icao = $closestAirports[0]['icao'];
10049
-						if ($globalDebug) echo "\o/ 1st ---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
10471
+						if ($globalDebug) {
10472
+							echo "\o/ 1st ---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
10473
+						}
10050 10474
 					} elseif (count($closestAirports > 1) && $row['arrival_airport_icao'] != '' && $row['arrival_airport_icao'] != 'NA') {
10051 10475
 						foreach ($closestAirports as $airport) {
10052 10476
 							if ($row['arrival_airport_icao'] == $airport['icao']) {
10053 10477
 								$airport_icao = $airport['icao'];
10054
-								if ($globalDebug) echo "\o/ try --++ Find arrival airport. airport_icao : ".$airport_icao."\n";
10478
+								if ($globalDebug) {
10479
+									echo "\o/ try --++ Find arrival airport. airport_icao : ".$airport_icao."\n";
10480
+								}
10055 10481
 								break;
10056 10482
 							}
10057 10483
 						}
10058 10484
 					} elseif ($row['last_altitude'] == 0 || ($row['last_altitude'] != '' && ($closestAirports[0]['altitude'] <= $row['last_altitude']*100+1000 && $row['last_altitude']*100 < $closestAirports[0]['altitude']+5000))) {
10059 10485
 						$airport_icao = $closestAirports[0]['icao'];
10060
-						if ($globalDebug) echo "\o/ NP --++ Find arrival airport. Airport ICAO : ".$airport_icao." !  Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist." - Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.($row['last_altitude']*100)."\n";
10486
+						if ($globalDebug) {
10487
+							echo "\o/ NP --++ Find arrival airport. Airport ICAO : ".$airport_icao." !  Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist." - Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.($row['last_altitude']*100)."\n";
10488
+						}
10061 10489
 					} else {
10062
-						if ($globalDebug) echo "----- Can't find arrival airport. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist." - Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.($row['last_altitude']*100)."\n";
10490
+						if ($globalDebug) {
10491
+							echo "----- Can't find arrival airport. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist." - Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.($row['last_altitude']*100)."\n";
10492
+						}
10063 10493
 					}
10064 10494
 				} else {
10065
-					if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist."\n";
10495
+					if ($globalDebug) {
10496
+						echo "----- No Airport near last coord. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist."\n";
10497
+					}
10066 10498
 				}
10067 10499
 				if ($row['real_arrival_airport_icao'] != $airport_icao) {
10068
-					if ($globalDebug) echo "Updating airport to ".$airport_icao."...\n";
10500
+					if ($globalDebug) {
10501
+						echo "Updating airport to ".$airport_icao."...\n";
10502
+					}
10069 10503
 					$update_query="UPDATE spotter_output SET real_arrival_airport_icao = :airport_icao WHERE spotter_id = :spotter_id";
10070 10504
 					$sthu = $this->db->prepare($update_query);
10071 10505
 					$sthu->execute(array(':airport_icao' => $airport_icao,':spotter_id' => $row['spotter_id']));
Please login to merge, or discard this patch.
require/class.ATC.php 1 patch
Braces   +14 added lines, -5 removed lines patch added patch discarded remove patch
@@ -20,20 +20,27 @@  discard block
 block discarded – undo
20 20
 	if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
21 21
 	    if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
22 22
 		foreach($globalStatsFilters[$globalFilterName] as $source) {
23
-			if (isset($source['source'])) $filter['source'][] = $source['source'];
23
+			if (isset($source['source'])) {
24
+				$filter['source'][] = $source['source'];
25
+			}
24 26
 		}
25 27
 	    } else {
26 28
 		$filter = $globalStatsFilters[$globalFilterName];
27 29
 	    }
28 30
 	}
29
-	if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
31
+	if (is_array($globalFilter)) {
32
+		$filter = array_merge($filter,$globalFilter);
33
+	}
30 34
 	$filter_query_join = '';
31 35
 	$filter_query_where = '';
32 36
 	if (isset($filter['source']) && !empty($filter['source'])) {
33 37
 	    $filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')";
34 38
 	}
35
-	if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
36
-	elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
39
+	if ($filter_query_where == '' && $where) {
40
+		$filter_query_where = ' WHERE';
41
+	} elseif ($filter_query_where != '' && $and) {
42
+		$filter_query_where .= ' AND';
43
+	}
37 44
 	$filter_query = $filter_query_join.$filter_query_where;
38 45
 	return $filter_query;
39 46
     }
@@ -57,7 +64,9 @@  discard block
 block discarded – undo
57 64
     		$info = str_replace('^','<br />',$info);
58 65
     		$info = str_replace('&amp;sect;','',$info);
59 66
     		$info = str_replace('"','',$info);
60
-    		if ($type == '') $type = NULL;
67
+    		if ($type == '') {
68
+    			$type = NULL;
69
+    		}
61 70
                 $query = "INSERT INTO atc (ident,frequency,latitude,longitude,atc_range,info,atc_lastseen,type,ivao_id,ivao_name,format_source,source_name) VALUES (:ident,:frequency,:latitude,:longitude,:range,:info,:date,:type,:ivao_id,:ivao_name,:format_source,:source_name)";
62 71
                 $query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type,':format_source' => $format_source,':source_name' => $source_name);
63 72
                  try {
Please login to merge, or discard this patch.
require/class.Stats.php 1 patch
Braces   +383 added lines, -133 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
         }
@@ -41,7 +43,9 @@  discard block
 block discarded – undo
41 43
                 return $all;
42 44
         }
43 45
 	public function getAllAirlineNames($filter_name = '') {
44
-		if ($filter_name == '') $filter_name = $this->filter_name;
46
+		if ($filter_name == '') {
47
+			$filter_name = $this->filter_name;
48
+		}
45 49
                 $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC";
46 50
                  try {
47 51
                         $sth = $this->db->prepare($query);
@@ -53,7 +57,9 @@  discard block
 block discarded – undo
53 57
                 return $all;
54 58
         }
55 59
 	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
56
-		if ($filter_name == '') $filter_name = $this->filter_name;
60
+		if ($filter_name == '') {
61
+			$filter_name = $this->filter_name;
62
+		}
57 63
                 $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
58 64
                  try {
59 65
                         $sth = $this->db->prepare($query);
@@ -65,7 +71,9 @@  discard block
 block discarded – undo
65 71
                 return $all;
66 72
         }
67 73
 	public function getAllManufacturers($stats_airline = '',$filter_name = '') {
68
-		if ($filter_name == '') $filter_name = $this->filter_name;
74
+		if ($filter_name == '') {
75
+			$filter_name = $this->filter_name;
76
+		}
69 77
                 $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";
70 78
                  try {
71 79
                         $sth = $this->db->prepare($query);
@@ -77,7 +85,9 @@  discard block
 block discarded – undo
77 85
                 return $all;
78 86
         }
79 87
 	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
80
-		if ($filter_name == '') $filter_name = $this->filter_name;
88
+		if ($filter_name == '') {
89
+			$filter_name = $this->filter_name;
90
+		}
81 91
                 $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";
82 92
                  try {
83 93
                         $sth = $this->db->prepare($query);
@@ -92,9 +102,14 @@  discard block
 block discarded – undo
92 102
 
93 103
 	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '') {
94 104
 		global $globalStatsFilters;
95
-		if ($filter_name == '') $filter_name = $this->filter_name;
96
-		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";
97
-		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";
105
+		if ($filter_name == '') {
106
+			$filter_name = $this->filter_name;
107
+		}
108
+		if ($limit) {
109
+			$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";
110
+		} else {
111
+			$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";
112
+		}
98 113
                  try {
99 114
                         $sth = $this->db->prepare($query);
100 115
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -114,9 +129,14 @@  discard block
 block discarded – undo
114 129
 	}
115 130
 	public function countAllAirlineCountries($limit = true,$filter_name = '') {
116 131
 		global $globalStatsFilters;
117
-		if ($filter_name == '') $filter_name = $this->filter_name;
118
-		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";
119
-		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";
132
+		if ($filter_name == '') {
133
+			$filter_name = $this->filter_name;
134
+		}
135
+		if ($limit) {
136
+			$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";
137
+		} else {
138
+			$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";
139
+		}
120 140
                  try {
121 141
                         $sth = $this->db->prepare($query);
122 142
                         $sth->execute(array(':filter_name' => $filter_name));
@@ -136,9 +156,14 @@  discard block
 block discarded – undo
136 156
 	}
137 157
 	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '') {
138 158
 		global $globalStatsFilters;
139
-		if ($filter_name == '') $filter_name = $this->filter_name;
140
-		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";
141
-		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";
159
+		if ($filter_name == '') {
160
+			$filter_name = $this->filter_name;
161
+		}
162
+		if ($limit) {
163
+			$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";
164
+		} else {
165
+			$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";
166
+		}
142 167
                  try {
143 168
                         $sth = $this->db->prepare($query);
144 169
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -159,9 +184,14 @@  discard block
 block discarded – undo
159 184
 
160 185
 	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '') {
161 186
 		global $globalStatsFilters;
162
-		if ($filter_name == '') $filter_name = $this->filter_name;
163
-		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";
164
-		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";
187
+		if ($filter_name == '') {
188
+			$filter_name = $this->filter_name;
189
+		}
190
+		if ($limit) {
191
+			$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";
192
+		} else {
193
+			$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";
194
+		}
165 195
                  try {
166 196
                         $sth = $this->db->prepare($query);
167 197
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -181,9 +211,14 @@  discard block
 block discarded – undo
181 211
 	}
182 212
 	public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '') {
183 213
 		global $globalStatsFilters;
184
-		if ($filter_name == '') $filter_name = $this->filter_name;
185
-		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";
186
-		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";
214
+		if ($filter_name == '') {
215
+			$filter_name = $this->filter_name;
216
+		}
217
+		if ($limit) {
218
+			$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";
219
+		} else {
220
+			$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";
221
+		}
187 222
                  try {
188 223
                         $sth = $this->db->prepare($query);
189 224
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -204,9 +239,14 @@  discard block
 block discarded – undo
204 239
 
205 240
 	public function countAllAirlines($limit = true,$filter_name = '') {
206 241
 		global $globalStatsFilters;
207
-		if ($filter_name == '') $filter_name = $this->filter_name;
208
-		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";
209
-		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";
242
+		if ($filter_name == '') {
243
+			$filter_name = $this->filter_name;
244
+		}
245
+		if ($limit) {
246
+			$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";
247
+		} else {
248
+			$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";
249
+		}
210 250
                  try {
211 251
                         $sth = $this->db->prepare($query);
212 252
                         $sth->execute(array(':filter_name' => $filter_name));
@@ -227,9 +267,14 @@  discard block
 block discarded – undo
227 267
 	}
228 268
 	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '') {
229 269
 		global $globalStatsFilters;
230
-		if ($filter_name == '') $filter_name = $this->filter_name;
231
-		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";
232
-		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";
270
+		if ($filter_name == '') {
271
+			$filter_name = $this->filter_name;
272
+		}
273
+		if ($limit) {
274
+			$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";
275
+		} else {
276
+			$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";
277
+		}
233 278
                  try {
234 279
                         $sth = $this->db->prepare($query);
235 280
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -249,9 +294,14 @@  discard block
 block discarded – undo
249 294
 	}
250 295
 	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '') {
251 296
 		global $globalStatsFilters;
252
-		if ($filter_name == '') $filter_name = $this->filter_name;
253
-		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";
254
-		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";
297
+		if ($filter_name == '') {
298
+			$filter_name = $this->filter_name;
299
+		}
300
+		if ($limit) {
301
+			$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";
302
+		} else {
303
+			$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";
304
+		}
255 305
 		 try {
256 306
 			$sth = $this->db->prepare($query);
257 307
 			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -271,10 +321,15 @@  discard block
 block discarded – undo
271 321
 	}
272 322
 	public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '') {
273 323
 		$Connection = new Connection();
274
-		if ($filter_name == '') $filter_name = $this->filter_name;
324
+		if ($filter_name == '') {
325
+			$filter_name = $this->filter_name;
326
+		}
275 327
 		if ($Connection->tableExists('countries')) {
276
-			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";
277
-			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";
328
+			if ($limit) {
329
+				$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";
330
+			} else {
331
+				$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";
332
+			}
278 333
 			 try {
279 334
 				$sth = $this->db->prepare($query);
280 335
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -295,9 +350,14 @@  discard block
 block discarded – undo
295 350
 	}
296 351
 	public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '') {
297 352
 		global $globalStatsFilters;
298
-		if ($filter_name == '') $filter_name = $this->filter_name;
299
-		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";
300
-		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";
353
+		if ($filter_name == '') {
354
+			$filter_name = $this->filter_name;
355
+		}
356
+		if ($limit) {
357
+			$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";
358
+		} else {
359
+			$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";
360
+		}
301 361
                  try {
302 362
                         $sth = $this->db->prepare($query);
303 363
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -317,9 +377,14 @@  discard block
 block discarded – undo
317 377
 	}
318 378
 	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '') {
319 379
 		global $globalStatsFilters;
320
-		if ($filter_name == '') $filter_name = $this->filter_name;
321
-		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";
322
-		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";
380
+		if ($filter_name == '') {
381
+			$filter_name = $this->filter_name;
382
+		}
383
+		if ($limit) {
384
+			$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";
385
+		} else {
386
+			$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";
387
+		}
323 388
                  try {
324 389
                         $sth = $this->db->prepare($query);
325 390
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -339,9 +404,14 @@  discard block
 block discarded – undo
339 404
 	}
340 405
 	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '') {
341 406
 		global $globalStatsFilters;
342
-		if ($filter_name == '') $filter_name = $this->filter_name;
343
-		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";
344
-		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";
407
+		if ($filter_name == '') {
408
+			$filter_name = $this->filter_name;
409
+		}
410
+		if ($limit) {
411
+			$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";
412
+		} else {
413
+			$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";
414
+		}
345 415
                  try {
346 416
                         $sth = $this->db->prepare($query);
347 417
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -367,7 +437,9 @@  discard block
 block discarded – undo
367 437
         			$icao = $value['airport_departure_icao'];
368 438
         			if (isset($all[$icao])) {
369 439
         				$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
370
-        			} else $all[$icao] = $value;
440
+        			} else {
441
+        				$all[$icao] = $value;
442
+        			}
371 443
         		}
372 444
         		$count = array();
373 445
         		foreach ($all as $key => $row) {
@@ -379,9 +451,14 @@  discard block
 block discarded – undo
379 451
 	}
380 452
 	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '') {
381 453
 		global $globalStatsFilters;
382
-		if ($filter_name == '') $filter_name = $this->filter_name;
383
-		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";
384
-		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";
454
+		if ($filter_name == '') {
455
+			$filter_name = $this->filter_name;
456
+		}
457
+		if ($limit) {
458
+			$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";
459
+		} else {
460
+			$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";
461
+		}
385 462
 		try {
386 463
 			$sth = $this->db->prepare($query);
387 464
 			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -407,7 +484,9 @@  discard block
 block discarded – undo
407 484
         			$icao = $value['airport_arrival_icao'];
408 485
         			if (isset($all[$icao])) {
409 486
         				$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
410
-        			} else $all[$icao] = $value;
487
+        			} else {
488
+        				$all[$icao] = $value;
489
+        			}
411 490
         		}
412 491
         		$count = array();
413 492
         		foreach ($all as $key => $row) {
@@ -420,13 +499,21 @@  discard block
 block discarded – undo
420 499
 	}
421 500
 	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
422 501
 		global $globalDBdriver, $globalStatsFilters;
423
-		if ($filter_name == '') $filter_name = $this->filter_name;
502
+		if ($filter_name == '') {
503
+			$filter_name = $this->filter_name;
504
+		}
424 505
 		if ($globalDBdriver == 'mysql') {
425
-			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";
426
-			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";
506
+			if ($limit) {
507
+				$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";
508
+			} else {
509
+				$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";
510
+			}
427 511
 		} else {
428
-			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";
429
-			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";
512
+			if ($limit) {
513
+				$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";
514
+			} else {
515
+				$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";
516
+			}
430 517
 		}
431 518
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
432 519
                  try {
@@ -450,7 +537,9 @@  discard block
 block discarded – undo
450 537
 	
451 538
 	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
452 539
 		global $globalStatsFilters;
453
-		if ($filter_name == '') $filter_name = $this->filter_name;
540
+		if ($filter_name == '') {
541
+			$filter_name = $this->filter_name;
542
+		}
454 543
 		$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";
455 544
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
456 545
                  try {
@@ -472,7 +561,9 @@  discard block
 block discarded – undo
472 561
 	}
473 562
 	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
474 563
 		global $globalDBdriver, $globalStatsFilters;
475
-		if ($filter_name == '') $filter_name = $this->filter_name;
564
+		if ($filter_name == '') {
565
+			$filter_name = $this->filter_name;
566
+		}
476 567
 		if ($globalDBdriver == 'mysql') {
477 568
 			$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";
478 569
 		} else {
@@ -498,7 +589,9 @@  discard block
 block discarded – undo
498 589
 	}
499 590
 	public function countAllDates($stats_airline = '',$filter_name = '') {
500 591
 		global $globalStatsFilters;
501
-		if ($filter_name == '') $filter_name = $this->filter_name;
592
+		if ($filter_name == '') {
593
+			$filter_name = $this->filter_name;
594
+		}
502 595
 		$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";
503 596
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
504 597
                  try {
@@ -520,7 +613,9 @@  discard block
 block discarded – undo
520 613
 	}
521 614
 	public function countAllDatesByAirlines($filter_name = '') {
522 615
 		global $globalStatsFilters;
523
-		if ($filter_name == '') $filter_name = $this->filter_name;
616
+		if ($filter_name == '') {
617
+			$filter_name = $this->filter_name;
618
+		}
524 619
 		$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";
525 620
 		$query_data = array('filter_name' => $filter_name);
526 621
                  try {
@@ -542,7 +637,9 @@  discard block
 block discarded – undo
542 637
 	}
543 638
 	public function countAllMonths($stats_airline = '',$filter_name = '') {
544 639
 		global $globalStatsFilters;
545
-		if ($filter_name == '') $filter_name = $this->filter_name;
640
+		if ($filter_name == '') {
641
+			$filter_name = $this->filter_name;
642
+		}
546 643
 	    	$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";
547 644
                  try {
548 645
                         $sth = $this->db->prepare($query);
@@ -563,7 +660,9 @@  discard block
 block discarded – undo
563 660
 	}
564 661
 	public function countAllMilitaryMonths($filter_name = '') {
565 662
 		global $globalStatsFilters;
566
-		if ($filter_name == '') $filter_name = $this->filter_name;
663
+		if ($filter_name == '') {
664
+			$filter_name = $this->filter_name;
665
+		}
567 666
 	    	$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";
568 667
                  try {
569 668
                         $sth = $this->db->prepare($query);
@@ -584,9 +683,14 @@  discard block
 block discarded – undo
584 683
 	}
585 684
 	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
586 685
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
587
-		if ($filter_name == '') $filter_name = $this->filter_name;
588
-		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";
589
-		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";
686
+		if ($filter_name == '') {
687
+			$filter_name = $this->filter_name;
688
+		}
689
+		if ($limit) {
690
+			$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";
691
+		} else {
692
+			$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";
693
+		}
590 694
 		if ($orderby == 'hour') {
591 695
 			/*
592 696
 			if ($globalDBdriver == 'mysql') {
@@ -595,7 +699,9 @@  discard block
 block discarded – undo
595 699
 			*/
596 700
 			$query .= " ORDER BY CAST(flight_date AS integer) ASC";
597 701
 		}
598
-		if ($orderby == 'count') $query .= " ORDER BY hour_count DESC";
702
+		if ($orderby == 'count') {
703
+			$query .= " ORDER BY hour_count DESC";
704
+		}
599 705
                  try {
600 706
                         $sth = $this->db->prepare($query);
601 707
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
@@ -616,7 +722,9 @@  discard block
 block discarded – undo
616 722
 	
617 723
 	public function countOverallFlights($stats_airline = '', $filter_name = '') {
618 724
 		global $globalStatsFilters;
619
-		if ($filter_name == '') $filter_name = $this->filter_name;
725
+		if ($filter_name == '') {
726
+			$filter_name = $this->filter_name;
727
+		}
620 728
 		$all = $this->getSumStats('flights_bymonth',date('Y'),$stats_airline,$filter_name);
621 729
 		if (empty($all)) {
622 730
 			$filters = array('airlines' => array($stats_airline));
@@ -630,7 +738,9 @@  discard block
 block discarded – undo
630 738
 	}
631 739
 	public function countOverallMilitaryFlights($filter_name = '') {
632 740
 		global $globalStatsFilters;
633
-		if ($filter_name == '') $filter_name = $this->filter_name;
741
+		if ($filter_name == '') {
742
+			$filter_name = $this->filter_name;
743
+		}
634 744
 		$all = $this->getSumStats('military_flights_bymonth',date('Y'),'',$filter_name);
635 745
 		if (empty($all)) {
636 746
 		        $filters = array();
@@ -644,7 +754,9 @@  discard block
 block discarded – undo
644 754
 	}
645 755
 	public function countOverallArrival($stats_airline = '',$filter_name = '') {
646 756
 		global $globalStatsFilters;
647
-		if ($filter_name == '') $filter_name = $this->filter_name;
757
+		if ($filter_name == '') {
758
+			$filter_name = $this->filter_name;
759
+		}
648 760
 		$all = $this->getSumStats('realarrivals_bymonth',date('Y'),$stats_airline,$filter_name);
649 761
 		if (empty($all)) {
650 762
 			$filters = array('airlines' => array($stats_airline));
@@ -658,7 +770,9 @@  discard block
 block discarded – undo
658 770
 	}
659 771
 	public function countOverallAircrafts($stats_airline = '',$filter_name = '') {
660 772
 		global $globalStatsFilters;
661
-		if ($filter_name == '') $filter_name = $this->filter_name;
773
+		if ($filter_name == '') {
774
+			$filter_name = $this->filter_name;
775
+		}
662 776
 		$all = $this->getSumStats('aircrafts_bymonth',date('Y'),$stats_airline,$filter_name);
663 777
 		if (empty($all)) {
664 778
 			$filters = array('airlines' => array($stats_airline));
@@ -672,7 +786,9 @@  discard block
 block discarded – undo
672 786
 	}
673 787
 	public function countOverallAirlines($filter_name = '') {
674 788
 		global $globalStatsFilters;
675
-		if ($filter_name == '') $filter_name = $this->filter_name;
789
+		if ($filter_name == '') {
790
+			$filter_name = $this->filter_name;
791
+		}
676 792
 		$query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name";
677 793
                  try {
678 794
                         $sth = $this->db->prepare($query);
@@ -695,7 +811,9 @@  discard block
 block discarded – undo
695 811
 	}
696 812
 	public function countOverallOwners($stats_airline = '',$filter_name = '') {
697 813
 		global $globalStatsFilters;
698
-		if ($filter_name == '') $filter_name = $this->filter_name;
814
+		if ($filter_name == '') {
815
+			$filter_name = $this->filter_name;
816
+		}
699 817
 		/*
700 818
 		$query = "SELECT COUNT(*) AS nb_owner FROM stats_owner";
701 819
                  try {
@@ -720,7 +838,9 @@  discard block
 block discarded – undo
720 838
 	}
721 839
 	public function countOverallPilots($stats_airline = '',$filter_name = '') {
722 840
 		global $globalStatsFilters;
723
-		if ($filter_name == '') $filter_name = $this->filter_name;
841
+		if ($filter_name == '') {
842
+			$filter_name = $this->filter_name;
843
+		}
724 844
 		$all = $this->getSumStats('pilots_bymonth',date('Y'),$stats_airline,$filter_name);
725 845
 		if (empty($all)) {
726 846
 			$filters = array('airlines' => array($stats_airline));
@@ -734,7 +854,9 @@  discard block
 block discarded – undo
734 854
 	}
735 855
 
736 856
 	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') {
737
-		if ($filter_name == '') $filter_name = $this->filter_name;
857
+		if ($filter_name == '') {
858
+			$filter_name = $this->filter_name;
859
+		}
738 860
 		$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";
739 861
 		$query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
740 862
                  try {
@@ -747,7 +869,9 @@  discard block
 block discarded – undo
747 869
                 return $all;
748 870
 	}
749 871
 	public function getStats($type,$stats_airline = '', $filter_name = '') {
750
-		if ($filter_name == '') $filter_name = $this->filter_name;
872
+		if ($filter_name == '') {
873
+			$filter_name = $this->filter_name;
874
+		}
751 875
                 $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
752 876
                 $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
753 877
                  try {
@@ -760,7 +884,9 @@  discard block
 block discarded – undo
760 884
                 return $all;
761 885
         }
762 886
 	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '') {
763
-		if ($filter_name == '') $filter_name = $this->filter_name;
887
+		if ($filter_name == '') {
888
+			$filter_name = $this->filter_name;
889
+		}
764 890
     		global $globalArchiveMonths, $globalDBdriver;
765 891
     		if ($globalDBdriver == 'mysql') {
766 892
 	                $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";
@@ -779,7 +905,9 @@  discard block
 block discarded – undo
779 905
         }
780 906
 	public function getStatsTotal($type, $stats_airline = '', $filter_name = '') {
781 907
     		global $globalArchiveMonths, $globalDBdriver;
782
-		if ($filter_name == '') $filter_name = $this->filter_name;
908
+		if ($filter_name == '') {
909
+			$filter_name = $this->filter_name;
910
+		}
783 911
     		if ($globalDBdriver == 'mysql') {
784 912
 			$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";
785 913
 		} else {
@@ -797,7 +925,9 @@  discard block
 block discarded – undo
797 925
         }
798 926
 	public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') {
799 927
     		global $globalArchiveMonths, $globalDBdriver;
800
-		if ($filter_name == '') $filter_name = $this->filter_name;
928
+		if ($filter_name == '') {
929
+			$filter_name = $this->filter_name;
930
+		}
801 931
     		if ($globalDBdriver == 'mysql') {
802 932
 			$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
803 933
                 } else {
@@ -814,7 +944,9 @@  discard block
 block discarded – undo
814 944
         }
815 945
 	public function getStatsAirlineTotal($filter_name = '') {
816 946
     		global $globalArchiveMonths, $globalDBdriver;
817
-		if ($filter_name == '') $filter_name = $this->filter_name;
947
+		if ($filter_name == '') {
948
+			$filter_name = $this->filter_name;
949
+		}
818 950
     		if ($globalDBdriver == 'mysql') {
819 951
 			$query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name";
820 952
                 } else {
@@ -831,7 +963,9 @@  discard block
 block discarded – undo
831 963
         }
832 964
 	public function getStatsOwnerTotal($filter_name = '') {
833 965
     		global $globalArchiveMonths, $globalDBdriver;
834
-		if ($filter_name == '') $filter_name = $this->filter_name;
966
+		if ($filter_name == '') {
967
+			$filter_name = $this->filter_name;
968
+		}
835 969
     		if ($globalDBdriver == 'mysql') {
836 970
 			$query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name";
837 971
 		} else {
@@ -848,7 +982,9 @@  discard block
 block discarded – undo
848 982
         }
849 983
 	public function getStatsPilotTotal($filter_name = '') {
850 984
     		global $globalArchiveMonths, $globalDBdriver;
851
-		if ($filter_name == '') $filter_name = $this->filter_name;
985
+		if ($filter_name == '') {
986
+			$filter_name = $this->filter_name;
987
+		}
852 988
     		if ($globalDBdriver == 'mysql') {
853 989
             		$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
854 990
             	} else {
@@ -866,7 +1002,9 @@  discard block
 block discarded – undo
866 1002
 
867 1003
 	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
868 1004
 		global $globalDBdriver;
869
-		if ($filter_name == '') $filter_name = $this->filter_name;
1005
+		if ($filter_name == '') {
1006
+			$filter_name = $this->filter_name;
1007
+		}
870 1008
 		if ($globalDBdriver == 'mysql') {
871 1009
 			$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";
872 1010
                 } else {
@@ -882,7 +1020,9 @@  discard block
 block discarded – undo
882 1020
         }
883 1021
 	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
884 1022
 		global $globalDBdriver;
885
-		if ($filter_name == '') $filter_name = $this->filter_name;
1023
+		if ($filter_name == '') {
1024
+			$filter_name = $this->filter_name;
1025
+		}
886 1026
 		if ($globalDBdriver == 'mysql') {
887 1027
 			$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";
888 1028
 		} else {
@@ -1365,47 +1505,69 @@  discard block
 block discarded – undo
1365 1505
 			$this->addLastStatsUpdate('last_update_stats',date('Y-m-d G:i:s'));
1366 1506
 		} else {
1367 1507
 		*/
1368
-			if ($globalDebug) echo 'Update stats !'."\n";
1369
-			if ($globalDebug) echo 'Count all aircraft types...'."\n";
1508
+			if ($globalDebug) {
1509
+				echo 'Update stats !'."\n";
1510
+			}
1511
+			if ($globalDebug) {
1512
+				echo 'Count all aircraft types...'."\n";
1513
+			}
1370 1514
 			if (isset($last_update[0]['value'])) {
1371 1515
 				$last_update_day = $last_update[0]['value'];
1372
-			} else $last_update_day = '2012-12-12 12:12:12';
1516
+			} else {
1517
+				$last_update_day = '2012-12-12 12:12:12';
1518
+			}
1373 1519
 			$Spotter = new Spotter($this->db);
1374 1520
 			$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);
1375 1521
 			foreach ($alldata as $number) {
1376 1522
 				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer']);
1377 1523
 			}
1378
-			if ($globalDebug) echo 'Count all airlines...'."\n";
1524
+			if ($globalDebug) {
1525
+				echo 'Count all airlines...'."\n";
1526
+			}
1379 1527
 			$alldata = $Spotter->countAllAirlines(false,0,$last_update_day);
1380 1528
 			foreach ($alldata as $number) {
1381 1529
 				$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name']);
1382 1530
 			}
1383
-			if ($globalDebug) echo 'Count all registrations...'."\n";
1531
+			if ($globalDebug) {
1532
+				echo 'Count all registrations...'."\n";
1533
+			}
1384 1534
 			$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day);
1385 1535
 			foreach ($alldata as $number) {
1386 1536
 				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao']);
1387 1537
 			}
1388
-			if ($globalDebug) echo 'Count all callsigns...'."\n";
1538
+			if ($globalDebug) {
1539
+				echo 'Count all callsigns...'."\n";
1540
+			}
1389 1541
 			$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day);
1390 1542
 			foreach ($alldata as $number) {
1391 1543
 				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao']);
1392 1544
 			}
1393
-			if ($globalDebug) echo 'Count all owners...'."\n";
1545
+			if ($globalDebug) {
1546
+				echo 'Count all owners...'."\n";
1547
+			}
1394 1548
 			$alldata = $Spotter->countAllOwners(false,0,$last_update_day);
1395 1549
 			foreach ($alldata as $number) {
1396 1550
 				$this->addStatOwner($number['owner_name'],$number['owner_count']);
1397 1551
 			}
1398
-			if ($globalDebug) echo 'Count all pilots...'."\n";
1552
+			if ($globalDebug) {
1553
+				echo 'Count all pilots...'."\n";
1554
+			}
1399 1555
 			$alldata = $Spotter->countAllPilots(false,0,$last_update_day);
1400 1556
 			foreach ($alldata as $number) {
1401 1557
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name']);
1402 1558
 			}
1403 1559
 			
1404
-			if ($globalDebug) echo 'Count all departure airports...'."\n";
1560
+			if ($globalDebug) {
1561
+				echo 'Count all departure airports...'."\n";
1562
+			}
1405 1563
 			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
1406
-			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
1564
+			if ($globalDebug) {
1565
+				echo 'Count all detected departure airports...'."\n";
1566
+			}
1407 1567
         		$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1408
-			if ($globalDebug) echo 'Order departure airports...'."\n";
1568
+			if ($globalDebug) {
1569
+				echo 'Order departure airports...'."\n";
1570
+			}
1409 1571
 	        	$alldata = array();
1410 1572
 	        	
1411 1573
     			foreach ($pall as $value) {
@@ -1416,7 +1578,9 @@  discard block
 block discarded – undo
1416 1578
     				$icao = $value['airport_departure_icao'];
1417 1579
         			if (isset($alldata[$icao])) {
1418 1580
     					$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1419
-        			} else $alldata[$icao] = $value;
1581
+        			} else {
1582
+        				$alldata[$icao] = $value;
1583
+        			}
1420 1584
 			}
1421 1585
     			$count = array();
1422 1586
     			foreach ($alldata as $key => $row) {
@@ -1426,11 +1590,17 @@  discard block
 block discarded – undo
1426 1590
 			foreach ($alldata as $number) {
1427 1591
 				echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count']);
1428 1592
 			}
1429
-			if ($globalDebug) echo 'Count all arrival airports...'."\n";
1593
+			if ($globalDebug) {
1594
+				echo 'Count all arrival airports...'."\n";
1595
+			}
1430 1596
 			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
1431
-			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
1597
+			if ($globalDebug) {
1598
+				echo 'Count all detected arrival airports...'."\n";
1599
+			}
1432 1600
         		$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1433
-			if ($globalDebug) echo 'Order arrival airports...'."\n";
1601
+			if ($globalDebug) {
1602
+				echo 'Order arrival airports...'."\n";
1603
+			}
1434 1604
 	        	$alldata = array();
1435 1605
     			foreach ($pall as $value) {
1436 1606
 	        		$icao = $value['airport_arrival_icao'];
@@ -1440,7 +1610,9 @@  discard block
 block discarded – undo
1440 1610
     				$icao = $value['airport_arrival_icao'];
1441 1611
         			if (isset($alldata[$icao])) {
1442 1612
         				$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1443
-	        		} else $alldata[$icao] = $value;
1613
+	        		} else {
1614
+	        			$alldata[$icao] = $value;
1615
+	        		}
1444 1616
     			}
1445 1617
         		$count = array();
1446 1618
         		foreach ($alldata as $key => $row) {
@@ -1451,7 +1623,9 @@  discard block
 block discarded – undo
1451 1623
 				echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count']);
1452 1624
 			}
1453 1625
 			if ($Connection->tableExists('countries')) {
1454
-				if ($globalDebug) echo 'Count all flights by countries...'."\n";
1626
+				if ($globalDebug) {
1627
+					echo 'Count all flights by countries...'."\n";
1628
+				}
1455 1629
 				$SpotterArchive = new SpotterArchive();
1456 1630
 				$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day);
1457 1631
 				foreach ($alldata as $number) {
@@ -1463,46 +1637,66 @@  discard block
 block discarded – undo
1463 1637
 			// Add by month using getstat if month finish...
1464 1638
 
1465 1639
 			//if (date('m',strtotime($last_update_day)) != date('m')) {
1466
-			if ($globalDebug) echo 'Count all flights by months...'."\n";
1640
+			if ($globalDebug) {
1641
+				echo 'Count all flights by months...'."\n";
1642
+			}
1467 1643
 			$Spotter = new Spotter($this->db);
1468 1644
 			$alldata = $Spotter->countAllMonths();
1469 1645
 			$lastyear = false;
1470 1646
 			foreach ($alldata as $number) {
1471
-				if ($number['year_name'] != date('Y')) $lastyear = true;
1647
+				if ($number['year_name'] != date('Y')) {
1648
+					$lastyear = true;
1649
+				}
1472 1650
 				$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'])));
1473 1651
 			}
1474
-			if ($globalDebug) echo 'Count all military flights by months...'."\n";
1652
+			if ($globalDebug) {
1653
+				echo 'Count all military flights by months...'."\n";
1654
+			}
1475 1655
 			$alldata = $Spotter->countAllMilitaryMonths();
1476 1656
 			foreach ($alldata as $number) {
1477 1657
 				$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'])));
1478 1658
 			}
1479
-			if ($globalDebug) echo 'Count all owners by months...'."\n";
1659
+			if ($globalDebug) {
1660
+				echo 'Count all owners by months...'."\n";
1661
+			}
1480 1662
 			$alldata = $Spotter->countAllMonthsOwners();
1481 1663
 			foreach ($alldata as $number) {
1482 1664
 				$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'])));
1483 1665
 			}
1484
-			if ($globalDebug) echo 'Count all pilots by months...'."\n";
1666
+			if ($globalDebug) {
1667
+				echo 'Count all pilots by months...'."\n";
1668
+			}
1485 1669
 			$alldata = $Spotter->countAllMonthsPilots();
1486 1670
 			foreach ($alldata as $number) {
1487 1671
 				$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'])));
1488 1672
 			}
1489
-			if ($globalDebug) echo 'Count all airlines by months...'."\n";
1673
+			if ($globalDebug) {
1674
+				echo 'Count all airlines by months...'."\n";
1675
+			}
1490 1676
 			$alldata = $Spotter->countAllMonthsAirlines();
1491 1677
 			foreach ($alldata as $number) {
1492 1678
 				$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'])));
1493 1679
 			}
1494
-			if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
1680
+			if ($globalDebug) {
1681
+				echo 'Count all aircrafts by months...'."\n";
1682
+			}
1495 1683
 			$alldata = $Spotter->countAllMonthsAircrafts();
1496 1684
 			foreach ($alldata as $number) {
1497 1685
 				$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'])));
1498 1686
 			}
1499
-			if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
1687
+			if ($globalDebug) {
1688
+				echo 'Count all real arrivals by months...'."\n";
1689
+			}
1500 1690
 			$alldata = $Spotter->countAllMonthsRealArrivals();
1501 1691
 			foreach ($alldata as $number) {
1502 1692
 				$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'])));
1503 1693
 			}
1504
-			if ($globalDebug) echo 'Airports data...'."\n";
1505
-			if ($globalDebug) echo '...Departure'."\n";
1694
+			if ($globalDebug) {
1695
+				echo 'Airports data...'."\n";
1696
+			}
1697
+			if ($globalDebug) {
1698
+				echo '...Departure'."\n";
1699
+			}
1506 1700
 			$this->deleteStatAirport('daily');
1507 1701
 //			$pall = $Spotter->getLast7DaysAirportsDeparture();
1508 1702
   //      		$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
@@ -1622,37 +1816,53 @@  discard block
 block discarded – undo
1622 1816
 
1623 1817
 			// Count by airlines
1624 1818
 			echo '--- Stats by airlines ---'."\n";
1625
-			if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n";
1819
+			if ($globalDebug) {
1820
+				echo 'Count all aircraft types by airlines...'."\n";
1821
+			}
1626 1822
 			$Spotter = new Spotter($this->db);
1627 1823
 			$alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day);
1628 1824
 			foreach ($alldata as $number) {
1629 1825
 				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao']);
1630 1826
 			}
1631
-			if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n";
1827
+			if ($globalDebug) {
1828
+				echo 'Count all aircraft registrations by airlines...'."\n";
1829
+			}
1632 1830
 			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day);
1633 1831
 			foreach ($alldata as $number) {
1634 1832
 				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao']);
1635 1833
 			}
1636
-			if ($globalDebug) echo 'Count all callsigns by airlines...'."\n";
1834
+			if ($globalDebug) {
1835
+				echo 'Count all callsigns by airlines...'."\n";
1836
+			}
1637 1837
 			$alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day);
1638 1838
 			foreach ($alldata as $number) {
1639 1839
 				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao']);
1640 1840
 			}
1641
-			if ($globalDebug) echo 'Count all owners by airlines...'."\n";
1841
+			if ($globalDebug) {
1842
+				echo 'Count all owners by airlines...'."\n";
1843
+			}
1642 1844
 			$alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day);
1643 1845
 			foreach ($alldata as $number) {
1644 1846
 				$this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao']);
1645 1847
 			}
1646
-			if ($globalDebug) echo 'Count all pilots by airlines...'."\n";
1848
+			if ($globalDebug) {
1849
+				echo 'Count all pilots by airlines...'."\n";
1850
+			}
1647 1851
 			$alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day);
1648 1852
 			foreach ($alldata as $number) {
1649 1853
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao']);
1650 1854
 			}
1651
-			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
1855
+			if ($globalDebug) {
1856
+				echo 'Count all departure airports by airlines...'."\n";
1857
+			}
1652 1858
 			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
1653
-			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
1859
+			if ($globalDebug) {
1860
+				echo 'Count all detected departure airports by airlines...'."\n";
1861
+			}
1654 1862
        			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
1655
-			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
1863
+			if ($globalDebug) {
1864
+				echo 'Order detected departure airports by airlines...'."\n";
1865
+			}
1656 1866
 	        	//$alldata = array();
1657 1867
     			foreach ($dall as $value) {
1658 1868
     				$icao = $value['airport_departure_icao'];
@@ -1673,11 +1883,17 @@  discard block
 block discarded – undo
1673 1883
 			foreach ($alldata as $number) {
1674 1884
 				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']);
1675 1885
 			}
1676
-			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
1886
+			if ($globalDebug) {
1887
+				echo 'Count all arrival airports by airlines...'."\n";
1888
+			}
1677 1889
 			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
1678
-			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
1890
+			if ($globalDebug) {
1891
+				echo 'Count all detected arrival airports by airlines...'."\n";
1892
+			}
1679 1893
         		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
1680
-			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
1894
+			if ($globalDebug) {
1895
+				echo 'Order arrival airports by airlines...'."\n";
1896
+			}
1681 1897
 	        	//$alldata = array();
1682 1898
     			foreach ($dall as $value) {
1683 1899
     				$icao = $value['airport_arrival_icao'];
@@ -1698,35 +1914,49 @@  discard block
 block discarded – undo
1698 1914
                         foreach ($alldata as $number) {
1699 1915
 				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']);
1700 1916
 			}
1701
-			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
1917
+			if ($globalDebug) {
1918
+				echo 'Count all flights by months by airlines...'."\n";
1919
+			}
1702 1920
 			$Spotter = new Spotter($this->db);
1703 1921
 			$alldata = $Spotter->countAllMonthsByAirlines();
1704 1922
 			$lastyear = false;
1705 1923
 			foreach ($alldata as $number) {
1706
-				if ($number['year_name'] != date('Y')) $lastyear = true;
1924
+				if ($number['year_name'] != date('Y')) {
1925
+					$lastyear = true;
1926
+				}
1707 1927
 				$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']);
1708 1928
 			}
1709
-			if ($globalDebug) echo 'Count all owners by months by airlines...'."\n";
1929
+			if ($globalDebug) {
1930
+				echo 'Count all owners by months by airlines...'."\n";
1931
+			}
1710 1932
 			$alldata = $Spotter->countAllMonthsOwnersByAirlines();
1711 1933
 			foreach ($alldata as $number) {
1712 1934
 				$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']);
1713 1935
 			}
1714
-			if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n";
1936
+			if ($globalDebug) {
1937
+				echo 'Count all pilots by months by airlines...'."\n";
1938
+			}
1715 1939
 			$alldata = $Spotter->countAllMonthsPilotsByAirlines();
1716 1940
 			foreach ($alldata as $number) {
1717 1941
 				$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']);
1718 1942
 			}
1719
-			if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n";
1943
+			if ($globalDebug) {
1944
+				echo 'Count all aircrafts by months by airlines...'."\n";
1945
+			}
1720 1946
 			$alldata = $Spotter->countAllMonthsAircraftsByAirlines();
1721 1947
 			foreach ($alldata as $number) {
1722 1948
 				$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']);
1723 1949
 			}
1724
-			if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n";
1950
+			if ($globalDebug) {
1951
+				echo 'Count all real arrivals by months by airlines...'."\n";
1952
+			}
1725 1953
 			$alldata = $Spotter->countAllMonthsRealArrivalsByAirlines();
1726 1954
 			foreach ($alldata as $number) {
1727 1955
 				$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']);
1728 1956
 			}
1729
-			if ($globalDebug) echo '...Departure'."\n";
1957
+			if ($globalDebug) {
1958
+				echo '...Departure'."\n";
1959
+			}
1730 1960
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
1731 1961
         		$dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines();
1732 1962
     			foreach ($dall as $value) {
@@ -1749,7 +1979,9 @@  discard block
 block discarded – undo
1749 1979
 			foreach ($alldata as $number) {
1750 1980
 				$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']);
1751 1981
 			}
1752
-			if ($globalDebug) echo '...Arrival'."\n";
1982
+			if ($globalDebug) {
1983
+				echo '...Arrival'."\n";
1984
+			}
1753 1985
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
1754 1986
         		$dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines();
1755 1987
     			foreach ($dall as $value) {
@@ -1773,13 +2005,19 @@  discard block
 block discarded – undo
1773 2005
 				$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']);
1774 2006
 			}
1775 2007
 
1776
-			if ($globalDebug) echo 'Flights data...'."\n";
1777
-			if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n";
2008
+			if ($globalDebug) {
2009
+				echo 'Flights data...'."\n";
2010
+			}
2011
+			if ($globalDebug) {
2012
+				echo '-> countAllDatesLastMonth...'."\n";
2013
+			}
1778 2014
 			$alldata = $Spotter->countAllDatesLastMonthByAirlines();
1779 2015
 			foreach ($alldata as $number) {
1780 2016
 				$this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']);
1781 2017
 			}
1782
-			if ($globalDebug) echo '-> countAllDates...'."\n";
2018
+			if ($globalDebug) {
2019
+				echo '-> countAllDates...'."\n";
2020
+			}
1783 2021
 			//$previousdata = $this->countAllDatesByAirlines();
1784 2022
 			$alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines());
1785 2023
 			$values = array();
@@ -1792,19 +2030,25 @@  discard block
 block discarded – undo
1792 2030
 				$this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']);
1793 2031
 			}
1794 2032
 			
1795
-			if ($globalDebug) echo '-> countAllHours...'."\n";
2033
+			if ($globalDebug) {
2034
+				echo '-> countAllHours...'."\n";
2035
+			}
1796 2036
 			$alldata = $Spotter->countAllHoursByAirlines('hour');
1797 2037
 			foreach ($alldata as $number) {
1798 2038
 				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']);
1799 2039
 			}
1800 2040
 			
1801 2041
 
1802
-			if (!isset($globalStatsFilters) || $globalStatsFilters == '') $globalStatsFilters = array();
2042
+			if (!isset($globalStatsFilters) || $globalStatsFilters == '') {
2043
+				$globalStatsFilters = array();
2044
+			}
1803 2045
 			foreach ($globalStatsFilters as $name => $filter) {
1804 2046
 				//$filter_name = $filter['name'];
1805 2047
 				$filter_name = $name;
1806 2048
 				// Count by filter
1807
-				if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n";
2049
+				if ($globalDebug) {
2050
+					echo '--- Stats for filter '.$filter_name.' ---'."\n";
2051
+				}
1808 2052
 				$Spotter = new Spotter($this->db);
1809 2053
 				$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter);
1810 2054
 				foreach ($alldata as $number) {
@@ -1842,7 +2086,9 @@  discard block
 block discarded – undo
1842 2086
 	    				$icao = $value['airport_departure_icao'];
1843 2087
         				if (isset($alldata[$icao])) {
1844 2088
     						$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1845
-        				} else $alldata[$icao] = $value;
2089
+        				} else {
2090
+        					$alldata[$icao] = $value;
2091
+        				}
1846 2092
 				}
1847 2093
 	    			$count = array();
1848 2094
     				foreach ($alldata as $key => $row) {
@@ -1863,7 +2109,9 @@  discard block
 block discarded – undo
1863 2109
 	    				$icao = $value['airport_arrival_icao'];
1864 2110
         				if (isset($alldata[$icao])) {
1865 2111
         					$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1866
-		        		} else $alldata[$icao] = $value;
2112
+		        		} else {
2113
+		        			$alldata[$icao] = $value;
2114
+		        		}
1867 2115
 	    			}
1868 2116
         			$count = array();
1869 2117
         			foreach ($alldata as $key => $row) {
@@ -1877,7 +2125,9 @@  discard block
 block discarded – undo
1877 2125
 				$alldata = $Spotter->countAllMonths($filter);
1878 2126
 				$lastyear = false;
1879 2127
 				foreach ($alldata as $number) {
1880
-					if ($number['year_name'] != date('Y')) $lastyear = true;
2128
+					if ($number['year_name'] != date('Y')) {
2129
+						$lastyear = true;
2130
+					}
1881 2131
 					$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);
1882 2132
 				}
1883 2133
 				$alldata = $Spotter->countAllMonthsOwners($filter);
Please login to merge, or discard this patch.
install/class.update_schema.php 1 patch
Braces   +230 added lines, -86 removed lines patch added patch discarded remove patch
@@ -258,7 +258,9 @@  discard block
 block discarded – undo
258 258
     		// Update table countries
259 259
     		if ($Connection->tableExists('airspace')) {
260 260
     		    $error .= update_db::update_countries();
261
-		    if ($error != '') return $error;
261
+		    if ($error != '') {
262
+		    	return $error;
263
+		    }
262 264
 		}
263 265
 		// Update schema_version to 7
264 266
 		$query = "UPDATE `config` SET `value` = '7' WHERE `name` = 'schema_version'";
@@ -314,7 +316,9 @@  discard block
 block discarded – undo
314 316
     		$error = '';
315 317
     		// Update table aircraft
316 318
 		$error .= create_db::import_file('../db/source_location.sql');
317
-		if ($error != '') return $error;
319
+		if ($error != '') {
320
+			return $error;
321
+		}
318 322
 		// Update schema_version to 6
319 323
 		$query = "UPDATE `config` SET `value` = '8' WHERE `name` = 'schema_version'";
320 324
         	try {
@@ -331,7 +335,9 @@  discard block
 block discarded – undo
331 335
     		$error = '';
332 336
     		// Update table aircraft
333 337
 		$error .= create_db::import_file('../db/notam.sql');
334
-		if ($error != '') return $error;
338
+		if ($error != '') {
339
+			return $error;
340
+		}
335 341
 		$query = "DELETE FROM config WHERE name = 'last_update_db';
336 342
                         INSERT INTO config (name,value) VALUES ('last_update_db',NOW());
337 343
                         DELETE FROM config WHERE name = 'last_update_notam_db';
@@ -365,7 +371,9 @@  discard block
 block discarded – undo
365 371
 		$error = '';
366 372
     		// Update table atc
367 373
 		$error .= create_db::import_file('../db/atc.sql');
368
-		if ($error != '') return $error;
374
+		if ($error != '') {
375
+			return $error;
376
+		}
369 377
 		
370 378
 		$query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'";
371 379
         	try {
@@ -389,13 +397,21 @@  discard block
 block discarded – undo
389 397
 		$error = '';
390 398
     		// Add tables
391 399
 		$error .= create_db::import_file('../db/aircraft_owner.sql');
392
-		if ($error != '') return $error;
400
+		if ($error != '') {
401
+			return $error;
402
+		}
393 403
 		$error .= create_db::import_file('../db/metar.sql');
394
-		if ($error != '') return $error;
404
+		if ($error != '') {
405
+			return $error;
406
+		}
395 407
 		$error .= create_db::import_file('../db/taf.sql');
396
-		if ($error != '') return $error;
408
+		if ($error != '') {
409
+			return $error;
410
+		}
397 411
 		$error .= create_db::import_file('../db/airport.sql');
398
-		if ($error != '') return $error;
412
+		if ($error != '') {
413
+			return $error;
414
+		}
399 415
 		
400 416
 		$query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'";
401 417
         	try {
@@ -469,19 +485,33 @@  discard block
 block discarded – undo
469 485
 		$error = '';
470 486
     		// Add tables
471 487
 		$error .= create_db::import_file('../db/stats.sql');
472
-		if ($error != '') return $error;
488
+		if ($error != '') {
489
+			return $error;
490
+		}
473 491
 		$error .= create_db::import_file('../db/stats_aircraft.sql');
474
-		if ($error != '') return $error;
492
+		if ($error != '') {
493
+			return $error;
494
+		}
475 495
 		$error .= create_db::import_file('../db/stats_airline.sql');
476
-		if ($error != '') return $error;
496
+		if ($error != '') {
497
+			return $error;
498
+		}
477 499
 		$error .= create_db::import_file('../db/stats_airport.sql');
478
-		if ($error != '') return $error;
500
+		if ($error != '') {
501
+			return $error;
502
+		}
479 503
 		$error .= create_db::import_file('../db/stats_owner.sql');
480
-		if ($error != '') return $error;
504
+		if ($error != '') {
505
+			return $error;
506
+		}
481 507
 		$error .= create_db::import_file('../db/stats_pilot.sql');
482
-		if ($error != '') return $error;
508
+		if ($error != '') {
509
+			return $error;
510
+		}
483 511
 		$error .= create_db::import_file('../db/spotter_archive_output.sql');
484
-		if ($error != '') return $error;
512
+		if ($error != '') {
513
+			return $error;
514
+		}
485 515
 		
486 516
 		$query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'";
487 517
         	try {
@@ -521,7 +551,9 @@  discard block
 block discarded – undo
521 551
     		// Add tables
522 552
     		if (!$Connection->tableExists('stats_flight')) {
523 553
 			$error .= create_db::import_file('../db/stats_flight.sql');
524
-			if ($error != '') return $error;
554
+			if ($error != '') {
555
+				return $error;
556
+			}
525 557
 		}
526 558
 		$query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'";
527 559
         	try {
@@ -545,7 +577,9 @@  discard block
 block discarded – undo
545 577
     		} catch(PDOException $e) {
546 578
 		    return "error (update stats) : ".$e->getMessage()."\n";
547 579
     		}
548
-		if ($error != '') return $error;
580
+		if ($error != '') {
581
+			return $error;
582
+		}
549 583
 		$query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'";
550 584
         	try {
551 585
             	    $sth = $Connection->db->prepare($query);
@@ -566,7 +600,9 @@  discard block
 block discarded – undo
566 600
     		if (!$Connection->tableExists('stats_callsign')) {
567 601
 			$error .= create_db::import_file('../db/stats_callsign.sql');
568 602
 		}
569
-		if ($error != '') return $error;
603
+		if ($error != '') {
604
+			return $error;
605
+		}
570 606
 		$query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'";
571 607
         	try {
572 608
             	    $sth = $Connection->db->prepare($query);
@@ -584,7 +620,9 @@  discard block
 block discarded – undo
584 620
     		if (!$Connection->tableExists('stats_country')) {
585 621
 			$error .= create_db::import_file('../db/stats_country.sql');
586 622
 		}
587
-		if ($error != '') return $error;
623
+		if ($error != '') {
624
+			return $error;
625
+		}
588 626
 		$query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'";
589 627
         	try {
590 628
             	    $sth = $Connection->db->prepare($query);
@@ -607,7 +645,9 @@  discard block
 block discarded – undo
607 645
 			    return "error (update stats) : ".$e->getMessage()."\n";
608 646
     			}
609 647
     		}
610
-		if ($error != '') return $error;
648
+		if ($error != '') {
649
+			return $error;
650
+		}
611 651
 		$query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'";
612 652
         	try {
613 653
             	    $sth = $Connection->db->prepare($query);
@@ -623,7 +663,9 @@  discard block
 block discarded – undo
623 663
 		$error = '';
624 664
     		// Update airport table
625 665
 		$error .= create_db::import_file('../db/airport.sql');
626
-		if ($error != '') return 'Import airport.sql : '.$error;
666
+		if ($error != '') {
667
+			return 'Import airport.sql : '.$error;
668
+		}
627 669
 		// Remove primary key on Spotter_Archive
628 670
 		$query = "alter table spotter_archive drop spotter_archive_id";
629 671
         	try {
@@ -699,7 +741,9 @@  discard block
 block discarded – undo
699 741
 				return "error (add source_name column) : ".$e->getMessage()."\n";
700 742
     			}
701 743
     		}
702
-		if ($error != '') return $error;
744
+		if ($error != '') {
745
+			return $error;
746
+		}
703 747
 		$query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'";
704 748
         	try {
705 749
             	    $sth = $Connection->db->prepare($query);
@@ -717,7 +761,9 @@  discard block
 block discarded – undo
717 761
     		// Update airline table
718 762
     		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
719 763
 			$error .= create_db::import_file('../db/airlines.sql');
720
-			if ($error != '') return 'Import airlines.sql : '.$error;
764
+			if ($error != '') {
765
+				return 'Import airlines.sql : '.$error;
766
+			}
721 767
 		}
722 768
 		if (!$Connection->checkColumnName('aircraft_modes','type_flight')) {
723 769
 			// Add column over_country
@@ -729,7 +775,9 @@  discard block
 block discarded – undo
729 775
 				return "error (add over_country) : ".$e->getMessage()."\n";
730 776
     			}
731 777
     		}
732
-		if ($error != '') return $error;
778
+		if ($error != '') {
779
+			return $error;
780
+		}
733 781
 		/*
734 782
     		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
735 783
 			// Force update ModeS (this will put type_flight data
@@ -759,7 +807,9 @@  discard block
 block discarded – undo
759 807
 			} catch(PDOException $e) {
760 808
 				return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n";
761 809
 			}
762
-			if ($error != '') return $error;
810
+			if ($error != '') {
811
+				return $error;
812
+			}
763 813
 		}
764 814
 		$query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'";
765 815
         	try {
@@ -782,7 +832,9 @@  discard block
 block discarded – undo
782 832
 			} else {
783 833
 				$error .= create_db::import_file('../db/pgsql/stats_source.sql');
784 834
 			}
785
-			if ($error != '') return $error;
835
+			if ($error != '') {
836
+				return $error;
837
+			}
786 838
 		}
787 839
 		$query = "UPDATE config SET value = '23' WHERE name = 'schema_version'";
788 840
         	try {
@@ -804,12 +856,16 @@  discard block
 block discarded – undo
804 856
 		if ($globalDBdriver == 'mysql') {
805 857
 			if (!$Connection->tableExists('tle')) {
806 858
 				$error .= create_db::import_file('../db/tle.sql');
807
-				if ($error != '') return $error;
859
+				if ($error != '') {
860
+					return $error;
861
+				}
808 862
 			}
809 863
 		} else {
810 864
 			if (!$Connection->tableExists('tle')) {
811 865
 				$error .= create_db::import_file('../db/pgsql/tle.sql');
812
-				if ($error != '') return $error;
866
+				if ($error != '') {
867
+					return $error;
868
+				}
813 869
 			}
814 870
 			$query = "create index flightaware_id_idx ON spotter_archive USING btree(flightaware_id)";
815 871
 			try {
@@ -849,7 +905,9 @@  discard block
 block discarded – undo
849 905
 		} else {
850 906
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
851 907
 		}
852
-		if ($error != '') return 'Import airlines.sql : '.$error;
908
+		if ($error != '') {
909
+			return 'Import airlines.sql : '.$error;
910
+		}
853 911
 		if (!$Connection->checkColumnName('airlines','forsource')) {
854 912
 			// Add forsource to airlines
855 913
 			$query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL";
@@ -1171,8 +1229,11 @@  discard block
 block discarded – undo
1171 1229
     	    if ($Connection->tableExists('aircraft')) {
1172 1230
     		if (!$Connection->tableExists('config')) {
1173 1231
     		    $version = '1';
1174
-    		    if ($update) return self::update_from_1();
1175
-    		    else return $version;
1232
+    		    if ($update) {
1233
+    		    	return self::update_from_1();
1234
+    		    } else {
1235
+    		    	return $version;
1236
+    		    }
1176 1237
 		} else {
1177 1238
     		    $Connection = new Connection();
1178 1239
 		    $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
@@ -1186,114 +1247,197 @@  discard block
 block discarded – undo
1186 1247
     		    if ($update) {
1187 1248
     			if ($result['value'] == '2') {
1188 1249
     			    $error = self::update_from_2();
1189
-    			    if ($error != '') return $error;
1190
-    			    else return self::check_version(true);
1250
+    			    if ($error != '') {
1251
+    			    	return $error;
1252
+    			    } else {
1253
+    			    	return self::check_version(true);
1254
+    			    }
1191 1255
     			} elseif ($result['value'] == '3') {
1192 1256
     			    $error = self::update_from_3();
1193
-    			    if ($error != '') return $error;
1194
-    			    else return self::check_version(true);
1257
+    			    if ($error != '') {
1258
+    			    	return $error;
1259
+    			    } else {
1260
+    			    	return self::check_version(true);
1261
+    			    }
1195 1262
     			} elseif ($result['value'] == '4') {
1196 1263
     			    $error = self::update_from_4();
1197
-    			    if ($error != '') return $error;
1198
-    			    else return self::check_version(true);
1264
+    			    if ($error != '') {
1265
+    			    	return $error;
1266
+    			    } else {
1267
+    			    	return self::check_version(true);
1268
+    			    }
1199 1269
     			} elseif ($result['value'] == '5') {
1200 1270
     			    $error = self::update_from_5();
1201
-    			    if ($error != '') return $error;
1202
-    			    else return self::check_version(true);
1271
+    			    if ($error != '') {
1272
+    			    	return $error;
1273
+    			    } else {
1274
+    			    	return self::check_version(true);
1275
+    			    }
1203 1276
     			} elseif ($result['value'] == '6') {
1204 1277
     			    $error = self::update_from_6();
1205
-    			    if ($error != '') return $error;
1206
-    			    else return self::check_version(true);
1278
+    			    if ($error != '') {
1279
+    			    	return $error;
1280
+    			    } else {
1281
+    			    	return self::check_version(true);
1282
+    			    }
1207 1283
     			} elseif ($result['value'] == '7') {
1208 1284
     			    $error = self::update_from_7();
1209
-    			    if ($error != '') return $error;
1210
-    			    else return self::check_version(true);
1285
+    			    if ($error != '') {
1286
+    			    	return $error;
1287
+    			    } else {
1288
+    			    	return self::check_version(true);
1289
+    			    }
1211 1290
     			} elseif ($result['value'] == '8') {
1212 1291
     			    $error = self::update_from_8();
1213
-    			    if ($error != '') return $error;
1214
-    			    else return self::check_version(true);
1292
+    			    if ($error != '') {
1293
+    			    	return $error;
1294
+    			    } else {
1295
+    			    	return self::check_version(true);
1296
+    			    }
1215 1297
     			} elseif ($result['value'] == '9') {
1216 1298
     			    $error = self::update_from_9();
1217
-    			    if ($error != '') return $error;
1218
-    			    else return self::check_version(true);
1299
+    			    if ($error != '') {
1300
+    			    	return $error;
1301
+    			    } else {
1302
+    			    	return self::check_version(true);
1303
+    			    }
1219 1304
     			} elseif ($result['value'] == '10') {
1220 1305
     			    $error = self::update_from_10();
1221
-    			    if ($error != '') return $error;
1222
-    			    else return self::check_version(true);
1306
+    			    if ($error != '') {
1307
+    			    	return $error;
1308
+    			    } else {
1309
+    			    	return self::check_version(true);
1310
+    			    }
1223 1311
     			} elseif ($result['value'] == '11') {
1224 1312
     			    $error = self::update_from_11();
1225
-    			    if ($error != '') return $error;
1226
-    			    else return self::check_version(true);
1313
+    			    if ($error != '') {
1314
+    			    	return $error;
1315
+    			    } else {
1316
+    			    	return self::check_version(true);
1317
+    			    }
1227 1318
     			} elseif ($result['value'] == '12') {
1228 1319
     			    $error = self::update_from_12();
1229
-    			    if ($error != '') return $error;
1230
-    			    else return self::check_version(true);
1320
+    			    if ($error != '') {
1321
+    			    	return $error;
1322
+    			    } else {
1323
+    			    	return self::check_version(true);
1324
+    			    }
1231 1325
     			} elseif ($result['value'] == '13') {
1232 1326
     			    $error = self::update_from_13();
1233
-    			    if ($error != '') return $error;
1234
-    			    else return self::check_version(true);
1327
+    			    if ($error != '') {
1328
+    			    	return $error;
1329
+    			    } else {
1330
+    			    	return self::check_version(true);
1331
+    			    }
1235 1332
     			} elseif ($result['value'] == '14') {
1236 1333
     			    $error = self::update_from_14();
1237
-    			    if ($error != '') return $error;
1238
-    			    else return self::check_version(true);
1334
+    			    if ($error != '') {
1335
+    			    	return $error;
1336
+    			    } else {
1337
+    			    	return self::check_version(true);
1338
+    			    }
1239 1339
     			} elseif ($result['value'] == '15') {
1240 1340
     			    $error = self::update_from_15();
1241
-    			    if ($error != '') return $error;
1242
-    			    else return self::check_version(true);
1341
+    			    if ($error != '') {
1342
+    			    	return $error;
1343
+    			    } else {
1344
+    			    	return self::check_version(true);
1345
+    			    }
1243 1346
     			} elseif ($result['value'] == '16') {
1244 1347
     			    $error = self::update_from_16();
1245
-    			    if ($error != '') return $error;
1246
-    			    else return self::check_version(true);
1348
+    			    if ($error != '') {
1349
+    			    	return $error;
1350
+    			    } else {
1351
+    			    	return self::check_version(true);
1352
+    			    }
1247 1353
     			} elseif ($result['value'] == '17') {
1248 1354
     			    $error = self::update_from_17();
1249
-    			    if ($error != '') return $error;
1250
-    			    else return self::check_version(true);
1355
+    			    if ($error != '') {
1356
+    			    	return $error;
1357
+    			    } else {
1358
+    			    	return self::check_version(true);
1359
+    			    }
1251 1360
     			} elseif ($result['value'] == '18') {
1252 1361
     			    $error = self::update_from_18();
1253
-    			    if ($error != '') return $error;
1254
-    			    else return self::check_version(true);
1362
+    			    if ($error != '') {
1363
+    			    	return $error;
1364
+    			    } else {
1365
+    			    	return self::check_version(true);
1366
+    			    }
1255 1367
     			} elseif ($result['value'] == '19') {
1256 1368
     			    $error = self::update_from_19();
1257
-    			    if ($error != '') return $error;
1258
-    			    else return self::check_version(true);
1369
+    			    if ($error != '') {
1370
+    			    	return $error;
1371
+    			    } else {
1372
+    			    	return self::check_version(true);
1373
+    			    }
1259 1374
     			} elseif ($result['value'] == '20') {
1260 1375
     			    $error = self::update_from_20();
1261
-    			    if ($error != '') return $error;
1262
-    			    else return self::check_version(true);
1376
+    			    if ($error != '') {
1377
+    			    	return $error;
1378
+    			    } else {
1379
+    			    	return self::check_version(true);
1380
+    			    }
1263 1381
     			} elseif ($result['value'] == '21') {
1264 1382
     			    $error = self::update_from_21();
1265
-    			    if ($error != '') return $error;
1266
-    			    else return self::check_version(true);
1383
+    			    if ($error != '') {
1384
+    			    	return $error;
1385
+    			    } else {
1386
+    			    	return self::check_version(true);
1387
+    			    }
1267 1388
     			} elseif ($result['value'] == '22') {
1268 1389
     			    $error = self::update_from_22();
1269
-    			    if ($error != '') return $error;
1270
-    			    else return self::check_version(true);
1390
+    			    if ($error != '') {
1391
+    			    	return $error;
1392
+    			    } else {
1393
+    			    	return self::check_version(true);
1394
+    			    }
1271 1395
     			} elseif ($result['value'] == '23') {
1272 1396
     			    $error = self::update_from_23();
1273
-    			    if ($error != '') return $error;
1274
-    			    else return self::check_version(true);
1397
+    			    if ($error != '') {
1398
+    			    	return $error;
1399
+    			    } else {
1400
+    			    	return self::check_version(true);
1401
+    			    }
1275 1402
     			} elseif ($result['value'] == '24') {
1276 1403
     			    $error = self::update_from_24();
1277
-    			    if ($error != '') return $error;
1278
-    			    else return self::check_version(true);
1404
+    			    if ($error != '') {
1405
+    			    	return $error;
1406
+    			    } else {
1407
+    			    	return self::check_version(true);
1408
+    			    }
1279 1409
     			} elseif ($result['value'] == '25') {
1280 1410
     			    $error = self::update_from_25();
1281
-    			    if ($error != '') return $error;
1282
-    			    else return self::check_version(true);
1411
+    			    if ($error != '') {
1412
+    			    	return $error;
1413
+    			    } else {
1414
+    			    	return self::check_version(true);
1415
+    			    }
1283 1416
     			} elseif ($result['value'] == '26') {
1284 1417
     			    $error = self::update_from_26();
1285
-    			    if ($error != '') return $error;
1286
-    			    else return self::check_version(true);
1418
+    			    if ($error != '') {
1419
+    			    	return $error;
1420
+    			    } else {
1421
+    			    	return self::check_version(true);
1422
+    			    }
1287 1423
     			} elseif ($result['value'] == '27') {
1288 1424
     			    $error = self::update_from_27();
1289
-    			    if ($error != '') return $error;
1290
-    			    else return self::check_version(true);
1291
-    			} else return '';
1425
+    			    if ($error != '') {
1426
+    			    	return $error;
1427
+    			    } else {
1428
+    			    	return self::check_version(true);
1429
+    			    }
1430
+    			} else {
1431
+    				return '';
1432
+    			}
1433
+    		    } else {
1434
+    		    	return $result['value'];
1292 1435
     		    }
1293
-    		    else return $result['value'];
1294 1436
 		}
1295 1437
 		
1296
-	    } else return $version;
1438
+	    } else {
1439
+	    	return $version;
1440
+	    }
1297 1441
     	}
1298 1442
     	
1299 1443
 }
Please login to merge, or discard this patch.
install/class.update_db.php 1 patch
Braces   +768 added lines, -267 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
 		}
@@ -276,7 +323,9 @@  discard block
 block discarded – undo
276 323
 			$Connection = new Connection();
277 324
 			$sth_dest = $Connection->db->prepare($query_dest);
278 325
 			try {
279
-				if ($globalTransaction) $Connection->db->beginTransaction();
326
+				if ($globalTransaction) {
327
+					$Connection->db->beginTransaction();
328
+				}
280 329
             			while (!feof($fh)) {
281 330
             				$values = array();
282 331
             				$line = $Common->hex2str(fgets($fh,9999));
@@ -287,7 +336,9 @@  discard block
 block discarded – undo
287 336
             				// Check if we can find ICAO, else set it to GLID
288 337
             				$aircraft_name_split = explode(' ',$aircraft_name);
289 338
             				$search_more = '';
290
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
339
+            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) {
340
+            					$search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
341
+            				}
291 342
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
292 343
             				$sth_search = $Connection->db->prepare($query_search);
293 344
 					try {
@@ -300,7 +351,9 @@  discard block
 block discarded – undo
300 351
 					} catch(PDOException $e) {
301 352
 						return "error : ".$e->getMessage();
302 353
 					}
303
-					if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
354
+					if (!isset($values['ICAOTypeCode'])) {
355
+						$values['ICAOTypeCode'] = 'GLID';
356
+					}
304 357
 					// Add data to db
305 358
 					if ($values['ModeS'] != '' && $values['Registration'] != '' && $values['Registration'] != '0000') {
306 359
 						//$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']);
@@ -309,7 +362,9 @@  discard block
 block discarded – undo
309 362
 						$sth_dest->execute($query_dest_values);
310 363
 					}
311 364
 				}
312
-				if ($globalTransaction) $Connection->db->commit();
365
+				if ($globalTransaction) {
366
+					$Connection->db->commit();
367
+				}
313 368
 			} catch(PDOException $e) {
314 369
 				return "error : ".$e->getMessage();
315 370
 			}
@@ -345,7 +400,9 @@  discard block
 block discarded – undo
345 400
 			$Connection = new Connection();
346 401
 			$sth_dest = $Connection->db->prepare($query_dest);
347 402
 			try {
348
-				if ($globalTransaction) $Connection->db->beginTransaction();
403
+				if ($globalTransaction) {
404
+					$Connection->db->beginTransaction();
405
+				}
349 406
 				$tmp = fgetcsv($fh,9999,',',"'");
350 407
             			while (!feof($fh)) {
351 408
             				$line = fgetcsv($fh,9999,',',"'");
@@ -358,13 +415,17 @@  discard block
 block discarded – undo
358 415
             				// Check if we can find ICAO, else set it to GLID
359 416
             				$aircraft_name_split = explode(' ',$aircraft_name);
360 417
             				$search_more = '';
361
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
418
+            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) {
419
+            					$search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
420
+            				}
362 421
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
363 422
             				$sth_search = $Connection->db->prepare($query_search);
364 423
 					try {
365 424
                                     		$sth_search->execute();
366 425
 	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
367
-	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
426
+	            				if (isset($result['icao']) && $result['icao'] != '') {
427
+	            					$values['ICAOTypeCode'] = $result['icao'];
428
+	            				}
368 429
 					} catch(PDOException $e) {
369 430
 						return "error : ".$e->getMessage();
370 431
 					}
@@ -377,7 +438,9 @@  discard block
 block discarded – undo
377 438
 						$sth_dest->execute($query_dest_values);
378 439
 					}
379 440
 				}
380
-				if ($globalTransaction) $Connection->db->commit();
441
+				if ($globalTransaction) {
442
+					$Connection->db->commit();
443
+				}
381 444
 			} catch(PDOException $e) {
382 445
 				return "error : ".$e->getMessage();
383 446
 			}
@@ -413,7 +476,9 @@  discard block
 block discarded – undo
413 476
 			$Connection = new Connection();
414 477
 			$sth_dest = $Connection->db->prepare($query_dest);
415 478
 			try {
416
-				if ($globalTransaction) $Connection->db->beginTransaction();
479
+				if ($globalTransaction) {
480
+					$Connection->db->beginTransaction();
481
+				}
417 482
 				$tmp = fgetcsv($fh,9999,',','"');
418 483
             			while (!feof($fh)) {
419 484
             				$line = fgetcsv($fh,9999,',','"');
@@ -423,16 +488,22 @@  discard block
 block discarded – undo
423 488
             				    $values['registration'] = $line[0];
424 489
             				    $values['base'] = $line[4];
425 490
             				    $values['owner'] = $line[5];
426
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
427
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
491
+            				    if ($line[6] == '') {
492
+            				    	$values['date_first_reg'] = null;
493
+            				    } else {
494
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
495
+					    }
428 496
 					    $values['cancel'] = $line[7];
429 497
 					} elseif ($country == 'EI') {
430 498
 					    // TODO : add modeS & reg to aircraft_modes
431 499
             				    $values['registration'] = $line[0];
432 500
             				    $values['base'] = $line[3];
433 501
             				    $values['owner'] = $line[2];
434
-            				    if ($line[1] == '') $values['date_first_reg'] = null;
435
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
502
+            				    if ($line[1] == '') {
503
+            				    	$values['date_first_reg'] = null;
504
+            				    } else {
505
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
506
+					    }
436 507
 					    $values['cancel'] = '';
437 508
 					} elseif ($country == 'HB') {
438 509
 					    // TODO : add modeS & reg to aircraft_modes
@@ -446,16 +517,22 @@  discard block
 block discarded – undo
446 517
             				    $values['registration'] = $line[3];
447 518
             				    $values['base'] = null;
448 519
             				    $values['owner'] = $line[5];
449
-            				    if ($line[18] == '') $values['date_first_reg'] = null;
450
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
520
+            				    if ($line[18] == '') {
521
+            				    	$values['date_first_reg'] = null;
522
+            				    } else {
523
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
524
+					    }
451 525
 					    $values['cancel'] = '';
452 526
 					} elseif ($country == 'VH') {
453 527
 					    // TODO : add modeS & reg to aircraft_modes
454 528
             				    $values['registration'] = $line[0];
455 529
             				    $values['base'] = null;
456 530
             				    $values['owner'] = $line[12];
457
-            				    if ($line[28] == '') $values['date_first_reg'] = null;
458
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
531
+            				    if ($line[28] == '') {
532
+            				    	$values['date_first_reg'] = null;
533
+            				    } else {
534
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
535
+					    }
459 536
 
460 537
 					    $values['cancel'] = $line[39];
461 538
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
@@ -474,29 +551,41 @@  discard block
 block discarded – undo
474 551
             				    $values['registration'] = $line[0];
475 552
             				    $values['base'] = null;
476 553
             				    $values['owner'] = $line[8];
477
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
478
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
554
+            				    if ($line[7] == '') {
555
+            				    	$values['date_first_reg'] = null;
556
+            				    } else {
557
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
558
+					    }
479 559
 					    $values['cancel'] = '';
480 560
 					} elseif ($country == 'PP') {
481 561
             				    $values['registration'] = $line[0];
482 562
             				    $values['base'] = null;
483 563
             				    $values['owner'] = $line[4];
484
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
485
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
564
+            				    if ($line[6] == '') {
565
+            				    	$values['date_first_reg'] = null;
566
+            				    } else {
567
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
568
+					    }
486 569
 					    $values['cancel'] = $line[7];
487 570
 					} elseif ($country == 'E7') {
488 571
             				    $values['registration'] = $line[0];
489 572
             				    $values['base'] = null;
490 573
             				    $values['owner'] = $line[4];
491
-            				    if ($line[5] == '') $values['date_first_reg'] = null;
492
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
574
+            				    if ($line[5] == '') {
575
+            				    	$values['date_first_reg'] = null;
576
+            				    } else {
577
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
578
+					    }
493 579
 					    $values['cancel'] = '';
494 580
 					} elseif ($country == '8Q') {
495 581
             				    $values['registration'] = $line[0];
496 582
             				    $values['base'] = null;
497 583
             				    $values['owner'] = $line[3];
498
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
499
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
584
+            				    if ($line[7] == '') {
585
+            				    	$values['date_first_reg'] = null;
586
+            				    } else {
587
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
588
+					    }
500 589
 					    $values['cancel'] = '';
501 590
 					} elseif ($country == 'ZK' || $country == 'OM' || $country == 'TF') {
502 591
             				    $values['registration'] = $line[0];
@@ -510,7 +599,9 @@  discard block
 block discarded – undo
510 599
 						$sth_dest->execute($query_dest_values);
511 600
 					}
512 601
 				}
513
-				if ($globalTransaction) $Connection->db->commit();
602
+				if ($globalTransaction) {
603
+					$Connection->db->commit();
604
+				}
514 605
 			} catch(PDOException $e) {
515 606
 				return "error : ".$e->getMessage();
516 607
 			}
@@ -644,25 +735,45 @@  discard block
 block discarded – undo
644 735
 		    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)";
645 736
 		$Connection = new Connection();
646 737
 		$sth_dest = $Connection->db->prepare($query_dest);
647
-		if ($globalTransaction) $Connection->db->beginTransaction();
738
+		if ($globalTransaction) {
739
+			$Connection->db->beginTransaction();
740
+		}
648 741
   
649 742
 		$i = 0;
650 743
 		while($row = sparql_fetch_array($result))
651 744
 		{
652 745
 			if ($i >= 1) {
653 746
 			//print_r($row);
654
-			if (!isset($row['iata'])) $row['iata'] = '';
655
-			if (!isset($row['icao'])) $row['icao'] = '';
656
-			if (!isset($row['type'])) $row['type'] = '';
657
-			if (!isset($row['altitude'])) $row['altitude'] = '';
747
+			if (!isset($row['iata'])) {
748
+				$row['iata'] = '';
749
+			}
750
+			if (!isset($row['icao'])) {
751
+				$row['icao'] = '';
752
+			}
753
+			if (!isset($row['type'])) {
754
+				$row['type'] = '';
755
+			}
756
+			if (!isset($row['altitude'])) {
757
+				$row['altitude'] = '';
758
+			}
658 759
 			if (isset($row['city_bis'])) {
659 760
 				$row['city'] = $row['city_bis'];
660 761
 			}
661
-			if (!isset($row['city'])) $row['city'] = '';
662
-			if (!isset($row['country'])) $row['country'] = '';
663
-			if (!isset($row['homepage'])) $row['homepage'] = '';
664
-			if (!isset($row['wikipedia_page'])) $row['wikipedia_page'] = '';
665
-			if (!isset($row['name'])) continue;
762
+			if (!isset($row['city'])) {
763
+				$row['city'] = '';
764
+			}
765
+			if (!isset($row['country'])) {
766
+				$row['country'] = '';
767
+			}
768
+			if (!isset($row['homepage'])) {
769
+				$row['homepage'] = '';
770
+			}
771
+			if (!isset($row['wikipedia_page'])) {
772
+				$row['wikipedia_page'] = '';
773
+			}
774
+			if (!isset($row['name'])) {
775
+				continue;
776
+			}
666 777
 			if (!isset($row['image'])) {
667 778
 				$row['image'] = '';
668 779
 				$row['image_thumb'] = '';
@@ -698,7 +809,9 @@  discard block
 block discarded – undo
698 809
 
699 810
 			$i++;
700 811
 		}
701
-		if ($globalTransaction) $Connection->db->commit();
812
+		if ($globalTransaction) {
813
+			$Connection->db->commit();
814
+		}
702 815
 		echo "Delete duplicate rows...\n";
703 816
 		$query = 'ALTER IGNORE TABLE airport ADD UNIQUE INDEX icaoidx (icao)';
704 817
 		try {
@@ -710,7 +823,9 @@  discard block
 block discarded – undo
710 823
                 }
711 824
 
712 825
 
713
-		if ($globalDebug) echo "Insert Not available Airport...\n";
826
+		if ($globalDebug) {
827
+			echo "Insert Not available Airport...\n";
828
+		}
714 829
 		$query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image`,`image_thumb`)
715 830
 		    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image, :image_thumb)";
716 831
 		$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' => '');
@@ -737,7 +852,9 @@  discard block
 block discarded – undo
737 852
 		$delimiter = ',';
738 853
 		$out_file = $tmp_dir.'airports.csv';
739 854
 		update_db::download('http://ourairports.com/data/airports.csv',$out_file);
740
-		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
855
+		if (!file_exists($out_file) || !is_readable($out_file)) {
856
+			return FALSE;
857
+		}
741 858
 		echo "Add data from ourairports.com...\n";
742 859
 
743 860
 		$header = NULL;
@@ -747,8 +864,9 @@  discard block
 block discarded – undo
747 864
 			//$Connection->db->beginTransaction();
748 865
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
749 866
 			{
750
-				if(!$header) $header = $row;
751
-				else {
867
+				if(!$header) {
868
+					$header = $row;
869
+				} else {
752 870
 					$data = array();
753 871
 					$data = array_combine($header, $row);
754 872
 					try {
@@ -786,7 +904,9 @@  discard block
 block discarded – undo
786 904
 		echo "Download data from another free database...\n";
787 905
 		$out_file = $tmp_dir.'GlobalAirportDatabase.zip';
788 906
 		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file);
789
-		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
907
+		if (!file_exists($out_file) || !is_readable($out_file)) {
908
+			return FALSE;
909
+		}
790 910
 		update_db::unzip($out_file);
791 911
 		$header = NULL;
792 912
 		echo "Add data from another free database...\n";
@@ -797,8 +917,9 @@  discard block
 block discarded – undo
797 917
 			//$Connection->db->beginTransaction();
798 918
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
799 919
 			{
800
-				if(!$header) $header = $row;
801
-				else {
920
+				if(!$header) {
921
+					$header = $row;
922
+				} else {
802 923
 					$data = $row;
803 924
 
804 925
 					$query = 'UPDATE airport SET `city` = :city, `country` = :country WHERE icao = :icao';
@@ -964,7 +1085,9 @@  discard block
 block discarded – undo
964 1085
 			$i = 0;
965 1086
 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
966 1087
 			//$Connection->db->beginTransaction();
967
-			if ($globalTransaction) $Connection->db->beginTransaction();
1088
+			if ($globalTransaction) {
1089
+				$Connection->db->beginTransaction();
1090
+			}
968 1091
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
969 1092
 			{
970 1093
 				if ($i > 0) {
@@ -979,7 +1102,9 @@  discard block
 block discarded – undo
979 1102
 				$i++;
980 1103
 			}
981 1104
 			fclose($handle);
982
-			if ($globalTransaction) $Connection->db->commit();
1105
+			if ($globalTransaction) {
1106
+				$Connection->db->commit();
1107
+			}
983 1108
 		}
984 1109
 		return '';
985 1110
         }
@@ -1004,7 +1129,9 @@  discard block
 block discarded – undo
1004 1129
 			$i = 0;
1005 1130
 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
1006 1131
 			//$Connection->db->beginTransaction();
1007
-			if ($globalTransaction) $Connection->db->beginTransaction();
1132
+			if ($globalTransaction) {
1133
+				$Connection->db->beginTransaction();
1134
+			}
1008 1135
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1009 1136
 			{
1010 1137
 				if ($i > 0) {
@@ -1019,7 +1146,9 @@  discard block
 block discarded – undo
1019 1146
 				$i++;
1020 1147
 			}
1021 1148
 			fclose($handle);
1022
-			if ($globalTransaction) $Connection->db->commit();
1149
+			if ($globalTransaction) {
1150
+				$Connection->db->commit();
1151
+			}
1023 1152
 		}
1024 1153
 		return '';
1025 1154
         }
@@ -1170,7 +1299,9 @@  discard block
 block discarded – undo
1170 1299
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1171 1300
 		{
1172 1301
 			$i = 0;
1173
-			if ($globalTransaction) $Connection->db->beginTransaction();
1302
+			if ($globalTransaction) {
1303
+				$Connection->db->beginTransaction();
1304
+			}
1174 1305
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1175 1306
 			{
1176 1307
 				$i++;
@@ -1198,7 +1329,9 @@  discard block
 block discarded – undo
1198 1329
 				}
1199 1330
 			}
1200 1331
 			fclose($handle);
1201
-			if ($globalTransaction) $Connection->db->commit();
1332
+			if ($globalTransaction) {
1333
+				$Connection->db->commit();
1334
+			}
1202 1335
 		}
1203 1336
 		return '';
1204 1337
         }
@@ -1221,7 +1354,9 @@  discard block
 block discarded – undo
1221 1354
 		$Connection = new Connection();
1222 1355
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1223 1356
 		{
1224
-			if ($globalTransaction) $Connection->db->beginTransaction();
1357
+			if ($globalTransaction) {
1358
+				$Connection->db->beginTransaction();
1359
+			}
1225 1360
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1226 1361
 			{
1227 1362
 				if(count($row) > 1) {
@@ -1235,7 +1370,9 @@  discard block
 block discarded – undo
1235 1370
 				}
1236 1371
 			}
1237 1372
 			fclose($handle);
1238
-			if ($globalTransaction) $Connection->db->commit();
1373
+			if ($globalTransaction) {
1374
+				$Connection->db->commit();
1375
+			}
1239 1376
 		}
1240 1377
 		return '';
1241 1378
         }
@@ -1255,8 +1392,9 @@  discard block
 block discarded – undo
1255 1392
 	        }
1256 1393
 
1257 1394
 
1258
-		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1259
-		else {
1395
+		if ($globalDBdriver == 'mysql') {
1396
+			update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1397
+		} else {
1260 1398
 			update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql');
1261 1399
 			$query = "CREATE EXTENSION postgis";
1262 1400
 			$Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']);
@@ -1275,20 +1413,30 @@  discard block
 block discarded – undo
1275 1413
 		global $tmp_dir, $globalDebug;
1276 1414
 		include_once('class.create_db.php');
1277 1415
 		require_once(dirname(__FILE__).'/../require/class.NOTAM.php');
1278
-		if ($globalDebug) echo "NOTAM from FlightAirMap website : Download...";
1416
+		if ($globalDebug) {
1417
+			echo "NOTAM from FlightAirMap website : Download...";
1418
+		}
1279 1419
 		update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz');
1280 1420
 		$error = '';
1281 1421
 		if (file_exists($tmp_dir.'notam.txt.gz')) {
1282
-			if ($globalDebug) echo "Gunzip...";
1422
+			if ($globalDebug) {
1423
+				echo "Gunzip...";
1424
+			}
1283 1425
 			update_db::gunzip($tmp_dir.'notam.txt.gz');
1284
-			if ($globalDebug) echo "Add to DB...";
1426
+			if ($globalDebug) {
1427
+				echo "Add to DB...";
1428
+			}
1285 1429
 			//$error = create_db::import_file($tmp_dir.'notam.sql');
1286 1430
 			$NOTAM = new NOTAM();
1287 1431
 			$NOTAM->updateNOTAMfromTextFile($tmp_dir.'notam.txt');
1288
-		} else $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";
1432
+		} else {
1433
+			$error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";
1434
+		}
1289 1435
 		if ($error != '') {
1290 1436
 			return $error;
1291
-		} elseif ($globalDebug) echo "Done\n";
1437
+		} elseif ($globalDebug) {
1438
+			echo "Done\n";
1439
+		}
1292 1440
 		return '';
1293 1441
 	}
1294 1442
 
@@ -1342,67 +1490,111 @@  discard block
 block discarded – undo
1342 1490
 		//if ($globalDebug) echo "IVAO : Download...";
1343 1491
 		//update_db::download('http://fr.mirror.ivao.aero/software/ivae_feb2013.zip',$tmp_dir.'ivae_feb2013.zip');
1344 1492
 		if (file_exists($tmp_dir.'ivae_feb2013.zip')) {
1345
-			if ($globalDebug) echo "Unzip...";
1493
+			if ($globalDebug) {
1494
+				echo "Unzip...";
1495
+			}
1346 1496
 			update_db::unzip($tmp_dir.'ivae_feb2013.zip');
1347
-			if ($globalDebug) echo "Add to DB...";
1497
+			if ($globalDebug) {
1498
+				echo "Add to DB...";
1499
+			}
1348 1500
 			update_db::ivao_airlines($tmp_dir.'data/airlines.dat');
1349
-			if ($globalDebug) echo "Copy airlines logos to airlines images directory...";
1501
+			if ($globalDebug) {
1502
+				echo "Copy airlines logos to airlines images directory...";
1503
+			}
1350 1504
 			if (is_writable(dirname(__FILE__).'/../images/airlines')) {
1351
-				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
1352
-			} else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
1353
-		} else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
1505
+				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) {
1506
+					$error = "Failed to copy airlines logo.";
1507
+				}
1508
+			} else {
1509
+				$error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
1510
+			}
1511
+		} else {
1512
+			$error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
1513
+		}
1354 1514
 		if ($error != '') {
1355 1515
 			return $error;
1356
-		} elseif ($globalDebug) echo "Done\n";
1516
+		} elseif ($globalDebug) {
1517
+			echo "Done\n";
1518
+		}
1357 1519
 		return '';
1358 1520
 	}
1359 1521
 
1360 1522
 	public static function update_routes() {
1361 1523
 		global $tmp_dir, $globalDebug;
1362 1524
 		$error = '';
1363
-		if ($globalDebug) echo "Routes : Download...";
1525
+		if ($globalDebug) {
1526
+			echo "Routes : Download...";
1527
+		}
1364 1528
 		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz');
1365 1529
 		if (file_exists($tmp_dir.'StandingData.sqb.gz')) {
1366
-			if ($globalDebug) echo "Gunzip...";
1530
+			if ($globalDebug) {
1531
+				echo "Gunzip...";
1532
+			}
1367 1533
 			update_db::gunzip($tmp_dir.'StandingData.sqb.gz');
1368
-			if ($globalDebug) echo "Add to DB...";
1534
+			if ($globalDebug) {
1535
+				echo "Add to DB...";
1536
+			}
1369 1537
 			$error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb');
1370
-		} else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
1538
+		} else {
1539
+			$error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
1540
+		}
1371 1541
 		if ($error != '') {
1372 1542
 			return $error;
1373
-		} elseif ($globalDebug) echo "Done\n";
1543
+		} elseif ($globalDebug) {
1544
+			echo "Done\n";
1545
+		}
1374 1546
 		return '';
1375 1547
 	}
1376 1548
 	public static function update_oneworld() {
1377 1549
 		global $tmp_dir, $globalDebug;
1378 1550
 		$error = '';
1379
-		if ($globalDebug) echo "Schedules Oneworld : Download...";
1551
+		if ($globalDebug) {
1552
+			echo "Schedules Oneworld : Download...";
1553
+		}
1380 1554
 		update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz');
1381 1555
 		if (file_exists($tmp_dir.'oneworld.csv.gz')) {
1382
-			if ($globalDebug) echo "Gunzip...";
1556
+			if ($globalDebug) {
1557
+				echo "Gunzip...";
1558
+			}
1383 1559
 			update_db::gunzip($tmp_dir.'oneworld.csv.gz');
1384
-			if ($globalDebug) echo "Add to DB...";
1560
+			if ($globalDebug) {
1561
+				echo "Add to DB...";
1562
+			}
1385 1563
 			$error = update_db::retrieve_route_oneworld($tmp_dir.'oneworld.csv');
1386
-		} else $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
1564
+		} else {
1565
+			$error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
1566
+		}
1387 1567
 		if ($error != '') {
1388 1568
 			return $error;
1389
-		} elseif ($globalDebug) echo "Done\n";
1569
+		} elseif ($globalDebug) {
1570
+			echo "Done\n";
1571
+		}
1390 1572
 		return '';
1391 1573
 	}
1392 1574
 	public static function update_skyteam() {
1393 1575
 		global $tmp_dir, $globalDebug;
1394 1576
 		$error = '';
1395
-		if ($globalDebug) echo "Schedules Skyteam : Download...";
1577
+		if ($globalDebug) {
1578
+			echo "Schedules Skyteam : Download...";
1579
+		}
1396 1580
 		update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz');
1397 1581
 		if (file_exists($tmp_dir.'skyteam.csv.gz')) {
1398
-			if ($globalDebug) echo "Gunzip...";
1582
+			if ($globalDebug) {
1583
+				echo "Gunzip...";
1584
+			}
1399 1585
 			update_db::gunzip($tmp_dir.'skyteam.csv.gz');
1400
-			if ($globalDebug) echo "Add to DB...";
1586
+			if ($globalDebug) {
1587
+				echo "Add to DB...";
1588
+			}
1401 1589
 			$error = update_db::retrieve_route_skyteam($tmp_dir.'skyteam.csv');
1402
-		} else $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
1590
+		} else {
1591
+			$error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
1592
+		}
1403 1593
 		if ($error != '') {
1404 1594
 			return $error;
1405
-		} elseif ($globalDebug) echo "Done\n";
1595
+		} elseif ($globalDebug) {
1596
+			echo "Done\n";
1597
+		}
1406 1598
 		return '';
1407 1599
 	}
1408 1600
 	public static function update_ModeS() {
@@ -1419,291 +1611,509 @@  discard block
 block discarded – undo
1419 1611
 			exit;
1420 1612
 		} elseif ($globalDebug) echo "Done\n";
1421 1613
 */
1422
-		if ($globalDebug) echo "Modes : Download...";
1423
-//		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
1614
+		if ($globalDebug) {
1615
+			echo "Modes : Download...";
1616
+		}
1617
+		//		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
1424 1618
 		update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz');
1425 1619
 
1426 1620
 //		if (file_exists($tmp_dir.'basestation_latest.zip')) {
1427 1621
 		if (file_exists($tmp_dir.'BaseStation.sqb.gz')) {
1428
-			if ($globalDebug) echo "Unzip...";
1429
-//			update_db::unzip($tmp_dir.'basestation_latest.zip');
1622
+			if ($globalDebug) {
1623
+				echo "Unzip...";
1624
+			}
1625
+			//			update_db::unzip($tmp_dir.'basestation_latest.zip');
1430 1626
 			update_db::gunzip($tmp_dir.'BaseStation.sqb.gz');
1431
-			if ($globalDebug) echo "Add to DB...";
1627
+			if ($globalDebug) {
1628
+				echo "Add to DB...";
1629
+			}
1432 1630
 			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb');
1433 1631
 //			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'basestation.sqb');
1434
-		} else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
1632
+		} else {
1633
+			$error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
1634
+		}
1435 1635
 		if ($error != '') {
1436 1636
 			return $error;
1437
-		} elseif ($globalDebug) echo "Done\n";
1637
+		} elseif ($globalDebug) {
1638
+			echo "Done\n";
1639
+		}
1438 1640
 		return '';
1439 1641
 	}
1440 1642
 
1441 1643
 	public static function update_ModeS_flarm() {
1442 1644
 		global $tmp_dir, $globalDebug;
1443
-		if ($globalDebug) echo "Modes Flarmnet: Download...";
1645
+		if ($globalDebug) {
1646
+			echo "Modes Flarmnet: Download...";
1647
+		}
1444 1648
 		update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln');
1445 1649
 		if (file_exists($tmp_dir.'data.fln')) {
1446
-			if ($globalDebug) echo "Add to DB...";
1650
+			if ($globalDebug) {
1651
+				echo "Add to DB...";
1652
+			}
1447 1653
 			$error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln');
1448
-		} else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";
1654
+		} else {
1655
+			$error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";
1656
+		}
1449 1657
 		if ($error != '') {
1450 1658
 			return $error;
1451
-		} elseif ($globalDebug) echo "Done\n";
1659
+		} elseif ($globalDebug) {
1660
+			echo "Done\n";
1661
+		}
1452 1662
 		return '';
1453 1663
 	}
1454 1664
 
1455 1665
 	public static function update_ModeS_ogn() {
1456 1666
 		global $tmp_dir, $globalDebug;
1457
-		if ($globalDebug) echo "Modes OGN: Download...";
1667
+		if ($globalDebug) {
1668
+			echo "Modes OGN: Download...";
1669
+		}
1458 1670
 		update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv');
1459 1671
 		if (file_exists($tmp_dir.'ogn.csv')) {
1460
-			if ($globalDebug) echo "Add to DB...";
1672
+			if ($globalDebug) {
1673
+				echo "Add to DB...";
1674
+			}
1461 1675
 			$error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv');
1462
-		} else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";
1676
+		} else {
1677
+			$error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";
1678
+		}
1463 1679
 		if ($error != '') {
1464 1680
 			return $error;
1465
-		} elseif ($globalDebug) echo "Done\n";
1681
+		} elseif ($globalDebug) {
1682
+			echo "Done\n";
1683
+		}
1466 1684
 		return '';
1467 1685
 	}
1468 1686
 
1469 1687
 	public static function update_owner() {
1470 1688
 		global $tmp_dir, $globalDebug;
1471 1689
 		
1472
-		if ($globalDebug) echo "Owner France: Download...";
1690
+		if ($globalDebug) {
1691
+			echo "Owner France: Download...";
1692
+		}
1473 1693
 		update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv');
1474 1694
 		if (file_exists($tmp_dir.'owner_f.csv')) {
1475
-			if ($globalDebug) echo "Add to DB...";
1695
+			if ($globalDebug) {
1696
+				echo "Add to DB...";
1697
+			}
1476 1698
 			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F');
1477
-		} else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
1699
+		} else {
1700
+			$error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
1701
+		}
1478 1702
 		if ($error != '') {
1479 1703
 			return $error;
1480
-		} elseif ($globalDebug) echo "Done\n";
1704
+		} elseif ($globalDebug) {
1705
+			echo "Done\n";
1706
+		}
1481 1707
 		
1482
-		if ($globalDebug) echo "Owner Ireland: Download...";
1708
+		if ($globalDebug) {
1709
+			echo "Owner Ireland: Download...";
1710
+		}
1483 1711
 		update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv');
1484 1712
 		if (file_exists($tmp_dir.'owner_ei.csv')) {
1485
-			if ($globalDebug) echo "Add to DB...";
1713
+			if ($globalDebug) {
1714
+				echo "Add to DB...";
1715
+			}
1486 1716
 			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI');
1487
-		} else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
1717
+		} else {
1718
+			$error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
1719
+		}
1488 1720
 		if ($error != '') {
1489 1721
 			return $error;
1490
-		} elseif ($globalDebug) echo "Done\n";
1491
-		if ($globalDebug) echo "Owner Switzerland: Download...";
1722
+		} elseif ($globalDebug) {
1723
+			echo "Done\n";
1724
+		}
1725
+		if ($globalDebug) {
1726
+			echo "Owner Switzerland: Download...";
1727
+		}
1492 1728
 		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv');
1493 1729
 		if (file_exists($tmp_dir.'owner_hb.csv')) {
1494
-			if ($globalDebug) echo "Add to DB...";
1730
+			if ($globalDebug) {
1731
+				echo "Add to DB...";
1732
+			}
1495 1733
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB');
1496
-		} else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
1734
+		} else {
1735
+			$error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
1736
+		}
1497 1737
 		if ($error != '') {
1498 1738
 			return $error;
1499
-		} elseif ($globalDebug) echo "Done\n";
1500
-		if ($globalDebug) echo "Owner Czech Republic: Download...";
1739
+		} elseif ($globalDebug) {
1740
+			echo "Done\n";
1741
+		}
1742
+		if ($globalDebug) {
1743
+			echo "Owner Czech Republic: Download...";
1744
+		}
1501 1745
 		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv');
1502 1746
 		if (file_exists($tmp_dir.'owner_ok.csv')) {
1503
-			if ($globalDebug) echo "Add to DB...";
1747
+			if ($globalDebug) {
1748
+				echo "Add to DB...";
1749
+			}
1504 1750
 			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK');
1505
-		} else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
1751
+		} else {
1752
+			$error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
1753
+		}
1506 1754
 		if ($error != '') {
1507 1755
 			return $error;
1508
-		} elseif ($globalDebug) echo "Done\n";
1509
-		if ($globalDebug) echo "Owner Australia: Download...";
1756
+		} elseif ($globalDebug) {
1757
+			echo "Done\n";
1758
+		}
1759
+		if ($globalDebug) {
1760
+			echo "Owner Australia: Download...";
1761
+		}
1510 1762
 		update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv');
1511 1763
 		if (file_exists($tmp_dir.'owner_vh.csv')) {
1512
-			if ($globalDebug) echo "Add to DB...";
1764
+			if ($globalDebug) {
1765
+				echo "Add to DB...";
1766
+			}
1513 1767
 			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH');
1514
-		} else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
1768
+		} else {
1769
+			$error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
1770
+		}
1515 1771
 		if ($error != '') {
1516 1772
 			return $error;
1517
-		} elseif ($globalDebug) echo "Done\n";
1518
-		if ($globalDebug) echo "Owner Austria: Download...";
1773
+		} elseif ($globalDebug) {
1774
+			echo "Done\n";
1775
+		}
1776
+		if ($globalDebug) {
1777
+			echo "Owner Austria: Download...";
1778
+		}
1519 1779
 		update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv');
1520 1780
 		if (file_exists($tmp_dir.'owner_oe.csv')) {
1521
-			if ($globalDebug) echo "Add to DB...";
1781
+			if ($globalDebug) {
1782
+				echo "Add to DB...";
1783
+			}
1522 1784
 			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE');
1523
-		} else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
1785
+		} else {
1786
+			$error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
1787
+		}
1524 1788
 		if ($error != '') {
1525 1789
 			return $error;
1526
-		} elseif ($globalDebug) echo "Done\n";
1527
-		if ($globalDebug) echo "Owner Chile: Download...";
1790
+		} elseif ($globalDebug) {
1791
+			echo "Done\n";
1792
+		}
1793
+		if ($globalDebug) {
1794
+			echo "Owner Chile: Download...";
1795
+		}
1528 1796
 		update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv');
1529 1797
 		if (file_exists($tmp_dir.'owner_cc.csv')) {
1530
-			if ($globalDebug) echo "Add to DB...";
1798
+			if ($globalDebug) {
1799
+				echo "Add to DB...";
1800
+			}
1531 1801
 			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC');
1532
-		} else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
1802
+		} else {
1803
+			$error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
1804
+		}
1533 1805
 		if ($error != '') {
1534 1806
 			return $error;
1535
-		} elseif ($globalDebug) echo "Done\n";
1536
-		if ($globalDebug) echo "Owner Colombia: Download...";
1807
+		} elseif ($globalDebug) {
1808
+			echo "Done\n";
1809
+		}
1810
+		if ($globalDebug) {
1811
+			echo "Owner Colombia: Download...";
1812
+		}
1537 1813
 		update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv');
1538 1814
 		if (file_exists($tmp_dir.'owner_hj.csv')) {
1539
-			if ($globalDebug) echo "Add to DB...";
1815
+			if ($globalDebug) {
1816
+				echo "Add to DB...";
1817
+			}
1540 1818
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ');
1541
-		} else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
1819
+		} else {
1820
+			$error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
1821
+		}
1542 1822
 		if ($error != '') {
1543 1823
 			return $error;
1544
-		} elseif ($globalDebug) echo "Done\n";
1545
-		if ($globalDebug) echo "Owner Bosnia Herzegobina: Download...";
1824
+		} elseif ($globalDebug) {
1825
+			echo "Done\n";
1826
+		}
1827
+		if ($globalDebug) {
1828
+			echo "Owner Bosnia Herzegobina: Download...";
1829
+		}
1546 1830
 		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv');
1547 1831
 		if (file_exists($tmp_dir.'owner_e7.csv')) {
1548
-			if ($globalDebug) echo "Add to DB...";
1832
+			if ($globalDebug) {
1833
+				echo "Add to DB...";
1834
+			}
1549 1835
 			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7');
1550
-		} else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
1836
+		} else {
1837
+			$error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
1838
+		}
1551 1839
 		if ($error != '') {
1552 1840
 			return $error;
1553
-		} elseif ($globalDebug) echo "Done\n";
1554
-		if ($globalDebug) echo "Owner Brazil: Download...";
1841
+		} elseif ($globalDebug) {
1842
+			echo "Done\n";
1843
+		}
1844
+		if ($globalDebug) {
1845
+			echo "Owner Brazil: Download...";
1846
+		}
1555 1847
 		update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv');
1556 1848
 		if (file_exists($tmp_dir.'owner_pp.csv')) {
1557
-			if ($globalDebug) echo "Add to DB...";
1849
+			if ($globalDebug) {
1850
+				echo "Add to DB...";
1851
+			}
1558 1852
 			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP');
1559
-		} else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
1853
+		} else {
1854
+			$error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
1855
+		}
1560 1856
 		if ($error != '') {
1561 1857
 			return $error;
1562
-		} elseif ($globalDebug) echo "Done\n";
1563
-		if ($globalDebug) echo "Owner Cayman Islands: Download...";
1858
+		} elseif ($globalDebug) {
1859
+			echo "Done\n";
1860
+		}
1861
+		if ($globalDebug) {
1862
+			echo "Owner Cayman Islands: Download...";
1863
+		}
1564 1864
 		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv');
1565 1865
 		if (file_exists($tmp_dir.'owner_vp.csv')) {
1566
-			if ($globalDebug) echo "Add to DB...";
1866
+			if ($globalDebug) {
1867
+				echo "Add to DB...";
1868
+			}
1567 1869
 			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP');
1568
-		} else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
1870
+		} else {
1871
+			$error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
1872
+		}
1569 1873
 		if ($error != '') {
1570 1874
 			return $error;
1571
-		} elseif ($globalDebug) echo "Done\n";
1572
-		if ($globalDebug) echo "Owner Croatia: Download...";
1875
+		} elseif ($globalDebug) {
1876
+			echo "Done\n";
1877
+		}
1878
+		if ($globalDebug) {
1879
+			echo "Owner Croatia: Download...";
1880
+		}
1573 1881
 		update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv');
1574 1882
 		if (file_exists($tmp_dir.'owner_9a.csv')) {
1575
-			if ($globalDebug) echo "Add to DB...";
1883
+			if ($globalDebug) {
1884
+				echo "Add to DB...";
1885
+			}
1576 1886
 			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A');
1577
-		} else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
1887
+		} else {
1888
+			$error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
1889
+		}
1578 1890
 		if ($error != '') {
1579 1891
 			return $error;
1580
-		} elseif ($globalDebug) echo "Done\n";
1581
-		if ($globalDebug) echo "Owner Luxembourg: Download...";
1892
+		} elseif ($globalDebug) {
1893
+			echo "Done\n";
1894
+		}
1895
+		if ($globalDebug) {
1896
+			echo "Owner Luxembourg: Download...";
1897
+		}
1582 1898
 		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv');
1583 1899
 		if (file_exists($tmp_dir.'owner_lx.csv')) {
1584
-			if ($globalDebug) echo "Add to DB...";
1900
+			if ($globalDebug) {
1901
+				echo "Add to DB...";
1902
+			}
1585 1903
 			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX');
1586
-		} else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
1904
+		} else {
1905
+			$error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
1906
+		}
1587 1907
 		if ($error != '') {
1588 1908
 			return $error;
1589
-		} elseif ($globalDebug) echo "Done\n";
1590
-		if ($globalDebug) echo "Owner Maldives: Download...";
1909
+		} elseif ($globalDebug) {
1910
+			echo "Done\n";
1911
+		}
1912
+		if ($globalDebug) {
1913
+			echo "Owner Maldives: Download...";
1914
+		}
1591 1915
 		update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv');
1592 1916
 		if (file_exists($tmp_dir.'owner_8q.csv')) {
1593
-			if ($globalDebug) echo "Add to DB...";
1917
+			if ($globalDebug) {
1918
+				echo "Add to DB...";
1919
+			}
1594 1920
 			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q');
1595
-		} else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
1921
+		} else {
1922
+			$error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
1923
+		}
1596 1924
 		if ($error != '') {
1597 1925
 			return $error;
1598
-		} elseif ($globalDebug) echo "Done\n";
1599
-		if ($globalDebug) echo "Owner New Zealand: Download...";
1926
+		} elseif ($globalDebug) {
1927
+			echo "Done\n";
1928
+		}
1929
+		if ($globalDebug) {
1930
+			echo "Owner New Zealand: Download...";
1931
+		}
1600 1932
 		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv');
1601 1933
 		if (file_exists($tmp_dir.'owner_zk.csv')) {
1602
-			if ($globalDebug) echo "Add to DB...";
1934
+			if ($globalDebug) {
1935
+				echo "Add to DB...";
1936
+			}
1603 1937
 			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK');
1604
-		} else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
1938
+		} else {
1939
+			$error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
1940
+		}
1605 1941
 		if ($error != '') {
1606 1942
 			return $error;
1607
-		} elseif ($globalDebug) echo "Done\n";
1608
-		if ($globalDebug) echo "Owner Papua New Guinea: Download...";
1943
+		} elseif ($globalDebug) {
1944
+			echo "Done\n";
1945
+		}
1946
+		if ($globalDebug) {
1947
+			echo "Owner Papua New Guinea: Download...";
1948
+		}
1609 1949
 		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv');
1610 1950
 		if (file_exists($tmp_dir.'owner_p2.csv')) {
1611
-			if ($globalDebug) echo "Add to DB...";
1951
+			if ($globalDebug) {
1952
+				echo "Add to DB...";
1953
+			}
1612 1954
 			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2');
1613
-		} else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
1955
+		} else {
1956
+			$error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
1957
+		}
1614 1958
 		if ($error != '') {
1615 1959
 			return $error;
1616
-		} elseif ($globalDebug) echo "Done\n";
1617
-		if ($globalDebug) echo "Owner Slovakia: Download...";
1960
+		} elseif ($globalDebug) {
1961
+			echo "Done\n";
1962
+		}
1963
+		if ($globalDebug) {
1964
+			echo "Owner Slovakia: Download...";
1965
+		}
1618 1966
 		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv');
1619 1967
 		if (file_exists($tmp_dir.'owner_om.csv')) {
1620
-			if ($globalDebug) echo "Add to DB...";
1968
+			if ($globalDebug) {
1969
+				echo "Add to DB...";
1970
+			}
1621 1971
 			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM');
1622
-		} else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
1972
+		} else {
1973
+			$error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
1974
+		}
1623 1975
 		if ($error != '') {
1624 1976
 			return $error;
1625
-		} elseif ($globalDebug) echo "Done\n";
1626
-		if ($globalDebug) echo "Owner Ecuador: Download...";
1977
+		} elseif ($globalDebug) {
1978
+			echo "Done\n";
1979
+		}
1980
+		if ($globalDebug) {
1981
+			echo "Owner Ecuador: Download...";
1982
+		}
1627 1983
 		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv');
1628 1984
 		if (file_exists($tmp_dir.'owner_hc.csv')) {
1629
-			if ($globalDebug) echo "Add to DB...";
1985
+			if ($globalDebug) {
1986
+				echo "Add to DB...";
1987
+			}
1630 1988
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC');
1631
-		} else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
1989
+		} else {
1990
+			$error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
1991
+		}
1632 1992
 		if ($error != '') {
1633 1993
 			return $error;
1634
-		} elseif ($globalDebug) echo "Done\n";
1635
-		if ($globalDebug) echo "Owner Iceland: Download...";
1994
+		} elseif ($globalDebug) {
1995
+			echo "Done\n";
1996
+		}
1997
+		if ($globalDebug) {
1998
+			echo "Owner Iceland: Download...";
1999
+		}
1636 2000
 		update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv');
1637 2001
 		if (file_exists($tmp_dir.'owner_tf.csv')) {
1638
-			if ($globalDebug) echo "Add to DB...";
2002
+			if ($globalDebug) {
2003
+				echo "Add to DB...";
2004
+			}
1639 2005
 			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF');
1640
-		} else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2006
+		} else {
2007
+			$error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2008
+		}
1641 2009
 		if ($error != '') {
1642 2010
 			return $error;
1643
-		} elseif ($globalDebug) echo "Done\n";
2011
+		} elseif ($globalDebug) {
2012
+			echo "Done\n";
2013
+		}
1644 2014
 		return '';
1645 2015
 	}
1646 2016
 
1647 2017
 	public static function update_translation() {
1648 2018
 		global $tmp_dir, $globalDebug;
1649 2019
 		$error = '';
1650
-		if ($globalDebug) echo "Translation : Download...";
2020
+		if ($globalDebug) {
2021
+			echo "Translation : Download...";
2022
+		}
1651 2023
 		update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip');
1652 2024
 		if (file_exists($tmp_dir.'translation.zip')) {
1653
-			if ($globalDebug) echo "Unzip...";
2025
+			if ($globalDebug) {
2026
+				echo "Unzip...";
2027
+			}
1654 2028
 			update_db::unzip($tmp_dir.'translation.zip');
1655
-			if ($globalDebug) echo "Add to DB...";
2029
+			if ($globalDebug) {
2030
+				echo "Add to DB...";
2031
+			}
1656 2032
 			$error = update_db::translation();
1657
-		} else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
2033
+		} else {
2034
+			$error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
2035
+		}
1658 2036
 		if ($error != '') {
1659 2037
 			return $error;
1660
-		} elseif ($globalDebug) echo "Done\n";
2038
+		} elseif ($globalDebug) {
2039
+			echo "Done\n";
2040
+		}
1661 2041
 		return '';
1662 2042
 	}
1663 2043
 
1664 2044
 	public static function update_translation_fam() {
1665 2045
 		global $tmp_dir, $globalDebug;
1666
-		if ($globalDebug) echo "Translation from FlightAirMap website : Download...";
2046
+		if ($globalDebug) {
2047
+			echo "Translation from FlightAirMap website : Download...";
2048
+		}
1667 2049
 		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz');
1668 2050
 		if (file_exists($tmp_dir.'translation.tsv.gz')) {
1669
-			if ($globalDebug) echo "Gunzip...";
2051
+			if ($globalDebug) {
2052
+				echo "Gunzip...";
2053
+			}
1670 2054
 			update_db::gunzip($tmp_dir.'translation.tsv.gz');
1671
-			if ($globalDebug) echo "Add to DB...";
2055
+			if ($globalDebug) {
2056
+				echo "Add to DB...";
2057
+			}
1672 2058
 			$error = update_db::translation_fam();
1673
-		} else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
2059
+		} else {
2060
+			$error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
2061
+		}
1674 2062
 		if ($error != '') {
1675 2063
 			return $error;
1676
-		} elseif ($globalDebug) echo "Done\n";
2064
+		} elseif ($globalDebug) {
2065
+			echo "Done\n";
2066
+		}
1677 2067
 		return '';
1678 2068
 	}
1679 2069
 	public static function update_ModeS_fam() {
1680 2070
 		global $tmp_dir, $globalDebug;
1681
-		if ($globalDebug) echo "ModeS from FlightAirMap website : Download...";
2071
+		if ($globalDebug) {
2072
+			echo "ModeS from FlightAirMap website : Download...";
2073
+		}
1682 2074
 		update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz');
1683 2075
 		if (file_exists($tmp_dir.'modes.tsv.gz')) {
1684
-			if ($globalDebug) echo "Gunzip...";
2076
+			if ($globalDebug) {
2077
+				echo "Gunzip...";
2078
+			}
1685 2079
 			update_db::gunzip($tmp_dir.'modes.tsv.gz');
1686
-			if ($globalDebug) echo "Add to DB...";
2080
+			if ($globalDebug) {
2081
+				echo "Add to DB...";
2082
+			}
1687 2083
 			$error = update_db::modes_fam();
1688
-		} else $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed.";
2084
+		} else {
2085
+			$error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed.";
2086
+		}
1689 2087
 		if ($error != '') {
1690 2088
 			return $error;
1691
-		} elseif ($globalDebug) echo "Done\n";
2089
+		} elseif ($globalDebug) {
2090
+			echo "Done\n";
2091
+		}
1692 2092
 		return '';
1693 2093
 	}
1694 2094
 	public static function update_routes_fam() {
1695 2095
 		global $tmp_dir, $globalDebug;
1696
-		if ($globalDebug) echo "Routes from FlightAirMap website : Download...";
2096
+		if ($globalDebug) {
2097
+			echo "Routes from FlightAirMap website : Download...";
2098
+		}
1697 2099
 		update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz');
1698 2100
 		if (file_exists($tmp_dir.'routes.tsv.gz')) {
1699
-			if ($globalDebug) echo "Gunzip...";
2101
+			if ($globalDebug) {
2102
+				echo "Gunzip...";
2103
+			}
1700 2104
 			update_db::gunzip($tmp_dir.'routes.tsv.gz');
1701
-			if ($globalDebug) echo "Add to DB...";
2105
+			if ($globalDebug) {
2106
+				echo "Add to DB...";
2107
+			}
1702 2108
 			$error = update_db::routes_fam();
1703
-		} else $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed.";
2109
+		} else {
2110
+			$error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed.";
2111
+		}
1704 2112
 		if ($error != '') {
1705 2113
 			return $error;
1706
-		} elseif ($globalDebug) echo "Done\n";
2114
+		} elseif ($globalDebug) {
2115
+			echo "Done\n";
2116
+		}
1707 2117
 		return '';
1708 2118
 	}
1709 2119
 
@@ -1711,7 +2121,9 @@  discard block
 block discarded – undo
1711 2121
 		global $tmp_dir, $globalDebug, $globalDBdriver;
1712 2122
 		include_once('class.create_db.php');
1713 2123
 		$error = '';
1714
-		if ($globalDebug) echo "Airspace from FlightAirMap website : Download...";
2124
+		if ($globalDebug) {
2125
+			echo "Airspace from FlightAirMap website : Download...";
2126
+		}
1715 2127
 		if ($globalDBdriver == 'mysql') {
1716 2128
 			update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
1717 2129
 		} else {
@@ -1727,9 +2139,13 @@  discard block
 block discarded – undo
1727 2139
 					update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz');
1728 2140
 				}
1729 2141
 				if (file_exists($tmp_dir.'airspace.sql.gz')) {
1730
-					if ($globalDebug) echo "Gunzip...";
2142
+					if ($globalDebug) {
2143
+						echo "Gunzip...";
2144
+					}
1731 2145
 					update_db::gunzip($tmp_dir.'airspace.sql.gz');
1732
-					if ($globalDebug) echo "Add to DB...";
2146
+					if ($globalDebug) {
2147
+						echo "Add to DB...";
2148
+					}
1733 2149
 					$Connection = new Connection();
1734 2150
 					if ($Connection->tableExists('airspace')) {
1735 2151
 						$query = 'DROP TABLE airspace';
@@ -1742,31 +2158,47 @@  discard block
 block discarded – undo
1742 2158
 		    			}
1743 2159
 					$error = create_db::import_file($tmp_dir.'airspace.sql');
1744 2160
 					update_db::insert_airspace_version($airspace_md5);
1745
-				} else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed.";
2161
+				} else {
2162
+					$error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed.";
2163
+				}
1746 2164
 			}
1747
-		} else $error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed.";
2165
+		} else {
2166
+			$error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed.";
2167
+		}
1748 2168
 		if ($error != '') {
1749 2169
 			return $error;
1750
-		} elseif ($globalDebug) echo "Done\n";
2170
+		} elseif ($globalDebug) {
2171
+			echo "Done\n";
2172
+		}
1751 2173
 		return '';
1752 2174
 	}
1753 2175
 
1754 2176
 	public static function update_tle() {
1755 2177
 		global $tmp_dir, $globalDebug;
1756
-		if ($globalDebug) echo "Download TLE : Download...";
2178
+		if ($globalDebug) {
2179
+			echo "Download TLE : Download...";
2180
+		}
1757 2181
 		$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',
1758 2182
 		'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',
1759 2183
 		'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt');
1760 2184
 		foreach ($alltle as $filename) {
1761
-			if ($globalDebug) echo "downloading ".$filename.'...';
2185
+			if ($globalDebug) {
2186
+				echo "downloading ".$filename.'...';
2187
+			}
1762 2188
 			update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename);
1763 2189
 			if (file_exists($tmp_dir.$filename)) {
1764
-				if ($globalDebug) echo "Add to DB ".$filename."...";
2190
+				if ($globalDebug) {
2191
+					echo "Add to DB ".$filename."...";
2192
+				}
1765 2193
 				$error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename));
1766
-			} else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
2194
+			} else {
2195
+				$error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
2196
+			}
1767 2197
 			if ($error != '') {
1768 2198
 				echo $error."\n";
1769
-			} elseif ($globalDebug) echo "Done\n";
2199
+			} elseif ($globalDebug) {
2200
+				echo "Done\n";
2201
+			}
1770 2202
 		}
1771 2203
 		return '';
1772 2204
 	}
@@ -1774,10 +2206,14 @@  discard block
 block discarded – undo
1774 2206
 	public static function update_models() {
1775 2207
 		global $tmp_dir, $globalDebug;
1776 2208
 		$error = '';
1777
-		if ($globalDebug) echo "Models from FlightAirMap website : Download...";
2209
+		if ($globalDebug) {
2210
+			echo "Models from FlightAirMap website : Download...";
2211
+		}
1778 2212
 		update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum');
1779 2213
 		if (file_exists($tmp_dir.'models.md5sum')) {
1780
-			if ($globalDebug) echo "Check files...\n";
2214
+			if ($globalDebug) {
2215
+				echo "Check files...\n";
2216
+			}
1781 2217
 			$newmodelsdb = array();
1782 2218
 			if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) {
1783 2219
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -1796,25 +2232,35 @@  discard block
 block discarded – undo
1796 2232
 			}
1797 2233
 			$diff = array_diff($newmodelsdb,$modelsdb);
1798 2234
 			foreach ($diff as $key => $value) {
1799
-				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
2235
+				if ($globalDebug) {
2236
+					echo 'Downloading model '.$key.' ...'."\n";
2237
+				}
1800 2238
 				update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key);
1801 2239
 				
1802 2240
 			}
1803 2241
 			update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum');
1804
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2242
+		} else {
2243
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2244
+		}
1805 2245
 		if ($error != '') {
1806 2246
 			return $error;
1807
-		} elseif ($globalDebug) echo "Done\n";
2247
+		} elseif ($globalDebug) {
2248
+			echo "Done\n";
2249
+		}
1808 2250
 		return '';
1809 2251
 	}
1810 2252
 
1811 2253
 	public static function update_space_models() {
1812 2254
 		global $tmp_dir, $globalDebug;
1813 2255
 		$error = '';
1814
-		if ($globalDebug) echo "Space models from FlightAirMap website : Download...";
2256
+		if ($globalDebug) {
2257
+			echo "Space models from FlightAirMap website : Download...";
2258
+		}
1815 2259
 		update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum');
1816 2260
 		if (file_exists($tmp_dir.'space_models.md5sum')) {
1817
-			if ($globalDebug) echo "Check files...\n";
2261
+			if ($globalDebug) {
2262
+				echo "Check files...\n";
2263
+			}
1818 2264
 			$newmodelsdb = array();
1819 2265
 			if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) {
1820 2266
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -1833,15 +2279,21 @@  discard block
 block discarded – undo
1833 2279
 			}
1834 2280
 			$diff = array_diff($newmodelsdb,$modelsdb);
1835 2281
 			foreach ($diff as $key => $value) {
1836
-				if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n";
2282
+				if ($globalDebug) {
2283
+					echo 'Downloading space model '.$key.' ...'."\n";
2284
+				}
1837 2285
 				update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key);
1838 2286
 				
1839 2287
 			}
1840 2288
 			update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum');
1841
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2289
+		} else {
2290
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2291
+		}
1842 2292
 		if ($error != '') {
1843 2293
 			return $error;
1844
-		} elseif ($globalDebug) echo "Done\n";
2294
+		} elseif ($globalDebug) {
2295
+			echo "Done\n";
2296
+		}
1845 2297
 		return '';
1846 2298
 	}
1847 2299
 
@@ -1884,7 +2336,9 @@  discard block
 block discarded – undo
1884 2336
                 }
1885 2337
 
1886 2338
 		$error = '';
1887
-		if ($globalDebug) echo "Notam : Download...";
2339
+		if ($globalDebug) {
2340
+			echo "Notam : Download...";
2341
+		}
1888 2342
 		update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss');
1889 2343
 		if (file_exists($tmp_dir.'notam.rss')) {
1890 2344
 			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true);
@@ -1899,14 +2353,30 @@  discard block
 block discarded – undo
1899 2353
 				$data['fir'] = $q[0];
1900 2354
 				$data['code'] = $q[1];
1901 2355
 				$ifrvfr = $q[2];
1902
-				if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR';
1903
-				if ($ifrvfr == 'I') $data['rules'] = 'IFR';
1904
-				if ($ifrvfr == 'V') $data['rules'] = 'VFR';
1905
-				if ($q[4] == 'A') $data['scope'] = 'Airport warning';
1906
-				if ($q[4] == 'E') $data['scope'] = 'Enroute warning';
1907
-				if ($q[4] == 'W') $data['scope'] = 'Navigation warning';
1908
-				if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning';
1909
-				if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning';
2356
+				if ($ifrvfr == 'IV') {
2357
+					$data['rules'] = 'IFR/VFR';
2358
+				}
2359
+				if ($ifrvfr == 'I') {
2360
+					$data['rules'] = 'IFR';
2361
+				}
2362
+				if ($ifrvfr == 'V') {
2363
+					$data['rules'] = 'VFR';
2364
+				}
2365
+				if ($q[4] == 'A') {
2366
+					$data['scope'] = 'Airport warning';
2367
+				}
2368
+				if ($q[4] == 'E') {
2369
+					$data['scope'] = 'Enroute warning';
2370
+				}
2371
+				if ($q[4] == 'W') {
2372
+					$data['scope'] = 'Navigation warning';
2373
+				}
2374
+				if ($q[4] == 'AE') {
2375
+					$data['scope'] = 'Airport/Enroute warning';
2376
+				}
2377
+				if ($q[4] == 'AW') {
2378
+					$data['scope'] = 'Airport/Navigation warning';
2379
+				}
1910 2380
 				//$data['scope'] = $q[4];
1911 2381
 				$data['lower_limit'] = $q[5];
1912 2382
 				$data['upper_limit'] = $q[6];
@@ -1914,8 +2384,12 @@  discard block
 block discarded – undo
1914 2384
 				sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius);
1915 2385
 				$latitude = $Common->convertDec($las,'latitude');
1916 2386
 				$longitude = $Common->convertDec($lns,'longitude');
1917
-				if ($lac == 'S') $latitude = '-'.$latitude;
1918
-				if ($lnc == 'W') $longitude = '-'.$longitude;
2387
+				if ($lac == 'S') {
2388
+					$latitude = '-'.$latitude;
2389
+				}
2390
+				if ($lnc == 'W') {
2391
+					$longitude = '-'.$longitude;
2392
+				}
1919 2393
 				$data['center_latitude'] = $latitude;
1920 2394
 				$data['center_longitude'] = $longitude;
1921 2395
 				$data['radius'] = intval($radius);
@@ -1945,10 +2419,14 @@  discard block
 block discarded – undo
1945 2419
 				$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']);
1946 2420
 				unset($data);
1947 2421
 			} 
1948
-		} else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
2422
+		} else {
2423
+			$error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
2424
+		}
1949 2425
 		if ($error != '') {
1950 2426
 			return $error;
1951
-		} elseif ($globalDebug) echo "Done\n";
2427
+		} elseif ($globalDebug) {
2428
+			echo "Done\n";
2429
+		}
1952 2430
 		return '';
1953 2431
 	}
1954 2432
 	
@@ -1973,7 +2451,9 @@  discard block
 block discarded – undo
1973 2451
 		$airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json');
1974 2452
 		$airspace_json = json_decode($airspace_lst,true);
1975 2453
 		foreach ($airspace_json['records'] as $airspace) {
1976
-			if ($globalDebug) echo $airspace['name']."...\n";
2454
+			if ($globalDebug) {
2455
+				echo $airspace['name']."...\n";
2456
+			}
1977 2457
 			update_db::download($airspace['uri'],$tmp_dir.$airspace['name']);
1978 2458
 			if (file_exists($tmp_dir.$airspace['name'])) {
1979 2459
 				file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name'])));
@@ -2002,8 +2482,11 @@  discard block
 block discarded – undo
2002 2482
                         return "error : ".$e->getMessage();
2003 2483
                 }
2004 2484
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2005
-                if ($row['nb'] > 0) return false;
2006
-                else return true;
2485
+                if ($row['nb'] > 0) {
2486
+                	return false;
2487
+                } else {
2488
+                	return true;
2489
+                }
2007 2490
 	}
2008 2491
 
2009 2492
 	public static function insert_last_update() {
@@ -2028,8 +2511,11 @@  discard block
 block discarded – undo
2028 2511
                         return "error : ".$e->getMessage();
2029 2512
                 }
2030 2513
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2031
-                if ($row['nb'] > 0) return true;
2032
-                else return false;
2514
+                if ($row['nb'] > 0) {
2515
+                	return true;
2516
+                } else {
2517
+                	return false;
2518
+                }
2033 2519
 	}
2034 2520
 
2035 2521
 
@@ -2060,8 +2546,11 @@  discard block
 block discarded – undo
2060 2546
                         return "error : ".$e->getMessage();
2061 2547
                 }
2062 2548
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2063
-                if ($row['nb'] > 0) return false;
2064
-                else return true;
2549
+                if ($row['nb'] > 0) {
2550
+                	return false;
2551
+                } else {
2552
+                	return true;
2553
+                }
2065 2554
 	}
2066 2555
 
2067 2556
 	public static function insert_last_notam_update() {
@@ -2090,8 +2579,11 @@  discard block
 block discarded – undo
2090 2579
                         return "error : ".$e->getMessage();
2091 2580
                 }
2092 2581
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2093
-                if ($row['nb'] > 0) return false;
2094
-                else return true;
2582
+                if ($row['nb'] > 0) {
2583
+                	return false;
2584
+                } else {
2585
+                	return true;
2586
+                }
2095 2587
 	}
2096 2588
 
2097 2589
 	public static function insert_last_airspace_update() {
@@ -2121,8 +2613,11 @@  discard block
 block discarded – undo
2121 2613
                         return "error : ".$e->getMessage();
2122 2614
                 }
2123 2615
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2124
-                if ($row['nb'] > 0) return false;
2125
-                else return true;
2616
+                if ($row['nb'] > 0) {
2617
+                	return false;
2618
+                } else {
2619
+                	return true;
2620
+                }
2126 2621
 	}
2127 2622
 
2128 2623
 	public static function insert_last_owner_update() {
@@ -2151,8 +2646,11 @@  discard block
 block discarded – undo
2151 2646
                         return "error : ".$e->getMessage();
2152 2647
                 }
2153 2648
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2154
-                if ($row['nb'] > 0) return false;
2155
-                else return true;
2649
+                if ($row['nb'] > 0) {
2650
+                	return false;
2651
+                } else {
2652
+                	return true;
2653
+                }
2156 2654
 	}
2157 2655
 
2158 2656
 	public static function insert_last_schedules_update() {
@@ -2181,8 +2679,11 @@  discard block
 block discarded – undo
2181 2679
                         return "error : ".$e->getMessage();
2182 2680
                 }
2183 2681
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2184
-                if ($row['nb'] > 0) return false;
2185
-                else return true;
2682
+                if ($row['nb'] > 0) {
2683
+                	return false;
2684
+                } else {
2685
+                	return true;
2686
+                }
2186 2687
 	}
2187 2688
 
2188 2689
 	public static function insert_last_tle_update() {
Please login to merge, or discard this patch.
scripts/update_db.php 1 patch
Braces   +20 added lines, -8 removed lines patch added patch discarded remove patch
@@ -9,7 +9,9 @@  discard block
 block discarded – undo
9 9
 if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') {
10 10
 	exec("ps ux", $output, $result);
11 11
 	$j = 0;
12
-	foreach ($output as $line) if(strpos($line, "update_db.php") && !strpos($line, "sh ")) $j++;
12
+	foreach ($output as $line) {
13
+		if(strpos($line, "update_db.php") && !strpos($line, "sh ")) $j++;
14
+	}
13 15
 	if ($j > 1) {
14 16
 		echo "Script is already runnning...";
15 17
 		die();
@@ -29,15 +31,19 @@  discard block
 block discarded – undo
29 31
 			$update_db->update_notam();
30 32
 		}
31 33
 		$update_db->insert_last_notam_update();
32
-	} elseif (isset($globalDebug) && $globalDebug && isset($globalNOTAM) && $globalNOTAM) echo "NOTAM are only updated once a day.\n";
34
+	} elseif (isset($globalDebug) && $globalDebug && isset($globalNOTAM) && $globalNOTAM) {
35
+		echo "NOTAM are only updated once a day.\n";
36
+	}
33 37
 	if ($update_db->check_last_update() && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
34 38
 		$update_db->update_all();
35 39
 	//	require_once(dirname(__FILE__).'/../require/class.Spotter.php');
36 40
 	//	$Spotter = new Spotter();
37 41
 	//	$Spotter->updateFieldsFromOtherTables();
38 42
 		$update_db->insert_last_update();
39
-	} elseif (isset($globalDebug) && $globalDebug && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM)) echo "DB are populated with external data only every 15 days ! Files are not updated more often.\n";
40
-}
43
+	} elseif (isset($globalDebug) && $globalDebug && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM)) {
44
+		echo "DB are populated with external data only every 15 days ! Files are not updated more often.\n";
45
+	}
46
+	}
41 47
 if (isset($globalWaypoints) && $globalWaypoints && $update_db->check_last_airspace_update()) {
42 48
 	echo "Check if new airspace version exist...";
43 49
 	echo $update_db->update_airspace_fam();
@@ -52,22 +58,28 @@  discard block
 block discarded – undo
52 58
 	if ($METAR->check_last_update()) {
53 59
 		$METAR->addMETARCycle();
54 60
 		$METAR->insert_last_update();
55
-	} else echo "METAR are only updated every 30 minutes.\n";
56
-}
61
+	} else {
62
+		echo "METAR are only updated every 30 minutes.\n";
63
+	}
64
+	}
57 65
 
58 66
 
59 67
 if (isset($globalOwner) && $globalOwner && $update_db->check_last_owner_update() && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
60 68
 	echo "Updating private aircraft's owners...\n";
61 69
 	$update_db->update_owner();
62 70
 	$update_db->insert_last_owner_update();
63
-} elseif (isset($globalDebug) && $globalDebug && isset($globalOwner) && $globalOwner && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) echo "Owner are only updated every 15 days.\n";
71
+} elseif (isset($globalDebug) && $globalDebug && isset($globalOwner) && $globalOwner && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
72
+	echo "Owner are only updated every 15 days.\n";
73
+}
64 74
 
65 75
 if (isset($globalSchedules) && $globalSchedules && $update_db->check_last_schedules_update() && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
66 76
 	echo "Updating schedules...";
67 77
 	//$update_db->update_oneworld();
68 78
 	$update_db->update_skyteam();
69 79
 	$update_db->insert_last_schedules_update();
70
-} elseif (isset($globalDebug) && $globalDebug && isset($globalOwner) && $globalOwner && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) echo "Schedules are only updated every 15 days.\n";
80
+} elseif (isset($globalDebug) && $globalDebug && isset($globalOwner) && $globalOwner && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
81
+	echo "Schedules are only updated every 15 days.\n";
82
+}
71 83
 
72 84
 if (isset($globalArchiveMonths) && $globalArchiveMonths > 0) {
73 85
 	echo "Updating statistics and archive old data...";
Please login to merge, or discard this patch.
live-santa-czml.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -28,7 +28,9 @@  discard block
 block discarded – undo
28 28
 
29 29
 //	$output .= ',"clock": {"interval" : "'.date("c",time()-$globalLiveInterval).'/'.date("c").'","currentTime" : "'.date("c",time() - $globalLiveInterval).'","multiplier" : 1,"range" : "UNBOUNDED","step": "SYSTEM_CLOCK_MULTIPLIER"}';
30 30
 $output .= ',"clock": {"currentTime" : "'.date("c",time() - $globalLiveInterval).'","multiplier" : 1,"range" : "UNBOUNDED","step": "SYSTEM_CLOCK_MULTIPLIER"';
31
-if (!isset($_GET['now'])) $output .= ',"interval": "'.date("Y").'-12-24T02:00:00Z/'.date("Y").'-12-25T02:00:00Z"';
31
+if (!isset($_GET['now'])) {
32
+	$output .= ',"interval": "'.date("Y").'-12-24T02:00:00Z/'.date("Y").'-12-25T02:00:00Z"';
33
+}
32 34
 $output .= '}';
33 35
 //$output .= ',"clock": {"currentTime" : "'.date("c",time()).'","multiplier" : 300,"range" : "UNBOUNDED","step": "TICK_DEPENDENT"}';
34 36
 //$output .= ',"clock": {"currentTime" : "%minitime%","multiplier" : 1,"range" : "UNBOUNDED","step": "SYSTEM_CLOCK_MULTIPLIER"}';
@@ -37,7 +39,9 @@  discard block
 block discarded – undo
37 39
 $output .= '},';
38 40
 $output .= '{';
39 41
 $output .= '"id": "santaclaus",';
40
-if (!isset($_GET['now'])) $output .= '"interval": "'.date("Y").'-12-24T02:00:00Z/'.date("Y").'-12-25T02:00:00Z",';
42
+if (!isset($_GET['now'])) {
43
+	$output .= '"interval": "'.date("Y").'-12-24T02:00:00Z/'.date("Y").'-12-25T02:00:00Z",';
44
+}
41 45
 $output .= '"properties": {';
42 46
 // Not yet supported in CZML with Cesium
43 47
 $output .= '},';
Please login to merge, or discard this patch.
js/map.js.php 1 patch
Braces   +128 added lines, -33 removed lines patch added patch discarded remove patch
@@ -6,8 +6,11 @@  discard block
 block discarded – undo
6 6
 //$_COOKIE['MapFormat'] = '2d';
7 7
 
8 8
 // Compressed GeoJson is used if true
9
-if (!isset($globalJsonCompress)) $compress = true;
10
-else $compress = $globalJsonCompress;
9
+if (!isset($globalJsonCompress)) {
10
+	$compress = true;
11
+} else {
12
+	$compress = $globalJsonCompress;
13
+}
11 14
 ?>
12 15
 <?php
13 16
 	if (isset($_GET['archive'])) {
@@ -19,8 +22,11 @@  discard block
 block discarded – undo
19 22
 		//$lastupd = round(($_GET['enddate']-$_GET['begindate'])/(($_GET['during']*60)/10));
20 23
 		//$lastupd = 20;
21 24
 		$lastupd = $_GET['archivespeed']*$archiveupdatetime;
22
-		if (isset($_GET['enddate']) && $_GET['enddate'] != '') $enddate = $_GET['enddate'];
23
-		else $enddate = time();
25
+		if (isset($_GET['enddate']) && $_GET['enddate'] != '') {
26
+			$enddate = $_GET['enddate'];
27
+		} else {
28
+			$enddate = time();
29
+		}
24 30
 		setcookie("archive_begin",$begindate);
25 31
 		setcookie("archive_end",$enddate);
26 32
 		setcookie("archive_update",$lastupd);
@@ -127,7 +133,17 @@  discard block
 block discarded – undo
127 133
 	}
128 134
 
129 135
 	//create the map
130
-	map = L.map('archive-map', { zoomControl:false }).setView([<?php if (isset($latitude)) print $latitude; else print $globalCenterLatitude; ?>,<?php if (isset($longitude)) print $longitude; else print $globalCenterLongitude; ?>], zoom);
136
+	map = L.map('archive-map', { zoomControl:false }).setView([<?php if (isset($latitude)) {
137
+	print $latitude;
138
+} else {
139
+	print $globalCenterLatitude;
140
+}
141
+?>,<?php if (isset($longitude)) {
142
+	print $longitude;
143
+} else {
144
+	print $globalCenterLongitude;
145
+}
146
+?>], zoom);
131 147
 <?php
132 148
 	} else {
133 149
 ?>
@@ -140,9 +156,19 @@  discard block
 block discarded – undo
140 156
 	     || navigator.userAgent.match(/BlackBerry/i)
141 157
 	     || navigator.userAgent.match(/Windows Phone/i))
142 158
 	{
143
-		var zoom = <?php if (isset($globalLiveZoom)) print $globalLiveZoom-1; else print '8'; ?>;
159
+		var zoom = <?php if (isset($globalLiveZoom)) {
160
+	print $globalLiveZoom-1;
161
+} else {
162
+	print '8';
163
+}
164
+?>;
144 165
 	} else {
145
-		var zoom = <?php if (isset($globalLiveZoom)) print $globalLiveZoom; else print '9'; ?>;
166
+		var zoom = <?php if (isset($globalLiveZoom)) {
167
+	print $globalLiveZoom;
168
+} else {
169
+	print '9';
170
+}
171
+?>;
146 172
 	}
147 173
 
148 174
 	//create the map
@@ -167,16 +193,27 @@  discard block
 block discarded – undo
167 193
 	bounds = L.latLngBounds(southWest,northEast);
168 194
 	//a few title layers
169 195
 <?php
170
-	if (isset($_COOKIE['MapType'])) $MapType = $_COOKIE['MapType'];
171
-	else $MapType = $globalMapProvider;
196
+	if (isset($_COOKIE['MapType'])) {
197
+		$MapType = $_COOKIE['MapType'];
198
+	} else {
199
+		$MapType = $globalMapProvider;
200
+	}
172 201
 
173 202
 	if ($MapType == 'Mapbox') {
174
-		if ($_COOKIE['MapTypeId'] == 'default') $MapBoxId = $globalMapboxId;
175
-		else $MapBoxId = $_COOKIE['MapTypeId'];
176
-?>
203
+		if ($_COOKIE['MapTypeId'] == 'default') {
204
+			$MapBoxId = $globalMapboxId;
205
+		} else {
206
+			$MapBoxId = $_COOKIE['MapTypeId'];
207
+		}
208
+		?>
177 209
 	L.tileLayer('https://{s}.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={token}', {
178 210
 	    maxZoom: 18,
179
-	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>,
211
+	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) {
212
+	print 'false';
213
+} else {
214
+	print 'true';
215
+}
216
+?>,
180 217
 	    attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' +
181 218
 	      '<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +
182 219
 	      'Imagery © <a href="http://mapbox.com">Mapbox</a>',
@@ -188,7 +225,12 @@  discard block
 block discarded – undo
188 225
 ?>
189 226
 	L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
190 227
 	    maxZoom: 18,
191
-	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>,
228
+	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) {
229
+	print 'false';
230
+} else {
231
+	print 'true';
232
+}
233
+?>,
192 234
 	    attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' +
193 235
 	      '<a href="www.openstreetmap.org/copyright">Open Database Licence</a>'
194 236
 	}).addTo(map);
@@ -234,20 +276,26 @@  discard block
 block discarded – undo
234 276
 	map.addLayer(yandexLayer);
235 277
 <?php
236 278
 	} elseif ($MapType == 'Bing-Aerial') {
237
-		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap');
238
-?>
279
+		if (!isset($globalBingMapKey) || $globalBingMapKey == '') {
280
+			setcookie('MapType','OpenStreetMap');
281
+		}
282
+		?>
239 283
 	var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'Aerial'});
240 284
 	map.addLayer(bingLayer);
241 285
 <?php
242 286
 	} elseif ($MapType == 'Bing-Hybrid') {
243
-		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap');
244
-?>
287
+		if (!isset($globalBingMapKey) || $globalBingMapKey == '') {
288
+			setcookie('MapType','OpenStreetMap');
289
+		}
290
+		?>
245 291
 	var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'AerialWithLabels'});
246 292
 	map.addLayer(bingLayer);
247 293
 <?php
248 294
 	} elseif ($MapType == 'Bing-Road') {
249
-		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap');
250
-?>
295
+		if (!isset($globalBingMapKey) || $globalBingMapKey == '') {
296
+			setcookie('MapType','OpenStreetMap');
297
+		}
298
+		?>
251 299
 	var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'Road'});
252 300
 	map.addLayer(bingLayer);
253 301
 <?php
@@ -295,7 +343,12 @@  discard block
 block discarded – undo
295 343
 		}
296 344
 	} elseif ($globalBounding == 'circle') {
297 345
 ?>
298
-	var circle = L.circle([<?php print $globalCenterLatitude; ?>, <?php print $globalCenterLongitude; ?>],<?php if (isset($globalBoundingCircleSize)) print $globalBoundingCircleSize; else print '70000'; ?>,{
346
+	var circle = L.circle([<?php print $globalCenterLatitude; ?>, <?php print $globalCenterLongitude; ?>],<?php if (isset($globalBoundingCircleSize)) {
347
+	print $globalBoundingCircleSize;
348
+} else {
349
+	print '70000';
350
+}
351
+?>,{
299 352
 	    color: '#92C7D1',
300 353
 	    fillColor: '#92C7D1',
301 354
 	    fillOpacity: 0.3,
@@ -354,8 +407,11 @@  discard block
 block discarded – undo
354 407
 
355 408
 	function update_airportsLayer() {
356 409
 	    <?php
357
-		if (isset($_COOKIE['AirportZoom'])) $getZoom = $_COOKIE['AirportZoom'];
358
-		else $getZoom = '7';
410
+		if (isset($_COOKIE['AirportZoom'])) {
411
+			$getZoom = $_COOKIE['AirportZoom'];
412
+		} else {
413
+			$getZoom = '7';
414
+		}
359 415
 	    ?>
360 416
 	    //if (map.getZoom() <= <?php print $getZoom; ?>) {
361 417
 		if (typeof airportsLayer != 'undefined') {
@@ -689,9 +745,13 @@  discard block
 block discarded – undo
689 745
 		    if (callsign != ""){ markerLabel += callsign; }
690 746
 		    if (departure_airport_code != "" && arrival_airport_code != "" && departure_airport_code != "NA" && arrival_airport_code != "NA"){ markerLabel += ' ( '+departure_airport_code+' - '+arrival_airport_code+' )'; }
691 747
 <?php
692
-	if (isset($_COOKIE['IconColor'])) $IconColor = $_COOKIE['IconColor'];
693
-	elseif (isset($globalAircraftIconColor)) $IconColor = $globalAircraftIconColor;
694
-	else $IconColor = '1a3151';
748
+	if (isset($_COOKIE['IconColor'])) {
749
+		$IconColor = $_COOKIE['IconColor'];
750
+	} elseif (isset($globalAircraftIconColor)) {
751
+		$IconColor = $globalAircraftIconColor;
752
+	} else {
753
+		$IconColor = '1a3151';
754
+	}
695 755
 	if (!isset($ident) && !isset($flightaware_id)) {
696 756
 ?>
697 757
 		    info_update(feature.properties.fc);
@@ -739,7 +799,12 @@  discard block
 block discarded – undo
739 799
 <?php
740 800
 		} else {
741 801
 ?>
742
-		    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
802
+		    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) {
803
+	print $archiveupdatetime*1000;
804
+} else {
805
+	print $globalMapRefresh*1000+20000;
806
+}
807
+?>+feature.properties.sqt*1000);
743 808
 		    return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
744 809
 <?php
745 810
 		}
@@ -786,7 +851,12 @@  discard block
 block discarded – undo
786 851
 <?php
787 852
 		} else {
788 853
 ?>
789
-			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
854
+			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) {
855
+	print $archiveupdatetime*1000;
856
+} else {
857
+	print $globalMapRefresh*1000+20000;
858
+}
859
+?>+feature.properties.sqt*1000);
790 860
 			    return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
791 861
 <?php
792 862
 		}
@@ -832,7 +902,12 @@  discard block
 block discarded – undo
832 902
 <?php
833 903
 		} else {
834 904
 ?>
835
-			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
905
+			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) {
906
+	print $archiveupdatetime*1000;
907
+} else {
908
+	print $globalMapRefresh*1000+20000;
909
+}
910
+?>+feature.properties.sqt*1000);
836 911
 			    return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
837 912
 <?php
838 913
 		}
@@ -1173,7 +1248,12 @@  discard block
 block discarded – undo
1173 1248
 	if (isset($_GET['archive'])) {
1174 1249
 ?>
1175 1250
 //then load it again every 30 seconds
1176
-//  var reload = setInterval(function(){if (noTimeout) getLiveData(0)},<?php if (isset($globalMapRefresh)) print ($globalMapRefresh*1000)/2; else print '15000'; ?>);
1251
+//  var reload = setInterval(function(){if (noTimeout) getLiveData(0)},<?php if (isset($globalMapRefresh)) {
1252
+	print ($globalMapRefresh*1000)/2;
1253
+} else {
1254
+	print '15000';
1255
+}
1256
+?>);
1177 1257
 reloadPage = setInterval(function(){if (noTimeout) getLiveData(0)},<?php print $archiveupdatetime*1000; ?>);
1178 1258
 <?php
1179 1259
 	} else {
@@ -1184,7 +1264,12 @@  discard block
 block discarded – undo
1184 1264
 	if (noTimeout) {
1185 1265
 	    getLiveData(0);
1186 1266
 	}
1187
-    ,<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000; else print '30000'; ?>);
1267
+    ,<?php if (isset($globalMapRefresh)) {
1268
+	print $globalMapRefresh*1000;
1269
+} else {
1270
+	print '30000';
1271
+}
1272
+?>);
1188 1273
 var currentdate = new Date(Date.UTC());
1189 1274
 var currentyear = new Date().getFullYear();
1190 1275
 var begindate = new Date(Date.UTC(currentyear,12,24,2,0,0,0));
@@ -1196,7 +1281,12 @@  discard block
 block discarded – undo
1196 1281
 		if (!((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) && (isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) {
1197 1282
 ?>
1198 1283
 update_polarLayer();
1199
-setInterval(function(){map.removeLayer(polarLayer);update_polarLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>);
1284
+setInterval(function(){map.removeLayer(polarLayer);update_polarLayer()},<?php if (isset($globalMapRefresh)) {
1285
+	print $globalMapRefresh*1000*2;
1286
+} else {
1287
+	print '60000';
1288
+}
1289
+?>);
1200 1290
 <?php
1201 1291
 		}
1202 1292
 ?>
@@ -1212,7 +1302,12 @@  discard block
 block discarded – undo
1212 1302
 	if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
1213 1303
 ?>
1214 1304
 update_atcLayer();
1215
-setInterval(function(){map.removeLayer(atcLayer);update_atcLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>);
1305
+setInterval(function(){map.removeLayer(atcLayer);update_atcLayer()},<?php if (isset($globalMapRefresh)) {
1306
+	print $globalMapRefresh*1000*2;
1307
+} else {
1308
+	print '60000';
1309
+}
1310
+?>);
1216 1311
 <?php
1217 1312
 	}
1218 1313
 ?>
Please login to merge, or discard this patch.