Completed
Push — master ( 36f624...bc4f96 )
by Yannick
11:00 queued 04:11
created
aircraft-data.php 1 patch
Braces   +34 added lines, -12 removed lines patch added patch discarded remove patch
@@ -55,7 +55,9 @@  discard block
 block discarded – undo
55 55
 {
56 56
 	if ($spotter_item['image_source'] == 'flickr' || $spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart') {
57 57
 		$image = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
58
-	} else $image = $spotter_item['image_thumbnail'];
58
+	} else {
59
+		$image = $spotter_item['image_thumbnail'];
60
+	}
59 61
 
60 62
 }
61 63
 /* else {
@@ -67,7 +69,9 @@  discard block
 block discarded – undo
67 69
 	print '<div class="left"><img src="'.$image.'" alt="'.$spotter_item['registration'].' '.$spotter_item['aircraft_name'].'" title="'.$spotter_item['registration'].' '.$spotter_item['aircraft_name'].' Image &copy; '.$spotter_item['image_copyright'].'"/><br />Image &copy; '.$spotter_item['image_copyright'].'</div>';
68 70
 }
69 71
 print '<div class="right"><div class="callsign-details"><div class="callsign"><a href="'.$globalURL.'/redirect/'.$spotter_item['flightaware_id'].'" target="_blank">'.$spotter_item['ident'].'</a></div>';
70
-if (isset($spotter_item['airline_name'])) print '<div class="airline">'.$spotter_item['airline_name'].'</div>';
72
+if (isset($spotter_item['airline_name'])) {
73
+	print '<div class="airline">'.$spotter_item['airline_name'].'</div>';
74
+}
71 75
 print '</div>';
72 76
 print '<div class="nomobile airports"><div class="airport"><span class="code"><a href="'.$globalURL.'/airport/'.$spotter_item['departure_airport'].'" target="_blank">'.$spotter_item['departure_airport'].'</a></span>'.$spotter_item['departure_airport_city'].' '.$spotter_item['departure_airport_country'];
73 77
 if (isset($spotter_item['departure_airport_time'])) {
@@ -95,9 +99,14 @@  discard block
 block discarded – undo
95 99
 print '<span class="code"><a href="'.$globalURL.'/airport/'.$spotter_item['arrival_airport'].'" target="_blank">'.$spotter_item['arrival_airport'].'</a></span>'.$spotter_item['arrival_airport_city'].' '.$spotter_item['arrival_airport_country'];
96 100
 print '</div></div><div>';
97 101
 print '<span>'._("Aircraft").'</span>';
98
-if (isset($spotter_item['aircraft_wiki'])) print '<a href="'.$spotter_item['aircraft_wiki'].'">'.$spotter_item['aircraft_name'].'</a>';
99
-if (isset($spotter_item['aircraft_type'])) print '<a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')</a>';
100
-else print $spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'];
102
+if (isset($spotter_item['aircraft_wiki'])) {
103
+	print '<a href="'.$spotter_item['aircraft_wiki'].'">'.$spotter_item['aircraft_name'].'</a>';
104
+}
105
+if (isset($spotter_item['aircraft_type'])) {
106
+	print '<a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')</a>';
107
+} else {
108
+	print $spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'];
109
+}
101 110
 print '</div>';
102 111
 print '<div><span>'._("Altitude").'</span>';
103 112
 if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) {
@@ -106,7 +115,9 @@  discard block
 block discarded – undo
106 115
 	print round($spotter_item['altitude']*30.48).' m (FL'.$spotter_item['altitude'].')';
107 116
 }
108 117
 print '</div>';
109
-if (isset($spotter_item['registration']) && $spotter_item['registration'] != '') print '<div><span>'._("Registration").'</span><a href="'.$globalURL.'/registration/'.$spotter_item['registration'].'" target="_blank">'.$spotter_item['registration'].'</a></div>';
118
+if (isset($spotter_item['registration']) && $spotter_item['registration'] != '') {
119
+	print '<div><span>'._("Registration").'</span><a href="'.$globalURL.'/registration/'.$spotter_item['registration'].'" target="_blank">'.$spotter_item['registration'].'</a></div>';
120
+}
110 121
 print '<div><span>'._("Speed").'</span>';
111 122
 if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'mph') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'mph')) {
112 123
 	print round($spotter_item['ground_speed']*1.15078).' mph';
@@ -120,8 +131,11 @@  discard block
 block discarded – undo
120 131
 print '<div><span>'._("Heading").'</span>'.$spotter_item['heading'].'°</div>';
121 132
 if (isset($spotter_item['pilot_name']) && $spotter_item['pilot_name'] != '') {
122 133
 	print '<div><span>'._("Pilot").'</span>';
123
-	if (isset($spotter_item['pilot_id'])) print $spotter_item['pilot_name'].' ('.$spotter_item['pilot_id'].')';
124
-	else print $spotter_item['pilot_name'];
134
+	if (isset($spotter_item['pilot_id'])) {
135
+		print $spotter_item['pilot_name'].' ('.$spotter_item['pilot_id'].')';
136
+	} else {
137
+		print $spotter_item['pilot_name'];
138
+	}
125 139
 	print '</div>';
126 140
 }
127 141
 
@@ -147,10 +161,18 @@  discard block
 block discarded – undo
147 161
 }
148 162
 print '</div>';
149 163
 
150
-if (isset($globalphpVMS) && $globalphpVMS && isset($globalVATSIM) && $globalVATSIM && isset($globalIVAO) && $globalIVAO && isset($spotter_item['format_source']) && $spotter_item['format_source'] != '' && $spotter_item['format_source'] != 'pireps') print '<div class="waypoints"><span>'._("Source").'</span>'.$spotter_item['format_source'].'</div>';
151
-if (isset($spotter_item['waypoints']) && $spotter_item['waypoints'] != '') print '<div class="waypoints"><span>'._("Route").'</span>'.$spotter_item['waypoints'].'</div>';
152
-if (isset($spotter_item['acars']['message'])) print '<div class="acars"><span>'._("Latest ACARS message").'</span>'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'<br/>',$spotter_item['acars']['message'])).'</div>';
153
-if (isset($spotter_item['squawk']) && $spotter_item['squawk'] != '' && $spotter_item['squawk'] != 0) print '<div class="bottom">'._("Squawk:").' '.$spotter_item['squawk'].' - '.$spotter_item['squawk_usage'].'</div>';
164
+if (isset($globalphpVMS) && $globalphpVMS && isset($globalVATSIM) && $globalVATSIM && isset($globalIVAO) && $globalIVAO && isset($spotter_item['format_source']) && $spotter_item['format_source'] != '' && $spotter_item['format_source'] != 'pireps') {
165
+	print '<div class="waypoints"><span>'._("Source").'</span>'.$spotter_item['format_source'].'</div>';
166
+}
167
+if (isset($spotter_item['waypoints']) && $spotter_item['waypoints'] != '') {
168
+	print '<div class="waypoints"><span>'._("Route").'</span>'.$spotter_item['waypoints'].'</div>';
169
+}
170
+if (isset($spotter_item['acars']['message'])) {
171
+	print '<div class="acars"><span>'._("Latest ACARS message").'</span>'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'<br/>',$spotter_item['acars']['message'])).'</div>';
172
+}
173
+if (isset($spotter_item['squawk']) && $spotter_item['squawk'] != '' && $spotter_item['squawk'] != 0) {
174
+	print '<div class="bottom">'._("Squawk:").' '.$spotter_item['squawk'].' - '.$spotter_item['squawk_usage'].'</div>';
175
+}
154 176
 print '</div>';
155 177
 ?>
156 178
 </div>
157 179
\ No newline at end of file
Please login to merge, or discard this patch.
marine-data.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -63,7 +63,9 @@
 block discarded – undo
63 63
 {
64 64
 	if ($spotter_item['image_source'] == 'flickr' || $spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart') {
65 65
 		$image = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
66
-	} else $image = $spotter_item['image_thumbnail'];
66
+	} else {
67
+		$image = $spotter_item['image_thumbnail'];
68
+	}
67 69
 
68 70
 }
69 71
 /* else {
Please login to merge, or discard this patch.
require/class.Spotter.php 1 patch
Braces   +735 added lines, -257 removed lines patch added patch discarded remove patch
@@ -72,7 +72,9 @@  discard block
 block discarded – undo
72 72
 		if (isset($filter[0]['source'])) {
73 73
 			$filters = array_merge($filters,$filter);
74 74
 		}
75
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
75
+		if (is_array($globalFilter)) {
76
+			$filter = array_merge($filter,$globalFilter);
77
+		}
76 78
 		$filter_query_join = '';
77 79
 		$filter_query_where = '';
78 80
 		foreach($filters as $flt) {
@@ -156,8 +158,11 @@  discard block
 block discarded – undo
156 158
 				$filter_query_where .= " AND EXTRACT(DAY FROM spotter_output.date) = '".$filter['day']."'";
157 159
 			}
158 160
 		}
159
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
160
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
161
+		if ($filter_query_where == '' && $where) {
162
+			$filter_query_where = ' WHERE';
163
+		} elseif ($filter_query_where != '' && $and) {
164
+			$filter_query_where .= ' AND';
165
+		}
161 166
 		if ($filter_query_where != '') {
162 167
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
163 168
 		}
@@ -180,10 +185,18 @@  discard block
 block discarded – undo
180 185
 		$Image = new Image($this->db);
181 186
 		$Schedule = new Schedule($this->db);
182 187
 		$ACARS = new ACARS($this->db);
183
-		if (!isset($globalIVAO)) $globalIVAO = FALSE;
184
-		if (!isset($globalVATSIM)) $globalVATSIM = FALSE;
185
-		if (!isset($globalphpVMS)) $globalphpVMS = FALSE;
186
-		if (!isset($globalVAM)) $globalVAM = FALSE;
188
+		if (!isset($globalIVAO)) {
189
+			$globalIVAO = FALSE;
190
+		}
191
+		if (!isset($globalVATSIM)) {
192
+			$globalVATSIM = FALSE;
193
+		}
194
+		if (!isset($globalphpVMS)) {
195
+			$globalphpVMS = FALSE;
196
+		}
197
+		if (!isset($globalVAM)) {
198
+			$globalVAM = FALSE;
199
+		}
187 200
 		date_default_timezone_set('UTC');
188 201
 		
189 202
 		if (!is_string($query))
@@ -230,21 +243,35 @@  discard block
 block discarded – undo
230 243
 			} else {
231 244
 				$temp_array['spotter_id'] = '';
232 245
 			}
233
-			if (isset($row['flightaware_id'])) $temp_array['flightaware_id'] = $row['flightaware_id'];
234
-			if (isset($row['modes'])) $temp_array['modes'] = $row['modes'];
246
+			if (isset($row['flightaware_id'])) {
247
+				$temp_array['flightaware_id'] = $row['flightaware_id'];
248
+			}
249
+			if (isset($row['modes'])) {
250
+				$temp_array['modes'] = $row['modes'];
251
+			}
235 252
 			$temp_array['ident'] = $row['ident'];
236 253
 			if (isset($row['registration']) && $row['registration'] != '') {
237 254
 				$temp_array['registration'] = $row['registration'];
238 255
 			} elseif (isset($temp_array['modes'])) {
239 256
 				$temp_array['registration'] = $this->getAircraftRegistrationBymodeS($temp_array['modes']);
240
-			} else $temp_array['registration'] = '';
241
-			if (isset($row['aircraft_icao'])) $temp_array['aircraft_type'] = $row['aircraft_icao'];
257
+			} else {
258
+				$temp_array['registration'] = '';
259
+			}
260
+			if (isset($row['aircraft_icao'])) {
261
+				$temp_array['aircraft_type'] = $row['aircraft_icao'];
262
+			}
242 263
 			
243 264
 			$temp_array['departure_airport'] = $row['departure_airport_icao'];
244 265
 			$temp_array['arrival_airport'] = $row['arrival_airport_icao'];
245
-			if (isset($row['real_arrival_airport_icao']) && $row['real_arrival_airport_icao'] != NULL) $temp_array['real_arrival_airport'] = $row['real_arrival_airport_icao'];
246
-			if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude'];
247
-			if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude'];
266
+			if (isset($row['real_arrival_airport_icao']) && $row['real_arrival_airport_icao'] != NULL) {
267
+				$temp_array['real_arrival_airport'] = $row['real_arrival_airport_icao'];
268
+			}
269
+			if (isset($row['latitude'])) {
270
+				$temp_array['latitude'] = $row['latitude'];
271
+			}
272
+			if (isset($row['longitude'])) {
273
+				$temp_array['longitude'] = $row['longitude'];
274
+			}
248 275
 			/*
249 276
 			if (Connection->tableExists('countries')) {
250 277
 				$country_info = $this->getCountryFromLatitudeLongitude($temp_array['latitude'],$temp_array['longitude']);
@@ -254,8 +281,12 @@  discard block
 block discarded – undo
254 281
 				}
255 282
 			}
256 283
 			*/
257
-			if (isset($row['waypoints'])) $temp_array['waypoints'] = $row['waypoints'];
258
-			if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source'];
284
+			if (isset($row['waypoints'])) {
285
+				$temp_array['waypoints'] = $row['waypoints'];
286
+			}
287
+			if (isset($row['format_source'])) {
288
+				$temp_array['format_source'] = $row['format_source'];
289
+			}
259 290
 			if (isset($row['route_stop']) && $row['route_stop'] != '') {
260 291
 				$temp_array['route_stop'] = $row['route_stop'];
261 292
 				$allroute = explode(' ',$row['route_stop']);
@@ -271,13 +302,19 @@  discard block
 block discarded – undo
271 302
 					}
272 303
 				}
273 304
 			}
274
-			if (isset($row['altitude'])) $temp_array['altitude'] = $row['altitude'];
305
+			if (isset($row['altitude'])) {
306
+				$temp_array['altitude'] = $row['altitude'];
307
+			}
275 308
 			if (isset($row['heading'])) {
276 309
 				$temp_array['heading'] = $row['heading'];
277 310
 				$heading_direction = $this->parseDirection($row['heading']);
278
-				if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
311
+				if (isset($heading_direction[0]['direction_fullname'])) {
312
+					$temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
313
+				}
314
+			}
315
+			if (isset($row['ground_speed'])) {
316
+				$temp_array['ground_speed'] = $row['ground_speed'];
279 317
 			}
280
-			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];
281 318
 			$temp_array['image'] = "";
282 319
 			$temp_array['image_thumbnail'] = "";
283 320
 			$temp_array['image_source'] = "";
@@ -285,7 +322,9 @@  discard block
 block discarded – undo
285 322
  
286 323
 			if (isset($row['highlight'])) {
287 324
 				$temp_array['highlight'] = $row['highlight'];
288
-			} else $temp_array['highlight'] = '';
325
+			} else {
326
+				$temp_array['highlight'] = '';
327
+			}
289 328
 			
290 329
 			if (isset($row['date'])) {
291 330
 				$dateArray = $this->parseDateString($row['date']);
@@ -341,7 +380,9 @@  discard block
 block discarded – undo
341 380
 				
342 381
 					if ($aircraft_array[0]['aircraft_shadow'] != NULL) {
343 382
 						$temp_array['aircraft_shadow'] = $aircraft_array[0]['aircraft_shadow'];
344
-					} else $temp_array['aircraft_shadow'] = 'default.png';
383
+					} else {
384
+						$temp_array['aircraft_shadow'] = 'default.png';
385
+					}
345 386
                                 } else {
346 387
                             		$temp_array['aircraft_shadow'] = 'default.png';
347 388
 					$temp_array['aircraft_name'] = 'N/A';
@@ -349,11 +390,17 @@  discard block
 block discarded – undo
349 390
                             	}
350 391
 			}
351 392
 			$fromsource = NULL;
352
-			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
353
-			elseif (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
354
-			elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') $fromsource = 'ivao';
355
-			elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
356
-			elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
393
+			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
394
+				$fromsource = $globalAirlinesSource;
395
+			} elseif (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') {
396
+				$fromsource = 'vatsim';
397
+			} elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') {
398
+				$fromsource = 'ivao';
399
+			} elseif (isset($globalVATSIM) && $globalVATSIM) {
400
+				$fromsource = 'vatsim';
401
+			} elseif (isset($globalIVAO) && $globalIVAO) {
402
+				$fromsource = 'ivao';
403
+			}
357 404
 			if (!isset($row['airline_name']) || $row['airline_name'] == '') {
358 405
 				if (!is_numeric(substr($row['ident'], 0, 3))) {
359 406
 					if (is_numeric(substr($row['ident'], 2, 1))) {
@@ -376,12 +423,18 @@  discard block
 block discarded – undo
376 423
 				}
377 424
 			} else {
378 425
 				$temp_array['airline_icao'] = $row['airline_icao'];
379
-				if (isset($row['airline_iata'])) $temp_array['airline_iata'] = $row['airline_iata'];
380
-				else $temp_array['airline_iata'] = 'N/A';
426
+				if (isset($row['airline_iata'])) {
427
+					$temp_array['airline_iata'] = $row['airline_iata'];
428
+				} else {
429
+					$temp_array['airline_iata'] = 'N/A';
430
+				}
381 431
 				$temp_array['airline_name'] = $row['airline_name'];
382 432
 				$temp_array['airline_country'] = $row['airline_country'];
383
-				if (isset($row['airline_callsign'])) $temp_array['airline_callsign'] = $row['airline_callsign'];
384
-				else $temp_array['airline_callsign'] = 'N/A';
433
+				if (isset($row['airline_callsign'])) {
434
+					$temp_array['airline_callsign'] = $row['airline_callsign'];
435
+				} else {
436
+					$temp_array['airline_callsign'] = 'N/A';
437
+				}
385 438
 				$temp_array['airline_type'] = $row['airline_type'];
386 439
 				if ($temp_array['airline_icao'] != '' && $temp_array['airline_iata'] == 'N/A') {
387 440
 					$airline_array = $this->getAllAirlineInfo($temp_array['airline_icao']);
@@ -408,7 +461,9 @@  discard block
 block discarded – undo
408 461
 			}
409 462
 			if ($temp_array['registration'] != "" && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && !isset($temp_array['aircraft_owner'])) {
410 463
 				$owner_info = $this->getAircraftOwnerByRegistration($temp_array['registration']);
411
-				if ($owner_info['owner'] != '') $temp_array['aircraft_owner'] = ucwords(strtolower($owner_info['owner']));
464
+				if ($owner_info['owner'] != '') {
465
+					$temp_array['aircraft_owner'] = ucwords(strtolower($owner_info['owner']));
466
+				}
412 467
 				$temp_array['aircraft_base'] = $owner_info['base'];
413 468
 				$temp_array['aircraft_date_first_reg'] = $owner_info['date_first_reg'];
414 469
 			}
@@ -416,9 +471,14 @@  discard block
 block discarded – undo
416 471
 			if($temp_array['registration'] != "" || ($globalIVAO && isset($temp_array['aircraft_type']) && $temp_array['aircraft_type'] != ''))
417 472
 			{
418 473
 				if ($globalIVAO) {
419
-					if (isset($temp_array['airline_icao']))	$image_array = $Image->getSpotterImage('',$temp_array['aircraft_type'],$temp_array['airline_icao']);
420
-					else $image_array = $Image->getSpotterImage('',$temp_array['aircraft_type']);
421
-				} else $image_array = $Image->getSpotterImage($temp_array['registration']);
474
+					if (isset($temp_array['airline_icao'])) {
475
+						$image_array = $Image->getSpotterImage('',$temp_array['aircraft_type'],$temp_array['airline_icao']);
476
+					} else {
477
+						$image_array = $Image->getSpotterImage('',$temp_array['aircraft_type']);
478
+					}
479
+				} else {
480
+					$image_array = $Image->getSpotterImage($temp_array['registration']);
481
+				}
422 482
 				if (count($image_array) > 0) {
423 483
 					$temp_array['image'] = $image_array[0]['image'];
424 484
 					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -470,7 +530,9 @@  discard block
 block discarded – undo
470 530
 			//if ($row['departure_airport_icao'] != '' && $row['departure_airport_name'] == '') {
471 531
 			if ($row['departure_airport_icao'] != '') {
472 532
 				$departure_airport_array = $this->getAllAirportInfo($row['departure_airport_icao']);
473
-				if (!isset($departure_airport_array[0]['name'])) $departure_airport_array = $this->getAllAirportInfo('NA');
533
+				if (!isset($departure_airport_array[0]['name'])) {
534
+					$departure_airport_array = $this->getAllAirportInfo('NA');
535
+				}
474 536
 			/*
475 537
 			} elseif ($row['departure_airport_name'] != '') {
476 538
 				$temp_array['departure_airport_name'] = $row['departure_airport_name'];
@@ -478,7 +540,9 @@  discard block
 block discarded – undo
478 540
 				$temp_array['departure_airport_country'] = $row['departure_airport_country'];
479 541
 				$temp_array['departure_airport_icao'] = $row['departure_airport_icao'];
480 542
 			*/
481
-			} else $departure_airport_array = $this->getAllAirportInfo('NA');
543
+			} else {
544
+				$departure_airport_array = $this->getAllAirportInfo('NA');
545
+			}
482 546
 			if (isset($departure_airport_array[0]['name'])) {
483 547
 				$temp_array['departure_airport_name'] = $departure_airport_array[0]['name'];
484 548
 				$temp_array['departure_airport_city'] = $departure_airport_array[0]['city'];
@@ -498,8 +562,12 @@  discard block
 block discarded – undo
498 562
 			
499 563
 			if ($row['arrival_airport_icao'] != '') {
500 564
 				$arrival_airport_array = $this->getAllAirportInfo($row['arrival_airport_icao']);
501
-				if (count($arrival_airport_array) == 0) $arrival_airport_array = $this->getAllAirportInfo('NA');
502
-			} else $arrival_airport_array = $this->getAllAirportInfo('NA');
565
+				if (count($arrival_airport_array) == 0) {
566
+					$arrival_airport_array = $this->getAllAirportInfo('NA');
567
+				}
568
+			} else {
569
+				$arrival_airport_array = $this->getAllAirportInfo('NA');
570
+			}
503 571
 			if (isset($arrival_airport_array[0]['name'])) {
504 572
 				$temp_array['arrival_airport_name'] = $arrival_airport_array[0]['name'];
505 573
 				$temp_array['arrival_airport_city'] = $arrival_airport_array[0]['city'];
@@ -515,27 +583,45 @@  discard block
 block discarded – undo
515 583
 				$temp_array['arrival_airport_time'] = $row['arrival_airport_time'];
516 584
 			}
517 585
 			*/
518
-			if (isset($row['pilot_id']) && $row['pilot_id'] != '') $temp_array['pilot_id'] = $row['pilot_id'];
519
-			if (isset($row['pilot_name']) && $row['pilot_name'] != '') $temp_array['pilot_name'] = $row['pilot_name'];
520
-			if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name'];
521
-			if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country'];
522
-			if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance'];
586
+			if (isset($row['pilot_id']) && $row['pilot_id'] != '') {
587
+				$temp_array['pilot_id'] = $row['pilot_id'];
588
+			}
589
+			if (isset($row['pilot_name']) && $row['pilot_name'] != '') {
590
+				$temp_array['pilot_name'] = $row['pilot_name'];
591
+			}
592
+			if (isset($row['source_name']) && $row['source_name'] != '') {
593
+				$temp_array['source_name'] = $row['source_name'];
594
+			}
595
+			if (isset($row['over_country']) && $row['over_country'] != '') {
596
+				$temp_array['over_country'] = $row['over_country'];
597
+			}
598
+			if (isset($row['distance']) && $row['distance'] != '') {
599
+				$temp_array['distance'] = $row['distance'];
600
+			}
523 601
 			if (isset($row['squawk'])) {
524 602
 				$temp_array['squawk'] = $row['squawk'];
525 603
 				if ($row['squawk'] != '' && isset($temp_array['country_iso2'])) {
526 604
 					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$temp_array['country_iso2']);
527
-					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
605
+					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) {
606
+						$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
607
+					}
528 608
 				} elseif ($row['squawk'] != '' && isset($temp_array['over_country'])) {
529 609
 					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$temp_array['over_country']);
530
-					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
531
-				} elseif ($row['squawk'] != '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
610
+					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) {
611
+						$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
612
+					}
613
+				} elseif ($row['squawk'] != '' && isset($globalSquawkCountry)) {
614
+					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
615
+				}
532 616
 			}
533 617
     			
534 618
 			$temp_array['query_number_rows'] = $num_rows;
535 619
 			
536 620
 			$spotter_array[] = $temp_array;
537 621
 		}
538
-		if ($num_rows == 0) return array();
622
+		if ($num_rows == 0) {
623
+			return array();
624
+		}
539 625
 		$spotter_array[0]['query_number_rows'] = $num_rows;
540 626
 		return $spotter_array;
541 627
 	}	
@@ -568,7 +654,9 @@  discard block
 block discarded – undo
568 654
 				foreach ($q_array as $q_item){
569 655
 					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
570 656
 					$additional_query .= " AND (";
571
-					if (is_int($q_item)) $additional_query .= "(spotter_output.spotter_id like '%".$q_item."%') OR ";
657
+					if (is_int($q_item)) {
658
+						$additional_query .= "(spotter_output.spotter_id like '%".$q_item."%') OR ";
659
+					}
572 660
 					$additional_query .= "(spotter_output.aircraft_icao like '%".$q_item."%') OR ";
573 661
 					$additional_query .= "(spotter_output.aircraft_name like '%".$q_item."%') OR ";
574 662
 					$additional_query .= "(spotter_output.aircraft_manufacturer like '%".$q_item."%') OR ";
@@ -589,7 +677,9 @@  discard block
 block discarded – undo
589 677
 					$additional_query .= "(spotter_output.pilot_name like '%".$q_item."%') OR ";
590 678
 					$additional_query .= "(spotter_output.ident like '%".$q_item."%') OR ";
591 679
 					$translate = $Translation->ident2icao($q_item);
592
-					if ($translate != $q_item) $additional_query .= "(spotter_output.ident like '%".$translate."%') OR ";
680
+					if ($translate != $q_item) {
681
+						$additional_query .= "(spotter_output.ident like '%".$translate."%') OR ";
682
+					}
593 683
 					$additional_query .= "(spotter_output.highlight like '%".$q_item."%')";
594 684
 					$additional_query .= ")";
595 685
 				}
@@ -816,7 +906,9 @@  discard block
 block discarded – undo
816 906
 				date_default_timezone_set($globalTimezone);
817 907
 				$datetime = new DateTime();
818 908
 				$offset = $datetime->format('P');
819
-			} else $offset = '+00:00';
909
+			} else {
910
+				$offset = '+00:00';
911
+			}
820 912
 
821 913
 			if ($date_array[1] != "")
822 914
 			{
@@ -848,8 +940,12 @@  discard block
 block discarded – undo
848 940
 			{
849 941
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
850 942
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
851
-			} else $limit_query = "";
852
-		} else $limit_query = "";
943
+			} else {
944
+				$limit_query = "";
945
+			}
946
+		} else {
947
+			$limit_query = "";
948
+		}
853 949
 
854 950
 
855 951
 		if ($sort != "")
@@ -917,8 +1013,12 @@  discard block
 block discarded – undo
917 1013
 			{
918 1014
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
919 1015
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
920
-			} else $limit_query = "";
921
-		} else $limit_query = "";
1016
+			} else {
1017
+				$limit_query = "";
1018
+			}
1019
+		} else {
1020
+			$limit_query = "";
1021
+		}
922 1022
 		
923 1023
 		if ($sort != "")
924 1024
 		{
@@ -1242,7 +1342,9 @@  discard block
 block discarded – undo
1242 1342
 		global $global_query;
1243 1343
 		
1244 1344
 		date_default_timezone_set('UTC');
1245
-		if ($id == '') return array();
1345
+		if ($id == '') {
1346
+			return array();
1347
+		}
1246 1348
 		$additional_query = "spotter_output.spotter_id = :id";
1247 1349
 		$query_values = array(':id' => $id);
1248 1350
 
@@ -1357,8 +1459,11 @@  discard block
 block discarded – undo
1357 1459
 		if ($sort != "")
1358 1460
 		{
1359 1461
 			$search_orderby_array = $this->getOrderBy();
1360
-			if (isset($search_orderby_array[$sort]['sql'])) $orderby_query = $search_orderby_array[$sort]['sql'];
1361
-			else $orderby_query = " ORDER BY spotter_output.date DESC";
1462
+			if (isset($search_orderby_array[$sort]['sql'])) {
1463
+				$orderby_query = $search_orderby_array[$sort]['sql'];
1464
+			} else {
1465
+				$orderby_query = " ORDER BY spotter_output.date DESC";
1466
+			}
1362 1467
 		} else {
1363 1468
 			$orderby_query = " ORDER BY spotter_output.date DESC";
1364 1469
 		}
@@ -1983,7 +2088,9 @@  discard block
 block discarded – undo
1983 2088
 		{
1984 2089
 			$highlight = $row['highlight'];
1985 2090
 		}
1986
-		if (isset($highlight)) return $highlight;
2091
+		if (isset($highlight)) {
2092
+			return $highlight;
2093
+		}
1987 2094
 	}
1988 2095
 
1989 2096
 	
@@ -2011,7 +2118,9 @@  discard block
 block discarded – undo
2011 2118
 		$sth->closeCursor();
2012 2119
 		if (count($row) > 0) {
2013 2120
 			return $row['usage'];
2014
-		} else return '';
2121
+		} else {
2122
+			return '';
2123
+		}
2015 2124
 	}
2016 2125
 
