Completed
Push — master ( 893da0...2b23bd )
by Yannick
05:38
created
require/class.Spotter.php 1 patch
Braces   +679 added lines, -235 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) {
@@ -77,8 +79,11 @@  discard block
 block discarded – undo
77 79
 				$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
78 80
 			}
79 81
 		}
80
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
81
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
82
+		if ($filter_query_where == '' && $where) {
83
+			$filter_query_where = ' WHERE';
84
+		} elseif ($filter_query_where != '' && $and) {
85
+			$filter_query_where .= ' AND';
86
+		}
82 87
 		$filter_query = $filter_query_join.$filter_query_where;
83 88
 		return $filter_query;
84 89
 	}
@@ -98,10 +103,18 @@  discard block
 block discarded – undo
98 103
 		$Image = new Image($this->db);
99 104
 		$Schedule = new Schedule($this->db);
100 105
 		$ACARS = new ACARS($this->db);
101
-		if (!isset($globalIVAO)) $globalIVAO = FALSE;
102
-		if (!isset($globalVATSIM)) $globalVATSIM = FALSE;
103
-		if (!isset($globalphpVMS)) $globalphpVMS = FALSE;
104
-		if (!isset($globalVAM)) $globalVAM = FALSE;
106
+		if (!isset($globalIVAO)) {
107
+			$globalIVAO = FALSE;
108
+		}
109
+		if (!isset($globalVATSIM)) {
110
+			$globalVATSIM = FALSE;
111
+		}
112
+		if (!isset($globalphpVMS)) {
113
+			$globalphpVMS = FALSE;
114
+		}
115
+		if (!isset($globalVAM)) {
116
+			$globalVAM = FALSE;
117
+		}
105 118
 		date_default_timezone_set('UTC');
106 119
 		
107 120
 		if (!is_string($query))
@@ -148,21 +161,35 @@  discard block
 block discarded – undo
148 161
 			} else {
149 162
 				$temp_array['spotter_id'] = '';
150 163
 			}
151
-			if (isset($row['flightaware_id'])) $temp_array['flightaware_id'] = $row['flightaware_id'];
152
-			if (isset($row['modes'])) $temp_array['modes'] = $row['modes'];
164
+			if (isset($row['flightaware_id'])) {
165
+				$temp_array['flightaware_id'] = $row['flightaware_id'];
166
+			}
167
+			if (isset($row['modes'])) {
168
+				$temp_array['modes'] = $row['modes'];
169
+			}
153 170
 			$temp_array['ident'] = $row['ident'];
154 171
 			if (isset($row['registration']) && $row['registration'] != '') {
155 172
 				$temp_array['registration'] = $row['registration'];
156 173
 			} elseif (isset($temp_array['modes'])) {
157 174
 				$temp_array['registration'] = $this->getAircraftRegistrationBymodeS($temp_array['modes']);
158
-			} else $temp_array['registration'] = '';
159
-			if (isset($row['aircraft_icao'])) $temp_array['aircraft_type'] = $row['aircraft_icao'];
175
+			} else {
176
+				$temp_array['registration'] = '';
177
+			}
178
+			if (isset($row['aircraft_icao'])) {
179
+				$temp_array['aircraft_type'] = $row['aircraft_icao'];
180
+			}
160 181
 			
161 182
 			$temp_array['departure_airport'] = $row['departure_airport_icao'];
162 183
 			$temp_array['arrival_airport'] = $row['arrival_airport_icao'];
163
-			if (isset($row['real_arrival_airport_icao']) && $row['real_arrival_airport_icao'] != NULL) $temp_array['real_arrival_airport'] = $row['real_arrival_airport_icao'];
164
-			if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude'];
165
-			if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude'];
184
+			if (isset($row['real_arrival_airport_icao']) && $row['real_arrival_airport_icao'] != NULL) {
185
+				$temp_array['real_arrival_airport'] = $row['real_arrival_airport_icao'];
186
+			}
187
+			if (isset($row['latitude'])) {
188
+				$temp_array['latitude'] = $row['latitude'];
189
+			}
190
+			if (isset($row['longitude'])) {
191
+				$temp_array['longitude'] = $row['longitude'];
192
+			}
166 193
 			/*
167 194
 			if (Connection->tableExists('countries')) {
168 195
 				$country_info = $this->getCountryFromLatitudeLongitude($temp_array['latitude'],$temp_array['longitude']);
@@ -172,8 +199,12 @@  discard block
 block discarded – undo
172 199
 				}
173 200
 			}
174 201
 			*/
175
-			if (isset($row['waypoints'])) $temp_array['waypoints'] = $row['waypoints'];
176
-			if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source'];
202
+			if (isset($row['waypoints'])) {
203
+				$temp_array['waypoints'] = $row['waypoints'];
204
+			}
205
+			if (isset($row['format_source'])) {
206
+				$temp_array['format_source'] = $row['format_source'];
207
+			}
177 208
 			if (isset($row['route_stop'])) {
178 209
 				$temp_array['route_stop'] = $row['route_stop'];
179 210
 				if ($row['route_stop'] != '') {
@@ -192,13 +223,19 @@  discard block
 block discarded – undo
192 223
 					}
193 224
 				}
194 225
 			}
195
-			if (isset($row['altitude'])) $temp_array['altitude'] = $row['altitude'];
226
+			if (isset($row['altitude'])) {
227
+				$temp_array['altitude'] = $row['altitude'];
228
+			}
196 229
 			if (isset($row['heading'])) {
197 230
 				$temp_array['heading'] = $row['heading'];
198 231
 				$heading_direction = $this->parseDirection($row['heading']);
199
-				if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
232
+				if (isset($heading_direction[0]['direction_fullname'])) {
233
+					$temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
234
+				}
235
+			}
236
+			if (isset($row['ground_speed'])) {
237
+				$temp_array['ground_speed'] = $row['ground_speed'];
200 238
 			}
201
-			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];
202 239
 			$temp_array['image'] = "";
203 240
 			$temp_array['image_thumbnail'] = "";
204 241
 			$temp_array['image_source'] = "";
@@ -206,7 +243,9 @@  discard block
 block discarded – undo
206 243
  
207 244
 			if (isset($row['highlight'])) {
208 245
 				$temp_array['highlight'] = $row['highlight'];
209
-			} else $temp_array['highlight'] = '';
246
+			} else {
247
+				$temp_array['highlight'] = '';
248
+			}
210 249
 			
211 250
 			if (isset($row['date'])) {
212 251
 				$dateArray = $this->parseDateString($row['date']);
@@ -254,7 +293,9 @@  discard block
 block discarded – undo
254 293
 				
255 294
 					if ($aircraft_array[0]['aircraft_shadow'] != NULL) {
256 295
 						$temp_array['aircraft_shadow'] = $aircraft_array[0]['aircraft_shadow'];
257
-					} else $temp_array['aircraft_shadow'] = 'default.png';
296
+					} else {
297
+						$temp_array['aircraft_shadow'] = 'default.png';
298
+					}
258 299
                                 } else {
259 300
                             		$temp_array['aircraft_shadow'] = 'default.png';
260 301
 					$temp_array['aircraft_name'] = 'N/A';
@@ -262,11 +303,17 @@  discard block
 block discarded – undo
262 303
                             	}
263 304
 			}
264 305
 			$fromsource = NULL;
265
-			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
266
-			elseif (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
267
-			elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') $fromsource = 'ivao';
268
-			elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
269
-			elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
306
+			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
307
+				$fromsource = $globalAirlinesSource;
308
+			} elseif (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') {
309
+				$fromsource = 'vatsim';
310
+			} elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') {
311
+				$fromsource = 'ivao';
312
+			} elseif (isset($globalVATSIM) && $globalVATSIM) {
313
+				$fromsource = 'vatsim';
314
+			} elseif (isset($globalIVAO) && $globalIVAO) {
315
+				$fromsource = 'ivao';
316
+			}
270 317
 			if (!isset($row['airline_name']) || $row['airline_name'] == '') {
271 318
 				if (!is_numeric(substr($row['ident'], 0, 3))) {
272 319
 					if (is_numeric(substr($row['ident'], 2, 1))) {
@@ -289,12 +336,18 @@  discard block
 block discarded – undo
289 336
 				}
290 337
 			} else {
291 338
 				$temp_array['airline_icao'] = $row['airline_icao'];
292
-				if (isset($row['airline_iata'])) $temp_array['airline_iata'] = $row['airline_iata'];
293
-				else $temp_array['airline_iata'] = 'N/A';
339
+				if (isset($row['airline_iata'])) {
340
+					$temp_array['airline_iata'] = $row['airline_iata'];
341
+				} else {
342
+					$temp_array['airline_iata'] = 'N/A';
343
+				}
294 344
 				$temp_array['airline_name'] = $row['airline_name'];
295 345
 				$temp_array['airline_country'] = $row['airline_country'];
296
-				if (isset($row['airline_callsign'])) $temp_array['airline_callsign'] = $row['airline_callsign'];
297
-				else $temp_array['airline_callsign'] = 'N/A';
346
+				if (isset($row['airline_callsign'])) {
347
+					$temp_array['airline_callsign'] = $row['airline_callsign'];
348
+				} else {
349
+					$temp_array['airline_callsign'] = 'N/A';
350
+				}
298 351
 				$temp_array['airline_type'] = $row['airline_type'];
299 352
 				if ($temp_array['airline_icao'] != '' && $temp_array['airline_iata'] == 'N/A') {
300 353
 					$airline_array = $this->getAllAirlineInfo($temp_array['airline_icao']);
@@ -321,7 +374,9 @@  discard block
 block discarded – undo
321 374
 			}
322 375
 			if ($temp_array['registration'] != "" && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && !isset($temp_array['aircraft_owner'])) {
323 376
 				$owner_info = $this->getAircraftOwnerByRegistration($temp_array['registration']);
324
-				if ($owner_info['owner'] != '') $temp_array['aircraft_owner'] = ucwords(strtolower($owner_info['owner']));
377
+				if ($owner_info['owner'] != '') {
378
+					$temp_array['aircraft_owner'] = ucwords(strtolower($owner_info['owner']));
379
+				}
325 380
 				$temp_array['aircraft_base'] = $owner_info['base'];
326 381
 				$temp_array['aircraft_date_first_reg'] = $owner_info['date_first_reg'];
327 382
 			}
@@ -329,9 +384,14 @@  discard block
 block discarded – undo
329 384
 			if($temp_array['registration'] != "" || ($globalIVAO && isset($temp_array['aircraft_type']) && $temp_array['aircraft_type'] != ''))
330 385
 			{
331 386
 				if ($globalIVAO) {
332
-					if (isset($temp_array['airline_icao']))	$image_array = $Image->getSpotterImage('',$temp_array['aircraft_type'],$temp_array['airline_icao']);
333
-					else $image_array = $Image->getSpotterImage('',$temp_array['aircraft_type']);
334
-				} else $image_array = $Image->getSpotterImage($temp_array['registration']);
387
+					if (isset($temp_array['airline_icao'])) {
388
+						$image_array = $Image->getSpotterImage('',$temp_array['aircraft_type'],$temp_array['airline_icao']);
389
+					} else {
390
+						$image_array = $Image->getSpotterImage('',$temp_array['aircraft_type']);
391
+					}
392
+				} else {
393
+					$image_array = $Image->getSpotterImage($temp_array['registration']);
394
+				}
335 395
 				if (count($image_array) > 0) {
336 396
 					$temp_array['image'] = $image_array[0]['image'];
337 397
 					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -383,7 +443,9 @@  discard block
 block discarded – undo
383 443
 			//if ($row['departure_airport_icao'] != '' && $row['departure_airport_name'] == '') {
384 444
 			if ($row['departure_airport_icao'] != '') {
385 445
 				$departure_airport_array = $this->getAllAirportInfo($row['departure_airport_icao']);
386
-				if (!isset($departure_airport_array[0]['name'])) $departure_airport_array = $this->getAllAirportInfo('NA');
446
+				if (!isset($departure_airport_array[0]['name'])) {
447
+					$departure_airport_array = $this->getAllAirportInfo('NA');
448
+				}
387 449
 			/*
388 450
 			} elseif ($row['departure_airport_name'] != '') {
389 451
 				$temp_array['departure_airport_name'] = $row['departure_airport_name'];
@@ -391,7 +453,9 @@  discard block
 block discarded – undo
391 453
 				$temp_array['departure_airport_country'] = $row['departure_airport_country'];
392 454
 				$temp_array['departure_airport_icao'] = $row['departure_airport_icao'];
393 455
 			*/
394
-			} else $departure_airport_array = $this->getAllAirportInfo('NA');
456
+			} else {
457
+				$departure_airport_array = $this->getAllAirportInfo('NA');
458
+			}
395 459
 			if (isset($departure_airport_array[0]['name'])) {
396 460
 				$temp_array['departure_airport_name'] = $departure_airport_array[0]['name'];
397 461
 				$temp_array['departure_airport_city'] = $departure_airport_array[0]['city'];
@@ -411,8 +475,12 @@  discard block
 block discarded – undo
411 475
 			
412 476
 			if ($row['arrival_airport_icao'] != '') {
413 477
 				$arrival_airport_array = $this->getAllAirportInfo($row['arrival_airport_icao']);
414
-				if (count($arrival_airport_array) == 0) $arrival_airport_array = $this->getAllAirportInfo('NA');
415
-			} else $arrival_airport_array = $this->getAllAirportInfo('NA');
478
+				if (count($arrival_airport_array) == 0) {
479
+					$arrival_airport_array = $this->getAllAirportInfo('NA');
480
+				}
481
+			} else {
482
+				$arrival_airport_array = $this->getAllAirportInfo('NA');
483
+			}
416 484
 			if (isset($arrival_airport_array[0]['name'])) {
417 485
 				$temp_array['arrival_airport_name'] = $arrival_airport_array[0]['name'];
418 486
 				$temp_array['arrival_airport_city'] = $arrival_airport_array[0]['city'];
@@ -428,27 +496,45 @@  discard block
 block discarded – undo
428 496
 				$temp_array['arrival_airport_time'] = $row['arrival_airport_time'];
429 497
 			}
430 498
 			*/
431
-			if (isset($row['pilot_id']) && $row['pilot_id'] != '') $temp_array['pilot_id'] = $row['pilot_id'];
432
-			if (isset($row['pilot_name']) && $row['pilot_name'] != '') $temp_array['pilot_name'] = $row['pilot_name'];
433
-			if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name'];
434
-			if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country'];
435
-			if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance'];
499
+			if (isset($row['pilot_id']) && $row['pilot_id'] != '') {
500
+				$temp_array['pilot_id'] = $row['pilot_id'];
501
+			}
502
+			if (isset($row['pilot_name']) && $row['pilot_name'] != '') {
503
+				$temp_array['pilot_name'] = $row['pilot_name'];
504
+			}
505
+			if (isset($row['source_name']) && $row['source_name'] != '') {
506
+				$temp_array['source_name'] = $row['source_name'];
507
+			}
508
+			if (isset($row['over_country']) && $row['over_country'] != '') {
509
+				$temp_array['over_country'] = $row['over_country'];
510
+			}
511
+			if (isset($row['distance']) && $row['distance'] != '') {
512
+				$temp_array['distance'] = $row['distance'];
513
+			}
436 514
 			if (isset($row['squawk'])) {
437 515
 				$temp_array['squawk'] = $row['squawk'];
438 516
 				if ($row['squawk'] != '' && isset($temp_array['country_iso2'])) {
439 517
 					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$temp_array['country_iso2']);
440
-					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
518
+					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) {
519
+						$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
520
+					}
441 521
 				} elseif ($row['squawk'] != '' && isset($temp_array['over_country'])) {
442 522
 					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$temp_array['over_country']);
443
-					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
444
-				} elseif ($row['squawk'] != '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
523
+					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) {
524
+						$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
525
+					}
526
+				} elseif ($row['squawk'] != '' && isset($globalSquawkCountry)) {
527
+					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
528
+				}
445 529
 			}
446 530
     			
447 531
 			$temp_array['query_number_rows'] = $num_rows;
448 532
 			
449 533
 			$spotter_array[] = $temp_array;
450 534
 		}
451
-		if ($num_rows == 0) return array();
535
+		if ($num_rows == 0) {
536
+			return array();
537
+		}
452 538
 		$spotter_array[0]['query_number_rows'] = $num_rows;
453 539
 		return $spotter_array;
454 540
 	}	
@@ -481,7 +567,9 @@  discard block
 block discarded – undo
481 567
 				foreach ($q_array as $q_item){
482 568
 					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
483 569
 					$additional_query .= " AND (";
484
-					if (is_int($q_item)) $additional_query .= "(spotter_output.spotter_id like '%".$q_item."%') OR ";
570
+					if (is_int($q_item)) {
571
+						$additional_query .= "(spotter_output.spotter_id like '%".$q_item."%') OR ";
572
+					}
485 573
 					$additional_query .= "(spotter_output.aircraft_icao like '%".$q_item."%') OR ";
486 574
 					$additional_query .= "(spotter_output.aircraft_name like '%".$q_item."%') OR ";
487 575
 					$additional_query .= "(spotter_output.aircraft_manufacturer like '%".$q_item."%') OR ";
@@ -502,7 +590,9 @@  discard block
 block discarded – undo
502 590
 					$additional_query .= "(spotter_output.pilot_name like '%".$q_item."%') OR ";
503 591
 					$additional_query .= "(spotter_output.ident like '%".$q_item."%') OR ";
504 592
 					$translate = $Translation->ident2icao($q_item);
505
-					if ($translate != $q_item) $additional_query .= "(spotter_output.ident like '%".$translate."%') OR ";
593
+					if ($translate != $q_item) {
594
+						$additional_query .= "(spotter_output.ident like '%".$translate."%') OR ";
595
+					}
506 596
 					$additional_query .= "(spotter_output.highlight like '%".$q_item."%')";
507 597
 					$additional_query .= ")";
508 598
 				}
@@ -729,7 +819,9 @@  discard block
 block discarded – undo
729 819
 				date_default_timezone_set($globalTimezone);
730 820
 				$datetime = new DateTime();
731 821
 				$offset = $datetime->format('P');
732
-			} else $offset = '+00:00';
822
+			} else {
823
+				$offset = '+00:00';
824
+			}
733 825
 
734 826
 			if ($date_array[1] != "")
735 827
 			{
@@ -761,8 +853,12 @@  discard block
 block discarded – undo
761 853
 			{
762 854
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
763 855
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
764
-			} else $limit_query = "";
765
-		} else $limit_query = "";
856
+			} else {
857
+				$limit_query = "";
858
+			}
859
+		} else {
860
+			$limit_query = "";
861
+		}
766 862
 
767 863
 
768 864
 		if ($sort != "")
@@ -830,8 +926,12 @@  discard block
 block discarded – undo
830 926
 			{
831 927
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
832 928
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
833
-			} else $limit_query = "";
834
-		} else $limit_query = "";
929
+			} else {
930
+				$limit_query = "";
931
+			}
932
+		} else {
933
+			$limit_query = "";
934
+		}
835 935
 		
836 936
 		if ($sort != "")
837 937
 		{
@@ -1155,7 +1255,9 @@  discard block
 block discarded – undo
1155 1255
 		global $global_query;
1156 1256
 		
1157 1257
 		date_default_timezone_set('UTC');
1158
-		if ($id == '') return array();
1258
+		if ($id == '') {
1259
+			return array();
1260
+		}
1159 1261
 		$additional_query = "spotter_output.spotter_id = :id";
1160 1262
 		$query_values = array(':id' => $id);
1161 1263
 
@@ -1784,7 +1886,9 @@  discard block
 block discarded – undo
1784 1886
 		{
1785 1887
 			$highlight = $row['highlight'];
1786 1888
 		}
1787
-		if (isset($highlight)) return $highlight;
1889
+		if (isset($highlight)) {
1890
+			return $highlight;
1891
+		}
1788 1892
 	}
1789 1893
 
1790 1894
 	
@@ -1812,7 +1916,9 @@  discard block
 block discarded – undo
1812 1916
 		$sth->closeCursor();
1813 1917
 		if (count($row) > 0) {
1814 1918
 			return $row['usage'];
1815
-		} else return '';
1919
+		} else {
1920
+			return '';
1921
+		}
1816 1922
 	}
1817 1923
 
1818 1924
 	/**
@@ -1837,7 +1943,9 @@  discard block
 block discarded – undo
1837 1943
 		$sth->closeCursor();
1838 1944
 		if (count($row) > 0) {
1839 1945
 			return $row['icao'];
1840
-		} else return '';
1946
+		} else {
1947
+			return '';
1948
+		}
1841 1949
 	}
1842 1950
 
1843 1951
 	/**
@@ -1865,7 +1973,9 @@  discard block
 block discarded – undo
1865 1973
 			$airport_longitude = $row['longitude'];
1866 1974
 			$Common = new Common();
1867 1975
 			return $Common->distance($latitude,$longitude,$airport_latitude,$airport_longitude);
1868
-		} else return '';
1976
+		} else {
1977
+			return '';
1978
+		}
1869 1979
 	}
1870 1980
 	
1871 1981
 	/**
@@ -1977,7 +2087,9 @@  discard block
 block discarded – undo
1977 2087
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1978 2088
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1979 2089
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1980
-		} else return array();
2090
+		} else {
2091
+			return array();
2092
+		}
1981 2093
 		if ($globalDBdriver == 'mysql') {
1982 2094
 			$query  = "SELECT airport.* FROM airport WHERE airport.latitude BETWEEN ".$minlat." AND ".$maxlat." AND airport.longitude BETWEEN ".$minlong." AND ".$maxlong." AND airport.type != 'closed'";
1983 2095
 		} else {
@@ -2012,7 +2124,9 @@  discard block
 block discarded – undo
2012 2124
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2013 2125
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2014 2126
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2015
-		} else return array();
2127
+		} else {
2128
+			return array();
2129
+		}
2016 2130
 		//$query  = "SELECT waypoints.* FROM waypoints WHERE waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong;
2017 2131
 		$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.")";
2018 2132
 		//$query  = "SELECT waypoints.* FROM waypoints";
@@ -2047,7 +2161,9 @@  discard block
 block discarded – undo
2047 2161
 	public function getAllAirlineInfo($airline_icao, $fromsource = NULL)
2048 2162
 	{
2049 2163
 		global $globalUseRealAirlines;
2050
-		if (isset($globalUseRealAirlines) && $globalUseRealAirlines) $fromsource = NULL;
2164
+		if (isset($globalUseRealAirlines) && $globalUseRealAirlines) {
2165
+			$fromsource = NULL;
2166
+		}
2051 2167
 		$airline_icao = strtoupper(filter_var($airline_icao,FILTER_SANITIZE_STRING));
2052 2168
 		if ($airline_icao == 'NA') {
2053 2169
 			$airline_array = array();
@@ -2097,7 +2213,9 @@  discard block
 block discarded – undo
2097 2213
 				$sth->execute(array(':fromsource' => $fromsource));
2098 2214
 				$row = $sth->fetch(PDO::FETCH_ASSOC);
2099 2215
 				$sth->closeCursor();
2100
-				if ($row['nb'] == 0) $result = $this->getAllAirlineInfo($airline_icao);
2216
+				if ($row['nb'] == 0) {
2217
+					$result = $this->getAllAirlineInfo($airline_icao);
2218
+				}
2101 2219
 			}
2102 2220
 			return $result;
2103 2221
 		}
@@ -2161,15 +2279,20 @@  discard block
 block discarded – undo
2161 2279
 				'A320-211' => 'A320',
2162 2280
 				'747-8i' => 'B748',
2163 2281
 				'A380' => 'A388');
2164
-		if (isset($all_aircraft[$aircraft_type])) return $all_aircraft[$aircraft_type];
2282
+		if (isset($all_aircraft[$aircraft_type])) {
2283
+			return $all_aircraft[$aircraft_type];
2284
+		}
2165 2285
 
2166 2286
 		$query  = "SELECT aircraft.icao FROM aircraft WHERE aircraft.type LIKE :saircraft_type OR aircraft.type = :aircraft_type OR aircraft.icao = :aircraft_type LIMIT 1";
2167 2287
 		$aircraft_type = strtoupper($aircraft_type);
2168 2288
 		$sth = $this->db->prepare($query);
2169 2289
 		$sth->execute(array(':saircraft_type' => '%'.$aircraft_type.'%',':aircraft_type' => $aircraft_type,));
2170 2290
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
2171
-		if (isset($result[0]['icao'])) return $result[0]['icao'];
2172
-		else return '';
2291
+		if (isset($result[0]['icao'])) {
2292
+			return $result[0]['icao'];
2293
+		} else {
2294
+			return '';
2295
+		}
2173 2296
 	}
2174 2297
 	
2175 2298
 	/**
@@ -2192,7 +2315,9 @@  discard block
 block discarded – undo
2192 2315
 		$sth->closeCursor();
2193 2316
 		if (isset($row['icaotypecode'])) {
2194 2317
 			return $row['icaotypecode'];
2195
-		} else return '';
2318
+		} else {
2319
+			return '';
2320
+		}
2196 2321
 	}
2197 2322
 
2198 2323
 	/**
@@ -2215,7 +2340,9 @@  discard block
 block discarded – undo
2215 2340
 		$sth->closeCursor();
2216 2341
 		if (isset($row['icaotypecode'])) {
2217 2342
 			return $row['icaotypecode'];
2218
-		} else return '';
2343
+		} else {
2344
+			return '';
2345
+		}
2219 2346
 	}
2220 2347
 
2221 2348
 	/**
@@ -2237,7 +2364,9 @@  discard block
 block discarded – undo
2237 2364
 		$sth->closeCursor();
2238 2365
 		if (isset($row['operator_correct'])) {
2239 2366
 			return $row['operator_correct'];
2240
-		} else return $operator;
2367
+		} else {
2368
+			return $operator;
2369
+		}
2241 2370
 	}
2242 2371
 
2243 2372
 	/**
@@ -2250,7 +2379,9 @@  discard block
 block discarded – undo
2250 2379
 	public function getRouteInfo($callsign)
2251 2380
 	{
2252 2381
 		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
2253
-                if ($callsign == '') return array();
2382
+                if ($callsign == '') {
2383
+                	return array();
2384
+                }
2254 2385
 		$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";
2255 2386
 		
2256 2387
 		$sth = $this->db->prepare($query);
@@ -2260,7 +2391,9 @@  discard block
 block discarded – undo
2260 2391
 		$sth->closeCursor();
2261 2392
 		if (count($row) > 0) {
2262 2393
 			return $row;
2263
-		} else return array();
2394
+		} else {
2395
+			return array();
2396
+		}
2264 2397
 	}
2265 2398
 	
2266 2399
 	/**
@@ -2313,7 +2446,9 @@  discard block
 block discarded – undo
2313 2446
 			$result = $sth->fetch(PDO::FETCH_ASSOC);
2314 2447
 			$sth->closeCursor();
2315 2448
 			return $result;
2316
-		} else return array();
2449
+		} else {
2450
+			return array();
2451
+		}
2317 2452
 	}
2318 2453
 	
2319 2454
   
@@ -2470,8 +2605,11 @@  discard block
 block discarded – undo
2470 2605
 		$query .= " ORDER BY spotter_output.source_name ASC";
2471 2606
 
2472 2607
 		$sth = $this->db->prepare($query);
2473
-		if (!empty($query_values)) $sth->execute($query_values);
2474
-		else $sth->execute();
2608
+		if (!empty($query_values)) {
2609
+			$sth->execute($query_values);
2610
+		} else {
2611
+			$sth->execute();
2612
+		}
2475 2613
 
2476 2614
 		$source_array = array();
2477 2615
 		$temp_array = array();
@@ -2504,9 +2642,13 @@  discard block
 block discarded – undo
2504 2642
 								WHERE spotter_output.airline_icao <> '' 
2505 2643
 								ORDER BY spotter_output.airline_name ASC";
2506 2644
 			*/
2507
-			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $forsource = $globalAirlinesSource;
2508
-			elseif (isset($globalVATSIM) && $globalVATSIM) $forsource = 'vatsim';
2509
-			elseif (isset($globalIVAO) && $globalIVAO) $forsource = 'ivao';
2645
+			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
2646
+				$forsource = $globalAirlinesSource;
2647
+			} elseif (isset($globalVATSIM) && $globalVATSIM) {
2648
+				$forsource = 'vatsim';
2649
+			} elseif (isset($globalIVAO) && $globalIVAO) {
2650
+				$forsource = 'ivao';
2651
+			}
2510 2652
 			if ($forsource === NULL) {
2511 2653
 				$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";
2512 2654
 				$query_data = array();
@@ -2798,7 +2940,9 @@  discard block
 block discarded – undo
2798 2940
 			date_default_timezone_set($globalTimezone);
2799 2941
 			$datetime = new DateTime();
2800 2942
 			$offset = $datetime->format('P');
2801
-		} else $offset = '+00:00';
2943
+		} else {
2944
+			$offset = '+00:00';
2945
+		}
2802 2946
 		if ($airport_icao == '') {
2803 2947
 			if ($globalDBdriver == 'mysql') {
2804 2948
 				$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";
@@ -2830,7 +2974,9 @@  discard block
 block discarded – undo
2830 2974
 			date_default_timezone_set($globalTimezone);
2831 2975
 			$datetime = new DateTime();
2832 2976
 			$offset = $datetime->format('P');
2833
-		} else $offset = '+00:00';
2977
+		} else {
2978
+			$offset = '+00:00';
2979
+		}
2834 2980
 		if ($airport_icao == '') {
2835 2981
 			if ($globalDBdriver == 'mysql') {
2836 2982
 				$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";
@@ -2863,7 +3009,9 @@  discard block
 block discarded – undo
2863 3009
 			date_default_timezone_set($globalTimezone);
2864 3010
 			$datetime = new DateTime();
2865 3011
 			$offset = $datetime->format('P');
2866
-		} else $offset = '+00:00';
3012
+		} else {
3013
+			$offset = '+00:00';
3014
+		}
2867 3015
 		if ($airport_icao == '') {
2868 3016
 			if ($globalDBdriver == 'mysql') {
2869 3017
 				$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 
@@ -2902,7 +3050,9 @@  discard block
 block discarded – undo
2902 3050
 			date_default_timezone_set($globalTimezone);
2903 3051
 			$datetime = new DateTime();
2904 3052
 			$offset = $datetime->format('P');
2905
-		} else $offset = '+00:00';
3053
+		} else {
3054
+			$offset = '+00:00';
3055
+		}
2906 3056
 		if ($airport_icao == '') {
2907 3057
 			if ($globalDBdriver == 'mysql') {
2908 3058
 				$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 
@@ -2947,7 +3097,9 @@  discard block
 block discarded – undo
2947 3097
 			date_default_timezone_set($globalTimezone);
2948 3098
 			$datetime = new DateTime();
2949 3099
 			$offset = $datetime->format('P');
2950
-		} else $offset = '+00:00';
3100
+		} else {
3101
+			$offset = '+00:00';
3102
+		}
2951 3103
 		if ($airport_icao == '') {
2952 3104
 			if ($globalDBdriver == 'mysql') {
2953 3105
 				$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";
@@ -2982,7 +3134,9 @@  discard block
 block discarded – undo
2982 3134
 			date_default_timezone_set($globalTimezone);
2983 3135
 			$datetime = new DateTime();
2984 3136
 			$offset = $datetime->format('P');
2985
-		} else $offset = '+00:00';
3137
+		} else {
3138
+			$offset = '+00:00';
3139
+		}
2986 3140
 		if ($airport_icao == '') {
2987 3141
 			if ($globalDBdriver == 'mysql') {
2988 3142
 				$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 
@@ -3024,7 +3178,9 @@  discard block
 block discarded – undo
3024 3178
 			date_default_timezone_set($globalTimezone);
3025 3179
 			$datetime = new DateTime();
3026 3180
 			$offset = $datetime->format('P');
3027
-		} else $offset = '+00:00';
3181
+		} else {
3182
+			$offset = '+00:00';
3183
+		}
3028 3184
 		if ($airport_icao == '') {
3029 3185
 			if ($globalDBdriver == 'mysql') {
3030 3186
 				$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";
@@ -3058,7 +3214,9 @@  discard block
 block discarded – undo
3058 3214
 			date_default_timezone_set($globalTimezone);
3059 3215
 			$datetime = new DateTime();
3060 3216
 			$offset = $datetime->format('P');
3061
-		} else $offset = '+00:00';
3217
+		} else {
3218
+			$offset = '+00:00';
3219
+		}
3062 3220
 		if ($airport_icao == '') {
3063 3221
 			if ($globalDBdriver == 'mysql') {
3064 3222
 				$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 
@@ -3106,7 +3264,9 @@  discard block
 block discarded – undo
3106 3264
 			date_default_timezone_set($globalTimezone);
3107 3265
 			$datetime = new DateTime();
3108 3266
 			$offset = $datetime->format('P');
3109
-		} else $offset = '+00:00';
3267
+		} else {
3268
+			$offset = '+00:00';
3269
+		}
3110 3270
 