2017 2126
 	/**
@@ -2036,7 +2145,9 @@  discard block
 block discarded – undo
2036 2145
 		$sth->closeCursor();
2037 2146
 		if (count($row) > 0) {
2038 2147
 			return $row['icao'];
2039
-		} else return '';
2148
+		} else {
2149
+			return '';
2150
+		}
2040 2151
 	}
2041 2152
 
2042 2153
 	/**
@@ -2064,7 +2175,9 @@  discard block
 block discarded – undo
2064 2175
 			$airport_longitude = $row['longitude'];
2065 2176
 			$Common = new Common();
2066 2177
 			return $Common->distance($latitude,$longitude,$airport_latitude,$airport_longitude);
2067
-		} else return '';
2178
+		} else {
2179
+			return '';
2180
+		}
2068 2181
 	}
2069 2182
 	
2070 2183
 	/**
@@ -2176,7 +2289,9 @@  discard block
 block discarded – undo
2176 2289
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2177 2290
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2178 2291
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2179
-		} else return array();
2292
+		} else {
2293
+			return array();
2294
+		}
2180 2295
 		if ($globalDBdriver == 'mysql') {
2181 2296
 			$query  = "SELECT airport.* FROM airport WHERE airport.latitude BETWEEN ".$minlat." AND ".$maxlat." AND airport.longitude BETWEEN ".$minlong." AND ".$maxlong." AND airport.type != 'closed'";
2182 2297
 		} else {
@@ -2211,7 +2326,9 @@  discard block
 block discarded – undo
2211 2326
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2212 2327
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2213 2328
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2214
-		} else return array();
2329
+		} else {
2330
+			return array();
2331
+		}
2215 2332
 		//$query  = "SELECT waypoints.* FROM waypoints WHERE waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong;
2216 2333
 		$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.")";
2217 2334
 		//$query  = "SELECT waypoints.* FROM waypoints";
@@ -2246,7 +2363,9 @@  discard block
 block discarded – undo
2246 2363
 	public function getAllAirlineInfo($airline_icao, $fromsource = NULL)
2247 2364
 	{
2248 2365
 		global $globalUseRealAirlines;
2249
-		if (isset($globalUseRealAirlines) && $globalUseRealAirlines) $fromsource = NULL;
2366
+		if (isset($globalUseRealAirlines) && $globalUseRealAirlines) {
2367
+			$fromsource = NULL;
2368
+		}
2250 2369
 		$airline_icao = strtoupper(filter_var($airline_icao,FILTER_SANITIZE_STRING));
2251 2370
 		if ($airline_icao == 'NA') {
2252 2371
 			$airline_array = array();
@@ -2315,7 +2434,9 @@  discard block
 block discarded – undo
2315 2434
 	public function getAllAirlineInfoByName($airline_name, $fromsource = NULL)
2316 2435
 	{
2317 2436
 		global $globalUseRealAirlines;
2318
-		if (isset($globalUseRealAirlines) && $globalUseRealAirlines) $fromsource = NULL;
2437
+		if (isset($globalUseRealAirlines) && $globalUseRealAirlines) {
2438
+			$fromsource = NULL;
2439
+		}
2319 2440
 		$airline_name = strtolower(filter_var($airline_name,FILTER_SANITIZE_STRING));
2320 2441
 		$query  = "SELECT airlines.name, airlines.iata, airlines.icao, airlines.callsign, airlines.country, airlines.type FROM airlines WHERE lower(airlines.name) = :airline_name AND airlines.active = 'Y' AND airlines.forsource IS NULL LIMIT 1";
2321 2442
 		$sth = $this->db->prepare($query);
@@ -2331,7 +2452,9 @@  discard block
 block discarded – undo
2331 2452
 			$sth->execute(array(':fromsource' => $fromsource));
2332 2453
 			$row = $sth->fetch(PDO::FETCH_ASSOC);
2333 2454
 			$sth->closeCursor();
2334
-			if ($row['nb'] == 0) $result = $this->getAllAirlineInfoByName($airline_name);
2455
+			if ($row['nb'] == 0) {
2456
+				$result = $this->getAllAirlineInfoByName($airline_name);
2457
+			}
2335 2458
 		}
2336 2459
 		return $result;
2337 2460
 	}
@@ -2394,15 +2517,20 @@  discard block
 block discarded – undo
2394 2517
 				'A320-211' => 'A320',
2395 2518
 				'747-8i' => 'B748',
2396 2519
 				'A380' => 'A388');
2397
-		if (isset($all_aircraft[$aircraft_type])) return $all_aircraft[$aircraft_type];
2520
+		if (isset($all_aircraft[$aircraft_type])) {
2521
+			return $all_aircraft[$aircraft_type];
2522
+		}
2398 2523
 
2399 2524
 		$query  = "SELECT aircraft.icao FROM aircraft WHERE aircraft.type LIKE :saircraft_type OR aircraft.type = :aircraft_type OR aircraft.icao = :aircraft_type LIMIT 1";
2400 2525
 		$aircraft_type = strtoupper($aircraft_type);
2401 2526
 		$sth = $this->db->prepare($query);
2402 2527
 		$sth->execute(array(':saircraft_type' => '%'.$aircraft_type.'%',':aircraft_type' => $aircraft_type,));
2403 2528
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
2404
-		if (isset($result[0]['icao'])) return $result[0]['icao'];
2405
-		else return '';
2529
+		if (isset($result[0]['icao'])) {
2530
+			return $result[0]['icao'];
2531
+		} else {
2532
+			return '';
2533
+		}
2406 2534
 	}
2407 2535
 	
2408 2536
 	/**
@@ -2430,11 +2558,15 @@  discard block
 block discarded – undo
2430 2558
 		$sth->closeCursor();
2431 2559
 		if (isset($row['icaotypecode'])) {
2432 2560
 			$icao = $row['icaotypecode'];
2433
-			if (isset($this->aircraft_correct_icaotype[$icao])) $icao = $this->aircraft_correct_icaotype[$icao];
2561
+			if (isset($this->aircraft_correct_icaotype[$icao])) {
2562
+				$icao = $this->aircraft_correct_icaotype[$icao];
2563
+			}
2434 2564
 			return $icao;
2435 2565
 		} elseif ($source_type == 'flarm') {
2436 2566
 			return $this->getAllAircraftType($aircraft_modes);
2437
-		} else  return '';
2567
+		} else {
2568
+			return '';
2569
+		}
2438 2570
 	}
2439 2571
 
2440 2572
 	/**
@@ -2457,7 +2589,9 @@  discard block
 block discarded – undo
2457 2589
 		$sth->closeCursor();
2458 2590
 		if (isset($row['icaotypecode'])) {
2459 2591
 			return $row['icaotypecode'];
2460
-		} else return '';
2592
+		} else {
2593
+			return '';
2594
+		}
2461 2595
 	}
2462 2596
 
2463 2597
 	/**
@@ -2503,7 +2637,9 @@  discard block
 block discarded – undo
2503 2637
 		$sth->closeCursor();
2504 2638
 		if (isset($row['operator_correct'])) {
2505 2639
 			return $row['operator_correct'];
2506
-		} else return $operator;
2640
+		} else {
2641
+			return $operator;
2642
+		}
2507 2643
 	}
2508 2644
 
2509 2645
 	/**
@@ -2516,7 +2652,9 @@  discard block
 block discarded – undo
2516 2652
 	public function getRouteInfo($callsign)
2517 2653
 	{
2518 2654
 		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
2519
-                if ($callsign == '') return array();
2655
+                if ($callsign == '') {
2656
+                	return array();
2657
+                }
2520 2658
 		$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";
2521 2659
 		
2522 2660
 		$sth = $this->db->prepare($query);
@@ -2526,7 +2664,9 @@  discard block
 block discarded – undo
2526 2664
 		$sth->closeCursor();
2527 2665
 		if (count($row) > 0) {
2528 2666
 			return $row;
2529
-		} else return array();
2667
+		} else {
2668
+			return array();
2669
+		}
2530 2670
 	}
2531 2671
 	
2532 2672
 	/**
@@ -2579,7 +2719,9 @@  discard block
 block discarded – undo
2579 2719
 			$result = $sth->fetch(PDO::FETCH_ASSOC);
2580 2720
 			$sth->closeCursor();
2581 2721
 			return $result;
2582
-		} else return array();
2722
+		} else {
2723
+			return array();
2724
+		}
2583 2725
 	}
2584 2726
 	
2585 2727
   
@@ -2738,8 +2880,11 @@  discard block
 block discarded – undo
2738 2880
 		$query .= " ORDER BY spotter_output.source_name ASC";
2739 2881
 
2740 2882
 		$sth = $this->db->prepare($query);
2741
-		if (!empty($query_values)) $sth->execute($query_values);
2742
-		else $sth->execute();
2883
+		if (!empty($query_values)) {
2884
+			$sth->execute($query_values);
2885
+		} else {
2886
+			$sth->execute();
2887
+		}
2743 2888
 
2744 2889
 		$source_array = array();
2745 2890
 		$temp_array = array();
@@ -2772,9 +2917,13 @@  discard block
 block discarded – undo
2772 2917
 								WHERE spotter_output.airline_icao <> '' 
2773 2918
 								ORDER BY spotter_output.airline_name ASC";
2774 2919
 			*/
2775
-			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $forsource = $globalAirlinesSource;
2776
-			elseif (isset($globalVATSIM) && $globalVATSIM) $forsource = 'vatsim';
2777
-			elseif (isset($globalIVAO) && $globalIVAO) $forsource = 'ivao';
2920
+			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
2921
+				$forsource = $globalAirlinesSource;
2922
+			} elseif (isset($globalVATSIM) && $globalVATSIM) {
2923
+				$forsource = 'vatsim';
2924
+			} elseif (isset($globalIVAO) && $globalIVAO) {
2925
+				$forsource = 'ivao';
2926
+			}
2778 2927
 			if ($forsource === NULL) {
2779 2928
 				$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";
2780 2929
 				$query_data = array();
@@ -2817,9 +2966,13 @@  discard block
 block discarded – undo
2817 2966
 	{
2818 2967
 		global $globalAirlinesSource,$globalVATSIM, $globalIVAO;
2819 2968
 		$filter_query = $this->getFilter($filters,true,true);
2820
-		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $forsource = $globalAirlinesSource;
2821
-		elseif (isset($globalVATSIM) && $globalVATSIM) $forsource = 'vatsim';
2822
-		elseif (isset($globalIVAO) && $globalIVAO) $forsource = 'ivao';
2969
+		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
2970
+			$forsource = $globalAirlinesSource;
2971
+		} elseif (isset($globalVATSIM) && $globalVATSIM) {
2972
+			$forsource = 'vatsim';
2973
+		} elseif (isset($globalIVAO) && $globalIVAO) {
2974
+			$forsource = 'ivao';
2975
+		}
2823 2976
 		if ($forsource === NULL) {
2824 2977
 			$query = "SELECT DISTINCT alliance FROM airlines WHERE alliance IS NOT NULL AND forsource IS NULL ORDER BY alliance ASC";
2825 2978
 			$query_data = array();
@@ -3130,7 +3283,9 @@  discard block
 block discarded – undo
3130 3283
 			date_default_timezone_set($globalTimezone);
3131 3284
 			$datetime = new DateTime();
3132 3285
 			$offset = $datetime->format('P');
3133
-		} else $offset = '+00:00';
3286
+		} else {
3287
+			$offset = '+00:00';
3288
+		}
3134 3289
 		if ($airport_icao == '') {
3135 3290
 			if ($globalDBdriver == 'mysql') {
3136 3291
 				$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' AND departure_airport_icao <> '' 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";
@@ -3162,7 +3317,9 @@  discard block
 block discarded – undo
3162 3317
 			date_default_timezone_set($globalTimezone);
3163 3318
 			$datetime = new DateTime();
3164 3319
 			$offset = $datetime->format('P');
3165
-		} else $offset = '+00:00';
3320
+		} else {
3321
+			$offset = '+00:00';
3322
+		}
3166 3323
 		if ($airport_icao == '') {
3167 3324
 			if ($globalDBdriver == 'mysql') {
3168 3325
 				$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 departure_airport_icao <> '' 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";
@@ -3195,7 +3352,9 @@  discard block
 block discarded – undo
3195 3352
 			date_default_timezone_set($globalTimezone);
3196 3353
 			$datetime = new DateTime();
3197 3354
 			$offset = $datetime->format('P');
3198
-		} else $offset = '+00:00';
3355
+		} else {
3356
+			$offset = '+00:00';
3357
+		}
3199 3358
 		if ($airport_icao == '') {
3200 3359
 			if ($globalDBdriver == 'mysql') {
3201 3360
 				$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 
@@ -3234,7 +3393,9 @@  discard block
 block discarded – undo
3234 3393
 			date_default_timezone_set($globalTimezone);
3235 3394
 			$datetime = new DateTime();
3236 3395
 			$offset = $datetime->format('P');
3237
-		} else $offset = '+00:00';
3396
+		} else {
3397
+			$offset = '+00:00';
3398
+		}
3238 3399
 		if ($airport_icao == '') {
3239 3400
 			if ($globalDBdriver == 'mysql') {
3240 3401
 				$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 
@@ -3279,7 +3440,9 @@  discard block
 block discarded – undo
3279 3440
 			date_default_timezone_set($globalTimezone);
3280 3441
 			$datetime = new DateTime();
3281 3442
 			$offset = $datetime->format('P');
3282
-		} else $offset = '+00:00';
3443
+		} else {
3444
+			$offset = '+00:00';
3445
+		}
3283 3446
 		if ($airport_icao == '') {
3284 3447
 			if ($globalDBdriver == 'mysql') {
3285 3448
 				$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' AND arrival_airport_icao <> '' 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";
@@ -3314,7 +3477,9 @@  discard block
 block discarded – undo
3314 3477
 			date_default_timezone_set($globalTimezone);
3315 3478
 			$datetime = new DateTime();
3316 3479
 			$offset = $datetime->format('P');
3317
-		} else $offset = '+00:00';
3480
+		} else {
3481
+			$offset = '+00:00';
3482
+		}
3318 3483
 		if ($airport_icao == '') {
3319 3484
 			if ($globalDBdriver == 'mysql') {
3320 3485
 				$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 
@@ -3356,7 +3521,9 @@  discard block
 block discarded – undo
3356 3521
 			date_default_timezone_set($globalTimezone);
3357 3522
 			$datetime = new DateTime();
3358 3523
 			$offset = $datetime->format('P');
3359
-		} else $offset = '+00:00';
3524
+		} else {
3525
+			$offset = '+00:00';
3526
+		}
3360 3527
 		if ($airport_icao == '') {
3361 3528
 			if ($globalDBdriver == 'mysql') {
3362 3529
 				$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 arrival_airport_icao <> '' 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";
@@ -3390,7 +3557,9 @@  discard block
 block discarded – undo
3390 3557
 			date_default_timezone_set($globalTimezone);
3391 3558
 			$datetime = new DateTime();
3392 3559
 			$offset = $datetime->format('P');
3393
-		} else $offset = '+00:00';
3560
+		} else {
3561
+			$offset = '+00:00';
3562
+		}
3394 3563
 		if ($airport_icao == '') {
3395 3564
 			if ($globalDBdriver == 'mysql') {
3396 3565
 				$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 
@@ -3438,7 +3607,9 @@  discard block
 block discarded – undo
3438 3607
 			date_default_timezone_set($globalTimezone);
3439 3608
 			$datetime = new DateTime();
3440 3609
 			$offset = $datetime->format('P');
3441
-		} else $offset = '+00:00';
3610
+		} else {
3611
+			$offset = '+00:00';
3612
+		}
3442 3613
 
3443 3614
 		if ($globalDBdriver == 'mysql') {
3444 3615
 			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) as date
@@ -3558,7 +3729,9 @@  discard block
 block discarded – undo
3558 3729
 	*/	
3559 3730
 	public function updateLatestSpotterData($flightaware_id = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $ground = false, $groundspeed = NULL, $date = '', $arrival_airport_icao = '',$arrival_airport_time = '')
3560 3731
 	{
3561
-		if ($groundspeed == '') $groundspeed = NULL;
3732
+		if ($groundspeed == '') {
3733
+			$groundspeed = NULL;
3734
+		}
3562 3735
 		$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';
3563 3736
                 $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);
3564 3737
 
@@ -3608,10 +3781,18 @@  discard block
 block discarded – undo
3608 3781
 		$Image = new Image($this->db);
3609 3782
 		$Common = new Common();
3610 3783
 		
3611
-		if (!isset($globalIVAO)) $globalIVAO = FALSE;
3612
-		if (!isset($globalVATSIM)) $globalVATSIM = FALSE;
3613
-		if (!isset($globalphpVMS)) $globalphpVMS = FALSE;
3614
-		if (!isset($globalVAM)) $globalVAM = FALSE;
3784
+		if (!isset($globalIVAO)) {
3785
+			$globalIVAO = FALSE;
3786
+		}
3787
+		if (!isset($globalVATSIM)) {
3788
+			$globalVATSIM = FALSE;
3789
+		}
3790
+		if (!isset($globalphpVMS)) {
3791
+			$globalphpVMS = FALSE;
3792
+		}
3793
+		if (!isset($globalVAM)) {
3794
+			$globalVAM = FALSE;
3795
+		}
3615 3796
 		date_default_timezone_set('UTC');
3616 3797
 		
3617 3798
 		//getting the registration
@@ -3624,23 +3805,33 @@  discard block
 block discarded – undo
3624 3805
 				if ($ModeS != '') {
3625 3806
 					$timeelapsed = microtime(true);
3626 3807
 					$registration = $this->getAircraftRegistrationBymodeS($ModeS,$source_type);
3627
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3808
+					if ($globalDebugTimeElapsed) {
3809
+						echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3810
+					}
3628 3811
 				} else {
3629 3812
 					$myhex = explode('-',$flightaware_id);
3630 3813
 					if (count($myhex) > 0) {
3631 3814
 						$timeelapsed = microtime(true);
3632 3815
 						$registration = $this->getAircraftRegistrationBymodeS($myhex[0],$source_type);
3633
-						if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3816
+						if ($globalDebugTimeElapsed) {
3817
+							echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3818
+						}
3634 3819
 					}
3635 3820
 				}
3636 3821
 			}
3637 3822
 		}
3638 3823
 		$fromsource = NULL;
3639
-		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
3640
-		elseif ($format_source == 'vatsimtxt') $fromsource = 'vatsim';
3641
-		elseif ($format_source == 'whazzup') $fromsource = 'ivao';
3642
-		elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
3643
-		elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
3824
+		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
3825
+			$fromsource = $globalAirlinesSource;
3826
+		} elseif ($format_source == 'vatsimtxt') {
3827
+			$fromsource = 'vatsim';
3828
+		} elseif ($format_source == 'whazzup') {
3829
+			$fromsource = 'ivao';
3830
+		} elseif (isset($globalVATSIM) && $globalVATSIM) {
3831
+			$fromsource = 'vatsim';
3832
+		} elseif (isset($globalIVAO) && $globalIVAO) {
3833
+			$fromsource = 'ivao';
3834
+		}
3644 3835
 		//getting the airline information
3645 3836
 		if ($ident != "")
3646 3837
 		{
@@ -3664,15 +3855,21 @@  discard block
 block discarded – undo
3664 3855
 					if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == ""){
3665 3856
 						$airline_array = $this->getAllAirlineInfo("NA");
3666 3857
 					}
3667
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3858
+					if ($globalDebugTimeElapsed) {
3859
+						echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3860
+					}
3668 3861
 
3669 3862
 				} else {
3670 3863
 					$timeelapsed = microtime(true);
3671 3864
 					$airline_array = $this->getAllAirlineInfo("NA");
3672
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3865
+					if ($globalDebugTimeElapsed) {
3866
+						echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3867
+					}
3673 3868
 				}
3674 3869
 			}
3675
-		} else $airline_array = array();
3870
+		} else {
3871
+			$airline_array = array();
3872
+		}
3676 3873
 		
3677 3874
 		//getting the aircraft information
3678 3875
 		$aircraft_array = array();
@@ -3686,27 +3883,37 @@  discard block
 block discarded – undo
3686 3883
 				{
3687 3884
 					$timeelapsed = microtime(true);
3688 3885
 					$aircraft_array = $this->getAllAircraftInfo("NA");
3689
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3886
+					if ($globalDebugTimeElapsed) {
3887
+						echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3888
+					}
3690 3889
 				} else {
3691 3890
 					$timeelapsed = microtime(true);
3692 3891
 					$aircraft_array = $this->getAllAircraftInfo($aircraft_icao);
3693
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3892
+					if ($globalDebugTimeElapsed) {
3893
+						echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3894
+					}
3694 3895
 				}
3695 3896
 			}
3696 3897
 		} else {
3697 3898
 			if ($ModeS != '') {
3698 3899
 				$timeelapsed = microtime(true);
3699 3900
 				$aircraft_icao = $this->getAllAircraftType($ModeS,$source_type);
3700
-				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAircraftType : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3901
+				if ($globalDebugTimeElapsed) {
3902
+					echo 'ADD SPOTTER DATA : Time elapsed for getAllAircraftType : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3903
+				}
3701 3904
 				if ($aircraft_icao == "" || $aircraft_icao == "XXXX")
3702 3905
 				{
3703 3906
 					$timeelapsed = microtime(true);
3704 3907
 					$aircraft_array = $this->getAllAircraftInfo("NA");
3705
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3908
+					if ($globalDebugTimeElapsed) {
3909
+						echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3910
+					}
3706 3911
 				} else {
3707 3912
 					$timeelapsed = microtime(true);
3708 3913
 					$aircraft_array = $this->getAllAircraftInfo($aircraft_icao);
3709
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3914
+					if ($globalDebugTimeElapsed) {
3915
+						echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3916
+					}
3710 3917
 				}
3711 3918
 			}
3712 3919
 		}
@@ -3722,7 +3929,9 @@  discard block
 block discarded – undo
3722 3929
 			} else {
3723 3930
 				$timeelapsed = microtime(true);
3724 3931
 				$departure_airport_array = $this->getAllAirportInfo($departure_airport_icao);
3725
-				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3932
+				if ($globalDebugTimeElapsed) {
3933
+					echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3934
+				}
3726 3935
 			}
3727 3936
 		}
3728 3937
 		
@@ -3737,7 +3946,9 @@  discard block
 block discarded – undo
3737 3946
 			} else {
3738 3947
 				$timeelapsed = microtime(true);
3739 3948
 				$arrival_airport_array = $this->getAllAirportInfo($arrival_airport_icao);
3740
-				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3949
+				if ($globalDebugTimeElapsed) {
3950
+					echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3951
+				}
3741 3952
 			}
3742 3953
 		}
3743 3954
 
@@ -3771,7 +3982,9 @@  discard block
 block discarded – undo
3771 3982
 			{
3772 3983
 				return false;
3773 3984
 			}
3774
-		} else $altitude = 0;
3985
+		} else {
3986
+			$altitude = 0;
3987
+		}
3775 3988
 		
3776 3989
 		if ($heading != "")
3777 3990
 		{
@@ -3800,7 +4013,9 @@  discard block
 block discarded – undo
3800 4013
 		{
3801 4014
 			$timeelapsed = microtime(true);
3802 4015
 			$image_array = $Image->getSpotterImage($registration);
3803
-			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getSpotterImage : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
4016
+			if ($globalDebugTimeElapsed) {
4017
+				echo 'ADD SPOTTER DATA : Time elapsed for getSpotterImage : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
4018
+			}
3804 4019
 			if (!isset($image_array[0]['registration']))
3805 4020
 			{
3806 4021
 				//echo "Add image !!!! \n";
@@ -3808,14 +4023,21 @@  discard block
 block discarded – undo
3808 4023
 			}
3809 4024
 			$timeelapsed = microtime(true);
3810 4025
 			$owner_info = $this->getAircraftOwnerByRegistration($registration);
3811
-			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftOwnerByRegistration : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3812
-			if ($owner_info['owner'] != '') $aircraft_owner = ucwords(strtolower($owner_info['owner']));
4026
+			if ($globalDebugTimeElapsed) {
4027
+				echo 'ADD SPOTTER DATA : Time elapsed for getAircraftOwnerByRegistration : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
4028
+			}
4029
+			if ($owner_info['owner'] != '') {
4030
+				$aircraft_owner = ucwords(strtolower($owner_info['owner']));
4031
+			}
3813 4032
 		}
3814 4033
     
3815 4034
 		if ($globalIVAO && $aircraft_icao != '')
3816 4035
 		{
3817
-            		if (isset($airline_array[0]['icao'])) $airline_icao = $airline_array[0]['icao'];
3818
-            		else $airline_icao = '';
4036
+            		if (isset($airline_array[0]['icao'])) {
4037
+            			$airline_icao = $airline_array[0]['icao'];
4038
+            		} else {
4039
+            			$airline_icao = '';
4040
+            		}
3819 4041
 			$image_array = $Image->getSpotterImage('',$aircraft_icao,$airline_icao);
3820 4042
 			if (!isset($image_array[0]['registration']))
3821 4043
 			{
@@ -3860,16 +4082,28 @@  discard block
 block discarded – undo
3860 4082
                 {
3861 4083
                         $arrival_airport_array = $this->getAllAirportInfo('NA');
3862 4084
                 }
3863
-                if ($registration == '') $registration = 'NA';
4085
+                if ($registration == '') {
4086
+                	$registration = 'NA';
4087
+                }
3864 4088
                 if ($latitude == '' && $longitude == '') {
3865 4089
             		$latitude = 0;
3866 4090
             		$longitude = 0;
3867 4091
             	}
3868
-                if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL;
3869
-                if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL;
3870
-                if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
3871
-                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
3872
-                if (!isset($aircraft_owner)) $aircraft_owner = NULL;
4092
+                if ($squawk == '' || $Common->isInteger($squawk) === false) {
4093
+                	$squawk = NULL;
4094
+                }
4095
+                if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) {
4096
+                	$verticalrate = NULL;
4097
+                }
4098
+                if ($heading == '' || $Common->isInteger($heading) === false) {
4099
+                	$heading = 0;
4100
+                }
4101
+                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) {
4102
+                	$groundspeed = 0;
4103
+                }
4104
+                if (!isset($aircraft_owner)) {
4105
+                	$aircraft_owner = NULL;
4106
+                }
3873 4107
                 $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) 
3874 4108
                 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)";
3875 4109
 
@@ -3880,9 +4114,13 @@  discard block
 block discarded – undo
3880 4114
 		if ($airline_type == '') {
3881 4115
 			$timeelapsed = microtime(true);
3882 4116
 			$airline_type = $this->getAircraftTypeBymodeS($ModeS);
3883
-			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftTypeBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
4117
+			if ($globalDebugTimeElapsed) {
4118
+				echo 'ADD SPOTTER DATA : Time elapsed for getAircraftTypeBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
4119
+			}
4120
+		}
4121
+		if ($airline_type == null) {
4122
+			$airline_type = '';
3884 4123
 		}
3885
-		if ($airline_type == null) $airline_type = '';
3886 4124
                 $aircraft_type = $aircraft_array[0]['type'];
3887 4125
                 $aircraft_manufacturer = $aircraft_array[0]['manufacturer'];
3888 4126
                 $departure_airport_name = $departure_airport_array[0]['name'];
@@ -4046,7 +4284,9 @@  discard block
 block discarded – undo
4046 4284
 			}
4047 4285
 		}
4048 4286
 		$query .= " GROUP BY spotter_output.airline_name,spotter_output.airline_icao, spotter_output.airline_country ORDER BY airline_count DESC";
4049
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4287
+		if ($limit) {
4288
+			$query .= " LIMIT 10 OFFSET 0";
4289
+		}
4050 4290
 
4051 4291
 		$sth = $this->db->prepare($query);
4052 4292
 		$sth->execute($query_values);
@@ -4119,7 +4359,9 @@  discard block
 block discarded – undo
4119 4359
 		}
4120 4360
 		
4121 4361
 		$query .= " GROUP BY spotter_output.pilot_id,s.pilot_name,spotter_output.format_source ORDER BY pilot_count DESC";
4122
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4362
+		if ($limit) {
4363
+			$query .= " LIMIT 10 OFFSET 0";
4364
+		}
4123 4365
       
4124 4366
 		
4125 4367
 		$sth = $this->db->prepare($query);
@@ -4163,7 +4405,9 @@  discard block
 block discarded – undo
4163 4405
 			}
4164 4406
 		}
4165 4407
 		$query .= "GROUP BY spotter_output.airline_icao, spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.format_source ORDER BY pilot_count DESC";
4166
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4408
+		if ($limit) {
4409
+			$query .= " LIMIT 10 OFFSET 0";
4410
+		}
4167 4411
       
4168 4412
 		
4169 4413
 		$sth = $this->db->prepare($query);
@@ -4239,7 +4483,9 @@  discard block
 block discarded – undo
4239 4483
 			}
4240 4484
 		}
4241 4485
 		$query .= " GROUP BY spotter_output.owner_name ORDER BY owner_count DESC";
4242
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4486
+		if ($limit) {
4487
+			$query .= " LIMIT 10 OFFSET 0";
4488
+		}
4243 4489
 		
4244 4490
 		$sth = $this->db->prepare($query);
4245 4491
 		$sth->execute($query_values);
@@ -4281,7 +4527,9 @@  discard block
 block discarded – undo
4281 4527
 			}
4282 4528
 		}
4283 4529
 		$query .= "GROUP BY spotter_output.airline_icao, spotter_output.owner_name ORDER BY owner_count DESC";
4284
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4530
+		if ($limit) {
4531
+			$query .= " LIMIT 10 OFFSET 0";
4532
+		}
4285 4533
       
4286 4534
 		
4287 4535
 		$sth = $this->db->prepare($query);
@@ -4524,7 +4772,9 @@  discard block
 block discarded – undo
4524 4772
 			date_default_timezone_set($globalTimezone);
4525 4773
 			$datetime = new DateTime($date);
4526 4774
 			$offset = $datetime->format('P');
4527
-		} else $offset = '+00:00';
4775
+		} else {
4776
+			$offset = '+00:00';
4777
+		}
4528 4778
 
4529 4779
 		if ($globalDBdriver == 'mysql') {
4530 4780
 			$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
@@ -4572,7 +4822,9 @@  discard block
 block discarded – undo
4572 4822
 			date_default_timezone_set($globalTimezone);
4573 4823
 			$datetime = new DateTime($date);
4574 4824
 			$offset = $datetime->format('P');
4575
-		} else $offset = '+00:00';
4825
+		} else {
4826
+			$offset = '+00:00';
4827
+		}
4576 4828
 		
4577 4829
 		if ($globalDBdriver == 'mysql') {
4578 4830
 			$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
@@ -4692,9 +4944,13 @@  discard block
 block discarded – undo
4692 4944
 		$sth = $this->db->prepare($query);
4693 4945
 		$sth->execute($query_values);
4694 4946
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
4695
-		if (is_numeric($result[0]['duration'])) return gmdate('H:i:s',$result[0]['duration']);
4696
-		elseif ($result[0]['duration'] == '') return 0;
4697
-		else return $result[0]['duration'];
4947
+		if (is_numeric($result[0]['duration'])) {
4948
+			return gmdate('H:i:s',$result[0]['duration']);
4949
+		} elseif ($result[0]['duration'] == '') {
4950
+			return 0;
4951
+		} else {
4952
+			return $result[0]['duration'];
4953
+		}
4698 4954
 	}
4699 4955
 
4700 4956
 	/**
@@ -4783,8 +5039,11 @@  discard block
 block discarded – undo
4783 5039
 		$sth = $this->db->prepare($query);
4784 5040
 		$sth->execute($query_values);
4785 5041
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
4786
-		if (is_int($result[0]['duration'])) return gmdate('H:i:s',$result[0]['duration']);
4787
-		else return $result[0]['duration'];
5042
+		if (is_int($result[0]['duration'])) {
5043
+			return gmdate('H:i:s',$result[0]['duration']);
5044
+		} else {
5045
+			return $result[0]['duration'];
5046
+		}
4788 5047
 	}
4789 5048
 
4790 5049
 	/**
@@ -4989,7 +5248,9 @@  discard block
 block discarded – undo
4989 5248
 		}
4990 5249
 		$query .= " GROUP BY spotter_output.airline_country
4991 5250
 					ORDER BY airline_country_count DESC";
4992
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5251
+		if ($limit) {
5252
+			$query .= " LIMIT 10 OFFSET 0";
5253
+		}
4993 5254
       
4994 5255
 		$sth = $this->db->prepare($query);
4995 5256
 		$sth->execute($query_values);
@@ -5017,7 +5278,9 @@  discard block
 block discarded – undo
5017 5278
 		global $globalDBdriver;
5018 5279
 		//$filter_query = $this->getFilter($filters,true,true);
5019 5280
 		$Connection= new Connection($this->db);
5020
-		if (!$Connection->tableExists('countries')) return array();
5281
+		if (!$Connection->tableExists('countries')) {
5282
+			return array();
5283
+		}
5021 5284
 		/*
5022 5285
 		$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
5023 5286
 					FROM countries c, spotter_output s
@@ -5049,7 +5312,9 @@  discard block
 block discarded – undo
5049 5312
 		}
5050 5313
 		$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 ";
5051 5314
 		$query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC";
5052
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5315
+		if ($limit) {
5316
+			$query .= " LIMIT 10 OFFSET 0";
5317
+		}
5053 5318
       
5054 5319
 		
5055 5320
 		$sth = $this->db->prepare($query);
@@ -5126,7 +5391,9 @@  discard block
 block discarded – undo
5126 5391
 		}
5127 5392
 
5128 5393
 		$query .= " GROUP BY spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer ORDER BY aircraft_icao_count DESC";
5129
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5394
+		if ($limit) {
5395
+			$query .= " LIMIT 10 OFFSET 0";
5396
+		}
5130 5397
  
5131 5398
 		$sth = $this->db->prepare($query);
5132 5399
 		$sth->execute($query_values);
@@ -5200,7 +5467,9 @@  discard block
 block discarded – undo
5200 5467
 		}
5201 5468
 
5202 5469
 		$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";
5203
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5470
+		if ($limit) {
5471
+			$query .= " LIMIT 10 OFFSET 0";
5472
+		}
5204 5473
  
5205 5474
 		$sth = $this->db->prepare($query);
5206 5475
 		$sth->execute($query_values);
@@ -5247,7 +5516,9 @@  discard block
 block discarded – undo
5247 5516
 		}
5248 5517
 
5249 5518
 		$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";
5250
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5519
+		if ($limit) {
5520
+			$query .= " LIMIT 10 OFFSET 0";
5521
+		}
5251 5522
  
5252 5523
 		$sth = $this->db->prepare($query);
5253 5524
 		$sth->execute();
@@ -5300,7 +5571,9 @@  discard block
 block discarded – undo
5300 5571
 			if($row['registration'] != "")
5301 5572
 			{
5302 5573
 				$image_array = $Image->getSpotterImage($row['registration']);
5303
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5574
+				if (isset($image_array[0]['image_thumbnail'])) {
5575
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5576
+				}
5304 5577
 			}
5305 5578
 			$temp_array['registration_count'] = $row['registration_count'];
5306 5579
 
@@ -5375,7 +5648,9 @@  discard block
 block discarded – undo
5375 5648
 			if($row['registration'] != "")
5376 5649
 			{
5377 5650
 				$image_array = $Image->getSpotterImage($row['registration']);
5378
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5651
+				if (isset($image_array[0]['image_thumbnail'])) {
5652
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5653
+				}
5379 5654
 			}
5380 5655
 			$temp_array['registration_count'] = $row['registration_count'];
5381 5656
 
@@ -5482,7 +5757,9 @@  discard block
 block discarded – undo
5482 5757
 			if($row['registration'] != "")
5483 5758
 			{
5484 5759
 				$image_array = $Image->getSpotterImage($row['registration']);
5485
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5760
+				if (isset($image_array[0]['image_thumbnail'])) {
5761
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5762
+				}
5486 5763
 			}
5487 5764
 			$temp_array['registration_count'] = $row['registration_count'];
5488 5765
 			$aircraft_array[] = $temp_array;
@@ -5607,7 +5884,9 @@  discard block
 block discarded – undo
5607 5884
 			date_default_timezone_set($globalTimezone);
5608 5885
 			$datetime = new DateTime($date);
5609 5886
 			$offset = $datetime->format('P');
5610
-		} else $offset = '+00:00';
5887
+		} else {
5888
+			$offset = '+00:00';
5889
+		}
5611 5890
 
5612 5891
 		if ($globalDBdriver == 'mysql') {
5613 5892
 			$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
@@ -5654,7 +5933,9 @@  discard block
 block discarded – undo
5654 5933
 			date_default_timezone_set($globalTimezone);
5655 5934
 			$datetime = new DateTime($date);
5656 5935
 			$offset = $datetime->format('P');
5657
-		} else $offset = '+00:00';
5936
+		} else {
5937
+			$offset = '+00:00';
5938
+		}
5658 5939
 
5659 5940
 		if ($globalDBdriver == 'mysql') {
5660 5941
 			$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 
@@ -5683,7 +5964,9 @@  discard block
 block discarded – undo
5683 5964
 			if($row['registration'] != "")
5684 5965
 			{
5685 5966
 				$image_array = $Image->getSpotterImage($row['registration']);
5686
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5967
+				if (isset($image_array[0]['image_thumbnail'])) {
5968
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5969
+				}
5687 5970
 			}
5688 5971
 			$temp_array['registration_count'] = $row['registration_count'];
5689 5972
  
@@ -5708,7 +5991,9 @@  discard block
 block discarded – undo
5708 5991
 			date_default_timezone_set($globalTimezone);
5709 5992
 			$datetime = new DateTime($date);
5710 5993
 			$offset = $datetime->format('P');
5711
-		} else $offset = '+00:00';
5994
+		} else {
5995
+			$offset = '+00:00';
5996
+		}
5712 5997
 
5713 5998
 		if ($globalDBdriver == 'mysql') {
5714 5999
 			$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
@@ -5904,8 +6189,11 @@  discard block
 block discarded – undo
5904 6189
 			if($row['registration'] != "")
5905 6190
 			{
5906 6191
 				$image_array = $Image->getSpotterImage($row['registration']);
5907
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5908
-				else $temp_array['image_thumbnail'] = '';
6192
+				if (isset($image_array[0]['image_thumbnail'])) {
6193
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6194
+				} else {
6195
+					$temp_array['image_thumbnail'] = '';
6196
+				}
5909 6197
 			}
5910 6198
 			$temp_array['registration_count'] = $row['registration_count'];
5911 6199
 			$aircraft_array[] = $temp_array;
@@ -5979,8 +6267,11 @@  discard block
 block discarded – undo
5979 6267
 			if($row['registration'] != "")
5980 6268
 			{
5981 6269
 				$image_array = $Image->getSpotterImage($row['registration']);
5982
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5983
-				else $temp_array['image_thumbnail'] = '';
6270
+				if (isset($image_array[0]['image_thumbnail'])) {
6271
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6272
+				} else {
6273
+					$temp_array['image_thumbnail'] = '';
6274
+				}
5984 6275
 			}
5985 6276
 			$temp_array['registration_count'] = $row['registration_count'];
5986 6277
 			$aircraft_array[] = $temp_array;
@@ -6054,8 +6345,11 @@  discard block
 block discarded – undo
6054 6345
 			if($row['registration'] != "")
6055 6346
 			{
6056 6347
 				$image_array = $Image->getSpotterImage($row['registration']);
6057
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6058
-				else $temp_array['image_thumbnail'] = '';
6348
+				if (isset($image_array[0]['image_thumbnail'])) {
6349
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6350
+				} else {
6351
+					$temp_array['image_thumbnail'] = '';
6352
+				}
6059 6353
 			}
6060 6354
 			$temp_array['registration_count'] = $row['registration_count'];
6061 6355
 			$aircraft_array[] = $temp_array;
@@ -6266,7 +6560,9 @@  discard block
 block discarded – undo
6266 6560
 			if($row['registration'] != "")
6267 6561
 			{
6268 6562
 				$image_array = $Image->getSpotterImage($row['registration']);
6269
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6563
+				if (isset($image_array[0]['image_thumbnail'])) {
6564
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6565
+				}
6270 6566
 			}
6271 6567
 			$temp_array['registration_count'] = $row['registration_count'];
6272 6568
           
@@ -6383,7 +6679,9 @@  discard block
 block discarded – undo
6383 6679
 			if($row['registration'] != "")
6384 6680
 			{
6385 6681
 				$image_array = $Image->getSpotterImage($row['registration']);
6386
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6682
+				if (isset($image_array[0]['image_thumbnail'])) {
6683
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6684
+				}
6387 6685
 			}
6388 6686
 			$temp_array['registration_count'] = $row['registration_count'];
6389 6687
           
@@ -6549,7 +6847,9 @@  discard block
 block discarded – undo
6549 6847
 			}
6550 6848
 		}
6551 6849
 		$query .= " GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name ORDER BY aircraft_registration_count DESC";
6552
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
6850
+		if ($limit) {
6851
+			$query .= " LIMIT 10 OFFSET 0";
6852
+		}
6553 6853
 		
6554 6854
 		$sth = $this->db->prepare($query);
6555 6855
 		$sth->execute($query_values);
@@ -6568,7 +6868,9 @@  discard block
 block discarded – undo
6568 6868
 			if($row['registration'] != "")
6569 6869
 			{
6570 6870
 				$image_array = $Image->getSpotterImage($row['registration']);
6571
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6871
+				if (isset($image_array[0]['image_thumbnail'])) {
6872
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6873
+				}
6572 6874
 			}
6573 6875
           
6574 6876
 			$aircraft_array[] = $temp_array;
@@ -6609,7 +6911,9 @@  discard block
 block discarded – undo
6609 6911
 		// if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
6610 6912
 		//if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6611 6913
                 $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";
6612
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
6914
+		if ($limit) {
6915
+			$query .= " LIMIT 10 OFFSET 0";
6916
+		}
6613 6917
 		
6614 6918
 		$sth = $this->db->prepare($query);
6615 6919
 		$sth->execute();
@@ -6629,7 +6933,9 @@  discard block
 block discarded – undo
6629 6933
 			if($row['registration'] != "")
6630 6934
 			{
6631 6935
 				$image_array = $Image->getSpotterImage($row['registration']);
6632
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6936
+				if (isset($image_array[0]['image_thumbnail'])) {
6937
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6938
+				}
6633 6939
 			}
6634 6940
           
6635 6941
 			$aircraft_array[] = $temp_array;
@@ -6695,7 +7001,9 @@  discard block
 block discarded – undo
6695 7001
 		}
6696 7002
                 $query .= " GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
6697 7003
 				ORDER BY airport_departure_icao_count DESC";
6698
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
7004
+		if ($limit) {
7005
+			$query .= " LIMIT 10 OFFSET 0";
7006
+		}
6699 7007
 
6700 7008
 		$sth = $this->db->prepare($query);
6701 7009
 		$sth->execute($query_values);
@@ -6746,7 +7054,9 @@  discard block
 block discarded – undo
6746 7054
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6747 7055
                 $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
6748 7056
 				ORDER BY airport_departure_icao_count DESC";
6749
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
7057
+		if ($limit) {
7058
+			$query .= " LIMIT 10 OFFSET 0";
7059
+		}
6750 7060
       
6751 7061
 		$sth = $this->db->prepare($query);
6752 7062
 		$sth->execute();
@@ -6824,7 +7134,9 @@  discard block
 block discarded – undo
6824 7134
 		}
6825 7135
                 $query .= " GROUP BY spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country
6826 7136
 				ORDER BY airport_departure_icao_count DESC";
6827
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
7137
+		if ($limit) {
7138
+			$query .= " LIMIT 10 OFFSET 0";
7139
+		}
6828 7140
     		//echo $query;
6829 7141
 		$sth = $this->db->prepare($query);
6830 7142
 		$sth->execute($query_values);
@@ -6876,7 +7188,9 @@  discard block
 block discarded – undo
6876 7188
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6877 7189
                 $query .= "GROUP BY spotter_output.airline_icao, spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country
6878 7190
 				ORDER BY airport_departure_icao_count DESC";
6879
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
7191
+		if ($limit) {
7192
+			$query .= " LIMIT 10 OFFSET 0";
7193
+		}
6880 7194
       
6881 7195
 		$sth = $this->db->prepare($query);
6882 7196
 		$sth->execute();
@@ -7271,7 +7585,9 @@  discard block
 block discarded – undo
7271 7585
 			date_default_timezone_set($globalTimezone);
7272 7586
 			$datetime = new DateTime($date);
7273 7587
 			$offset = $datetime->format('P');
7274
-		} else $offset = '+00:00';
7588
+		} else {
7589
+			$offset = '+00:00';
7590
+		}
7275 7591
 
7276 7592
 		if ($globalDBdriver == 'mysql') {
7277 7593
 			$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 
@@ -7321,7 +7637,9 @@  discard block
 block discarded – undo
7321 7637
 			date_default_timezone_set($globalTimezone);
7322 7638
 			$datetime = new DateTime($date);
7323 7639
 			$offset = $datetime->format('P');
7324
-		} else $offset = '+00:00';
7640
+		} else {
7641
+			$offset = '+00:00';
7642
+		}
7325 7643
 
7326 7644
 		if ($globalDBdriver == 'mysql') {
7327 7645
 			$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
@@ -7670,7 +7988,9 @@  discard block
 block discarded – undo
7670 7988
 		}
7671 7989
                 $query .= " GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
7672 7990
 					ORDER BY airport_arrival_icao_count DESC";
7673
-		if ($limit) $query .= " LIMIT 10";
7991
+		if ($limit) {
7992
+			$query .= " LIMIT 10";
7993
+		}
7674 7994
       
7675 7995
 		
7676 7996
 		$sth = $this->db->prepare($query);
@@ -7690,7 +8010,9 @@  discard block
 block discarded – undo
7690 8010
 			if ($icaoaskey) {
7691 8011
 				$icao = $row['arrival_airport_icao'];
7692 8012
 				$airport_array[$icao] = $temp_array;
7693
-			} else $airport_array[] = $temp_array;
8013
+			} else {
8014
+				$airport_array[] = $temp_array;
8015
+			}
7694 8016
 		}
7695 8017
 
7696 8018
 		return $airport_array;
@@ -7727,7 +8049,9 @@  discard block
 block discarded – undo
7727 8049
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
7728 8050
                 $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
7729 8051
 					ORDER BY airport_arrival_icao_count DESC";
7730
-		if ($limit) $query .= " LIMIT 10";
8052
+		if ($limit) {
8053
+			$query .= " LIMIT 10";
8054
+		}
7731 8055
       
7732 8056
 		
7733 8057
 		$sth = $this->db->prepare($query);
@@ -7748,7 +8072,9 @@  discard block
 block discarded – undo
7748 8072
 			if ($icaoaskey) {
7749 8073
 				$icao = $row['arrival_airport_icao'];
7750 8074
 				$airport_array[$icao] = $temp_array;
7751
-			} else $airport_array[] = $temp_array;
8075
+			} else {
8076
+				$airport_array[] = $temp_array;
8077
+			}
7752 8078
 		}
7753 8079
 
7754 8080
 		return $airport_array;
@@ -7811,7 +8137,9 @@  discard block
 block discarded – undo
7811 8137
 		}
7812 8138
                 $query .= " GROUP BY spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country
7813 8139
 					ORDER BY airport_arrival_icao_count DESC";
7814
-		if ($limit) $query .= " LIMIT 10";
8140
+		if ($limit) {
8141
+			$query .= " LIMIT 10";
8142
+		}
7815 8143
       
7816 8144
 		
7817 8145
 		$sth = $this->db->prepare($query);
@@ -7830,7 +8158,9 @@  discard block
 block discarded – undo
7830 8158
 			if ($icaoaskey) {
7831 8159
 				$icao = $row['arrival_airport_icao'];
7832 8160
 				$airport_array[$icao] = $temp_array;
7833
-			} else $airport_array[] = $temp_array;
8161
+			} else {
8162
+				$airport_array[] = $temp_array;
8163
+			}
7834 8164
 		}
7835 8165
 
7836 8166
 		return $airport_array;
@@ -7867,7 +8197,9 @@  discard block
 block discarded – undo
7867 8197
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
7868 8198
                 $query .= "GROUP BY spotter_output.airline_icao, spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country
7869 8199
 					ORDER BY airport_arrival_icao_count DESC";
7870
-		if ($limit) $query .= " LIMIT 10";
8200
+		if ($limit) {
8201
+			$query .= " LIMIT 10";
8202
+		}
7871 8203
       
7872 8204
 		
7873 8205
 		$sth = $this->db->prepare($query);
@@ -7888,7 +8220,9 @@  discard block
 block discarded – undo
7888 8220
 			if ($icaoaskey) {
7889 8221
 				$icao = $row['arrival_airport_icao'];
7890 8222
 				$airport_array[$icao] = $temp_array;
7891
-			} else $airport_array[] = $temp_array;
8223
+			} else {
8224
+				$airport_array[] = $temp_array;
8225
+			}
7892 8226
 		}
7893 8227
 
7894 8228
 		return $airport_array;
@@ -8269,7 +8603,9 @@  discard block
 block discarded – undo
8269 8603
 			date_default_timezone_set($globalTimezone);
8270 8604
 			$datetime = new DateTime($date);
8271 8605
 			$offset = $datetime->format('P');
8272
-		} else $offset = '+00:00';
8606
+		} else {
8607
+			$offset = '+00:00';
8608
+		}
8273 8609
 
8274 8610
 		if ($globalDBdriver == 'mysql') {
8275 8611
 			$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 
@@ -8319,7 +8655,9 @@  discard block
 block discarded – undo
8319 8655
 			date_default_timezone_set($globalTimezone);
8320 8656
 			$datetime = new DateTime($date);
8321 8657
 			$offset = $datetime->format('P');
8322
-		} else $offset = '+00:00';
8658
+		} else {
8659
+			$offset = '+00:00';
8660
+		}
8323 8661
 
8324 8662
 		if ($globalDBdriver == 'mysql') {
8325 8663
 			$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
@@ -8710,7 +9048,9 @@  discard block
 block discarded – undo
8710 9048
 		}
8711 9049
 		$query .= " GROUP BY spotter_output.arrival_airport_country
8712 9050
 					ORDER BY airport_arrival_country_count DESC";
8713
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
9051
+		if ($limit) {
9052
+			$query .= " LIMIT 10 OFFSET 0";
9053
+		}
8714 9054
       
8715 9055
 		
8716 9056
 		$sth = $this->db->prepare($query);
@@ -8997,7 +9337,9 @@  discard block
 block discarded – undo
8997 9337
 			date_default_timezone_set($globalTimezone);
8998 9338
 			$datetime = new DateTime($date);
8999 9339
 			$offset = $datetime->format('P');
9000
-		} else $offset = '+00:00';
9340
+		} else {
9341
+			$offset = '+00:00';
9342
+		}
9001 9343
 		
9002 9344
 		if ($globalDBdriver == 'mysql') {
9003 9345
 			$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
@@ -9253,12 +9595,18 @@  discard block
 block discarded – undo
9253 9595
 		$query  = "SELECT DISTINCT spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name, spotter_output.airline_icao  
9254 9596
                     FROM spotter_output".$filter_query." spotter_output.ident <> ''";
9255 9597
 		 if ($olderthanmonths > 0) {
9256
-			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
9257
-			else $query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
9598
+			if ($globalDBdriver == 'mysql') {
9599
+				$query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
9600
+			} else {
9601
+				$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
9602
+			}
9258 9603
 		}
9259 9604
 		if ($sincedate != '') {
9260
-			if ($globalDBdriver == 'mysql') $query .= " AND spotter_output.date > '".$sincedate."'";
9261
-			else $query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
9605
+			if ($globalDBdriver == 'mysql') {
9606
+				$query .= " AND spotter_output.date > '".$sincedate."'";
9607
+			} else {
9608
+				$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
9609
+			}
9262 9610
 		}
9263 9611
 		$query_values = array();
9264 9612
 		if ($year != '') {
@@ -9289,7 +9637,9 @@  discard block
 block discarded – undo
9289 9637
 			}
9290 9638
 		}
9291 9639
 		$query .= " GROUP BY spotter_output.ident, spotter_output.airline_name, spotter_output.airline_icao ORDER BY callsign_icao_count DESC";
9292
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
9640
+		if ($limit) {
9641
+			$query .= " LIMIT 10 OFFSET 0";
9642
+		}
9293 9643
       		
9294 9644
 		$sth = $this->db->prepare($query);
9295 9645
 		$sth->execute($query_values);
@@ -9323,15 +9673,23 @@  discard block
 block discarded – undo
9323 9673
 		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name  
9324 9674
                     FROM spotter_output".$filter_query." spotter_output.ident <> ''  AND spotter_output.airline_icao <> '' ";
9325 9675
 		 if ($olderthanmonths > 0) {
9326
-			if ($globalDBdriver == 'mysql') $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
9327
-			else $query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
9676
+			if ($globalDBdriver == 'mysql') {
9677
+				$query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
9678
+			} else {
9679
+				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
9680
+			}
9328 9681
 		}
9329 9682
 		if ($sincedate != '') {
9330
-			if ($globalDBdriver == 'mysql') $query .= "AND spotter_output.date > '".$sincedate."' ";
9331
-			else $query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP) ";
9683
+			if ($globalDBdriver == 'mysql') {
9684
+				$query .= "AND spotter_output.date > '".$sincedate."' ";
9685
+			} else {
9686
+				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP) ";
9687
+			}
9332 9688
 		}
9333 9689
 		$query .= "GROUP BY spotter_output.airline_icao, spotter_output.ident, spotter_output.airline_name, spotter_output.airline_icao ORDER BY callsign_icao_count DESC";
9334
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
9690
+		if ($limit) {
9691
+			$query .= " LIMIT 10 OFFSET 0";
9692
+		}
9335 9693
       		
9336 9694
 		$sth = $this->db->prepare($query);
9337 9695
 		$sth->execute();
@@ -9368,7 +9726,9 @@  discard block
 block discarded – undo
9368 9726
 			date_default_timezone_set($globalTimezone);
9369 9727
 			$datetime = new DateTime();
9370 9728
 			$offset = $datetime->format('P');
9371
-		} else $offset = '+00:00';
9729
+		} else {
9730
+			$offset = '+00:00';
9731
+		}
9372 9732
 
9373 9733
 		if ($globalDBdriver == 'mysql') {
9374 9734
 			$query  = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -9417,7 +9777,9 @@  discard block
 block discarded – undo
9417 9777
 			date_default_timezone_set($globalTimezone);
9418 9778
 			$datetime = new DateTime();
9419 9779
 			$offset = $datetime->format('P');
9420
-		} else $offset = '+00:00';
9780
+		} else {
9781
+			$offset = '+00:00';
9782
+		}
9421 9783
 		$filter_query = $this->getFilter($filters,true,true);
9422 9784
 		if ($globalDBdriver == 'mysql') {
9423 9785
 			$query  = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -9466,7 +9828,9 @@  discard block
 block discarded – undo
9466 9828
 			date_default_timezone_set($globalTimezone);
9467 9829
 			$datetime = new DateTime();
9468 9830
 			$offset = $datetime->format('P');
9469
-		} else $offset = '+00:00';
9831
+		} else {
9832
+			$offset = '+00:00';
9833
+		}
9470 9834
 		$filter_query = $this->getFilter($filters,true,true);
9471 9835
 		if ($globalDBdriver == 'mysql') {
9472 9836
 			$query  = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -9512,7 +9876,9 @@  discard block
 block discarded – undo
9512 9876
 			date_default_timezone_set($globalTimezone);
9513 9877
 			$datetime = new DateTime();
9514 9878
 			$offset = $datetime->format('P');
9515
-		} else $offset = '+00:00';
9879
+		} else {
9880
+			$offset = '+00:00';
9881
+		}
9516 9882
 		$filter_query = $this->getFilter($filters,true,true);
9517 9883
 		if ($globalDBdriver == 'mysql') {
9518 9884
 			$query  = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -9560,7 +9926,9 @@  discard block
 block discarded – undo
9560 9926
 			date_default_timezone_set($globalTimezone);
9561 9927
 			$datetime = new DateTime();
9562 9928
 			$offset = $datetime->format('P');
9563
-		} else $offset = '+00:00';
9929
+		} else {
9930
+			$offset = '+00:00';
9931
+		}
9564 9932
 		
9565 9933
 		if ($globalDBdriver == 'mysql') {
9566 9934
 			$query  = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -9608,7 +9976,9 @@  discard block
 block discarded – undo
9608 9976
 			date_default_timezone_set($globalTimezone);
9609 9977
 			$datetime = new DateTime();
9610 9978
 			$offset = $datetime->format('P');
9611
-		} else $offset = '+00:00';
9979
+		} else {
9980
+			$offset = '+00:00';
9981
+		}
9612 9982
 
9613 9983
 		if ($globalDBdriver == 'mysql') {
9614 9984
 			$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
@@ -9655,7 +10025,9 @@  discard block
 block discarded – undo
9655 10025
 			date_default_timezone_set($globalTimezone);
9656 10026
 			$datetime = new DateTime();
9657 10027
 			$offset = $datetime->format('P');
9658
-		} else $offset = '+00:00';
10028
+		} else {
10029
+			$offset = '+00:00';
10030
+		}
9659 10031
 
9660 10032
 		if ($globalDBdriver == 'mysql') {
9661 10033
 			$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
@@ -9703,7 +10075,9 @@  discard block
 block discarded – undo
9703 10075
 			date_default_timezone_set($globalTimezone);
9704 10076
 			$datetime = new DateTime();
9705 10077
 			$offset = $datetime->format('P');
9706
-		} else $offset = '+00:00';
10078
+		} else {
10079
+			$offset = '+00:00';
10080
+		}
9707 10081
 		$filter_query = $this->getFilter($filters,true,true);
9708 10082
 		if ($globalDBdriver == 'mysql') {
9709 10083
 			$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
@@ -9748,7 +10122,9 @@  discard block
 block discarded – undo
9748 10122
 			date_default_timezone_set($globalTimezone);
9749 10123
 			$datetime = new DateTime();
9750 10124
 			$offset = $datetime->format('P');
9751
-		} else $offset = '+00:00';
10125
+		} else {
10126
+			$offset = '+00:00';
10127
+		}
9752 10128
 		$filter_query = $this->getFilter($filters,true,true);
9753 10129
 
9754 10130
 		if ($globalDBdriver == 'mysql') {
@@ -9795,7 +10171,9 @@  discard block
 block discarded – undo
9795 10171
 			date_default_timezone_set($globalTimezone);
9796 10172
 			$datetime = new DateTime();
9797 10173
 			$offset = $datetime->format('P');
9798
-		} else $offset = '+00:00';
10174
+		} else {
10175
+			$offset = '+00:00';
10176
+		}
9799 10177
 
9800 10178
 		if ($globalDBdriver == 'mysql') {
9801 10179
 			$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
@@ -9841,7 +10219,9 @@  discard block
 block discarded – undo
9841 10219
 			date_default_timezone_set($globalTimezone);
9842 10220
 			$datetime = new DateTime();
9843 10221
 			$offset = $datetime->format('P');
9844
-		} else $offset = '+00:00';
10222
+		} else {
10223
+			$offset = '+00:00';
10224
+		}
9845 10225
 		$filter_query = $this->getFilter($filters,true,true);
9846 10226
 
9847 10227
 		if ($globalDBdriver == 'mysql') {
@@ -9888,7 +10268,9 @@  discard block
 block discarded – undo
9888 10268
 			date_default_timezone_set($globalTimezone);
9889 10269
 			$datetime = new DateTime();
9890 10270
 			$offset = $datetime->format('P');
9891
-		} else $offset = '+00:00';
10271
+		} else {
10272
+			$offset = '+00:00';
10273
+		}
9892 10274
 
9893 10275
 		if ($globalDBdriver == 'mysql') {
9894 10276
 			$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
@@ -9935,7 +10317,9 @@  discard block
 block discarded – undo
9935 10317
 			date_default_timezone_set($globalTimezone);
9936 10318
 			$datetime = new DateTime();
9937 10319
 			$offset = $datetime->format('P');
9938
-		} else $offset = '+00:00';
10320
+		} else {
10321
+			$offset = '+00:00';
10322
+		}
9939 10323
 
9940 10324
 		if ($globalDBdriver == 'mysql') {
9941 10325
 			$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
@@ -9980,7 +10364,9 @@  discard block
 block discarded – undo
9980 10364
 			date_default_timezone_set($globalTimezone);
9981 10365
 			$datetime = new DateTime();
9982 10366
 			$offset = $datetime->format('P');
9983
-		} else $offset = '+00:00';
10367
+		} else {
10368
+			$offset = '+00:00';
10369
+		}
9984 10370
 		$filter_query = $this->getFilter($filters,true,true);
9985 10371
 
9986 10372
 		if ($globalDBdriver == 'mysql') {
@@ -10028,7 +10414,9 @@  discard block
 block discarded – undo
10028 10414
 			date_default_timezone_set($globalTimezone);
10029 10415
 			$datetime = new DateTime();
10030 10416
 			$offset = $datetime->format('P');
10031
-		} else $offset = '+00:00';
10417
+		} else {
10418
+			$offset = '+00:00';
10419
+		}
10032 10420
 
10033 10421
 		if ($globalDBdriver == 'mysql') {
10034 10422
 			$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
@@ -10074,7 +10462,9 @@  discard block
 block discarded – undo
10074 10462
 			date_default_timezone_set($globalTimezone);
10075 10463
 			$datetime = new DateTime();
10076 10464
 			$offset = $datetime->format('P');
10077
-		} else $offset = '+00:00';
10465
+		} else {
10466
+			$offset = '+00:00';
10467
+		}
10078 10468
 		$filter_query = $this->getFilter($filters,true,true);
10079 10469
 
10080 10470
 		if ($globalDBdriver == 'mysql') {
@@ -10122,7 +10512,9 @@  discard block
 block discarded – undo
10122 10512
 			date_default_timezone_set($globalTimezone);
10123 10513
 			$datetime = new DateTime();
10124 10514
 			$offset = $datetime->format('P');
10125
-		} else $offset = '+00:00';
10515
+		} else {
10516
+			$offset = '+00:00';
10517
+		}
10126 10518
 
10127 10519
 		if ($globalDBdriver == 'mysql') {
10128 10520
 			$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
@@ -10169,7 +10561,9 @@  discard block
 block discarded – undo
10169 10561
 			date_default_timezone_set($globalTimezone);
10170 10562
 			$datetime = new DateTime();
10171 10563
 			$offset = $datetime->format('P');
10172
-		} else $offset = '+00:00';
10564
+		} else {
10565
+			$offset = '+00:00';
10566
+		}
10173 10567
 		$filter_query = $this->getFilter($filters,true,true);
10174 10568
 		if ($globalDBdriver == 'mysql') {
10175 10569
 			$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
@@ -10218,7 +10612,9 @@  discard block
 block discarded – undo
10218 10612
 			date_default_timezone_set($globalTimezone);
10219 10613
 			$datetime = new DateTime();
10220 10614
 			$offset = $datetime->format('P');
10221
-		} else $offset = '+00:00';
10615
+		} else {
10616
+			$offset = '+00:00';
10617
+		}
10222 10618
 
10223 10619
 		$orderby_sql = '';
10224 10620
 		if ($orderby == "hour")
@@ -10284,7 +10680,9 @@  discard block
 block discarded – undo
10284 10680
 			date_default_timezone_set($globalTimezone);
10285 10681
 			$datetime = new DateTime();
10286 10682
 			$offset = $datetime->format('P');
10287
-		} else $offset = '+00:00';
10683
+		} else {
10684
+			$offset = '+00:00';
10685
+		}
10288 10686
 
10289 10687
 		$orderby_sql = '';
10290 10688
 		if ($orderby == "hour")
@@ -10351,7 +10749,9 @@  discard block
 block discarded – undo
10351 10749
 			date_default_timezone_set($globalTimezone);
10352 10750
 			$datetime = new DateTime();
10353 10751
 			$offset = $datetime->format('P');
10354
-		} else $offset = '+00:00';
10752
+		} else {
10753
+			$offset = '+00:00';
10754
+		}
10355 10755
 
10356 10756
 		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
10357 10757
 
@@ -10402,7 +10802,9 @@  discard block
 block discarded – undo
10402 10802
 			date_default_timezone_set($globalTimezone);
10403 10803
 			$datetime = new DateTime();
10404 10804
 			$offset = $datetime->format('P');
10405
-		} else $offset = '+00:00';
10805
+		} else {
10806
+			$offset = '+00:00';
10807
+		}
10406 10808
 
10407 10809
 		if ($globalDBdriver == 'mysql') {
10408 10810
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10449,7 +10851,9 @@  discard block
 block discarded – undo
10449 10851
 			date_default_timezone_set($globalTimezone);
10450 10852
 			$datetime = new DateTime();
10451 10853
 			$offset = $datetime->format('P');
10452
-		} else $offset = '+00:00';
10854
+		} else {
10855
+			$offset = '+00:00';
10856
+		}
10453 10857
 
10454 10858
 		if ($globalDBdriver == 'mysql') {
10455 10859
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10496,7 +10900,9 @@  discard block
 block discarded – undo
10496 10900
 			date_default_timezone_set($globalTimezone);
10497 10901
 			$datetime = new DateTime();
10498 10902
 			$offset = $datetime->format('P');
10499
-		} else $offset = '+00:00';
10903
+		} else {
10904
+			$offset = '+00:00';
10905
+		}
10500 10906
 
10501 10907
 		if ($globalDBdriver == 'mysql') {
10502 10908
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10544,7 +10950,9 @@  discard block
 block discarded – undo
10544 10950
 			date_default_timezone_set($globalTimezone);
10545 10951
 			$datetime = new DateTime();
10546 10952
 			$offset = $datetime->format('P');
10547
-		} else $offset = '+00:00';
10953
+		} else {
10954
+			$offset = '+00:00';
10955
+		}
10548 10956
 
10549 10957
 		if ($globalDBdriver == 'mysql') {
10550 10958
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10592,7 +11000,9 @@  discard block
 block discarded – undo
10592 11000
 			date_default_timezone_set($globalTimezone);
10593 11001
 			$datetime = new DateTime($date);
10594 11002
 			$offset = $datetime->format('P');
10595
-		} else $offset = '+00:00';
11003
+		} else {
11004
+			$offset = '+00:00';
11005
+		}
10596 11006
 
10597 11007
 		if ($globalDBdriver == 'mysql') {
10598 11008
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10640,7 +11050,9 @@  discard block
 block discarded – undo
10640 11050
 			date_default_timezone_set($globalTimezone);
10641 11051
 			$datetime = new DateTime();
10642 11052
 			$offset = $datetime->format('P');
10643
-		} else $offset = '+00:00';
11053
+		} else {
11054
+			$offset = '+00:00';
11055
+		}
10644 11056
 
10645 11057
 		if ($globalDBdriver == 'mysql') {
10646 11058
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10687,7 +11099,9 @@  discard block
 block discarded – undo
10687 11099
 			date_default_timezone_set($globalTimezone);
10688 11100
 			$datetime = new DateTime();
10689 11101
 			$offset = $datetime->format('P');
10690
-		} else $offset = '+00:00';
11102
+		} else {
11103
+			$offset = '+00:00';
11104
+		}
10691 11105
 
10692 11106
 		if ($globalDBdriver == 'mysql') {
10693 11107
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10734,7 +11148,9 @@  discard block
 block discarded – undo
10734 11148
 			date_default_timezone_set($globalTimezone);
10735 11149
 			$datetime = new DateTime();
10736 11150
 			$offset = $datetime->format('P');
10737
-		} else $offset = '+00:00';
11151
+		} else {
11152
+			$offset = '+00:00';
11153
+		}
10738 11154
 
10739 11155
 		if ($globalDBdriver == 'mysql') {
10740 11156
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10784,7 +11200,9 @@  discard block
 block discarded – undo
10784 11200
 			date_default_timezone_set($globalTimezone);
10785 11201
 			$datetime = new DateTime();
10786 11202
 			$offset = $datetime->format('P');
10787
-		} else $offset = '+00:00';
11203
+		} else {
11204
+			$offset = '+00:00';
11205
+		}
10788 11206
 
10789 11207
 		if ($globalDBdriver == 'mysql') {
10790 11208
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10831,7 +11249,9 @@  discard block
 block discarded – undo
10831 11249
 			date_default_timezone_set($globalTimezone);
10832 11250
 			$datetime = new DateTime();
10833 11251
 			$offset = $datetime->format('P');
10834
-		} else $offset = '+00:00';
11252
+		} else {
11253
+			$offset = '+00:00';
11254
+		}
10835 11255
 
10836 11256
 		if ($globalDBdriver == 'mysql') {
10837 11257
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -11042,8 +11462,11 @@  discard block
 block discarded – undo
11042 11462
 				$query_values = array_merge($query_values,array(':month' => $month));
11043 11463
 			}
11044 11464
 		}
11045
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
11046
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
11465
+		if (empty($query_values)) {
11466
+			$queryi .= $this->getFilter($filters);
11467
+		} else {
11468
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
11469
+		}
11047 11470
 		
11048 11471
 		$sth = $this->db->prepare($queryi);
11049 11472
 		$sth->execute($query_values);
@@ -11121,8 +11544,11 @@  discard block
 block discarded – undo
11121 11544
 				$query_values = array_merge($query_values,array(':month' => $month));
11122 11545
 			}
11123 11546
 		}
11124
-                if ($query == '') $queryi .= $this->getFilter($filters);
11125
-                else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
11547
+                if ($query == '') {
11548
+                	$queryi .= $this->getFilter($filters);
11549
+                } else {
11550
+                	$queryi .= $this->getFilter($filters,true,true).substr($query,4);
11551
+                }
11126 11552
 
11127 11553
 
11128 11554
 		$sth = $this->db->prepare($queryi);
@@ -11145,7 +11571,9 @@  discard block
 block discarded – undo
11145 11571
 			date_default_timezone_set($globalTimezone);
11146 11572
 			$datetime = new DateTime();
11147 11573
 			$offset = $datetime->format('P');
11148
-		} else $offset = '+00:00';
11574
+		} else {
11575
+			$offset = '+00:00';
11576
+		}
11149 11577
 
11150 11578
 		if ($globalDBdriver == 'mysql') {
11151 11579
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -11331,7 +11759,9 @@  discard block
 block discarded – undo
11331 11759
 	*/