3111 3271
 		if ($globalDBdriver == 'mysql') {
3112 3272
 			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) as date
@@ -3226,7 +3386,9 @@  discard block
 block discarded – undo
3226 3386
 	*/	
3227 3387
 	public function updateLatestSpotterData($flightaware_id = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $ground = false, $groundspeed = NULL, $date = '', $arrival_airport_icao = '',$arrival_airport_time = '')
3228 3388
 	{
3229
-		if ($groundspeed == '') $groundspeed = NULL;
3389
+		if ($groundspeed == '') {
3390
+			$groundspeed = NULL;
3391
+		}
3230 3392
 		$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';
3231 3393
                 $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);
3232 3394
 
@@ -3276,10 +3438,18 @@  discard block
 block discarded – undo
3276 3438
 		$Image = new Image($this->db);
3277 3439
 		$Common = new Common();
3278 3440
 		
3279
-		if (!isset($globalIVAO)) $globalIVAO = FALSE;
3280
-		if (!isset($globalVATSIM)) $globalVATSIM = FALSE;
3281
-		if (!isset($globalphpVMS)) $globalphpVMS = FALSE;
3282
-		if (!isset($globalVAM)) $globalVAM = FALSE;
3441
+		if (!isset($globalIVAO)) {
3442
+			$globalIVAO = FALSE;
3443
+		}
3444
+		if (!isset($globalVATSIM)) {
3445
+			$globalVATSIM = FALSE;
3446
+		}
3447
+		if (!isset($globalphpVMS)) {
3448
+			$globalphpVMS = FALSE;
3449
+		}
3450
+		if (!isset($globalVAM)) {
3451
+			$globalVAM = FALSE;
3452
+		}
3283 3453
 		date_default_timezone_set('UTC');
3284 3454
 		
3285 3455
 		//getting the registration
@@ -3292,23 +3462,33 @@  discard block
 block discarded – undo
3292 3462
 				if ($ModeS != '') {
3293 3463
 					$timeelapsed = microtime(true);
3294 3464
 					$registration = $this->getAircraftRegistrationBymodeS($ModeS);
3295
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3465
+					if ($globalDebugTimeElapsed) {
3466
+						echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3467
+					}
3296 3468
 				} else {
3297 3469
 					$myhex = explode('-',$flightaware_id);
3298 3470
 					if (count($myhex) > 0) {
3299 3471
 						$timeelapsed = microtime(true);
3300 3472
 						$registration = $this->getAircraftRegistrationBymodeS($myhex[0]);
3301
-						if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3473
+						if ($globalDebugTimeElapsed) {
3474
+							echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3475
+						}
3302 3476
 					}
3303 3477
 				}
3304 3478
 			}
3305 3479
 		}
3306 3480
 		$fromsource = NULL;
3307
-		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
3308
-		elseif ($format_source == 'vatsimtxt') $fromsource = 'vatsim';
3309
-		elseif ($format_source == 'whazzup') $fromsource = 'ivao';
3310
-		elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
3311
-		elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
3481
+		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
3482
+			$fromsource = $globalAirlinesSource;
3483
+		} elseif ($format_source == 'vatsimtxt') {
3484
+			$fromsource = 'vatsim';
3485
+		} elseif ($format_source == 'whazzup') {
3486
+			$fromsource = 'ivao';
3487
+		} elseif (isset($globalVATSIM) && $globalVATSIM) {
3488
+			$fromsource = 'vatsim';
3489
+		} elseif (isset($globalIVAO) && $globalIVAO) {
3490
+			$fromsource = 'ivao';
3491
+		}
3312 3492
 		//getting the airline information
3313 3493
 		if ($ident != "")
3314 3494
 		{
@@ -3332,15 +3512,21 @@  discard block
 block discarded – undo
3332 3512
 					if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == ""){
3333 3513
 						$airline_array = $this->getAllAirlineInfo("NA");
3334 3514
 					}
3335
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3515
+					if ($globalDebugTimeElapsed) {
3516
+						echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3517
+					}
3336 3518
 
3337 3519
 				} else {
3338 3520
 					$timeelapsed = microtime(true);
3339 3521
 					$airline_array = $this->getAllAirlineInfo("NA");
3340
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3522
+					if ($globalDebugTimeElapsed) {
3523
+						echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3524
+					}
3341 3525
 				}
3342 3526
 			}
3343
-		} else $airline_array = array();
3527
+		} else {
3528
+			$airline_array = array();
3529
+		}
3344 3530
 		
3345 3531
 		//getting the aircraft information
3346 3532
 		$aircraft_array = array();
@@ -3354,27 +3540,37 @@  discard block
 block discarded – undo
3354 3540
 				{
3355 3541
 					$timeelapsed = microtime(true);
3356 3542
 					$aircraft_array = $this->getAllAircraftInfo("NA");
3357
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3543
+					if ($globalDebugTimeElapsed) {
3544
+						echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3545
+					}
3358 3546
 				} else {
3359 3547
 					$timeelapsed = microtime(true);
3360 3548
 					$aircraft_array = $this->getAllAircraftInfo($aircraft_icao);
3361
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3549
+					if ($globalDebugTimeElapsed) {
3550
+						echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3551
+					}
3362 3552
 				}
3363 3553
 			}
3364 3554
 		} else {
3365 3555
 			if ($ModeS != '') {
3366 3556
 				$timeelapsed = microtime(true);
3367 3557
 				$aircraft_icao = $this->getAllAircraftType($ModeS);
3368
-				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAircraftType : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3558
+				if ($globalDebugTimeElapsed) {
3559
+					echo 'ADD SPOTTER DATA : Time elapsed for getAllAircraftType : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3560
+				}
3369 3561
 				if ($aircraft_icao == "" || $aircraft_icao == "XXXX")
3370 3562
 				{
3371 3563
 					$timeelapsed = microtime(true);
3372 3564
 					$aircraft_array = $this->getAllAircraftInfo("NA");
3373
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3565
+					if ($globalDebugTimeElapsed) {
3566
+						echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3567
+					}
3374 3568
 				} else {
3375 3569
 					$timeelapsed = microtime(true);
3376 3570
 					$aircraft_array = $this->getAllAircraftInfo($aircraft_icao);
3377
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3571
+					if ($globalDebugTimeElapsed) {
3572
+						echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3573
+					}
3378 3574
 				}
3379 3575
 			}
3380 3576
 		}
@@ -3389,7 +3585,9 @@  discard block
 block discarded – undo
3389 3585
 			} else {
3390 3586
 				$timeelapsed = microtime(true);
3391 3587
 				$departure_airport_array = $this->getAllAirportInfo($departure_airport_icao);
3392
-				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3588
+				if ($globalDebugTimeElapsed) {
3589
+					echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3590
+				}
3393 3591
 			}
3394 3592
 		}
3395 3593
 		
@@ -3403,7 +3601,9 @@  discard block
 block discarded – undo
3403 3601
 			} else {
3404 3602
 				$timeelapsed = microtime(true);
3405 3603
 				$arrival_airport_array = $this->getAllAirportInfo($arrival_airport_icao);
3406
-				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3604
+				if ($globalDebugTimeElapsed) {
3605
+					echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3606
+				}
3407 3607
 			}
3408 3608
 		}
3409 3609
 
@@ -3438,7 +3638,9 @@  discard block
 block discarded – undo
3438 3638
 			{
3439 3639
 				return false;
3440 3640
 			}
3441
-		} else $altitude = 0;
3641
+		} else {
3642
+			$altitude = 0;
3643
+		}
3442 3644
 		
3443 3645
 		if ($heading != "")
3444 3646
 		{
@@ -3467,7 +3669,9 @@  discard block
 block discarded – undo
3467 3669
 		{
3468 3670
 			$timeelapsed = microtime(true);
3469 3671
 			$image_array = $Image->getSpotterImage($registration);
3470
-			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getSpotterImage : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3672
+			if ($globalDebugTimeElapsed) {
3673
+				echo 'ADD SPOTTER DATA : Time elapsed for getSpotterImage : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3674
+			}
3471 3675
 			if (!isset($image_array[0]['registration']))
3472 3676
 			{
3473 3677
 				//echo "Add image !!!! \n";
@@ -3475,14 +3679,21 @@  discard block
 block discarded – undo
3475 3679
 			}
3476 3680
 			$timeelapsed = microtime(true);
3477 3681
 			$owner_info = $this->getAircraftOwnerByRegistration($registration);
3478
-			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftOwnerByRegistration : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3479
-			if ($owner_info['owner'] != '') $aircraft_owner = ucwords(strtolower($owner_info['owner']));
3682
+			if ($globalDebugTimeElapsed) {
3683
+				echo 'ADD SPOTTER DATA : Time elapsed for getAircraftOwnerByRegistration : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3684
+			}
3685
+			if ($owner_info['owner'] != '') {
3686
+				$aircraft_owner = ucwords(strtolower($owner_info['owner']));
3687
+			}
3480 3688
 		}
3481 3689
     
3482 3690
 		if ($globalIVAO && $aircraft_icao != '')
3483 3691
 		{
3484
-            		if (isset($airline_array[0]['icao'])) $airline_icao = $airline_array[0]['icao'];
3485
-            		else $airline_icao = '';
3692
+            		if (isset($airline_array[0]['icao'])) {
3693
+            			$airline_icao = $airline_array[0]['icao'];
3694
+            		} else {
3695
+            			$airline_icao = '';
3696
+            		}
3486 3697
 			$image_array = $Image->getSpotterImage('',$aircraft_icao,$airline_icao);
3487 3698
 			if (!isset($image_array[0]['registration']))
3488 3699
 			{
@@ -3527,16 +3738,28 @@  discard block
 block discarded – undo
3527 3738
                 {
3528 3739
                         $arrival_airport_array = $this->getAllAirportInfo('NA');
3529 3740
                 }
3530
-                if ($registration == '') $registration = 'NA';
3741
+                if ($registration == '') {
3742
+                	$registration = 'NA';
3743
+                }
3531 3744
                 if ($latitude == '' && $longitude == '') {
3532 3745
             		$latitude = 0;
3533 3746
             		$longitude = 0;
3534 3747
             	}
3535
-                if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL;
3536
-                if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL;
3537
-                if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
3538
-                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
3539
-                if (!isset($aircraft_owner)) $aircraft_owner = NULL;
3748
+                if ($squawk == '' || $Common->isInteger($squawk) === false) {
3749
+                	$squawk = NULL;
3750
+                }
3751
+                if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) {
3752
+                	$verticalrate = NULL;
3753
+                }
3754
+                if ($heading == '' || $Common->isInteger($heading) === false) {
3755
+                	$heading = 0;
3756
+                }
3757
+                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) {
3758
+                	$groundspeed = 0;
3759
+                }
3760
+                if (!isset($aircraft_owner)) {
3761
+                	$aircraft_owner = NULL;
3762
+                }
3540 3763
                 $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) 
3541 3764
                 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)";
3542 3765
 
@@ -3547,9 +3770,13 @@  discard block
 block discarded – undo
3547 3770
 		if ($airline_type == '') {
3548 3771
 			$timeelapsed = microtime(true);
3549 3772
 			$airline_type = $this->getAircraftTypeBymodeS($ModeS);
3550
-			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftTypeBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3773
+			if ($globalDebugTimeElapsed) {
3774
+				echo 'ADD SPOTTER DATA : Time elapsed for getAircraftTypeBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3775
+			}
3776
+		}
3777
+		if ($airline_type == null) {
3778
+			$airline_type = '';
3551 3779
 		}
3552
-		if ($airline_type == null) $airline_type = '';
3553 3780
                 $aircraft_type = $aircraft_array[0]['type'];
3554 3781
                 $aircraft_manufacturer = $aircraft_array[0]['manufacturer'];
3555 3782
                 $departure_airport_name = $departure_airport_array[0]['name'];
@@ -3684,7 +3911,9 @@  discard block
 block discarded – undo
3684 3911
 			}
3685 3912
 		}
3686 3913
 		$query .= "GROUP BY spotter_output.airline_name,spotter_output.airline_icao, spotter_output.airline_country ORDER BY airline_count DESC";
3687
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
3914
+		if ($limit) {
3915
+			$query .= " LIMIT 10 OFFSET 0";
3916
+		}
3688 3917
 		
3689 3918
 		$sth = $this->db->prepare($query);
3690 3919
 		$sth->execute();
@@ -3729,7 +3958,9 @@  discard block
 block discarded – undo
3729 3958
 			}
3730 3959
 		}
3731 3960
 		$query .= "GROUP BY spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.format_source ORDER BY pilot_count DESC";
3732
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
3961
+		if ($limit) {
3962
+			$query .= " LIMIT 10 OFFSET 0";
3963
+		}
3733 3964
       
3734 3965
 		
3735 3966
 		$sth = $this->db->prepare($query);
@@ -3775,7 +4006,9 @@  discard block
 block discarded – undo
3775 4006
 			}
3776 4007
 		}
3777 4008
 		$query .= "GROUP BY spotter_output.airline_icao, spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.format_source ORDER BY pilot_count DESC";
3778
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4009
+		if ($limit) {
4010
+			$query .= " LIMIT 10 OFFSET 0";
4011
+		}
3779 4012
       
3780 4013
 		
3781 4014
 		$sth = $this->db->prepare($query);
@@ -3823,7 +4056,9 @@  discard block
 block discarded – undo
3823 4056
 			}
3824 4057
 		}
3825 4058
 		$query .= "GROUP BY spotter_output.owner_name ORDER BY owner_count DESC";
3826
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4059
+		if ($limit) {
4060
+			$query .= " LIMIT 10 OFFSET 0";
4061
+		}
3827 4062
       
3828 4063
 		
3829 4064
 		$sth = $this->db->prepare($query);
@@ -3868,7 +4103,9 @@  discard block
 block discarded – undo
3868 4103
 			}
3869 4104
 		}
3870 4105
 		$query .= "GROUP BY spotter_output.airline_icao, spotter_output.owner_name ORDER BY owner_count DESC";
3871
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4106
+		if ($limit) {
4107
+			$query .= " LIMIT 10 OFFSET 0";
4108
+		}
3872 4109
       
3873 4110
 		
3874 4111
 		$sth = $this->db->prepare($query);
@@ -4111,7 +4348,9 @@  discard block
 block discarded – undo
4111 4348
 			date_default_timezone_set($globalTimezone);
4112 4349
 			$datetime = new DateTime($date);
4113 4350
 			$offset = $datetime->format('P');
4114
-		} else $offset = '+00:00';
4351
+		} else {
4352
+			$offset = '+00:00';
4353
+		}
4115 4354
 
4116 4355
 		if ($globalDBdriver == 'mysql') {
4117 4356
 			$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
@@ -4159,7 +4398,9 @@  discard block
 block discarded – undo
4159 4398
 			date_default_timezone_set($globalTimezone);
4160 4399
 			$datetime = new DateTime($date);
4161 4400
 			$offset = $datetime->format('P');
4162
-		} else $offset = '+00:00';
4401
+		} else {
4402
+			$offset = '+00:00';
4403
+		}
4163 4404
 		