11332 11760
 	public function parseDirection($direction = 0)
11333 11761
 	{
11334
-		if ($direction == '') $direction = 0;
11762
+		if ($direction == '') {
11763
+			$direction = 0;
11764
+		}
11335 11765
 		$direction_array = array();
11336 11766
 		$temp_array = array();
11337 11767
 
@@ -11432,7 +11862,9 @@  discard block
 block discarded – undo
11432 11862
 		if (isset($result->AirlineFlightInfoResult))
11433 11863
 		{
11434 11864
 			$registration = $result->AirlineFlightInfoResult->tailnumber;
11435
-		} else return '';
11865
+		} else {
11866
+			return '';
11867
+		}
11436 11868
 		
11437 11869
 		$registration = $this->convertAircraftRegistration($registration);
11438 11870
 		
@@ -11466,7 +11898,9 @@  discard block
 block discarded – undo
11466 11898
 		    return $row['registration'];
11467 11899
 		} elseif ($source_type == 'flarm') {
11468 11900
 			return $this->getAircraftRegistrationBymodeS($aircraft_modes);
11469
-		} else return '';
11901
+		} else {
11902
+			return '';
11903
+		}
11470 11904
 	
11471 11905
 	}
11472 11906
 
@@ -11493,11 +11927,16 @@  discard block
 block discarded – undo
11493 11927
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
11494 11928
 		$sth->closeCursor();
11495 11929
 		if (count($row) > 0) {
11496
-			if ($row['type_flight'] == null) return '';
11497
-			else return $row['type_flight'];
11930
+			if ($row['type_flight'] == null) {
11931
+				return '';
11932
+			} else {
11933
+				return $row['type_flight'];
11934
+			}
11498 11935
 		} elseif ($source_type == 'flarm') {
11499 11936
 			return $this->getAircraftTypeBymodeS($aircraft_modes);
11500
-		} else return '';
11937
+		} else {
11938
+			return '';
11939
+		}
11501 11940
 	
11502 11941
 	}
11503 11942
 
@@ -11515,7 +11954,9 @@  discard block
 block discarded – undo
11515 11954
 		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
11516 11955
 	
11517 11956
 		$Connection = new Connection($this->db);
11518
-		if (!$Connection->tableExists('countries')) return '';
11957
+		if (!$Connection->tableExists('countries')) {
11958
+			return '';
11959
+		}
11519 11960
 	
11520 11961
 		try {
11521 11962
 			/*
@@ -11535,9 +11976,13 @@  discard block
 block discarded – undo
11535 11976
 			$sth->closeCursor();
11536 11977
 			if (count($row) > 0) {
11537 11978
 				return $row;
11538
-			} else return '';
11979
+			} else {
11980
+				return '';
11981
+			}
11539 11982
 		} catch (PDOException $e) {
11540
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
11983
+			if (isset($globalDebug) && $globalDebug) {
11984
+				echo 'Error : '.$e->getMessage()."\n";
11985
+			}
11541 11986
 			return '';
11542 11987
 		}
11543 11988
 	
@@ -11555,7 +12000,9 @@  discard block
 block discarded – undo
11555 12000
 		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
11556 12001
 	
11557 12002
 		$Connection = new Connection($this->db);
11558
-		if (!$Connection->tableExists('countries')) return '';
12003
+		if (!$Connection->tableExists('countries')) {
12004
+			return '';
12005
+		}
11559 12006
 	
11560 12007
 		try {
11561 12008
 			$query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1";
@@ -11567,9 +12014,13 @@  discard block
 block discarded – undo
11567 12014
 			$sth->closeCursor();
11568 12015
 			if (count($row) > 0) {
11569 12016
 				return $row;
11570
-			} else return '';
12017
+			} else {
12018
+				return '';
12019
+			}
11571 12020
 		} catch (PDOException $e) {
11572
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
12021
+			if (isset($globalDebug) && $globalDebug) {
12022
+				echo 'Error : '.$e->getMessage()."\n";
12023
+			}
11573 12024
 			return '';
11574 12025
 		}
11575 12026
 	
@@ -11819,7 +12270,9 @@  discard block
 block discarded – undo
11819 12270
 	{
11820 12271
 		global $globalBitlyAccessToken;
11821 12272
 		
11822
-		if ($globalBitlyAccessToken == '') return $url;
12273
+		if ($globalBitlyAccessToken == '') {
12274
+			return $url;
12275
+		}
11823 12276
         
11824 12277
 		$google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url;
11825 12278
 		
@@ -11968,7 +12421,9 @@  discard block
 block discarded – undo
11968 12421
 		
11969 12422
 
11970 12423
 		// routes
11971
-		if ($globalDebug) print "Routes...\n";
12424
+		if ($globalDebug) {
12425
+			print "Routes...\n";
12426
+		}
11972 12427
 		if ($globalDBdriver == 'mysql') {
11973 12428
 			$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)";
11974 12429
 		} else {
@@ -11987,7 +12442,9 @@  discard block
 block discarded – undo
11987 12442
 			}
11988 12443
 		}
11989 12444
 		
11990
-		if ($globalDebug) print "Airlines...\n";
12445
+		if ($globalDebug) {
12446
+			print "Airlines...\n";
12447
+		}
11991 12448
 		//airlines
11992 12449
 		if ($globalDBdriver == 'mysql') {
11993 12450
 			$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)";
@@ -12001,10 +12458,15 @@  discard block
 block discarded – undo
12001 12458
 			if (is_numeric(substr($row['ident'], -1, 1)))
12002 12459
 			{
12003 12460
 				$fromsource = NULL;
12004
-				if (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
12005
-				elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') $fromsource = 'ivao';
12006
-				elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
12007
-				elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
12461
+				if (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') {
12462
+					$fromsource = 'vatsim';
12463
+				} elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') {
12464
+					$fromsource = 'ivao';
12465
+				} elseif (isset($globalVATSIM) && $globalVATSIM) {
12466
+					$fromsource = 'vatsim';
12467
+				} elseif (isset($globalIVAO) && $globalIVAO) {
12468
+					$fromsource = 'ivao';
12469
+				}
12008 12470
 				$airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 3),$fromsource);
12009 12471
 				if (isset($airline_array[0]['name'])) {
12010 12472
 					$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";
@@ -12014,13 +12476,17 @@  discard block
 block discarded – undo
12014 12476
 			}
12015 12477
 		}
12016 12478
 
12017
-		if ($globalDebug) print "Remove Duplicate in aircraft_modes...\n";
12479
+		if ($globalDebug) {
12480
+			print "Remove Duplicate in aircraft_modes...\n";
12481
+		}
12018 12482
 		//duplicate modes
12019 12483
 		$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";
12020 12484
 		$sth = $this->db->prepare($query);
12021 12485
 		$sth->execute();
12022 12486
 		
12023
-		if ($globalDebug) print "Aircraft...\n";
12487
+		if ($globalDebug) {
12488
+			print "Aircraft...\n";
12489
+		}
12024 12490
 		//aircraft
12025 12491
 		if ($globalDBdriver == 'mysql') {
12026 12492
 			$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)";
@@ -12063,26 +12529,38 @@  discard block
 block discarded – undo
12063 12529
 				 if (isset($closestAirports[0])) {
12064 12530
 					if ($row['arrival_airport_icao'] == $closestAirports[0]['icao']) {
12065 12531
 						$airport_icao = $closestAirports[0]['icao'];
12066
-						if ($globalDebug) echo "\o/ 1st ---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
12532
+						if ($globalDebug) {
12533
+							echo "\o/ 1st ---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
12534
+						}
12067 12535
 					} elseif (count($closestAirports > 1) && $row['arrival_airport_icao'] != '' && $row['arrival_airport_icao'] != 'NA') {
12068 12536
 						foreach ($closestAirports as $airport) {
12069 12537
 							if ($row['arrival_airport_icao'] == $airport['icao']) {
12070 12538
 								$airport_icao = $airport['icao'];
12071
-								if ($globalDebug) echo "\o/ try --++ Find arrival airport. airport_icao : ".$airport_icao."\n";
12539
+								if ($globalDebug) {
12540
+									echo "\o/ try --++ Find arrival airport. airport_icao : ".$airport_icao."\n";
12541
+								}
12072 12542
 								break;
12073 12543
 							}
12074 12544
 						}
12075 12545
 					} elseif ($row['last_altitude'] == 0 || ($row['last_altitude'] != '' && ($closestAirports[0]['altitude'] <= $row['last_altitude']*100+1000 && $row['last_altitude']*100 < $closestAirports[0]['altitude']+5000))) {
12076 12546
 						$airport_icao = $closestAirports[0]['icao'];
12077
-						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";
12547
+						if ($globalDebug) {
12548
+							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";
12549
+						}
12078 12550
 					} else {
12079
-						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";
12551
+						if ($globalDebug) {
12552
+							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";
12553
+						}
12080 12554
 					}
12081 12555
 				} else {
12082
-					if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist."\n";
12556
+					if ($globalDebug) {
12557
+						echo "----- No Airport near last coord. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist."\n";
12558
+					}
12083 12559
 				}
12084 12560
 				if ($row['real_arrival_airport_icao'] != $airport_icao) {
12085
-					if ($globalDebug) echo "Updating airport to ".$airport_icao."...\n";
12561
+					if ($globalDebug) {
12562
+						echo "Updating airport to ".$airport_icao."...\n";
12563
+					}
12086 12564
 					$update_query="UPDATE spotter_output SET real_arrival_airport_icao = :airport_icao WHERE spotter_id = :spotter_id";
12087 12565
 					$sthu = $this->db->prepare($update_query);
12088 12566
 					$sthu->execute(array(':airport_icao' => $airport_icao,':spotter_id' => $row['spotter_id']));
Please login to merge, or discard this patch.
require/class.Tracker.php 1 patch
Braces   +143 added lines, -51 removed lines patch added patch discarded remove patch
@@ -31,7 +31,9 @@  discard block
 block discarded – undo
31 31
 		if (isset($filter[0]['source'])) {
32 32
 			$filters = array_merge($filters,$filter);
33 33
 		}
34
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
34
+		if (is_array($globalFilter)) {
35
+			$filter = array_merge($filter,$globalFilter);
36
+		}
35 37
 		$filter_query_join = '';
36 38
 		$filter_query_where = '';
37 39
 		foreach($filters as $flt) {
@@ -70,8 +72,11 @@  discard block
 block discarded – undo
70 72
 				$filter_query_where .= " AND EXTRACT(DAY FROM tracker_output.date) = '".$filter['day']."'";
71 73
 			}
72 74
 		}
73
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
74
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
75
+		if ($filter_query_where == '' && $where) {
76
+			$filter_query_where = ' WHERE';
77
+		} elseif ($filter_query_where != '' && $and) {
78
+			$filter_query_where .= ' AND';
79
+		}
75 80
 		if ($filter_query_where != '') {
76 81
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
77 82
 		}
@@ -125,26 +130,43 @@  discard block
 block discarded – undo
125 130
 				$temp_array['spotter_id'] = $row['spotter_archive_id'];
126 131
 			} elseif (isset($row['spotter_archive_output_id'])) {
127 132
 				$temp_array['spotter_id'] = $row['spotter_archive_output_id'];
128
-			*/} 
129
-			elseif (isset($row['trackerid'])) {
133
+			*/} elseif (isset($row['trackerid'])) {
130 134
 				$temp_array['trackerid'] = $row['trackerid'];
131 135
 			} else {
132 136
 				$temp_array['trackerid'] = '';
133 137
 			}
134
-			if (isset($row['famtrackid'])) $temp_array['famtrackid'] = $row['famtrackid'];
135
-			if (isset($row['type'])) $temp_array['type'] = $row['type'];
136
-			if (isset($row['comment'])) $temp_array['comment'] = $row['comment'];
138
+			if (isset($row['famtrackid'])) {
139
+				$temp_array['famtrackid'] = $row['famtrackid'];
140
+			}
141
+			if (isset($row['type'])) {
142
+				$temp_array['type'] = $row['type'];
143
+			}
144
+			if (isset($row['comment'])) {
145
+				$temp_array['comment'] = $row['comment'];
146
+			}
137 147
 			$temp_array['ident'] = $row['ident'];
138
-			if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude'];
139
-			if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude'];
140
-			if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source'];
141
-			if (isset($row['altitude'])) $temp_array['altitude'] = $row['altitude'];
148
+			if (isset($row['latitude'])) {
149
+				$temp_array['latitude'] = $row['latitude'];
150
+			}
151
+			if (isset($row['longitude'])) {
152
+				$temp_array['longitude'] = $row['longitude'];
153
+			}
154
+			if (isset($row['format_source'])) {
155
+				$temp_array['format_source'] = $row['format_source'];
156
+			}
157
+			if (isset($row['altitude'])) {
158
+				$temp_array['altitude'] = $row['altitude'];
159
+			}
142 160
 			if (isset($row['heading'])) {
143 161
 				$temp_array['heading'] = $row['heading'];
144 162
 				$heading_direction = $this->parseDirection($row['heading']);
145
-				if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
163
+				if (isset($heading_direction[0]['direction_fullname'])) {
164
+					$temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
165
+				}
166
+			}
167
+			if (isset($row['ground_speed'])) {
168
+				$temp_array['ground_speed'] = $row['ground_speed'];
146 169
 			}
147
-			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];
148 170
 			
149 171
 			if (isset($row['date'])) {
150 172
 				$dateArray = $this->parseDateString($row['date']);
@@ -187,13 +209,21 @@  discard block
 block discarded – undo
187 209
 			}
188 210
 			
189 211
 			$fromsource = NULL;
190
-			if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name'];
191
-			if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country'];
192
-			if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance'];
212
+			if (isset($row['source_name']) && $row['source_name'] != '') {
213
+				$temp_array['source_name'] = $row['source_name'];
214
+			}
215
+			if (isset($row['over_country']) && $row['over_country'] != '') {
216
+				$temp_array['over_country'] = $row['over_country'];
217
+			}
218
+			if (isset($row['distance']) && $row['distance'] != '') {
219
+				$temp_array['distance'] = $row['distance'];
220
+			}
193 221
 			$temp_array['query_number_rows'] = $num_rows;
194 222
 			$spotter_array[] = $temp_array;
195 223
 		}
196
-		if ($num_rows == 0) return array();
224
+		if ($num_rows == 0) {
225
+			return array();
226
+		}
197 227
 		$spotter_array[0]['query_number_rows'] = $num_rows;
198 228
 		return $spotter_array;
199 229
 	}	
@@ -224,8 +254,12 @@  discard block
 block discarded – undo
224 254
 			{
225 255
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
226 256
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
227
-			} else $limit_query = "";
228
-		} else $limit_query = "";
257
+			} else {
258
+				$limit_query = "";
259
+			}
260
+		} else {
261
+			$limit_query = "";
262
+		}
229 263
 		
230 264
 		if ($sort != "")
231 265
 		{
@@ -253,7 +287,9 @@  discard block
 block discarded – undo
253 287
 		global $global_query;
254 288
 		
255 289
 		date_default_timezone_set('UTC');
256
-		if ($id == '') return array();
290
+		if ($id == '') {
291
+			return array();
292
+		}
257 293
 		$additional_query = "tracker_output.famtrackid = :id";
258 294
 		$query_values = array(':id' => $id);
259 295
 		$query  = $global_query." WHERE ".$additional_query." ";
@@ -396,8 +432,11 @@  discard block
 block discarded – undo
396 432
 		$query .= " ORDER BY tracker_output.source_name ASC";
397 433
 
398 434
 		$sth = $this->db->prepare($query);
399
-		if (!empty($query_values)) $sth->execute($query_values);
400
-		else $sth->execute();
435
+		if (!empty($query_values)) {
436
+			$sth->execute($query_values);
437
+		} else {
438
+			$sth->execute();
439
+		}
401 440
 
402 441
 		$source_array = array();
403 442
 		$temp_array = array();
@@ -452,7 +491,9 @@  discard block
 block discarded – undo
452 491
 			date_default_timezone_set($globalTimezone);
453 492
 			$datetime = new DateTime();
454 493
 			$offset = $datetime->format('P');
455
-		} else $offset = '+00:00';
494
+		} else {
495
+			$offset = '+00:00';
496
+		}
456 497
 
457 498
 		if ($globalDBdriver == 'mysql') {
458 499
 			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) as date
@@ -608,7 +649,9 @@  discard block
 block discarded – undo
608 649
 			{
609 650
 				return false;
610 651
 			}
611
-		} else $altitude = 0;
652
+		} else {
653
+			$altitude = 0;
654
+		}
612 655
 		
613 656
 		if ($heading != "")
614 657
 		{
@@ -647,8 +690,12 @@  discard block
 block discarded – undo
647 690
             		$latitude = 0;
648 691
             		$longitude = 0;
649 692
             	}
650
-                if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
651
-                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
693
+                if ($heading == '' || $Common->isInteger($heading) === false) {
694
+                	$heading = 0;
695
+                }
696
+                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) {
697
+                	$groundspeed = 0;
698
+                }
652 699
                 $query  = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) 
653 700
                 VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:speed,:date,:format_source, :source_name,:comment,:type)";
654 701
 
@@ -813,12 +860,18 @@  discard block
 block discarded – undo
813 860
 		$query  = "SELECT DISTINCT tracker_output.ident, COUNT(tracker_output.ident) AS callsign_icao_count 
814 861
                     FROM tracker_output".$filter_query." tracker_output.ident <> ''";
815 862
 		 if ($olderthanmonths > 0) {
816
-			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
817
-			else $query .= " AND tracker_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
863
+			if ($globalDBdriver == 'mysql') {
864
+				$query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
865
+			} else {
866
+				$query .= " AND tracker_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
867
+			}
818 868
 		}
819 869
 		if ($sincedate != '') {
820
-			if ($globalDBdriver == 'mysql') $query .= " AND tracker_output.date > '".$sincedate."'";
821
-			else $query .= " AND tracker_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
870
+			if ($globalDBdriver == 'mysql') {
871
+				$query .= " AND tracker_output.date > '".$sincedate."'";
872
+			} else {
873
+				$query .= " AND tracker_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
874
+			}
822 875
 		}
823 876
 		$query_values = array();
824 877
 		if ($year != '') {
@@ -849,7 +902,9 @@  discard block
 block discarded – undo
849 902
 			}
850 903
 		}
851 904
 		$query .= " GROUP BY tracker_output.ident ORDER BY callsign_icao_count DESC";
852
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
905
+		if ($limit) {
906
+			$query .= " LIMIT 10 OFFSET 0";
907
+		}
853 908
       		
854 909
 		$sth = $this->db->prepare($query);
855 910
 		$sth->execute($query_values);
@@ -884,7 +939,9 @@  discard block
 block discarded – undo
884 939
 			date_default_timezone_set($globalTimezone);
885 940
 			$datetime = new DateTime();
886 941
 			$offset = $datetime->format('P');
887
-		} else $offset = '+00:00';
942
+		} else {
943
+			$offset = '+00:00';
944
+		}
888 945
 
889 946
 		if ($globalDBdriver == 'mysql') {
890 947
 			$query  = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -934,7 +991,9 @@  discard block
 block discarded – undo
934 991
 			date_default_timezone_set($globalTimezone);
935 992
 			$datetime = new DateTime();
936 993
 			$offset = $datetime->format('P');
937
-		} else $offset = '+00:00';
994
+		} else {
995
+			$offset = '+00:00';
996
+		}
938 997
 		$filter_query = $this->getFilter($filters,true,true);
939 998
 		if ($globalDBdriver == 'mysql') {
940 999
 			$query  = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -980,7 +1039,9 @@  discard block
 block discarded – undo
980 1039
 			date_default_timezone_set($globalTimezone);
981 1040
 			$datetime = new DateTime();
982 1041
 			$offset = $datetime->format('P');
983
-		} else $offset = '+00:00';
1042
+		} else {
1043
+			$offset = '+00:00';
1044
+		}
984 1045
 		$filter_query = $this->getFilter($filters,true,true);
985 1046
 		if ($globalDBdriver == 'mysql') {
986 1047
 			$query  = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1028,7 +1089,9 @@  discard block
 block discarded – undo
1028 1089
 			date_default_timezone_set($globalTimezone);
1029 1090
 			$datetime = new DateTime();
1030 1091
 			$offset = $datetime->format('P');
1031
-		} else $offset = '+00:00';
1092
+		} else {
1093
+			$offset = '+00:00';
1094
+		}
1032 1095
 
1033 1096
 		if ($globalDBdriver == 'mysql') {
1034 1097
 			$query  = "SELECT YEAR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
@@ -1077,7 +1140,9 @@  discard block
 block discarded – undo
1077 1140
 			date_default_timezone_set($globalTimezone);
1078 1141
 			$datetime = new DateTime();
1079 1142
 			$offset = $datetime->format('P');
1080
-		} else $offset = '+00:00';
1143
+		} else {
1144
+			$offset = '+00:00';
1145
+		}
1081 1146
 		$filter_query = $this->getFilter($filters,true,true);
1082 1147
 		if ($globalDBdriver == 'mysql') {
1083 1148
 			$query  = "SELECT MONTH(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count
@@ -1126,7 +1191,9 @@  discard block
 block discarded – undo
1126 1191
 			date_default_timezone_set($globalTimezone);
1127 1192
 			$datetime = new DateTime();
1128 1193
 			$offset = $datetime->format('P');
1129
-		} else $offset = '+00:00';
1194
+		} else {
1195
+			$offset = '+00:00';
1196
+		}
1130 1197
 
1131 1198
 		$orderby_sql = '';
1132 1199
 		if ($orderby == "hour")
@@ -1195,7 +1262,9 @@  discard block
 block discarded – undo
1195 1262
 			date_default_timezone_set($globalTimezone);
1196 1263
 			$datetime = new DateTime($date);
1197 1264
 			$offset = $datetime->format('P');
1198
-		} else $offset = '+00:00';
1265
+		} else {
1266
+			$offset = '+00:00';
1267
+		}
1199 1268
 
1200 1269
 		if ($globalDBdriver == 'mysql') {
1201 1270
 			$query  = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1243,7 +1312,9 @@  discard block
 block discarded – undo
1243 1312
 			date_default_timezone_set($globalTimezone);
1244 1313
 			$datetime = new DateTime();
1245 1314
 			$offset = $datetime->format('P');
1246
-		} else $offset = '+00:00';
1315
+		} else {
1316
+			$offset = '+00:00';
1317
+		}
1247 1318
 
1248 1319
 		if ($globalDBdriver == 'mysql') {
1249 1320
 			$query  = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1307,8 +1378,11 @@  discard block
 block discarded – undo
1307 1378
 				$query_values = array_merge($query_values,array(':month' => $month));
1308 1379
 			}
1309 1380
 		}
1310
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1311
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1381
+		if (empty($query_values)) {
1382
+			$queryi .= $this->getFilter($filters);
1383
+		} else {
1384
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
1385
+		}
1312 1386
 		
1313 1387
 		$sth = $this->db->prepare($queryi);
1314 1388
 		$sth->execute($query_values);
@@ -1330,7 +1404,9 @@  discard block
 block discarded – undo
1330 1404
 			date_default_timezone_set($globalTimezone);
1331 1405
 			$datetime = new DateTime();
1332 1406
 			$offset = $datetime->format('P');
1333
-		} else $offset = '+00:00';
1407
+		} else {
1408
+			$offset = '+00:00';
1409
+		}
1334 1410
 
1335 1411
 		if ($globalDBdriver == 'mysql') {
1336 1412
 			$query  = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1434,7 +1510,9 @@  discard block
 block discarded – undo
1434 1510
 	*/
1435 1511
 	public function parseDirection($direction = 0)
1436 1512
 	{
1437
-		if ($direction == '') $direction = 0;
1513
+		if ($direction == '') {
1514
+			$direction = 0;
1515
+		}
1438 1516
 		$direction_array = array();
1439 1517
 		$temp_array = array();
1440 1518
 
@@ -1523,7 +1601,9 @@  discard block
 block discarded – undo
1523 1601
 		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1524 1602
 	
1525 1603
 		$Connection = new Connection($this->db);
1526
-		if (!$Connection->tableExists('countries')) return '';
1604
+		if (!$Connection->tableExists('countries')) {
1605
+			return '';
1606
+		}
1527 1607
 	
1528 1608
 		try {
1529 1609
 			/*
@@ -1543,9 +1623,13 @@  discard block
 block discarded – undo
1543 1623
 			$sth->closeCursor();
1544 1624
 			if (count($row) > 0) {
1545 1625
 				return $row;
1546
-			} else return '';
1626
+			} else {
1627
+				return '';
1628
+			}
1547 1629
 		} catch (PDOException $e) {
1548
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
1630
+			if (isset($globalDebug) && $globalDebug) {
1631
+				echo 'Error : '.$e->getMessage()."\n";
1632
+			}
1549 1633
 			return '';
1550 1634
 		}
1551 1635
 	
@@ -1563,7 +1647,9 @@  discard block
 block discarded – undo
1563 1647
 		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
1564 1648
 	
1565 1649
 		$Connection = new Connection($this->db);
1566
-		if (!$Connection->tableExists('countries')) return '';
1650
+		if (!$Connection->tableExists('countries')) {
1651
+			return '';
1652
+		}
1567 1653
 	
1568 1654
 		try {
1569 1655
 			$query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1";
@@ -1575,9 +1661,13 @@  discard block
 block discarded – undo
1575 1661
 			$sth->closeCursor();
1576 1662
 			if (count($row) > 0) {
1577 1663
 				return $row;
1578
-			} else return '';
1664
+			} else {
1665
+				return '';
1666
+			}
1579 1667
 		} catch (PDOException $e) {
1580
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
1668
+			if (isset($globalDebug) && $globalDebug) {
1669
+				echo 'Error : '.$e->getMessage()."\n";
1670
+			}
1581 1671
 			return '';
1582 1672
 		}
1583 1673
 	
@@ -1595,7 +1685,9 @@  discard block
 block discarded – undo
1595 1685
 	{
1596 1686
 		global $globalBitlyAccessToken;
1597 1687
 		
1598
-		if ($globalBitlyAccessToken == '') return $url;
1688
+		if ($globalBitlyAccessToken == '') {
1689
+			return $url;
1690
+		}
1599 1691
         
1600 1692
 		$google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url;
1601 1693
 		
Please login to merge, or discard this patch.
require/class.TrackerLive.php 1 patch
Braces   +59 added lines, -20 removed lines patch added patch discarded remove patch
@@ -29,7 +29,9 @@  discard block
 block discarded – undo
29 29
 		if (isset($filter[0]['source'])) {
30 30
 			$filters = array_merge($filters,$filter);
31 31
 		}
32
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
32
+		if (is_array($globalFilter)) {
33
+			$filter = array_merge($filter,$globalFilter);
34
+		}
33 35
 		$filter_query_join = '';
34 36
 		$filter_query_where = '';
35 37
 		foreach($filters as $flt) {
@@ -76,8 +78,11 @@  discard block
 block discarded – undo
76 78
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
77 79
 			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
78 80
 		}
79
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
80
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
81
+		if ($filter_query_where == '' && $where) {
82
+			$filter_query_where = ' WHERE';
83
+		} elseif ($filter_query_where != '' && $and) {
84
+			$filter_query_where .= ' AND';
85
+		}
81 86
 		if ($filter_query_where != '') {
82 87
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
83 88
 		}
@@ -119,7 +124,9 @@  discard block
 block discarded – undo
119 124
 			}
120 125
 		}
121 126
 
122
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
127
+		if (!isset($globalLiveInterval)) {
128
+			$globalLiveInterval = '200';
129
+		}
123 130
 		if ($globalDBdriver == 'mysql') {
124 131
 			//$query  = "SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate";
125 132
 			$query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate'.$filter_query.$orderby_query;
@@ -144,7 +151,9 @@  discard block
 block discarded – undo
144 151
 
145 152
 		$filter_query = $this->getFilter($filter,true,true);
146 153
 
147
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
154
+		if (!isset($globalLiveInterval)) {
155
+			$globalLiveInterval = '200';
156
+		}
148 157
 		if ($globalDBdriver == 'mysql') {
149 158
 			$query  = 'SELECT tracker_live.ident, tracker_live.type,tracker_live.famtrackid, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
150 159
 			FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate'.$filter_query." tracker_live.latitude <> 0 AND tracker_live.longitude <> 0";
@@ -182,7 +191,9 @@  discard block
 block discarded – undo
182 191
 
183 192
 		$filter_query = $this->getFilter($filter,true,true);
184 193
 
185
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
194
+		if (!isset($globalLiveInterval)) {
195
+			$globalLiveInterval = '200';
196
+		}
186 197
 		if ($globalDBdriver == 'mysql') {
187 198
 			$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
188 199
 			FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' 
@@ -215,7 +226,9 @@  discard block
 block discarded – undo
215 226
 		global $globalDBdriver, $globalLiveInterval;
216 227
 		$filter_query = $this->getFilter($filter,true,true);
217 228
 
218
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
229
+		if (!isset($globalLiveInterval)) {
230
+			$globalLiveInterval = '200';
231
+		}
219 232
 		if ($globalDBdriver == 'mysql') {
220 233
 			$query = 'SELECT COUNT(DISTINCT tracker_live.famtrackid) as nb FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
221 234
 		} else {
@@ -243,7 +256,9 @@  discard block
 block discarded – undo
243 256
 	{
244 257
 		global $globalDBdriver, $globalLiveInterval;
245 258
 		$Spotter = new Spotter($this->db);
246
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
259
+		if (!isset($globalLiveInterval)) {
260
+			$globalLiveInterval = '200';
261
+		}
247 262
 		$filter_query = $this->getFilter($filter);
248 263
 
249 264
 		if (is_array($coord)) {
@@ -251,7 +266,9 @@  discard block
 block discarded – undo
251 266
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
252 267
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
253 268
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
254
-		} else return array();
269
+		} else {
270
+			return array();
271
+		}
255 272
 		if ($globalDBdriver == 'mysql') {
256 273
 			$query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND tracker_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY tracker_live.famtrackid'.$filter_query;
257 274
 		} else {
@@ -441,11 +458,15 @@  discard block
 block discarded – undo
441 458
 		//$query  = self::$global_query.' WHERE tracker_live.famtrackid = :id ORDER BY date';
442 459
 		if ($globalDBdriver == 'mysql') {
443 460
 			$query = 'SELECT tracker_live.* FROM tracker_live WHERE tracker_live.famtrackid = :id';
444
-			if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
461
+			if ($liveinterval) {
462
+				$query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
463
+			}
445 464
 			$query .= ' ORDER BY date';
446 465
 		} else {
447 466
 			$query = 'SELECT tracker_live.* FROM tracker_live WHERE tracker_live.famtrackid = :id';
448
-			if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
467
+			if ($liveinterval) {
468
+				$query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
469
+			}
449 470
 			$query .= ' ORDER BY date';
450 471
 		}
451 472
 
@@ -540,7 +561,9 @@  discard block
 block discarded – undo
540 561
 				$i++;
541 562
 				$j++;
542 563
 				if ($j == 30) {
543
-					if ($globalDebug) echo ".";
564
+					if ($globalDebug) {
565
+						echo ".";
566
+					}
544 567
 				    	try {
545 568
 						
546 569
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
@@ -787,7 +810,9 @@  discard block
 block discarded – undo
787 810
 			{
788 811
 				return false;
789 812
 			}
790
-		} else return '';
813
+		} else {
814
+			return '';
815
+		}
791 816
 
792 817
 		if ($longitude != '')
793 818
 		{
@@ -795,7 +820,9 @@  discard block
 block discarded – undo
795 820
 			{
796 821
 				return false;
797 822
 			}
798
-		} else return '';
823
+		} else {
824
+			return '';
825
+		}
799 826
 
800 827
 		if ($altitude != '')
801 828
 		{
@@ -803,7 +830,9 @@  discard block
 block discarded – undo
803 830
 			{
804 831
 				return false;
805 832
 			}
806
-		} else $altitude = 0;
833
+		} else {
834
+			$altitude = 0;
835
+		}
807 836
 
808 837
 		if ($heading != '')
809 838
 		{
@@ -811,7 +840,9 @@  discard block
 block discarded – undo
811 840
 			{
812 841
 				return false;
813 842
 			}
814
-		} else $heading = 0;
843
+		} else {
844
+			$heading = 0;
845
+		}
815 846
 
816 847
 		if ($groundspeed != '')
817 848
 		{
@@ -819,9 +850,13 @@  discard block
 block discarded – undo
819 850
 			{
820 851
 				return false;
821 852
 			}
822
-		} else $groundspeed = 0;
853
+		} else {
854
+			$groundspeed = 0;
855
+		}
823 856
 		date_default_timezone_set('UTC');
824
-		if ($date == '') $date = date("Y-m-d H:i:s", time());
857
+		if ($date == '') {
858
+			$date = date("Y-m-d H:i:s", time());
859
+		}
825 860
 
826 861
         
827 862
 		$famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING);
@@ -837,8 +872,12 @@  discard block
 block discarded – undo
837 872
 		$comment = filter_var($comment,FILTER_SANITIZE_STRING);
838 873
 		$type = filter_var($type,FILTER_SANITIZE_STRING);
839 874
 
840
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
841
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
875
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) {
876
+            		$groundspeed = 0;
877
+            	}
878
+            	if ($heading == '' || $Common->isInteger($heading) === false ) {
879
+            		$heading = 0;
880
+            	}
842 881
             	
843 882
 		$query  = 'INSERT INTO tracker_live (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) 
844 883
 		VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)';
Please login to merge, or discard this patch.
require/class.TrackerImport.php 1 patch
Braces   +149 added lines, -51 removed lines patch added patch discarded remove patch
@@ -44,7 +44,9 @@  discard block
 block discarded – undo
44 44
 
45 45
     public function checkAll() {
46 46
 	global $globalDebug;
47
-	if ($globalDebug) echo "Update last seen tracked data...\n";
47
+	if ($globalDebug) {
48
+		echo "Update last seen tracked data...\n";
49
+	}
48 50
 	foreach ($this->all_tracked as $key => $flight) {
49 51
 	    if (isset($this->all_tracked[$key]['id'])) {
50 52
 		//echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
@@ -57,12 +59,16 @@  discard block
 block discarded – undo
57 59
     public function del() {
58 60
 	global $globalDebug;
59 61
 	// Delete old infos
60
-	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
62
+	if ($globalDebug) {
63
+		echo 'Delete old values and update latest data...'."\n";
64
+	}
61 65
 	foreach ($this->all_tracked as $key => $flight) {
62 66
     	    if (isset($flight['lastupdate'])) {
63 67
         	if ($flight['lastupdate'] < (time()-3000)) {
64 68
             	    if (isset($this->all_tracked[$key]['id'])) {
65
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
69
+            		if ($globalDebug) {
70
+            			echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
71
+            		}
66 72
 			/*
67 73
 			$TrackerLive = new TrackerLive();
68 74
             		$TrackerLive->deleteLiveTrackerDataById($this->all_tracked[$key]['id']);
@@ -72,7 +78,9 @@  discard block
 block discarded – undo
72 78
             		$Tracker = new Tracker($this->db);
73 79
             		if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
74 80
 				$result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed']);
75
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
81
+				if ($globalDebug && $result != 'success') {
82
+					echo '!!! ERROR : '.$result."\n";
83
+				}
76 84
 			}
77 85
 			// Put in archive
78 86
 //			$Tracker->db = null;
@@ -85,7 +93,9 @@  discard block
 block discarded – undo
85 93
 
86 94
     public function add($line) {
87 95
 	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked;
88
-	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
96
+	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') {
97
+		$globalCoordMinChange = '0.02';
98
+	}
89 99
 	date_default_timezone_set('UTC');
90 100
 	$dataFound = false;
91 101
 	$send = false;
@@ -109,8 +119,11 @@  discard block
 block discarded – undo
109 119
 		*/
110 120
 		
111 121
 		$Common = new Common();
112
-	        if (!isset($line['id'])) $id = trim($line['ident']);
113
-	        else $id = trim($line['id']);
122
+	        if (!isset($line['id'])) {
123
+	        	$id = trim($line['ident']);
124
+	        } else {
125
+	        	$id = trim($line['id']);
126
+	        }
114 127
 		
115 128
 		if (!isset($this->all_tracked[$id])) {
116 129
 		    $this->all_tracked[$id] = array();
@@ -118,18 +131,27 @@  discard block
 block discarded – undo
118 131
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => ''));
119 132
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
120 133
 		    if (!isset($line['id'])) {
121
-			if (!isset($globalDaemon)) $globalDaemon = TRUE;
134
+			if (!isset($globalDaemon)) {
135
+				$globalDaemon = TRUE;
136
+			}
122 137
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
123
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
124
-		    if ($globalAllTracked !== FALSE) $dataFound = true;
138
+		     } else {
139
+		     	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
140
+		     }
141
+		    if ($globalAllTracked !== FALSE) {
142
+		    	$dataFound = true;
143
+		    }
125 144
 		}
126 145
 		
127 146
 		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60) {
128 147
 		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) {
129 148
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
130 149
 		    } else {
131
-				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n";
132
-				elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n";
150
+				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) {
151
+					echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n";
152
+				} elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) {
153
+					echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n";
154
+				}
133 155
 				return '';
134 156
 		    }
135 157
 		} else {
@@ -145,11 +167,17 @@  discard block
 block discarded – undo
145 167
             		$Tracker = new Tracker($this->db);
146 168
             		$fromsource = NULL;
147 169
             		$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
148
-			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
170
+			if ($globalDebug && $result != 'success') {
171
+				echo '!!! ERROR : '.$result."\n";
172
+			}
149 173
 			$Tracker->db = null;
150
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
174
+			if ($globalDebugTimeElapsed) {
175
+				echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
176
+			}
177
+		    }
178
+		    if (!isset($this->all_tracked[$id]['id'])) {
179
+		    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
151 180
 		    }
152
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
153 181
 		}
154 182
 
155 183
 		if (isset($line['speed']) && $line['speed'] != '') {
@@ -160,14 +188,21 @@  discard block
 block discarded – undo
160 188
 		    if ($distance > 1000 && $distance < 10000) {
161 189
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
162 190
 			$speed = $speed*3.6;
163
-			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
164
-  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
191
+			if ($speed < 1000) {
192
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
193
+			}
194
+  			if ($globalDebug) {
195
+  				echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
196
+  			}
165 197
 		    }
166 198
 		}
167 199
 
168 200
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
169
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
170
-	    	    else unset($timediff);
201
+	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) {
202
+	    	    	$timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
203
+	    	    } else {
204
+	    	    	unset($timediff);
205
+	    	    }
171 206
 	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
172 207
 			if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) {
173 208
 			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
@@ -175,20 +210,30 @@  discard block
 block discarded – undo
175 210
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
176 211
 				$this->all_tracked[$id]['putinarchive'] = true;
177 212
 				
178
-				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
213
+				if ($globalDebug) {
214
+					echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
215
+				}
179 216
 				$timeelapsed = microtime(true);
180 217
 				$Tracker = new Tracker($this->db);
181 218
 				$all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
182
-				if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
219
+				if (!empty($all_country)) {
220
+					$this->all_tracked[$id]['over_country'] = $all_country['iso2'];
221
+				}
183 222
 				$Tracker->db = null;
184
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
223
+				if ($globalDebugTimeElapsed) {
224
+					echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
225
+				}
185 226
 				$this->tmd = 0;
186
-				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
227
+				if ($globalDebug) {
228
+					echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
229
+				}
187 230
 			    }
188 231
 			}
189 232
 
190 233
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
191
-				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
234
+				if (!isset($this->all_tracked[$id]['archive_latitude'])) {
235
+					$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
236
+				}
192 237
 				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
193 238
 				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
194 239
 				    $dataFound = true;
@@ -197,8 +242,12 @@  discard block
 block discarded – undo
197 242
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
198 243
 			}
199 244
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
200
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
201
-				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
245
+			    if ($line['longitude'] > 180) {
246
+			    	$line['longitude'] = $line['longitude'] - 360;
247
+			    }
248
+				if (!isset($this->all_tracked[$id]['archive_longitude'])) {
249
+					$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
250
+				}
202 251
 				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
203 252
 				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
204 253
 				    $dataFound = true;
@@ -216,7 +265,9 @@  discard block
 block discarded – undo
216 265
 		    }
217 266
 		}
218 267
 		if (isset($line['last_update']) && $line['last_update'] != '') {
219
-		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
268
+		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) {
269
+		    	$dataFound = true;
270
+		    }
220 271
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
221 272
 		}
222 273
 		if (isset($line['format_source']) && $line['format_source'] != '') {
@@ -236,7 +287,9 @@  discard block
 block discarded – undo
236 287
 
237 288
 		if (isset($line['altitude']) && $line['altitude'] != '') {
238 289
 		    //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
239
-			if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true;
290
+			if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) {
291
+				$this->all_tracked[$id]['putinarchive'] = true;
292
+			}
240 293
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => round($line['altitude']/100)));
241 294
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude']));
242 295
 			//$dataFound = true;
@@ -248,15 +301,21 @@  discard block
 block discarded – undo
248 301
 		}
249 302
 		
250 303
 		if (isset($line['heading']) && $line['heading'] != '') {
251
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
304
+		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) {
305
+		    	$this->all_tracked[$id]['putinarchive'] = true;
306
+		    }
252 307
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
253 308
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
254 309
 		    //$dataFound = true;
255 310
   		} elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) {
256 311
   		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
257 312
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
258
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
259
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
313
+		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) {
314
+		    	$this->all_tracked[$id]['putinarchive'] = true;
315
+		    }
316
+  		    if ($globalDebug) {
317
+  		    	echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
318
+  		    }
260 319
   		}
261 320
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
262 321
 
@@ -265,20 +324,31 @@  discard block
 block discarded – undo
265 324
 		    if ($this->all_tracked[$id]['addedTracker'] == 0) {
266 325
 		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
267 326
 			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
268
-				if ($globalDebug) echo "Check if aircraft is already in DB...";
327
+				if ($globalDebug) {
328
+					echo "Check if aircraft is already in DB...";
329
+				}
269 330
 				$timeelapsed = microtime(true);
270 331
 				$TrackerLive = new TrackerLive($this->db);
271 332
 				if (isset($line['id'])) {
272 333
 				    $recent_ident = $TrackerLive->checkIdRecent($line['id']);
273
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
334
+				    if ($globalDebugTimeElapsed) {
335
+				    	echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
336
+				    }
274 337
 				} elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
275 338
 				    $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']);
276
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
277
-				} else $recent_ident = '';
339
+				    if ($globalDebugTimeElapsed) {
340
+				    	echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
341
+				    }
342
+				} else {
343
+					$recent_ident = '';
344
+				}
278 345
 				$TrackerLive->db=null;
279 346
 
280
-				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
281
-				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
347
+				if ($globalDebug && $recent_ident == '') {
348
+					echo " Not in DB.\n";
349
+				} elseif ($globalDebug && $recent_ident != '') {
350
+					echo " Already in DB.\n";
351
+				}
282 352
 			    } else {
283 353
 				$recent_ident = '';
284 354
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
@@ -286,16 +356,24 @@  discard block
 block discarded – undo
286 356
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
287 357
 			    if($recent_ident == "")
288 358
 			    {
289
-				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
359
+				if ($globalDebug) {
360
+					echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
361
+				}
290 362
 				//adds the spotter data for the archive
291 363
 				    $highlight = '';
292
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
364
+				    if (!isset($this->all_tracked[$id]['id'])) {
365
+				    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
366
+				    }
293 367
 				    $timeelapsed = microtime(true);
294 368
 				    $Tracker = new Tracker($this->db);
295 369
 				    $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
296 370
 				    $Tracker->db = null;
297
-				    if ($globalDebug && isset($result)) echo $result."\n";
298
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
371
+				    if ($globalDebug && isset($result)) {
372
+				    	echo $result."\n";
373
+				    }
374
+				    if ($globalDebugTimeElapsed) {
375
+				    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
376
+				    }
299 377
 				    
300 378
 				    /*
301 379
 				    // Add source stat in DB
@@ -329,12 +407,16 @@  discard block
 block discarded – undo
329 407
 				$this->all_tracked[$id]['addedTracker'] = 1;
330 408
 				//print_r($this->all_tracked[$id]);
331 409
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
332
-				    if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours...";
410
+				    if ($globalDebug) {
411
+				    	echo "---- Deleting Live Tracker data older than 9 hours...";
412
+				    }
333 413
 				    //TrackerLive->deleteLiveTrackerDataNotUpdated();
334 414
 				    $TrackerLive = new TrackerLive($this->db);
335 415
 				    $TrackerLive->deleteLiveTrackerData();
336 416
 				    $TrackerLive->db=null;
337
-				    if ($globalDebug) echo " Done\n";
417
+				    if ($globalDebug) {
418
+				    	echo " Done\n";
419
+				    }
338 420
 				    $this->last_delete = time();
339 421
 				}
340 422
 			    } else {
@@ -357,13 +439,17 @@  discard block
 block discarded – undo
357 439
 
358 440
 		    if (!$ignoreImport) {
359 441
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
360
-				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
442
+				if ($globalDebug) {
443
+					echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
444
+				}
361 445
 				$timeelapsed = microtime(true);
362 446
 				$TrackerLive = new TrackerLive($this->db);
363 447
 				$result = $TrackerLive->addLiveTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
364 448
 				$TrackerLive->db = null;
365 449
 				$this->all_tracked[$id]['putinarchive'] = false;
366
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
450
+				if ($globalDebugTimeElapsed) {
451
+					echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
452
+				}
367 453
 
368 454
 				// Put statistics in $this->stats variable
369 455
 				/*
@@ -420,19 +506,29 @@  discard block
 block discarded – undo
420 506
 				*/
421 507
 
422 508
 				$this->all_tracked[$id]['lastupdate'] = time();
423
-				if ($this->all_tracked[$id]['putinarchive']) $send = true;
424
-				if ($globalDebug) echo $result."\n";
425
-			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
509
+				if ($this->all_tracked[$id]['putinarchive']) {
510
+					$send = true;
511
+				}
512
+				if ($globalDebug) {
513
+					echo $result."\n";
514
+				}
515
+			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
516
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
517
+			}
426 518
 			//$this->del();
427 519
 			
428 520
 			
429 521
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
430
-			    if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour...";
522
+			    if ($globalDebug) {
523
+			    	echo "---- Deleting Live Tracker data Not updated since 2 hour...";
524
+			    }
431 525
 			    $TrackerLive = new TrackerLive($this->db);
432 526
 			    $TrackerLive->deleteLiveTrackerDataNotUpdated();
433 527
 			    $TrackerLive->db = null;
434 528
 			    //TrackerLive->deleteLiveTrackerData();
435
-			    if ($globalDebug) echo " Done\n";
529
+			    if ($globalDebug) {
530
+			    	echo " Done\n";
531
+			    }
436 532
 			    $this->last_delete_hourly = time();
437 533
 			}
438 534
 			
@@ -440,7 +536,9 @@  discard block
 block discarded – undo
440 536
 		    //$ignoreImport = false;
441 537
 		}
442 538
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
443
-		if ($send) return $this->all_tracked[$id];
539
+		if ($send) {
540
+			return $this->all_tracked[$id];
541
+		}
444 542
 	    }
445 543
 	}
446 544
     }
Please login to merge, or discard this patch.
tracker-data.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -63,7 +63,9 @@
 block discarded – undo
63 63
 {
64 64
 	if ($spotter_item['image_source'] == 'flickr' || $spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart') {
65 65
 		$image = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
66
-	} else $image = $spotter_item['image_thumbnail'];
66
+	} else {
67
+		$image = $spotter_item['image_thumbnail'];
68
+	}
67 69
 
68 70
 }