4164 4405
 		if ($globalDBdriver == 'mysql') {
4165 4406
 			$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
@@ -4377,7 +4618,9 @@  discard block
 block discarded – undo
4377 4618
 		 			FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND spotter_output.airline_country <> 'NA' 
4378 4619
 					GROUP BY spotter_output.airline_country
4379 4620
 					ORDER BY airline_country_count DESC";
4380
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4621
+		if ($limit) {
4622
+			$query .= " LIMIT 10 OFFSET 0";
4623
+		}
4381 4624
       
4382 4625
 		$sth = $this->db->prepare($query);
4383 4626
 		$sth->execute();
@@ -4405,7 +4648,9 @@  discard block
 block discarded – undo
4405 4648
 		global $globalDBdriver;
4406 4649
 		//$filter_query = $this->getFilter($filters,true,true);
4407 4650
 		$Connection= new Connection($this->db);
4408
-		if (!$Connection->tableExists('countries')) return array();
4651
+		if (!$Connection->tableExists('countries')) {
4652
+			return array();
4653
+		}
4409 4654
 		/*
4410 4655
 		$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
4411 4656
 					FROM countries c, spotter_output s
@@ -4437,7 +4682,9 @@  discard block
 block discarded – undo
4437 4682
 		}
4438 4683
 		$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb FROM countries c INNER JOIN (SELECT DISTINCT flightaware_id,over_country FROM spotter_live".$filter_query.") l ON c.iso2 = l.over_country ";
4439 4684
 		$query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC";
4440
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4685
+		if ($limit) {
4686
+			$query .= " LIMIT 10 OFFSET 0";
4687
+		}
4441 4688
       
4442 4689
 		
4443 4690
 		$sth = $this->db->prepare($query);
@@ -4487,7 +4734,9 @@  discard block
 block discarded – undo
4487 4734
 		}
4488 4735
 
4489 4736
 		$query .= " GROUP BY spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer ORDER BY aircraft_icao_count DESC";
4490
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4737
+		if ($limit) {
4738
+			$query .= " LIMIT 10 OFFSET 0";
4739
+		}
4491 4740
  
4492 4741
 		$sth = $this->db->prepare($query);
4493 4742
 		$sth->execute();
@@ -4533,7 +4782,9 @@  discard block
 block discarded – undo
4533 4782
 		}
4534 4783
 
4535 4784
 		$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";
4536
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4785
+		if ($limit) {
4786
+			$query .= " LIMIT 10 OFFSET 0";
4787
+		}
4537 4788
  
4538 4789
 		$sth = $this->db->prepare($query);
4539 4790
 		$sth->execute();
@@ -4580,7 +4831,9 @@  discard block
 block discarded – undo
4580 4831
 		}
4581 4832
 
4582 4833
 		$query .= "GROUP BY EXTRACT(month from spotter_output.date), EXTRACT(year from spotter_output.date), spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer ORDER BY aircraft_icao_count DESC";
4583
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4834
+		if ($limit) {
4835
+			$query .= " LIMIT 10 OFFSET 0";
4836
+		}
4584 4837
  
4585 4838
 		$sth = $this->db->prepare($query);
4586 4839
 		$sth->execute();
@@ -4633,7 +4886,9 @@  discard block
 block discarded – undo
4633 4886
 			if($row['registration'] != "")
4634 4887
 			{
4635 4888
 				$image_array = $Image->getSpotterImage($row['registration']);
4636
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
4889
+				if (isset($image_array[0]['image_thumbnail'])) {
4890
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
4891
+				}
4637 4892
 			}
4638 4893
 			$temp_array['registration_count'] = $row['registration_count'];
4639 4894
 
@@ -4708,7 +4963,9 @@  discard block
 block discarded – undo
4708 4963
 			if($row['registration'] != "")
4709 4964
 			{
4710 4965
 				$image_array = $Image->getSpotterImage($row['registration']);
4711
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
4966
+				if (isset($image_array[0]['image_thumbnail'])) {
4967
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
4968
+				}
4712 4969
 			}
4713 4970
 			$temp_array['registration_count'] = $row['registration_count'];
4714 4971
 
@@ -4815,7 +5072,9 @@  discard block
 block discarded – undo
4815 5072
 			if($row['registration'] != "")
4816 5073
 			{
4817 5074
 				$image_array = $Image->getSpotterImage($row['registration']);
4818
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5075
+				if (isset($image_array[0]['image_thumbnail'])) {
5076
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5077
+				}
4819 5078
 			}
4820 5079
 			$temp_array['registration_count'] = $row['registration_count'];
4821 5080
 			$aircraft_array[] = $temp_array;
@@ -4940,7 +5199,9 @@  discard block
 block discarded – undo
4940 5199
 			date_default_timezone_set($globalTimezone);
4941 5200
 			$datetime = new DateTime($date);
4942 5201
 			$offset = $datetime->format('P');
4943
-		} else $offset = '+00:00';
5202
+		} else {
5203
+			$offset = '+00:00';
5204
+		}
4944 5205
 
4945 5206
 		if ($globalDBdriver == 'mysql') {
4946 5207
 			$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
@@ -4987,7 +5248,9 @@  discard block
 block discarded – undo
4987 5248
 			date_default_timezone_set($globalTimezone);
4988 5249
 			$datetime = new DateTime($date);
4989 5250
 			$offset = $datetime->format('P');
4990
-		} else $offset = '+00:00';
5251
+		} else {
5252
+			$offset = '+00:00';
5253
+		}
4991 5254
 
4992 5255
 		if ($globalDBdriver == 'mysql') {
4993 5256
 			$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 
@@ -5016,7 +5279,9 @@  discard block
 block discarded – undo
5016 5279
 			if($row['registration'] != "")
5017 5280
 			{
5018 5281
 				$image_array = $Image->getSpotterImage($row['registration']);
5019
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5282
+				if (isset($image_array[0]['image_thumbnail'])) {
5283
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5284
+				}
5020 5285
 			}
5021 5286
 			$temp_array['registration_count'] = $row['registration_count'];
5022 5287
  
@@ -5041,7 +5306,9 @@  discard block
 block discarded – undo
5041 5306
 			date_default_timezone_set($globalTimezone);
5042 5307
 			$datetime = new DateTime($date);
5043 5308
 			$offset = $datetime->format('P');
5044
-		} else $offset = '+00:00';
5309
+		} else {
5310
+			$offset = '+00:00';
5311
+		}
5045 5312
 
5046 5313
 		if ($globalDBdriver == 'mysql') {
5047 5314
 			$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
@@ -5139,8 +5406,11 @@  discard block
 block discarded – undo
5139 5406
 			if($row['registration'] != "")
5140 5407
 			{
5141 5408
 				$image_array = $Image->getSpotterImage($row['registration']);
5142
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5143
-				else $temp_array['image_thumbnail'] = '';
5409
+				if (isset($image_array[0]['image_thumbnail'])) {
5410
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5411
+				} else {
5412
+					$temp_array['image_thumbnail'] = '';
5413
+				}
5144 5414
 			}
5145 5415
 			$temp_array['registration_count'] = $row['registration_count'];
5146 5416
 			$aircraft_array[] = $temp_array;
@@ -5247,7 +5517,9 @@  discard block
 block discarded – undo
5247 5517
 			if($row['registration'] != "")
5248 5518
 			{
5249 5519
 				$image_array = $Image->getSpotterImage($row['registration']);
5250
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5520
+				if (isset($image_array[0]['image_thumbnail'])) {
5521
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5522
+				}
5251 5523
 			}
5252 5524
 			$temp_array['registration_count'] = $row['registration_count'];
5253 5525
           
@@ -5364,7 +5636,9 @@  discard block
 block discarded – undo
5364 5636
 			if($row['registration'] != "")
5365 5637
 			{
5366 5638
 				$image_array = $Image->getSpotterImage($row['registration']);
5367
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5639
+				if (isset($image_array[0]['image_thumbnail'])) {
5640
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5641
+				}
5368 5642
 			}
5369 5643
 			$temp_array['registration_count'] = $row['registration_count'];
5370 5644
           
@@ -5476,7 +5750,9 @@  discard block
 block discarded – undo
5476 5750
 		// if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
5477 5751
 		//if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
5478 5752
                 $query .= " GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name ORDER BY aircraft_registration_count DESC";
5479
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5753
+		if ($limit) {
5754
+			$query .= " LIMIT 10 OFFSET 0";
5755
+		}
5480 5756
 		
5481 5757
 		$sth = $this->db->prepare($query);
5482 5758
 		$sth->execute();
@@ -5495,7 +5771,9 @@  discard block
 block discarded – undo
5495 5771
 			if($row['registration'] != "")
5496 5772
 			{
5497 5773
 				$image_array = $Image->getSpotterImage($row['registration']);
5498
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5774
+				if (isset($image_array[0]['image_thumbnail'])) {
5775
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5776
+				}
5499 5777
 			}
5500 5778
           
5501 5779
 			$aircraft_array[] = $temp_array;
@@ -5536,7 +5814,9 @@  discard block
 block discarded – undo
5536 5814
 		// if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
5537 5815
 		//if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
5538 5816
                 $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";
5539
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5817
+		if ($limit) {
5818
+			$query .= " LIMIT 10 OFFSET 0";
5819
+		}
5540 5820
 		
5541 5821
 		$sth = $this->db->prepare($query);
5542 5822
 		$sth->execute();
@@ -5556,7 +5836,9 @@  discard block
 block discarded – undo
5556 5836
 			if($row['registration'] != "")
5557 5837
 			{
5558 5838
 				$image_array = $Image->getSpotterImage($row['registration']);
5559
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5839
+				if (isset($image_array[0]['image_thumbnail'])) {
5840
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5841
+				}
5560 5842
 			}
5561 5843
           
5562 5844
 			$aircraft_array[] = $temp_array;
@@ -5597,7 +5879,9 @@  discard block
 block discarded – undo
5597 5879
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
5598 5880
                 $query .= " GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
5599 5881
 				ORDER BY airport_departure_icao_count DESC";
5600
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5882
+		if ($limit) {
5883
+			$query .= " LIMIT 10 OFFSET 0";
5884
+		}
5601 5885
       
5602 5886
 		$sth = $this->db->prepare($query);
5603 5887
 		$sth->execute();
@@ -5649,7 +5933,9 @@  discard block
 block discarded – undo
5649 5933
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
5650 5934
                 $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
5651 5935
 				ORDER BY airport_departure_icao_count DESC";
5652
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5936
+		if ($limit) {
5937
+			$query .= " LIMIT 10 OFFSET 0";
5938
+		}
5653 5939
       
5654 5940
 		$sth = $this->db->prepare($query);
5655 5941
 		$sth->execute();
@@ -5701,7 +5987,9 @@  discard block
 block discarded – undo
5701 5987
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
5702 5988
                 $query .= " GROUP BY spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country
5703 5989
 				ORDER BY airport_departure_icao_count DESC";
5704
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5990
+		if ($limit) {
5991
+			$query .= " LIMIT 10 OFFSET 0";
5992
+		}
5705 5993
     		//echo $query;
5706 5994
 		$sth = $this->db->prepare($query);
5707 5995
 		$sth->execute();
@@ -5753,7 +6041,9 @@  discard block
 block discarded – undo
5753 6041
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
5754 6042
                 $query .= "GROUP BY spotter_output.airline_icao, spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country
5755 6043
 				ORDER BY airport_departure_icao_count DESC";
5756
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
6044
+		if ($limit) {
6045
+			$query .= " LIMIT 10 OFFSET 0";
6046
+		}
5757 6047
       
5758 6048
 		$sth = $this->db->prepare($query);
5759 6049
 		$sth->execute();
@@ -6148,7 +6438,9 @@  discard block
 block discarded – undo
6148 6438
 			date_default_timezone_set($globalTimezone);
6149 6439
 			$datetime = new DateTime($date);
6150 6440
 			$offset = $datetime->format('P');
6151
-		} else $offset = '+00:00';
6441
+		} else {
6442
+			$offset = '+00:00';
6443
+		}
6152 6444
 
6153 6445
 		if ($globalDBdriver == 'mysql') {
6154 6446
 			$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 
@@ -6198,7 +6490,9 @@  discard block
 block discarded – undo
6198 6490
 			date_default_timezone_set($globalTimezone);
6199 6491
 			$datetime = new DateTime($date);
6200 6492
 			$offset = $datetime->format('P');
6201
-		} else $offset = '+00:00';
6493
+		} else {
6494
+			$offset = '+00:00';
6495
+		}
6202 6496
 
6203 6497
 		if ($globalDBdriver == 'mysql') {
6204 6498
 			$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
@@ -6411,7 +6705,9 @@  discard block
 block discarded – undo
6411 6705
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6412 6706
                 $query .= " GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
6413 6707
 					ORDER BY airport_arrival_icao_count DESC";
6414
-		if ($limit) $query .= " LIMIT 10";
6708
+		if ($limit) {
6709
+			$query .= " LIMIT 10";
6710
+		}
6415 6711
       
6416 6712
 		
6417 6713
 		$sth = $this->db->prepare($query);
@@ -6431,7 +6727,9 @@  discard block
 block discarded – undo
6431 6727
 			if ($icaoaskey) {
6432 6728
 				$icao = $row['arrival_airport_icao'];
6433 6729
 				$airport_array[$icao] = $temp_array;
6434
-			} else $airport_array[] = $temp_array;
6730
+			} else {
6731
+				$airport_array[] = $temp_array;
6732
+			}
6435 6733
 		}
6436 6734
 
6437 6735
 		return $airport_array;
@@ -6473,7 +6771,9 @@  discard block
 block discarded – undo
6473 6771
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6474 6772
                 $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
6475 6773
 					ORDER BY airport_arrival_icao_count DESC";
6476
-		if ($limit) $query .= " LIMIT 10";
6774
+		if ($limit) {
6775
+			$query .= " LIMIT 10";
6776
+		}
6477 6777
       
6478 6778
 		
6479 6779
 		$sth = $this->db->prepare($query);
@@ -6494,7 +6794,9 @@  discard block
 block discarded – undo
6494 6794
 			if ($icaoaskey) {
6495 6795
 				$icao = $row['arrival_airport_icao'];
6496 6796
 				$airport_array[$icao] = $temp_array;
6497
-			} else $airport_array[] = $temp_array;
6797
+			} else {
6798
+				$airport_array[] = $temp_array;
6799
+			}
6498 6800
 		}
6499 6801
 
6500 6802
 		return $airport_array;
@@ -6536,7 +6838,9 @@  discard block
 block discarded – undo
6536 6838
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6537 6839
                 $query .= " GROUP BY spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country
6538 6840
 					ORDER BY airport_arrival_icao_count DESC";
6539
-		if ($limit) $query .= " LIMIT 10";
6841
+		if ($limit) {
6842
+			$query .= " LIMIT 10";
6843
+		}
6540 6844
       
6541 6845
 		
6542 6846
 		$sth = $this->db->prepare($query);
@@ -6556,7 +6860,9 @@  discard block
 block discarded – undo
6556 6860
 			if ($icaoaskey) {
6557 6861
 				$icao = $row['arrival_airport_icao'];
6558 6862
 				$airport_array[$icao] = $temp_array;
6559
-			} else $airport_array[] = $temp_array;
6863
+			} else {
6864
+				$airport_array[] = $temp_array;
6865
+			}
6560 6866
 		}
6561 6867
 
6562 6868
 		return $airport_array;
@@ -6598,7 +6904,9 @@  discard block
 block discarded – undo
6598 6904
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6599 6905
                 $query .= "GROUP BY spotter_output.airline_icao, spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country
6600 6906
 					ORDER BY airport_arrival_icao_count DESC";
6601
-		if ($limit) $query .= " LIMIT 10";
6907
+		if ($limit) {
6908
+			$query .= " LIMIT 10";
6909
+		}
6602 6910
       
6603 6911
 		
6604 6912
 		$sth = $this->db->prepare($query);
@@ -6619,7 +6927,9 @@  discard block
 block discarded – undo
6619 6927
 			if ($icaoaskey) {
6620 6928
 				$icao = $row['arrival_airport_icao'];
6621 6929
 				$airport_array[$icao] = $temp_array;
6622
-			} else $airport_array[] = $temp_array;
6930
+			} else {
6931
+				$airport_array[] = $temp_array;
6932
+			}
6623 6933
 		}
6624 6934
 
6625 6935
 		return $airport_array;
@@ -7000,7 +7310,9 @@  discard block
 block discarded – undo
7000 7310
 			date_default_timezone_set($globalTimezone);
7001 7311
 			$datetime = new DateTime($date);
7002 7312
 			$offset = $datetime->format('P');
7003
-		} else $offset = '+00:00';
7313
+		} else {
7314
+			$offset = '+00:00';
7315
+		}
7004 7316
 
7005 7317
 		if ($globalDBdriver == 'mysql') {
7006 7318
 			$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 
@@ -7050,7 +7362,9 @@  discard block
 block discarded – undo
7050 7362
 			date_default_timezone_set($globalTimezone);
7051 7363
 			$datetime = new DateTime($date);
7052 7364
 			$offset = $datetime->format('P');
7053
-		} else $offset = '+00:00';
7365
+		} else {
7366
+			$offset = '+00:00';
7367
+		}
7054 7368
 
7055 7369
 		if ($globalDBdriver == 'mysql') {
7056 7370
 			$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
@@ -7273,7 +7587,9 @@  discard block
 block discarded – undo
7273 7587
 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.arrival_airport_icao <> 'NA'";
7274 7588
 		$query .= " GROUP BY spotter_output.arrival_airport_country
7275 7589
 					ORDER BY airport_arrival_country_count DESC";
7276
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
7590
+		if ($limit) {
7591
+			$query .= " LIMIT 10 OFFSET 0";
7592
+		}
7277 7593
       
7278 7594
 		
7279 7595
 		$sth = $this->db->prepare($query);
@@ -7560,7 +7876,9 @@  discard block
 block discarded – undo
7560 7876
 			date_default_timezone_set($globalTimezone);
7561 7877
 			$datetime = new DateTime($date);
7562 7878
 			$offset = $datetime->format('P');
7563
-		} else $offset = '+00:00';
7879
+		} else {
7880
+			$offset = '+00:00';
7881
+		}
7564 7882
 		
7565 7883
 		if ($globalDBdriver == 'mysql') {
7566 7884
 			$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
@@ -7736,15 +8054,23 @@  discard block
 block discarded – undo
7736 8054
 		$query  = "SELECT DISTINCT spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name, spotter_output.airline_icao  
7737 8055
                     FROM spotter_output".$filter_query." spotter_output.ident <> '' ";
7738 8056
 		 if ($olderthanmonths > 0) {
7739
-			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
7740
-			else $query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
8057
+			if ($globalDBdriver == 'mysql') {
8058
+				$query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
8059
+			} else {
8060
+				$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
8061
+			}
7741 8062
 		}
7742 8063
 		if ($sincedate != '') {
7743
-			if ($globalDBdriver == 'mysql') $query .= " AND spotter_output.date > '".$sincedate."'";
7744
-			else $query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
8064
+			if ($globalDBdriver == 'mysql') {
8065
+				$query .= " AND spotter_output.date > '".$sincedate."'";
8066
+			} else {
8067
+				$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
8068
+			}
7745 8069
 		}
7746 8070
 		$query .= " GROUP BY spotter_output.ident, spotter_output.airline_name, spotter_output.airline_icao ORDER BY callsign_icao_count DESC";
7747
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
8071
+		if ($limit) {
8072
+			$query .= " LIMIT 10 OFFSET 0";
8073
+		}
7748 8074
       		
7749 8075
 		$sth = $this->db->prepare($query);
7750 8076
 		$sth->execute();
@@ -7778,15 +8104,23 @@  discard block
 block discarded – undo
7778 8104
 		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name  
7779 8105
                     FROM spotter_output".$filter_query." spotter_output.ident <> ''  AND spotter_output.airline_icao <> '' ";
7780 8106
 		 if ($olderthanmonths > 0) {
7781
-			if ($globalDBdriver == 'mysql') $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
7782
-			else $query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
8107
+			if ($globalDBdriver == 'mysql') {
8108
+				$query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
8109
+			} else {
8110
+				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
8111
+			}
7783 8112
 		}
7784 8113
 		if ($sincedate != '') {
7785
-			if ($globalDBdriver == 'mysql') $query .= "AND spotter_output.date > '".$sincedate."' ";
7786
-			else $query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP) ";
8114
+			if ($globalDBdriver == 'mysql') {
8115
+				$query .= "AND spotter_output.date > '".$sincedate."' ";
8116
+			} else {
8117
+				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP) ";
8118
+			}
7787 8119
 		}
7788 8120
 		$query .= "GROUP BY spotter_output.airline_icao, spotter_output.ident, spotter_output.airline_name, spotter_output.airline_icao ORDER BY callsign_icao_count DESC";
7789
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
8121
+		if ($limit) {
8122
+			$query .= " LIMIT 10 OFFSET 0";
8123
+		}
7790 8124
       		
7791 8125
 		$sth = $this->db->prepare($query);
7792 8126
 		$sth->execute();
@@ -7823,7 +8157,9 @@  discard block
 block discarded – undo
7823 8157
 			date_default_timezone_set($globalTimezone);
7824 8158
 			$datetime = new DateTime();
7825 8159
 			$offset = $datetime->format('P');
7826
-		} else $offset = '+00:00';
8160
+		} else {
8161
+			$offset = '+00:00';
8162
+		}
7827 8163
 
7828 8164
 		if ($globalDBdriver == 'mysql') {
7829 8165
 			$query  = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -7872,7 +8208,9 @@  discard block
 block discarded – undo
7872 8208
 			date_default_timezone_set($globalTimezone);
7873 8209
 			$datetime = new DateTime();
7874 8210
 			$offset = $datetime->format('P');
7875
-		} else $offset = '+00:00';
8211
+		} else {
8212
+			$offset = '+00:00';
8213
+		}
7876 8214
 		$filter_query = $this->getFilter($filters,true,true);
7877 8215
 		if ($globalDBdriver == 'mysql') {
7878 8216
 			$query  = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -7921,7 +8259,9 @@  discard block
 block discarded – undo
7921 8259
 			date_default_timezone_set($globalTimezone);
7922 8260
 			$datetime = new DateTime();
7923 8261
 			$offset = $datetime->format('P');
7924
-		} else $offset = '+00:00';
8262
+		} else {
8263
+			$offset = '+00:00';
8264
+		}
7925 8265
 		$filter_query = $this->getFilter($filters,true,true);
7926 8266
 		if ($globalDBdriver == 'mysql') {
7927 8267
 			$query  = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -7967,7 +8307,9 @@  discard block
 block discarded – undo
7967 8307
 			date_default_timezone_set($globalTimezone);
7968 8308
 			$datetime = new DateTime();
7969 8309
 			$offset = $datetime->format('P');
7970
-		} else $offset = '+00:00';
8310
+		} else {
8311
+			$offset = '+00:00';
8312
+		}
7971 8313
 		$filter_query = $this->getFilter($filters,true,true);
7972 8314
 		if ($globalDBdriver == 'mysql') {
7973 8315
 			$query  = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -8015,7 +8357,9 @@  discard block
 block discarded – undo
8015 8357
 			date_default_timezone_set($globalTimezone);
8016 8358
 			$datetime = new DateTime();
8017 8359
 			$offset = $datetime->format('P');
8018
-		} else $offset = '+00:00';
8360
+		} else {
8361
+			$offset = '+00:00';
8362
+		}
8019 8363
 		
8020 8364
 		if ($globalDBdriver == 'mysql') {
8021 8365
 			$query  = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -8063,7 +8407,9 @@  discard block
 block discarded – undo
8063 8407
 			date_default_timezone_set($globalTimezone);
8064 8408
 			$datetime = new DateTime();
8065 8409
 			$offset = $datetime->format('P');
8066
-		} else $offset = '+00:00';
8410
+		} else {
8411
+			$offset = '+00:00';
8412
+		}
8067 8413
 
8068 8414
 		if ($globalDBdriver == 'mysql') {
8069 8415
 			$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
@@ -8110,7 +8456,9 @@  discard block
 block discarded – undo
8110 8456
 			date_default_timezone_set($globalTimezone);
8111 8457
 			$datetime = new DateTime();
8112 8458
 			$offset = $datetime->format('P');
8113
-		} else $offset = '+00:00';
8459
+		} else {
8460
+			$offset = '+00:00';
8461
+		}
8114 8462
 
8115 8463
 		if ($globalDBdriver == 'mysql') {
8116 8464
 			$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
@@ -8158,7 +8506,9 @@  discard block
 block discarded – undo
8158 8506
 			date_default_timezone_set($globalTimezone);
8159 8507
 			$datetime = new DateTime();
8160 8508
 			$offset = $datetime->format('P');
8161
-		} else $offset = '+00:00';
8509
+		} else {
8510
+			$offset = '+00:00';
8511
+		}
8162 8512
 		$filter_query = $this->getFilter($filters,true,true);
8163 8513
 		if ($globalDBdriver == 'mysql') {
8164 8514
 			$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
@@ -8203,7 +8553,9 @@  discard block
 block discarded – undo
8203 8553
 			date_default_timezone_set($globalTimezone);
8204 8554
 			$datetime = new DateTime();
8205 8555
 			$offset = $datetime->format('P');
8206
-		} else $offset = '+00:00';
8556
+		} else {
8557
+			$offset = '+00:00';
8558
+		}
8207 8559
 		$filter_query = $this->getFilter($filters,true,true);
8208 8560
 
8209 8561
 		if ($globalDBdriver == 'mysql') {
@@ -8250,7 +8602,9 @@  discard block
 block discarded – undo
8250 8602
 			date_default_timezone_set($globalTimezone);
8251 8603
 			$datetime = new DateTime();
8252 8604
 			$offset = $datetime->format('P');
8253
-		} else $offset = '+00:00';
8605
+		} else {
8606
+			$offset = '+00:00';
8607
+		}
8254 8608
 
8255 8609
 		if ($globalDBdriver == 'mysql') {
8256 8610
 			$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
@@ -8296,7 +8650,9 @@  discard block
 block discarded – undo
8296 8650
 			date_default_timezone_set($globalTimezone);
8297 8651
 			$datetime = new DateTime();
8298 8652
 			$offset = $datetime->format('P');
8299
-		} else $offset = '+00:00';
8653
+		} else {
8654
+			$offset = '+00:00';
8655
+		}
8300 8656
 		$filter_query = $this->getFilter($filters,true,true);
8301 8657
 
8302 8658
 		if ($globalDBdriver == 'mysql') {
@@ -8343,7 +8699,9 @@  discard block
 block discarded – undo
8343 8699
 			date_default_timezone_set($globalTimezone);
8344 8700
 			$datetime = new DateTime();
8345 8701
 			$offset = $datetime->format('P');
8346
-		} else $offset = '+00:00';
8702
+		} else {
8703
+			$offset = '+00:00';
8704
+		}
8347 8705
 
8348 8706
 		if ($globalDBdriver == 'mysql') {
8349 8707
 			$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
@@ -8390,7 +8748,9 @@  discard block
 block discarded – undo
8390 8748
 			date_default_timezone_set($globalTimezone);
8391 8749
 			$datetime = new DateTime();
8392 8750
 			$offset = $datetime->format('P');
8393
-		} else $offset = '+00:00';
8751
+		} else {
8752
+			$offset = '+00:00';
8753
+		}
8394 8754
 
8395 8755
 		if ($globalDBdriver == 'mysql') {
8396 8756
 			$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
@@ -8435,7 +8795,9 @@  discard block
 block discarded – undo
8435 8795
 			date_default_timezone_set($globalTimezone);
8436 8796
 			$datetime = new DateTime();
8437 8797
 			$offset = $datetime->format('P');
8438
-		} else $offset = '+00:00';
8798
+		} else {
8799
+			$offset = '+00:00';
8800
+		}
8439 8801
 		$filter_query = $this->getFilter($filters,true,true);
8440 8802
 
8441 8803
 		if ($globalDBdriver == 'mysql') {
@@ -8483,7 +8845,9 @@  discard block
 block discarded – undo
8483 8845
 			date_default_timezone_set($globalTimezone);
8484 8846
 			$datetime = new DateTime();
8485 8847
 			$offset = $datetime->format('P');
8486
-		} else $offset = '+00:00';
8848
+		} else {
8849
+			$offset = '+00:00';
8850
+		}
8487 8851
 
8488 8852
 		if ($globalDBdriver == 'mysql') {
8489 8853
 			$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
@@ -8529,7 +8893,9 @@  discard block
 block discarded – undo
8529 8893
 			date_default_timezone_set($globalTimezone);
8530 8894
 			$datetime = new DateTime();
8531 8895
 			$offset = $datetime->format('P');
8532
-		} else $offset = '+00:00';
8896
+		} else {
8897
+			$offset = '+00:00';
8898
+		}
8533 8899
 		$filter_query = $this->getFilter($filters,true,true);
8534 8900
 
8535 8901
 		if ($globalDBdriver == 'mysql') {
@@ -8577,7 +8943,9 @@  discard block
 block discarded – undo
8577 8943
 			date_default_timezone_set($globalTimezone);
8578 8944
 			$datetime = new DateTime();
8579 8945
 			$offset = $datetime->format('P');
8580
-		} else $offset = '+00:00';
8946
+		} else {
8947
+			$offset = '+00:00';
8948
+		}
8581 8949
 
8582 8950
 		if ($globalDBdriver == 'mysql') {
8583 8951
 			$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
@@ -8624,7 +8992,9 @@  discard block
 block discarded – undo
8624 8992
 			date_default_timezone_set($globalTimezone);
8625 8993
 			$datetime = new DateTime();
8626 8994
 			$offset = $datetime->format('P');
8627
-		} else $offset = '+00:00';
8995
+		} else {
8996
+			$offset = '+00:00';
8997
+		}
8628 8998
 		$filter_query = $this->getFilter($filters,true,true);
8629 8999
 		if ($globalDBdriver == 'mysql') {
8630 9000
 			$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
@@ -8673,7 +9043,9 @@  discard block
 block discarded – undo
8673 9043
 			date_default_timezone_set($globalTimezone);
8674 9044
 			$datetime = new DateTime();
8675 9045
 			$offset = $datetime->format('P');
8676
-		} else $offset = '+00:00';
9046
+		} else {
9047
+			$offset = '+00:00';
9048
+		}
8677 9049
 
8678 9050
 		$orderby_sql = '';
8679 9051
 		if ($orderby == "hour")
@@ -8739,7 +9111,9 @@  discard block
 block discarded – undo
8739 9111
 			date_default_timezone_set($globalTimezone);
8740 9112
 			$datetime = new DateTime();
8741 9113
 			$offset = $datetime->format('P');
8742
-		} else $offset = '+00:00';
9114
+		} else {
9115
+			$offset = '+00:00';
9116
+		}
8743 9117
 
8744 9118
 		$orderby_sql = '';
8745 9119
 		if ($orderby == "hour")
@@ -8806,7 +9180,9 @@  discard block
 block discarded – undo
8806 9180
 			date_default_timezone_set($globalTimezone);
8807 9181
 			$datetime = new DateTime();
8808 9182
 			$offset = $datetime->format('P');
8809
-		} else $offset = '+00:00';
9183
+		} else {
9184
+			$offset = '+00:00';
9185
+		}
8810 9186
 
8811 9187
 		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
8812 9188
 
@@ -8857,7 +9233,9 @@  discard block
 block discarded – undo
8857 9233
 			date_default_timezone_set($globalTimezone);
8858 9234
 			$datetime = new DateTime();
8859 9235
 			$offset = $datetime->format('P');
8860
-		} else $offset = '+00:00';
9236
+		} else {
9237
+			$offset = '+00:00';
9238
+		}
8861 9239
 
8862 9240
 		if ($globalDBdriver == 'mysql') {
8863 9241
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -8904,7 +9282,9 @@  discard block
 block discarded – undo
8904 9282
 			date_default_timezone_set($globalTimezone);
8905 9283
 			$datetime = new DateTime();
8906 9284
 			$offset = $datetime->format('P');
8907
-		} else $offset = '+00:00';
9285
+		} else {
9286
+			$offset = '+00:00';
9287
+		}
8908 9288
 
8909 9289
 		if ($globalDBdriver == 'mysql') {
8910 9290
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -8951,7 +9331,9 @@  discard block
 block discarded – undo
8951 9331
 			date_default_timezone_set($globalTimezone);
8952 9332
 			$datetime = new DateTime();
8953 9333
 			$offset = $datetime->format('P');
8954
-		} else $offset = '+00:00';
9334
+		} else {
9335
+			$offset = '+00:00';
9336
+		}
8955 9337
 
8956 9338
 		if ($globalDBdriver == 'mysql') {
8957 9339
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -8999,7 +9381,9 @@  discard block
 block discarded – undo
8999 9381
 			date_default_timezone_set($globalTimezone);
9000 9382
 			$datetime = new DateTime();
9001 9383
 			$offset = $datetime->format('P');
9002
-		} else $offset = '+00:00';
9384
+		} else {
9385
+			$offset = '+00:00';
9386
+		}
9003 9387
 
9004 9388
 		if ($globalDBdriver == 'mysql') {
9005 9389
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -9047,7 +9431,9 @@  discard block
 block discarded – undo
9047 9431
 			date_default_timezone_set($globalTimezone);
9048 9432
 			$datetime = new DateTime($date);
9049 9433
 			$offset = $datetime->format('P');
9050
-		} else $offset = '+00:00';
9434
+		} else {
9435
+			$offset = '+00:00';
9436
+		}
9051 9437
 
9052 9438
 		if ($globalDBdriver == 'mysql') {
9053 9439
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -9095,7 +9481,9 @@  discard block
 block discarded – undo
9095 9481
 			date_default_timezone_set($globalTimezone);
9096 9482
 			$datetime = new DateTime();
9097 9483
 			$offset = $datetime->format('P');
9098
-		} else $offset = '+00:00';
9484
+		} else {
9485
+			$offset = '+00:00';
9486
+		}
9099 9487
 
9100 9488
 		if ($globalDBdriver == 'mysql') {
9101 9489
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -9145,7 +9533,9 @@  discard block
 block discarded – undo
9145 9533
 			date_default_timezone_set($globalTimezone);
9146 9534
 			$datetime = new DateTime();
9147 9535
 			$offset = $datetime->format('P');
9148
-		} else $offset = '+00:00';
9536
+		} else {
9537
+			$offset = '+00:00';
9538
+		}
9149 9539
 
9150 9540
 		if ($globalDBdriver == 'mysql') {
9151 9541
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -9192,7 +9582,9 @@  discard block
 block discarded – undo
9192 9582
 			date_default_timezone_set($globalTimezone);
9193 9583
 			$datetime = new DateTime();
9194 9584
 			$offset = $datetime->format('P');
9195
-		} else $offset = '+00:00';
9585
+		} else {
9586
+			$offset = '+00:00';
9587
+		}
9196 9588
 
9197 9589
 		if ($globalDBdriver == 'mysql') {
9198 9590
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -9360,7 +9752,9 @@  discard block
 block discarded – undo
9360 9752
 			date_default_timezone_set($globalTimezone);
9361 9753
 			$datetime = new DateTime();
9362 9754
 			$offset = $datetime->format('P');
9363
-		} else $offset = '+00:00';
9755
+		} else {
9756
+			$offset = '+00:00';
9757
+		}
9364 9758
 
9365 9759
 		if ($globalDBdriver == 'mysql') {
9366 9760
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -9546,7 +9940,9 @@  discard block
 block discarded – undo
9546 9940
 	*/
9547 9941
 	public function parseDirection($direction = 0)
9548 9942
 	{
9549
-		if ($direction == '') $direction = 0;
9943
+		if ($direction == '') {
9944
+			$direction = 0;
9945
+		}
9550 9946
 		$direction_array = array();
9551 9947
 		$temp_array = array();
9552 9948
 
@@ -9647,7 +10043,9 @@  discard block
 block discarded – undo
9647 10043
 		if (isset($result->AirlineFlightInfoResult))
9648 10044
 		{
9649 10045
 			$registration = $result->AirlineFlightInfoResult->tailnumber;
9650
-		} else return '';
10046
+		} else {
10047
+			return '';
10048
+		}
9651 10049
 		
9652 10050
 		$registration = $this->convertAircraftRegistration($registration);
9653 10051
 		
@@ -9676,7 +10074,9 @@  discard block
 block discarded – undo
9676 10074
 		if (count($row) > 0) {
9677 10075
 		    //return $row['Registration'];
9678 10076
 		    return $row['registration'];
9679
-		} else return '';
10077
+		} else {
10078
+			return '';
10079
+		}
9680 10080
 	
9681 10081
 	}
9682 10082
 
@@ -9699,9 +10099,14 @@  discard block
 block discarded – undo
9699 10099
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
9700 10100
 		$sth->closeCursor();
9701 10101
 		if (count($row) > 0) {
9702
-		    if ($row['type_flight'] == null) return '';
9703
-		    else return $row['type_flight'];
9704
-		} else return '';
10102
+		    if ($row['type_flight'] == null) {
10103
+		    	return '';
10104
+		    } else {
10105
+		    	return $row['type_flight'];
10106
+		    }
10107
+		} else {
10108
+			return '';
10109
+		}
9705 10110
 	
9706 10111
 	}
9707 10112
 
@@ -9719,7 +10124,9 @@  discard block
 block discarded – undo
9719 10124
 		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
9720 10125
 	
9721 10126
 		$Connection = new Connection($this->db);
9722
-		if (!$Connection->tableExists('countries')) return '';
10127
+		if (!$Connection->tableExists('countries')) {
10128
+			return '';
10129
+		}
9723 10130
 	
9724 10131
 		try {
9725 10132
 			/*
@@ -9739,9 +10146,13 @@  discard block
 block discarded – undo
9739 10146
 			$sth->closeCursor();
9740 10147
 			if (count($row) > 0) {
9741 10148
 				return $row;
9742
-			} else return '';
10149
+			} else {
10150
+				return '';
10151
+			}
9743 10152
 		} catch (PDOException $e) {
9744
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
10153
+			if (isset($globalDebug) && $globalDebug) {
10154
+				echo 'Error : '.$e->getMessage()."\n";
10155
+			}
9745 10156
 			return '';
9746 10157
 		}
9747 10158
 	
@@ -9759,7 +10170,9 @@  discard block
 block discarded – undo
9759 10170
 		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
9760 10171
 	
9761 10172
 		$Connection = new Connection($this->db);
9762
-		if (!$Connection->tableExists('countries')) return '';
10173
+		if (!$Connection->tableExists('countries')) {
10174
+			return '';
10175
+		}
9763 10176
 	
9764 10177
 		try {
9765 10178
 			$query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1";
@@ -9771,9 +10184,13 @@  discard block
 block discarded – undo
9771 10184
 			$sth->closeCursor();
9772 10185
 			if (count($row) > 0) {
9773 10186
 				return $row;
9774
-			} else return '';
10187
+			} else {
10188
+				return '';
10189
+			}
9775 10190
 		} catch (PDOException $e) {
9776
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
10191
+			if (isset($globalDebug) && $globalDebug) {
10192
+				echo 'Error : '.$e->getMessage()."\n";
10193
+			}
9777 10194
 			return '';
9778 10195
 		}
9779 10196
 	
@@ -9943,7 +10360,9 @@  discard block
 block discarded – undo
9943 10360
 	{
9944 10361
 		global $globalBitlyAccessToken;
9945 10362
 		
9946
-		if ($globalBitlyAccessToken == '') return $url;
10363
+		if ($globalBitlyAccessToken == '') {
10364
+			return $url;
10365
+		}
9947 10366
         
9948 10367
 		$google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url;
9949 10368
 		
@@ -10092,7 +10511,9 @@  discard block
 block discarded – undo
10092 10511
 		
10093 10512
 
10094 10513
 		// routes
10095
-		if ($globalDebug) print "Routes...\n";
10514
+		if ($globalDebug) {
10515
+			print "Routes...\n";
10516
+		}
10096 10517
 		if ($globalDBdriver == 'mysql') {
10097 10518
 			$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)";
10098 10519
 		} else {
@@ -10111,7 +10532,9 @@  discard block
 block discarded – undo
10111 10532
 			}
10112 10533
 		}
10113 10534
 		
10114
-		if ($globalDebug) print "Airlines...\n";
10535
+		if ($globalDebug) {
10536
+			print "Airlines...\n";
10537
+		}
10115 10538
 		//airlines
10116 10539
 		if ($globalDBdriver == 'mysql') {
10117 10540
 			$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)";
@@ -10125,10 +10548,15 @@  discard block
 block discarded – undo
10125 10548
 			if (is_numeric(substr($row['ident'], -1, 1)))
10126 10549
 			{
10127 10550
 				$fromsource = NULL;
10128
-				if (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
10129
-				elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') $fromsource = 'ivao';
10130
-				elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
10131
-				elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
10551
+				if (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') {
10552
+					$fromsource = 'vatsim';
10553
+				} elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') {
10554
+					$fromsource = 'ivao';
10555
+				} elseif (isset($globalVATSIM) && $globalVATSIM) {
10556
+					$fromsource = 'vatsim';
10557
+				} elseif (isset($globalIVAO) && $globalIVAO) {
10558
+					$fromsource = 'ivao';
10559
+				}
10132 10560
 				$airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 3),$fromsource);
10133 10561
 				if (isset($airline_array[0]['name'])) {
10134 10562
 					$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";
@@ -10138,13 +10566,17 @@  discard block
 block discarded – undo
10138 10566
 			}
10139 10567
 		}
10140 10568
 
10141
-		if ($globalDebug) print "Remove Duplicate in aircraft_modes...\n";
10569
+		if ($globalDebug) {
10570
+			print "Remove Duplicate in aircraft_modes...\n";
10571
+		}
10142 10572
 		//duplicate modes
10143 10573
 		$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";
10144 10574
 		$sth = $this->db->prepare($query);
10145 10575
 		$sth->execute();
10146 10576
 		
10147
-		if ($globalDebug) print "Aircraft...\n";
10577
+		if ($globalDebug) {
10578
+			print "Aircraft...\n";
10579
+		}
10148 10580
 		//aircraft
10149 10581
 		if ($globalDBdriver == 'mysql') {
10150 10582
 			$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)";
@@ -10187,26 +10619,38 @@  discard block
 block discarded – undo
10187 10619
 				 if (isset($closestAirports[0])) {
10188 10620
 					if ($row['arrival_airport_icao'] == $closestAirports[0]['icao']) {
10189 10621
 						$airport_icao = $closestAirports[0]['icao'];
10190
-						if ($globalDebug) echo "\o/ 1st ---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
10622
+						if ($globalDebug) {
10623
+							echo "\o/ 1st ---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
10624
+						}
10191 10625
 					} elseif (count($closestAirports > 1) && $row['arrival_airport_icao'] != '' && $row['arrival_airport_icao'] != 'NA') {
10192 10626
 						foreach ($closestAirports as $airport) {
10193 10627
 							if ($row['arrival_airport_icao'] == $airport['icao']) {
10194 10628
 								$airport_icao = $airport['icao'];
10195
-								if ($globalDebug) echo "\o/ try --++ Find arrival airport. airport_icao : ".$airport_icao."\n";
10629
+								if ($globalDebug) {
10630
+									echo "\o/ try --++ Find arrival airport. airport_icao : ".$airport_icao."\n";
10631
+								}
10196 10632
 								break;
10197 10633
 							}
10198 10634
 						}
10199 10635
 					} elseif ($row['last_altitude'] == 0 || ($row['last_altitude'] != '' && ($closestAirports[0]['altitude'] <= $row['last_altitude']*100+1000 && $row['last_altitude']*100 < $closestAirports[0]['altitude']+5000))) {
10200 10636
 						$airport_icao = $closestAirports[0]['icao'];
10201
-						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";
10637
+						if ($globalDebug) {
10638
+							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";
10639
+						}
10202 10640
 					} else {
10203
-						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";
10641
+						if ($globalDebug) {
10642
+							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";
10643
+						}
10204 10644
 					}
10205 10645
 				} else {
10206
-					if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist."\n";
10646
+					if ($globalDebug) {
10647
+						echo "----- No Airport near last coord. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist."\n";
10648
+					}
10207 10649
 				}
10208 10650
 				if ($row['real_arrival_airport_icao'] != $airport_icao) {
10209
-					if ($globalDebug) echo "Updating airport to ".$airport_icao."...\n";
10651
+					if ($globalDebug) {
10652
+						echo "Updating airport to ".$airport_icao."...\n";
10653
+					}
10210 10654
 					$update_query="UPDATE spotter_output SET real_arrival_airport_icao = :airport_icao WHERE spotter_id = :spotter_id";
10211 10655
 					$sthu = $this->db->prepare($update_query);
10212 10656
 					$sthu->execute(array(':airport_icao' => $airport_icao,':spotter_id' => $row['spotter_id']));
Please login to merge, or discard this patch.
accident-latest.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -38,8 +38,12 @@
 block discarded – undo
38 38
 if (!empty($spotter_array) && $spotter_array[0]['query_number_rows'] != 0) {
39 39
 	include('table-output.php');
40 40
 	print '<div class="pagination">';
41
-	if ($limit_previous_1 >= 0) print '<a href="'.$page_url.'/'.$limit_previous_1.','.$limit_previous_2.'">&laquo;'._("Previous Page").'</a>';
42
-	if ($spotter_array[0]['query_number_rows'] == $absolute_difference) print '<a href="'.$page_url.'/'.$limit_end.','.$limit_next.'">'._("Next Page").'&raquo;</a>';
41
+	if ($limit_previous_1 >= 0) {
42
+		print '<a href="'.$page_url.'/'.$limit_previous_1.','.$limit_previous_2.'">&laquo;'._("Previous Page").'</a>';
43
+	}
44
+	if ($spotter_array[0]['query_number_rows'] == $absolute_difference) {
45
+		print '<a href="'.$page_url.'/'.$limit_end.','.$limit_next.'">'._("Next Page").'&raquo;</a>';
46
+	}
43 47
 	print '</div>';
44 48
 }
45 49
 print '</div>';
Please login to merge, or discard this patch.
table-output.php 1 patch
Braces   +45 added lines, -17 removed lines patch added patch discarded remove patch
@@ -365,7 +365,9 @@  discard block
 block discarded – undo
365 365
 	if (isset($globalTimezone))
366 366
 	{
367 367
 		date_default_timezone_set($globalTimezone);
368
-	} else date_default_timezone_set('UTC');
368
+	} else {
369
+		date_default_timezone_set('UTC');
370
+	}
369 371
 	if ($showSpecial === true)
370 372
 	{
371 373
 		print '<tr class="special">'."\n";
@@ -384,8 +386,9 @@  discard block
 block discarded – undo
384 386
 			print '<td class="aircraft_thumbnail">'."\n";
385 387
 			
386 388
 			if ($spotter_item['image_source'] == 'planespotters') {
387
-				if ($spotter_item['image_source_website'] != '') $image_src = $spotter_item['image_source_website'];
388
-				else {
389
+				if ($spotter_item['image_source_website'] != '') {
390
+					$image_src = $spotter_item['image_source_website'];
391
+				} else {
389 392
 					$planespotter_url_array = explode("_", $spotter_item['image']);
390 393
 					$planespotter_id = str_replace(".jpg", "", $planespotter_url_array[1]);
391 394
                                         $image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id;
@@ -398,7 +401,9 @@  discard block
 block discarded – undo
398 401
                         } else {
399 402
                     		if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
400 403
                     		$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
401
-                    		} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
404
+                    		} else {
405
+                    			$image_thumbnail = $spotter_item['image_thumbnail'];
406
+                    		}
402 407
 				if (isset($spotter_item['airline_name'])) {
403 408
 					print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '.$spotter_item['airline_name'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
404 409
 				} else {
@@ -420,8 +425,9 @@  discard block
 block discarded – undo
420 425
 			print '<td class="aircraft_thumbnail">'."\n";
421 426
 			//print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$spotter_item['image_thumbnail'].'" alt="Click to see more information about this flight" title="Click to see more information about this flight" width="100px" /></a>';
422 427
 			if ($spotter_item['image_source'] == 'planespotters') {
423
-				if ($spotter_item['image_source_website'] != '') $image_src = $spotter_item['image_source_website'];
424
-				else {
428
+				if ($spotter_item['image_source_website'] != '') {
429
+					$image_src = $spotter_item['image_source_website'];
430
+				} else {
425 431
 					$planespotter_url_array = explode("_", $spotter_array[0]['image']);
426 432
 					$planespotter_id = str_replace(".jpg", "", $planespotter_url_array[1]);
427 433
                                         $image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id;
@@ -438,7 +444,9 @@  discard block
 block discarded – undo
438 444
 			} else {
439 445
                     		if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
440 446
                     		$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
441
-                    		} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
447
+                    		} else {
448
+                    			$image_thumbnail = $spotter_item['image_thumbnail'];
449
+                    		}
442 450
 				if (!isset($spotter_item['airline_name']) && isset($spotter_item['aircraft_name'])) {
443 451
 					print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
444 452
 				} elseif (!isset($spotter_item['aircraft_name']) && isset($spotter_item['airline_name'])) {
@@ -525,15 +533,21 @@  discard block
 block discarded – undo
525 533
 		if (isset($spotter_item['departure_airport_time']) && isset($spotter_item['real_departure_airport_time'])) {
526 534
 			if ($spotter_item['departure_airport_time'] > 2460) {
527 535
 				$departure_airport_time = date('H:m',$spotter_item['departure_airport_time']);
528
-			} else $departure_airport_time = substr($spotter_item['departure_airport_time'],0,-2).':'.substr($spotter_item['departure_airport_time'],-2);
536
+			} else {
537
+				$departure_airport_time = substr($spotter_item['departure_airport_time'],0,-2).':'.substr($spotter_item['departure_airport_time'],-2);
538
+			}
529 539
 			if ($spotter_item['real_departure_airport_time'] > 2460) {
530 540
 				$real_departure_airport_time = date('H:m',$spotter_item['real_departure_airport_time']);
531
-			} else $real_departure_airport_time = $spotter_item['real_departure_airport_time'];
541
+			} else {
542
+				$real_departure_airport_time = $spotter_item['real_departure_airport_time'];
543
+			}
532 544
 			print '<br /><span class="airport_time">'.$departure_airport_time.' ('.$real_departure_airport_time.')</span>'."\n";
533 545
 		} elseif (isset($spotter_item['real_departure_airport_time']) && $spotter_item['real_departure_airport_time'] != 'NULL') {
534 546
 			if ($spotter_item['real_departure_airport_time'] > 2460) {
535 547
 				$real_departure_airport_time = date('H:m',$spotter_item['real_departure_airport_time']);
536
-			} else $real_departure_airport_time = $spotter_item['real_departure_airport_time'];
548
+			} else {
549
+				$real_departure_airport_time = $spotter_item['real_departure_airport_time'];
550
+			}
537 551
 			print '<br /><span class="airport_time">'.$real_departure_airport_time.'</span>'."\n";
538 552
 		} elseif (isset($spotter_item['departure_airport_time']) && $spotter_item['departure_airport_time'] != 'NULL') {
539 553
 			if ($spotter_item['departure_airport_time'] > 2460) {
@@ -555,7 +569,9 @@  discard block
 block discarded – undo
555 569
 					$longitude = $spotter_item['longitude'];
556 570
 				}
557 571
 				$distance = $Spotter->getAirportDistance($spotter_item['departure_airport'],$latitude,$longitude);
558
-			} else $distance = '';
572
+			} else {
573
+				$distance = '';
574
+			}
559 575
 			if ($distance != '') {
560 576
 			    if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
561 577
 				    echo '<br/><i>'.round($distance*0.539957).' nm</i>';
@@ -580,7 +596,9 @@  discard block
 block discarded – undo
580 596
 		} else {
581 597
 			if (isset($spotter_item['real_arrival_airport']) && $spotter_item['real_arrival_airport'] != $spotter_item['arrival_airport']) {
582 598
 				print '<span class="nomobile">Scheduled : <a href="'.$globalURL.'/airport/'.$spotter_item['arrival_airport'].'">'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].' ('.$spotter_item['arrival_airport'].')</a></span>'."\n";
583
-				if (!isset($Spotter)) $Spotter = new Spotter();
599
+				if (!isset($Spotter)) {
600
+					$Spotter = new Spotter();
601
+				}
584 602
 				$arrival_airport_info = $Spotter->getAllAirportInfo($spotter_item['real_arrival_airport']);
585 603
 				print '<br /><span class="nomobile">'._("Real:").' <a href="'.$globalURL.'/airport/'.$spotter_item['real_arrival_airport'].'">'.$arrival_airport_info[0]['city'].','.$arrival_airport_info[0]['country'].' ('.$spotter_item['real_arrival_airport'].')</a></span>'."\n";
586 604
 				print '<span class="mobile">'._("Scheduled:").' <a href="'.$globalURL.'/airport/'.$spotter_item['real_arrival_airport'].'">'.$spotter_item['real_arrival_airport'].'</a></span>'."\n";
@@ -596,20 +614,28 @@  discard block
 block discarded – undo
596 614
 		if (isset($spotter_item['arrival_airport_time']) && isset($spotter_item['real_arrival_airport_time'])) {
597 615
 			if ($spotter_item['arrival_airport_time'] > 2460) {
598 616
 				$arrival_airport_time = date('H:m',$spotter_item['arrival_airport_time']);
599
-			} else $arrival_airport_time = $spotter_item['arrival_airport_time'];
617
+			} else {
618
+				$arrival_airport_time = $spotter_item['arrival_airport_time'];
619
+			}
600 620
 			if ($spotter_item['real_arrival_airport_time'] > 2460) {
601 621
 				$real_arrival_airport_time = date('H:m',$spotter_item['real_arrival_airport_time']);
602
-			} else $real_arrival_airport_time = $spotter_item['real_arrival_airport_time'];
622
+			} else {
623
+				$real_arrival_airport_time = $spotter_item['real_arrival_airport_time'];
624
+			}
603 625
 			print '<br /><span class="airport_time">'.$spotter_item['arrival_airport_time'].' ('.$spotter_item['real_arrival_airport_time'].')</span>'."\n";
604 626
 		} elseif (isset($spotter_item['real_arrival_airport_time'])) {
605 627
 			if ($spotter_item['real_arrival_airport_time'] > 2460) {
606 628
 				$real_arrival_airport_time = date('H:m',$spotter_item['real_arrival_airport_time']);
607
-			} else $real_arrival_airport_time = $spotter_item['real_arrival_airport_time'];
629
+			} else {
630
+				$real_arrival_airport_time = $spotter_item['real_arrival_airport_time'];
631
+			}
608 632
 			print '<br /><span class="airport_time">'.$real_arrival_airport_time.'</span>'."\n";
609 633
 		} elseif (isset($spotter_item['arrival_airport_time']) && $spotter_item['arrival_airport_time'] != 'NULL') {
610 634
 			if ($spotter_item['arrival_airport_time'] > 2460) {
611 635
 				$arrival_airport_time = date('H:m',$spotter_item['arrival_airport_time']);
612
-			} else $arrival_airport_time = $spotter_item['arrival_airport_time'];
636
+			} else {
637
+				$arrival_airport_time = $spotter_item['arrival_airport_time'];
638
+			}
613 639
 			print '<br /><span class="airport_time">'.$arrival_airport_time.'</span>'."\n";
614 640
 		}
615 641
 		if (!isset($spotter_item['real_arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') {
@@ -622,7 +648,9 @@  discard block
 block discarded – undo
622 648
 					$longitude = $spotter_item['longitude'];
623 649
 				}
624 650
 				$distance = $Spotter->getAirportDistance($spotter_item['arrival_airport'],$latitude,$longitude);
625
-			} else $distance = '';
651
+			} else {
652
+				$distance = '';
653
+			}
626 654
 				if ($distance != '') {
627 655
 				    if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
628 656
 					    echo '<br/><i>'.round($distance*0.539957).' nm</i>';
Please login to merge, or discard this patch.
install/class.update_db.php 1 patch
Braces   +828 added lines, -287 removed lines patch added patch discarded remove patch
@@ -16,7 +16,9 @@  discard block
 block discarded – undo
16 16
 		curl_setopt($ch, CURLOPT_URL, $url);
17 17
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
18 18
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
19
-		if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer);
19
+		if ($referer != '') {
20
+			curl_setopt($ch, CURLOPT_REFERER, $referer);
21
+		}
20 22
 		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5');
21 23
 		curl_setopt($ch, CURLOPT_FILE, $fp);
22 24
 		curl_exec($ch);
@@ -27,12 +29,16 @@  discard block
 block discarded – undo
27 29
 	public static function gunzip($in_file,$out_file_name = '') {
28 30
 		//echo $in_file.' -> '.$out_file_name."\n";
29 31
 		$buffer_size = 4096; // read 4kb at a time
30
-		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
32
+		if ($out_file_name == '') {
33
+			$out_file_name = str_replace('.gz', '', $in_file);
34
+		}
31 35
 		if ($in_file != '' && file_exists($in_file)) {
32 36
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
33
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
34
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
35
-			else {
37
+			if (function_exists('gzopen')) {
38
+				$file = gzopen($in_file,'rb');
39
+			} elseif (function_exists('gzopen64')) {
40
+				$file = gzopen64($in_file,'rb');
41
+			} else {
36 42
 				echo 'gzopen not available';
37 43
 				die;
38 44
 			}
@@ -53,8 +59,12 @@  discard block
 block discarded – undo
53 59
 			if ($res === TRUE) {
54 60
 				$zip->extractTo($path);
55 61
 				$zip->close();
56
-			} else return false;
57
-		} else return false;
62
+			} else {
63
+				return false;
64
+			}
65
+		} else {
66
+			return false;
67
+		}
58 68
 	}
59 69
 	
60 70
 	public static function connect_sqlite($database) {
@@ -69,7 +79,9 @@  discard block
 block discarded – undo
69 79
 	public static function retrieve_route_sqlite_to_dest($database_file) {
70 80
 		global $globalDebug, $globalTransaction;
71 81
 		//$query = 'TRUNCATE TABLE routes';
72
-		if ($globalDebug) echo " - Delete previous routes from DB -";
82
+		if ($globalDebug) {
83
+			echo " - Delete previous routes from DB -";
84
+		}
73 85
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
74 86
 		$Connection = new Connection();
75 87
 		try {
@@ -80,7 +92,9 @@  discard block
 block discarded – undo
80 92
                         return "error : ".$e->getMessage();
81 93
                 }
82 94
 
83
-    		if ($globalDebug) echo " - Add routes to DB -";
95
+    		if ($globalDebug) {
96
+    			echo " - Add routes to DB -";
97
+    		}
84 98
     		update_db::connect_sqlite($database_file);
85 99
 		//$query = 'select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID';
86 100
 		$query = "select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao, rstp.allstop AS AllStop from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID LEFT JOIN (select RouteId,GROUP_CONCAT(icao,' ') as allstop from routestop left join Airport as air ON routestop.AirportId = air.AirportID group by RouteID) AS rstp ON Route.RouteID = rstp.RouteID";
@@ -95,15 +109,21 @@  discard block
 block discarded – undo
95 109
 		$Connection = new Connection();
96 110
 		$sth_dest = $Connection->db->prepare($query_dest);
97 111
 		try {
98
-			if ($globalTransaction) $Connection->db->beginTransaction();
112
+			if ($globalTransaction) {
113
+				$Connection->db->beginTransaction();
114
+			}
99 115
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
100 116
 				//$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
101 117
 				$query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
102 118
 				$sth_dest->execute($query_dest_values);
103 119
             		}
104
-			if ($globalTransaction) $Connection->db->commit();
120
+			if ($globalTransaction) {
121
+				$Connection->db->commit();
122
+			}
105 123
 		} catch(PDOException $e) {
106
-			if ($globalTransaction) $Connection->db->rollBack(); 
124
+			if ($globalTransaction) {
125
+				$Connection->db->rollBack();
126
+			}
107 127
 			return "error : ".$e->getMessage();
108 128
 		}
109 129
                 return '';
@@ -111,7 +131,9 @@  discard block
 block discarded – undo
111 131
 	public static function retrieve_route_oneworld($database_file) {
112 132
 		global $globalDebug, $globalTransaction;
113 133
 		//$query = 'TRUNCATE TABLE routes';
114
-		if ($globalDebug) echo " - Delete previous routes from DB -";
134
+		if ($globalDebug) {
135
+			echo " - Delete previous routes from DB -";
136
+		}
115 137
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
116 138
 		$Connection = new Connection();
117 139
 		try {
@@ -122,14 +144,18 @@  discard block
 block discarded – undo
122 144
                         return "error : ".$e->getMessage();
123 145
                 }
124 146
 
125
-    		if ($globalDebug) echo " - Add routes to DB -";
147
+    		if ($globalDebug) {
148
+    			echo " - Add routes to DB -";
149
+    		}
126 150
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
127 151
 		$Spotter = new Spotter();
128 152
 		if ($fh = fopen($database_file,"r")) {
129 153
 			$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)';
130 154
 			$Connection = new Connection();
131 155
 			$sth_dest = $Connection->db->prepare($query_dest);
132
-			if ($globalTransaction) $Connection->db->beginTransaction();
156
+			if ($globalTransaction) {
157
+				$Connection->db->beginTransaction();
158
+			}
133 159
 			while (!feof($fh)) {
134 160
 				$line = fgetcsv($fh,9999,',');
135 161
 				if ($line[0] != '') {
@@ -138,13 +164,17 @@  discard block
 block discarded – undo
138 164
 							$query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld');
139 165
 							$sth_dest->execute($query_dest_values);
140 166
 						} catch(PDOException $e) {
141
-							if ($globalTransaction) $Connection->db->rollBack(); 
167
+							if ($globalTransaction) {
168
+								$Connection->db->rollBack();
169
+							}
142 170
 							return "error : ".$e->getMessage();
143 171
 						}
144 172
 					}
145 173
 				}
146 174
 			}
147
-			if ($globalTransaction) $Connection->db->commit();
175
+			if ($globalTransaction) {
176
+				$Connection->db->commit();
177
+			}
148 178
 		}
149 179
                 return '';
150 180
 	}
@@ -152,7 +182,9 @@  discard block
 block discarded – undo
152 182
 	public static function retrieve_route_skyteam($database_file) {
153 183
 		global $globalDebug, $globalTransaction;
154 184
 		//$query = 'TRUNCATE TABLE routes';
155
-		if ($globalDebug) echo " - Delete previous routes from DB -";
185
+		if ($globalDebug) {
186
+			echo " - Delete previous routes from DB -";
187
+		}
156 188
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
157 189
 		$Connection = new Connection();
158 190
 		try {
@@ -163,7 +195,9 @@  discard block
 block discarded – undo
163 195
                         return "error : ".$e->getMessage();
164 196
                 }
165 197
 
166
-    		if ($globalDebug) echo " - Add routes to DB -";
198
+    		if ($globalDebug) {
199
+    			echo " - Add routes to DB -";
200
+    		}
167 201
 
168 202
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
169 203
 		$Spotter = new Spotter();
@@ -172,7 +206,9 @@  discard block
 block discarded – undo
172 206
 			$Connection = new Connection();
173 207
 			$sth_dest = $Connection->db->prepare($query_dest);
174 208
 			try {
175
-				if ($globalTransaction) $Connection->db->beginTransaction();
209
+				if ($globalTransaction) {
210
+					$Connection->db->beginTransaction();
211
+				}
176 212
 				while (!feof($fh)) {
177 213
 					$line = fgetcsv($fh,9999,',');
178 214
 					if ($line[0] != '') {
@@ -183,9 +219,13 @@  discard block
 block discarded – undo
183 219
 						}
184 220
 					}
185 221
 				}
186
-				if ($globalTransaction) $Connection->db->commit();
222
+				if ($globalTransaction) {
223
+					$Connection->db->commit();
224
+				}
187 225
 			} catch(PDOException $e) {
188
-				if ($globalTransaction) $Connection->db->rollBack(); 
226
+				if ($globalTransaction) {
227
+					$Connection->db->rollBack();
228
+				}
189 229
 				return "error : ".$e->getMessage();
190 230
 			}
191 231
 		}
@@ -228,11 +268,16 @@  discard block
 block discarded – undo
228 268
 		$sth_dest = $Connection->db->prepare($query_dest);
229 269
 		$sth_dest_owner = $Connection->db->prepare($query_dest_owner);
230 270
 		try {
231
-			if ($globalTransaction) $Connection->db->beginTransaction();
271
+			if ($globalTransaction) {
272
+				$Connection->db->beginTransaction();
273
+			}
232 274
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
233 275
 			//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
234
-				if ($values['UserString4'] == 'M') $type = 'military';
235
-				else $type = null;
276
+				if ($values['UserString4'] == 'M') {
277
+					$type = 'military';
278
+				} else {
279
+					$type = null;
280
+				}
236 281
 				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
237 282
 				$sth_dest->execute($query_dest_values);
238 283
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
@@ -240,7 +285,9 @@  discard block
 block discarded – undo
240 285
 				    $sth_dest_owner->execute($query_dest_owner_values);
241 286
 				}
242 287
             		}
243
-			if ($globalTransaction) $Connection->db->commit();
288
+			if ($globalTransaction) {
289
+				$Connection->db->commit();
290
+			}
244 291
 		} catch(PDOException $e) {
245 292
 			return "error : ".$e->getMessage();
246 293
 		}
@@ -277,7 +324,9 @@  discard block
 block discarded – undo
277 324
 			$Connection = new Connection();
278 325
 			$sth_dest = $Connection->db->prepare($query_dest);
279 326
 			try {
280
-				if ($globalTransaction) $Connection->db->beginTransaction();
327
+				if ($globalTransaction) {
328
+					$Connection->db->beginTransaction();
329
+				}
281 330
             			while (!feof($fh)) {
282 331
             				$values = array();
283 332
             				$line = $Common->hex2str(fgets($fh,9999));
@@ -288,7 +337,9 @@  discard block
 block discarded – undo
288 337
             				// Check if we can find ICAO, else set it to GLID
289 338
             				$aircraft_name_split = explode(' ',$aircraft_name);
290 339
             				$search_more = '';
291
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
340
+            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) {
341
+            					$search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
342
+            				}
292 343
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
293 344
             				$sth_search = $Connection->db->prepare($query_search);
294 345
 					try {
@@ -301,7 +352,9 @@  discard block
 block discarded – undo
301 352
 					} catch(PDOException $e) {
302 353
 						return "error : ".$e->getMessage();
303 354
 					}
304
-					if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
355
+					if (!isset($values['ICAOTypeCode'])) {
356
+						$values['ICAOTypeCode'] = 'GLID';
357
+					}
305 358
 					// Add data to db
306 359
 					if ($values['Registration'] != '' && $values['Registration'] != '0000') {
307 360
 						//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
@@ -310,7 +363,9 @@  discard block
 block discarded – undo
310 363
 						$sth_dest->execute($query_dest_values);
311 364
 					}
312 365
 				}
313
-				if ($globalTransaction) $Connection->db->commit();
366
+				if ($globalTransaction) {
367
+					$Connection->db->commit();
368
+				}
314 369
 			} catch(PDOException $e) {
315 370
 				return "error : ".$e->getMessage();
316 371
 			}
@@ -346,7 +401,9 @@  discard block
 block discarded – undo
346 401
 			$Connection = new Connection();
347 402
 			$sth_dest = $Connection->db->prepare($query_dest);
348 403
 			try {
349
-				if ($globalTransaction) $Connection->db->beginTransaction();
404
+				if ($globalTransaction) {
405
+					$Connection->db->beginTransaction();
406
+				}
350 407
 				$tmp = fgetcsv($fh,9999,',',"'");
351 408
             			while (!feof($fh)) {
352 409
             				$line = fgetcsv($fh,9999,',',"'");
@@ -359,13 +416,17 @@  discard block
 block discarded – undo
359 416
             				// Check if we can find ICAO, else set it to GLID
360 417
             				$aircraft_name_split = explode(' ',$aircraft_name);
361 418
             				$search_more = '';
362
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
419
+            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) {
420
+            					$search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
421
+            				}
363 422
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
364 423
             				$sth_search = $Connection->db->prepare($query_search);
365 424
 					try {
366 425
                                     		$sth_search->execute();
367 426
 	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
368
-	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
427
+	            				if (isset($result['icao']) && $result['icao'] != '') {
428
+	            					$values['ICAOTypeCode'] = $result['icao'];
429
+	            				}
369 430
 					} catch(PDOException $e) {
370 431
 						return "error : ".$e->getMessage();
371 432
 					}
@@ -378,7 +439,9 @@  discard block
 block discarded – undo
378 439
 						$sth_dest->execute($query_dest_values);
379 440
 					}
380 441
 				}
381
-				if ($globalTransaction) $Connection->db->commit();
442
+				if ($globalTransaction) {
443
+					$Connection->db->commit();
444
+				}
382 445
 			} catch(PDOException $e) {
383 446
 				return "error : ".$e->getMessage();
384 447
 			}
@@ -414,7 +477,9 @@  discard block
 block discarded – undo
414 477
 			$Connection = new Connection();
415 478
 			$sth_dest = $Connection->db->prepare($query_dest);
416 479
 			try {
417
-				if ($globalTransaction) $Connection->db->beginTransaction();
480
+				if ($globalTransaction) {
481
+					$Connection->db->beginTransaction();
482
+				}
418 483
 				$tmp = fgetcsv($fh,9999,',','"');
419 484
             			while (!feof($fh)) {
420 485
             				$line = fgetcsv($fh,9999,',','"');
@@ -424,16 +489,22 @@  discard block
 block discarded – undo
424 489
             				    $values['registration'] = $line[0];
425 490
             				    $values['base'] = $line[4];
426 491
             				    $values['owner'] = $line[5];
427
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
428
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
492
+            				    if ($line[6] == '') {
493
+            				    	$values['date_first_reg'] = null;
494
+            				    } else {
495
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
496
+					    }
429 497
 					    $values['cancel'] = $line[7];
430 498
 					} elseif ($country == 'EI') {
431 499
 					    // TODO : add modeS & reg to aircraft_modes
432 500
             				    $values['registration'] = $line[0];
433 501
             				    $values['base'] = $line[3];
434 502
             				    $values['owner'] = $line[2];
435
-            				    if ($line[1] == '') $values['date_first_reg'] = null;
436
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
503
+            				    if ($line[1] == '') {
504
+            				    	$values['date_first_reg'] = null;
505
+            				    } else {
506
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
507
+					    }
437 508
 					    $values['cancel'] = '';
438 509
 					} elseif ($country == 'HB') {
439 510
 					    // TODO : add modeS & reg to aircraft_modes
@@ -447,16 +518,22 @@  discard block
 block discarded – undo
447 518
             				    $values['registration'] = $line[3];
448 519
             				    $values['base'] = null;
449 520
             				    $values['owner'] = $line[5];
450
-            				    if ($line[18] == '') $values['date_first_reg'] = null;
451
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
521
+            				    if ($line[18] == '') {
522
+            				    	$values['date_first_reg'] = null;
523
+            				    } else {
524
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
525
+					    }
452 526
 					    $values['cancel'] = '';
453 527
 					} elseif ($country == 'VH') {
454 528
 					    // TODO : add modeS & reg to aircraft_modes
455 529
             				    $values['registration'] = $line[0];
456 530
             				    $values['base'] = null;
457 531
             				    $values['owner'] = $line[12];
458
-            				    if ($line[28] == '') $values['date_first_reg'] = null;
459
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
532
+            				    if ($line[28] == '') {
533
+            				    	$values['date_first_reg'] = null;
534
+            				    } else {
535
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
536
+					    }
460 537
 
461 538
 					    $values['cancel'] = $line[39];
462 539
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
@@ -475,29 +552,41 @@  discard block
 block discarded – undo
475 552
             				    $values['registration'] = $line[0];
476 553
             				    $values['base'] = null;
477 554
             				    $values['owner'] = $line[8];
478
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
479
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
555
+            				    if ($line[7] == '') {
556
+            				    	$values['date_first_reg'] = null;
557
+            				    } else {
558
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
559
+					    }
480 560
 					    $values['cancel'] = '';
481 561
 					} elseif ($country == 'PP') {
482 562
             				    $values['registration'] = $line[0];
483 563
             				    $values['base'] = null;
484 564
             				    $values['owner'] = $line[4];
485
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
486
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
565
+            				    if ($line[6] == '') {
566
+            				    	$values['date_first_reg'] = null;
567
+            				    } else {
568
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
569
+					    }
487 570
 					    $values['cancel'] = $line[7];
488 571
 					} elseif ($country == 'E7') {
489 572
             				    $values['registration'] = $line[0];
490 573
             				    $values['base'] = null;
491 574
             				    $values['owner'] = $line[4];
492
-            				    if ($line[5] == '') $values['date_first_reg'] = null;
493
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
575
+            				    if ($line[5] == '') {
576
+            				    	$values['date_first_reg'] = null;
577
+            				    } else {
578
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
579
+					    }
494 580
 					    $values['cancel'] = '';
495 581
 					} elseif ($country == '8Q') {
496 582
             				    $values['registration'] = $line[0];
497 583
             				    $values['base'] = null;
498 584
             				    $values['owner'] = $line[3];
499
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
500
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
585
+            				    if ($line[7] == '') {
586
+            				    	$values['date_first_reg'] = null;
587
+            				    } else {
588
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
589
+					    }
501 590
 					    $values['cancel'] = '';
502 591
 					} elseif ($country == 'ZK' || $country == 'OM' || $country == 'TF') {
503 592
             				    $values['registration'] = $line[0];
@@ -511,7 +600,9 @@  discard block
 block discarded – undo
511 600
 						$sth_dest->execute($query_dest_values);
512 601
 					}
513 602
 				}
514
-				if ($globalTransaction) $Connection->db->commit();
603
+				if ($globalTransaction) {
604
+					$Connection->db->commit();
605
+				}
515 606
 			} catch(PDOException $e) {
516 607
 				return "error : ".$e->getMessage();
517 608
 			}
@@ -645,25 +736,45 @@  discard block
 block discarded – undo
645 736
 		    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)";
646 737
 		$Connection = new Connection();
647 738
 		$sth_dest = $Connection->db->prepare($query_dest);
648
-		if ($globalTransaction) $Connection->db->beginTransaction();
739
+		if ($globalTransaction) {
740
+			$Connection->db->beginTransaction();
741
+		}
649 742
   
650 743
 		$i = 0;
651 744
 		while($row = sparql_fetch_array($result))
652 745
 		{
653 746
 			if ($i >= 1) {
654 747
 			//print_r($row);
655
-			if (!isset($row['iata'])) $row['iata'] = '';
656
-			if (!isset($row['icao'])) $row['icao'] = '';
657
-			if (!isset($row['type'])) $row['type'] = '';
658
-			if (!isset($row['altitude'])) $row['altitude'] = '';
748
+			if (!isset($row['iata'])) {
749
+				$row['iata'] = '';
750
+			}
751
+			if (!isset($row['icao'])) {
752
+				$row['icao'] = '';
753
+			}
754
+			if (!isset($row['type'])) {
755
+				$row['type'] = '';
756
+			}
757
+			if (!isset($row['altitude'])) {
758
+				$row['altitude'] = '';
759
+			}
659 760
 			if (isset($row['city_bis'])) {
660 761
 				$row['city'] = $row['city_bis'];
661 762
 			}
662
-			if (!isset($row['city'])) $row['city'] = '';
663
-			if (!isset($row['country'])) $row['country'] = '';
664
-			if (!isset($row['homepage'])) $row['homepage'] = '';
665
-			if (!isset($row['wikipedia_page'])) $row['wikipedia_page'] = '';
666
-			if (!isset($row['name'])) continue;
763
+			if (!isset($row['city'])) {
764
+				$row['city'] = '';
765
+			}
766
+			if (!isset($row['country'])) {
767
+				$row['country'] = '';
768
+			}
769
+			if (!isset($row['homepage'])) {
770
+				$row['homepage'] = '';
771
+			}
772
+			if (!isset($row['wikipedia_page'])) {
773
+				$row['wikipedia_page'] = '';
774
+			}
775
+			if (!isset($row['name'])) {
776
+				continue;
777
+			}
667 778
 			if (!isset($row['image'])) {
668 779
 				$row['image'] = '';
669 780
 				$row['image_thumb'] = '';
@@ -699,7 +810,9 @@  discard block
 block discarded – undo
699 810
 
700 811
 			$i++;
701 812
 		}
702
-		if ($globalTransaction) $Connection->db->commit();
813
+		if ($globalTransaction) {
814
+			$Connection->db->commit();
815
+		}
703 816
 		echo "Delete duplicate rows...\n";
704 817
 		$query = 'ALTER IGNORE TABLE airport ADD UNIQUE INDEX icaoidx (icao)';
705 818
 		try {
@@ -711,7 +824,9 @@  discard block
 block discarded – undo
711 824
                 }
712 825
 
713 826
 
714
-		if ($globalDebug) echo "Insert Not available Airport...\n";
827
+		if ($globalDebug) {
828
+			echo "Insert Not available Airport...\n";
829
+		}
715 830
 		$query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image`,`image_thumb`)
716 831
 		    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image, :image_thumb)";
717 832
 		$query_values = array(':airport_id' => $i, ':name' => 'Not available',':iata' => 'NA',':icao' => 'NA',':latitude' => '0',':longitude' => '0',':altitude' => '0',':type' => 'NA',':city' => 'N/A',':country' => 'N/A',':home_link' => '',':wikipedia_link' => '',':image' => '',':image_thumb' => '');
@@ -738,7 +853,9 @@  discard block
 block discarded – undo
738 853
 		$delimiter = ',';
739 854
 		$out_file = $tmp_dir.'airports.csv';
740 855
 		update_db::download('http://ourairports.com/data/airports.csv',$out_file);
741
-		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
856
+		if (!file_exists($out_file) || !is_readable($out_file)) {
857
+			return FALSE;
858
+		}
742 859
 		echo "Add data from ourairports.com...\n";
743 860
 
744 861
 		$header = NULL;
@@ -748,8 +865,9 @@  discard block
 block discarded – undo
748 865
 			//$Connection->db->beginTransaction();
749 866
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
750 867
 			{
751
-				if(!$header) $header = $row;
752
-				else {
868
+				if(!$header) {
869
+					$header = $row;
870
+				} else {
753 871
 					$data = array();
754 872
 					$data = array_combine($header, $row);
755 873
 					try {
@@ -787,7 +905,9 @@  discard block
 block discarded – undo
787 905
 		echo "Download data from another free database...\n";
788 906
 		$out_file = $tmp_dir.'GlobalAirportDatabase.zip';
789 907
 		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file);
790
-		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
908
+		if (!file_exists($out_file) || !is_readable($out_file)) {
909
+			return FALSE;
910
+		}
791 911
 		update_db::unzip($out_file);
792 912
 		$header = NULL;
793 913
 		echo "Add data from another free database...\n";
@@ -798,8 +918,9 @@  discard block
 block discarded – undo
798 918
 			//$Connection->db->beginTransaction();
799 919
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
800 920
 			{
801
-				if(!$header) $header = $row;
802
-				else {
921
+				if(!$header) {
922
+					$header = $row;
923
+				} else {
803 924
 					$data = $row;
804 925
 
805 926
 					$query = 'UPDATE airport SET `city` = :city, `country` = :country WHERE icao = :icao';
@@ -974,7 +1095,9 @@  discard block
 block discarded – undo
974 1095
 		if (($handle = fopen($tmp_dir.'MASTER.txt', 'r')) !== FALSE)
975 1096
 		{
976 1097
 			$i = 0;
977
-			if ($globalTransaction) $Connection->db->beginTransaction();
1098
+			if ($globalTransaction) {
1099
+				$Connection->db->beginTransaction();
1100
+			}
978 1101
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
979 1102
 			{
980 1103
 				if ($i > 0) {
@@ -987,7 +1110,9 @@  discard block
 block discarded – undo
987 1110
 					}
988 1111
 					$result_search = $sths->fetchAll(PDO::FETCH_ASSOC);
989 1112
 					if (!empty($result_search)) {
990
-						if ($globalDebug) echo '.';
1113
+						if ($globalDebug) {
1114
+							echo '.';
1115
+						}
991 1116
 						$queryi = 'UPDATE aircraft SET mfr = :mfr WHERE icao = :icao';
992 1117
 						try {
993 1118
 							$sthi = $Connection->db->prepare($queryi);
@@ -1005,8 +1130,12 @@  discard block
 block discarded – undo
1005 1130
 						}
1006 1131
 						$result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC);
1007 1132
 						if (!empty($result_search_mfr)) {
1008
-							if (trim($data[16]) == '' && trim($data[23]) != '') $data[16] = $data[23];
1009
-							if (trim($data[16]) == '' && trim($data[15]) != '') $data[16] = $data[15];
1133
+							if (trim($data[16]) == '' && trim($data[23]) != '') {
1134
+								$data[16] = $data[23];
1135
+							}
1136
+							if (trim($data[16]) == '' && trim($data[15]) != '') {
1137
+								$data[16] = $data[15];
1138
+							}
1010 1139
 							$queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)';
1011 1140
 							try {
1012 1141
 								$sthf = $Connection->db->prepare($queryf);
@@ -1017,7 +1146,9 @@  discard block
 block discarded – undo
1017 1146
 						}
1018 1147
 					}
1019 1148
 					if (strtotime($data[29]) > time()) {
1020
-						if ($globalDebug) echo 'i';
1149
+						if ($globalDebug) {
1150
+							echo 'i';
1151
+						}
1021 1152
 						$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
1022 1153
 						try {
1023 1154
 							$sth = $Connection->db->prepare($query);
@@ -1028,13 +1159,19 @@  discard block
 block discarded – undo
1028 1159
 					}
1029 1160
 				}
1030 1161
 				if ($i % 90 == 0) {
1031
-					if ($globalTransaction) $Connection->db->commit();
1032
-					if ($globalTransaction) $Connection->db->beginTransaction();
1162
+					if ($globalTransaction) {
1163
+						$Connection->db->commit();
1164
+					}
1165
+					if ($globalTransaction) {
1166
+						$Connection->db->beginTransaction();
1167
+					}
1033 1168
 				}
1034 1169
 				$i++;
1035 1170
 			}
1036 1171
 			fclose($handle);
1037
-			if ($globalTransaction) $Connection->db->commit();
1172
+			if ($globalTransaction) {
1173
+				$Connection->db->commit();
1174
+			}
1038 1175
 		}
1039 1176
 		return '';
1040 1177
         }
@@ -1058,7 +1195,9 @@  discard block
 block discarded – undo
1058 1195
 			$i = 0;
1059 1196
 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
1060 1197
 			//$Connection->db->beginTransaction();
1061
-			if ($globalTransaction) $Connection->db->beginTransaction();
1198
+			if ($globalTransaction) {
1199
+				$Connection->db->beginTransaction();
1200
+			}
1062 1201
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1063 1202
 			{
1064 1203
 				if ($i > 0) {
@@ -1073,7 +1212,9 @@  discard block
 block discarded – undo
1073 1212
 				$i++;
1074 1213
 			}
1075 1214
 			fclose($handle);
1076
-			if ($globalTransaction) $Connection->db->commit();
1215
+			if ($globalTransaction) {
1216
+				$Connection->db->commit();
1217
+			}
1077 1218
 		}
1078 1219
 		return '';
1079 1220
         }
@@ -1094,7 +1235,9 @@  discard block
 block discarded – undo
1094 1235
 		if (($handle = fopen($tmp_dir.'owners.tsv', 'r')) !== FALSE)
1095 1236
 		{
1096 1237
 			$i = 0;
1097
-			if ($globalTransaction) $Connection->db->beginTransaction();
1238
+			if ($globalTransaction) {
1239
+				$Connection->db->beginTransaction();
1240
+			}
1098 1241
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1099 1242
 			{
1100 1243
 				if ($i > 0) {
@@ -1110,7 +1253,9 @@  discard block
 block discarded – undo
1110 1253
 				$i++;
1111 1254
 			}
1112 1255
 			fclose($handle);
1113
-			if ($globalTransaction) $Connection->db->commit();
1256
+			if ($globalTransaction) {
1257
+				$Connection->db->commit();
1258
+			}
1114 1259
 		}
1115 1260
 		return '';
1116 1261
         }
@@ -1135,7 +1280,9 @@  discard block
 block discarded – undo
1135 1280
 			$i = 0;
1136 1281
 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
1137 1282
 			//$Connection->db->beginTransaction();
1138
-			if ($globalTransaction) $Connection->db->beginTransaction();
1283
+			if ($globalTransaction) {
1284
+				$Connection->db->beginTransaction();
1285
+			}
1139 1286
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1140 1287
 			{
1141 1288
 				if ($i > 0) {
@@ -1150,7 +1297,9 @@  discard block
 block discarded – undo
1150 1297
 				$i++;
1151 1298
 			}
1152 1299
 			fclose($handle);
1153
-			if ($globalTransaction) $Connection->db->commit();
1300
+			if ($globalTransaction) {
1301
+				$Connection->db->commit();
1302
+			}
1154 1303
 		}
1155 1304
 		return '';
1156 1305
         }
@@ -1301,7 +1450,9 @@  discard block
 block discarded – undo
1301 1450
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1302 1451
 		{
1303 1452
 			$i = 0;
1304
-			if ($globalTransaction) $Connection->db->beginTransaction();
1453
+			if ($globalTransaction) {
1454
+				$Connection->db->beginTransaction();
1455
+			}
1305 1456
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1306 1457
 			{
1307 1458
 				$i++;
@@ -1329,7 +1480,9 @@  discard block
 block discarded – undo
1329 1480
 				}
1330 1481
 			}
1331 1482
 			fclose($handle);
1332
-			if ($globalTransaction) $Connection->db->commit();
1483
+			if ($globalTransaction) {
1484
+				$Connection->db->commit();
1485
+			}
1333 1486
 		}
1334 1487
 		return '';
1335 1488
         }
@@ -1352,7 +1505,9 @@  discard block
 block discarded – undo
1352 1505
 		$Connection = new Connection();
1353 1506
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1354 1507
 		{
1355
-			if ($globalTransaction) $Connection->db->beginTransaction();
1508
+			if ($globalTransaction) {
1509
+				$Connection->db->beginTransaction();
1510
+			}
1356 1511
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1357 1512
 			{
1358 1513
 				if(count($row) > 1) {
@@ -1366,7 +1521,9 @@  discard block
 block discarded – undo
1366 1521
 				}
1367 1522
 			}
1368 1523
 			fclose($handle);
1369
-			if ($globalTransaction) $Connection->db->commit();
1524
+			if ($globalTransaction) {
1525
+				$Connection->db->commit();
1526
+			}
1370 1527
 		}
1371 1528
 		return '';
1372 1529
         }
@@ -1386,8 +1543,9 @@  discard block
 block discarded – undo
1386 1543
 	        }
1387 1544
 
1388 1545
 
1389
-		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1390
-		else {
1546
+		if ($globalDBdriver == 'mysql') {
1547
+			update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1548
+		} else {
1391 1549
 			update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql');
1392 1550
 			$query = "CREATE EXTENSION postgis";
1393 1551
 			$Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']);
@@ -1406,20 +1564,30 @@  discard block
 block discarded – undo
1406 1564
 		global $tmp_dir, $globalDebug;
1407 1565
 		include_once('class.create_db.php');
1408 1566
 		require_once(dirname(__FILE__).'/../require/class.NOTAM.php');
1409
-		if ($globalDebug) echo "NOTAM from FlightAirMap website : Download...";
1567
+		if ($globalDebug) {
1568
+			echo "NOTAM from FlightAirMap website : Download...";
1569
+		}
1410 1570
 		update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz');
1411 1571
 		$error = '';
1412 1572
 		if (file_exists($tmp_dir.'notam.txt.gz')) {
1413
-			if ($globalDebug) echo "Gunzip...";
1573
+			if ($globalDebug) {
1574
+				echo "Gunzip...";
1575
+			}
1414 1576
 			update_db::gunzip($tmp_dir.'notam.txt.gz');
1415
-			if ($globalDebug) echo "Add to DB...";
1577
+			if ($globalDebug) {
1578
+				echo "Add to DB...";
1579
+			}
1416 1580
 			//$error = create_db::import_file($tmp_dir.'notam.sql');
1417 1581
 			$NOTAM = new NOTAM();
1418 1582
 			$NOTAM->updateNOTAMfromTextFile($tmp_dir.'notam.txt');
1419
-		} else $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";
1583
+		} else {
1584
+			$error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";
1585
+		}
1420 1586
 		if ($error != '') {
1421 1587
 			return $error;
1422
-		} elseif ($globalDebug) echo "Done\n";
1588
+		} elseif ($globalDebug) {
1589
+			echo "Done\n";
1590
+		}
1423 1591
 		return '';
1424 1592
 	}
1425 1593
 
@@ -1473,67 +1641,111 @@  discard block
 block discarded – undo
1473 1641
 		//if ($globalDebug) echo "IVAO : Download...";
1474 1642
 		//update_db::download('http://fr.mirror.ivao.aero/software/ivae_feb2013.zip',$tmp_dir.'ivae_feb2013.zip');
1475 1643
 		if (file_exists($tmp_dir.'ivae_feb2013.zip')) {
1476
-			if ($globalDebug) echo "Unzip...";
1644
+			if ($globalDebug) {
1645
+				echo "Unzip...";
1646
+			}
1477 1647
 			update_db::unzip($tmp_dir.'ivae_feb2013.zip');
1478
-			if ($globalDebug) echo "Add to DB...";
1648
+			if ($globalDebug) {
1649
+				echo "Add to DB...";
1650
+			}
1479 1651
 			update_db::ivao_airlines($tmp_dir.'data/airlines.dat');
1480
-			if ($globalDebug) echo "Copy airlines logos to airlines images directory...";
1652
+			if ($globalDebug) {
1653
+				echo "Copy airlines logos to airlines images directory...";
1654
+			}
1481 1655
 			if (is_writable(dirname(__FILE__).'/../images/airlines')) {
1482
-				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
1483
-			} else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
1484
-		} else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
1656
+				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) {
1657
+					$error = "Failed to copy airlines logo.";
1658
+				}
1659
+			} else {
1660
+				$error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
1661
+			}
1662
+		} else {
1663
+			$error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
1664
+		}
1485 1665
 		if ($error != '') {
1486 1666
 			return $error;
1487
-		} elseif ($globalDebug) echo "Done\n";
1667
+		} elseif ($globalDebug) {
1668
+			echo "Done\n";
1669
+		}
1488 1670
 		return '';
1489 1671
 	}
1490 1672
 
1491 1673
 	public static function update_routes() {
1492 1674
 		global $tmp_dir, $globalDebug;
1493 1675
 		$error = '';
1494
-		if ($globalDebug) echo "Routes : Download...";
1676
+		if ($globalDebug) {
1677
+			echo "Routes : Download...";
1678
+		}
1495 1679
 		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz');
1496 1680
 		if (file_exists($tmp_dir.'StandingData.sqb.gz')) {
1497
-			if ($globalDebug) echo "Gunzip...";
1681
+			if ($globalDebug) {
1682
+				echo "Gunzip...";
1683
+			}
1498 1684
 			update_db::gunzip($tmp_dir.'StandingData.sqb.gz');
1499
-			if ($globalDebug) echo "Add to DB...";
1685
+			if ($globalDebug) {
1686
+				echo "Add to DB...";
1687
+			}
1500 1688
 			$error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb');
1501
-		} else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
1689
+		} else {
1690
+			$error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
1691
+		}
1502 1692
 		if ($error != '') {
1503 1693
 			return $error;
1504
-		} elseif ($globalDebug) echo "Done\n";
1694
+		} elseif ($globalDebug) {
1695
+			echo "Done\n";
1696
+		}
1505 1697
 		return '';
1506 1698
 	}
1507 1699
 	public static function update_oneworld() {
1508 1700
 		global $tmp_dir, $globalDebug;
1509 1701
 		$error = '';
1510
-		if ($globalDebug) echo "Schedules Oneworld : Download...";
1702
+		if ($globalDebug) {
1703
+			echo "Schedules Oneworld : Download...";
1704
+		}
1511 1705
 		update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz');
1512 1706
 		if (file_exists($tmp_dir.'oneworld.csv.gz')) {
1513
-			if ($globalDebug) echo "Gunzip...";
1707
+			if ($globalDebug) {
1708
+				echo "Gunzip...";
1709
+			}
1514 1710
 			update_db::gunzip($tmp_dir.'oneworld.csv.gz');
1515
-			if ($globalDebug) echo "Add to DB...";
1711
+			if ($globalDebug) {
1712
+				echo "Add to DB...";
1713
+			}
1516 1714
 			$error = update_db::retrieve_route_oneworld($tmp_dir.'oneworld.csv');
1517
-		} else $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
1715
+		} else {
1716
+			$error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
1717
+		}
1518 1718
 		if ($error != '') {
1519 1719
 			return $error;
1520
-		} elseif ($globalDebug) echo "Done\n";
1720
+		} elseif ($globalDebug) {
1721
+			echo "Done\n";
1722
+		}
1521 1723
 		return '';
1522 1724
 	}
1523 1725
 	public static function update_skyteam() {
1524 1726
 		global $tmp_dir, $globalDebug;
1525 1727
 		$error = '';
1526
-		if ($globalDebug) echo "Schedules Skyteam : Download...";
1728
+		if ($globalDebug) {
1729
+			echo "Schedules Skyteam : Download...";
1730
+		}
1527 1731
 		update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz');
1528 1732
 		if (file_exists($tmp_dir.'skyteam.csv.gz')) {
1529
-			if ($globalDebug) echo "Gunzip...";
1733
+			if ($globalDebug) {
1734
+				echo "Gunzip...";
1735
+			}
1530 1736
 			update_db::gunzip($tmp_dir.'skyteam.csv.gz');
1531
-			if ($globalDebug) echo "Add to DB...";
1737
+			if ($globalDebug) {
1738
+				echo "Add to DB...";
1739
+			}
1532 1740
 			$error = update_db::retrieve_route_skyteam($tmp_dir.'skyteam.csv');
1533
-		} else $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
1741
+		} else {
1742
+			$error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
1743
+		}
1534 1744
 		if ($error != '') {
1535 1745
 			return $error;
1536
-		} elseif ($globalDebug) echo "Done\n";
1746
+		} elseif ($globalDebug) {
1747
+			echo "Done\n";
1748
+		}
1537 1749
 		return '';
1538 1750
 	}
1539 1751
 	public static function update_ModeS() {
@@ -1550,326 +1762,564 @@  discard block
 block discarded – undo
1550 1762
 			exit;
1551 1763
 		} elseif ($globalDebug) echo "Done\n";
1552 1764
 */
1553
-		if ($globalDebug) echo "Modes : Download...";
1554
-//		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
1765
+		if ($globalDebug) {
1766
+			echo "Modes : Download...";
1767
+		}
1768
+		//		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
1555 1769
 		update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz');
1556 1770
 
1557 1771
 //		if (file_exists($tmp_dir.'basestation_latest.zip')) {
1558 1772
 		if (file_exists($tmp_dir.'BaseStation.sqb.gz')) {
1559
-			if ($globalDebug) echo "Unzip...";
1560
-//			update_db::unzip($tmp_dir.'basestation_latest.zip');
1773
+			if ($globalDebug) {
1774
+				echo "Unzip...";
1775
+			}
1776
+			//			update_db::unzip($tmp_dir.'basestation_latest.zip');
1561 1777
 			update_db::gunzip($tmp_dir.'BaseStation.sqb.gz');
1562
-			if ($globalDebug) echo "Add to DB...";
1778
+			if ($globalDebug) {
1779
+				echo "Add to DB...";
1780
+			}
1563 1781
 			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb');
1564 1782
 //			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'basestation.sqb');
1565
-		} else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
1783
+		} else {
1784
+			$error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
1785
+		}
1566 1786
 		if ($error != '') {
1567 1787
 			return $error;
1568
-		} elseif ($globalDebug) echo "Done\n";
1788
+		} elseif ($globalDebug) {
1789
+			echo "Done\n";
1790
+		}
1569 1791
 		return '';