69 71
 /* else {
Please login to merge, or discard this patch.
install/class.update_db.php 1 patch
Braces   +903 added lines, -312 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
 			}
@@ -417,7 +480,9 @@  discard block
 block discarded – undo
417 480
 			$sth_dest = $Connection->db->prepare($query_dest);
418 481
 			$sth_modes = $Connection->db->prepare($query_modes);
419 482
 			try {
420
-				if ($globalTransaction) $Connection->db->beginTransaction();
483
+				if ($globalTransaction) {
484
+					$Connection->db->beginTransaction();
485
+				}
421 486
 				$tmp = fgetcsv($fh,9999,',','"');
422 487
             			while (!feof($fh)) {
423 488
             				$line = fgetcsv($fh,9999,',','"');
@@ -427,16 +492,22 @@  discard block
 block discarded – undo
427 492
             				    $values['registration'] = $line[0];
428 493
             				    $values['base'] = $line[4];
429 494
             				    $values['owner'] = $line[5];
430
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
431
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
495
+            				    if ($line[6] == '') {
496
+            				    	$values['date_first_reg'] = null;
497
+            				    } else {
498
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
499
+					    }
432 500
 					    $values['cancel'] = $line[7];
433 501
 					} elseif ($country == 'EI') {
434 502
 					    // TODO : add modeS & reg to aircraft_modes
435 503
             				    $values['registration'] = $line[0];
436 504
             				    $values['base'] = $line[3];
437 505
             				    $values['owner'] = $line[2];
438
-            				    if ($line[1] == '') $values['date_first_reg'] = null;
439
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
506
+            				    if ($line[1] == '') {
507
+            				    	$values['date_first_reg'] = null;
508
+            				    } else {
509
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
510
+					    }
440 511
 					    $values['cancel'] = '';
441 512
 					    $values['modes'] = $line[7];
442 513
 					    $values['icao'] = $line[8];
@@ -455,16 +526,22 @@  discard block
 block discarded – undo
455 526
             				    $values['registration'] = $line[3];
456 527
             				    $values['base'] = null;
457 528
             				    $values['owner'] = $line[5];
458
-            				    if ($line[18] == '') $values['date_first_reg'] = null;
459
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
529
+            				    if ($line[18] == '') {
530
+            				    	$values['date_first_reg'] = null;
531
+            				    } else {
532
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
533
+					    }
460 534
 					    $values['cancel'] = '';
461 535
 					} elseif ($country == 'VH') {
462 536
 					    // TODO : add modeS & reg to aircraft_modes
463 537
             				    $values['registration'] = $line[0];
464 538
             				    $values['base'] = null;
465 539
             				    $values['owner'] = $line[12];
466
-            				    if ($line[28] == '') $values['date_first_reg'] = null;
467
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
540
+            				    if ($line[28] == '') {
541
+            				    	$values['date_first_reg'] = null;
542
+            				    } else {
543
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
544
+					    }
468 545
 
469 546
 					    $values['cancel'] = $line[39];
470 547
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
@@ -483,29 +560,41 @@  discard block
 block discarded – undo
483 560
             				    $values['registration'] = $line[0];
484 561
             				    $values['base'] = null;
485 562
             				    $values['owner'] = $line[8];
486
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
487
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
563
+            				    if ($line[7] == '') {
564
+            				    	$values['date_first_reg'] = null;
565
+            				    } else {
566
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
567
+					    }
488 568
 					    $values['cancel'] = '';
489 569
 					} elseif ($country == 'PP') {
490 570
             				    $values['registration'] = $line[0];
491 571
             				    $values['base'] = null;
492 572
             				    $values['owner'] = $line[4];
493
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
494
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
573
+            				    if ($line[6] == '') {
574
+            				    	$values['date_first_reg'] = null;
575
+            				    } else {
576
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
577
+					    }
495 578
 					    $values['cancel'] = $line[7];
496 579
 					} elseif ($country == 'E7') {
497 580
             				    $values['registration'] = $line[0];
498 581
             				    $values['base'] = null;
499 582
             				    $values['owner'] = $line[4];
500
-            				    if ($line[5] == '') $values['date_first_reg'] = null;
501
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
583
+            				    if ($line[5] == '') {
584
+            				    	$values['date_first_reg'] = null;
585
+            				    } else {
586
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
587
+					    }
502 588
 					    $values['cancel'] = '';
503 589
 					} elseif ($country == '8Q') {
504 590
             				    $values['registration'] = $line[0];
505 591
             				    $values['base'] = null;
506 592
             				    $values['owner'] = $line[3];
507
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
508
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
593
+            				    if ($line[7] == '') {
594
+            				    	$values['date_first_reg'] = null;
595
+            				    } else {
596
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
597
+					    }
509 598
 					    $values['cancel'] = '';
510 599
 					} elseif ($country == 'ZK') {
511 600
             				    $values['registration'] = $line[0];
@@ -550,7 +639,9 @@  discard block
 block discarded – undo
550 639
 						$sth_modes->execute($query_modes_values);
551 640
 					}
552 641
 				}
553
-				if ($globalTransaction) $Connection->db->commit();
642
+				if ($globalTransaction) {
643
+					$Connection->db->commit();
644
+				}
554 645
 			} catch(PDOException $e) {
555 646
 				return "error : ".$e->getMessage();
556 647
 			}
@@ -684,25 +775,45 @@  discard block
 block discarded – undo
684 775
 		    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)";
685 776
 		$Connection = new Connection();
686 777
 		$sth_dest = $Connection->db->prepare($query_dest);
687
-		if ($globalTransaction) $Connection->db->beginTransaction();
778
+		if ($globalTransaction) {
779
+			$Connection->db->beginTransaction();
780
+		}
688 781
   
689 782
 		$i = 0;
690 783
 		while($row = sparql_fetch_array($result))
691 784
 		{
692 785
 			if ($i >= 1) {
693 786
 			//print_r($row);
694
-			if (!isset($row['iata'])) $row['iata'] = '';
695
-			if (!isset($row['icao'])) $row['icao'] = '';
696
-			if (!isset($row['type'])) $row['type'] = '';
697
-			if (!isset($row['altitude'])) $row['altitude'] = '';
787
+			if (!isset($row['iata'])) {
788
+				$row['iata'] = '';
789
+			}
790
+			if (!isset($row['icao'])) {
791
+				$row['icao'] = '';
792
+			}
793
+			if (!isset($row['type'])) {
794
+				$row['type'] = '';
795
+			}
796
+			if (!isset($row['altitude'])) {
797
+				$row['altitude'] = '';
798
+			}
698 799
 			if (isset($row['city_bis'])) {
699 800
 				$row['city'] = $row['city_bis'];
700 801
 			}
701
-			if (!isset($row['city'])) $row['city'] = '';
702
-			if (!isset($row['country'])) $row['country'] = '';
703
-			if (!isset($row['homepage'])) $row['homepage'] = '';
704
-			if (!isset($row['wikipedia_page'])) $row['wikipedia_page'] = '';
705
-			if (!isset($row['name'])) continue;
802
+			if (!isset($row['city'])) {
803
+				$row['city'] = '';
804
+			}
805
+			if (!isset($row['country'])) {
806
+				$row['country'] = '';
807
+			}
808
+			if (!isset($row['homepage'])) {
809
+				$row['homepage'] = '';
810
+			}
811
+			if (!isset($row['wikipedia_page'])) {
812
+				$row['wikipedia_page'] = '';
813
+			}
814
+			if (!isset($row['name'])) {
815
+				continue;
816
+			}
706 817
 			if (!isset($row['image'])) {
707 818
 				$row['image'] = '';
708 819
 				$row['image_thumb'] = '';
@@ -738,7 +849,9 @@  discard block
 block discarded – undo
738 849
 
739 850
 			$i++;
740 851
 		}
741
-		if ($globalTransaction) $Connection->db->commit();
852
+		if ($globalTransaction) {
853
+			$Connection->db->commit();
854
+		}
742 855
 		echo "Delete duplicate rows...\n";
743 856
 		$query = 'ALTER IGNORE TABLE airport ADD UNIQUE INDEX icaoidx (icao)';
744 857
 		try {
@@ -750,7 +863,9 @@  discard block
 block discarded – undo
750 863
                 }
751 864
 
752 865
 
753
-		if ($globalDebug) echo "Insert Not available Airport...\n";
866
+		if ($globalDebug) {
867
+			echo "Insert Not available Airport...\n";
868
+		}
754 869
 		$query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image`,`image_thumb`)
755 870
 		    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image, :image_thumb)";
756 871
 		$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' => '');
@@ -777,7 +892,9 @@  discard block
 block discarded – undo
777 892
 		$delimiter = ',';
778 893
 		$out_file = $tmp_dir.'airports.csv';
779 894
 		update_db::download('http://ourairports.com/data/airports.csv',$out_file);
780
-		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
895
+		if (!file_exists($out_file) || !is_readable($out_file)) {
896
+			return FALSE;
897
+		}
781 898
 		echo "Add data from ourairports.com...\n";
782 899
 
783 900
 		$header = NULL;
@@ -787,8 +904,9 @@  discard block
 block discarded – undo
787 904
 			//$Connection->db->beginTransaction();
788 905
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
789 906
 			{
790
-				if(!$header) $header = $row;
791
-				else {
907
+				if(!$header) {
908
+					$header = $row;
909
+				} else {
792 910
 					$data = array();
793 911
 					$data = array_combine($header, $row);
794 912
 					try {
@@ -826,7 +944,9 @@  discard block
 block discarded – undo
826 944
 		echo "Download data from another free database...\n";
827 945
 		$out_file = $tmp_dir.'GlobalAirportDatabase.zip';
828 946
 		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file);
829
-		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
947
+		if (!file_exists($out_file) || !is_readable($out_file)) {
948
+			return FALSE;
949
+		}
830 950
 		update_db::unzip($out_file);
831 951
 		$header = NULL;
832 952
 		echo "Add data from another free database...\n";
@@ -837,8 +957,9 @@  discard block
 block discarded – undo
837 957
 			//$Connection->db->beginTransaction();
838 958
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
839 959
 			{
840
-				if(!$header) $header = $row;
841
-				else {
960
+				if(!$header) {
961
+					$header = $row;
962
+				} else {
842 963
 					$data = $row;
843 964
 
844 965
 					$query = 'UPDATE airport SET `city` = :city, `country` = :country WHERE icao = :icao';
@@ -1014,7 +1135,9 @@  discard block
 block discarded – undo
1014 1135
 		if (($handle = fopen($tmp_dir.'MASTER.txt', 'r')) !== FALSE)
1015 1136
 		{
1016 1137
 			$i = 0;
1017
-			if ($globalTransaction) $Connection->db->beginTransaction();
1138
+			if ($globalTransaction) {
1139
+				$Connection->db->beginTransaction();
1140
+			}
1018 1141
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1019 1142
 			{
1020 1143
 				if ($i > 0) {
@@ -1027,7 +1150,9 @@  discard block
 block discarded – undo
1027 1150
 					}
1028 1151
 					$result_search = $sths->fetchAll(PDO::FETCH_ASSOC);
1029 1152
 					if (!empty($result_search)) {
1030
-						if ($globalDebug) echo '.';
1153
+						if ($globalDebug) {
1154
+							echo '.';
1155
+						}
1031 1156
 							//if ($globalDBdriver == 'mysql') {
1032 1157
 							//	$queryi = 'INSERT INTO faamfr (mfr,icao) VALUES (:mfr,:icao) ON DUPLICATE KEY UPDATE icao = :icao';
1033 1158
 							//} else {
@@ -1049,8 +1174,12 @@  discard block
 block discarded – undo
1049 1174
 						}
1050 1175
 						$result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC);
1051 1176
 						if (!empty($result_search_mfr)) {
1052
-							if (trim($data[16]) == '' && trim($data[23]) != '') $data[16] = $data[23];
1053
-							if (trim($data[16]) == '' && trim($data[15]) != '') $data[16] = $data[15];
1177
+							if (trim($data[16]) == '' && trim($data[23]) != '') {
1178
+								$data[16] = $data[23];
1179
+							}
1180
+							if (trim($data[16]) == '' && trim($data[15]) != '') {
1181
+								$data[16] = $data[15];
1182
+							}
1054 1183
 							$queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)';
1055 1184
 							try {
1056 1185
 								$sthf = $Connection->db->prepare($queryf);
@@ -1061,7 +1190,9 @@  discard block
 block discarded – undo
1061 1190
 						}
1062 1191
 					}
1063 1192
 					if (strtotime($data[29]) > time()) {
1064
-						if ($globalDebug) echo 'i';
1193
+						if ($globalDebug) {
1194
+							echo 'i';
1195
+						}
1065 1196
 						$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
1066 1197
 						try {
1067 1198
 							$sth = $Connection->db->prepare($query);
@@ -1072,13 +1203,19 @@  discard block
 block discarded – undo
1072 1203
 					}
1073 1204
 				}
1074 1205
 				if ($i % 90 == 0) {
1075
-					if ($globalTransaction) $Connection->db->commit();
1076
-					if ($globalTransaction) $Connection->db->beginTransaction();
1206
+					if ($globalTransaction) {
1207
+						$Connection->db->commit();
1208
+					}
1209
+					if ($globalTransaction) {
1210
+						$Connection->db->beginTransaction();
1211
+					}
1077 1212
 				}
1078 1213
 				$i++;
1079 1214
 			}
1080 1215
 			fclose($handle);
1081
-			if ($globalTransaction) $Connection->db->commit();
1216
+			if ($globalTransaction) {
1217
+				$Connection->db->commit();
1218
+			}
1082 1219
 		}
1083 1220
 		print_r($mfr);
1084 1221
 		return '';
@@ -1103,11 +1240,15 @@  discard block
 block discarded – undo
1103 1240
 			$i = 0;
1104 1241
 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
1105 1242
 			//$Connection->db->beginTransaction();
1106
-			if ($globalTransaction) $Connection->db->beginTransaction();
1243
+			if ($globalTransaction) {
1244
+				$Connection->db->beginTransaction();
1245
+			}
1107 1246
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1108 1247
 			{
1109 1248
 				if ($i > 0) {
1110
-					if ($data[1] == 'NULL') $data[1] = $data[0];
1249
+					if ($data[1] == 'NULL') {
1250
+						$data[1] = $data[0];
1251
+					}
1111 1252
 					$query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)';
1112 1253
 					try {
1113 1254
 						$sth = $Connection->db->prepare($query);
@@ -1119,7 +1260,9 @@  discard block
 block discarded – undo
1119 1260
 				$i++;
1120 1261
 			}
1121 1262
 			fclose($handle);
1122
-			if ($globalTransaction) $Connection->db->commit();
1263
+			if ($globalTransaction) {
1264
+				$Connection->db->commit();
1265
+			}
1123 1266
 		}
1124 1267
 		return '';
1125 1268
         }
@@ -1140,7 +1283,9 @@  discard block
 block discarded – undo
1140 1283
 		if (($handle = fopen($tmp_dir.'owners.tsv', 'r')) !== FALSE)
1141 1284
 		{
1142 1285
 			$i = 0;
1143
-			if ($globalTransaction) $Connection->db->beginTransaction();
1286
+			if ($globalTransaction) {
1287
+				$Connection->db->beginTransaction();
1288
+			}
1144 1289
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1145 1290
 			{
1146 1291
 				if ($i > 0) {
@@ -1156,7 +1301,9 @@  discard block
 block discarded – undo
1156 1301
 				$i++;
1157 1302
 			}
1158 1303
 			fclose($handle);
1159
-			if ($globalTransaction) $Connection->db->commit();
1304
+			if ($globalTransaction) {
1305
+				$Connection->db->commit();
1306
+			}
1160 1307
 		}
1161 1308
 		return '';
1162 1309
         }
@@ -1181,7 +1328,9 @@  discard block
 block discarded – undo
1181 1328
 			$i = 0;
1182 1329
 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
1183 1330
 			//$Connection->db->beginTransaction();
1184
-			if ($globalTransaction) $Connection->db->beginTransaction();
1331
+			if ($globalTransaction) {
1332
+				$Connection->db->beginTransaction();
1333
+			}
1185 1334
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1186 1335
 			{
1187 1336
 				if ($i > 0) {
@@ -1196,7 +1345,9 @@  discard block
 block discarded – undo
1196 1345
 				$i++;
1197 1346
 			}
1198 1347
 			fclose($handle);
1199
-			if ($globalTransaction) $Connection->db->commit();
1348
+			if ($globalTransaction) {
1349
+				$Connection->db->commit();
1350
+			}
1200 1351
 		}
1201 1352
 		return '';
1202 1353
         }
@@ -1215,7 +1366,9 @@  discard block
 block discarded – undo
1215 1366
 		$Connection = new Connection();
1216 1367
 		if (($handle = fopen($tmp_dir.'ban_eu.csv', 'r')) !== FALSE)
1217 1368
 		{
1218
-			if ($globalTransaction) $Connection->db->beginTransaction();
1369
+			if ($globalTransaction) {
1370
+				$Connection->db->beginTransaction();
1371
+			}
1219 1372
 			while (($data = fgetcsv($handle, 1000)) !== FALSE)
1220 1373
 			{
1221 1374
 				$query = 'UPDATE airlines SET ban_eu = 1 WHERE icao = :icao AND forsource IS NULL';
@@ -1230,7 +1383,9 @@  discard block
 block discarded – undo
1230 1383
 				}
1231 1384
 			}
1232 1385
 			fclose($handle);
1233
-			if ($globalTransaction) $Connection->db->commit();
1386
+			if ($globalTransaction) {
1387
+				$Connection->db->commit();
1388
+			}
1234 1389
 		}
1235 1390
 		return '';
1236 1391
         }
@@ -1381,7 +1536,9 @@  discard block
 block discarded – undo
1381 1536
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1382 1537
 		{
1383 1538
 			$i = 0;
1384
-			if ($globalTransaction) $Connection->db->beginTransaction();
1539
+			if ($globalTransaction) {
1540
+				$Connection->db->beginTransaction();
1541
+			}
1385 1542
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1386 1543
 			{
1387 1544
 				$i++;
@@ -1409,7 +1566,9 @@  discard block
 block discarded – undo
1409 1566
 				}
1410 1567
 			}
1411 1568
 			fclose($handle);
1412
-			if ($globalTransaction) $Connection->db->commit();
1569
+			if ($globalTransaction) {
1570
+				$Connection->db->commit();
1571
+			}
1413 1572
 		}
1414 1573
 		return '';
1415 1574
         }
@@ -1432,7 +1591,9 @@  discard block
 block discarded – undo
1432 1591
 		$Connection = new Connection();
1433 1592
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1434 1593
 		{
1435
-			if ($globalTransaction) $Connection->db->beginTransaction();
1594
+			if ($globalTransaction) {
1595
+				$Connection->db->beginTransaction();
1596
+			}
1436 1597
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1437 1598
 			{
1438 1599
 				if(count($row) > 1) {
@@ -1446,7 +1607,9 @@  discard block
 block discarded – undo
1446 1607
 				}
1447 1608
 			}
1448 1609
 			fclose($handle);
1449
-			if ($globalTransaction) $Connection->db->commit();
1610
+			if ($globalTransaction) {
1611
+				$Connection->db->commit();
1612
+			}
1450 1613
 		}
1451 1614
 		return '';
1452 1615
         }
@@ -1466,8 +1629,9 @@  discard block
 block discarded – undo
1466 1629
 	        }
1467 1630
 
1468 1631
 
1469
-		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1470
-		else {
1632
+		if ($globalDBdriver == 'mysql') {
1633
+			update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1634
+		} else {
1471 1635
 			update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql');
1472 1636
 			$query = "CREATE EXTENSION postgis";
1473 1637
 			$Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']);
@@ -1486,20 +1650,30 @@  discard block
 block discarded – undo
1486 1650
 		global $tmp_dir, $globalDebug;
1487 1651
 		include_once('class.create_db.php');
1488 1652
 		require_once(dirname(__FILE__).'/../require/class.NOTAM.php');
1489
-		if ($globalDebug) echo "NOTAM from FlightAirMap website : Download...";
1653
+		if ($globalDebug) {
1654
+			echo "NOTAM from FlightAirMap website : Download...";
1655
+		}
1490 1656
 		update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz');
1491 1657
 		$error = '';
1492 1658
 		if (file_exists($tmp_dir.'notam.txt.gz')) {
1493
-			if ($globalDebug) echo "Gunzip...";
1659
+			if ($globalDebug) {
1660
+				echo "Gunzip...";
1661
+			}
1494 1662
 			update_db::gunzip($tmp_dir.'notam.txt.gz');
1495
-			if ($globalDebug) echo "Add to DB...";
1663
+			if ($globalDebug) {
1664
+				echo "Add to DB...";
1665
+			}
1496 1666
 			//$error = create_db::import_file($tmp_dir.'notam.sql');
1497 1667
 			$NOTAM = new NOTAM();
1498 1668
 			$NOTAM->updateNOTAMfromTextFile($tmp_dir.'notam.txt');
1499
-		} else $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";
1669
+		} else {
1670
+			$error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";
1671
+		}
1500 1672
 		if ($error != '') {
1501 1673
 			return $error;
1502
-		} elseif ($globalDebug) echo "Done\n";
1674
+		} elseif ($globalDebug) {
1675
+			echo "Done\n";
1676
+		}
1503 1677
 		return '';
1504 1678
 	}
1505 1679
 
@@ -1553,67 +1727,111 @@  discard block
 block discarded – undo
1553 1727
 		//if ($globalDebug) echo "IVAO : Download...";
1554 1728
 		//update_db::download('http://fr.mirror.ivao.aero/software/ivae_feb2013.zip',$tmp_dir.'ivae_feb2013.zip');
1555 1729
 		if (file_exists($tmp_dir.'ivae_feb2013.zip')) {
1556
-			if ($globalDebug) echo "Unzip...";
1730
+			if ($globalDebug) {
1731
+				echo "Unzip...";
1732
+			}
1557 1733
 			update_db::unzip($tmp_dir.'ivae_feb2013.zip');
1558
-			if ($globalDebug) echo "Add to DB...";
1734
+			if ($globalDebug) {
1735
+				echo "Add to DB...";
1736
+			}
1559 1737
 			update_db::ivao_airlines($tmp_dir.'data/airlines.dat');
1560
-			if ($globalDebug) echo "Copy airlines logos to airlines images directory...";
1738
+			if ($globalDebug) {
1739
+				echo "Copy airlines logos to airlines images directory...";
1740
+			}
1561 1741
 			if (is_writable(dirname(__FILE__).'/../images/airlines')) {
1562
-				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
1563
-			} else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
1564
-		} else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
1742
+				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) {
1743
+					$error = "Failed to copy airlines logo.";
1744
+				}
1745
+			} else {
1746
+				$error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
1747
+			}
1748
+		} else {
1749
+			$error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
1750
+		}
1565 1751
 		if ($error != '') {
1566 1752
 			return $error;
1567
-		} elseif ($globalDebug) echo "Done\n";
1753
+		} elseif ($globalDebug) {
1754
+			echo "Done\n";
1755
+		}
1568 1756
 		return '';
1569 1757
 	}
1570 1758
 
1571 1759
 	public static function update_routes() {
1572 1760
 		global $tmp_dir, $globalDebug;
1573 1761
 		$error = '';
1574
-		if ($globalDebug) echo "Routes : Download...";
1762
+		if ($globalDebug) {
1763
+			echo "Routes : Download...";
1764
+		}
1575 1765
 		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz');
1576 1766
 		if (file_exists($tmp_dir.'StandingData.sqb.gz')) {
1577
-			if ($globalDebug) echo "Gunzip...";
1767
+			if ($globalDebug) {
1768
+				echo "Gunzip...";
1769
+			}
1578 1770
 			update_db::gunzip($tmp_dir.'StandingData.sqb.gz');
1579
-			if ($globalDebug) echo "Add to DB...";
1771
+			if ($globalDebug) {
1772
+				echo "Add to DB...";
1773
+			}
1580 1774
 			$error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb');
1581
-		} else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
1775
+		} else {
1776
+			$error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
1777
+		}
1582 1778
 		if ($error != '') {
1583 1779
 			return $error;
1584
-		} elseif ($globalDebug) echo "Done\n";
1780
+		} elseif ($globalDebug) {
1781
+			echo "Done\n";
1782
+		}
1585 1783
 		return '';
1586 1784
 	}
1587 1785
 	public static function update_oneworld() {
1588 1786
 		global $tmp_dir, $globalDebug;
1589 1787
 		$error = '';
1590
-		if ($globalDebug) echo "Schedules Oneworld : Download...";
1788
+		if ($globalDebug) {
1789
+			echo "Schedules Oneworld : Download...";
1790
+		}
1591 1791
 		update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz');
1592 1792
 		if (file_exists($tmp_dir.'oneworld.csv.gz')) {
1593
-			if ($globalDebug) echo "Gunzip...";
1793
+			if ($globalDebug) {
1794
+				echo "Gunzip...";
1795
+			}
1594 1796
 			update_db::gunzip($tmp_dir.'oneworld.csv.gz');
1595
-			if ($globalDebug) echo "Add to DB...";
1797
+			if ($globalDebug) {
1798
+				echo "Add to DB...";
1799
+			}
1596 1800
 			$error = update_db::retrieve_route_oneworld($tmp_dir.'oneworld.csv');
1597
-		} else $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
1801
+		} else {
1802
+			$error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
1803
+		}
1598 1804
 		if ($error != '') {
1599 1805
 			return $error;
1600
-		} elseif ($globalDebug) echo "Done\n";
1806
+		} elseif ($globalDebug) {
1807
+			echo "Done\n";
1808
+		}
1601 1809
 		return '';
1602 1810
 	}
1603 1811
 	public static function update_skyteam() {
1604 1812
 		global $tmp_dir, $globalDebug;
1605 1813
 		$error = '';
1606
-		if ($globalDebug) echo "Schedules Skyteam : Download...";
1814
+		if ($globalDebug) {
1815
+			echo "Schedules Skyteam : Download...";
1816
+		}
1607 1817
 		update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz');
1608 1818
 		if (file_exists($tmp_dir.'skyteam.csv.gz')) {
1609
-			if ($globalDebug) echo "Gunzip...";
1819
+			if ($globalDebug) {
1820
+				echo "Gunzip...";
1821
+			}
1610 1822
 			update_db::gunzip($tmp_dir.'skyteam.csv.gz');
1611
-			if ($globalDebug) echo "Add to DB...";
1823
+			if ($globalDebug) {
1824
+				echo "Add to DB...";
1825
+			}
1612 1826
 			$error = update_db::retrieve_route_skyteam($tmp_dir.'skyteam.csv');
1613
-		} else $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
1827
+		} else {
1828
+			$error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
1829
+		}
1614 1830
 		if ($error != '') {
1615 1831
 			return $error;
1616
-		} elseif ($globalDebug) echo "Done\n";
1832
+		} elseif ($globalDebug) {
1833
+			echo "Done\n";
1834
+		}
1617 1835
 		return '';
1618 1836
 	}
1619 1837
 	public static function update_ModeS() {
@@ -1630,370 +1848,642 @@  discard block
 block discarded – undo
1630 1848
 			exit;
1631 1849
 		} elseif ($globalDebug) echo "Done\n";
1632 1850
 */
1633
-		if ($globalDebug) echo "Modes : Download...";
1634
-//		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
1851
+		if ($globalDebug) {
1852
+			echo "Modes : Download...";
1853
+		}
1854
+		//		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
1635 1855
 		update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz');
1636 1856
 
1637 1857
 //		if (file_exists($tmp_dir.'basestation_latest.zip')) {
1638 1858
 		if (file_exists($tmp_dir.'BaseStation.sqb.gz')) {
1639
-			if ($globalDebug) echo "Unzip...";
1640
-//			update_db::unzip($tmp_dir.'basestation_latest.zip');
1859
+			if ($globalDebug) {
1860
+				echo "Unzip...";
1861
+			}
1862
+			//			update_db::unzip($tmp_dir.'basestation_latest.zip');
1641 1863
 			update_db::gunzip($tmp_dir.'BaseStation.sqb.gz');
1642
-			if ($globalDebug) echo "Add to DB...";
1864
+			if ($globalDebug) {
1865
+				echo "Add to DB...";
1866
+			}
1643 1867
 			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb');
1644 1868
 //			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'basestation.sqb');
1645
-		} else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
1869
+		} else {
1870
+			$error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
1871
+		}
1646 1872
 		if ($error != '') {
1647 1873
 			return $error;
1648
-		} elseif ($globalDebug) echo "Done\n";
1874
+		} elseif ($globalDebug) {
1875
+			echo "Done\n";
1876
+		}
1649 1877
 		return '';
1650 1878
 	}
1651 1879
 
1652 1880
 	public static function update_ModeS_faa() {
1653 1881
 		global $tmp_dir, $globalDebug;
1654
-		if ($globalDebug) echo "Modes FAA: Download...";
1882
+		if ($globalDebug) {
1883
+			echo "Modes FAA: Download...";
1884
+		}
1655 1885
 		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip');
1656 1886
 		if (file_exists($tmp_dir.'ReleasableAircraft.zip')) {
1657
-			if ($globalDebug) echo "Unzip...";
1887
+			if ($globalDebug) {
1888
+				echo "Unzip...";
1889
+			}
1658 1890
 			update_db::unzip($tmp_dir.'ReleasableAircraft.zip');
1659
-			if ($globalDebug) echo "Add to DB...";
1891
+			if ($globalDebug) {
1892
+				echo "Add to DB...";
1893
+			}
1660 1894
 			$error = update_db::modes_faa();
1661
-		} else $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed.";
1895
+		} else {
1896
+			$error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed.";
1897
+		}
1662 1898
 		if ($error != '') {
1663 1899
 			return $error;
1664
-		} elseif ($globalDebug) echo "Done\n";
1900
+		} elseif ($globalDebug) {
1901
+			echo "Done\n";
1902
+		}
1665 1903
 		return '';
1666 1904
 	}
1667 1905
 
1668 1906
 	public static function update_ModeS_flarm() {
1669 1907
 		global $tmp_dir, $globalDebug;
1670
-		if ($globalDebug) echo "Modes Flarmnet: Download...";
1908
+		if ($globalDebug) {
1909
+			echo "Modes Flarmnet: Download...";
1910
+		}
1671 1911
 		update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln');
1672 1912
 		if (file_exists($tmp_dir.'data.fln')) {
1673
-			if ($globalDebug) echo "Add to DB...";
1913
+			if ($globalDebug) {
1914
+				echo "Add to DB...";
1915
+			}
1674 1916
 			$error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln');
1675
-		} else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";
1917
+		} else {
1918
+			$error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";
1919
+		}
1676 1920
 		if ($error != '') {
1677 1921
 			return $error;
1678
-		} elseif ($globalDebug) echo "Done\n";
1922
+		} elseif ($globalDebug) {
1923
+			echo "Done\n";
1924
+		}
1679 1925
 		return '';
1680 1926
 	}
1681 1927
 
1682 1928
 	public static function update_ModeS_ogn() {
1683 1929
 		global $tmp_dir, $globalDebug;
1684
-		if ($globalDebug) echo "Modes OGN: Download...";
1930
+		if ($globalDebug) {
1931
+			echo "Modes OGN: Download...";
1932
+		}
1685 1933
 		update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv');
1686 1934
 		if (file_exists($tmp_dir.'ogn.csv')) {
1687
-			if ($globalDebug) echo "Add to DB...";
1935
+			if ($globalDebug) {
1936
+				echo "Add to DB...";
1937
+			}
1688 1938
 			$error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv');
1689
-		} else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";
1939
+		} else {
1940
+			$error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";
1941
+		}
1690 1942
 		if ($error != '') {
1691 1943
 			return $error;
1692
-		} elseif ($globalDebug) echo "Done\n";
1944
+		} elseif ($globalDebug) {
1945
+			echo "Done\n";
1946
+		}
1693 1947
 		return '';
1694 1948
 	}
1695 1949
 
1696 1950
 	public static function update_owner() {
1697 1951
 		global $tmp_dir, $globalDebug, $globalMasterSource;
1698 1952
 		
1699
-		if ($globalDebug) echo "Owner France: Download...";
1953
+		if ($globalDebug) {
1954
+			echo "Owner France: Download...";
1955
+		}
1700 1956
 		update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv');
1701 1957
 		if (file_exists($tmp_dir.'owner_f.csv')) {
1702
-			if ($globalDebug) echo "Add to DB...";
1958
+			if ($globalDebug) {
1959
+				echo "Add to DB...";
1960
+			}
1703 1961
 			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F');
1704
-		} else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
1962
+		} else {
1963
+			$error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
1964
+		}
1705 1965
 		if ($error != '') {
1706 1966
 			return $error;
1707
-		} elseif ($globalDebug) echo "Done\n";
1967
+		} elseif ($globalDebug) {
1968
+			echo "Done\n";
1969
+		}
1708 1970
 		
1709
-		if ($globalDebug) echo "Owner Ireland: Download...";
1971
+		if ($globalDebug) {
1972
+			echo "Owner Ireland: Download...";
1973
+		}
1710 1974
 		update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv');
1711 1975
 		if (file_exists($tmp_dir.'owner_ei.csv')) {
1712
-			if ($globalDebug) echo "Add to DB...";
1976
+			if ($globalDebug) {
1977
+				echo "Add to DB...";
1978
+			}
1713 1979
 			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI');
1714
-		} else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
1980
+		} else {
1981
+			$error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
1982
+		}
1715 1983
 		if ($error != '') {
1716 1984
 			return $error;
1717
-		} elseif ($globalDebug) echo "Done\n";
1718
-		if ($globalDebug) echo "Owner Switzerland: Download...";
1985
+		} elseif ($globalDebug) {
1986
+			echo "Done\n";
1987
+		}
1988
+		if ($globalDebug) {
1989
+			echo "Owner Switzerland: Download...";
1990
+		}
1719 1991
 		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv');
1720 1992
 		if (file_exists($tmp_dir.'owner_hb.csv')) {
1721
-			if ($globalDebug) echo "Add to DB...";
1993
+			if ($globalDebug) {
1994
+				echo "Add to DB...";
1995
+			}
1722 1996
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB');
1723
-		} else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
1997
+		} else {
1998
+			$error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
1999
+		}
1724 2000
 		if ($error != '') {
1725 2001
 			return $error;
1726
-		} elseif ($globalDebug) echo "Done\n";
1727
-		if ($globalDebug) echo "Owner Czech Republic: Download...";
2002
+		} elseif ($globalDebug) {
2003
+			echo "Done\n";
2004
+		}
2005
+		if ($globalDebug) {
2006
+			echo "Owner Czech Republic: Download...";
2007
+		}
1728 2008
 		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv');
1729 2009
 		if (file_exists($tmp_dir.'owner_ok.csv')) {
1730
-			if ($globalDebug) echo "Add to DB...";
2010
+			if ($globalDebug) {
2011
+				echo "Add to DB...";
2012
+			}
1731 2013
 			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK');
1732
-		} else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
2014
+		} else {
2015
+			$error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
2016
+		}
1733 2017
 		if ($error != '') {
1734 2018
 			return $error;
1735
-		} elseif ($globalDebug) echo "Done\n";
1736
-		if ($globalDebug) echo "Owner Australia: Download...";
2019
+		} elseif ($globalDebug) {
2020
+			echo "Done\n";
2021
+		}
2022
+		if ($globalDebug) {
2023
+			echo "Owner Australia: Download...";
2024
+		}
1737 2025
 		update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv');
1738 2026
 		if (file_exists($tmp_dir.'owner_vh.csv')) {
1739
-			if ($globalDebug) echo "Add to DB...";
2027
+			if ($globalDebug) {
2028
+				echo "Add to DB...";
2029
+			}
1740 2030
 			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH');
1741
-		} else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
2031
+		} else {
2032
+			$error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
2033
+		}
1742 2034
 		if ($error != '') {
1743 2035
 			return $error;
1744
-		} elseif ($globalDebug) echo "Done\n";
1745
-		if ($globalDebug) echo "Owner Austria: Download...";
2036
+		} elseif ($globalDebug) {
2037
+			echo "Done\n";
2038
+		}
2039
+		if ($globalDebug) {
2040
+			echo "Owner Austria: Download...";
2041
+		}
1746 2042
 		update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv');
1747 2043
 		if (file_exists($tmp_dir.'owner_oe.csv')) {
1748
-			if ($globalDebug) echo "Add to DB...";
2044
+			if ($globalDebug) {
2045
+				echo "Add to DB...";
2046
+			}
1749 2047
 			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE');
1750
-		} else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
2048
+		} else {
2049
+			$error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
2050
+		}
1751 2051
 		if ($error != '') {
1752 2052
 			return $error;
1753
-		} elseif ($globalDebug) echo "Done\n";
1754
-		if ($globalDebug) echo "Owner Chile: Download...";
2053
+		} elseif ($globalDebug) {
2054
+			echo "Done\n";
2055
+		}
2056
+		if ($globalDebug) {
2057
+			echo "Owner Chile: Download...";
2058
+		}
1755 2059
 		update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv');
1756 2060
 		if (file_exists($tmp_dir.'owner_cc.csv')) {
1757
-			if ($globalDebug) echo "Add to DB...";
2061
+			if ($globalDebug) {
2062
+				echo "Add to DB...";
2063
+			}
1758 2064
 			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC');
1759
-		} else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
2065
+		} else {
2066
+			$error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
2067
+		}
1760 2068
 		if ($error != '') {
1761 2069
 			return $error;
1762
-		} elseif ($globalDebug) echo "Done\n";
1763
-		if ($globalDebug) echo "Owner Colombia: Download...";
2070
+		} elseif ($globalDebug) {
2071
+			echo "Done\n";
2072
+		}
2073
+		if ($globalDebug) {
2074
+			echo "Owner Colombia: Download...";
2075
+		}
1764 2076
 		update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv');
1765 2077
 		if (file_exists($tmp_dir.'owner_hj.csv')) {
1766
-			if ($globalDebug) echo "Add to DB...";
2078
+			if ($globalDebug) {
2079
+				echo "Add to DB...";
2080
+			}
1767 2081
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ');
1768
-		} else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
2082
+		} else {
2083
+			$error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
2084
+		}
1769 2085
 		if ($error != '') {
1770 2086
 			return $error;
1771
-		} elseif ($globalDebug) echo "Done\n";
1772
-		if ($globalDebug) echo "Owner Bosnia Herzegobina: Download...";
2087
+		} elseif ($globalDebug) {
2088
+			echo "Done\n";
2089
+		}
2090
+		if ($globalDebug) {
2091
+			echo "Owner Bosnia Herzegobina: Download...";
2092
+		}
1773 2093
 		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv');
1774 2094
 		if (file_exists($tmp_dir.'owner_e7.csv')) {
1775
-			if ($globalDebug) echo "Add to DB...";
2095
+			if ($globalDebug) {
2096
+				echo "Add to DB...";
2097
+			}
1776 2098
 			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7');
1777
-		} else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
2099
+		} else {
2100
+			$error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
2101
+		}
1778 2102
 		if ($error != '') {
1779 2103
 			return $error;
1780
-		} elseif ($globalDebug) echo "Done\n";
1781
-		if ($globalDebug) echo "Owner Brazil: Download...";
2104
+		} elseif ($globalDebug) {
2105
+			echo "Done\n";
2106
+		}
2107
+		if ($globalDebug) {
2108
+			echo "Owner Brazil: Download...";
2109
+		}
1782 2110
 		update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv');
1783 2111
 		if (file_exists($tmp_dir.'owner_pp.csv')) {
1784
-			if ($globalDebug) echo "Add to DB...";
2112
+			if ($globalDebug) {
2113
+				echo "Add to DB...";
2114
+			}
1785 2115
 			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP');
1786
-		} else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
2116
+		} else {
2117
+			$error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
2118
+		}
1787 2119
 		if ($error != '') {
1788 2120
 			return $error;
1789
-		} elseif ($globalDebug) echo "Done\n";
1790
-		if ($globalDebug) echo "Owner Cayman Islands: Download...";
2121
+		} elseif ($globalDebug) {
2122
+			echo "Done\n";
2123
+		}
2124
+		if ($globalDebug) {
2125
+			echo "Owner Cayman Islands: Download...";
2126
+		}
1791 2127
 		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv');
1792 2128
 		if (file_exists($tmp_dir.'owner_vp.csv')) {
1793
-			if ($globalDebug) echo "Add to DB...";
2129
+			if ($globalDebug) {
2130
+				echo "Add to DB...";
2131
+			}
1794 2132
 			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP');
1795
-		} else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
2133
+		} else {
2134
+			$error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
2135
+		}
1796 2136
 		if ($error != '') {
1797 2137
 			return $error;
1798
-		} elseif ($globalDebug) echo "Done\n";
1799
-		if ($globalDebug) echo "Owner Croatia: Download...";
2138
+		} elseif ($globalDebug) {
2139
+			echo "Done\n";
2140
+		}
2141
+		if ($globalDebug) {
2142
+			echo "Owner Croatia: Download...";
2143
+		}
1800 2144
 		update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv');
1801 2145
 		if (file_exists($tmp_dir.'owner_9a.csv')) {
1802
-			if ($globalDebug) echo "Add to DB...";
2146
+			if ($globalDebug) {
2147
+				echo "Add to DB...";
2148
+			}
1803 2149
 			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A');
1804
-		} else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
2150
+		} else {
2151
+			$error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
2152
+		}
1805 2153
 		if ($error != '') {
1806 2154
 			return $error;
1807
-		} elseif ($globalDebug) echo "Done\n";
1808
-		if ($globalDebug) echo "Owner Luxembourg: Download...";
2155
+		} elseif ($globalDebug) {
2156
+			echo "Done\n";
2157
+		}
2158
+		if ($globalDebug) {
2159
+			echo "Owner Luxembourg: Download...";
2160
+		}
1809 2161
 		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv');
1810 2162
 		if (file_exists($tmp_dir.'owner_lx.csv')) {
1811
-			if ($globalDebug) echo "Add to DB...";
2163
+			if ($globalDebug) {
2164
+				echo "Add to DB...";
2165
+			}
1812 2166
 			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX');
1813
-		} else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
2167
+		} else {
2168
+			$error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
2169
+		}
1814 2170
 		if ($error != '') {
1815 2171
 			return $error;
1816
-		} elseif ($globalDebug) echo "Done\n";
1817
-		if ($globalDebug) echo "Owner Maldives: Download...";
2172
+		} elseif ($globalDebug) {
2173
+			echo "Done\n";
2174
+		}
2175
+		if ($globalDebug) {
2176
+			echo "Owner Maldives: Download...";
2177
+		}
1818 2178
 		update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv');
1819 2179
 		if (file_exists($tmp_dir.'owner_8q.csv')) {
1820
-			if ($globalDebug) echo "Add to DB...";
2180
+			if ($globalDebug) {
2181
+				echo "Add to DB...";
2182
+			}
1821 2183
 			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q');
1822
-		} else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
2184
+		} else {
2185
+			$error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
2186
+		}
1823 2187
 		if ($error != '') {
1824 2188
 			return $error;
1825
-		} elseif ($globalDebug) echo "Done\n";
1826
-		if ($globalDebug) echo "Owner New Zealand: Download...";
2189
+		} elseif ($globalDebug) {
2190
+			echo "Done\n";
2191
+		}
2192
+		if ($globalDebug) {
2193
+			echo "Owner New Zealand: Download...";
2194
+		}
1827 2195
 		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv');
1828 2196
 		if (file_exists($tmp_dir.'owner_zk.csv')) {
1829
-			if ($globalDebug) echo "Add to DB...";
2197
+			if ($globalDebug) {
2198
+				echo "Add to DB...";
2199
+			}
1830 2200
 			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK');
1831
-		} else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
2201
+		} else {
2202
+			$error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
2203
+		}
1832 2204
 		if ($error != '') {
1833 2205
 			return $error;
1834
-		} elseif ($globalDebug) echo "Done\n";
1835
-		if ($globalDebug) echo "Owner Papua New Guinea: Download...";
2206
+		} elseif ($globalDebug) {
2207
+			echo "Done\n";
2208
+		}
2209
+		if ($globalDebug) {
2210
+			echo "Owner Papua New Guinea: Download...";
2211
+		}
1836 2212
 		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv');
1837 2213
 		if (file_exists($tmp_dir.'owner_p2.csv')) {
1838
-			if ($globalDebug) echo "Add to DB...";
2214
+			if ($globalDebug) {
2215
+				echo "Add to DB...";
2216
+			}
1839 2217
 			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2');
1840
-		} else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
2218
+		} else {
2219
+			$error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
2220
+		}
1841 2221
 		if ($error != '') {
1842 2222
 			return $error;
1843
-		} elseif ($globalDebug) echo "Done\n";
1844
-		if ($globalDebug) echo "Owner Slovakia: Download...";
2223
+		} elseif ($globalDebug) {
2224
+			echo "Done\n";
2225
+		}
2226
+		if ($globalDebug) {
2227
+			echo "Owner Slovakia: Download...";
2228
+		}
1845 2229
 		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv');
1846 2230
 		if (file_exists($tmp_dir.'owner_om.csv')) {
1847
-			if ($globalDebug) echo "Add to DB...";
2231
+			if ($globalDebug) {
2232
+				echo "Add to DB...";
2233
+			}
1848 2234
 			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM');
1849
-		} else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
2235
+		} else {
2236
+			$error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
2237
+		}
1850 2238
 		if ($error != '') {
1851 2239
 			return $error;
1852
-		} elseif ($globalDebug) echo "Done\n";
1853
-		if ($globalDebug) echo "Owner Ecuador: Download...";
2240
+		} elseif ($globalDebug) {
2241
+			echo "Done\n";
2242
+		}
2243
+		if ($globalDebug) {
2244
+			echo "Owner Ecuador: Download...";
2245
+		}
1854 2246
 		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv');
1855 2247
 		if (file_exists($tmp_dir.'owner_hc.csv')) {
1856
-			if ($globalDebug) echo "Add to DB...";
2248
+			if ($globalDebug) {
2249
+				echo "Add to DB...";
2250
+			}
1857 2251
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC');
1858
-		} else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
2252
+		} else {
2253
+			$error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
2254
+		}
1859 2255
 		if ($error != '') {
1860 2256
 			return $error;
1861
-		} elseif ($globalDebug) echo "Done\n";
1862
-		if ($globalDebug) echo "Owner Iceland: Download...";
2257
+		} elseif ($globalDebug) {
2258
+			echo "Done\n";
2259
+		}
2260
+		if ($globalDebug) {
2261
+			echo "Owner Iceland: Download...";
2262
+		}
1863 2263
 		update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv');
1864 2264
 		if (file_exists($tmp_dir.'owner_tf.csv')) {
1865
-			if ($globalDebug) echo "Add to DB...";
2265
+			if ($globalDebug) {
2266
+				echo "Add to DB...";
2267
+			}
1866 2268
 			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF');
1867
-		} else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2269
+		} else {
2270
+			$error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2271
+		}
1868 2272
 		if ($error != '') {
1869 2273
 			return $error;
1870
-		} elseif ($globalDebug) echo "Done\n";
1871
-		if ($globalDebug) echo "Owner Isle of Man: Download...";
2274
+		} elseif ($globalDebug) {
2275
+			echo "Done\n";
2276
+		}
2277
+		if ($globalDebug) {
2278
+			echo "Owner Isle of Man: Download...";
2279
+		}
1872 2280
 		update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv');
1873 2281
 		if (file_exists($tmp_dir.'owner_m.csv')) {
1874
-			if ($globalDebug) echo "Add to DB...";
2282
+			if ($globalDebug) {
2283
+				echo "Add to DB...";
2284
+			}
1875 2285
 			$error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M');
1876
-		} else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed.";
2286
+		} else {
2287
+			$error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed.";
2288
+		}
1877 2289
 		if ($error != '') {
1878 2290
 			return $error;
1879
-		} elseif ($globalDebug) echo "Done\n";
2291
+		} elseif ($globalDebug) {
2292
+			echo "Done\n";
2293
+		}
1880 2294
 		if ($globalMasterSource) {
1881
-			if ($globalDebug) echo "ModeS Netherlands: Download...";
2295
+			if ($globalDebug) {
2296
+				echo "ModeS Netherlands: Download...";
2297
+			}
1882 2298
 			update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv');
1883 2299
 			if (file_exists($tmp_dir.'owner_ph.csv')) {
1884
-				if ($globalDebug) echo "Add to DB...";
2300
+				if ($globalDebug) {
2301
+					echo "Add to DB...";
2302
+				}
1885 2303
 				$error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH');
1886
-			} else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed.";
2304
+			} else {
2305
+				$error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed.";
2306
+			}
1887 2307
 			if ($error != '') {
1888 2308
 				return $error;
1889
-			} elseif ($globalDebug) echo "Done\n";
1890
-			if ($globalDebug) echo "ModeS Denmark: Download...";
2309
+			} elseif ($globalDebug) {
2310
+				echo "Done\n";
2311
+			}
2312
+			if ($globalDebug) {
2313
+				echo "ModeS Denmark: Download...";
2314
+			}
1891 2315
 			update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv');
1892 2316
 			if (file_exists($tmp_dir.'owner_oy.csv')) {
1893
-				if ($globalDebug) echo "Add to DB...";
2317
+				if ($globalDebug) {
2318
+					echo "Add to DB...";
2319
+				}
1894 2320
 				$error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY');
1895
-			} else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed.";
2321
+			} else {
2322
+				$error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed.";
2323
+			}
1896 2324
 			if ($error != '') {
1897 2325
 				return $error;
1898
-			} elseif ($globalDebug) echo "Done\n";
1899
-		} elseif ($globalDebug) echo "Done\n";
2326
+			} elseif ($globalDebug) {
2327
+				echo "Done\n";
2328
+			}
2329
+		} elseif ($globalDebug) {
2330
+			echo "Done\n";
2331
+		}
1900 2332
 		return '';
1901 2333
 	}
1902 2334
 
1903 2335
 	public static function update_translation() {
1904 2336
 		global $tmp_dir, $globalDebug;
1905 2337
 		$error = '';
1906
-		if ($globalDebug) echo "Translation : Download...";
2338
+		if ($globalDebug) {
2339
+			echo "Translation : Download...";
2340
+		}
1907 2341
 		update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip');
1908 2342
 		if (file_exists($tmp_dir.'translation.zip')) {
1909
-			if ($globalDebug) echo "Unzip...";
2343
+			if ($globalDebug) {
2344
+				echo "Unzip...";
2345
+			}
1910 2346
 			update_db::unzip($tmp_dir.'translation.zip');
1911
-			if ($globalDebug) echo "Add to DB...";
2347
+			if ($globalDebug) {
2348
+				echo "Add to DB...";
2349
+			}
1912 2350
 			$error = update_db::translation();
1913
-		} else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
2351
+		} else {
2352
+			$error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
2353
+		}
1914 2354
 		if ($error != '') {
1915 2355
 			return $error;
1916
-		} elseif ($globalDebug) echo "Done\n";
2356
+		} elseif ($globalDebug) {
2357
+			echo "Done\n";
2358
+		}
1917 2359
 		return '';
1918 2360
 	}
1919 2361
 
1920 2362
 	public static function update_translation_fam() {
1921 2363
 		global $tmp_dir, $globalDebug;
1922
-		if ($globalDebug) echo "Translation from FlightAirMap website : Download...";
2364
+		if ($globalDebug) {
2365
+			echo "Translation from FlightAirMap website : Download...";
2366
+		}
1923 2367
 		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz');
1924 2368
 		if (file_exists($tmp_dir.'translation.tsv.gz')) {
1925
-			if ($globalDebug) echo "Gunzip...";
2369
+			if ($globalDebug) {
2370
+				echo "Gunzip...";
2371
+			}
1926 2372
 			update_db::gunzip($tmp_dir.'translation.tsv.gz');
1927
-			if ($globalDebug) echo "Add to DB...";
2373
+			if ($globalDebug) {
2374
+				echo "Add to DB...";
2375
+			}
1928 2376
 			$error = update_db::translation_fam();
1929
-		} else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
2377
+		} else {
2378
+			$error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
2379
+		}
1930 2380
 		if ($error != '') {
1931 2381
 			return $error;
1932
-		} elseif ($globalDebug) echo "Done\n";
2382
+		} elseif ($globalDebug) {
2383
+			echo "Done\n";
2384
+		}
1933 2385
 		return '';
1934 2386
 	}
1935 2387
 	public static function update_ModeS_fam() {
1936 2388
 		global $tmp_dir, $globalDebug;
1937
-		if ($globalDebug) echo "ModeS from FlightAirMap website : Download...";
2389
+		if ($globalDebug) {
2390
+			echo "ModeS from FlightAirMap website : Download...";
2391
+		}
1938 2392
 		update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz');
1939 2393
 		if (file_exists($tmp_dir.'modes.tsv.gz')) {
1940
-			if ($globalDebug) echo "Gunzip...";
2394
+			if ($globalDebug) {
2395
+				echo "Gunzip...";
2396
+			}
1941 2397
 			update_db::gunzip($tmp_dir.'modes.tsv.gz');
1942
-			if ($globalDebug) echo "Add to DB...";
2398
+			if ($globalDebug) {
2399
+				echo "Add to DB...";
2400
+			}
1943 2401
 			$error = update_db::modes_fam();
1944
-		} else $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed.";
2402
+		} else {
2403
+			$error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed.";
2404
+		}
1945 2405
 		if ($error != '') {
1946 2406
 			return $error;
1947
-		} elseif ($globalDebug) echo "Done\n";
2407
+		} elseif ($globalDebug) {
2408
+			echo "Done\n";
2409
+		}
1948 2410
 		return '';
1949 2411
 	}
1950 2412
 	public static function update_owner_fam() {
1951 2413
 		global $tmp_dir, $globalDebug, $globalOwner;
1952
-		if ($globalDebug) echo "owner from FlightAirMap website : Download...";
2414
+		if ($globalDebug) {
2415
+			echo "owner from FlightAirMap website : Download...";
2416
+		}
1953 2417
 		if ($globalOwner === TRUE) {
1954 2418
 			update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz');
1955 2419
 		} else {
1956 2420
 			update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz',$tmp_dir.'owners.tsv.gz');
1957 2421
 		}
1958 2422
 		if (file_exists($tmp_dir.'owners.tsv.gz')) {
1959
-			if ($globalDebug) echo "Gunzip...";
2423
+			if ($globalDebug) {
2424
+				echo "Gunzip...";
2425
+			}
1960 2426
 			update_db::gunzip($tmp_dir.'owners.tsv.gz');
1961
-			if ($globalDebug) echo "Add to DB...";
2427
+			if ($globalDebug) {
2428
+				echo "Add to DB...";
2429
+			}
1962 2430
 			$error = update_db::owner_fam();
1963
-		} else $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed.";
2431
+		} else {
2432
+			$error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed.";
2433
+		}
1964 2434
 		if ($error != '') {
1965 2435
 			return $error;
1966
-		} elseif ($globalDebug) echo "Done\n";
2436
+		} elseif ($globalDebug) {
2437
+			echo "Done\n";
2438
+		}
1967 2439
 		return '';
1968 2440
 	}
1969 2441
 	public static function update_routes_fam() {
1970 2442
 		global $tmp_dir, $globalDebug;
1971
-		if ($globalDebug) echo "Routes from FlightAirMap website : Download...";
2443
+		if ($globalDebug) {
2444
+			echo "Routes from FlightAirMap website : Download...";
2445
+		}
1972 2446
 		update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz');
1973 2447
 		if (file_exists($tmp_dir.'routes.tsv.gz')) {
1974
-			if ($globalDebug) echo "Gunzip...";
2448
+			if ($globalDebug) {
2449
+				echo "Gunzip...";
2450
+			}
1975 2451
 			update_db::gunzip($tmp_dir.'routes.tsv.gz');
1976
-			if ($globalDebug) echo "Add to DB...";
2452
+			if ($globalDebug) {
2453
+				echo "Add to DB...";
2454
+			}
1977 2455
 			$error = update_db::routes_fam();
1978
-		} else $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed.";
2456
+		} else {
2457
+			$error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed.";
2458
+		}
1979 2459
 		if ($error != '') {
1980 2460
 			return $error;
1981
-		} elseif ($globalDebug) echo "Done\n";
2461
+		} elseif ($globalDebug) {
2462
+			echo "Done\n";
2463
+		}
1982 2464
 		return '';
1983 2465
 	}
1984 2466
 	public static function update_banned_fam() {
1985 2467
 		global $tmp_dir, $globalDebug;
1986
-		if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download...";
2468
+		if ($globalDebug) {
2469
+			echo "Banned airlines in Europe from FlightAirMap website : Download...";
2470
+		}
1987 2471
 		update_db::download('http://data.flightairmap.fr/data/ban_eu.csv',$tmp_dir.'ban_eu.csv');
1988 2472
 		if (file_exists($tmp_dir.'ban_eu.csv')) {
1989 2473
 			//if ($globalDebug) echo "Gunzip...";
1990 2474
 			//update_db::gunzip($tmp_dir.'ban_ue.csv');
1991
-			if ($globalDebug) echo "Add to DB...";
2475
+			if ($globalDebug) {
2476
+				echo "Add to DB...";
2477
+			}
1992 2478
 			$error = update_db::banned_fam();
1993
-		} else $error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed.";
2479
+		} else {
2480
+			$error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed.";
2481
+		}
1994 2482
 		if ($error != '') {
1995 2483
 			return $error;
1996
-		} elseif ($globalDebug) echo "Done\n";
2484
+		} elseif ($globalDebug) {
2485
+			echo "Done\n";
2486
+		}
1997 2487
 		return '';
1998 2488
 	}
1999 2489
 
@@ -2001,7 +2491,9 @@  discard block
 block discarded – undo
2001 2491
 		global $tmp_dir, $globalDebug, $globalDBdriver;
2002 2492
 		include_once('class.create_db.php');
2003 2493
 		$error = '';
2004
-		if ($globalDebug) echo "Airspace from FlightAirMap website : Download...";
2494
+		if ($globalDebug) {
2495
+			echo "Airspace from FlightAirMap website : Download...";
2496
+		}
2005 2497
 		if ($globalDBdriver == 'mysql') {
2006 2498
 			update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
2007 2499
 		} else {
@@ -2017,9 +2509,13 @@  discard block
 block discarded – undo
2017 2509
 					update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz');
2018 2510
 				}
2019 2511
 				if (file_exists($tmp_dir.'airspace.sql.gz')) {
2020
-					if ($globalDebug) echo "Gunzip...";
2512
+					if ($globalDebug) {
2513
+						echo "Gunzip...";
2514
+					}
2021 2515
 					update_db::gunzip($tmp_dir.'airspace.sql.gz');
2022
-					if ($globalDebug) echo "Add to DB...";
2516
+					if ($globalDebug) {
2517
+						echo "Add to DB...";
2518
+					}
2023 2519
 					$Connection = new Connection();
2024 2520
 					if ($Connection->tableExists('airspace')) {
2025 2521
 						$query = 'DROP TABLE airspace';
@@ -2032,31 +2528,47 @@  discard block
 block discarded – undo
2032 2528
 		    			}
2033 2529
 					$error = create_db::import_file($tmp_dir.'airspace.sql');
2034 2530
 					update_db::insert_airspace_version($airspace_md5);
2035
-				} else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed.";
2531
+				} else {
2532
+					$error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed.";
2533
+				}
2036 2534
 			}
2037
-		} else $error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed.";
2535
+		} else {
2536
+			$error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed.";
2537
+		}
2038 2538
 		if ($error != '') {
2039 2539
 			return $error;
2040
-		} elseif ($globalDebug) echo "Done\n";
2540
+		} elseif ($globalDebug) {
2541
+			echo "Done\n";
2542
+		}
2041 2543
 		return '';
2042 2544
 	}
2043 2545
 
2044 2546
 	public static function update_tle() {
2045 2547
 		global $tmp_dir, $globalDebug;
2046
-		if ($globalDebug) echo "Download TLE : Download...";
2548
+		if ($globalDebug) {
2549
+			echo "Download TLE : Download...";
2550
+		}
2047 2551
 		$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',
2048 2552
 		'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',
2049 2553
 		'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt');
2050 2554
 		foreach ($alltle as $filename) {
2051
-			if ($globalDebug) echo "downloading ".$filename.'...';
2555
+			if ($globalDebug) {
2556
+				echo "downloading ".$filename.'...';
2557
+			}
2052 2558
 			update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename);
2053 2559
 			if (file_exists($tmp_dir.$filename)) {
2054
-				if ($globalDebug) echo "Add to DB ".$filename."...";
2560
+				if ($globalDebug) {
2561
+					echo "Add to DB ".$filename."...";
2562
+				}
2055 2563
 				$error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename));
2056
-			} else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
2564
+			} else {
2565
+				$error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
2566
+			}
2057 2567
 			if ($error != '') {
2058 2568
 				echo $error."\n";
2059
-			} elseif ($globalDebug) echo "Done\n";
2569
+			} elseif ($globalDebug) {
2570
+				echo "Done\n";
2571
+			}
2060 2572
 		}
2061 2573
 		return '';
2062 2574
 	}
@@ -2064,10 +2576,14 @@  discard block
 block discarded – undo
2064 2576
 	public static function update_models() {
2065 2577
 		global $tmp_dir, $globalDebug;
2066 2578
 		$error = '';
2067
-		if ($globalDebug) echo "Models from FlightAirMap website : Download...";
2579
+		if ($globalDebug) {
2580
+			echo "Models from FlightAirMap website : Download...";
2581
+		}
2068 2582
 		update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum');
2069 2583
 		if (file_exists($tmp_dir.'models.md5sum')) {
2070
-			if ($globalDebug) echo "Check files...\n";
2584
+			if ($globalDebug) {
2585
+				echo "Check files...\n";
2586
+			}
2071 2587
 			$newmodelsdb = array();
2072 2588
 			if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) {
2073 2589
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2086,25 +2602,35 @@  discard block
 block discarded – undo
2086 2602
 			}
2087 2603
 			$diff = array_diff($newmodelsdb,$modelsdb);
2088 2604
 			foreach ($diff as $key => $value) {
2089
-				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
2605
+				if ($globalDebug) {
2606
+					echo 'Downloading model '.$key.' ...'."\n";
2607
+				}
2090 2608
 				update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key);
2091 2609
 				
2092 2610
 			}
2093 2611
 			update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum');
2094
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2612
+		} else {
2613
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2614
+		}
2095 2615
 		if ($error != '') {
2096 2616
 			return $error;
2097
-		} elseif ($globalDebug) echo "Done\n";
2617
+		} elseif ($globalDebug) {
2618
+			echo "Done\n";
2619
+		}
2098 2620
 		return '';
2099 2621
 	}
2100 2622
 
2101 2623
 	public static function update_space_models() {
2102 2624
 		global $tmp_dir, $globalDebug;
2103 2625
 		$error = '';
2104
-		if ($globalDebug) echo "Space models from FlightAirMap website : Download...";
2626
+		if ($globalDebug) {
2627
+			echo "Space models from FlightAirMap website : Download...";
2628
+		}
2105 2629
 		update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum');
2106 2630
 		if (file_exists($tmp_dir.'space_models.md5sum')) {
2107
-			if ($globalDebug) echo "Check files...\n";
2631
+			if ($globalDebug) {
2632
+				echo "Check files...\n";
2633
+			}
2108 2634
 			$newmodelsdb = array();
2109 2635
 			if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) {
2110 2636
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2123,25 +2649,35 @@  discard block
 block discarded – undo
2123 2649
 			}
2124 2650
 			$diff = array_diff($newmodelsdb,$modelsdb);
2125 2651
 			foreach ($diff as $key => $value) {
2126
-				if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n";
2652
+				if ($globalDebug) {
2653
+					echo 'Downloading space model '.$key.' ...'."\n";
2654
+				}
2127 2655
 				update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key);
2128 2656
 				
2129 2657
 			}
2130 2658
 			update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum');
2131
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2659
+		} else {
2660
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2661
+		}
2132 2662
 		if ($error != '') {
2133 2663
 			return $error;
2134
-		} elseif ($globalDebug) echo "Done\n";
2664
+		} elseif ($globalDebug) {
2665
+			echo "Done\n";
2666
+		}
2135 2667
 		return '';
2136 2668
 	}
2137 2669
 
2138 2670
 	public static function update_vehicules_models() {
2139 2671
 		global $tmp_dir, $globalDebug;
2140 2672
 		$error = '';
2141
-		if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download...";
2673
+		if ($globalDebug) {
2674
+			echo "Vehicules models from FlightAirMap website : Download...";
2675
+		}
2142 2676
 		update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum');
2143 2677
 		if (file_exists($tmp_dir.'vehicules_models.md5sum')) {
2144
-			if ($globalDebug) echo "Check files...\n";
2678
+			if ($globalDebug) {
2679
+				echo "Check files...\n";
2680
+			}
2145 2681
 			$newmodelsdb = array();
2146 2682
 			if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) {
2147 2683
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2160,15 +2696,21 @@  discard block
 block discarded – undo
2160 2696
 			}
2161 2697
 			$diff = array_diff($newmodelsdb,$modelsdb);
2162 2698
 			foreach ($diff as $key => $value) {
2163
-				if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n";
2699
+				if ($globalDebug) {
2700
+					echo 'Downloading vehicules model '.$key.' ...'."\n";
2701
+				}
2164 2702
 				update_db::download('http://data.flightairmap.fr/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key);
2165 2703
 				
2166 2704
 			}
2167 2705
 			update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum');
2168
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2706
+		} else {
2707
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2708
+		}
2169 2709
 		if ($error != '') {
2170 2710
 			return $error;
2171
-		} elseif ($globalDebug) echo "Done\n";
2711
+		} elseif ($globalDebug) {
2712
+			echo "Done\n";
2713
+		}
2172 2714
 		return '';
2173 2715
 	}
2174 2716
 
@@ -2211,7 +2753,9 @@  discard block
 block discarded – undo
2211 2753
                 }
2212 2754
 
2213 2755
 		$error = '';
2214
-		if ($globalDebug) echo "Notam : Download...";
2756
+		if ($globalDebug) {
2757
+			echo "Notam : Download...";
2758
+		}
2215 2759
 		update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss');
2216 2760
 		if (file_exists($tmp_dir.'notam.rss')) {
2217 2761
 			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true);
@@ -2226,14 +2770,30 @@  discard block
 block discarded – undo
2226 2770
 				$data['fir'] = $q[0];
2227 2771
 				$data['code'] = $q[1];
2228 2772
 				$ifrvfr = $q[2];
2229
-				if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR';
2230
-				if ($ifrvfr == 'I') $data['rules'] = 'IFR';
2231
-				if ($ifrvfr == 'V') $data['rules'] = 'VFR';
2232
-				if ($q[4] == 'A') $data['scope'] = 'Airport warning';
2233
-				if ($q[4] == 'E') $data['scope'] = 'Enroute warning';
2234
-				if ($q[4] == 'W') $data['scope'] = 'Navigation warning';
2235
-				if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning';
2236
-				if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning';
2773
+				if ($ifrvfr == 'IV') {
2774
+					$data['rules'] = 'IFR/VFR';
2775
+				}
2776
+				if ($ifrvfr == 'I') {
2777
+					$data['rules'] = 'IFR';
2778
+				}
2779
+				if ($ifrvfr == 'V') {
2780
+					$data['rules'] = 'VFR';
2781
+				}
2782
+				if ($q[4] == 'A') {
2783
+					$data['scope'] = 'Airport warning';
2784
+				}
2785
+				if ($q[4] == 'E') {
2786
+					$data['scope'] = 'Enroute warning';
2787
+				}
2788
+				if ($q[4] == 'W') {
2789
+					$data['scope'] = 'Navigation warning';
2790
+				}
2791
+				if ($q[4] == 'AE') {
2792
+					$data['scope'] = 'Airport/Enroute warning';
2793
+				}
2794
+				if ($q[4] == 'AW') {
2795
+					$data['scope'] = 'Airport/Navigation warning';
2796
+				}
2237 2797
 				//$data['scope'] = $q[4];
2238 2798
 				$data['lower_limit'] = $q[5];
2239 2799
 				$data['upper_limit'] = $q[6];
@@ -2241,8 +2801,12 @@  discard block
 block discarded – undo
2241 2801
 				sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius);
2242 2802
 				$latitude = $Common->convertDec($las,'latitude');
2243 2803
 				$longitude = $Common->convertDec($lns,'longitude');
2244
-				if ($lac == 'S') $latitude = '-'.$latitude;
2245
-				if ($lnc == 'W') $longitude = '-'.$longitude;
2804
+				if ($lac == 'S') {
2805
+					$latitude = '-'.$latitude;
2806
+				}
2807
+				if ($lnc == 'W') {
2808
+					$longitude = '-'.$longitude;
2809
+				}
2246 2810
 				$data['center_latitude'] = $latitude;
2247 2811
 				$data['center_longitude'] = $longitude;
2248 2812
 				$data['radius'] = intval($radius);
@@ -2272,10 +2836,14 @@  discard block
 block discarded – undo
2272 2836
 				$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']);
2273 2837
 				unset($data);
2274 2838
 			} 
2275
-		} else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
2839
+		} else {
2840
+			$error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
2841
+		}
2276 2842
 		if ($error != '') {
2277 2843
 			return $error;
2278
-		} elseif ($globalDebug) echo "Done\n";
2844
+		} elseif ($globalDebug) {
2845
+			echo "Done\n";
2846
+		}
2279 2847
 		return '';
2280 2848
 	}
2281 2849
 	
@@ -2300,7 +2868,9 @@  discard block
 block discarded – undo
2300 2868
 		$airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json');
2301 2869
 		$airspace_json = json_decode($airspace_lst,true);
2302 2870
 		foreach ($airspace_json['records'] as $airspace) {
2303
-			if ($globalDebug) echo $airspace['name']."...\n";
2871
+			if ($globalDebug) {
2872
+				echo $airspace['name']."...\n";
2873
+			}
2304 2874
 			update_db::download($airspace['uri'],$tmp_dir.$airspace['name']);
2305 2875
 			if (file_exists($tmp_dir.$airspace['name'])) {
2306 2876
 				file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name'])));
@@ -2344,8 +2914,11 @@  discard block
 block discarded – undo
2344 2914
                         return "error : ".$e->getMessage();
2345 2915
                 }
2346 2916
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2347
-                if ($row['nb'] > 0) return false;
2348
-                else return true;
2917
+                if ($row['nb'] > 0) {
2918
+                	return false;
2919
+                } else {
2920
+                	return true;
2921
+                }
2349 2922
 	}
2350 2923
 
2351 2924
 	public static function insert_last_update() {
@@ -2370,8 +2943,11 @@  discard block
 block discarded – undo
2370 2943
                         return "error : ".$e->getMessage();
2371 2944
                 }