1570 1792
 	}
1571 1793
 
1572 1794
 	public static function update_ModeS_faa() {
1573 1795
 		global $tmp_dir, $globalDebug;
1574
-		if ($globalDebug) echo "Modes FAA: Download...";
1796
+		if ($globalDebug) {
1797
+			echo "Modes FAA: Download...";
1798
+		}
1575 1799
 		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip');
1576 1800
 		if (file_exists($tmp_dir.'ReleasableAircraft.zip')) {
1577
-			if ($globalDebug) echo "Unzip...";
1801
+			if ($globalDebug) {
1802
+				echo "Unzip...";
1803
+			}
1578 1804
 			update_db::unzip($tmp_dir.'ReleasableAircraft.zip');
1579
-			if ($globalDebug) echo "Add to DB...";
1805
+			if ($globalDebug) {
1806
+				echo "Add to DB...";
1807
+			}
1580 1808
 			$error = update_db::modes_faa();
1581
-		} else $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed.";
1809
+		} else {
1810
+			$error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed.";
1811
+		}
1582 1812
 		if ($error != '') {
1583 1813
 			return $error;
1584
-		} elseif ($globalDebug) echo "Done\n";
1814
+		} elseif ($globalDebug) {
1815
+			echo "Done\n";
1816
+		}
1585 1817
 		return '';
1586 1818
 	}
1587 1819
 
1588 1820
 	public static function update_ModeS_flarm() {
1589 1821
 		global $tmp_dir, $globalDebug;
1590
-		if ($globalDebug) echo "Modes Flarmnet: Download...";
1822
+		if ($globalDebug) {
1823
+			echo "Modes Flarmnet: Download...";
1824
+		}
1591 1825
 		update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln');
1592 1826
 		if (file_exists($tmp_dir.'data.fln')) {
1593
-			if ($globalDebug) echo "Add to DB...";
1827
+			if ($globalDebug) {
1828
+				echo "Add to DB...";
1829
+			}
1594 1830
 			$error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln');
1595
-		} else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";
1831
+		} else {
1832
+			$error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";
1833
+		}
1596 1834
 		if ($error != '') {
1597 1835
 			return $error;
1598
-		} elseif ($globalDebug) echo "Done\n";
1836
+		} elseif ($globalDebug) {
1837
+			echo "Done\n";
1838
+		}
1599 1839
 		return '';
1600 1840
 	}
1601 1841
 
1602 1842
 	public static function update_ModeS_ogn() {
1603 1843
 		global $tmp_dir, $globalDebug;
1604
-		if ($globalDebug) echo "Modes OGN: Download...";
1844
+		if ($globalDebug) {
1845
+			echo "Modes OGN: Download...";
1846
+		}
1605 1847
 		update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv');
1606 1848
 		if (file_exists($tmp_dir.'ogn.csv')) {
1607
-			if ($globalDebug) echo "Add to DB...";
1849
+			if ($globalDebug) {
1850
+				echo "Add to DB...";
1851
+			}
1608 1852
 			$error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv');
1609
-		} else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";
1853
+		} else {
1854
+			$error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";
1855
+		}
1610 1856
 		if ($error != '') {
1611 1857
 			return $error;
1612
-		} elseif ($globalDebug) echo "Done\n";
1858
+		} elseif ($globalDebug) {
1859
+			echo "Done\n";
1860
+		}
1613 1861
 		return '';
1614 1862
 	}
1615 1863
 
1616 1864
 	public static function update_owner() {
1617 1865
 		global $tmp_dir, $globalDebug;
1618 1866
 		
1619
-		if ($globalDebug) echo "Owner France: Download...";
1867
+		if ($globalDebug) {
1868
+			echo "Owner France: Download...";
1869
+		}
1620 1870
 		update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv');
1621 1871
 		if (file_exists($tmp_dir.'owner_f.csv')) {
1622
-			if ($globalDebug) echo "Add to DB...";
1872
+			if ($globalDebug) {
1873
+				echo "Add to DB...";
1874
+			}
1623 1875
 			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F');
1624
-		} else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
1876
+		} else {
1877
+			$error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
1878
+		}
1625 1879
 		if ($error != '') {
1626 1880
 			return $error;
1627
-		} elseif ($globalDebug) echo "Done\n";
1881
+		} elseif ($globalDebug) {
1882
+			echo "Done\n";
1883
+		}
1628 1884
 		
1629
-		if ($globalDebug) echo "Owner Ireland: Download...";
1885
+		if ($globalDebug) {
1886
+			echo "Owner Ireland: Download...";
1887
+		}
1630 1888
 		update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv');
1631 1889
 		if (file_exists($tmp_dir.'owner_ei.csv')) {
1632
-			if ($globalDebug) echo "Add to DB...";
1890
+			if ($globalDebug) {
1891
+				echo "Add to DB...";
1892
+			}
1633 1893
 			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI');
1634
-		} else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
1894
+		} else {
1895
+			$error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
1896
+		}
1635 1897
 		if ($error != '') {
1636 1898
 			return $error;
1637
-		} elseif ($globalDebug) echo "Done\n";
1638
-		if ($globalDebug) echo "Owner Switzerland: Download...";
1899
+		} elseif ($globalDebug) {
1900
+			echo "Done\n";
1901
+		}
1902
+		if ($globalDebug) {
1903
+			echo "Owner Switzerland: Download...";
1904
+		}
1639 1905
 		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv');
1640 1906
 		if (file_exists($tmp_dir.'owner_hb.csv')) {
1641
-			if ($globalDebug) echo "Add to DB...";
1907
+			if ($globalDebug) {
1908
+				echo "Add to DB...";
1909
+			}
1642 1910
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB');
1643
-		} else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
1911
+		} else {
1912
+			$error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
1913
+		}
1644 1914
 		if ($error != '') {
1645 1915
 			return $error;
1646
-		} elseif ($globalDebug) echo "Done\n";
1647
-		if ($globalDebug) echo "Owner Czech Republic: Download...";
1916
+		} elseif ($globalDebug) {
1917
+			echo "Done\n";
1918
+		}
1919
+		if ($globalDebug) {
1920
+			echo "Owner Czech Republic: Download...";
1921
+		}
1648 1922
 		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv');
1649 1923
 		if (file_exists($tmp_dir.'owner_ok.csv')) {
1650
-			if ($globalDebug) echo "Add to DB...";
1924
+			if ($globalDebug) {
1925
+				echo "Add to DB...";
1926
+			}
1651 1927
 			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK');
1652
-		} else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
1928
+		} else {
1929
+			$error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
1930
+		}
1653 1931
 		if ($error != '') {
1654 1932
 			return $error;
1655
-		} elseif ($globalDebug) echo "Done\n";
1656
-		if ($globalDebug) echo "Owner Australia: Download...";
1933
+		} elseif ($globalDebug) {
1934
+			echo "Done\n";
1935
+		}
1936
+		if ($globalDebug) {
1937
+			echo "Owner Australia: Download...";
1938
+		}
1657 1939
 		update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv');
1658 1940
 		if (file_exists($tmp_dir.'owner_vh.csv')) {
1659
-			if ($globalDebug) echo "Add to DB...";
1941
+			if ($globalDebug) {
1942
+				echo "Add to DB...";
1943
+			}
1660 1944
 			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH');
1661
-		} else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
1945
+		} else {
1946
+			$error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
1947
+		}
1662 1948
 		if ($error != '') {
1663 1949
 			return $error;
1664
-		} elseif ($globalDebug) echo "Done\n";
1665
-		if ($globalDebug) echo "Owner Austria: Download...";
1950
+		} elseif ($globalDebug) {
1951
+			echo "Done\n";
1952
+		}
1953
+		if ($globalDebug) {
1954
+			echo "Owner Austria: Download...";
1955
+		}
1666 1956
 		update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv');
1667 1957
 		if (file_exists($tmp_dir.'owner_oe.csv')) {
1668
-			if ($globalDebug) echo "Add to DB...";
1958
+			if ($globalDebug) {
1959
+				echo "Add to DB...";
1960
+			}
1669 1961
 			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE');
1670
-		} else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
1962
+		} else {
1963
+			$error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
1964
+		}
1671 1965
 		if ($error != '') {
1672 1966
 			return $error;
1673
-		} elseif ($globalDebug) echo "Done\n";
1674
-		if ($globalDebug) echo "Owner Chile: Download...";
1967
+		} elseif ($globalDebug) {
1968
+			echo "Done\n";
1969
+		}
1970
+		if ($globalDebug) {
1971
+			echo "Owner Chile: Download...";
1972
+		}
1675 1973
 		update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv');
1676 1974
 		if (file_exists($tmp_dir.'owner_cc.csv')) {
1677
-			if ($globalDebug) echo "Add to DB...";
1975
+			if ($globalDebug) {
1976
+				echo "Add to DB...";
1977
+			}
1678 1978
 			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC');
1679
-		} else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
1979
+		} else {
1980
+			$error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
1981
+		}
1680 1982
 		if ($error != '') {
1681 1983
 			return $error;
1682
-		} elseif ($globalDebug) echo "Done\n";
1683
-		if ($globalDebug) echo "Owner Colombia: Download...";
1984
+		} elseif ($globalDebug) {
1985
+			echo "Done\n";
1986
+		}
1987
+		if ($globalDebug) {
1988
+			echo "Owner Colombia: Download...";
1989
+		}
1684 1990
 		update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv');
1685 1991
 		if (file_exists($tmp_dir.'owner_hj.csv')) {
1686
-			if ($globalDebug) echo "Add to DB...";
1992
+			if ($globalDebug) {
1993
+				echo "Add to DB...";
1994
+			}
1687 1995
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ');
1688
-		} else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
1996
+		} else {
1997
+			$error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
1998
+		}
1689 1999
 		if ($error != '') {
1690 2000
 			return $error;
1691
-		} elseif ($globalDebug) echo "Done\n";
1692
-		if ($globalDebug) echo "Owner Bosnia Herzegobina: Download...";
2001
+		} elseif ($globalDebug) {
2002
+			echo "Done\n";
2003
+		}
2004
+		if ($globalDebug) {
2005
+			echo "Owner Bosnia Herzegobina: Download...";
2006
+		}
1693 2007
 		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv');
1694 2008
 		if (file_exists($tmp_dir.'owner_e7.csv')) {
1695
-			if ($globalDebug) echo "Add to DB...";
2009
+			if ($globalDebug) {
2010
+				echo "Add to DB...";
2011
+			}
1696 2012
 			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7');
1697
-		} else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
2013
+		} else {
2014
+			$error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
2015
+		}
1698 2016
 		if ($error != '') {
1699 2017
 			return $error;
1700
-		} elseif ($globalDebug) echo "Done\n";
1701
-		if ($globalDebug) echo "Owner Brazil: Download...";
2018
+		} elseif ($globalDebug) {
2019
+			echo "Done\n";
2020
+		}
2021
+		if ($globalDebug) {
2022
+			echo "Owner Brazil: Download...";
2023
+		}
1702 2024
 		update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv');
1703 2025
 		if (file_exists($tmp_dir.'owner_pp.csv')) {
1704
-			if ($globalDebug) echo "Add to DB...";
2026
+			if ($globalDebug) {
2027
+				echo "Add to DB...";
2028
+			}
1705 2029
 			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP');
1706
-		} else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
2030
+		} else {
2031
+			$error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
2032
+		}
1707 2033
 		if ($error != '') {
1708 2034
 			return $error;
1709
-		} elseif ($globalDebug) echo "Done\n";
1710
-		if ($globalDebug) echo "Owner Cayman Islands: Download...";
2035
+		} elseif ($globalDebug) {
2036
+			echo "Done\n";
2037
+		}
2038
+		if ($globalDebug) {
2039
+			echo "Owner Cayman Islands: Download...";
2040
+		}
1711 2041
 		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv');
1712 2042
 		if (file_exists($tmp_dir.'owner_vp.csv')) {
1713
-			if ($globalDebug) echo "Add to DB...";
2043
+			if ($globalDebug) {
2044
+				echo "Add to DB...";
2045
+			}
1714 2046
 			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP');
1715
-		} else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
2047
+		} else {
2048
+			$error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
2049
+		}
1716 2050
 		if ($error != '') {
1717 2051
 			return $error;
1718
-		} elseif ($globalDebug) echo "Done\n";
1719
-		if ($globalDebug) echo "Owner Croatia: Download...";
2052
+		} elseif ($globalDebug) {
2053
+			echo "Done\n";
2054
+		}
2055
+		if ($globalDebug) {
2056
+			echo "Owner Croatia: Download...";
2057
+		}
1720 2058
 		update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv');
1721 2059
 		if (file_exists($tmp_dir.'owner_9a.csv')) {
1722
-			if ($globalDebug) echo "Add to DB...";
2060
+			if ($globalDebug) {
2061
+				echo "Add to DB...";
2062
+			}
1723 2063
 			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A');
1724
-		} else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
2064
+		} else {
2065
+			$error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
2066
+		}
1725 2067
 		if ($error != '') {
1726 2068
 			return $error;
1727
-		} elseif ($globalDebug) echo "Done\n";
1728
-		if ($globalDebug) echo "Owner Luxembourg: Download...";
2069
+		} elseif ($globalDebug) {
2070
+			echo "Done\n";
2071
+		}
2072
+		if ($globalDebug) {
2073
+			echo "Owner Luxembourg: Download...";
2074
+		}
1729 2075
 		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv');
1730 2076
 		if (file_exists($tmp_dir.'owner_lx.csv')) {
1731
-			if ($globalDebug) echo "Add to DB...";
2077
+			if ($globalDebug) {
2078
+				echo "Add to DB...";
2079
+			}
1732 2080
 			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX');
1733
-		} else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
2081
+		} else {
2082
+			$error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
2083
+		}
1734 2084
 		if ($error != '') {
1735 2085
 			return $error;
1736
-		} elseif ($globalDebug) echo "Done\n";
1737
-		if ($globalDebug) echo "Owner Maldives: Download...";
2086
+		} elseif ($globalDebug) {
2087
+			echo "Done\n";
2088
+		}
2089
+		if ($globalDebug) {
2090
+			echo "Owner Maldives: Download...";
2091
+		}
1738 2092
 		update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv');
1739 2093
 		if (file_exists($tmp_dir.'owner_8q.csv')) {
1740
-			if ($globalDebug) echo "Add to DB...";
2094
+			if ($globalDebug) {
2095
+				echo "Add to DB...";
2096
+			}
1741 2097
 			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q');
1742
-		} else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
2098
+		} else {
2099
+			$error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
2100
+		}
1743 2101
 		if ($error != '') {
1744 2102
 			return $error;
1745
-		} elseif ($globalDebug) echo "Done\n";
1746
-		if ($globalDebug) echo "Owner New Zealand: Download...";
2103
+		} elseif ($globalDebug) {
2104
+			echo "Done\n";
2105
+		}
2106
+		if ($globalDebug) {
2107
+			echo "Owner New Zealand: Download...";
2108
+		}
1747 2109
 		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv');
1748 2110
 		if (file_exists($tmp_dir.'owner_zk.csv')) {
1749
-			if ($globalDebug) echo "Add to DB...";
2111
+			if ($globalDebug) {
2112
+				echo "Add to DB...";
2113
+			}
1750 2114
 			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK');
1751
-		} else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
2115
+		} else {
2116
+			$error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
2117
+		}
1752 2118
 		if ($error != '') {
1753 2119
 			return $error;
1754
-		} elseif ($globalDebug) echo "Done\n";
1755
-		if ($globalDebug) echo "Owner Papua New Guinea: Download...";
2120
+		} elseif ($globalDebug) {
2121
+			echo "Done\n";
2122
+		}
2123
+		if ($globalDebug) {
2124
+			echo "Owner Papua New Guinea: Download...";
2125
+		}
1756 2126
 		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv');
1757 2127
 		if (file_exists($tmp_dir.'owner_p2.csv')) {
1758
-			if ($globalDebug) echo "Add to DB...";
2128
+			if ($globalDebug) {
2129
+				echo "Add to DB...";
2130
+			}
1759 2131
 			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2');
1760
-		} else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
2132
+		} else {
2133
+			$error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
2134
+		}
1761 2135
 		if ($error != '') {
1762 2136
 			return $error;
1763
-		} elseif ($globalDebug) echo "Done\n";
1764
-		if ($globalDebug) echo "Owner Slovakia: Download...";
2137
+		} elseif ($globalDebug) {
2138
+			echo "Done\n";
2139
+		}
2140
+		if ($globalDebug) {
2141
+			echo "Owner Slovakia: Download...";
2142
+		}
1765 2143
 		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv');
1766 2144
 		if (file_exists($tmp_dir.'owner_om.csv')) {
1767
-			if ($globalDebug) echo "Add to DB...";
2145
+			if ($globalDebug) {
2146
+				echo "Add to DB...";
2147
+			}
1768 2148
 			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM');
1769
-		} else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
2149
+		} else {
2150
+			$error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
2151
+		}
1770 2152
 		if ($error != '') {
1771 2153
 			return $error;
1772
-		} elseif ($globalDebug) echo "Done\n";
1773
-		if ($globalDebug) echo "Owner Ecuador: Download...";
2154
+		} elseif ($globalDebug) {
2155
+			echo "Done\n";
2156
+		}
2157
+		if ($globalDebug) {
2158
+			echo "Owner Ecuador: Download...";
2159
+		}
1774 2160
 		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv');