2372 2945
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2373
-                if ($row['nb'] > 0) return true;
2374
-                else return false;
2946
+                if ($row['nb'] > 0) {
2947
+                	return true;
2948
+                } else {
2949
+                	return false;
2950
+                }
2375 2951
 	}
2376 2952
 
2377 2953
 
@@ -2402,8 +2978,11 @@  discard block
 block discarded – undo
2402 2978
                         return "error : ".$e->getMessage();
2403 2979
                 }
2404 2980
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2405
-                if ($row['nb'] > 0) return false;
2406
-                else return true;
2981
+                if ($row['nb'] > 0) {
2982
+                	return false;
2983
+                } else {
2984
+                	return true;
2985
+                }
2407 2986
 	}
2408 2987
 
2409 2988
 	public static function insert_last_notam_update() {
@@ -2432,8 +3011,11 @@  discard block
 block discarded – undo
2432 3011
                         return "error : ".$e->getMessage();
2433 3012
                 }
2434 3013
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2435
-                if ($row['nb'] > 0) return false;
2436
-                else return true;
3014
+                if ($row['nb'] > 0) {
3015
+                	return false;
3016
+                } else {
3017
+                	return true;
3018
+                }
2437 3019
 	}
2438 3020
 
2439 3021
 	public static function insert_last_airspace_update() {
@@ -2463,8 +3045,11 @@  discard block
 block discarded – undo
2463 3045
                         return "error : ".$e->getMessage();
2464 3046
                 }
2465 3047
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2466
-                if ($row['nb'] > 0) return false;
2467
-                else return true;
3048
+                if ($row['nb'] > 0) {
3049
+                	return false;
3050
+                } else {
3051
+                	return true;
3052
+                }
2468 3053
 	}
2469 3054
 
2470 3055
 	public static function insert_last_owner_update() {
@@ -2493,8 +3078,11 @@  discard block
 block discarded – undo
2493 3078
                         return "error : ".$e->getMessage();
2494 3079
                 }
2495 3080
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2496
-                if ($row['nb'] > 0) return false;
2497
-                else return true;
3081
+                if ($row['nb'] > 0) {
3082
+                	return false;
3083
+                } else {
3084
+                	return true;
3085
+                }
2498 3086
 	}
2499 3087
 
2500 3088
 	public static function insert_last_schedules_update() {
@@ -2523,8 +3111,11 @@  discard block
 block discarded – undo
2523 3111
                         return "error : ".$e->getMessage();
2524 3112
                 }
2525 3113
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2526
-                if ($row['nb'] > 0) return false;
2527
-                else return true;
3114
+                if ($row['nb'] > 0) {
3115
+                	return false;
3116
+                } else {
3117
+                	return true;
3118
+                }
2528 3119
 	}
2529 3120
 
2530 3121
 	public static function insert_last_tle_update() {
Please login to merge, or discard this patch.
install/class.update_schema.php 1 patch
Braces   +323 added lines, -120 removed lines patch added patch discarded remove patch
@@ -258,7 +258,9 @@  discard block
 block discarded – undo
258 258
     		// Update table countries
259 259
     		if ($Connection->tableExists('airspace')) {
260 260
     		    $error .= update_db::update_countries();
261
-		    if ($error != '') return $error;
261
+		    if ($error != '') {
262
+		    	return $error;
263
+		    }
262 264
 		}
263 265
 		// Update schema_version to 7
264 266
 		$query = "UPDATE `config` SET `value` = '7' WHERE `name` = 'schema_version'";
@@ -314,7 +316,9 @@  discard block
 block discarded – undo
314 316
     		$error = '';
315 317
     		// Update table aircraft
316 318
 		$error .= create_db::import_file('../db/source_location.sql');
317
-		if ($error != '') return $error;
319
+		if ($error != '') {
320
+			return $error;
321
+		}
318 322
 		// Update schema_version to 6
319 323
 		$query = "UPDATE `config` SET `value` = '8' WHERE `name` = 'schema_version'";
320 324
         	try {
@@ -331,7 +335,9 @@  discard block
 block discarded – undo
331 335
     		$error = '';
332 336
     		// Update table aircraft
333 337
 		$error .= create_db::import_file('../db/notam.sql');
334
-		if ($error != '') return $error;
338
+		if ($error != '') {
339
+			return $error;
340
+		}
335 341
 		$query = "DELETE FROM config WHERE name = 'last_update_db';
336 342
                         INSERT INTO config (name,value) VALUES ('last_update_db',NOW());
337 343
                         DELETE FROM config WHERE name = 'last_update_notam_db';
@@ -365,7 +371,9 @@  discard block
 block discarded – undo
365 371
 		$error = '';
366 372
     		// Update table atc
367 373
 		$error .= create_db::import_file('../db/atc.sql');
368
-		if ($error != '') return $error;
374
+		if ($error != '') {
375
+			return $error;
376
+		}
369 377
 		
370 378
 		$query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'";
371 379
         	try {
@@ -389,13 +397,21 @@  discard block
 block discarded – undo
389 397
 		$error = '';
390 398
     		// Add tables
391 399
 		$error .= create_db::import_file('../db/aircraft_owner.sql');
392
-		if ($error != '') return $error;
400
+		if ($error != '') {
401
+			return $error;
402
+		}
393 403
 		$error .= create_db::import_file('../db/metar.sql');
394
-		if ($error != '') return $error;
404
+		if ($error != '') {
405
+			return $error;
406
+		}
395 407
 		$error .= create_db::import_file('../db/taf.sql');
396
-		if ($error != '') return $error;
408
+		if ($error != '') {
409
+			return $error;
410
+		}
397 411
 		$error .= create_db::import_file('../db/airport.sql');
398
-		if ($error != '') return $error;
412
+		if ($error != '') {
413
+			return $error;
414
+		}
399 415
 		
400 416
 		$query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'";
401 417
         	try {
@@ -469,19 +485,33 @@  discard block
 block discarded – undo
469 485
 		$error = '';
470 486
     		// Add tables
471 487
 		$error .= create_db::import_file('../db/stats.sql');
472
-		if ($error != '') return $error;
488
+		if ($error != '') {
489
+			return $error;
490
+		}
473 491
 		$error .= create_db::import_file('../db/stats_aircraft.sql');
474
-		if ($error != '') return $error;
492
+		if ($error != '') {
493
+			return $error;
494
+		}
475 495
 		$error .= create_db::import_file('../db/stats_airline.sql');
476
-		if ($error != '') return $error;
496
+		if ($error != '') {
497
+			return $error;
498
+		}
477 499
 		$error .= create_db::import_file('../db/stats_airport.sql');
478
-		if ($error != '') return $error;
500
+		if ($error != '') {
501
+			return $error;
502
+		}
479 503
 		$error .= create_db::import_file('../db/stats_owner.sql');
480
-		if ($error != '') return $error;
504
+		if ($error != '') {
505
+			return $error;
506
+		}
481 507
 		$error .= create_db::import_file('../db/stats_pilot.sql');
482
-		if ($error != '') return $error;
508
+		if ($error != '') {
509
+			return $error;
510
+		}
483 511
 		$error .= create_db::import_file('../db/spotter_archive_output.sql');
484
-		if ($error != '') return $error;
512
+		if ($error != '') {
513
+			return $error;
514
+		}
485 515
 		
486 516
 		$query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'";
487 517
         	try {
@@ -521,7 +551,9 @@  discard block
 block discarded – undo
521 551
     		// Add tables
522 552
     		if (!$Connection->tableExists('stats_flight')) {
523 553
 			$error .= create_db::import_file('../db/stats_flight.sql');
524
-			if ($error != '') return $error;
554
+			if ($error != '') {
555
+				return $error;
556
+			}
525 557
 		}
526 558
 		$query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'";
527 559
         	try {
@@ -545,7 +577,9 @@  discard block
 block discarded – undo
545 577
     		} catch(PDOException $e) {
546 578
 		    return "error (update stats) : ".$e->getMessage()."\n";
547 579
     		}
548
-		if ($error != '') return $error;
580
+		if ($error != '') {
581
+			return $error;
582
+		}
549 583
 		$query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'";
550 584
         	try {
551 585
             	    $sth = $Connection->db->prepare($query);
@@ -566,7 +600,9 @@  discard block
 block discarded – undo
566 600
     		if (!$Connection->tableExists('stats_callsign')) {
567 601
 			$error .= create_db::import_file('../db/stats_callsign.sql');
568 602
 		}
569
-		if ($error != '') return $error;
603
+		if ($error != '') {
604
+			return $error;
605
+		}
570 606
 		$query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'";
571 607
         	try {
572 608
             	    $sth = $Connection->db->prepare($query);
@@ -584,7 +620,9 @@  discard block
 block discarded – undo
584 620
     		if (!$Connection->tableExists('stats_country')) {
585 621
 			$error .= create_db::import_file('../db/stats_country.sql');
586 622
 		}
587
-		if ($error != '') return $error;
623
+		if ($error != '') {
624
+			return $error;
625
+		}
588 626
 		$query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'";
589 627
         	try {
590 628
             	    $sth = $Connection->db->prepare($query);
@@ -607,7 +645,9 @@  discard block
 block discarded – undo
607 645
 			    return "error (update stats) : ".$e->getMessage()."\n";
608 646
     			}
609 647
     		}
610
-		if ($error != '') return $error;
648
+		if ($error != '') {
649
+			return $error;
650
+		}
611 651
 		$query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'";
612 652
         	try {
613 653
             	    $sth = $Connection->db->prepare($query);
@@ -623,7 +663,9 @@  discard block
 block discarded – undo
623 663
 		$error = '';
624 664
     		// Update airport table
625 665
 		$error .= create_db::import_file('../db/airport.sql');
626
-		if ($error != '') return 'Import airport.sql : '.$error;
666
+		if ($error != '') {
667
+			return 'Import airport.sql : '.$error;
668
+		}
627 669
 		// Remove primary key on Spotter_Archive
628 670
 		$query = "alter table spotter_archive drop spotter_archive_id";
629 671
         	try {
@@ -699,7 +741,9 @@  discard block
 block discarded – undo
699 741
 				return "error (add source_name column) : ".$e->getMessage()."\n";
700 742
     			}
701 743
     		}
702
-		if ($error != '') return $error;
744
+		if ($error != '') {
745
+			return $error;
746
+		}
703 747
 		$query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'";
704 748
         	try {
705 749
             	    $sth = $Connection->db->prepare($query);
@@ -717,7 +761,9 @@  discard block
 block discarded – undo
717 761
     		// Update airline table
718 762
     		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
719 763
 			$error .= create_db::import_file('../db/airlines.sql');
720
-			if ($error != '') return 'Import airlines.sql : '.$error;
764
+			if ($error != '') {
765
+				return 'Import airlines.sql : '.$error;
766
+			}
721 767
 		}
722 768
 		if (!$Connection->checkColumnName('aircraft_modes','type_flight')) {
723 769
 			// Add column over_country
@@ -729,7 +775,9 @@  discard block
 block discarded – undo
729 775
 				return "error (add over_country) : ".$e->getMessage()."\n";
730 776
     			}
731 777
     		}
732
-		if ($error != '') return $error;
778
+		if ($error != '') {
779
+			return $error;
780
+		}
733 781
 		/*
734 782
     		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
735 783
 			// Force update ModeS (this will put type_flight data
@@ -759,7 +807,9 @@  discard block
 block discarded – undo
759 807
 			} catch(PDOException $e) {
760 808
 				return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n";
761 809
 			}
762
-			if ($error != '') return $error;
810
+			if ($error != '') {
811
+				return $error;
812
+			}
763 813
 		}
764 814
 		$query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'";
765 815
         	try {
@@ -782,7 +832,9 @@  discard block
 block discarded – undo
782 832
 			} else {
783 833
 				$error .= create_db::import_file('../db/pgsql/stats_source.sql');
784 834
 			}
785
-			if ($error != '') return $error;
835
+			if ($error != '') {
836
+				return $error;
837
+			}
786 838
 		}
787 839
 		$query = "UPDATE config SET value = '23' WHERE name = 'schema_version'";
788 840
         	try {
@@ -804,12 +856,16 @@  discard block
 block discarded – undo
804 856
 		if ($globalDBdriver == 'mysql') {
805 857
 			if (!$Connection->tableExists('tle')) {
806 858
 				$error .= create_db::import_file('../db/tle.sql');
807
-				if ($error != '') return $error;
859
+				if ($error != '') {
860
+					return $error;
861
+				}
808 862
 			}
809 863
 		} else {
810 864
 			if (!$Connection->tableExists('tle')) {
811 865
 				$error .= create_db::import_file('../db/pgsql/tle.sql');
812
-				if ($error != '') return $error;
866
+				if ($error != '') {
867
+					return $error;
868
+				}
813 869
 			}
814 870
 			$query = "create index flightaware_id_idx ON spotter_archive USING btree(flightaware_id)";
815 871
 			try {
@@ -849,7 +905,9 @@  discard block
 block discarded – undo
849 905
 		} else {
850 906
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
851 907
 		}
852
-		if ($error != '') return 'Import airlines.sql : '.$error;
908
+		if ($error != '') {
909
+			return 'Import airlines.sql : '.$error;
910
+		}
853 911
 		if (!$Connection->checkColumnName('airlines','forsource')) {
854 912
 			// Add forsource to airlines
855 913
 			$query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL";
@@ -1332,20 +1390,28 @@  discard block
 block discarded – undo
1332 1390
 		}
1333 1391
 		if ($globalDBdriver == 'mysql') {
1334 1392
 			$error .= create_db::import_file('../db/airlines.sql');
1335
-			if ($error != '') return $error;
1393
+			if ($error != '') {
1394
+				return $error;
1395
+			}
1336 1396
 		} else {
1337 1397
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
1338
-			if ($error != '') return $error;
1398
+			if ($error != '') {
1399
+				return $error;
1400
+			}
1339 1401
 		}
1340 1402
 		if ((isset($globalVATSIM) && $globalVATSIM) || (isset($globalIVAO) && $globalIVAO)) {
1341 1403
 			include_once(dirname(__FILE__).'/class.update_db.php');
1342 1404
 			if (isset($globalVATSIM) && $globalVATSIM) {
1343 1405
 				$error .= update_db::update_vatsim();
1344
-				if ($error != '') return $error;
1406
+				if ($error != '') {
1407
+					return $error;
1408
+				}
1345 1409
 			}
1346 1410
 			if (isset($globalIVAO) && $globalIVAO && file_exists('tmp/ivae_feb2013.zip')) {
1347 1411
 				$error .= update_db::update_IVAO();
1348
-				if ($error != '') return $error;
1412
+				if ($error != '') {
1413
+					return $error;
1414
+				}
1349 1415
 			}
1350 1416
 		}
1351 1417
 
@@ -1607,30 +1673,54 @@  discard block
 block discarded – undo
1607 1673
 		*/
1608 1674
 		if ($globalDBdriver == 'mysql') {
1609 1675
 			$error .= create_db::import_file('../db/tracker_output.sql');
1610
-			if ($error != '') return $error;
1676
+			if ($error != '') {
1677
+				return $error;
1678
+			}
1611 1679
 			$error .= create_db::import_file('../db/tracker_live.sql');
1612
-			if ($error != '') return $error;
1680
+			if ($error != '') {
1681
+				return $error;
1682
+			}
1613 1683
 			$error .= create_db::import_file('../db/marine_output.sql');
1614
-			if ($error != '') return $error;
1684
+			if ($error != '') {
1685
+				return $error;
1686
+			}
1615 1687
 			$error .= create_db::import_file('../db/marine_live.sql');
1616
-			if ($error != '') return $error;
1688
+			if ($error != '') {
1689
+				return $error;
1690
+			}
1617 1691
 			$error .= create_db::import_file('../db/marine_identity.sql');
1618
-			if ($error != '') return $error;
1692
+			if ($error != '') {
1693
+				return $error;
1694
+			}
1619 1695
 			$error .= create_db::import_file('../db/marine_mid.sql');
1620
-			if ($error != '') return $error;
1696
+			if ($error != '') {
1697
+				return $error;
1698
+			}
1621 1699
 		} else {
1622 1700
 			$error .= create_db::import_file('../db/pgsql/tracker_output.sql');
1623
-			if ($error != '') return $error;
1701
+			if ($error != '') {
1702
+				return $error;
1703
+			}
1624 1704
 			$error .= create_db::import_file('../db/pgsql/tracker_live.sql');
1625
-			if ($error != '') return $error;
1705
+			if ($error != '') {
1706
+				return $error;
1707
+			}
1626 1708
 			$error .= create_db::import_file('../db/pgsql/marine_output.sql');
1627
-			if ($error != '') return $error;
1709
+			if ($error != '') {
1710
+				return $error;
1711
+			}
1628 1712
 			$error .= create_db::import_file('../db/pgsql/marine_live.sql');
1629
-			if ($error != '') return $error;
1713
+			if ($error != '') {
1714
+				return $error;
1715
+			}
1630 1716
 			$error .= create_db::import_file('../db/pgsql/marine_identity.sql');
1631
-			if ($error != '') return $error;
1717
+			if ($error != '') {
1718
+				return $error;
1719
+			}
1632 1720
 			$error .= create_db::import_file('../db/pgsql/marine_mid.sql');
1633
-			if ($error != '') return $error;
1721
+			if ($error != '') {
1722
+				return $error;
1723
+			}
1634 1724
 		}
1635 1725
 		$query = "UPDATE config SET value = '37' WHERE name = 'schema_version'";
1636 1726
 		try {
@@ -1650,8 +1740,11 @@  discard block
 block discarded – undo
1650 1740
     	    if ($Connection->tableExists('aircraft')) {
1651 1741
     		if (!$Connection->tableExists('config')) {
1652 1742
     		    $version = '1';
1653
-    		    if ($update) return self::update_from_1();
1654
-    		    else return $version;
1743
+    		    if ($update) {
1744
+    		    	return self::update_from_1();
1745
+    		    } else {
1746
+    		    	return $version;
1747
+    		    }
1655 1748
 		} else {
1656 1749
     		    $Connection = new Connection();
1657 1750
 		    $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
@@ -1665,150 +1758,260 @@  discard block
 block discarded – undo
1665 1758
     		    if ($update) {
1666 1759
     			if ($result['value'] == '2') {
1667 1760
     			    $error = self::update_from_2();
1668
-    			    if ($error != '') return $error;
1669
-    			    else return self::check_version(true);
1761
+    			    if ($error != '') {
1762
+    			    	return $error;
1763
+    			    } else {
1764
+    			    	return self::check_version(true);
1765
+    			    }
1670 1766
     			} elseif ($result['value'] == '3') {
1671 1767
     			    $error = self::update_from_3();
1672
-    			    if ($error != '') return $error;
1673
-    			    else return self::check_version(true);
1768
+    			    if ($error != '') {
1769
+    			    	return $error;
1770
+    			    } else {
1771
+    			    	return self::check_version(true);
1772
+    			    }
1674 1773
     			} elseif ($result['value'] == '4') {
1675 1774
     			    $error = self::update_from_4();
1676
-    			    if ($error != '') return $error;
1677
-    			    else return self::check_version(true);
1775
+    			    if ($error != '') {
1776
+    			    	return $error;
1777
+    			    } else {
1778
+    			    	return self::check_version(true);
1779
+    			    }
1678 1780
     			} elseif ($result['value'] == '5') {
1679 1781
     			    $error = self::update_from_5();
1680
-    			    if ($error != '') return $error;
1681
-    			    else return self::check_version(true);
1782
+    			    if ($error != '') {
1783
+    			    	return $error;
1784
+    			    } else {
1785
+    			    	return self::check_version(true);
1786
+    			    }
1682 1787
     			} elseif ($result['value'] == '6') {
1683 1788
     			    $error = self::update_from_6();
1684
-    			    if ($error != '') return $error;
1685
-    			    else return self::check_version(true);
1789
+    			    if ($error != '') {
1790
+    			    	return $error;
1791
+    			    } else {
1792
+    			    	return self::check_version(true);
1793
+    			    }
1686 1794
     			} elseif ($result['value'] == '7') {
1687 1795
     			    $error = self::update_from_7();
1688
-    			    if ($error != '') return $error;
1689
-    			    else return self::check_version(true);
1796
+    			    if ($error != '') {
1797
+    			    	return $error;
1798
+    			    } else {
1799
+    			    	return self::check_version(true);
1800
+    			    }
1690 1801
     			} elseif ($result['value'] == '8') {
1691 1802
     			    $error = self::update_from_8();
1692
-    			    if ($error != '') return $error;
1693
-    			    else return self::check_version(true);
1803
+    			    if ($error != '') {
1804
+    			    	return $error;
1805
+    			    } else {
1806
+    			    	return self::check_version(true);
1807
+    			    }
1694 1808
     			} elseif ($result['value'] == '9') {
1695 1809
     			    $error = self::update_from_9();
1696
-    			    if ($error != '') return $error;
1697
-    			    else return self::check_version(true);
1810
+    			    if ($error != '') {
1811
+    			    	return $error;
1812
+    			    } else {
1813
+    			    	return self::check_version(true);
1814
+    			    }
1698 1815
     			} elseif ($result['value'] == '10') {
1699 1816
     			    $error = self::update_from_10();
1700
-    			    if ($error != '') return $error;
1701
-    			    else return self::check_version(true);
1817
+    			    if ($error != '') {
1818
+    			    	return $error;
1819
+    			    } else {
1820
+    			    	return self::check_version(true);
1821
+    			    }
1702 1822
     			} elseif ($result['value'] == '11') {
1703 1823
     			    $error = self::update_from_11();
1704
-    			    if ($error != '') return $error;
1705
-    			    else return self::check_version(true);
1824
+    			    if ($error != '') {
1825
+    			    	return $error;
1826
+    			    } else {
1827
+    			    	return self::check_version(true);
1828
+    			    }
1706 1829
     			} elseif ($result['value'] == '12') {
1707 1830
     			    $error = self::update_from_12();
1708
-    			    if ($error != '') return $error;
1709
-    			    else return self::check_version(true);
1831
+    			    if ($error != '') {
1832
+    			    	return $error;
1833
+    			    } else {
1834
+    			    	return self::check_version(true);
1835
+    			    }
1710 1836
     			} elseif ($result['value'] == '13') {
1711 1837
     			    $error = self::update_from_13();
1712
-    			    if ($error != '') return $error;
1713
-    			    else return self::check_version(true);
1838
+    			    if ($error != '') {
1839
+    			    	return $error;
1840
+    			    } else {
1841
+    			    	return self::check_version(true);
1842
+    			    }
1714 1843
     			} elseif ($result['value'] == '14') {
1715 1844
     			    $error = self::update_from_14();
1716
-    			    if ($error != '') return $error;
1717
-    			    else return self::check_version(true);
1845
+    			    if ($error != '') {
1846
+    			    	return $error;
1847
+    			    } else {
1848
+    			    	return self::check_version(true);
1849
+    			    }
1718 1850
     			} elseif ($result['value'] == '15') {
1719 1851
     			    $error = self::update_from_15();
1720
-    			    if ($error != '') return $error;
1721
-    			    else return self::check_version(true);
1852
+    			    if ($error != '') {
1853
+    			    	return $error;
1854
+    			    } else {
1855
+    			    	return self::check_version(true);
1856
+    			    }
1722 1857
     			} elseif ($result['value'] == '16') {
1723 1858
     			    $error = self::update_from_16();
1724
-    			    if ($error != '') return $error;
1725
-    			    else return self::check_version(true);
1859
+    			    if ($error != '') {
1860
+    			    	return $error;
1861
+    			    } else {
1862
+    			    	return self::check_version(true);
1863
+    			    }
1726 1864
     			} elseif ($result['value'] == '17') {
1727 1865
     			    $error = self::update_from_17();
1728
-    			    if ($error != '') return $error;
1729
-    			    else return self::check_version(true);
1866
+    			    if ($error != '') {
1867
+    			    	return $error;
1868
+    			    } else {
1869
+    			    	return self::check_version(true);
1870
+    			    }
1730 1871
     			} elseif ($result['value'] == '18') {
1731 1872
     			    $error = self::update_from_18();
1732
-    			    if ($error != '') return $error;
1733
-    			    else return self::check_version(true);
1873
+    			    if ($error != '') {
1874
+    			    	return $error;
1875
+    			    } else {
1876
+    			    	return self::check_version(true);
1877
+    			    }
1734 1878
     			} elseif ($result['value'] == '19') {
1735 1879
     			    $error = self::update_from_19();
1736
-    			    if ($error != '') return $error;
1737
-    			    else return self::check_version(true);
1880
+    			    if ($error != '') {
1881
+    			    	return $error;
1882
+    			    } else {
1883
+    			    	return self::check_version(true);
1884
+    			    }
1738 1885
     			} elseif ($result['value'] == '20') {
1739 1886
     			    $error = self::update_from_20();
1740
-    			    if ($error != '') return $error;
1741
-    			    else return self::check_version(true);
1887
+    			    if ($error != '') {
1888
+    			    	return $error;
1889
+    			    } else {
1890
+    			    	return self::check_version(true);
1891
+    			    }
1742 1892
     			} elseif ($result['value'] == '21') {
1743 1893
     			    $error = self::update_from_21();
1744
-    			    if ($error != '') return $error;
1745
-    			    else return self::check_version(true);
1894
+    			    if ($error != '') {
1895
+    			    	return $error;
1896
+    			    } else {
1897
+    			    	return self::check_version(true);
1898
+    			    }
1746 1899
     			} elseif ($result['value'] == '22') {
1747 1900
     			    $error = self::update_from_22();
1748
-    			    if ($error != '') return $error;
1749
-    			    else return self::check_version(true);
1901
+    			    if ($error != '') {
1902
+    			    	return $error;
1903
+    			    } else {
1904
+    			    	return self::check_version(true);
1905
+    			    }
1750 1906
     			} elseif ($result['value'] == '23') {
1751 1907
     			    $error = self::update_from_23();
1752
-    			    if ($error != '') return $error;
1753
-    			    else return self::check_version(true);
1908
+    			    if ($error != '') {
1909
+    			    	return $error;
1910
+    			    } else {
1911
+    			    	return self::check_version(true);
1912
+    			    }
1754 1913
     			} elseif ($result['value'] == '24') {
1755 1914
     			    $error = self::update_from_24();
1756
-    			    if ($error != '') return $error;
1757
-    			    else return self::check_version(true);
1915
+    			    if ($error != '') {
1916
+    			    	return $error;
1917
+    			    } else {
1918
+    			    	return self::check_version(true);
1919
+    			    }
1758 1920
     			} elseif ($result['value'] == '25') {
1759 1921
     			    $error = self::update_from_25();
1760
-    			    if ($error != '') return $error;
1761
-    			    else return self::check_version(true);
1922
+    			    if ($error != '') {
1923
+    			    	return $error;
1924
+    			    } else {
1925
+    			    	return self::check_version(true);
1926
+    			    }
1762 1927
     			} elseif ($result['value'] == '26') {
1763 1928
     			    $error = self::update_from_26();
1764
-    			    if ($error != '') return $error;
1765
-    			    else return self::check_version(true);
1929
+    			    if ($error != '') {
1930
+    			    	return $error;
1931
+    			    } else {
1932
+    			    	return self::check_version(true);
1933
+    			    }
1766 1934
     			} elseif ($result['value'] == '27') {
1767 1935
     			    $error = self::update_from_27();
1768
-    			    if ($error != '') return $error;
1769
-    			    else return self::check_version(true);
1936
+    			    if ($error != '') {
1937
+    			    	return $error;
1938
+    			    } else {
1939
+    			    	return self::check_version(true);
1940
+    			    }
1770 1941
     			} elseif ($result['value'] == '28') {
1771 1942
     			    $error = self::update_from_28();
1772
-    			    if ($error != '') return $error;
1773
-    			    else return self::check_version(true);
1943
+    			    if ($error != '') {
1944
+    			    	return $error;
1945
+    			    } else {
1946
+    			    	return self::check_version(true);
1947
+    			    }
1774 1948
     			} elseif ($result['value'] == '29') {
1775 1949
     			    $error = self::update_from_29();
1776
-    			    if ($error != '') return $error;
1777
-    			    else return self::check_version(true);
1950
+    			    if ($error != '') {
1951
+    			    	return $error;
1952
+    			    } else {
1953
+    			    	return self::check_version(true);
1954
+    			    }
1778 1955
     			} elseif ($result['value'] == '30') {
1779 1956
     			    $error = self::update_from_30();
1780
-    			    if ($error != '') return $error;
1781
-    			    else return self::check_version(true);
1957
+    			    if ($error != '') {
1958
+    			    	return $error;
1959
+    			    } else {
1960
+    			    	return self::check_version(true);
1961
+    			    }
1782 1962
     			} elseif ($result['value'] == '31') {
1783 1963
     			    $error = self::update_from_31();
1784
-    			    if ($error != '') return $error;
1785
-    			    else return self::check_version(true);
1964
+    			    if ($error != '') {
1965
+    			    	return $error;
1966
+    			    } else {
1967
+    			    	return self::check_version(true);
1968
+    			    }
1786 1969
     			} elseif ($result['value'] == '32') {
1787 1970
     			    $error = self::update_from_32();
1788
-    			    if ($error != '') return $error;
1789
-    			    else return self::check_version(true);
1971
+    			    if ($error != '') {
1972
+    			    	return $error;
1973
+    			    } else {
1974
+    			    	return self::check_version(true);
1975
+    			    }
1790 1976
     			} elseif ($result['value'] == '33') {
1791 1977
     			    $error = self::update_from_33();
1792
-    			    if ($error != '') return $error;
1793
-    			    else return self::check_version(true);
1978
+    			    if ($error != '') {
1979
+    			    	return $error;
1980
+    			    } else {
1981
+    			    	return self::check_version(true);
1982
+    			    }
1794 1983
     			} elseif ($result['value'] == '34') {
1795 1984
     			    $error = self::update_from_34();
1796
-    			    if ($error != '') return $error;
1797
-    			    else return self::check_version(true);
1985
+    			    if ($error != '') {
1986
+    			    	return $error;
1987
+    			    } else {
1988
+    			    	return self::check_version(true);
1989
+    			    }
1798 1990
     			} elseif ($result['value'] == '35') {
1799 1991
     			    $error = self::update_from_35();
1800
-    			    if ($error != '') return $error;
1801
-    			    else return self::check_version(true);
1992
+    			    if ($error != '') {
1993
+    			    	return $error;
1994
+    			    } else {
1995
+    			    	return self::check_version(true);
1996
+    			    }
1802 1997
     			} elseif ($result['value'] == '36') {
1803 1998
     			    $error = self::update_from_36();
1804
-    			    if ($error != '') return $error;
1805
-    			    else return self::check_version(true);
1806
-    			} else return '';
1999
+    			    if ($error != '') {
2000
+    			    	return $error;
2001
+    			    } else {
2002
+    			    	return self::check_version(true);
2003
+    			    }
2004
+    			} else {
2005
+    				return '';
2006
+    			}
2007
+    		    } else {
2008
+    		    	return $result['value'];
1807 2009
     		    }
1808
-    		    else return $result['value'];
1809 2010
 		}
1810 2011
 		
1811
-	    } else return $version;
2012
+	    } else {
2013
+	    	return $version;
2014
+	    }
1812 2015
     	}
1813 2016
     	
1814 2017
 }
Please login to merge, or discard this patch.