1775 2161
 		if (file_exists($tmp_dir.'owner_hc.csv')) {
1776
-			if ($globalDebug) echo "Add to DB...";
2162
+			if ($globalDebug) {
2163
+				echo "Add to DB...";
2164
+			}
1777 2165
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC');
1778
-		} else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
2166
+		} else {
2167
+			$error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
2168
+		}
1779 2169
 		if ($error != '') {
1780 2170
 			return $error;
1781
-		} elseif ($globalDebug) echo "Done\n";
1782
-		if ($globalDebug) echo "Owner Iceland: Download...";
2171
+		} elseif ($globalDebug) {
2172
+			echo "Done\n";
2173
+		}
2174
+		if ($globalDebug) {
2175
+			echo "Owner Iceland: Download...";
2176
+		}
1783 2177
 		update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv');
1784 2178
 		if (file_exists($tmp_dir.'owner_tf.csv')) {
1785
-			if ($globalDebug) echo "Add to DB...";
2179
+			if ($globalDebug) {
2180
+				echo "Add to DB...";
2181
+			}
1786 2182
 			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF');
1787
-		} else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2183
+		} else {
2184
+			$error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2185
+		}
1788 2186
 		if ($error != '') {
1789 2187
 			return $error;
1790
-		} elseif ($globalDebug) echo "Done\n";
2188
+		} elseif ($globalDebug) {
2189
+			echo "Done\n";
2190
+		}
1791 2191
 		return '';
1792 2192
 	}
1793 2193
 
1794 2194
 	public static function update_translation() {
1795 2195
 		global $tmp_dir, $globalDebug;
1796 2196
 		$error = '';
1797
-		if ($globalDebug) echo "Translation : Download...";
2197
+		if ($globalDebug) {
2198
+			echo "Translation : Download...";
2199
+		}
1798 2200
 		update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip');
1799 2201
 		if (file_exists($tmp_dir.'translation.zip')) {
1800
-			if ($globalDebug) echo "Unzip...";
2202
+			if ($globalDebug) {
2203
+				echo "Unzip...";
2204
+			}
1801 2205
 			update_db::unzip($tmp_dir.'translation.zip');
1802
-			if ($globalDebug) echo "Add to DB...";
2206
+			if ($globalDebug) {
2207
+				echo "Add to DB...";
2208
+			}
1803 2209
 			$error = update_db::translation();
1804
-		} else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
2210
+		} else {
2211
+			$error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
2212
+		}
1805 2213
 		if ($error != '') {
1806 2214
 			return $error;
1807
-		} elseif ($globalDebug) echo "Done\n";
2215
+		} elseif ($globalDebug) {
2216
+			echo "Done\n";
2217
+		}
1808 2218
 		return '';
1809 2219
 	}
1810 2220
 
1811 2221
 	public static function update_translation_fam() {
1812 2222
 		global $tmp_dir, $globalDebug;
1813
-		if ($globalDebug) echo "Translation from FlightAirMap website : Download...";
2223
+		if ($globalDebug) {
2224
+			echo "Translation from FlightAirMap website : Download...";
2225
+		}
1814 2226
 		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz');
1815 2227
 		if (file_exists($tmp_dir.'translation.tsv.gz')) {
1816
-			if ($globalDebug) echo "Gunzip...";
2228
+			if ($globalDebug) {
2229
+				echo "Gunzip...";
2230
+			}
1817 2231
 			update_db::gunzip($tmp_dir.'translation.tsv.gz');
1818
-			if ($globalDebug) echo "Add to DB...";
2232
+			if ($globalDebug) {
2233
+				echo "Add to DB...";
2234
+			}
1819 2235
 			$error = update_db::translation_fam();
1820
-		} else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
2236
+		} else {
2237
+			$error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
2238
+		}
1821 2239
 		if ($error != '') {
1822 2240
 			return $error;
1823
-		} elseif ($globalDebug) echo "Done\n";
2241
+		} elseif ($globalDebug) {
2242
+			echo "Done\n";
2243
+		}
1824 2244
 		return '';
1825 2245
 	}
1826 2246
 	public static function update_ModeS_fam() {
1827 2247
 		global $tmp_dir, $globalDebug;
1828
-		if ($globalDebug) echo "ModeS from FlightAirMap website : Download...";
2248
+		if ($globalDebug) {
2249
+			echo "ModeS from FlightAirMap website : Download...";
2250
+		}
1829 2251
 		update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz');
1830 2252
 		if (file_exists($tmp_dir.'modes.tsv.gz')) {
1831
-			if ($globalDebug) echo "Gunzip...";
2253
+			if ($globalDebug) {
2254
+				echo "Gunzip...";
2255
+			}
1832 2256
 			update_db::gunzip($tmp_dir.'modes.tsv.gz');
1833
-			if ($globalDebug) echo "Add to DB...";
2257
+			if ($globalDebug) {
2258
+				echo "Add to DB...";
2259
+			}
1834 2260
 			$error = update_db::modes_fam();
1835
-		} else $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed.";
2261
+		} else {
2262
+			$error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed.";
2263
+		}
1836 2264
 		if ($error != '') {
1837 2265
 			return $error;
1838
-		} elseif ($globalDebug) echo "Done\n";
2266
+		} elseif ($globalDebug) {
2267
+			echo "Done\n";
2268
+		}
1839 2269
 		return '';
1840 2270
 	}
1841 2271
 	public static function update_owner_fam() {
1842 2272
 		global $tmp_dir, $globalDebug, $globalOwner;
1843
-		if ($globalDebug) echo "owner from FlightAirMap website : Download...";
2273
+		if ($globalDebug) {
2274
+			echo "owner from FlightAirMap website : Download...";
2275
+		}
1844 2276
 		if ($globalOwner === TRUE) {
1845 2277
 			update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz');
1846 2278
 		} else {
1847 2279
 			update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz',$tmp_dir.'owners.tsv.gz');
1848 2280
 		}
1849 2281
 		if (file_exists($tmp_dir.'owners.tsv.gz')) {
1850
-			if ($globalDebug) echo "Gunzip...";
2282
+			if ($globalDebug) {
2283
+				echo "Gunzip...";
2284
+			}
1851 2285
 			update_db::gunzip($tmp_dir.'owners.tsv.gz');
1852
-			if ($globalDebug) echo "Add to DB...";
2286
+			if ($globalDebug) {
2287
+				echo "Add to DB...";
2288
+			}
1853 2289
 			$error = update_db::owner_fam();
1854
-		} else $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed.";
2290
+		} else {
2291
+			$error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed.";
2292
+		}
1855 2293
 		if ($error != '') {
1856 2294
 			return $error;
1857
-		} elseif ($globalDebug) echo "Done\n";
2295
+		} elseif ($globalDebug) {
2296
+			echo "Done\n";
2297
+		}
1858 2298
 		return '';
1859 2299
 	}
1860 2300
 	public static function update_routes_fam() {
1861 2301
 		global $tmp_dir, $globalDebug;
1862
-		if ($globalDebug) echo "Routes from FlightAirMap website : Download...";
2302
+		if ($globalDebug) {
2303
+			echo "Routes from FlightAirMap website : Download...";
2304
+		}
1863 2305
 		update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz');
1864 2306
 		if (file_exists($tmp_dir.'routes.tsv.gz')) {
1865
-			if ($globalDebug) echo "Gunzip...";
2307
+			if ($globalDebug) {
2308
+				echo "Gunzip...";
2309
+			}
1866 2310
 			update_db::gunzip($tmp_dir.'routes.tsv.gz');
1867
-			if ($globalDebug) echo "Add to DB...";
2311
+			if ($globalDebug) {
2312
+				echo "Add to DB...";
2313
+			}
1868 2314
 			$error = update_db::routes_fam();
1869
-		} else $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed.";
2315
+		} else {
2316
+			$error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed.";
2317
+		}
1870 2318
 		if ($error != '') {
1871 2319
 			return $error;
1872
-		} elseif ($globalDebug) echo "Done\n";
2320
+		} elseif ($globalDebug) {
2321
+			echo "Done\n";
2322
+		}
1873 2323
 		return '';
1874 2324
 	}
1875 2325
 
@@ -1877,7 +2327,9 @@  discard block
 block discarded – undo
1877 2327
 		global $tmp_dir, $globalDebug, $globalDBdriver;
1878 2328
 		include_once('class.create_db.php');
1879 2329
 		$error = '';
1880
-		if ($globalDebug) echo "Airspace from FlightAirMap website : Download...";
2330
+		if ($globalDebug) {
2331
+			echo "Airspace from FlightAirMap website : Download...";
2332
+		}
1881 2333
 		if ($globalDBdriver == 'mysql') {
1882 2334
 			update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
1883 2335
 		} else {
@@ -1893,9 +2345,13 @@  discard block
 block discarded – undo
1893 2345
 					update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz');
1894 2346
 				}
1895 2347
 				if (file_exists($tmp_dir.'airspace.sql.gz')) {
1896
-					if ($globalDebug) echo "Gunzip...";
2348
+					if ($globalDebug) {
2349
+						echo "Gunzip...";
2350
+					}
1897 2351
 					update_db::gunzip($tmp_dir.'airspace.sql.gz');
1898
-					if ($globalDebug) echo "Add to DB...";
2352
+					if ($globalDebug) {
2353
+						echo "Add to DB...";
2354
+					}
1899 2355
 					$Connection = new Connection();
1900 2356
 					if ($Connection->tableExists('airspace')) {
1901 2357
 						$query = 'DROP TABLE airspace';
@@ -1908,31 +2364,47 @@  discard block
 block discarded – undo
1908 2364
 		    			}
1909 2365
 					$error = create_db::import_file($tmp_dir.'airspace.sql');
1910 2366
 					update_db::insert_airspace_version($airspace_md5);
1911
-				} else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed.";
2367
+				} else {
2368
+					$error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed.";
2369
+				}
1912 2370
 			}
1913
-		} else $error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed.";
2371
+		} else {
2372
+			$error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed.";
2373
+		}
1914 2374
 		if ($error != '') {
1915 2375
 			return $error;
1916
-		} elseif ($globalDebug) echo "Done\n";
2376
+		} elseif ($globalDebug) {
2377
+			echo "Done\n";
2378
+		}
1917 2379
 		return '';
1918 2380
 	}
1919 2381
 
1920 2382
 	public static function update_tle() {
1921 2383
 		global $tmp_dir, $globalDebug;
1922
-		if ($globalDebug) echo "Download TLE : Download...";
2384
+		if ($globalDebug) {
2385
+			echo "Download TLE : Download...";
2386
+		}
1923 2387
 		$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',
1924 2388
 		'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',
1925 2389
 		'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt');
1926 2390
 		foreach ($alltle as $filename) {
1927
-			if ($globalDebug) echo "downloading ".$filename.'...';
2391
+			if ($globalDebug) {
2392
+				echo "downloading ".$filename.'...';
2393
+			}
1928 2394
 			update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename);
1929 2395
 			if (file_exists($tmp_dir.$filename)) {
1930
-				if ($globalDebug) echo "Add to DB ".$filename."...";
2396
+				if ($globalDebug) {
2397
+					echo "Add to DB ".$filename."...";
2398
+				}
1931 2399
 				$error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename));
1932
-			} else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
2400
+			} else {
2401
+				$error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
2402
+			}
1933 2403
 			if ($error != '') {
1934 2404
 				echo $error."\n";
1935
-			} elseif ($globalDebug) echo "Done\n";
2405
+			} elseif ($globalDebug) {
2406
+				echo "Done\n";
2407
+			}
1936 2408
 		}
1937 2409
 		return '';
1938 2410
 	}
@@ -1940,10 +2412,14 @@  discard block
 block discarded – undo
1940 2412
 	public static function update_models() {
1941 2413
 		global $tmp_dir, $globalDebug;
1942 2414
 		$error = '';
1943
-		if ($globalDebug) echo "Models from FlightAirMap website : Download...";
2415
+		if ($globalDebug) {
2416
+			echo "Models from FlightAirMap website : Download...";
2417
+		}
1944 2418
 		update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum');
1945 2419
 		if (file_exists($tmp_dir.'models.md5sum')) {
1946
-			if ($globalDebug) echo "Check files...\n";
2420
+			if ($globalDebug) {
2421
+				echo "Check files...\n";
2422
+			}
1947 2423
 			$newmodelsdb = array();
1948 2424
 			if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) {
1949 2425
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -1962,25 +2438,35 @@  discard block
 block discarded – undo
1962 2438
 			}
1963 2439
 			$diff = array_diff($newmodelsdb,$modelsdb);
1964 2440
 			foreach ($diff as $key => $value) {
1965
-				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
2441
+				if ($globalDebug) {
2442
+					echo 'Downloading model '.$key.' ...'."\n";
2443
+				}
1966 2444
 				update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key);
1967 2445
 				
1968 2446
 			}
1969 2447
 			update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum');
1970
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2448
+		} else {
2449
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2450
+		}
1971 2451
 		if ($error != '') {
1972 2452
 			return $error;
1973
-		} elseif ($globalDebug) echo "Done\n";
2453
+		} elseif ($globalDebug) {
2454
+			echo "Done\n";
2455
+		}
1974 2456
 		return '';
1975 2457
 	}
1976 2458
 
1977 2459
 	public static function update_space_models() {
1978 2460
 		global $tmp_dir, $globalDebug;
1979 2461
 		$error = '';
1980
-		if ($globalDebug) echo "Space models from FlightAirMap website : Download...";
2462
+		if ($globalDebug) {
2463
+			echo "Space models from FlightAirMap website : Download...";
2464
+		}
1981 2465
 		update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum');
1982 2466
 		if (file_exists($tmp_dir.'space_models.md5sum')) {
1983
-			if ($globalDebug) echo "Check files...\n";
2467
+			if ($globalDebug) {
2468
+				echo "Check files...\n";
2469
+			}
1984 2470
 			$newmodelsdb = array();
1985 2471
 			if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) {
1986 2472
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -1999,15 +2485,21 @@  discard block
 block discarded – undo
1999 2485
 			}
2000 2486
 			$diff = array_diff($newmodelsdb,$modelsdb);
2001 2487
 			foreach ($diff as $key => $value) {
2002
-				if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n";
2488
+				if ($globalDebug) {
2489
+					echo 'Downloading space model '.$key.' ...'."\n";
2490
+				}
2003 2491
 				update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key);
2004 2492
 				
2005 2493
 			}
2006 2494
 			update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum');
2007
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2495
+		} else {
2496
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2497
+		}
2008 2498
 		if ($error != '') {
2009 2499
 			return $error;
2010
-		} elseif ($globalDebug) echo "Done\n";
2500
+		} elseif ($globalDebug) {
2501
+			echo "Done\n";
2502
+		}
2011 2503
 		return '';
2012 2504
 	}
2013 2505
 
@@ -2050,7 +2542,9 @@  discard block
 block discarded – undo
2050 2542
                 }
2051 2543
 
2052 2544
 		$error = '';
2053
-		if ($globalDebug) echo "Notam : Download...";
2545
+		if ($globalDebug) {
2546
+			echo "Notam : Download...";
2547
+		}
2054 2548
 		update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss');
2055 2549
 		if (file_exists($tmp_dir.'notam.rss')) {
2056 2550
 			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true);
@@ -2065,14 +2559,30 @@  discard block
 block discarded – undo
2065 2559
 				$data['fir'] = $q[0];
2066 2560
 				$data['code'] = $q[1];
2067 2561
 				$ifrvfr = $q[2];
2068
-				if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR';
2069
-				if ($ifrvfr == 'I') $data['rules'] = 'IFR';
2070
-				if ($ifrvfr == 'V') $data['rules'] = 'VFR';
2071
-				if ($q[4] == 'A') $data['scope'] = 'Airport warning';
2072
-				if ($q[4] == 'E') $data['scope'] = 'Enroute warning';
2073
-				if ($q[4] == 'W') $data['scope'] = 'Navigation warning';
2074
-				if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning';
2075
-				if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning';
2562
+				if ($ifrvfr == 'IV') {
2563
+					$data['rules'] = 'IFR/VFR';
2564
+				}
2565
+				if ($ifrvfr == 'I') {
2566
+					$data['rules'] = 'IFR';
2567
+				}
2568
+				if ($ifrvfr == 'V') {
2569
+					$data['rules'] = 'VFR';
2570
+				}
2571
+				if ($q[4] == 'A') {
2572
+					$data['scope'] = 'Airport warning';
2573
+				}
2574
+				if ($q[4] == 'E') {
2575
+					$data['scope'] = 'Enroute warning';
2576
+				}
2577
+				if ($q[4] == 'W') {
2578
+					$data['scope'] = 'Navigation warning';
2579
+				}
2580
+				if ($q[4] == 'AE') {
2581
+					$data['scope'] = 'Airport/Enroute warning';
2582
+				}
2583
+				if ($q[4] == 'AW') {
2584
+					$data['scope'] = 'Airport/Navigation warning';
2585
+				}
2076 2586
 				//$data['scope'] = $q[4];
2077 2587
 				$data['lower_limit'] = $q[5];
2078 2588
 				$data['upper_limit'] = $q[6];
@@ -2080,8 +2590,12 @@  discard block
 block discarded – undo
2080 2590
 				sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius);
2081 2591
 				$latitude = $Common->convertDec($las,'latitude');
2082 2592
 				$longitude = $Common->convertDec($lns,'longitude');
2083
-				if ($lac == 'S') $latitude = '-'.$latitude;
2084
-				if ($lnc == 'W') $longitude = '-'.$longitude;
2593
+				if ($lac == 'S') {
2594
+					$latitude = '-'.$latitude;
2595
+				}
2596
+				if ($lnc == 'W') {
2597
+					$longitude = '-'.$longitude;
2598
+				}
2085 2599
 				$data['center_latitude'] = $latitude;
2086 2600
 				$data['center_longitude'] = $longitude;
2087 2601
 				$data['radius'] = intval($radius);
@@ -2111,10 +2625,14 @@  discard block
 block discarded – undo
2111 2625
 				$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']);
2112 2626
 				unset($data);
2113 2627
 			} 
2114
-		} else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
2628
+		} else {
2629
+			$error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
2630
+		}
2115 2631
 		if ($error != '') {
2116 2632
 			return $error;
2117
-		} elseif ($globalDebug) echo "Done\n";
2633
+		} elseif ($globalDebug) {
2634
+			echo "Done\n";
2635
+		}
2118 2636
 		return '';
2119 2637
 	}
2120 2638
 	
@@ -2139,7 +2657,9 @@  discard block
 block discarded – undo
2139 2657
 		$airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json');
2140 2658
 		$airspace_json = json_decode($airspace_lst,true);
2141 2659
 		foreach ($airspace_json['records'] as $airspace) {
2142
-			if ($globalDebug) echo $airspace['name']."...\n";
2660
+			if ($globalDebug) {
2661
+				echo $airspace['name']."...\n";
2662
+			}
2143 2663
 			update_db::download($airspace['uri'],$tmp_dir.$airspace['name']);
2144 2664
 			if (file_exists($tmp_dir.$airspace['name'])) {
2145 2665
 				file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name'])));
@@ -2168,8 +2688,11 @@  discard block
 block discarded – undo
2168 2688
                         return "error : ".$e->getMessage();
2169 2689
                 }
2170 2690
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2171
-                if ($row['nb'] > 0) return false;
2172
-                else return true;
2691
+                if ($row['nb'] > 0) {
2692
+                	return false;
2693
+                } else {
2694
+                	return true;
2695
+                }
2173 2696
 	}
2174 2697
 
2175 2698
 	public static function insert_last_update() {
@@ -2194,8 +2717,11 @@  discard block
 block discarded – undo
2194 2717
                         return "error : ".$e->getMessage();
2195 2718
                 }
2196 2719
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2197
-                if ($row['nb'] > 0) return true;
2198
-                else return false;
2720
+                if ($row['nb'] > 0) {
2721
+                	return true;
2722
+                } else {
2723
+                	return false;
2724
+                }
2199 2725
 	}
2200 2726
 
2201 2727
 
@@ -2226,8 +2752,11 @@  discard block
 block discarded – undo
2226 2752
                         return "error : ".$e->getMessage();
2227 2753
                 }
2228 2754
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2229
-                if ($row['nb'] > 0) return false;
2230
-                else return true;
2755
+                if ($row['nb'] > 0) {
2756
+                	return false;
2757
+                } else {
2758
+                	return true;
2759
+                }
2231 2760
 	}
2232 2761
 
2233 2762
 	public static function insert_last_notam_update() {
@@ -2256,8 +2785,11 @@  discard block
 block discarded – undo
2256 2785
                         return "error : ".$e->getMessage();
2257 2786
                 }
2258 2787
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2259
-                if ($row['nb'] > 0) return false;
2260
-                else return true;
2788
+                if ($row['nb'] > 0) {
2789
+                	return false;
2790
+                } else {
2791
+                	return true;
2792
+                }
2261 2793
 	}
2262 2794
 
2263 2795
 	public static function insert_last_airspace_update() {
@@ -2287,8 +2819,11 @@  discard block
 block discarded – undo
2287 2819
                         return "error : ".$e->getMessage();
2288 2820
                 }
2289 2821
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2290
-                if ($row['nb'] > 0) return false;
2291
-                else return true;
2822
+                if ($row['nb'] > 0) {
2823
+                	return false;
2824
+                } else {
2825
+                	return true;
2826
+                }
2292 2827
 	}
2293 2828
 
2294 2829
 	public static function insert_last_owner_update() {
@@ -2317,8 +2852,11 @@  discard block
 block discarded – undo
2317 2852
                         return "error : ".$e->getMessage();
2318 2853
                 }
2319 2854
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2320
-                if ($row['nb'] > 0) return false;
2321
-                else return true;
2855
+                if ($row['nb'] > 0) {
2856
+                	return false;
2857
+                } else {
2858
+                	return true;
2859
+                }
2322 2860
 	}
2323 2861
 
2324 2862
 	public static function insert_last_schedules_update() {
@@ -2347,8 +2885,11 @@  discard block
 block discarded – undo
2347 2885
                         return "error : ".$e->getMessage();
2348 2886
                 }
2349 2887
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2350
-                if ($row['nb'] > 0) return false;
2351
-                else return true;
2888
+                if ($row['nb'] > 0) {
2889
+                	return false;
2890
+                } else {
2891
+                	return true;
2892
+                }
2352 2893
 	}
2353 2894
 
2354 2895
 	public static function insert_last_tle_update() {
Please login to merge, or discard this patch.
incident-latest.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -38,8 +38,12 @@
 block discarded – undo
38 38
 if (!empty($spotter_array) && $spotter_array[0]['query_number_rows'] != 0) {
39 39
 	include('table-output.php');
40 40
 	print '<div class="pagination">';
41
-	if ($limit_previous_1 >= 0) print '<a href="'.$page_url.'/'.$limit_previous_1.','.$limit_previous_2.'">&laquo;'._("Previous Page").'</a>';
42
-	if ($spotter_array[0]['query_number_rows'] == $absolute_difference) print '<a href="'.$page_url.'/'.$limit_end.','.$limit_next.'">'._("Next Page").'&raquo;</a>';
41
+	if ($limit_previous_1 >= 0) {
42
+		print '<a href="'.$page_url.'/'.$limit_previous_1.','.$limit_previous_2.'">&laquo;'._("Previous Page").'</a>';
43
+	}
44
+	if ($spotter_array[0]['query_number_rows'] == $absolute_difference) {
45
+		print '<a href="'.$page_url.'/'.$limit_end.','.$limit_next.'">'._("Next Page").'&raquo;</a>';
46
+	}
43 47
 	print '</div>';
44 48
 }
45 49
 print '</div>';
Please login to merge, or discard this patch.
install/class.update_schema.php 1 patch
Braces   +240 added lines, -90 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";
@@ -1245,8 +1303,11 @@  discard block
 block discarded – undo
1245 1303
     	    if ($Connection->tableExists('aircraft')) {
1246 1304
     		if (!$Connection->tableExists('config')) {
1247 1305
     		    $version = '1';
1248
-    		    if ($update) return self::update_from_1();
1249
-    		    else return $version;
1306
+    		    if ($update) {
1307
+    		    	return self::update_from_1();
1308
+    		    } else {
1309
+    		    	return $version;
1310
+    		    }
1250 1311
 		} else {
1251 1312
     		    $Connection = new Connection();
1252 1313
 		    $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
@@ -1260,122 +1321,211 @@  discard block
 block discarded – undo
1260 1321
     		    if ($update) {
1261 1322
     			if ($result['value'] == '2') {
1262 1323
     			    $error = self::update_from_2();
1263
-    			    if ($error != '') return $error;
1264
-    			    else return self::check_version(true);
1324
+    			    if ($error != '') {
1325
+    			    	return $error;
1326
+    			    } else {
1327
+    			    	return self::check_version(true);
1328
+    			    }
1265 1329
     			} elseif ($result['value'] == '3') {
1266 1330
     			    $error = self::update_from_3();
1267
-    			    if ($error != '') return $error;
1268
-    			    else return self::check_version(true);
1331
+    			    if ($error != '') {
1332
+    			    	return $error;
1333
+    			    } else {
1334
+    			    	return self::check_version(true);
1335
+    			    }
1269 1336
     			} elseif ($result['value'] == '4') {
1270 1337
     			    $error = self::update_from_4();
1271
-    			    if ($error != '') return $error;
1272
-    			    else return self::check_version(true);
1338
+    			    if ($error != '') {
1339
+    			    	return $error;
1340
+    			    } else {
1341
+    			    	return self::check_version(true);
1342
+    			    }
1273 1343
     			} elseif ($result['value'] == '5') {
1274 1344
     			    $error = self::update_from_5();
1275
-    			    if ($error != '') return $error;
1276
-    			    else return self::check_version(true);
1345
+    			    if ($error != '') {
1346
+    			    	return $error;
1347
+    			    } else {
1348
+    			    	return self::check_version(true);
1349
+    			    }
1277 1350
     			} elseif ($result['value'] == '6') {
1278 1351
     			    $error = self::update_from_6();
1279
-    			    if ($error != '') return $error;
1280
-    			    else return self::check_version(true);
1352
+    			    if ($error != '') {
1353
+    			    	return $error;
1354
+    			    } else {
1355
+    			    	return self::check_version(true);
1356
+    			    }
1281 1357
     			} elseif ($result['value'] == '7') {
1282 1358
     			    $error = self::update_from_7();
1283
-    			    if ($error != '') return $error;
1284
-    			    else return self::check_version(true);
1359
+    			    if ($error != '') {
1360
+    			    	return $error;
1361
+    			    } else {
1362
+    			    	return self::check_version(true);
1363
+    			    }
1285 1364
     			} elseif ($result['value'] == '8') {
1286 1365
     			    $error = self::update_from_8();
1287
-    			    if ($error != '') return $error;
1288
-    			    else return self::check_version(true);
1366
+    			    if ($error != '') {
1367
+    			    	return $error;
1368
+    			    } else {
1369
+    			    	return self::check_version(true);
1370
+    			    }
1289 1371
     			} elseif ($result['value'] == '9') {
1290 1372
     			    $error = self::update_from_9();
1291
-    			    if ($error != '') return $error;
1292
-    			    else return self::check_version(true);
1373
+    			    if ($error != '') {
1374
+    			    	return $error;
1375
+    			    } else {
1376
+    			    	return self::check_version(true);
1377
+    			    }
1293 1378
     			} elseif ($result['value'] == '10') {
1294 1379
     			    $error = self::update_from_10();
1295
-    			    if ($error != '') return $error;
1296
-    			    else return self::check_version(true);
1380
+    			    if ($error != '') {
1381
+    			    	return $error;
1382
+    			    } else {
1383
+    			    	return self::check_version(true);
1384
+    			    }
1297 1385
     			} elseif ($result['value'] == '11') {
1298 1386
     			    $error = self::update_from_11();
1299
-    			    if ($error != '') return $error;
1300
-    			    else return self::check_version(true);
1387
+    			    if ($error != '') {
1388
+    			    	return $error;
1389
+    			    } else {
1390
+    			    	return self::check_version(true);
1391
+    			    }
1301 1392
     			} elseif ($result['value'] == '12') {
1302 1393
     			    $error = self::update_from_12();
1303
-    			    if ($error != '') return $error;
1304
-    			    else return self::check_version(true);
1394
+    			    if ($error != '') {
1395
+    			    	return $error;
1396
+    			    } else {
1397
+    			    	return self::check_version(true);
1398
+    			    }
1305 1399
     			} elseif ($result['value'] == '13') {
1306 1400
     			    $error = self::update_from_13();
1307
-    			    if ($error != '') return $error;
1308
-    			    else return self::check_version(true);
1401
+    			    if ($error != '') {
1402
+    			    	return $error;
1403
+    			    } else {
1404
+    			    	return self::check_version(true);
1405
+    			    }
1309 1406
     			} elseif ($result['value'] == '14') {
1310 1407
     			    $error = self::update_from_14();
1311
-    			    if ($error != '') return $error;
1312
-    			    else return self::check_version(true);
1408
+    			    if ($error != '') {
1409
+    			    	return $error;
1410
+    			    } else {
1411
+    			    	return self::check_version(true);
1412
+    			    }
1313 1413
     			} elseif ($result['value'] == '15') {
1314 1414
     			    $error = self::update_from_15();
1315
-    			    if ($error != '') return $error;
1316
-    			    else return self::check_version(true);
1415
+    			    if ($error != '') {
1416
+    			    	return $error;
1417
+    			    } else {
1418
+    			    	return self::check_version(true);
1419
+    			    }
1317 1420
     			} elseif ($result['value'] == '16') {
1318 1421
     			    $error = self::update_from_16();
1319
-    			    if ($error != '') return $error;
1320
-    			    else return self::check_version(true);
1422
+    			    if ($error != '') {
1423
+    			    	return $error;
1424
+    			    } else {
1425
+    			    	return self::check_version(true);
1426
+    			    }
1321 1427
     			} elseif ($result['value'] == '17') {
1322 1428
     			    $error = self::update_from_17();
1323
-    			    if ($error != '') return $error;
1324
-    			    else return self::check_version(true);
1429
+    			    if ($error != '') {
1430
+    			    	return $error;
1431
+    			    } else {
1432
+    			    	return self::check_version(true);
1433
+    			    }
1325 1434
     			} elseif ($result['value'] == '18') {
1326 1435
     			    $error = self::update_from_18();
1327
-    			    if ($error != '') return $error;
1328
-    			    else return self::check_version(true);
1436
+    			    if ($error != '') {
1437
+    			    	return $error;
1438
+    			    } else {
1439
+    			    	return self::check_version(true);
1440
+    			    }
1329 1441
     			} elseif ($result['value'] == '19') {
1330 1442
     			    $error = self::update_from_19();
1331
-    			    if ($error != '') return $error;
1332
-    			    else return self::check_version(true);
1443
+    			    if ($error != '') {
1444
+    			    	return $error;
1445
+    			    } else {
1446
+    			    	return self::check_version(true);
1447
+    			    }
1333 1448
     			} elseif ($result['value'] == '20') {
1334 1449
     			    $error = self::update_from_20();
1335
-    			    if ($error != '') return $error;
1336
-    			    else return self::check_version(true);
1450
+    			    if ($error != '') {
1451
+    			    	return $error;
1452
+    			    } else {
1453
+    			    	return self::check_version(true);
1454
+    			    }
1337 1455
     			} elseif ($result['value'] == '21') {
1338 1456
     			    $error = self::update_from_21();
1339
-    			    if ($error != '') return $error;
1340
-    			    else return self::check_version(true);
1457
+    			    if ($error != '') {
1458
+    			    	return $error;
1459
+    			    } else {
1460
+    			    	return self::check_version(true);
1461
+    			    }
1341 1462
     			} elseif ($result['value'] == '22') {
1342 1463
     			    $error = self::update_from_22();
1343
-    			    if ($error != '') return $error;
1344
-    			    else return self::check_version(true);
1464
+    			    if ($error != '') {
1465
+    			    	return $error;
1466
+    			    } else {
1467
+    			    	return self::check_version(true);
1468
+    			    }
1345 1469
     			} elseif ($result['value'] == '23') {
1346 1470
     			    $error = self::update_from_23();
1347
-    			    if ($error != '') return $error;
1348
-    			    else return self::check_version(true);
1471
+    			    if ($error != '') {
1472
+    			    	return $error;
1473
+    			    } else {
1474
+    			    	return self::check_version(true);
1475
+    			    }
1349 1476
     			} elseif ($result['value'] == '24') {
1350 1477
     			    $error = self::update_from_24();
1351
-    			    if ($error != '') return $error;
1352
-    			    else return self::check_version(true);
1478
+    			    if ($error != '') {
1479
+    			    	return $error;
1480
+    			    } else {
1481
+    			    	return self::check_version(true);
1482
+    			    }
1353 1483
     			} elseif ($result['value'] == '25') {
1354 1484
     			    $error = self::update_from_25();
1355
-    			    if ($error != '') return $error;
1356
-    			    else return self::check_version(true);
1485
+    			    if ($error != '') {
1486
+    			    	return $error;
1487
+    			    } else {
1488
+    			    	return self::check_version(true);
1489
+    			    }
1357 1490
     			} elseif ($result['value'] == '26') {
1358 1491
     			    $error = self::update_from_26();
1359
-    			    if ($error != '') return $error;
1360
-    			    else return self::check_version(true);
1492
+    			    if ($error != '') {
1493
+    			    	return $error;
1494
+    			    } else {
1495
+    			    	return self::check_version(true);
1496
+    			    }
1361 1497
     			} elseif ($result['value'] == '27') {
1362 1498
     			    $error = self::update_from_27();
1363
-    			    if ($error != '') return $error;
1364
-    			    else return self::check_version(true);
1499
+    			    if ($error != '') {
1500
+    			    	return $error;
1501
+    			    } else {
1502
+    			    	return self::check_version(true);
1503
+    			    }
1365 1504
     			} elseif ($result['value'] == '28') {
1366 1505
     			    $error = self::update_from_28();
1367
-    			    if ($error != '') return $error;
1368
-    			    else return self::check_version(true);
1506
+    			    if ($error != '') {
1507
+    			    	return $error;
1508
+    			    } else {
1509
+    			    	return self::check_version(true);
1510
+    			    }
1369 1511
     			} elseif ($result['value'] == '29') {
1370 1512
     			    $error = self::update_from_29();
1371
-    			    if ($error != '') return $error;
1372
-    			    else return self::check_version(true);
1373
-    			} else return '';
1513
+    			    if ($error != '') {
1514
+    			    	return $error;
1515
+    			    } else {
1516
+    			    	return self::check_version(true);
1517
+    			    }
1518
+    			} else {
1519
+    				return '';
1520
+    			}
1521
+    		    } else {
1522
+    		    	return $result['value'];
1374 1523
     		    }
1375
-    		    else return $result['value'];
1376 1524
 		}
1377 1525
 		
1378
-	    } else return $version;
1526
+	    } else {
1527
+	    	return $version;
1528
+	    }
1379 1529
     	}
1380 1530
     	
1381 1531
 }
Please login to merge, or discard this patch.
require/class.METAR.php 1 patch
Braces   +94 added lines, -36 removed lines patch added patch discarded remove patch
@@ -59,8 +59,11 @@  discard block
 block discarded – undo
59 59
                 }
60 60
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
61 61
                 $sth->closeCursor();
62
-                if ($row['nb'] > 0) return false;
63
-                else return true;
62
+                if ($row['nb'] > 0) {
63
+                	return false;
64
+                } else {
65
+                	return true;
66
+                }
64 67
         }
65 68
 
66 69
         public static function insert_last_update() {
@@ -84,9 +87,14 @@  discard block
 block discarded – undo
84 87
     		//$pieces = explode(' ',$data);
85 88
     		$pieces = preg_split('/\s/',$data);
86 89
     		$pos = 0;
87
-    		if ($pieces[0] == 'METAR') $pos++;
88
-    		elseif ($pieces[0] == 'SPECI') $pos++;
89
-    		if (strlen($pieces[$pos]) != 4) $pos++;
90
+    		if ($pieces[0] == 'METAR') {
91
+    			$pos++;
92
+    		} elseif ($pieces[0] == 'SPECI') {
93
+    			$pos++;
94
+    		}
95
+    		if (strlen($pieces[$pos]) != 4) {
96
+    			$pos++;
97
+    		}
90 98
     		$result = array();
91 99
     		$result['location'] = $pieces[$pos];
92 100
     		$pos++;
@@ -95,16 +103,26 @@  discard block
 block discarded – undo
95 103
     		$c = count($pieces);
96 104
     		for($pos++; $pos < $c; $pos++) {
97 105
     			$piece = $pieces[$pos];
98
-    			if ($piece == 'RMK') break;
99
-    			if ($piece == 'AUTO') $result['auto'] = true;
100
-    			if ($piece == 'COR') $result['correction'] = true;
106
+    			if ($piece == 'RMK') {
107
+    				break;
108
+    			}
109
+    			if ($piece == 'AUTO') {
110
+    				$result['auto'] = true;
111
+    			}
112
+    			if ($piece == 'COR') {
113
+    				$result['correction'] = true;
114
+    			}
101 115
     			// Wind Speed
102 116
     			if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) {
103 117
     				$result['wind']['direction'] = (float)$matches[1];
104 118
 				$result['wind']['unit'] = $matches[4];
105
-    				if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2);
106
-    				elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2);
107
-    				elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2);
119
+    				if ($result['wind']['unit'] == 'KT') {
120
+    					$result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2);
121
+    				} elseif ($result['wind']['unit'] == 'KPH') {
122
+    					$result['wind']['speed'] = round(((float)$matches[2])*1000,2);
123
+    				} elseif ($result['wind']['unit'] == 'MPS') {
124
+    					$result['wind']['speed'] = round(((float)$matches[2]),2);
125
+    				}
108 126
 				$result['wind']['gust'] = (float)$matches[3];
109 127
 				$result['wind']['unit'] = $matches[4];
110 128
 				$result['wind']['min_variation'] = array_key_exists(5,$matches) ? $matches[5] : 0;
@@ -186,14 +204,23 @@  discard block
 block discarded – undo
186 204
     				//$this->addCloudCover($matches[1], ((float)$matches[2]) * 100, isset($matches[3]) ? $matches[3] : '');
187 205
     				$type = $matches[1];
188 206
     				$cloud = array();
189
-    				if ($type == 'SKC') $cloud['type'] = 'No cloud/Sky clear';
190
-    				elseif ($type == 'CLR') $cloud['type'] = 'No cloud below 12,000ft (3700m)';
191
-    				elseif ($type == 'NSC') $cloud['type'] = 'No significant cloud';
192
-    				elseif ($type == 'FEW') $cloud['type'] = 'Few';
193
-    				elseif ($type == 'SCT') $cloud['type'] = 'Scattered';
194
-    				elseif ($type == 'BKN') $cloud['type'] = 'Broken';
195
-    				elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage';
196
-    				elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility';
207
+    				if ($type == 'SKC') {
208
+    					$cloud['type'] = 'No cloud/Sky clear';
209
+    				} elseif ($type == 'CLR') {
210
+    					$cloud['type'] = 'No cloud below 12,000ft (3700m)';
211
+    				} elseif ($type == 'NSC') {
212
+    					$cloud['type'] = 'No significant cloud';
213
+    				} elseif ($type == 'FEW') {
214
+    					$cloud['type'] = 'Few';
215
+    				} elseif ($type == 'SCT') {
216
+    					$cloud['type'] = 'Scattered';
217
+    				} elseif ($type == 'BKN') {
218
+    					$cloud['type'] = 'Broken';
219
+    				} elseif ($type == 'OVC') {
220
+    					$cloud['type'] = 'Overcast/Full cloud coverage';
221
+    				} elseif ($type == 'VV') {
222
+    					$cloud['type'] = 'Vertical visibility';
223
+    				}
197 224
     				$cloud['type_code'] = $type;
198 225
     				$cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048);
199 226
     				$cloud['significant'] = isset($matches[3]) ? $matches[3] : '';
@@ -223,8 +250,11 @@  discard block
 block discarded – undo
223 250
     			if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
224 251
     				//echo $piece;
225 252
     				//print_r($matches);
226
-    				if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
227
-    				else $range = array('exact' => (float)$matches[2], 'unit' => 'M');
253
+    				if (isset($matches[5])) {
254
+    					$range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
255
+    				} else {
256
+    					$range = array('exact' => (float)$matches[2], 'unit' => 'M');
257
+    				}
228 258
 				if (isset($matches[3])) {
229 259
 					$range = Array(
230 260
 					    'from' => (float)$matches[2],
@@ -257,8 +287,11 @@  discard block
 block discarded – undo
257 287
 				if (isset($matches[3])) {
258 288
 					$text[] = $this->texts[$matches[3]];
259 289
 				}
260
-				if (!isset($result['weather'])) $result['weather'] = implode(' ', $text);
261
-				else $result['weather'] = $result['weather'].' / '.implode(' ', $text);
290
+				if (!isset($result['weather'])) {
291
+					$result['weather'] = implode(' ', $text);
292
+				} else {
293
+					$result['weather'] = $result['weather'].' / '.implode(' ', $text);
294
+				}
262 295
     			}
263 296
     		}
264 297
     		return $result;
@@ -270,8 +303,11 @@  discard block
 block discarded – undo
270 303
     		if (isset($globalMETARcycle) && $globalMETARcycle) {
271 304
             		$query = "SELECT * FROM metar WHERE metar_location = :icao";
272 305
                 } else {
273
-            		if ($globalDBdriver == 'mysql') $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1";
274
-            		else $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1";
306
+            		if ($globalDBdriver == 'mysql') {
307
+            			$query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1";
308
+            		} else {
309
+            			$query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1";
310
+            		}
275 311
                 }
276 312
                 $query_values = array(':icao' => $icao);
277 313
                  try {
@@ -326,7 +362,9 @@  discard block
 block discarded – undo
326 362
         
327 363
         public function addMETARCycle() {
328 364
     		global $globalDebug, $globalIVAO;
329
-    		if (isset($globalDebug) && $globalDebug) echo "Downloading METAR cycle...";
365
+    		if (isset($globalDebug) && $globalDebug) {
366
+    			echo "Downloading METAR cycle...";
367
+    		}
330 368
     		date_default_timezone_set("UTC");
331 369
     		$Common = new Common();
332 370
     		if (isset($globalIVAO) && $globalIVAO) {
@@ -339,7 +377,9 @@  discard block
 block discarded – undo
339 377
     			$handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT',"r");
340 378
     		}
341 379
     		if ($handle) {
342
-			if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB...";
380
+			if (isset($globalDebug) && $globalDebug) {
381
+				echo "Done - Updating DB...";
382
+			}
343 383
 			$date = '';
344 384
     			//foreach(explode("\n",$cycle) as $line) {
345 385
 	    		while(($line = fgets($handle,4096)) !== false) {
@@ -347,23 +387,33 @@  discard block
 block discarded – undo
347 387
 					$date = $line;
348 388
     				} elseif ($line != '') {
349 389
     				    //$this->parse($line);
350
-    				    if ($date == '') $date = date('Y/m/d H:m');
390
+    				    if ($date == '') {
391
+    				    	$date = date('Y/m/d H:m');
392
+    				    }
351 393
         			    $pos = 0;
352 394
         			    $pieces = preg_split('/\s/',$line);
353
-        			    if ($pieces[0] == 'METAR') $pos++;
354
-        			    if (strlen($pieces[$pos]) != 4) $pos++;
395
+        			    if ($pieces[0] == 'METAR') {
396
+        			    	$pos++;
397
+        			    }
398
+        			    if (strlen($pieces[$pos]) != 4) {
399
+        			    	$pos++;
400
+        			    }
355 401
 		        	    $location = $pieces[$pos];
356 402
         	        	    echo $this->addMETAR($location,$line,$date);
357 403
     				}
358 404
     			}
359 405
     			fclose($handle);
360 406
     		}
361
-    		if (isset($globalDebug) && $globalDebug) echo "Done\n";
407
+    		if (isset($globalDebug) && $globalDebug) {
408
+    			echo "Done\n";
409
+    		}
362 410
         
363 411
         }
364 412
         public function downloadMETAR($icao) {
365 413
     		global $globalMETARurl;
366
-    		if ($globalMETARurl == '') return array();
414
+    		if ($globalMETARurl == '') {
415
+    			return array();
416
+    		}
367 417
     		date_default_timezone_set("UTC");
368 418
     		$Common = new Common();
369 419
     		$url = str_replace('{icao}',$icao,$globalMETARurl);
@@ -377,16 +427,24 @@  discard block
 block discarded – undo
377 427
     			if ($line != '') {
378 428
     			    //$this->parse($line);
379 429
     			    //echo $line;
380
-    			    if ($date == '') $date = date('Y/m/d H:m');
430
+    			    if ($date == '') {
431
+    			    	$date = date('Y/m/d H:m');
432
+    			    }
381 433
     			    $pos = 0;
382 434
     			    $pieces = preg_split('/\s/',$line);
383
-    			    if ($pieces[0] == 'METAR') $pos++;
384
-    			    if (strlen($pieces[$pos]) != 4) $pos++;
435
+    			    if ($pieces[0] == 'METAR') {
436
+    			    	$pos++;
437
+    			    }
438
+    			    if (strlen($pieces[$pos]) != 4) {
439
+    			    	$pos++;
440
+    			    }
385 441
 	        	    $location = $pieces[$pos];
386 442
 	        	    if (strlen($location == 4)) {
387 443
 	        		$this->addMETAR($location,$line,$date);
388 444
 	        		return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line));
389
-	        	    } else return array();
445
+	        	    } else {
446
+	        	    	return array();
447
+	        	    }
390 448
     			}
391 449
     			//echo $line."\n";
392 450
     		}
Please login to merge, or discard this patch.
require/class.Common.php 1 patch
Braces   +46 added lines, -17 removed lines patch added patch discarded remove patch
@@ -27,8 +27,11 @@  discard block
 block discarded – undo
27 27
 		} else {
28 28
 			curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
29 29
 		}
30
-		if ($timeout == '') curl_setopt($ch, CURLOPT_TIMEOUT, 10); 
31
-		else curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); 
30
+		if ($timeout == '') {
31
+			curl_setopt($ch, CURLOPT_TIMEOUT, 10);
32
+		} else {
33
+			curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
34
+		}
32 35
 		curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common',"curlResponseHeaderCallback"));
33 36
 		if ($type == 'post') {
34 37
 			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
@@ -74,8 +77,9 @@  discard block
 block discarded – undo
74 77
 	private function curlResponseHeaderCallback($ch, $headerLine) {
75 78
 		//global $cookies;
76 79
 		$cookies = array();
77
-		if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1)
78
-			$cookies[] = $cookie;
80
+		if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1) {
81
+					$cookies[] = $cookie;
82
+		}
79 83
 		return strlen($headerLine); // Needed by curl
80 84
 	}
81 85
 
@@ -85,7 +89,9 @@  discard block
 block discarded – undo
85 89
 		curl_setopt($ch, CURLOPT_URL, $url);
86 90
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
87 91
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
88
-		if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer);
92
+		if ($referer != '') {
93
+			curl_setopt($ch, CURLOPT_REFERER, $referer);
94
+		}
89 95
 		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');
90 96
 		curl_setopt($ch, CURLOPT_FILE, $fp);
91 97
 		curl_exec($ch);
@@ -99,10 +105,16 @@  discard block
 block discarded – undo
99 105
 	* @return Array array of the tables in HTML page
100 106
 	*/
101 107
 	public function table2array($data) {
102
-		if (!is_string($data)) return array();
103
-		if ($data == '') return array();
108
+		if (!is_string($data)) {
109
+			return array();
110
+		}
111
+		if ($data == '') {
112
+			return array();
113
+		}
104 114
 		$html = str_get_html($data);
105
-		if ($html === false) return array();
115
+		if ($html === false) {
116
+			return array();
117
+		}
106 118
 		$tabledata=array();
107 119
 		foreach($html->find('tr') as $element)
108 120
 		{
@@ -137,7 +149,9 @@  discard block
 block discarded – undo
137 149
 	*/
138 150
 	public function text2array($data) {
139 151
 		$html = str_get_html($data);
140
-		if ($html === false) return array();
152
+		if ($html === false) {
153
+			return array();
154
+		}
141 155
 		$tabledata=array();
142 156
 		foreach($html->find('p') as $element)
143 157
 		{
@@ -158,7 +172,9 @@  discard block
 block discarded – undo
158 172
 	* @return Float Distance in $unit
159 173
 	*/
160 174
 	public function distance($lat, $lon, $latc, $lonc, $unit = 'km') {
161
-		if ($lat == $latc && $lon == $lonc) return 0;
175
+		if ($lat == $latc && $lon == $lonc) {
176
+			return 0;
177
+		}
162 178
 		$dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc)))+ cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon)-floatval($lonc)))))*60*1.1515;
163 179
 		if ($unit == "km") {
164 180
 			return round($dist * 1.609344);
@@ -182,10 +198,16 @@  discard block
 block discarded – undo
182 198
 	public function withinThreshold ($timeDifference, $distance) {
183 199
 		$x = abs($timeDifference);
184 200
 		$d = abs($distance);
185
-		if ($x == 0 || $d == 0) return true;
201
+		if ($x == 0 || $d == 0) {
202
+			return true;
203
+		}
186 204
 		// may be due to Internet jitter; distance is realistic
187
-		if ($x < 0.7 && $d < 2000) return true;
188
-		else return $d/$x < 1500*0.27778; // 1500 km/h max
205
+		if ($x < 0.7 && $d < 2000) {
206
+			return true;
207
+		} else {
208
+			return $d/$x < 1500*0.27778;
209
+		}
210
+		// 1500 km/h max
189 211
 	}
190 212
 
191 213
 
@@ -245,7 +267,9 @@  discard block
 block discarded – undo
245 267
 	public function hex2str($hex) {
246 268
 		$str = '';
247 269
 		$hexln = strlen($hex);
248
-		for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2)));
270
+		for($i=0;$i<$hexln;$i+=2) {
271
+			$str .= chr(hexdec(substr($hex,$i,2)));
272
+		}
249 273
 		return $str;
250 274
 	}
251 275
 	
@@ -273,8 +297,11 @@  discard block
 block discarded – undo
273 297
 		$b = $lat2 - $lat1;
274 298
 		$c = -($a*$lat1+$b*$lon1);
275 299
 		$d = $a*$lat3+$b*$lon3+$c;
276
-		if ($d > -$approx && $d < $approx) return true;
277
-		else return false;
300
+		if ($d > -$approx && $d < $approx) {
301
+			return true;
302
+		} else {
303
+			return false;
304
+		}
278 305
 	}
279 306
 	
280 307
 	public function array_merge_noappend() {
@@ -310,7 +337,9 @@  discard block
 block discarded – undo
310 337
 			return $result;
311 338
 		}
312 339
 		$handle = @opendir('./locale');
313
-		if ($handle === false) return $result;
340
+		if ($handle === false) {
341
+			return $result;
342
+		}
314 343
 		while (false !== ($file = readdir($handle))) {
315 344
 			$path = './locale'.'/'.$file.'/LC_MESSAGES/fam.mo';
316 345
 			if ($file != "." && $file != ".." && @file_exists($path)) {
Please login to merge, or discard this patch.
require/class.Stats.php 1 patch
Braces   +389 added lines, -135 removed lines patch added patch discarded remove patch
@@ -12,7 +12,9 @@  discard block
 block discarded – undo
12 12
 	
13 13
 	public function __construct($dbc = null) {
14 14
 		global $globalFilterName;
15
-		if (isset($globalFilterName)) $this->filter_name = $globalFilterName;
15
+		if (isset($globalFilterName)) {
16
+			$this->filter_name = $globalFilterName;
17
+		}
16 18
 		$Connection = new Connection($dbc);
17 19
 		$this->db = $Connection->db();
18 20
         }
@@ -77,7 +79,9 @@  discard block
 block discarded – undo
77 79
                 }
78 80
         }
79 81
 	public function getAllAirlineNames($filter_name = '') {
80
-		if ($filter_name == '') $filter_name = $this->filter_name;
82
+		if ($filter_name == '') {
83
+			$filter_name = $this->filter_name;
84
+		}
81 85
                 $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC";
82 86
                  try {
83 87
                         $sth = $this->db->prepare($query);
@@ -89,7 +93,9 @@  discard block
 block discarded – undo
89 93
                 return $all;
90 94
         }
91 95
 	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
92
-		if ($filter_name == '') $filter_name = $this->filter_name;
96
+		if ($filter_name == '') {
97
+			$filter_name = $this->filter_name;
98
+		}
93 99
                 $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
94 100
                  try {
95 101
                         $sth = $this->db->prepare($query);
@@ -101,7 +107,9 @@  discard block
 block discarded – undo
101 107
                 return $all;
102 108
         }
103 109
 	public function getAllManufacturers($stats_airline = '',$filter_name = '') {
104
-		if ($filter_name == '') $filter_name = $this->filter_name;
110
+		if ($filter_name == '') {
111
+			$filter_name = $this->filter_name;
112
+		}
105 113
                 $query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC";
106 114
                  try {
107 115
                         $sth = $this->db->prepare($query);
@@ -113,7 +121,9 @@  discard block
 block discarded – undo
113 121
                 return $all;
114 122
         }
115 123
 	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
116
-		if ($filter_name == '') $filter_name = $this->filter_name;
124
+		if ($filter_name == '') {
125
+			$filter_name = $this->filter_name;
126
+		}
117 127
                 $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC";
118 128
                  try {
119 129
                         $sth = $this->db->prepare($query);
@@ -128,9 +138,14 @@  discard block
 block discarded – undo
128 138
 
129 139
 	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '') {
130 140
 		global $globalStatsFilters;
131
-		if ($filter_name == '') $filter_name = $this->filter_name;
132
-		if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
133
-		else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
141
+		if ($filter_name == '') {
142
+			$filter_name = $this->filter_name;
143
+		}
144
+		if ($limit) {
145
+			$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
146
+		} else {
147
+			$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
148
+		}
134 149
                  try {
135 150
                         $sth = $this->db->prepare($query);
136 151
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -150,9 +165,14 @@  discard block
 block discarded – undo
150 165
 	}
151 166
 	public function countAllAirlineCountries($limit = true,$filter_name = '') {
152 167
 		global $globalStatsFilters;
153
-		if ($filter_name == '') $filter_name = $this->filter_name;
154
-		if ($limit) $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0";
155
-		else $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC";
168
+		if ($filter_name == '') {
169
+			$filter_name = $this->filter_name;
170
+		}
171
+		if ($limit) {
172
+			$query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0";
173
+		} else {
174
+			$query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC";
175
+		}
156 176
                  try {
157 177
                         $sth = $this->db->prepare($query);
158 178
                         $sth->execute(array(':filter_name' => $filter_name));
@@ -172,9 +192,14 @@  discard block
 block discarded – undo
172 192
 	}
173 193
 	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '') {
174 194
 		global $globalStatsFilters;
175
-		if ($filter_name == '') $filter_name = $this->filter_name;
176
-		if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
177
-		else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
195
+		if ($filter_name == '') {
196
+			$filter_name = $this->filter_name;
197
+		}
198
+		if ($limit) {
199
+			$query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
200
+		} else {
201
+			$query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
202
+		}
178 203
                  try {
179 204
                         $sth = $this->db->prepare($query);
180 205
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -195,9 +220,14 @@  discard block
 block discarded – undo
195 220
 
196 221
 	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '') {
197 222
 		global $globalStatsFilters;
198
-		if ($filter_name == '') $filter_name = $this->filter_name;
199
-		if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
200
-		else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC";
223
+		if ($filter_name == '') {
224
+			$filter_name = $this->filter_name;
225
+		}
226
+		if ($limit) {
227
+			$query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
228
+		} else {
229
+			$query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC";
230
+		}
201 231
                  try {
202 232
                         $sth = $this->db->prepare($query);
203 233
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -217,9 +247,14 @@  discard block
 block discarded – undo
217 247
 	}
218 248
 	public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '') {
219 249
 		global $globalStatsFilters;
220
-		if ($filter_name == '') $filter_name = $this->filter_name;
221
-		if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
222
-		else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC";
250
+		if ($filter_name == '') {
251
+			$filter_name = $this->filter_name;
252
+		}
253
+		if ($limit) {
254
+			$query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
255
+		} else {
256
+			$query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC";
257
+		}
223 258
                  try {
224 259
                         $sth = $this->db->prepare($query);
225 260
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -240,9 +275,14 @@  discard block
 block discarded – undo
240 275
 
241 276
 	public function countAllAirlines($limit = true,$filter_name = '') {
242 277
 		global $globalStatsFilters;
243
-		if ($filter_name == '') $filter_name = $this->filter_name;
244
-		if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
245
-		else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC";
278
+		if ($filter_name == '') {
279
+			$filter_name = $this->filter_name;
280
+		}
281
+		if ($limit) {
282
+			$query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
283
+		} else {
284
+			$query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC";
285
+		}
246 286
                  try {
247 287
                         $sth = $this->db->prepare($query);
248 288
                         $sth->execute(array(':filter_name' => $filter_name));
@@ -263,9 +303,14 @@  discard block
 block discarded – undo
263 303
 	}
264 304
 	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '') {
265 305
 		global $globalStatsFilters;
266
-		if ($filter_name == '') $filter_name = $this->filter_name;
267
-		if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0";
268
-		else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC";
306
+		if ($filter_name == '') {
307
+			$filter_name = $this->filter_name;
308
+		}
309
+		if ($limit) {
310
+			$query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0";
311
+		} else {
312
+			$query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC";
313
+		}
269 314
                  try {
270 315
                         $sth = $this->db->prepare($query);
271 316
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -285,9 +330,14 @@  discard block
 block discarded – undo
285 330
 	}
286 331
 	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '') {
287 332
 		global $globalStatsFilters;
288
-		if ($filter_name == '') $filter_name = $this->filter_name;
289
-		if ($limit) $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
290
-		else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
333
+		if ($filter_name == '') {
334
+			$filter_name = $this->filter_name;
335
+		}
336
+		if ($limit) {
337
+			$query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
338
+		} else {
339
+			$query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
340
+		}
291 341
 		 try {
292 342
 			$sth = $this->db->prepare($query);
293 343
 			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -307,10 +357,15 @@  discard block
 block discarded – undo
307 357
 	}
308 358
 	public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '') {
309 359
 		$Connection = new Connection();
310
-		if ($filter_name == '') $filter_name = $this->filter_name;
360
+		if ($filter_name == '') {
361
+			$filter_name = $this->filter_name;
362
+		}
311 363
 		if ($Connection->tableExists('countries')) {
312
-			if ($limit) $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0";
313
-			else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC";
364
+			if ($limit) {
365
+				$query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0";
366
+			} else {
367
+				$query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC";
368
+			}
314 369
 			 try {
315 370
 				$sth = $this->db->prepare($query);
316 371
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -331,9 +386,14 @@  discard block
 block discarded – undo
331 386
 	}
332 387
 	public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '') {
333 388
 		global $globalStatsFilters;
334
-		if ($filter_name == '') $filter_name = $this->filter_name;
335
-		if ($limit) $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0";
336
-		else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC";
389
+		if ($filter_name == '') {
390
+			$filter_name = $this->filter_name;
391
+		}
392
+		if ($limit) {
393
+			$query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0";
394
+		} else {
395
+			$query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC";
396
+		}
337 397
                  try {
338 398
                         $sth = $this->db->prepare($query);
339 399
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -353,9 +413,14 @@  discard block
 block discarded – undo
353 413
 	}
354 414
 	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '') {
355 415
 		global $globalStatsFilters;
356
-		if ($filter_name == '') $filter_name = $this->filter_name;
357
-		if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
358
-		else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC";
416
+		if ($filter_name == '') {
417
+			$filter_name = $this->filter_name;
418
+		}
419
+		if ($limit) {
420
+			$query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
421
+		} else {
422
+			$query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC";
423
+		}
359 424
                  try {
360 425
                         $sth = $this->db->prepare($query);
361 426
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -375,9 +440,14 @@  discard block
 block discarded – undo
375 440
 	}
376 441
 	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '') {
377 442
 		global $globalStatsFilters;
378
-		if ($filter_name == '') $filter_name = $this->filter_name;
379
-		if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
380
-		else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
443
+		if ($filter_name == '') {
444
+			$filter_name = $this->filter_name;
445
+		}
446
+		if ($limit) {
447
+			$query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
448
+		} else {
449
+			$query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
450
+		}
381 451
                  try {
382 452
                         $sth = $this->db->prepare($query);
383 453
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -403,7 +473,9 @@  discard block
 block discarded – undo
403 473
         			$icao = $value['airport_departure_icao'];
404 474
         			if (isset($all[$icao])) {
405 475
         				$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
406
-        			} else $all[$icao] = $value;
476
+        			} else {
477
+        				$all[$icao] = $value;
478
+        			}
407 479
         		}
408 480
         		$count = array();
409 481
         		foreach ($all as $key => $row) {
@@ -415,9 +487,14 @@  discard block
 block discarded – undo
415 487
 	}
416 488
 	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '') {
417 489
 		global $globalStatsFilters;
418
-		if ($filter_name == '') $filter_name = $this->filter_name;
419
-		if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
420
-		else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
490
+		if ($filter_name == '') {
491
+			$filter_name = $this->filter_name;
492
+		}
493
+		if ($limit) {
494
+			$query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
495
+		} else {
496
+			$query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
497
+		}
421 498
 		try {
422 499
 			$sth = $this->db->prepare($query);
423 500
 			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -443,7 +520,9 @@  discard block
 block discarded – undo
443 520
         			$icao = $value['airport_arrival_icao'];
444 521
         			if (isset($all[$icao])) {
445 522
         				$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
446
-        			} else $all[$icao] = $value;
523
+        			} else {
524
+        				$all[$icao] = $value;
525
+        			}
447 526
         		}
448 527
         		$count = array();
449 528
         		foreach ($all as $key => $row) {
@@ -456,13 +535,21 @@  discard block
 block discarded – undo
456 535
 	}
457 536
 	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
458 537
 		global $globalDBdriver, $globalStatsFilters;
459
-		if ($filter_name == '') $filter_name = $this->filter_name;
538
+		if ($filter_name == '') {
539
+			$filter_name = $this->filter_name;
540
+		}
460 541
 		if ($globalDBdriver == 'mysql') {
461
-			if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name";
462
-			else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
542
+			if ($limit) {
543
+				$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name";
544
+			} else {
545
+				$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
546
+			}
463 547
 		} else {
464
-			if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
465
-			else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
548
+			if ($limit) {
549
+				$query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
550
+			} else {
551
+				$query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
552
+			}
466 553
 		}
467 554
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
468 555
                  try {
@@ -486,7 +573,9 @@  discard block
 block discarded – undo
486 573
 	
487 574
 	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
488 575
 		global $globalStatsFilters;
489
-		if ($filter_name == '') $filter_name = $this->filter_name;
576
+		if ($filter_name == '') {
577
+			$filter_name = $this->filter_name;
578
+		}
490 579
 		$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline = :stats_airline AND filter_name = :filter_name";
491 580
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
492 581
                  try {
@@ -508,7 +597,9 @@  discard block
 block discarded – undo
508 597
 	}
509 598
 	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
510 599
 		global $globalDBdriver, $globalStatsFilters;
511
-		if ($filter_name == '') $filter_name = $this->filter_name;
600
+		if ($filter_name == '') {
601
+			$filter_name = $this->filter_name;
602
+		}
512 603
 		if ($globalDBdriver == 'mysql') {
513 604
 			$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND stats_airline = :stats_airline AND filter_name = :filter_name";
514 605
 		} else {
@@ -534,7 +625,9 @@  discard block
 block discarded – undo
534 625
 	}
535 626
 	public function countAllDates($stats_airline = '',$filter_name = '') {
536 627
 		global $globalStatsFilters;
537
-		if ($filter_name == '') $filter_name = $this->filter_name;
628
+		if ($filter_name == '') {
629
+			$filter_name = $this->filter_name;
630
+		}
538 631
 		$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline = :stats_airline AND filter_name = :filter_name";
539 632
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
540 633
                  try {
@@ -556,7 +649,9 @@  discard block
 block discarded – undo
556 649
 	}
557 650
 	public function countAllDatesByAirlines($filter_name = '') {
558 651
 		global $globalStatsFilters;
559
-		if ($filter_name == '') $filter_name = $this->filter_name;
652
+		if ($filter_name == '') {
653
+			$filter_name = $this->filter_name;
654
+		}
560 655
 		$query = "SELECT stats_airline as airline_icao, flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND filter_name = :filter_name";
561 656
 		$query_data = array('filter_name' => $filter_name);
562 657
                  try {
@@ -578,7 +673,9 @@  discard block
 block discarded – undo
578 673
 	}
579 674
 	public function countAllMonths($stats_airline = '',$filter_name = '') {
580 675
 		global $globalStatsFilters;
581
-		if ($filter_name == '') $filter_name = $this->filter_name;
676
+		if ($filter_name == '') {
677
+			$filter_name = $this->filter_name;
678
+		}
582 679
 	    	$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
583 680
                  try {
584 681
                         $sth = $this->db->prepare($query);
@@ -599,7 +696,9 @@  discard block
 block discarded – undo
599 696
 	}
600 697
 	public function countAllMilitaryMonths($filter_name = '') {
601 698
 		global $globalStatsFilters;
602
-		if ($filter_name == '') $filter_name = $this->filter_name;
699
+		if ($filter_name == '') {
700
+			$filter_name = $this->filter_name;
701
+		}
603 702
 	    	$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'military_flights_bymonth' AND filter_name = :filter_name";
604 703
                  try {
605 704
                         $sth = $this->db->prepare($query);
@@ -620,9 +719,14 @@  discard block
 block discarded – undo
620 719
 	}
621 720
 	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
622 721
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
623
-		if ($filter_name == '') $filter_name = $this->filter_name;
624
-		if ($limit) $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name";
625
-		else $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name";
722
+		if ($filter_name == '') {
723
+			$filter_name = $this->filter_name;
724
+		}
725
+		if ($limit) {
726
+			$query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name";
727
+		} else {
728
+			$query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name";
729
+		}
626 730
 		if ($orderby == 'hour') {
627 731
 			/*
628 732
 			if ($globalDBdriver == 'mysql') {
@@ -631,7 +735,9 @@  discard block
 block discarded – undo
631 735
 			*/
632 736
 			$query .= " ORDER BY CAST(flight_date AS integer) ASC";
633 737
 		}
634
-		if ($orderby == 'count') $query .= " ORDER BY hour_count DESC";
738
+		if ($orderby == 'count') {
739
+			$query .= " ORDER BY hour_count DESC";
740
+		}
635 741
                  try {
636 742
                         $sth = $this->db->prepare($query);
637 743
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
@@ -652,7 +758,9 @@  discard block
 block discarded – undo
652 758
 	
653 759
 	public function countOverallFlights($stats_airline = '', $filter_name = '') {
654 760
 		global $globalStatsFilters;
655
-		if ($filter_name == '') $filter_name = $this->filter_name;
761
+		if ($filter_name == '') {
762
+			$filter_name = $this->filter_name;
763
+		}
656 764
 		$all = $this->getSumStats('flights_bymonth',date('Y'),$stats_airline,$filter_name);
657 765
 		if (empty($all)) {
658 766
 			$filters = array('airlines' => array($stats_airline));
@@ -666,7 +774,9 @@  discard block
 block discarded – undo
666 774
 	}
667 775
 	public function countOverallMilitaryFlights($filter_name = '') {
668 776
 		global $globalStatsFilters;
669
-		if ($filter_name == '') $filter_name = $this->filter_name;
777
+		if ($filter_name == '') {
778
+			$filter_name = $this->filter_name;
779
+		}
670 780
 		$all = $this->getSumStats('military_flights_bymonth',date('Y'),'',$filter_name);
671 781
 		if (empty($all)) {
672 782
 		        $filters = array();
@@ -680,7 +790,9 @@  discard block
 block discarded – undo
680 790
 	}
681 791
 	public function countOverallArrival($stats_airline = '',$filter_name = '') {
682 792
 		global $globalStatsFilters;
683
-		if ($filter_name == '') $filter_name = $this->filter_name;
793
+		if ($filter_name == '') {
794
+			$filter_name = $this->filter_name;
795
+		}
684 796
 		$all = $this->getSumStats('realarrivals_bymonth',date('Y'),$stats_airline,$filter_name);
685 797
 		if (empty($all)) {
686 798
 			$filters = array('airlines' => array($stats_airline));
@@ -694,7 +806,9 @@  discard block
 block discarded – undo
694 806
 	}
695 807
 	public function countOverallAircrafts($stats_airline = '',$filter_name = '') {
696 808
 		global $globalStatsFilters;
697
-		if ($filter_name == '') $filter_name = $this->filter_name;
809
+		if ($filter_name == '') {
810
+			$filter_name = $this->filter_name;
811
+		}
698 812
 		$all = $this->getSumStats('aircrafts_bymonth',date('Y'),$stats_airline,$filter_name);
699 813
 		if (empty($all)) {
700 814
 			$filters = array('airlines' => array($stats_airline));
@@ -708,7 +822,9 @@  discard block
 block discarded – undo
708 822
 	}
709 823
 	public function countOverallAirlines($filter_name = '') {
710 824
 		global $globalStatsFilters;
711
-		if ($filter_name == '') $filter_name = $this->filter_name;
825
+		if ($filter_name == '') {
826
+			$filter_name = $this->filter_name;
827
+		}
712 828
 		$query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name";
713 829
                  try {
714 830
                         $sth = $this->db->prepare($query);
@@ -731,7 +847,9 @@  discard block
 block discarded – undo
731 847
 	}
732 848
 	public function countOverallOwners($stats_airline = '',$filter_name = '') {
733 849
 		global $globalStatsFilters;
734
-		if ($filter_name == '') $filter_name = $this->filter_name;
850
+		if ($filter_name == '') {
851
+			$filter_name = $this->filter_name;
852
+		}
735 853
 		/*
736 854
 		$query = "SELECT COUNT(*) AS nb_owner FROM stats_owner";
737 855
                  try {
@@ -756,7 +874,9 @@  discard block
 block discarded – undo
756 874
 	}
757 875
 	public function countOverallPilots($stats_airline = '',$filter_name = '') {
758 876
 		global $globalStatsFilters;
759
-		if ($filter_name == '') $filter_name = $this->filter_name;
877
+		if ($filter_name == '') {
878
+			$filter_name = $this->filter_name;
879
+		}
760 880
 		$all = $this->getSumStats('pilots_bymonth',date('Y'),$stats_airline,$filter_name);
761 881
 		if (empty($all)) {
762 882
 			$filters = array('airlines' => array($stats_airline));
@@ -770,7 +890,9 @@  discard block
 block discarded – undo
770 890
 	}
771 891
 
772 892
 	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') {
773
-		if ($filter_name == '') $filter_name = $this->filter_name;
893
+		if ($filter_name == '') {
894
+			$filter_name = $this->filter_name;
895
+		}
774 896
 		$query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date";
775 897
 		$query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
776 898
                  try {
@@ -783,7 +905,9 @@  discard block
 block discarded – undo
783 905
                 return $all;
784 906
 	}
785 907
 	public function getStats($type,$stats_airline = '', $filter_name = '') {
786
-		if ($filter_name == '') $filter_name = $this->filter_name;
908
+		if ($filter_name == '') {
909
+			$filter_name = $this->filter_name;
910
+		}
787 911
                 $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
788 912
                 $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
789 913
                  try {
@@ -796,7 +920,9 @@  discard block
 block discarded – undo
796 920
                 return $all;
797 921
         }
798 922
 	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '') {
799
-		if ($filter_name == '') $filter_name = $this->filter_name;
923
+		if ($filter_name == '') {
924
+			$filter_name = $this->filter_name;
925
+		}
800 926
     		global $globalArchiveMonths, $globalDBdriver;
801 927
     		if ($globalDBdriver == 'mysql') {
802 928
 	                $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name";
@@ -815,7 +941,9 @@  discard block
 block discarded – undo
815 941
         }
816 942
 	public function getStatsTotal($type, $stats_airline = '', $filter_name = '') {
817 943
     		global $globalArchiveMonths, $globalDBdriver;
818
-		if ($filter_name == '') $filter_name = $this->filter_name;
944
+		if ($filter_name == '') {
945
+			$filter_name = $this->filter_name;
946
+		}
819 947
     		if ($globalDBdriver == 'mysql') {
820 948
 			$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL ".$globalArchiveMonths." MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name";
821 949
 		} else {
@@ -833,7 +961,9 @@  discard block
 block discarded – undo
833 961
         }
834 962
 	public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') {
835 963
     		global $globalArchiveMonths, $globalDBdriver;
836
-		if ($filter_name == '') $filter_name = $this->filter_name;
964
+		if ($filter_name == '') {
965
+			$filter_name = $this->filter_name;
966
+		}
837 967
     		if ($globalDBdriver == 'mysql') {
838 968
 			$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
839 969
                 } else {
@@ -850,7 +980,9 @@  discard block
 block discarded – undo
850 980
         }
851 981
 	public function getStatsAirlineTotal($filter_name = '') {
852 982
     		global $globalArchiveMonths, $globalDBdriver;
853
-		if ($filter_name == '') $filter_name = $this->filter_name;
983
+		if ($filter_name == '') {
984
+			$filter_name = $this->filter_name;
985
+		}
854 986
     		if ($globalDBdriver == 'mysql') {
855 987
 			$query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name";
856 988
                 } else {
@@ -867,7 +999,9 @@  discard block
 block discarded – undo
867 999
         }
868 1000
 	public function getStatsOwnerTotal($filter_name = '') {
869 1001
     		global $globalArchiveMonths, $globalDBdriver;
870
-		if ($filter_name == '') $filter_name = $this->filter_name;
1002
+		if ($filter_name == '') {
1003
+			$filter_name = $this->filter_name;
1004
+		}
871 1005
     		if ($globalDBdriver == 'mysql') {
872 1006
 			$query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name";
873 1007
 		} else {
@@ -884,7 +1018,9 @@  discard block
 block discarded – undo
884 1018
         }
885 1019
 	public function getStatsPilotTotal($filter_name = '') {
886 1020
     		global $globalArchiveMonths, $globalDBdriver;
887
-		if ($filter_name == '') $filter_name = $this->filter_name;
1021
+		if ($filter_name == '') {
1022
+			$filter_name = $this->filter_name;
1023
+		}
888 1024
     		if ($globalDBdriver == 'mysql') {
889 1025
             		$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
890 1026
             	} else {
@@ -902,7 +1038,9 @@  discard block
 block discarded – undo
902 1038
 
903 1039
 	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
904 1040
 		global $globalDBdriver;
905
-		if ($filter_name == '') $filter_name = $this->filter_name;
1041
+		if ($filter_name == '') {
1042
+			$filter_name = $this->filter_name;
1043
+		}
906 1044
 		if ($globalDBdriver == 'mysql') {
907 1045
 			$query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = :cnt";
908 1046
                 } else {
@@ -918,7 +1056,9 @@  discard block
 block discarded – undo
918 1056
         }
919 1057
 	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
920 1058
 		global $globalDBdriver;
921
-		if ($filter_name == '') $filter_name = $this->filter_name;
1059
+		if ($filter_name == '') {
1060
+			$filter_name = $this->filter_name;
1061
+		}
922 1062
 		if ($globalDBdriver == 'mysql') {
923 1063
 			$query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
924 1064
 		} else {
@@ -1401,47 +1541,69 @@  discard block
 block discarded – undo
1401 1541
 			$this->addLastStatsUpdate('last_update_stats',date('Y-m-d G:i:s'));
1402 1542
 		} else {
1403 1543
 		*/
1404
-			if ($globalDebug) echo 'Update stats !'."\n";
1405
-			if ($globalDebug) echo 'Count all aircraft types...'."\n";
1544
+			if ($globalDebug) {
1545
+				echo 'Update stats !'."\n";
1546
+			}
1547
+			if ($globalDebug) {
1548
+				echo 'Count all aircraft types...'."\n";
1549
+			}
1406 1550
 			if (isset($last_update[0]['value'])) {
1407 1551
 				$last_update_day = $last_update[0]['value'];
1408
-			} else $last_update_day = '2012-12-12 12:12:12';
1552
+			} else {
1553
+				$last_update_day = '2012-12-12 12:12:12';
1554
+			}
1409 1555
 			$Spotter = new Spotter($this->db);
1410 1556
 			$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);
1411 1557
 			foreach ($alldata as $number) {
1412 1558
 				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer']);
1413 1559
 			}
1414
-			if ($globalDebug) echo 'Count all airlines...'."\n";
1560
+			if ($globalDebug) {
1561
+				echo 'Count all airlines...'."\n";
1562
+			}
1415 1563
 			$alldata = $Spotter->countAllAirlines(false,0,$last_update_day);
1416 1564
 			foreach ($alldata as $number) {
1417 1565
 				$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name']);
1418 1566
 			}
1419
-			if ($globalDebug) echo 'Count all registrations...'."\n";
1567
+			if ($globalDebug) {
1568
+				echo 'Count all registrations...'."\n";
1569
+			}
1420 1570
 			$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day);
1421 1571
 			foreach ($alldata as $number) {
1422 1572
 				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao']);
1423 1573
 			}
1424
-			if ($globalDebug) echo 'Count all callsigns...'."\n";
1574
+			if ($globalDebug) {
1575
+				echo 'Count all callsigns...'."\n";
1576
+			}
1425 1577
 			$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day);
1426 1578
 			foreach ($alldata as $number) {
1427 1579
 				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao']);
1428 1580
 			}
1429
-			if ($globalDebug) echo 'Count all owners...'."\n";
1581
+			if ($globalDebug) {
1582
+				echo 'Count all owners...'."\n";
1583
+			}
1430 1584
 			$alldata = $Spotter->countAllOwners(false,0,$last_update_day);
1431 1585
 			foreach ($alldata as $number) {
1432 1586
 				$this->addStatOwner($number['owner_name'],$number['owner_count']);
1433 1587
 			}
1434
-			if ($globalDebug) echo 'Count all pilots...'."\n";
1588
+			if ($globalDebug) {
1589
+				echo 'Count all pilots...'."\n";
1590
+			}
1435 1591
 			$alldata = $Spotter->countAllPilots(false,0,$last_update_day);
1436 1592
 			foreach ($alldata as $number) {
1437 1593
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source']);
1438 1594
 			}
1439 1595
 			
1440
-			if ($globalDebug) echo 'Count all departure airports...'."\n";
1596
+			if ($globalDebug) {
1597
+				echo 'Count all departure airports...'."\n";
1598
+			}
1441 1599
 			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
1442
-			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
1600
+			if ($globalDebug) {
1601
+				echo 'Count all detected departure airports...'."\n";
1602
+			}
1443 1603
         		$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1444
-			if ($globalDebug) echo 'Order departure airports...'."\n";
1604
+			if ($globalDebug) {
1605
+				echo 'Order departure airports...'."\n";
1606
+			}
1445 1607
 	        	$alldata = array();
1446 1608
 	        	
1447 1609
     			foreach ($pall as $value) {
@@ -1452,7 +1614,9 @@  discard block
 block discarded – undo
1452 1614
     				$icao = $value['airport_departure_icao'];
1453 1615
         			if (isset($alldata[$icao])) {
1454 1616
     					$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1455
-        			} else $alldata[$icao] = $value;
1617
+        			} else {
1618
+        				$alldata[$icao] = $value;
1619
+        			}
1456 1620
 			}
1457 1621
     			$count = array();
1458 1622
     			foreach ($alldata as $key => $row) {
@@ -1462,11 +1626,17 @@  discard block
 block discarded – undo
1462 1626
 			foreach ($alldata as $number) {
1463 1627
 				echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count']);
1464 1628
 			}
1465
-			if ($globalDebug) echo 'Count all arrival airports...'."\n";
1629
+			if ($globalDebug) {
1630
+				echo 'Count all arrival airports...'."\n";
1631
+			}
1466 1632
 			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
1467
-			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
1633
+			if ($globalDebug) {
1634
+				echo 'Count all detected arrival airports...'."\n";
1635
+			}
1468 1636
         		$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1469
-			if ($globalDebug) echo 'Order arrival airports...'."\n";
1637
+			if ($globalDebug) {
1638
+				echo 'Order arrival airports...'."\n";
1639
+			}
1470 1640
 	        	$alldata = array();
1471 1641
     			foreach ($pall as $value) {
1472 1642
 	        		$icao = $value['airport_arrival_icao'];
@@ -1476,7 +1646,9 @@  discard block
 block discarded – undo
1476 1646
     				$icao = $value['airport_arrival_icao'];
1477 1647
         			if (isset($alldata[$icao])) {
1478 1648
         				$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1479
-	        		} else $alldata[$icao] = $value;
1649
+	        		} else {
1650
+	        			$alldata[$icao] = $value;
1651
+	        		}
1480 1652
     			}
1481 1653
         		$count = array();
1482 1654
         		foreach ($alldata as $key => $row) {
@@ -1487,7 +1659,9 @@  discard block
 block discarded – undo
1487 1659
 				echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count']);
1488 1660
 			}
1489 1661
 			if ($Connection->tableExists('countries')) {
1490
-				if ($globalDebug) echo 'Count all flights by countries...'."\n";
1662
+				if ($globalDebug) {
1663
+					echo 'Count all flights by countries...'."\n";
1664
+				}
1491 1665
 				$SpotterArchive = new SpotterArchive();
1492 1666
 				$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day);
1493 1667
 				foreach ($alldata as $number) {
@@ -1499,46 +1673,66 @@  discard block
 block discarded – undo
1499 1673
 			// Add by month using getstat if month finish...
1500 1674
 
1501 1675
 			//if (date('m',strtotime($last_update_day)) != date('m')) {
1502
-			if ($globalDebug) echo 'Count all flights by months...'."\n";
1676
+			if ($globalDebug) {
1677
+				echo 'Count all flights by months...'."\n";
1678
+			}
1503 1679
 			$Spotter = new Spotter($this->db);
1504 1680
 			$alldata = $Spotter->countAllMonths();
1505 1681
 			$lastyear = false;
1506 1682
 			foreach ($alldata as $number) {
1507
-				if ($number['year_name'] != date('Y')) $lastyear = true;
1683
+				if ($number['year_name'] != date('Y')) {
1684
+					$lastyear = true;
1685
+				}
1508 1686
 				$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'])));
1509 1687
 			}
1510
-			if ($globalDebug) echo 'Count all military flights by months...'."\n";
1688
+			if ($globalDebug) {
1689
+				echo 'Count all military flights by months...'."\n";
1690
+			}
1511 1691
 			$alldata = $Spotter->countAllMilitaryMonths();
1512 1692
 			foreach ($alldata as $number) {
1513 1693
 				$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'])));
1514 1694
 			}
1515
-			if ($globalDebug) echo 'Count all owners by months...'."\n";
1695
+			if ($globalDebug) {
1696
+				echo 'Count all owners by months...'."\n";
1697
+			}
1516 1698
 			$alldata = $Spotter->countAllMonthsOwners();
1517 1699
 			foreach ($alldata as $number) {
1518 1700
 				$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'])));
1519 1701
 			}
1520
-			if ($globalDebug) echo 'Count all pilots by months...'."\n";
1702
+			if ($globalDebug) {
1703
+				echo 'Count all pilots by months...'."\n";
1704
+			}
1521 1705
 			$alldata = $Spotter->countAllMonthsPilots();
1522 1706
 			foreach ($alldata as $number) {
1523 1707
 				$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'])));
1524 1708
 			}
1525
-			if ($globalDebug) echo 'Count all airlines by months...'."\n";
1709
+			if ($globalDebug) {
1710
+				echo 'Count all airlines by months...'."\n";
1711
+			}
1526 1712
 			$alldata = $Spotter->countAllMonthsAirlines();
1527 1713
 			foreach ($alldata as $number) {
1528 1714
 				$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'])));
1529 1715
 			}
1530
-			if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
1716
+			if ($globalDebug) {
1717
+				echo 'Count all aircrafts by months...'."\n";
1718
+			}
1531 1719
 			$alldata = $Spotter->countAllMonthsAircrafts();
1532 1720
 			foreach ($alldata as $number) {
1533 1721
 				$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'])));
1534 1722
 			}
1535
-			if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
1723
+			if ($globalDebug) {
1724
+				echo 'Count all real arrivals by months...'."\n";
1725
+			}
1536 1726
 			$alldata = $Spotter->countAllMonthsRealArrivals();
1537 1727
 			foreach ($alldata as $number) {
1538 1728
 				$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'])));
1539 1729
 			}
1540
-			if ($globalDebug) echo 'Airports data...'."\n";
1541
-			if ($globalDebug) echo '...Departure'."\n";
1730
+			if ($globalDebug) {
1731
+				echo 'Airports data...'."\n";
1732
+			}
1733
+			if ($globalDebug) {
1734
+				echo '...Departure'."\n";
1735
+			}
1542 1736
 			$this->deleteStatAirport('daily');
1543 1737
 //			$pall = $Spotter->getLast7DaysAirportsDeparture();
1544 1738
   //      		$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
@@ -1658,37 +1852,53 @@  discard block
 block discarded – undo
1658 1852
 
1659 1853
 			// Count by airlines
1660 1854
 			echo '--- Stats by airlines ---'."\n";
1661
-			if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n";
1855
+			if ($globalDebug) {
1856
+				echo 'Count all aircraft types by airlines...'."\n";
1857
+			}
1662 1858
 			$Spotter = new Spotter($this->db);
1663 1859
 			$alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day);
1664 1860
 			foreach ($alldata as $number) {
1665 1861
 				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao']);
1666 1862
 			}
1667
-			if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n";
1863
+			if ($globalDebug) {
1864
+				echo 'Count all aircraft registrations by airlines...'."\n";
1865
+			}
1668 1866
 			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day);
1669 1867
 			foreach ($alldata as $number) {
1670 1868
 				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao']);
1671 1869
 			}
1672
-			if ($globalDebug) echo 'Count all callsigns by airlines...'."\n";
1870
+			if ($globalDebug) {
1871
+				echo 'Count all callsigns by airlines...'."\n";
1872
+			}
1673 1873
 			$alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day);
1674 1874
 			foreach ($alldata as $number) {
1675 1875
 				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao']);
1676 1876
 			}
1677
-			if ($globalDebug) echo 'Count all owners by airlines...'."\n";
1877
+			if ($globalDebug) {
1878
+				echo 'Count all owners by airlines...'."\n";
1879
+			}
1678 1880
 			$alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day);
1679 1881
 			foreach ($alldata as $number) {
1680 1882
 				$this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao']);
1681 1883
 			}
1682
-			if ($globalDebug) echo 'Count all pilots by airlines...'."\n";
1884
+			if ($globalDebug) {
1885
+				echo 'Count all pilots by airlines...'."\n";
1886
+			}
1683 1887
 			$alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day);
1684 1888
 			foreach ($alldata as $number) {
1685 1889
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source']);
1686 1890
 			}
1687
-			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
1891
+			if ($globalDebug) {
1892
+				echo 'Count all departure airports by airlines...'."\n";
1893
+			}
1688 1894
 			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
1689
-			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
1895
+			if ($globalDebug) {
1896
+				echo 'Count all detected departure airports by airlines...'."\n";
1897
+			}
1690 1898
        			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
1691
-			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
1899
+			if ($globalDebug) {
1900
+				echo 'Order detected departure airports by airlines...'."\n";
1901
+			}
1692 1902
 	        	//$alldata = array();
1693 1903
     			foreach ($dall as $value) {
1694 1904
     				$icao = $value['airport_departure_icao'];
@@ -1709,11 +1919,17 @@  discard block
 block discarded – undo
1709 1919
 			foreach ($alldata as $number) {
1710 1920
 				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']);
1711 1921
 			}
1712
-			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
1922
+			if ($globalDebug) {
1923
+				echo 'Count all arrival airports by airlines...'."\n";
1924
+			}
1713 1925
 			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
1714
-			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
1926
+			if ($globalDebug) {
1927
+				echo 'Count all detected arrival airports by airlines...'."\n";
1928
+			}
1715 1929
         		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
1716
-			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
1930
+			if ($globalDebug) {
1931
+				echo 'Order arrival airports by airlines...'."\n";
1932
+			}
1717 1933
 	        	//$alldata = array();
1718 1934
     			foreach ($dall as $value) {
1719 1935
     				$icao = $value['airport_arrival_icao'];
@@ -1732,37 +1948,53 @@  discard block
 block discarded – undo
1732 1948
     			}
1733 1949
     			$alldata = $pall;
1734 1950
                         foreach ($alldata as $number) {
1735
-				if ($number['airline_icao'] != '') echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao']);
1951
+				if ($number['airline_icao'] != '') {
1952
+					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']);
1953
+				}
1954
+			}
1955
+			if ($globalDebug) {
1956
+				echo 'Count all flights by months by airlines...'."\n";
1736 1957
 			}
1737
-			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
1738 1958
 			$Spotter = new Spotter($this->db);
1739 1959
 			$alldata = $Spotter->countAllMonthsByAirlines();
1740 1960
 			$lastyear = false;
1741 1961
 			foreach ($alldata as $number) {
1742
-				if ($number['year_name'] != date('Y')) $lastyear = true;
1962
+				if ($number['year_name'] != date('Y')) {
1963
+					$lastyear = true;
1964
+				}
1743 1965
 				$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']);
1744 1966
 			}
1745
-			if ($globalDebug) echo 'Count all owners by months by airlines...'."\n";
1967
+			if ($globalDebug) {
1968
+				echo 'Count all owners by months by airlines...'."\n";
1969
+			}
1746 1970
 			$alldata = $Spotter->countAllMonthsOwnersByAirlines();
1747 1971
 			foreach ($alldata as $number) {
1748 1972
 				$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']);
1749 1973
 			}
1750
-			if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n";
1974
+			if ($globalDebug) {
1975
+				echo 'Count all pilots by months by airlines...'."\n";
1976
+			}
1751 1977
 			$alldata = $Spotter->countAllMonthsPilotsByAirlines();
1752 1978
 			foreach ($alldata as $number) {
1753 1979
 				$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']);
1754 1980
 			}
1755
-			if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n";
1981
+			if ($globalDebug) {
1982
+				echo 'Count all aircrafts by months by airlines...'."\n";
1983
+			}
1756 1984
 			$alldata = $Spotter->countAllMonthsAircraftsByAirlines();
1757 1985
 			foreach ($alldata as $number) {
1758 1986
 				$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']);
1759 1987
 			}
1760
-			if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n";
1988
+			if ($globalDebug) {
1989
+				echo 'Count all real arrivals by months by airlines...'."\n";
1990
+			}
1761 1991
 			$alldata = $Spotter->countAllMonthsRealArrivalsByAirlines();
1762 1992
 			foreach ($alldata as $number) {
1763 1993
 				$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']);
1764 1994
 			}
1765
-			if ($globalDebug) echo '...Departure'."\n";
1995
+			if ($globalDebug) {
1996
+				echo '...Departure'."\n";
1997
+			}
1766 1998
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
1767 1999
         		$dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines();
1768 2000
     			foreach ($dall as $value) {
@@ -1785,7 +2017,9 @@  discard block
 block discarded – undo
1785 2017
 			foreach ($alldata as $number) {
1786 2018
 				$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']);
1787 2019
 			}
1788
-			if ($globalDebug) echo '...Arrival'."\n";
2020
+			if ($globalDebug) {
2021
+				echo '...Arrival'."\n";
2022
+			}
1789 2023
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
1790 2024
         		$dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines();
1791 2025
     			foreach ($dall as $value) {
@@ -1809,13 +2043,19 @@  discard block
 block discarded – undo
1809 2043
 				$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']);
1810 2044
 			}
1811 2045
 
1812
-			if ($globalDebug) echo 'Flights data...'."\n";
1813
-			if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n";
2046
+			if ($globalDebug) {
2047
+				echo 'Flights data...'."\n";
2048
+			}
2049
+			if ($globalDebug) {
2050
+				echo '-> countAllDatesLastMonth...'."\n";
2051
+			}
1814 2052
 			$alldata = $Spotter->countAllDatesLastMonthByAirlines();
1815 2053
 			foreach ($alldata as $number) {
1816 2054
 				$this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']);
1817 2055
 			}
1818
-			if ($globalDebug) echo '-> countAllDates...'."\n";
2056
+			if ($globalDebug) {
2057
+				echo '-> countAllDates...'."\n";
2058
+			}
1819 2059
 			//$previousdata = $this->countAllDatesByAirlines();
1820 2060
 			$alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines());
1821 2061
 			$values = array();
@@ -1828,14 +2068,18 @@  discard block
 block discarded – undo
1828 2068
 				$this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']);
1829 2069
 			}
1830 2070
 			
1831
-			if ($globalDebug) echo '-> countAllHours...'."\n";
2071
+			if ($globalDebug) {
2072
+				echo '-> countAllHours...'."\n";
2073
+			}
1832 2074
 			$alldata = $Spotter->countAllHoursByAirlines('hour');
1833 2075
 			foreach ($alldata as $number) {
1834 2076
 				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']);
1835 2077
 			}
1836 2078
 			
1837 2079
 
1838
-			if (!isset($globalStatsFilters) || $globalStatsFilters == '') $globalStatsFilters = array();
2080
+			if (!isset($globalStatsFilters) || $globalStatsFilters == '') {
2081
+				$globalStatsFilters = array();
2082
+			}
1839 2083
 			foreach ($globalStatsFilters as $name => $filter) {
1840 2084
 				//$filter_name = $filter['name'];
1841 2085
 				$filter_name = $name;
@@ -1843,10 +2087,14 @@  discard block
 block discarded – undo
1843 2087
 				$last_update = $this->getLastStatsUpdate('last_update_stats_'.$filter_name);
1844 2088
 				if (isset($last_update[0]['value'])) {
1845 2089
 					$last_update_day = $last_update[0]['value'];
1846
-				} else $last_update_day = '2012-12-12 12:12:12';
2090
+				} else {
2091
+					$last_update_day = '2012-12-12 12:12:12';
2092
+				}
1847 2093
 
1848 2094
 				// Count by filter
1849
-				if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n";
2095
+				if ($globalDebug) {
2096
+					echo '--- Stats for filter '.$filter_name.' ---'."\n";
2097
+				}
1850 2098
 				$Spotter = new Spotter($this->db);
1851 2099
 				$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter);
1852 2100
 				foreach ($alldata as $number) {
@@ -1883,7 +2131,9 @@  discard block
 block discarded – undo
1883 2131
 	    				$icao = $value['airport_departure_icao'];
1884 2132
         				if (isset($alldata[$icao])) {
1885 2133
     						$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1886
-        				} else $alldata[$icao] = $value;
2134
+        				} else {
2135
+        					$alldata[$icao] = $value;
2136
+        				}
1887 2137
 				}
1888 2138
 	    			$count = array();
1889 2139
     				foreach ($alldata as $key => $row) {
@@ -1904,7 +2154,9 @@  discard block
 block discarded – undo
1904 2154
 	    				$icao = $value['airport_arrival_icao'];
1905 2155
         				if (isset($alldata[$icao])) {
1906 2156
         					$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1907
-		        		} else $alldata[$icao] = $value;
2157
+		        		} else {
2158
+		        			$alldata[$icao] = $value;
2159
+		        		}
1908 2160
 	    			}
1909 2161
         			$count = array();
1910 2162
         			foreach ($alldata as $key => $row) {
@@ -1918,7 +2170,9 @@  discard block
 block discarded – undo
1918 2170
 				$alldata = $Spotter->countAllMonths($filter);
1919 2171
 				$lastyear = false;
1920 2172
 				foreach ($alldata as $number) {
1921
-					if ($number['year_name'] != date('Y')) $lastyear = true;
2173
+					if ($number['year_name'] != date('Y')) {
2174
+						$lastyear = true;
2175
+					}
1922 2176
 					$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);
1923 2177
 				}
1924 2178
 				$alldata = $Spotter->countAllMonthsOwners($filter);
Please login to merge, or discard this patch.