Completed
Push — master ( 078d82...094023 )
by Yannick
06:07
created
require/class.NOTAM.php 1 patch
Braces   +208 added lines, -88 removed lines patch added patch discarded remove patch
@@ -1015,8 +1015,11 @@  discard block
 block discarded – undo
1015 1015
 		$data = file_get_contents($filename);
1016 1016
 		preg_match_all("/%%(.+?)%%/is", $data, $matches);
1017 1017
 		//print_r($matches);
1018
-		if (isset($matches[1])) return $matches[1];
1019
-		else return array();
1018
+		if (isset($matches[1])) {
1019
+			return $matches[1];
1020
+		} else {
1021
+			return array();
1022
+		}
1020 1023
 	}
1021 1024
 	public function getAllNOTAMbyScope($scope) {
1022 1025
 		global $globalDBdriver;
@@ -1043,7 +1046,9 @@  discard block
 block discarded – undo
1043 1046
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1044 1047
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1045 1048
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1046
-		} else return array();
1049
+		} else {
1050
+			return array();
1051
+		}
1047 1052
 		if ($globalDBdriver == 'mysql') {
1048 1053
 			$query  = 'SELECT * FROM notam WHERE center_latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND center_longitude BETWEEN '.$minlong.' AND '.$maxlong.' AND radius > 0 AND date_end > UTC_TIMESTAMP() AND date_begin < UTC_TIMESTAMP()';
1049 1054
 		} else {
@@ -1067,7 +1072,9 @@  discard block
 block discarded – undo
1067 1072
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1068 1073
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1069 1074
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1070
-		} else return array();
1075
+		} else {
1076
+			return array();
1077
+		}
1071 1078
 		if ($globalDBdriver == 'mysql') {
1072 1079
 			$query  = 'SELECT * FROM notam WHERE center_latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND center_longitude BETWEEN '.$minlong.' AND '.$maxlong.' AND radius > 0 AND date_end > UTC_TIMESTAMP() AND date_begin < UTC_TIMESTAMP() AND scope = :scope';
1073 1080
 		} else {
@@ -1094,8 +1101,11 @@  discard block
 block discarded – undo
1094 1101
 			return "error : ".$e->getMessage();
1095 1102
 		}
1096 1103
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1097
-		if (isset($all[0])) return $all[0];
1098
-		else return array();
1104
+		if (isset($all[0])) {
1105
+			return $all[0];
1106
+		} else {
1107
+			return array();
1108
+		}
1099 1109
 	}
1100 1110
 
1101 1111
 	public function addNOTAM($ref,$title,$type,$fir,$code,$rules,$scope,$lower_limit,$upper_limit,$center_latitude,$center_longitude,$radius,$date_begin,$date_end,$permanent,$text,$full_notam) {
@@ -1173,7 +1183,9 @@  discard block
 block discarded – undo
1173 1183
 					foreach ($alldata as $initial_data) {
1174 1184
 						$data = $this->parse($initial_data);
1175 1185
 						$notamref = $this->getNOTAMbyRef($data['ref']);
1176
-						if (count($notamref) == 0) $this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']);
1186
+						if (count($notamref) == 0) {
1187
+							$this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']);
1188
+						}
1177 1189
 					}
1178 1190
 				}
1179 1191
 			}
@@ -1186,7 +1198,9 @@  discard block
 block discarded – undo
1186 1198
 			foreach ($alldata as $initial_data) {
1187 1199
 				$data = $this->parse($initial_data);
1188 1200
 				$notamref = $this->getNOTAMbyRef($data['ref']);
1189
-				if (!isset($notamref['notam_id'])) $this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']);
1201
+				if (!isset($notamref['notam_id'])) {
1202
+					$this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']);
1203
+				}
1190 1204
 			}
1191 1205
 		}
1192 1206
 	}
@@ -1198,11 +1212,15 @@  discard block
 block discarded – undo
1198 1212
 		foreach (array_chunk($allairports,20) as $airport) {
1199 1213
 			$airports_icao = array();
1200 1214
 			foreach($airport as $icao) {
1201
-				if (isset($icao['icao'])) $airports_icao[] = $icao['icao'];
1215
+				if (isset($icao['icao'])) {
1216
+					$airports_icao[] = $icao['icao'];
1217
+				}
1202 1218
 			}
1203 1219
 			$airport_icao = implode(',',$airports_icao);
1204 1220
 			$alldata = $this->downloadNOTAM($airport_icao);
1205
-			if ($globalTransaction) $this->db->beginTransaction();
1221
+			if ($globalTransaction) {
1222
+				$this->db->beginTransaction();
1223
+			}
1206 1224
 			if (count($alldata) > 0) {
1207 1225
 				foreach ($alldata as $initial_data) {
1208 1226
 					//print_r($initial_data);
@@ -1211,14 +1229,23 @@  discard block
 block discarded – undo
1211 1229
 					if (isset($data['ref'])) {
1212 1230
 						$notamref = $this->getNOTAMbyRef($data['ref']);
1213 1231
 						if (count($notamref) == 0) {
1214
-							if (isset($data['ref_replaced'])) $this->deleteNOTAMbyRef($data['ref_replaced']);
1215
-							if (isset($data['ref_cancelled'])) $this->deleteNOTAMbyRef($data['ref_cancelled']);
1216
-							elseif (isset($data['latitude']) && isset($data['scope']) && isset($data['text']) && isset($data['permanent'])) echo $this->addNOTAM($data['ref'],'','',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']);
1232
+							if (isset($data['ref_replaced'])) {
1233
+								$this->deleteNOTAMbyRef($data['ref_replaced']);
1234
+							}
1235
+							if (isset($data['ref_cancelled'])) {
1236
+								$this->deleteNOTAMbyRef($data['ref_cancelled']);
1237
+							} elseif (isset($data['latitude']) && isset($data['scope']) && isset($data['text']) && isset($data['permanent'])) {
1238
+								echo $this->addNOTAM($data['ref'],'','',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']);
1239
+							}
1217 1240
 						}
1218 1241
 					}
1219 1242
 				}
1220
-			} else echo 'Error on download. Nothing matches for '.$airport_icao."\n";
1221
-			if ($globalTransaction) $this->db->commit();
1243
+			} else {
1244
+				echo 'Error on download. Nothing matches for '.$airport_icao."\n";
1245
+			}
1246
+			if ($globalTransaction) {
1247
+				$this->db->commit();
1248
+			}
1222 1249
 			sleep(5);
1223 1250
 		}
1224 1251
 	}
@@ -1231,8 +1258,11 @@  discard block
 block discarded – undo
1231 1258
 		$data = $Common->getData($url);
1232 1259
 		preg_match_all("/<pre>(.+?)<\/pre>/is", $data, $matches);
1233 1260
 		//print_r($matches);
1234
-		if (isset($matches[1])) return $matches[1];
1235
-		else return array();
1261
+		if (isset($matches[1])) {
1262
+			return $matches[1];
1263
+		} else {
1264
+			return array();
1265
+		}
1236 1266
 	}
1237 1267
 
1238 1268
 	public function parse($data) {
@@ -1255,89 +1285,145 @@  discard block
 block discarded – undo
1255 1285
 					$rules = str_split($matches[3]);
1256 1286
 					foreach ($rules as $rule) {
1257 1287
 						if ($rule == 'I') {
1258
-							if (isset($result['rules'])) $result['rules'] = $result['rules'].'/IFR';
1259
-							else $result['rules'] = 'IFR';
1288
+							if (isset($result['rules'])) {
1289
+								$result['rules'] = $result['rules'].'/IFR';
1290
+							} else {
1291
+								$result['rules'] = 'IFR';
1292
+							}
1260 1293
 						} elseif ($rule == 'V') {
1261
-							if (isset($result['rules'])) $result['rules'] = $result['rules'].'/VFR';
1262
-							else $result['rules'] = 'VFR';
1294
+							if (isset($result['rules'])) {
1295
+								$result['rules'] = $result['rules'].'/VFR';
1296
+							} else {
1297
+								$result['rules'] = 'VFR';
1298
+							}
1263 1299
 						} elseif ($rule == 'K') {
1264
-							if (isset($result['rules'])) $result['rules'] = $result['rules'].'/Checklist';
1265
-							else $result['rules'] = 'Checklist';
1300
+							if (isset($result['rules'])) {
1301
+								$result['rules'] = $result['rules'].'/Checklist';
1302
+							} else {
1303
+								$result['rules'] = 'Checklist';
1304
+							}
1266 1305
 						}
1267 1306
 					}
1268 1307
 					$attentions = str_split($matches[4]);
1269 1308
 					foreach ($attentions as $attention) {
1270 1309
 						if ($attention == 'N') {
1271
-							if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Immediate attention';
1272
-							else $result['rules'] = 'Immediate attention';
1310
+							if (isset($result['attention'])) {
1311
+								$result['attention'] = $result['attention'].' / Immediate attention';
1312
+							} else {
1313
+								$result['rules'] = 'Immediate attention';
1314
+							}
1273 1315
 						} elseif ($attention == 'B') {
1274
-							if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Operational significance';
1275
-							else $result['rules'] = 'Operational significance';
1316
+							if (isset($result['attention'])) {
1317
+								$result['attention'] = $result['attention'].' / Operational significance';
1318
+							} else {
1319
+								$result['rules'] = 'Operational significance';
1320
+							}
1276 1321
 						} elseif ($attention == 'O') {
1277
-							if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Flight operations';
1278
-							else $result['rules'] = 'Flight operations';
1322
+							if (isset($result['attention'])) {
1323
+								$result['attention'] = $result['attention'].' / Flight operations';
1324
+							} else {
1325
+								$result['rules'] = 'Flight operations';
1326
+							}
1279 1327
 						} elseif ($attention == 'M') {
1280
-							if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Misc';
1281
-							else $result['rules'] = 'Misc';
1328
+							if (isset($result['attention'])) {
1329
+								$result['attention'] = $result['attention'].' / Misc';
1330
+							} else {
1331
+								$result['rules'] = 'Misc';
1332
+							}
1282 1333
 						} elseif ($attention == 'K') {
1283
-							if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Checklist';
1284
-							else $result['rules'] = 'Checklist';
1334
+							if (isset($result['attention'])) {
1335
+								$result['attention'] = $result['attention'].' / Checklist';
1336
+							} else {
1337
+								$result['rules'] = 'Checklist';
1338
+							}
1285 1339
 						}
1286 1340
 					}
1287
-					if ($matches[5] == 'A') $result['scope'] = 'Airport warning';
1288
-					elseif ($matches[5] == 'E') $result['scope'] = 'Enroute warning';
1289
-					elseif ($matches[5] == 'W') $result['scope'] = 'Navigation warning';
1290
-					elseif ($matches[5] == 'K') $result['scope'] = 'Checklist';
1291
-					elseif ($matches[5] == 'AE') $result['scope'] = 'Airport/Enroute warning';
1292
-					elseif ($matches[5] == 'AW') $result['scope'] = 'Airport/Navigation warning';
1341
+					if ($matches[5] == 'A') {
1342
+						$result['scope'] = 'Airport warning';
1343
+					} elseif ($matches[5] == 'E') {
1344
+						$result['scope'] = 'Enroute warning';
1345
+					} elseif ($matches[5] == 'W') {
1346
+						$result['scope'] = 'Navigation warning';
1347
+					} elseif ($matches[5] == 'K') {
1348
+						$result['scope'] = 'Checklist';
1349
+					} elseif ($matches[5] == 'AE') {
1350
+						$result['scope'] = 'Airport/Enroute warning';
1351
+					} elseif ($matches[5] == 'AW') {
1352
+						$result['scope'] = 'Airport/Navigation warning';
1353
+					}
1293 1354
 					$result['lower_limit'] = $matches[6];
1294 1355
 					$result['upper_limit'] = $matches[7];
1295 1356
 					$latitude = $Common->convertDec($matches[8],'latitude');
1296
-					if ($matches[9] == 'S') $latitude = -$latitude;
1357
+					if ($matches[9] == 'S') {
1358
+						$latitude = -$latitude;
1359
+					}
1297 1360
 					$longitude = $Common->convertDec($matches[10],'longitude');
1298
-					if ($matches[11] == 'W') $longitude = -$longitude;
1361
+					if ($matches[11] == 'W') {
1362
+						$longitude = -$longitude;
1363
+					}
1299 1364
 					$result['latitude'] = $latitude;
1300 1365
 					$result['longitude'] = $longitude;
1301 1366
 					$result['radius'] = intval($matches[12]);
1302
-				} else echo 'ERROR : '.$line."\n";
1303
-			}
1304
-			elseif (preg_match('#A\) (.*)#',$line,$matches)) {
1367
+				} else {
1368
+					echo 'ERROR : '.$line."\n";
1369
+				}
1370
+			} elseif (preg_match('#A\) (.*)#',$line,$matches)) {
1305 1371
 				$result['icao'] = $matches[1];
1306
-			}
1307
-			elseif (preg_match('#B\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})#',$line,$matches)) {
1308
-				if ($matches[1] > 50) $year = '19'.$matches[1];
1309
-				else $year = '20'.$matches[1];
1372
+			} elseif (preg_match('#B\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})#',$line,$matches)) {
1373
+				if ($matches[1] > 50) {
1374
+					$year = '19'.$matches[1];
1375
+				} else {
1376
+					$year = '20'.$matches[1];
1377
+				}
1310 1378
 				$result['date_begin'] = $year.'/'.$matches[2].'/'.$matches[3].' '.$matches[4].':'.$matches[5];
1311
-			}
1312
-			elseif (preg_match('#C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#',$line,$matches)) {
1313
-				if ($matches[1] > 50) $year = '19'.$matches[1];
1314
-				else $year = '20'.$matches[1];
1379
+			} elseif (preg_match('#C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#',$line,$matches)) {
1380
+				if ($matches[1] > 50) {
1381
+					$year = '19'.$matches[1];
1382
+				} else {
1383
+					$year = '20'.$matches[1];
1384
+				}
1315 1385
 				$result['date_end'] = $year.'/'.$matches[2].'/'.$matches[3].' '.$matches[4].':'.$matches[5];
1316 1386
 				$result['permanent'] = 0;
1317
-			}
1318
-			elseif (preg_match('#C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2}) (EST|PERM)$#',$line,$matches)) {
1319
-				if ($matches[1] > 50) $year = '19'.$matches[1];
1320
-				else $year = '20'.$matches[1];
1387
+			} elseif (preg_match('#C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2}) (EST|PERM)$#',$line,$matches)) {
1388
+				if ($matches[1] > 50) {
1389
+					$year = '19'.$matches[1];
1390
+				} else {
1391
+					$year = '20'.$matches[1];
1392
+				}
1321 1393
 				$result['date_end'] = $year.'/'.$matches[2].'/'.$matches[3].' '.$matches[4].':'.$matches[5];
1322
-				if ($matches[6] == 'EST') $result['estimated'] = 1;
1323
-				else $result['estimated'] = 0;
1324
-				if ($matches[6] == 'PERM') $result['permanent'] = 1;
1325
-				else $result['permanent'] = 0;
1326
-			}
1327
-			elseif (preg_match('#C\) (EST|PERM)$#',$line,$matches)) {
1394
+				if ($matches[6] == 'EST') {
1395
+					$result['estimated'] = 1;
1396
+				} else {
1397
+					$result['estimated'] = 0;
1398
+				}
1399
+				if ($matches[6] == 'PERM') {
1400
+					$result['permanent'] = 1;
1401
+				} else {
1402
+					$result['permanent'] = 0;
1403
+				}
1404
+			} elseif (preg_match('#C\) (EST|PERM)$#',$line,$matches)) {
1328 1405
 				$result['date_end'] = '2030/12/20 12:00';
1329
-				if ($matches[1] == 'EST') $result['estimated'] = 1;
1330
-				else $result['estimated'] = 0;
1331
-				if ($matches[1] == 'PERM') $result['permanent'] = 1;
1332
-				else $result['permanent'] = 0;
1333
-			}
1334
-			elseif (preg_match('#E\) (.*)#',$line,$matches)) {
1406
+				if ($matches[1] == 'EST') {
1407
+					$result['estimated'] = 1;
1408
+				} else {
1409
+					$result['estimated'] = 0;
1410
+				}
1411
+				if ($matches[1] == 'PERM') {
1412
+					$result['permanent'] = 1;
1413
+				} else {
1414
+					$result['permanent'] = 0;
1415
+				}
1416
+			} elseif (preg_match('#E\) (.*)#',$line,$matches)) {
1335 1417
 				$rtext = array();
1336 1418
 				$text = explode(' ',$matches[1]);
1337 1419
 				foreach ($text as $word) {
1338
-					if (isset($this->abbr[$word])) $rtext[] = strtoupper($this->abbr[$word]);
1339
-					elseif (ctype_digit(strval(substr($word,3))) && isset($this->abbr[substr($word,0,3)])) $rtext[] = strtoupper($this->abbr[substr($word,0,3)]).' '.substr($word,3);
1340
-					else $rtext[] = $word;
1420
+					if (isset($this->abbr[$word])) {
1421
+						$rtext[] = strtoupper($this->abbr[$word]);
1422
+					} elseif (ctype_digit(strval(substr($word,3))) && isset($this->abbr[substr($word,0,3)])) {
1423
+						$rtext[] = strtoupper($this->abbr[substr($word,0,3)]).' '.substr($word,3);
1424
+					} else {
1425
+						$rtext[] = $word;
1426
+					}
1341 1427
 				}
1342 1428
 				$result['text'] = implode(' ',$rtext);
1343 1429
 			//} elseif (preg_match('#F\) (.*)#',$line,$matches)) {
@@ -1345,7 +1431,9 @@  discard block
 block discarded – undo
1345 1431
 			} elseif (preg_match('#(NOTAMN|NOTAMR|NOTAMC)#',$line,$matches)) {
1346 1432
 				$text = explode(' ',$line);
1347 1433
 				$result['ref'] = $text[0];
1348
-				if ($matches[1] == 'NOTAMN') $result['type'] = 'new';
1434
+				if ($matches[1] == 'NOTAMN') {
1435
+					$result['type'] = 'new';
1436
+				}
1349 1437
 				if ($matches[1] == 'NOTAMC') {
1350 1438
 					$result['type'] = 'cancel';
1351 1439
 					$result['ref_cancelled'] = $text[2];
@@ -1367,69 +1455,101 @@  discard block
 block discarded – undo
1367 1455
 		switch ($code[1]) {
1368 1456
 			case 'A':
1369 1457
 				$result = 'Airspace organization ';
1370
-				if (isset($this->code_airspace[$code_fp])) $result .= $this->code_airspace[$code_fp];
1458
+				if (isset($this->code_airspace[$code_fp])) {
1459
+					$result .= $this->code_airspace[$code_fp];
1460
+				}
1371 1461
 				break;
1372 1462
 			case 'C':
1373 1463
 				$result = 'Communications and radar facilities ';
1374
-				if (isset($this->code_comradar[$code_fp])) $result .= $this->code_comradar[$code_fp];
1464
+				if (isset($this->code_comradar[$code_fp])) {
1465
+					$result .= $this->code_comradar[$code_fp];
1466
+				}
1375 1467
 				break;
1376 1468
 			case 'F':
1377 1469
 				$result = 'Facilities and services ';
1378
-				if (isset($this->code_facilities[$code_fp])) $result .= $this->code_facilities[$code_fp];
1470
+				if (isset($this->code_facilities[$code_fp])) {
1471
+					$result .= $this->code_facilities[$code_fp];
1472
+				}
1379 1473
 				break;
1380 1474
 			case 'I':
1381 1475
 				$result = 'Instrument and Microwave Landing System ';
1382
-				if (isset($this->code_instrumentlanding[$code_fp])) $result .= $this->code_instrumentlanding[$code_fp];
1476
+				if (isset($this->code_instrumentlanding[$code_fp])) {
1477
+					$result .= $this->code_instrumentlanding[$code_fp];
1478
+				}
1383 1479
 				break;
1384 1480
 			case 'L':
1385 1481
 				$result = 'Lighting facilities ';
1386
-				if (isset($this->code_lightingfacilities[$code_fp])) $result .= $this->code_lightingfacilities[$code_fp];
1482
+				if (isset($this->code_lightingfacilities[$code_fp])) {
1483
+					$result .= $this->code_lightingfacilities[$code_fp];
1484
+				}
1387 1485
 				break;
1388 1486
 			case 'M':
1389 1487
 				$result = 'Movement and landing areas ';
1390
-				if (isset($this->code_movementareas[$code_fp])) $result .= $this->code_movementareas[$code_fp];
1488
+				if (isset($this->code_movementareas[$code_fp])) {
1489
+					$result .= $this->code_movementareas[$code_fp];
1490
+				}
1391 1491
 				break;
1392 1492
 			case 'N':
1393 1493
 				$result = 'Terminal and En Route Navigation Facilities ';
1394
-				if (isset($this->code_terminalfacilities[$code_fp])) $result .= $this->code_terminalfacilities[$code_fp];
1494
+				if (isset($this->code_terminalfacilities[$code_fp])) {
1495
+					$result .= $this->code_terminalfacilities[$code_fp];
1496
+				}
1395 1497
 				break;
1396 1498
 			case 'O':
1397 1499
 				$result = 'Other information ';
1398
-				if (isset($this->code_information[$code_fp])) $result .= $this->code_information[$code_fp];
1500
+				if (isset($this->code_information[$code_fp])) {
1501
+					$result .= $this->code_information[$code_fp];
1502
+				}
1399 1503
 				break;
1400 1504
 			case 'P':
1401 1505
 				$result = 'Air Traffic procedures ';
1402
-				if (isset($this->code_airtraffic[$code_fp])) $result .= $this->code_airtraffic[$code_fp];
1506
+				if (isset($this->code_airtraffic[$code_fp])) {
1507
+					$result .= $this->code_airtraffic[$code_fp];
1508
+				}
1403 1509
 				break;
1404 1510
 			case 'R':
1405 1511
 				$result = 'Navigation Warnings: Airspace Restrictions ';
1406
-				if (isset($this->code_navigationw[$code_fp])) $result .= $this->code_navigationw[$code_fp];
1512
+				if (isset($this->code_navigationw[$code_fp])) {
1513
+					$result .= $this->code_navigationw[$code_fp];
1514
+				}
1407 1515
 				break;
1408 1516
 			case 'S':
1409 1517
 				$result = 'Air Traffic and VOLMET Services ';
1410
-				if (isset($this->code_volmet[$code_fp])) $result .= $this->code_volmet[$code_fp];
1518
+				if (isset($this->code_volmet[$code_fp])) {
1519
+					$result .= $this->code_volmet[$code_fp];
1520
+				}
1411 1521
 				break;
1412 1522
 			case 'W':
1413 1523
 				$result = 'Navigation Warnings: Warnings ';
1414
-				if (isset($this->code_warnings[$code_fp])) $result .= $this->code_warnings[$code_fp];
1524
+				if (isset($this->code_warnings[$code_fp])) {
1525
+					$result .= $this->code_warnings[$code_fp];
1526
+				}
1415 1527
 				break;
1416 1528
 		}
1417 1529
 		switch ($code[3]) {
1418 1530
 			case 'A':
1419 1531
 				// Availability
1420
-				if (isset($this->code_sp_availabity[$code_sp])) $result .= ' '.$this->code_sp_availabity[$code_sp];
1532
+				if (isset($this->code_sp_availabity[$code_sp])) {
1533
+					$result .= ' '.$this->code_sp_availabity[$code_sp];
1534
+				}
1421 1535
 				break;
1422 1536
 			case 'C':
1423 1537
 				// Changes
1424
-				if (isset($this->code_sp_changes[$code_sp])) $result .= ' '.$this->code_sp_changes[$code_sp];
1538
+				if (isset($this->code_sp_changes[$code_sp])) {
1539
+					$result .= ' '.$this->code_sp_changes[$code_sp];
1540
+				}
1425 1541
 				break;
1426 1542
 			case 'H':
1427 1543
 				// Hazardous conditions
1428
-				if (isset($this->code_sp_hazardous[$code_sp])) $result .= ' '.$this->code_sp_hazardous[$code_sp];
1544
+				if (isset($this->code_sp_hazardous[$code_sp])) {
1545
+					$result .= ' '.$this->code_sp_hazardous[$code_sp];
1546
+				}
1429 1547
 				break;
1430 1548
 			case 'L':
1431 1549
 				// Limitations
1432
-				if (isset($this->code_sp_limitations[$code_sp])) $result .= ' '.$this->code_sp_limitations[$code_sp];
1550
+				if (isset($this->code_sp_limitations[$code_sp])) {
1551
+					$result .= ' '.$this->code_sp_limitations[$code_sp];
1552
+				}
1433 1553
 				break;
1434 1554
 			case 'X':
1435 1555
 				// Other Information
Please login to merge, or discard this patch.
airspace-data.php 1 patch
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -25,7 +25,9 @@  discard block
 block discarded – undo
25 25
 $airspace = $result[0];
26 26
 date_default_timezone_set('UTC');
27 27
 print '<div class="top">';
28
-if (isset($airspace['name'])) $airspace['title'] = $airspace['name']; 
28
+if (isset($airspace['name'])) {
29
+	$airspace['title'] = $airspace['name'];
30
+}
29 31
 print '<div class="right"><div class="callsign-details"><div class="callsign">'.$airspace['title'].'</a></div>';
30 32
 print '</div>';
31 33
 print '<div class="details">';
@@ -44,13 +46,17 @@  discard block
 block discarded – undo
44 46
 	print '</div>';
45 47
 }
46 48
 
47
-if (isset($airspace['ceiling'])) $airspace['tops'] = $airspace['ceiling'];
49
+if (isset($airspace['ceiling'])) {
50
+	$airspace['tops'] = $airspace['ceiling'];
51
+}
48 52
 print '<div>';
49 53
 print '<span>'._("Tops").'</span>';
50 54
 print $airspace['tops'];
51 55
 print '</div>';
52 56
 
53
-if (isset($airspace['floor'])) $airspace['base'] = $airspace['floor'];
57
+if (isset($airspace['floor'])) {
58
+	$airspace['base'] = $airspace['floor'];
59
+}
54 60
 print '<div>';
55 61
 print '<span>'._("Base").'</span>';
56 62
 print $airspace['base'];
Please login to merge, or discard this patch.
airspace-geojson.php 1 patch
Braces   +16 added lines, -6 removed lines patch added patch discarded remove patch
@@ -67,12 +67,22 @@
 block discarded – undo
67 67
 		} else {
68 68
 			$geom = geoPHP::load(stream_get_contents($row['wkb']));
69 69
 		}
70
-		if (isset($properties['type'])) $properties['type'] = trim($properties['type']);
71
-		elseif (isset($properties['class'])) $properties['type'] = trim($properties['class']);
72
-		if (isset($properties['ogr_fid'])) $properties['id'] = $properties['ogr_fid'];
73
-		elseif (isset($properties['ogc_fid'])) $properties['id'] = $properties['ogc_fid'];
74
-		if (isset($properties['ceiling'])) $properties['tops'] = $properties['ceiling'];
75
-		if (isset($properties['floor'])) $properties['base'] = $properties['floor'];
70
+		if (isset($properties['type'])) {
71
+			$properties['type'] = trim($properties['type']);
72
+		} elseif (isset($properties['class'])) {
73
+			$properties['type'] = trim($properties['class']);
74
+		}
75
+		if (isset($properties['ogr_fid'])) {
76
+			$properties['id'] = $properties['ogr_fid'];
77
+		} elseif (isset($properties['ogc_fid'])) {
78
+			$properties['id'] = $properties['ogc_fid'];
79
+		}
80
+		if (isset($properties['ceiling'])) {
81
+			$properties['tops'] = $properties['ceiling'];
82
+		}
83
+		if (isset($properties['floor'])) {
84
+			$properties['base'] = $properties['floor'];
85
+		}
76 86
 		if (preg_match('/^FL(\s)*(?<alt>\d+)/',strtoupper($properties['tops']),$matches)) {
77 87
 			$properties['upper_limit'] = round($matches['alt']*100*0.38048);
78 88
 		} elseif (preg_match('/^(?<alt>\d+)(\s)*(FT|AGL|ALT|MSL)/',strtoupper($properties['tops']),$matches)) {
Please login to merge, or discard this patch.
scripts/update_db.php 1 patch
Braces   +20 added lines, -8 removed lines patch added patch discarded remove patch
@@ -9,7 +9,9 @@  discard block
 block discarded – undo
9 9
 if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') {
10 10
 	exec("ps ux", $output, $result);
11 11
 	$j = 0;
12
-	foreach ($output as $line) if(strpos($line, "update_db.php") && !strpos($line, "sh ")) $j++;
12
+	foreach ($output as $line) {
13
+		if(strpos($line, "update_db.php") && !strpos($line, "sh ")) $j++;
14
+	}
13 15
 	if ($j > 1) {
14 16
 		echo "Script is already runnning...";
15 17
 		die();
@@ -28,8 +30,10 @@  discard block
 block discarded – undo
28 30
 			$update_db->update_notam();
29 31
 		}
30 32
 		$update_db->insert_last_notam_update();
31
-	} elseif (isset($globalDebug) && $globalDebug && isset($globalNOTAM) && $globalNOTAM) echo "NOTAM are only updated once a day.\n";
32
-}
33
+	} elseif (isset($globalDebug) && $globalDebug && isset($globalNOTAM) && $globalNOTAM) {
34
+		echo "NOTAM are only updated once a day.\n";
35
+	}
36
+	}
33 37
 
34 38
 if ($update_db->check_last_update() && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
35 39
 	$update_db->update_all();
@@ -37,7 +41,9 @@  discard block
 block discarded – undo
37 41
 //	$Spotter = new Spotter();
38 42
 //	$Spotter->updateFieldsFromOtherTables();
39 43
 	$update_db->insert_last_update();
40
-} elseif (isset($globalDebug) && $globalDebug && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM)) echo "DB are populated with external data only every 15 days ! Files are not updated more often.\n";
44
+} elseif (isset($globalDebug) && $globalDebug && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM)) {
45
+	echo "DB are populated with external data only every 15 days ! Files are not updated more often.\n";
46
+}
41 47
 
42 48
 
43 49
 if (isset($globalMETAR) && isset($globalMETARcycle) && $globalMETAR && $globalMETARcycle) {
@@ -47,22 +53,28 @@  discard block
 block discarded – undo
47 53
 	if ($METAR->check_last_update()) {
48 54
 		$METAR->addMETARCycle();
49 55
 		$METAR->insert_last_update();
50
-	} else echo "METAR are only updated every 30 minutes.\n";
51
-}
56
+	} else {
57
+		echo "METAR are only updated every 30 minutes.\n";
58
+	}
59
+	}
52 60
 
53 61
 
54 62
 if (isset($globalOwner) && $globalOwner && $update_db->check_last_owner_update() && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
55 63
 	echo "Updating private aircraft's owners...";
56 64
 	$update_db->update_owner();
57 65
 	$update_db->insert_last_owner_update();
58
-} elseif (isset($globalDebug) && $globalDebug && isset($globalOwner) && $globalOwner && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) echo "Owner are only updated every 15 days.\n";
66
+} elseif (isset($globalDebug) && $globalDebug && isset($globalOwner) && $globalOwner && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
67
+	echo "Owner are only updated every 15 days.\n";
68
+}
59 69
 
60 70
 if (isset($globalSchedules) && $globalSchedules && $update_db->check_last_schedules_update() && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
61 71
 	echo "Updating schedules...";
62 72
 	$update_db->update_oneworld();
63 73
 	$update_db->update_skyteam();
64 74
 	$update_db->insert_last_schedules_update();
65
-} elseif (isset($globalDebug) && $globalDebug && isset($globalOwner) && $globalOwner && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) echo "Schedules are only updated every 15 days.\n";
75
+} elseif (isset($globalDebug) && $globalDebug && isset($globalOwner) && $globalOwner && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
76
+	echo "Schedules are only updated every 15 days.\n";
77
+}
66 78
 
67 79
 if (isset($globalArchiveMonths) && $globalArchiveMonths > 0) {
68 80
 	echo "Updating statistics and archive old data...";
Please login to merge, or discard this patch.
install/class.create_db.php 1 patch
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -14,7 +14,9 @@  discard block
 block discarded – undo
14 14
 			//foreach ($lines as $line)
15 15
 			while (($line = fgets($handle,4096)) !== false)
16 16
 			{
17
-				if (substr($line,0,2) == '--' || $line == '') continue;
17
+				if (substr($line,0,2) == '--' || $line == '') {
18
+					continue;
19
+				}
18 20
 				$templine .= $line;
19 21
 				if (substr(trim($line), -1,1) == ';')
20 22
 				{
@@ -40,7 +42,9 @@  discard block
 block discarded – undo
40 42
 		//foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)) as $filename)
41 43
 		while(false !== ($filename = readdir($dh)))
42 44
 		{
43
-		    if (preg_match('/\.sql$/',$filename)) $error .= create_db::import_file($directory.$filename);
45
+		    if (preg_match('/\.sql$/',$filename)) {
46
+		    	$error .= create_db::import_file($directory.$filename);
47
+		    }
44 48
 		}
45 49
 		return $error;
46 50
 	}
@@ -56,13 +60,17 @@  discard block
 block discarded – undo
56 60
 		// Dirty hack
57 61
 		if ($host != 'localhost' && $host != '127.0.0.1') {
58 62
 		    $grantright = $_SERVER['SERVER_ADDR'];
59
-		} else $grantright = 'localhost';
63
+		} else {
64
+			$grantright = 'localhost';
65
+		}
60 66
 		try {
61 67
 			$dbh = new PDO($db_type.':host='.$host,$root,$root_pass);
62 68
 			$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
63 69
 			if ($db_type == 'mysql') {
64 70
 				$dbh->exec('CREATE DATABASE IF NOT EXISTS `'.$db.'`;GRANT ALL ON `'.$db."`.* TO '".$user."'@'".$grantright."' IDENTIFIED BY '".$password."';FLUSH PRIVILEGES;");
65
-				if ($grantright == 'localhost') $dbh->exec('GRANT ALL ON `'.$db."`.* TO '".$user."'@'127.0.0.1' IDENTIFIED BY '".$password."';FLUSH PRIVILEGES;");
71
+				if ($grantright == 'localhost') {
72
+					$dbh->exec('GRANT ALL ON `'.$db."`.* TO '".$user."'@'127.0.0.1' IDENTIFIED BY '".$password."';FLUSH PRIVILEGES;");
73
+				}
66 74
 			} else if ($db_type == 'pgsql') {
67 75
 				$dbh->exec("CREATE DATABASE ".$db.";");
68 76
 				$dbh->exec("CREATE USER ".$user." WITH PASSWORD '".$password."';
Please login to merge, or discard this patch.
install/class.update_db.php 1 patch
Braces   +724 added lines, -251 removed lines patch added patch discarded remove patch
@@ -16,7 +16,9 @@  discard block
 block discarded – undo
16 16
 		curl_setopt($ch, CURLOPT_URL, $url);
17 17
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
18 18
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
19
-		if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer);
19
+		if ($referer != '') {
20
+			curl_setopt($ch, CURLOPT_REFERER, $referer);
21
+		}
20 22
 		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5');
21 23
 		curl_setopt($ch, CURLOPT_FILE, $fp);
22 24
 		curl_exec($ch);
@@ -27,12 +29,16 @@  discard block
 block discarded – undo
27 29
 	public static function gunzip($in_file,$out_file_name = '') {
28 30
 		//echo $in_file.' -> '.$out_file_name."\n";
29 31
 		$buffer_size = 4096; // read 4kb at a time
30
-		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
32
+		if ($out_file_name == '') {
33
+			$out_file_name = str_replace('.gz', '', $in_file);
34
+		}
31 35
 		if ($in_file != '' && file_exists($in_file)) {
32 36
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
33
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
34
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
35
-			else {
37
+			if (function_exists('gzopen')) {
38
+				$file = gzopen($in_file,'rb');
39
+			} elseif (function_exists('gzopen64')) {
40
+				$file = gzopen64($in_file,'rb');
41
+			} else {
36 42
 				echo 'gzopen not available';
37 43
 				die;
38 44
 			}
@@ -53,8 +59,12 @@  discard block
 block discarded – undo
53 59
 			if ($res === TRUE) {
54 60
 				$zip->extractTo($path);
55 61
 				$zip->close();
56
-			} else return false;
57
-		} else return false;
62
+			} else {
63
+				return false;
64
+			}
65
+		} else {
66
+			return false;
67
+		}
58 68
 	}
59 69
 	
60 70
 	public static function connect_sqlite($database) {
@@ -69,7 +79,9 @@  discard block
 block discarded – undo
69 79
 	public static function retrieve_route_sqlite_to_dest($database_file) {
70 80
 		global $globalDebug, $globalTransaction;
71 81
 		//$query = 'TRUNCATE TABLE routes';
72
-		if ($globalDebug) echo " - Delete previous routes from DB -";
82
+		if ($globalDebug) {
83
+			echo " - Delete previous routes from DB -";
84
+		}
73 85
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
74 86
 		$Connection = new Connection();
75 87
 		try {
@@ -80,7 +92,9 @@  discard block
 block discarded – undo
80 92
                         return "error : ".$e->getMessage();
81 93
                 }
82 94
 
83
-    		if ($globalDebug) echo " - Add routes to DB -";
95
+    		if ($globalDebug) {
96
+    			echo " - Add routes to DB -";
97
+    		}
84 98
     		update_db::connect_sqlite($database_file);
85 99
 		//$query = 'select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID';
86 100
 		$query = "select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao, rstp.allstop AS AllStop from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID LEFT JOIN (select RouteId,GROUP_CONCAT(icao,' ') as allstop from routestop left join Airport as air ON routestop.AirportId = air.AirportID group by RouteID) AS rstp ON Route.RouteID = rstp.RouteID";
@@ -95,15 +109,21 @@  discard block
 block discarded – undo
95 109
 		$Connection = new Connection();
96 110
 		$sth_dest = $Connection->db->prepare($query_dest);
97 111
 		try {
98
-			if ($globalTransaction) $Connection->db->beginTransaction();
112
+			if ($globalTransaction) {
113
+				$Connection->db->beginTransaction();
114
+			}
99 115
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
100 116
 				//$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
101 117
 				$query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
102 118
 				$sth_dest->execute($query_dest_values);
103 119
             		}
104
-			if ($globalTransaction) $Connection->db->commit();
120
+			if ($globalTransaction) {
121
+				$Connection->db->commit();
122
+			}
105 123
 		} catch(PDOException $e) {
106
-			if ($globalTransaction) $Connection->db->rollBack(); 
124
+			if ($globalTransaction) {
125
+				$Connection->db->rollBack();
126
+			}
107 127
 			return "error : ".$e->getMessage();
108 128
 		}
109 129
                 return '';
@@ -111,7 +131,9 @@  discard block
 block discarded – undo
111 131
 	public static function retrieve_route_oneworld($database_file) {
112 132
 		global $globalDebug, $globalTransaction;
113 133
 		//$query = 'TRUNCATE TABLE routes';
114
-		if ($globalDebug) echo " - Delete previous routes from DB -";
134
+		if ($globalDebug) {
135
+			echo " - Delete previous routes from DB -";
136
+		}
115 137
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
116 138
 		$Connection = new Connection();
117 139
 		try {
@@ -122,14 +144,18 @@  discard block
 block discarded – undo
122 144
                         return "error : ".$e->getMessage();
123 145
                 }
124 146
 
125
-    		if ($globalDebug) echo " - Add routes to DB -";
147
+    		if ($globalDebug) {
148
+    			echo " - Add routes to DB -";
149
+    		}
126 150
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
127 151
 		$Spotter = new Spotter();
128 152
 		if ($fh = fopen($database_file,"r")) {
129 153
 			$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)';
130 154
 			$Connection = new Connection();
131 155
 			$sth_dest = $Connection->db->prepare($query_dest);
132
-			if ($globalTransaction) $Connection->db->beginTransaction();
156
+			if ($globalTransaction) {
157
+				$Connection->db->beginTransaction();
158
+			}
133 159
 			while (!feof($fh)) {
134 160
 				$line = fgetcsv($fh,9999,',');
135 161
 				if ($line[0] != '') {
@@ -138,13 +164,17 @@  discard block
 block discarded – undo
138 164
 							$query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld');
139 165
 							$sth_dest->execute($query_dest_values);
140 166
 						} catch(PDOException $e) {
141
-							if ($globalTransaction) $Connection->db->rollBack(); 
167
+							if ($globalTransaction) {
168
+								$Connection->db->rollBack();
169
+							}
142 170
 							return "error : ".$e->getMessage();
143 171
 						}
144 172
 					}
145 173
 				}
146 174
 			}
147
-			if ($globalTransaction) $Connection->db->commit();
175
+			if ($globalTransaction) {
176
+				$Connection->db->commit();
177
+			}
148 178
 		}
149 179
                 return '';
150 180
 	}
@@ -152,7 +182,9 @@  discard block
 block discarded – undo
152 182
 	public static function retrieve_route_skyteam($database_file) {
153 183
 		global $globalDebug, $globalTransaction;
154 184
 		//$query = 'TRUNCATE TABLE routes';
155
-		if ($globalDebug) echo " - Delete previous routes from DB -";
185
+		if ($globalDebug) {
186
+			echo " - Delete previous routes from DB -";
187
+		}
156 188
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
157 189
 		$Connection = new Connection();
158 190
 		try {
@@ -163,7 +195,9 @@  discard block
 block discarded – undo
163 195
                         return "error : ".$e->getMessage();
164 196
                 }
165 197
 
166
-    		if ($globalDebug) echo " - Add routes to DB -";
198
+    		if ($globalDebug) {
199
+    			echo " - Add routes to DB -";
200
+    		}
167 201
 
168 202
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
169 203
 		$Spotter = new Spotter();
@@ -172,7 +206,9 @@  discard block
 block discarded – undo
172 206
 			$Connection = new Connection();
173 207
 			$sth_dest = $Connection->db->prepare($query_dest);
174 208
 			try {
175
-				if ($globalTransaction) $Connection->db->beginTransaction();
209
+				if ($globalTransaction) {
210
+					$Connection->db->beginTransaction();
211
+				}
176 212
 				while (!feof($fh)) {
177 213
 					$line = fgetcsv($fh,9999,',');
178 214
 					if ($line[0] != '') {
@@ -183,9 +219,13 @@  discard block
 block discarded – undo
183 219
 						//}
184 220
 					}
185 221
 				}
186
-				if ($globalTransaction) $Connection->db->commit();
222
+				if ($globalTransaction) {
223
+					$Connection->db->commit();
224
+				}
187 225
 			} catch(PDOException $e) {
188
-				if ($globalTransaction) $Connection->db->rollBack(); 
226
+				if ($globalTransaction) {
227
+					$Connection->db->rollBack();
228
+				}
189 229
 				return "error : ".$e->getMessage();
190 230
 			}
191 231
 		}
@@ -228,11 +268,16 @@  discard block
 block discarded – undo
228 268
 		$sth_dest = $Connection->db->prepare($query_dest);
229 269
 		$sth_dest_owner = $Connection->db->prepare($query_dest_owner);
230 270
 		try {
231
-			if ($globalTransaction) $Connection->db->beginTransaction();
271
+			if ($globalTransaction) {
272
+				$Connection->db->beginTransaction();
273
+			}
232 274
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
233 275
 			//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
234
-				if ($values['UserString4'] == 'M') $type = 'military';
235
-				else $type = null;
276
+				if ($values['UserString4'] == 'M') {
277
+					$type = 'military';
278
+				} else {
279
+					$type = null;
280
+				}
236 281
 				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
237 282
 				$sth_dest->execute($query_dest_values);
238 283
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
@@ -240,7 +285,9 @@  discard block
 block discarded – undo
240 285
 				    $sth_dest_owner->execute($query_dest_owner_values);
241 286
 				}
242 287
             		}
243
-			if ($globalTransaction) $Connection->db->commit();
288
+			if ($globalTransaction) {
289
+				$Connection->db->commit();
290
+			}
244 291
 		} catch(PDOException $e) {
245 292
 			return "error : ".$e->getMessage();
246 293
 		}
@@ -276,7 +323,9 @@  discard block
 block discarded – undo
276 323
 			$Connection = new Connection();
277 324
 			$sth_dest = $Connection->db->prepare($query_dest);
278 325
 			try {
279
-				if ($globalTransaction) $Connection->db->beginTransaction();
326
+				if ($globalTransaction) {
327
+					$Connection->db->beginTransaction();
328
+				}
280 329
             			while (!feof($fh)) {
281 330
             				$values = array();
282 331
             				$line = $Common->hex2str(fgets($fh,9999));
@@ -287,7 +336,9 @@  discard block
 block discarded – undo
287 336
             				// Check if we can find ICAO, else set it to GLID
288 337
             				$aircraft_name_split = explode(' ',$aircraft_name);
289 338
             				$search_more = '';
290
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
339
+            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) {
340
+            					$search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
341
+            				}
291 342
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
292 343
             				$sth_search = $Connection->db->prepare($query_search);
293 344
 					try {
@@ -300,7 +351,9 @@  discard block
 block discarded – undo
300 351
 					} catch(PDOException $e) {
301 352
 						return "error : ".$e->getMessage();
302 353
 					}
303
-					if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
354
+					if (!isset($values['ICAOTypeCode'])) {
355
+						$values['ICAOTypeCode'] = 'GLID';
356
+					}
304 357
 					// Add data to db
305 358
 					if ($values['ModeS'] != '' && $values['Registration'] != '' && $values['Registration'] != '0000') {
306 359
 						//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
@@ -309,7 +362,9 @@  discard block
 block discarded – undo
309 362
 						$sth_dest->execute($query_dest_values);
310 363
 					}
311 364
 				}
312
-				if ($globalTransaction) $Connection->db->commit();
365
+				if ($globalTransaction) {
366
+					$Connection->db->commit();
367
+				}
313 368
 			} catch(PDOException $e) {
314 369
 				return "error : ".$e->getMessage();
315 370
 			}
@@ -345,7 +400,9 @@  discard block
 block discarded – undo
345 400
 			$Connection = new Connection();
346 401
 			$sth_dest = $Connection->db->prepare($query_dest);
347 402
 			try {
348
-				if ($globalTransaction) $Connection->db->beginTransaction();
403
+				if ($globalTransaction) {
404
+					$Connection->db->beginTransaction();
405
+				}
349 406
 				$tmp = fgetcsv($fh,9999,',',"'");
350 407
             			while (!feof($fh)) {
351 408
             				$line = fgetcsv($fh,9999,',',"'");
@@ -358,13 +415,17 @@  discard block
 block discarded – undo
358 415
             				// Check if we can find ICAO, else set it to GLID
359 416
             				$aircraft_name_split = explode(' ',$aircraft_name);
360 417
             				$search_more = '';
361
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
418
+            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) {
419
+            					$search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
420
+            				}
362 421
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
363 422
             				$sth_search = $Connection->db->prepare($query_search);
364 423
 					try {
365 424
                                     		$sth_search->execute();
366 425
 	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
367
-	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
426
+	            				if (isset($result['icao']) && $result['icao'] != '') {
427
+	            					$values['ICAOTypeCode'] = $result['icao'];
428
+	            				}
368 429
 					} catch(PDOException $e) {
369 430
 						return "error : ".$e->getMessage();
370 431
 					}
@@ -377,7 +438,9 @@  discard block
 block discarded – undo
377 438
 						$sth_dest->execute($query_dest_values);
378 439
 					}
379 440
 				}
380
-				if ($globalTransaction) $Connection->db->commit();
441
+				if ($globalTransaction) {
442
+					$Connection->db->commit();
443
+				}
381 444
 			} catch(PDOException $e) {
382 445
 				return "error : ".$e->getMessage();
383 446
 			}
@@ -413,7 +476,9 @@  discard block
 block discarded – undo
413 476
 			$Connection = new Connection();
414 477
 			$sth_dest = $Connection->db->prepare($query_dest);
415 478
 			try {
416
-				if ($globalTransaction) $Connection->db->beginTransaction();
479
+				if ($globalTransaction) {
480
+					$Connection->db->beginTransaction();
481
+				}
417 482
 				$tmp = fgetcsv($fh,9999,',','"');
418 483
             			while (!feof($fh)) {
419 484
             				$line = fgetcsv($fh,9999,',','"');
@@ -423,16 +488,22 @@  discard block
 block discarded – undo
423 488
             				    $values['registration'] = $line[0];
424 489
             				    $values['base'] = $line[4];
425 490
             				    $values['owner'] = $line[5];
426
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
427
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
491
+            				    if ($line[6] == '') {
492
+            				    	$values['date_first_reg'] = null;
493
+            				    } else {
494
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
495
+					    }
428 496
 					    $values['cancel'] = $line[7];
429 497
 					} elseif ($country == 'EI') {
430 498
 					    // TODO : add modeS & reg to aircraft_modes
431 499
             				    $values['registration'] = $line[0];
432 500
             				    $values['base'] = $line[3];
433 501
             				    $values['owner'] = $line[2];
434
-            				    if ($line[1] == '') $values['date_first_reg'] = null;
435
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
502
+            				    if ($line[1] == '') {
503
+            				    	$values['date_first_reg'] = null;
504
+            				    } else {
505
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
506
+					    }
436 507
 					    $values['cancel'] = '';
437 508
 					} elseif ($country == 'HB') {
438 509
 					    // TODO : add modeS & reg to aircraft_modes
@@ -446,16 +517,22 @@  discard block
 block discarded – undo
446 517
             				    $values['registration'] = $line[3];
447 518
             				    $values['base'] = null;
448 519
             				    $values['owner'] = $line[5];
449
-            				    if ($line[18] == '') $values['date_first_reg'] = null;
450
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
520
+            				    if ($line[18] == '') {
521
+            				    	$values['date_first_reg'] = null;
522
+            				    } else {
523
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
524
+					    }
451 525
 					    $values['cancel'] = '';
452 526
 					} elseif ($country == 'VH') {
453 527
 					    // TODO : add modeS & reg to aircraft_modes
454 528
             				    $values['registration'] = $line[0];
455 529
             				    $values['base'] = null;
456 530
             				    $values['owner'] = $line[12];
457
-            				    if ($line[28] == '') $values['date_first_reg'] = null;
458
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
531
+            				    if ($line[28] == '') {
532
+            				    	$values['date_first_reg'] = null;
533
+            				    } else {
534
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
535
+					    }
459 536
 
460 537
 					    $values['cancel'] = $line[39];
461 538
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
@@ -474,29 +551,41 @@  discard block
 block discarded – undo
474 551
             				    $values['registration'] = $line[0];
475 552
             				    $values['base'] = null;
476 553
             				    $values['owner'] = $line[8];
477
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
478
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
554
+            				    if ($line[7] == '') {
555
+            				    	$values['date_first_reg'] = null;
556
+            				    } else {
557
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
558
+					    }
479 559
 					    $values['cancel'] = '';
480 560
 					} elseif ($country == 'PP') {
481 561
             				    $values['registration'] = $line[0];
482 562
             				    $values['base'] = null;
483 563
             				    $values['owner'] = $line[4];
484
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
485
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
564
+            				    if ($line[6] == '') {
565
+            				    	$values['date_first_reg'] = null;
566
+            				    } else {
567
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
568
+					    }
486 569
 					    $values['cancel'] = $line[7];
487 570
 					} elseif ($country == 'E7') {
488 571
             				    $values['registration'] = $line[0];
489 572
             				    $values['base'] = null;
490 573
             				    $values['owner'] = $line[4];
491
-            				    if ($line[5] == '') $values['date_first_reg'] = null;
492
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
574
+            				    if ($line[5] == '') {
575
+            				    	$values['date_first_reg'] = null;
576
+            				    } else {
577
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
578
+					    }
493 579
 					    $values['cancel'] = '';
494 580
 					} elseif ($country == '8Q') {
495 581
             				    $values['registration'] = $line[0];
496 582
             				    $values['base'] = null;
497 583
             				    $values['owner'] = $line[3];
498
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
499
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
584
+            				    if ($line[7] == '') {
585
+            				    	$values['date_first_reg'] = null;
586
+            				    } else {
587
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
588
+					    }
500 589
 					    $values['cancel'] = '';
501 590
 					} elseif ($country == 'ZK' || $country == 'OM' || $country == 'TF') {
502 591
             				    $values['registration'] = $line[0];
@@ -510,7 +599,9 @@  discard block
 block discarded – undo
510 599
 						$sth_dest->execute($query_dest_values);
511 600
 					}
512 601
 				}
513
-				if ($globalTransaction) $Connection->db->commit();
602
+				if ($globalTransaction) {
603
+					$Connection->db->commit();
604
+				}
514 605
 			} catch(PDOException $e) {
515 606
 				return "error : ".$e->getMessage();
516 607
 			}
@@ -644,25 +735,45 @@  discard block
 block discarded – undo
644 735
 		    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)";
645 736
 		$Connection = new Connection();
646 737
 		$sth_dest = $Connection->db->prepare($query_dest);
647
-		if ($globalTransaction) $Connection->db->beginTransaction();
738
+		if ($globalTransaction) {
739
+			$Connection->db->beginTransaction();
740
+		}
648 741
   
649 742
 		$i = 0;
650 743
 		while($row = sparql_fetch_array($result))
651 744
 		{
652 745
 			if ($i >= 1) {
653 746
 			//print_r($row);
654
-			if (!isset($row['iata'])) $row['iata'] = '';
655
-			if (!isset($row['icao'])) $row['icao'] = '';
656
-			if (!isset($row['type'])) $row['type'] = '';
657
-			if (!isset($row['altitude'])) $row['altitude'] = '';
747
+			if (!isset($row['iata'])) {
748
+				$row['iata'] = '';
749
+			}
750
+			if (!isset($row['icao'])) {
751
+				$row['icao'] = '';
752
+			}
753
+			if (!isset($row['type'])) {
754
+				$row['type'] = '';
755
+			}
756
+			if (!isset($row['altitude'])) {
757
+				$row['altitude'] = '';
758
+			}
658 759
 			if (isset($row['city_bis'])) {
659 760
 				$row['city'] = $row['city_bis'];
660 761
 			}
661
-			if (!isset($row['city'])) $row['city'] = '';
662
-			if (!isset($row['country'])) $row['country'] = '';
663
-			if (!isset($row['homepage'])) $row['homepage'] = '';
664
-			if (!isset($row['wikipedia_page'])) $row['wikipedia_page'] = '';
665
-			if (!isset($row['name'])) continue;
762
+			if (!isset($row['city'])) {
763
+				$row['city'] = '';
764
+			}
765
+			if (!isset($row['country'])) {
766
+				$row['country'] = '';
767
+			}
768
+			if (!isset($row['homepage'])) {
769
+				$row['homepage'] = '';
770
+			}
771
+			if (!isset($row['wikipedia_page'])) {
772
+				$row['wikipedia_page'] = '';
773
+			}
774
+			if (!isset($row['name'])) {
775
+				continue;
776
+			}
666 777
 			if (!isset($row['image'])) {
667 778
 				$row['image'] = '';
668 779
 				$row['image_thumb'] = '';
@@ -698,7 +809,9 @@  discard block
 block discarded – undo
698 809
 
699 810
 			$i++;
700 811
 		}
701
-		if ($globalTransaction) $Connection->db->commit();
812
+		if ($globalTransaction) {
813
+			$Connection->db->commit();
814
+		}
702 815
 		echo "Delete duplicate rows...\n";
703 816
 		$query = 'ALTER IGNORE TABLE airport ADD UNIQUE INDEX icaoidx (icao)';
704 817
 		try {
@@ -710,7 +823,9 @@  discard block
 block discarded – undo
710 823
                 }
711 824
 
712 825
 
713
-		if ($globalDebug) echo "Insert Not available Airport...\n";
826
+		if ($globalDebug) {
827
+			echo "Insert Not available Airport...\n";
828
+		}
714 829
 		$query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image`,`image_thumb`)
715 830
 		    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image, :image_thumb)";
716 831
 		$query_values = array(':airport_id' => $i, ':name' => 'Not available',':iata' => 'NA',':icao' => 'NA',':latitude' => '0',':longitude' => '0',':altitude' => '0',':type' => 'NA',':city' => 'N/A',':country' => 'N/A',':home_link' => '',':wikipedia_link' => '',':image' => '',':image_thumb' => '');
@@ -737,7 +852,9 @@  discard block
 block discarded – undo
737 852
 		$delimiter = ',';
738 853
 		$out_file = $tmp_dir.'airports.csv';
739 854
 		update_db::download('http://ourairports.com/data/airports.csv',$out_file);
740
-		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
855
+		if (!file_exists($out_file) || !is_readable($out_file)) {
856
+			return FALSE;
857
+		}
741 858
 		echo "Add data from ourairports.com...\n";
742 859
 
743 860
 		$header = NULL;
@@ -747,8 +864,9 @@  discard block
 block discarded – undo
747 864
 			//$Connection->db->beginTransaction();
748 865
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
749 866
 			{
750
-				if(!$header) $header = $row;
751
-				else {
867
+				if(!$header) {
868
+					$header = $row;
869
+				} else {
752 870
 					$data = array();
753 871
 					$data = array_combine($header, $row);
754 872
 					try {
@@ -786,7 +904,9 @@  discard block
 block discarded – undo
786 904
 		echo "Download data from another free database...\n";
787 905
 		$out_file = $tmp_dir.'GlobalAirportDatabase.zip';
788 906
 		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file);
789
-		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
907
+		if (!file_exists($out_file) || !is_readable($out_file)) {
908
+			return FALSE;
909
+		}
790 910
 		update_db::unzip($out_file);
791 911
 		$header = NULL;
792 912
 		echo "Add data from another free database...\n";
@@ -797,8 +917,9 @@  discard block
 block discarded – undo
797 917
 			//$Connection->db->beginTransaction();
798 918
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
799 919
 			{
800
-				if(!$header) $header = $row;
801
-				else {
920
+				if(!$header) {
921
+					$header = $row;
922
+				} else {
802 923
 					$data = $row;
803 924
 
804 925
 					$query = 'UPDATE airport SET `city` = :city, `country` = :country WHERE icao = :icao';
@@ -1090,7 +1211,9 @@  discard block
 block discarded – undo
1090 1211
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1091 1212
 		{
1092 1213
 			$i = 0;
1093
-			if ($globalTransaction) $Connection->db->beginTransaction();
1214
+			if ($globalTransaction) {
1215
+				$Connection->db->beginTransaction();
1216
+			}
1094 1217
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1095 1218
 			{
1096 1219
 				$i++;
@@ -1118,7 +1241,9 @@  discard block
 block discarded – undo
1118 1241
 				}
1119 1242
 			}
1120 1243
 			fclose($handle);
1121
-			if ($globalTransaction) $Connection->db->commit();
1244
+			if ($globalTransaction) {
1245
+				$Connection->db->commit();
1246
+			}
1122 1247
 		}
1123 1248
 		return '';
1124 1249
         }
@@ -1141,7 +1266,9 @@  discard block
 block discarded – undo
1141 1266
 		$Connection = new Connection();
1142 1267
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1143 1268
 		{
1144
-			if ($globalTransaction) $Connection->db->beginTransaction();
1269
+			if ($globalTransaction) {
1270
+				$Connection->db->beginTransaction();
1271
+			}
1145 1272
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1146 1273
 			{
1147 1274
 				if(count($row) > 1) {
@@ -1155,7 +1282,9 @@  discard block
 block discarded – undo
1155 1282
 				}
1156 1283
 			}
1157 1284
 			fclose($handle);
1158
-			if ($globalTransaction) $Connection->db->commit();
1285
+			if ($globalTransaction) {
1286
+				$Connection->db->commit();
1287
+			}
1159 1288
 		}
1160 1289
 		return '';
1161 1290
         }
@@ -1175,8 +1304,9 @@  discard block
 block discarded – undo
1175 1304
 	        }
1176 1305
 
1177 1306
 
1178
-		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1179
-		else {
1307
+		if ($globalDBdriver == 'mysql') {
1308
+			update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1309
+		} else {
1180 1310
 			update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql');
1181 1311
 			$query = "CREATE EXTENSION postgis";
1182 1312
 			$Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']);
@@ -1195,20 +1325,30 @@  discard block
 block discarded – undo
1195 1325
 		global $tmp_dir, $globalDebug;
1196 1326
 		include_once('class.create_db.php');
1197 1327
 		require_once(dirname(__FILE__).'/../require/class.NOTAM.php');
1198
-		if ($globalDebug) echo "NOTAM from FlightAirMap website : Download...";
1328
+		if ($globalDebug) {
1329
+			echo "NOTAM from FlightAirMap website : Download...";
1330
+		}
1199 1331
 		update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz');
1200 1332
 		$error = '';
1201 1333
 		if (file_exists($tmp_dir.'notam.txt.gz')) {
1202
-			if ($globalDebug) echo "Gunzip...";
1334
+			if ($globalDebug) {
1335
+				echo "Gunzip...";
1336
+			}
1203 1337
 			update_db::gunzip($tmp_dir.'notam.txt.gz');
1204
-			if ($globalDebug) echo "Add to DB...";
1338
+			if ($globalDebug) {
1339
+				echo "Add to DB...";
1340
+			}
1205 1341
 			//$error = create_db::import_file($tmp_dir.'notam.sql');
1206 1342
 			$NOTAM = new NOTAM();
1207 1343
 			$NOTAM->updateNOTAMfromTextFile($tmp_dir.'notam.txt');
1208
-		} else $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";
1344
+		} else {
1345
+			$error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";
1346
+		}
1209 1347
 		if ($error != '') {
1210 1348
 			return $error;
1211
-		} elseif ($globalDebug) echo "Done\n";
1349
+		} elseif ($globalDebug) {
1350
+			echo "Done\n";
1351
+		}
1212 1352
 		return '';
1213 1353
 	}
1214 1354
 
@@ -1262,67 +1402,111 @@  discard block
 block discarded – undo
1262 1402
 		//if ($globalDebug) echo "IVAO : Download...";
1263 1403
 		//update_db::download('http://fr.mirror.ivao.aero/software/ivae_feb2013.zip',$tmp_dir.'ivae_feb2013.zip');
1264 1404
 		if (file_exists($tmp_dir.'ivae_feb2013.zip')) {
1265
-			if ($globalDebug) echo "Unzip...";
1405
+			if ($globalDebug) {
1406
+				echo "Unzip...";
1407
+			}
1266 1408
 			update_db::unzip($tmp_dir.'ivae_feb2013.zip');
1267
-			if ($globalDebug) echo "Add to DB...";
1409
+			if ($globalDebug) {
1410
+				echo "Add to DB...";
1411
+			}
1268 1412
 			update_db::ivao_airlines($tmp_dir.'data/airlines.dat');
1269
-			if ($globalDebug) echo "Copy airlines logos to airlines images directory...";
1413
+			if ($globalDebug) {
1414
+				echo "Copy airlines logos to airlines images directory...";
1415
+			}
1270 1416
 			if (is_writable(dirname(__FILE__).'/../images/airlines')) {
1271
-				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
1272
-			} else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
1273
-		} else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
1417
+				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) {
1418
+					$error = "Failed to copy airlines logo.";
1419
+				}
1420
+			} else {
1421
+				$error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
1422
+			}
1423
+		} else {
1424
+			$error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
1425
+		}
1274 1426
 		if ($error != '') {
1275 1427
 			return $error;
1276
-		} elseif ($globalDebug) echo "Done\n";
1428
+		} elseif ($globalDebug) {
1429
+			echo "Done\n";
1430
+		}
1277 1431
 		return '';
1278 1432
 	}
1279 1433
 
1280 1434
 	public static function update_routes() {
1281 1435
 		global $tmp_dir, $globalDebug;
1282 1436
 		$error = '';
1283
-		if ($globalDebug) echo "Routes : Download...";
1437
+		if ($globalDebug) {
1438
+			echo "Routes : Download...";
1439
+		}
1284 1440
 		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz');
1285 1441
 		if (file_exists($tmp_dir.'StandingData.sqb.gz')) {
1286
-			if ($globalDebug) echo "Gunzip...";
1442
+			if ($globalDebug) {
1443
+				echo "Gunzip...";
1444
+			}
1287 1445
 			update_db::gunzip($tmp_dir.'StandingData.sqb.gz');
1288
-			if ($globalDebug) echo "Add to DB...";
1446
+			if ($globalDebug) {
1447
+				echo "Add to DB...";
1448
+			}
1289 1449
 			$error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb');
1290
-		} else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
1450
+		} else {
1451
+			$error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
1452
+		}
1291 1453
 		if ($error != '') {
1292 1454
 			return $error;
1293
-		} elseif ($globalDebug) echo "Done\n";
1455
+		} elseif ($globalDebug) {
1456
+			echo "Done\n";
1457
+		}
1294 1458
 		return '';
1295 1459
 	}
1296 1460
 	public static function update_oneworld() {
1297 1461
 		global $tmp_dir, $globalDebug;
1298 1462
 		$error = '';
1299
-		if ($globalDebug) echo "Schedules Oneworld : Download...";
1463
+		if ($globalDebug) {
1464
+			echo "Schedules Oneworld : Download...";
1465
+		}
1300 1466
 		update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz');
1301 1467
 		if (file_exists($tmp_dir.'oneworld.csv.gz')) {
1302
-			if ($globalDebug) echo "Gunzip...";
1468
+			if ($globalDebug) {
1469
+				echo "Gunzip...";
1470
+			}
1303 1471
 			update_db::gunzip($tmp_dir.'oneworld.csv.gz');
1304
-			if ($globalDebug) echo "Add to DB...";
1472
+			if ($globalDebug) {
1473
+				echo "Add to DB...";
1474
+			}
1305 1475
 			$error = update_db::retrieve_route_oneworld($tmp_dir.'oneworld.csv');
1306
-		} else $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
1476
+		} else {
1477
+			$error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
1478
+		}
1307 1479
 		if ($error != '') {
1308 1480
 			return $error;
1309
-		} elseif ($globalDebug) echo "Done\n";
1481
+		} elseif ($globalDebug) {
1482
+			echo "Done\n";
1483
+		}
1310 1484
 		return '';
1311 1485
 	}
1312 1486
 	public static function update_skyteam() {
1313 1487
 		global $tmp_dir, $globalDebug;
1314 1488
 		$error = '';
1315
-		if ($globalDebug) echo "Schedules Skyteam : Download...";
1489
+		if ($globalDebug) {
1490
+			echo "Schedules Skyteam : Download...";
1491
+		}
1316 1492
 		update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz');
1317 1493
 		if (file_exists($tmp_dir.'skyteam.csv.gz')) {
1318
-			if ($globalDebug) echo "Gunzip...";
1494
+			if ($globalDebug) {
1495
+				echo "Gunzip...";
1496
+			}
1319 1497
 			update_db::gunzip($tmp_dir.'skyteam.csv.gz');
1320
-			if ($globalDebug) echo "Add to DB...";
1498
+			if ($globalDebug) {
1499
+				echo "Add to DB...";
1500
+			}
1321 1501
 			$error = update_db::retrieve_route_skyteam($tmp_dir.'skyteam.csv');
1322
-		} else $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
1502
+		} else {
1503
+			$error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
1504
+		}
1323 1505
 		if ($error != '') {
1324 1506
 			return $error;
1325
-		} elseif ($globalDebug) echo "Done\n";
1507
+		} elseif ($globalDebug) {
1508
+			echo "Done\n";
1509
+		}
1326 1510
 		return '';
1327 1511
 	}
1328 1512
 	public static function update_ModeS() {
@@ -1339,263 +1523,463 @@  discard block
 block discarded – undo
1339 1523
 			exit;
1340 1524
 		} elseif ($globalDebug) echo "Done\n";
1341 1525
 */
1342
-		if ($globalDebug) echo "Modes : Download...";
1526
+		if ($globalDebug) {
1527
+			echo "Modes : Download...";
1528
+		}
1343 1529
 		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
1344 1530
 		if (file_exists($tmp_dir.'basestation_latest.zip')) {
1345
-			if ($globalDebug) echo "Unzip...";
1531
+			if ($globalDebug) {
1532
+				echo "Unzip...";
1533
+			}
1346 1534
 			update_db::unzip($tmp_dir.'basestation_latest.zip');
1347
-			if ($globalDebug) echo "Add to DB...";
1535
+			if ($globalDebug) {
1536
+				echo "Add to DB...";
1537
+			}
1348 1538
 			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb');
1349
-		} else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
1539
+		} else {
1540
+			$error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
1541
+		}
1350 1542
 		if ($error != '') {
1351 1543
 			return $error;
1352
-		} elseif ($globalDebug) echo "Done\n";
1544
+		} elseif ($globalDebug) {
1545
+			echo "Done\n";
1546
+		}
1353 1547
 		return '';
1354 1548
 	}
1355 1549
 
1356 1550
 	public static function update_ModeS_flarm() {
1357 1551
 		global $tmp_dir, $globalDebug;
1358
-		if ($globalDebug) echo "Modes Flarmnet: Download...";
1552
+		if ($globalDebug) {
1553
+			echo "Modes Flarmnet: Download...";
1554
+		}
1359 1555
 		update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln');
1360 1556
 		if (file_exists($tmp_dir.'data.fln')) {
1361
-			if ($globalDebug) echo "Add to DB...";
1557
+			if ($globalDebug) {
1558
+				echo "Add to DB...";
1559
+			}
1362 1560
 			$error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln');
1363
-		} else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";
1561
+		} else {
1562
+			$error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";
1563
+		}
1364 1564
 		if ($error != '') {
1365 1565
 			return $error;
1366
-		} elseif ($globalDebug) echo "Done\n";
1566
+		} elseif ($globalDebug) {
1567
+			echo "Done\n";
1568
+		}
1367 1569
 		return '';
1368 1570
 	}
1369 1571
 
1370 1572
 	public static function update_ModeS_ogn() {
1371 1573
 		global $tmp_dir, $globalDebug;
1372
-		if ($globalDebug) echo "Modes OGN: Download...";
1574
+		if ($globalDebug) {
1575
+			echo "Modes OGN: Download...";
1576
+		}
1373 1577
 		update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv');
1374 1578
 		if (file_exists($tmp_dir.'ogn.csv')) {
1375
-			if ($globalDebug) echo "Add to DB...";
1579
+			if ($globalDebug) {
1580
+				echo "Add to DB...";
1581
+			}
1376 1582
 			$error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv');
1377
-		} else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";
1583
+		} else {
1584
+			$error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";
1585
+		}
1378 1586
 		if ($error != '') {
1379 1587
 			return $error;
1380
-		} elseif ($globalDebug) echo "Done\n";
1588
+		} elseif ($globalDebug) {
1589
+			echo "Done\n";
1590
+		}
1381 1591
 		return '';
1382 1592
 	}
1383 1593
 
1384 1594
 	public static function update_owner() {
1385 1595
 		global $tmp_dir, $globalDebug;
1386 1596
 		
1387
-		if ($globalDebug) echo "Owner France: Download...";
1597
+		if ($globalDebug) {
1598
+			echo "Owner France: Download...";
1599
+		}
1388 1600
 		update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv');
1389 1601
 		if (file_exists($tmp_dir.'owner_f.csv')) {
1390
-			if ($globalDebug) echo "Add to DB...";
1602
+			if ($globalDebug) {
1603
+				echo "Add to DB...";
1604
+			}
1391 1605
 			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F');
1392
-		} else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
1606
+		} else {
1607
+			$error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
1608
+		}
1393 1609
 		if ($error != '') {
1394 1610
 			return $error;
1395
-		} elseif ($globalDebug) echo "Done\n";
1611
+		} elseif ($globalDebug) {
1612
+			echo "Done\n";
1613
+		}
1396 1614
 		
1397
-		if ($globalDebug) echo "Owner Ireland: Download...";
1615
+		if ($globalDebug) {
1616
+			echo "Owner Ireland: Download...";
1617
+		}
1398 1618
 		update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv');
1399 1619
 		if (file_exists($tmp_dir.'owner_ei.csv')) {
1400
-			if ($globalDebug) echo "Add to DB...";
1620
+			if ($globalDebug) {
1621
+				echo "Add to DB...";
1622
+			}
1401 1623
 			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI');
1402
-		} else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
1624
+		} else {
1625
+			$error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
1626
+		}
1403 1627
 		if ($error != '') {
1404 1628
 			return $error;
1405
-		} elseif ($globalDebug) echo "Done\n";
1406
-		if ($globalDebug) echo "Owner Switzerland: Download...";
1629
+		} elseif ($globalDebug) {
1630
+			echo "Done\n";
1631
+		}
1632
+		if ($globalDebug) {
1633
+			echo "Owner Switzerland: Download...";
1634
+		}
1407 1635
 		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv');
1408 1636
 		if (file_exists($tmp_dir.'owner_hb.csv')) {
1409
-			if ($globalDebug) echo "Add to DB...";
1637
+			if ($globalDebug) {
1638
+				echo "Add to DB...";
1639
+			}
1410 1640
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB');
1411
-		} else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
1641
+		} else {
1642
+			$error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
1643
+		}
1412 1644
 		if ($error != '') {
1413 1645
 			return $error;
1414
-		} elseif ($globalDebug) echo "Done\n";
1415
-		if ($globalDebug) echo "Owner Czech Republic: Download...";
1646
+		} elseif ($globalDebug) {
1647
+			echo "Done\n";
1648
+		}
1649
+		if ($globalDebug) {
1650
+			echo "Owner Czech Republic: Download...";
1651
+		}
1416 1652
 		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv');
1417 1653
 		if (file_exists($tmp_dir.'owner_ok.csv')) {
1418
-			if ($globalDebug) echo "Add to DB...";
1654
+			if ($globalDebug) {
1655
+				echo "Add to DB...";
1656
+			}
1419 1657
 			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK');
1420
-		} else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
1658
+		} else {
1659
+			$error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
1660
+		}
1421 1661
 		if ($error != '') {
1422 1662
 			return $error;
1423
-		} elseif ($globalDebug) echo "Done\n";
1424
-		if ($globalDebug) echo "Owner Australia: Download...";
1663
+		} elseif ($globalDebug) {
1664
+			echo "Done\n";
1665
+		}
1666
+		if ($globalDebug) {
1667
+			echo "Owner Australia: Download...";
1668
+		}
1425 1669
 		update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv');
1426 1670
 		if (file_exists($tmp_dir.'owner_vh.csv')) {
1427
-			if ($globalDebug) echo "Add to DB...";
1671
+			if ($globalDebug) {
1672
+				echo "Add to DB...";
1673
+			}
1428 1674
 			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH');
1429
-		} else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
1675
+		} else {
1676
+			$error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
1677
+		}
1430 1678
 		if ($error != '') {
1431 1679
 			return $error;
1432
-		} elseif ($globalDebug) echo "Done\n";
1433
-		if ($globalDebug) echo "Owner Austria: Download...";
1680
+		} elseif ($globalDebug) {
1681
+			echo "Done\n";
1682
+		}
1683
+		if ($globalDebug) {
1684
+			echo "Owner Austria: Download...";
1685
+		}
1434 1686
 		update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv');
1435 1687
 		if (file_exists($tmp_dir.'owner_oe.csv')) {
1436
-			if ($globalDebug) echo "Add to DB...";
1688
+			if ($globalDebug) {
1689
+				echo "Add to DB...";
1690
+			}
1437 1691
 			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE');
1438
-		} else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
1692
+		} else {
1693
+			$error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
1694
+		}
1439 1695
 		if ($error != '') {
1440 1696
 			return $error;
1441
-		} elseif ($globalDebug) echo "Done\n";
1442
-		if ($globalDebug) echo "Owner Chile: Download...";
1697
+		} elseif ($globalDebug) {
1698
+			echo "Done\n";
1699
+		}
1700
+		if ($globalDebug) {
1701
+			echo "Owner Chile: Download...";
1702
+		}
1443 1703
 		update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv');
1444 1704
 		if (file_exists($tmp_dir.'owner_cc.csv')) {
1445
-			if ($globalDebug) echo "Add to DB...";
1705
+			if ($globalDebug) {
1706
+				echo "Add to DB...";
1707
+			}
1446 1708
 			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC');
1447
-		} else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
1709
+		} else {
1710
+			$error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
1711
+		}
1448 1712
 		if ($error != '') {
1449 1713
 			return $error;
1450
-		} elseif ($globalDebug) echo "Done\n";
1451
-		if ($globalDebug) echo "Owner Colombia: Download...";
1714
+		} elseif ($globalDebug) {
1715
+			echo "Done\n";
1716
+		}
1717
+		if ($globalDebug) {
1718
+			echo "Owner Colombia: Download...";
1719
+		}
1452 1720
 		update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv');
1453 1721
 		if (file_exists($tmp_dir.'owner_hj.csv')) {
1454
-			if ($globalDebug) echo "Add to DB...";
1722
+			if ($globalDebug) {
1723
+				echo "Add to DB...";
1724
+			}
1455 1725
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ');
1456
-		} else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
1726
+		} else {
1727
+			$error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
1728
+		}
1457 1729
 		if ($error != '') {
1458 1730
 			return $error;
1459
-		} elseif ($globalDebug) echo "Done\n";
1460
-		if ($globalDebug) echo "Owner Bosnia Herzegobina: Download...";
1731
+		} elseif ($globalDebug) {
1732
+			echo "Done\n";
1733
+		}
1734
+		if ($globalDebug) {
1735
+			echo "Owner Bosnia Herzegobina: Download...";
1736
+		}
1461 1737
 		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv');
1462 1738
 		if (file_exists($tmp_dir.'owner_e7.csv')) {
1463
-			if ($globalDebug) echo "Add to DB...";
1739
+			if ($globalDebug) {
1740
+				echo "Add to DB...";
1741
+			}
1464 1742
 			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7');
1465
-		} else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
1743
+		} else {
1744
+			$error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
1745
+		}
1466 1746
 		if ($error != '') {
1467 1747
 			return $error;
1468
-		} elseif ($globalDebug) echo "Done\n";
1469
-		if ($globalDebug) echo "Owner Brazil: Download...";
1748
+		} elseif ($globalDebug) {
1749
+			echo "Done\n";
1750
+		}
1751
+		if ($globalDebug) {
1752
+			echo "Owner Brazil: Download...";
1753
+		}
1470 1754
 		update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv');
1471 1755
 		if (file_exists($tmp_dir.'owner_pp.csv')) {
1472
-			if ($globalDebug) echo "Add to DB...";
1756
+			if ($globalDebug) {
1757
+				echo "Add to DB...";
1758
+			}
1473 1759
 			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP');
1474
-		} else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
1760
+		} else {
1761
+			$error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
1762
+		}
1475 1763
 		if ($error != '') {
1476 1764
 			return $error;
1477
-		} elseif ($globalDebug) echo "Done\n";
1478
-		if ($globalDebug) echo "Owner Cayman Islands: Download...";
1765
+		} elseif ($globalDebug) {
1766
+			echo "Done\n";
1767
+		}
1768
+		if ($globalDebug) {
1769
+			echo "Owner Cayman Islands: Download...";
1770
+		}
1479 1771
 		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv');
1480 1772
 		if (file_exists($tmp_dir.'owner_vp.csv')) {
1481
-			if ($globalDebug) echo "Add to DB...";
1773
+			if ($globalDebug) {
1774
+				echo "Add to DB...";
1775
+			}
1482 1776
 			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP');
1483
-		} else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
1777
+		} else {
1778
+			$error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
1779
+		}
1484 1780
 		if ($error != '') {
1485 1781
 			return $error;
1486
-		} elseif ($globalDebug) echo "Done\n";
1487
-		if ($globalDebug) echo "Owner Croatia: Download...";
1782
+		} elseif ($globalDebug) {
1783
+			echo "Done\n";
1784
+		}
1785
+		if ($globalDebug) {
1786
+			echo "Owner Croatia: Download...";
1787
+		}
1488 1788
 		update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv');
1489 1789
 		if (file_exists($tmp_dir.'owner_9a.csv')) {
1490
-			if ($globalDebug) echo "Add to DB...";
1790
+			if ($globalDebug) {
1791
+				echo "Add to DB...";
1792
+			}
1491 1793
 			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A');
1492
-		} else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
1794
+		} else {
1795
+			$error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
1796
+		}
1493 1797
 		if ($error != '') {
1494 1798
 			return $error;
1495
-		} elseif ($globalDebug) echo "Done\n";
1496
-		if ($globalDebug) echo "Owner Luxembourg: Download...";
1799
+		} elseif ($globalDebug) {
1800
+			echo "Done\n";
1801
+		}
1802
+		if ($globalDebug) {
1803
+			echo "Owner Luxembourg: Download...";
1804
+		}
1497 1805
 		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv');
1498 1806
 		if (file_exists($tmp_dir.'owner_lx.csv')) {
1499
-			if ($globalDebug) echo "Add to DB...";
1807
+			if ($globalDebug) {
1808
+				echo "Add to DB...";
1809
+			}
1500 1810
 			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX');
1501
-		} else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
1811
+		} else {
1812
+			$error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
1813
+		}
1502 1814
 		if ($error != '') {
1503 1815
 			return $error;
1504
-		} elseif ($globalDebug) echo "Done\n";
1505
-		if ($globalDebug) echo "Owner Maldives: Download...";
1816
+		} elseif ($globalDebug) {
1817
+			echo "Done\n";
1818
+		}
1819
+		if ($globalDebug) {
1820
+			echo "Owner Maldives: Download...";
1821
+		}
1506 1822
 		update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv');
1507 1823
 		if (file_exists($tmp_dir.'owner_8q.csv')) {
1508
-			if ($globalDebug) echo "Add to DB...";
1824
+			if ($globalDebug) {
1825
+				echo "Add to DB...";
1826
+			}
1509 1827
 			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q');
1510
-		} else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
1828
+		} else {
1829
+			$error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
1830
+		}
1511 1831
 		if ($error != '') {
1512 1832
 			return $error;
1513
-		} elseif ($globalDebug) echo "Done\n";
1514
-		if ($globalDebug) echo "Owner New Zealand: Download...";
1833
+		} elseif ($globalDebug) {
1834
+			echo "Done\n";
1835
+		}
1836
+		if ($globalDebug) {
1837
+			echo "Owner New Zealand: Download...";
1838
+		}
1515 1839
 		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv');
1516 1840
 		if (file_exists($tmp_dir.'owner_zk.csv')) {
1517
-			if ($globalDebug) echo "Add to DB...";
1841
+			if ($globalDebug) {
1842
+				echo "Add to DB...";
1843
+			}
1518 1844
 			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK');
1519
-		} else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
1845
+		} else {
1846
+			$error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
1847
+		}
1520 1848
 		if ($error != '') {
1521 1849
 			return $error;
1522
-		} elseif ($globalDebug) echo "Done\n";
1523
-		if ($globalDebug) echo "Owner Papua New Guinea: Download...";
1850
+		} elseif ($globalDebug) {
1851
+			echo "Done\n";
1852
+		}
1853
+		if ($globalDebug) {
1854
+			echo "Owner Papua New Guinea: Download...";
1855
+		}
1524 1856
 		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv');
1525 1857
 		if (file_exists($tmp_dir.'owner_p2.csv')) {
1526
-			if ($globalDebug) echo "Add to DB...";
1858
+			if ($globalDebug) {
1859
+				echo "Add to DB...";
1860
+			}
1527 1861
 			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2');
1528
-		} else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
1862
+		} else {
1863
+			$error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
1864
+		}
1529 1865
 		if ($error != '') {
1530 1866
 			return $error;
1531
-		} elseif ($globalDebug) echo "Done\n";
1532
-		if ($globalDebug) echo "Owner Slovakia: Download...";
1867
+		} elseif ($globalDebug) {
1868
+			echo "Done\n";
1869
+		}
1870
+		if ($globalDebug) {
1871
+			echo "Owner Slovakia: Download...";
1872
+		}
1533 1873
 		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv');
1534 1874
 		if (file_exists($tmp_dir.'owner_om.csv')) {
1535
-			if ($globalDebug) echo "Add to DB...";
1875
+			if ($globalDebug) {
1876
+				echo "Add to DB...";
1877
+			}
1536 1878
 			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM');
1537
-		} else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
1879
+		} else {
1880
+			$error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
1881
+		}
1538 1882
 		if ($error != '') {
1539 1883
 			return $error;
1540
-		} elseif ($globalDebug) echo "Done\n";
1541
-		if ($globalDebug) echo "Owner Ecuador: Download...";
1884
+		} elseif ($globalDebug) {
1885
+			echo "Done\n";
1886
+		}
1887
+		if ($globalDebug) {
1888
+			echo "Owner Ecuador: Download...";
1889
+		}
1542 1890
 		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv');
1543 1891
 		if (file_exists($tmp_dir.'owner_hc.csv')) {
1544
-			if ($globalDebug) echo "Add to DB...";
1892
+			if ($globalDebug) {
1893
+				echo "Add to DB...";
1894
+			}
1545 1895
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC');
1546
-		} else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
1896
+		} else {
1897
+			$error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
1898
+		}
1547 1899
 		if ($error != '') {
1548 1900
 			return $error;
1549
-		} elseif ($globalDebug) echo "Done\n";
1550
-		if ($globalDebug) echo "Owner Iceland: Download...";
1901
+		} elseif ($globalDebug) {
1902
+			echo "Done\n";
1903
+		}
1904
+		if ($globalDebug) {
1905
+			echo "Owner Iceland: Download...";
1906
+		}
1551 1907
 		update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv');
1552 1908
 		if (file_exists($tmp_dir.'owner_tf.csv')) {
1553
-			if ($globalDebug) echo "Add to DB...";
1909
+			if ($globalDebug) {
1910
+				echo "Add to DB...";
1911
+			}
1554 1912
 			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF');
1555
-		} else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
1913
+		} else {
1914
+			$error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
1915
+		}
1556 1916
 		if ($error != '') {
1557 1917
 			return $error;
1558
-		} elseif ($globalDebug) echo "Done\n";
1918
+		} elseif ($globalDebug) {
1919
+			echo "Done\n";
1920
+		}
1559 1921
 		return '';
1560 1922
 	}
1561 1923
 
1562 1924
 	public static function update_translation() {
1563 1925
 		global $tmp_dir, $globalDebug;
1564 1926
 		$error = '';
1565
-		if ($globalDebug) echo "Translation : Download...";
1927
+		if ($globalDebug) {
1928
+			echo "Translation : Download...";
1929
+		}
1566 1930
 		update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip');
1567 1931
 		if (file_exists($tmp_dir.'translation.zip')) {
1568
-			if ($globalDebug) echo "Unzip...";
1932
+			if ($globalDebug) {
1933
+				echo "Unzip...";
1934
+			}
1569 1935
 			update_db::unzip($tmp_dir.'translation.zip');
1570
-			if ($globalDebug) echo "Add to DB...";
1936
+			if ($globalDebug) {
1937
+				echo "Add to DB...";
1938
+			}
1571 1939
 			$error = update_db::translation();
1572
-		} else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
1940
+		} else {
1941
+			$error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
1942
+		}
1573 1943
 		if ($error != '') {
1574 1944
 			return $error;
1575
-		} elseif ($globalDebug) echo "Done\n";
1945
+		} elseif ($globalDebug) {
1946
+			echo "Done\n";
1947
+		}
1576 1948
 		return '';
1577 1949
 	}
1578 1950
 
1579 1951
 	public static function update_translation_fam() {
1580 1952
 		global $tmp_dir, $globalDebug;
1581
-		if ($globalDebug) echo "Translation from FlightAirMap website : Download...";
1953
+		if ($globalDebug) {
1954
+			echo "Translation from FlightAirMap website : Download...";
1955
+		}
1582 1956
 		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz');
1583 1957
 		if (file_exists($tmp_dir.'translation.tsv.gz')) {
1584
-			if ($globalDebug) echo "Gunzip...";
1958
+			if ($globalDebug) {
1959
+				echo "Gunzip...";
1960
+			}
1585 1961
 			update_db::gunzip($tmp_dir.'translation.tsv.gz');
1586
-			if ($globalDebug) echo "Add to DB...";
1962
+			if ($globalDebug) {
1963
+				echo "Add to DB...";
1964
+			}
1587 1965
 			$error = update_db::translation_fam();
1588
-		} else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
1966
+		} else {
1967
+			$error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
1968
+		}
1589 1969
 		if ($error != '') {
1590 1970
 			return $error;
1591
-		} elseif ($globalDebug) echo "Done\n";
1971
+		} elseif ($globalDebug) {
1972
+			echo "Done\n";
1973
+		}
1592 1974
 		return '';
1593 1975
 	}
1594 1976
 
1595 1977
 	public static function update_airspace_fam() {
1596 1978
 		global $tmp_dir, $globalDebug, $globalDBdriver;
1597 1979
 		include_once('class.create_db.php');
1598
-		if ($globalDebug) echo "Airspace from FlightAirMap website : Download...";
1980
+		if ($globalDebug) {
1981
+			echo "Airspace from FlightAirMap website : Download...";
1982
+		}
1599 1983
 		if ($globalDBdriver == 'mysql') {
1600 1984
 			update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
1601 1985
 		} else {
@@ -1611,9 +1995,13 @@  discard block
 block discarded – undo
1611 1995
 					update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz');
1612 1996
 				}
1613 1997
 				if (file_exists($tmp_dir.'airspace.sql.gz')) {
1614
-					if ($globalDebug) echo "Gunzip...";
1998
+					if ($globalDebug) {
1999
+						echo "Gunzip...";
2000
+					}
1615 2001
 					update_db::gunzip($tmp_dir.'airspace.sql.gz');
1616
-					if ($globalDebug) echo "Add to DB...";
2002
+					if ($globalDebug) {
2003
+						echo "Add to DB...";
2004
+					}
1617 2005
 					$Connection = new Connection();
1618 2006
 					if ($Connection->tableExists('airspace')) {
1619 2007
 						$query = 'DROP TABLE airspace';
@@ -1626,31 +2014,47 @@  discard block
 block discarded – undo
1626 2014
 		    			}
1627 2015
 					$error = create_db::import_file($tmp_dir.'airspace.sql');
1628 2016
 					update_db::insert_airspace_version($airspace_md5);
1629
-				} else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed.";
2017
+				} else {
2018
+					$error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed.";
2019
+				}
1630 2020
 			}
1631
-		} else $error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed.";
2021
+		} else {
2022
+			$error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed.";
2023
+		}
1632 2024
 		if ($error != '') {
1633 2025
 			return $error;
1634
-		} elseif ($globalDebug) echo "Done\n";
2026
+		} elseif ($globalDebug) {
2027
+			echo "Done\n";
2028
+		}
1635 2029
 		return '';
1636 2030
 	}
1637 2031
 
1638 2032
 	public static function update_tle() {
1639 2033
 		global $tmp_dir, $globalDebug;
1640
-		if ($globalDebug) echo "Download TLE : Download...";
2034
+		if ($globalDebug) {
2035
+			echo "Download TLE : Download...";
2036
+		}
1641 2037
 		$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',
1642 2038
 		'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',
1643 2039
 		'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt');
1644 2040
 		foreach ($alltle as $filename) {
1645
-			if ($globalDebug) echo "downloading ".$filename.'...';
2041
+			if ($globalDebug) {
2042
+				echo "downloading ".$filename.'...';
2043
+			}
1646 2044
 			update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename);
1647 2045
 			if (file_exists($tmp_dir.$filename)) {
1648
-				if ($globalDebug) echo "Add to DB ".$filename."...";
2046
+				if ($globalDebug) {
2047
+					echo "Add to DB ".$filename."...";
2048
+				}
1649 2049
 				$error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename));
1650
-			} else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
2050
+			} else {
2051
+				$error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
2052
+			}
1651 2053
 			if ($error != '') {
1652 2054
 				echo $error."\n";
1653
-			} elseif ($globalDebug) echo "Done\n";
2055
+			} elseif ($globalDebug) {
2056
+				echo "Done\n";
2057
+			}
1654 2058
 		}
1655 2059
 		return '';
1656 2060
 	}
@@ -1658,10 +2062,14 @@  discard block
 block discarded – undo
1658 2062
 	public static function update_models() {
1659 2063
 		global $tmp_dir, $globalDebug;
1660 2064
 		$error = '';
1661
-		if ($globalDebug) echo "Models from FlightAirMap website : Download...";
2065
+		if ($globalDebug) {
2066
+			echo "Models from FlightAirMap website : Download...";
2067
+		}
1662 2068
 		update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum');
1663 2069
 		if (file_exists($tmp_dir.'models.md5sum')) {
1664
-			if ($globalDebug) echo "Check files...\n";
2070
+			if ($globalDebug) {
2071
+				echo "Check files...\n";
2072
+			}
1665 2073
 			$newmodelsdb = array();
1666 2074
 			if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) {
1667 2075
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -1680,25 +2088,35 @@  discard block
 block discarded – undo
1680 2088
 			}
1681 2089
 			$diff = array_diff($newmodelsdb,$modelsdb);
1682 2090
 			foreach ($diff as $key => $value) {
1683
-				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
2091
+				if ($globalDebug) {
2092
+					echo 'Downloading model '.$key.' ...'."\n";
2093
+				}
1684 2094
 				update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key);
1685 2095
 				
1686 2096
 			}
1687 2097
 			update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum');
1688
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2098
+		} else {
2099
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2100
+		}
1689 2101
 		if ($error != '') {
1690 2102
 			return $error;
1691
-		} elseif ($globalDebug) echo "Done\n";
2103
+		} elseif ($globalDebug) {
2104
+			echo "Done\n";
2105
+		}
1692 2106
 		return '';
1693 2107
 	}
1694 2108
 
1695 2109
 	public static function update_space_models() {
1696 2110
 		global $tmp_dir, $globalDebug;
1697 2111
 		$error = '';
1698
-		if ($globalDebug) echo "Space models from FlightAirMap website : Download...";
2112
+		if ($globalDebug) {
2113
+			echo "Space models from FlightAirMap website : Download...";
2114
+		}
1699 2115
 		update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum');
1700 2116
 		if (file_exists($tmp_dir.'space_models.md5sum')) {
1701
-			if ($globalDebug) echo "Check files...\n";
2117
+			if ($globalDebug) {
2118
+				echo "Check files...\n";
2119
+			}
1702 2120
 			$newmodelsdb = array();
1703 2121
 			if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) {
1704 2122
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -1717,15 +2135,21 @@  discard block
 block discarded – undo
1717 2135
 			}
1718 2136
 			$diff = array_diff($newmodelsdb,$modelsdb);
1719 2137
 			foreach ($diff as $key => $value) {
1720
-				if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n";
2138
+				if ($globalDebug) {
2139
+					echo 'Downloading space model '.$key.' ...'."\n";
2140
+				}
1721 2141
 				update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key);
1722 2142
 				
1723 2143
 			}
1724 2144
 			update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum');
1725
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2145
+		} else {
2146
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2147
+		}
1726 2148
 		if ($error != '') {
1727 2149
 			return $error;
1728
-		} elseif ($globalDebug) echo "Done\n";
2150
+		} elseif ($globalDebug) {
2151
+			echo "Done\n";
2152
+		}
1729 2153
 		return '';
1730 2154
 	}
1731 2155
 
@@ -1768,7 +2192,9 @@  discard block
 block discarded – undo
1768 2192
                 }
1769 2193
 
1770 2194
 		$error = '';
1771
-		if ($globalDebug) echo "Notam : Download...";
2195
+		if ($globalDebug) {
2196
+			echo "Notam : Download...";
2197
+		}
1772 2198
 		update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss');
1773 2199
 		if (file_exists($tmp_dir.'notam.rss')) {
1774 2200
 			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true);
@@ -1783,14 +2209,30 @@  discard block
 block discarded – undo
1783 2209
 				$data['fir'] = $q[0];
1784 2210
 				$data['code'] = $q[1];
1785 2211
 				$ifrvfr = $q[2];
1786
-				if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR';
1787
-				if ($ifrvfr == 'I') $data['rules'] = 'IFR';
1788
-				if ($ifrvfr == 'V') $data['rules'] = 'VFR';
1789
-				if ($q[4] == 'A') $data['scope'] = 'Airport warning';
1790
-				if ($q[4] == 'E') $data['scope'] = 'Enroute warning';
1791
-				if ($q[4] == 'W') $data['scope'] = 'Navigation warning';
1792
-				if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning';
1793
-				if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning';
2212
+				if ($ifrvfr == 'IV') {
2213
+					$data['rules'] = 'IFR/VFR';
2214
+				}
2215
+				if ($ifrvfr == 'I') {
2216
+					$data['rules'] = 'IFR';
2217
+				}
2218
+				if ($ifrvfr == 'V') {
2219
+					$data['rules'] = 'VFR';
2220
+				}
2221
+				if ($q[4] == 'A') {
2222
+					$data['scope'] = 'Airport warning';
2223
+				}
2224
+				if ($q[4] == 'E') {
2225
+					$data['scope'] = 'Enroute warning';
2226
+				}
2227
+				if ($q[4] == 'W') {
2228
+					$data['scope'] = 'Navigation warning';
2229
+				}
2230
+				if ($q[4] == 'AE') {
2231
+					$data['scope'] = 'Airport/Enroute warning';
2232
+				}
2233
+				if ($q[4] == 'AW') {
2234
+					$data['scope'] = 'Airport/Navigation warning';
2235
+				}
1794 2236
 				//$data['scope'] = $q[4];
1795 2237
 				$data['lower_limit'] = $q[5];
1796 2238
 				$data['upper_limit'] = $q[6];
@@ -1798,8 +2240,12 @@  discard block
 block discarded – undo
1798 2240
 				sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius);
1799 2241
 				$latitude = $Common->convertDec($las,'latitude');
1800 2242
 				$longitude = $Common->convertDec($lns,'longitude');
1801
-				if ($lac == 'S') $latitude = '-'.$latitude;
1802
-				if ($lnc == 'W') $longitude = '-'.$longitude;
2243
+				if ($lac == 'S') {
2244
+					$latitude = '-'.$latitude;
2245
+				}
2246
+				if ($lnc == 'W') {
2247
+					$longitude = '-'.$longitude;
2248
+				}
1803 2249
 				$data['center_latitude'] = $latitude;
1804 2250
 				$data['center_longitude'] = $longitude;
1805 2251
 				$data['radius'] = intval($radius);
@@ -1829,10 +2275,14 @@  discard block
 block discarded – undo
1829 2275
 				$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']);
1830 2276
 				unset($data);
1831 2277
 			} 
1832
-		} else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
2278
+		} else {
2279
+			$error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
2280
+		}
1833 2281
 		if ($error != '') {
1834 2282
 			return $error;
1835
-		} elseif ($globalDebug) echo "Done\n";
2283
+		} elseif ($globalDebug) {
2284
+			echo "Done\n";
2285
+		}
1836 2286
 		return '';
1837 2287
 	}
1838 2288
 	
@@ -1857,7 +2307,9 @@  discard block
 block discarded – undo
1857 2307
 		$airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json');
1858 2308
 		$airspace_json = json_decode($airspace_lst,true);
1859 2309
 		foreach ($airspace_json['records'] as $airspace) {
1860
-			if ($globalDebug) echo $airspace['name']."...\n";
2310
+			if ($globalDebug) {
2311
+				echo $airspace['name']."...\n";
2312
+			}
1861 2313
 			update_db::download($airspace['uri'],$tmp_dir.$airspace['name']);
1862 2314
 			if (file_exists($tmp_dir.$airspace['name'])) {
1863 2315
 				file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name'])));
@@ -1886,8 +2338,11 @@  discard block
 block discarded – undo
1886 2338
                         return "error : ".$e->getMessage();
1887 2339
                 }
1888 2340
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
1889
-                if ($row['nb'] > 0) return false;
1890
-                else return true;
2341
+                if ($row['nb'] > 0) {
2342
+                	return false;
2343
+                } else {
2344
+                	return true;
2345
+                }
1891 2346
 	}
1892 2347
 
1893 2348
 	public static function insert_last_update() {
@@ -1912,8 +2367,11 @@  discard block
 block discarded – undo
1912 2367
                         return "error : ".$e->getMessage();
1913 2368
                 }
1914 2369
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
1915
-                if ($row['nb'] > 0) return true;
1916
-                else return false;
2370
+                if ($row['nb'] > 0) {
2371
+                	return true;
2372
+                } else {
2373
+                	return false;
2374
+                }
1917 2375
 	}
1918 2376
 
1919 2377
 
@@ -1944,8 +2402,11 @@  discard block
 block discarded – undo
1944 2402
                         return "error : ".$e->getMessage();
1945 2403
                 }
1946 2404
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
1947
-                if ($row['nb'] > 0) return false;
1948
-                else return true;
2405
+                if ($row['nb'] > 0) {
2406
+                	return false;
2407
+                } else {
2408
+                	return true;
2409
+                }
1949 2410
 	}
1950 2411
 
1951 2412
 	public static function insert_last_notam_update() {
@@ -1974,8 +2435,11 @@  discard block
 block discarded – undo
1974 2435
                         return "error : ".$e->getMessage();
1975 2436
                 }
1976 2437
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
1977
-                if ($row['nb'] > 0) return false;
1978
-                else return true;
2438
+                if ($row['nb'] > 0) {
2439
+                	return false;
2440
+                } else {
2441
+                	return true;
2442
+                }
1979 2443
 	}
1980 2444
 
1981 2445
 	public static function insert_last_airspace_update() {
@@ -2005,8 +2469,11 @@  discard block
 block discarded – undo
2005 2469
                         return "error : ".$e->getMessage();
2006 2470
                 }
2007 2471
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2008
-                if ($row['nb'] > 0) return false;
2009
-                else return true;
2472
+                if ($row['nb'] > 0) {
2473
+                	return false;
2474
+                } else {
2475
+                	return true;
2476
+                }
2010 2477
 	}
2011 2478
 
2012 2479
 	public static function insert_last_owner_update() {
@@ -2035,8 +2502,11 @@  discard block
 block discarded – undo
2035 2502
                         return "error : ".$e->getMessage();
2036 2503
                 }
2037 2504
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2038
-                if ($row['nb'] > 0) return false;
2039
-                else return true;
2505
+                if ($row['nb'] > 0) {
2506
+                	return false;
2507
+                } else {
2508
+                	return true;
2509
+                }
2040 2510
 	}
2041 2511
 
2042 2512
 	public static function insert_last_schedules_update() {
@@ -2065,8 +2535,11 @@  discard block
 block discarded – undo
2065 2535
                         return "error : ".$e->getMessage();
2066 2536
                 }
2067 2537
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2068
-                if ($row['nb'] > 0) return false;
2069
-                else return true;
2538
+                if ($row['nb'] > 0) {
2539
+                	return false;
2540
+                } else {
2541
+                	return true;
2542
+                }
2070 2543
 	}
2071 2544
 
2072 2545
 	public static function insert_last_tle_update() {
Please login to merge, or discard this patch.
require/class.Connection.php 1 patch
Braces   +77 added lines, -30 removed lines patch added patch discarded remove patch
@@ -64,8 +64,11 @@  discard block
 block discarded – undo
64 64
 				$globalDBSname = $globalDBname;
65 65
 				$globalDBSuser = $globalDBuser;
66 66
 				$globalDBSpass = $globalDBpass;
67
-				if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') $globalDBSport = 3306;
68
-				else $globalDBSport = $globalDBport;
67
+				if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') {
68
+					$globalDBSport = 3306;
69
+				} else {
70
+					$globalDBSport = $globalDBport;
71
+				}
69 72
 			} else {
70 73
 				$DBname = 'default';
71 74
 				$globalDBSdriver = $globalDBdriver;
@@ -73,8 +76,11 @@  discard block
 block discarded – undo
73 76
 				$globalDBSname = $globalDBname;
74 77
 				$globalDBSuser = $user;
75 78
 				$globalDBSpass = $pass;
76
-				if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') $globalDBSport = 3306;
77
-				else $globalDBSport = $globalDBport;
79
+				if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') {
80
+					$globalDBSport = 3306;
81
+				} else {
82
+					$globalDBSport = $globalDBport;
83
+				}
78 84
 			}
79 85
 		} else {
80 86
 			$globalDBSdriver = $globalDB[$DBname]['driver'];
@@ -82,11 +88,16 @@  discard block
 block discarded – undo
82 88
 			$globalDBSname = $globalDB[$DBname]['name'];
83 89
 			$globalDBSuser = $globalDB[$DBname]['user'];
84 90
 			$globalDBSpass = $globalDB[$DBname]['pass'];
85
-			if (isset($globalDB[$DBname]['port'])) $globalDBSport = $globalDB[$DBname]['port'];
86
-			else $globalDBSport = 3306;
91
+			if (isset($globalDB[$DBname]['port'])) {
92
+				$globalDBSport = $globalDB[$DBname]['port'];
93
+			} else {
94
+				$globalDBSport = 3306;
95
+			}
87 96
 		}
88 97
 		// Set number of try to connect to DB
89
-		if (!isset($globalDBretry) || $globalDBretry == '' || $globalDBretry === NULL) $globalDBretry = 5;
98
+		if (!isset($globalDBretry) || $globalDBretry == '' || $globalDBretry === NULL) {
99
+			$globalDBretry = 5;
100
+		}
90 101
 		$i = 0;
91 102
 		while (true) {
92 103
 			try {
@@ -95,10 +106,16 @@  discard block
 block discarded – undo
95 106
 					$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'");
96 107
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
97 108
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER);
98
-					if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,500);
99
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut);
100
-					if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true);
101
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent);
109
+					if (!isset($globalDBTimeOut)) {
110
+						$this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,500);
111
+					} else {
112
+						$this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut);
113
+					}
114
+					if (!isset($globalDBPersistent)) {
115
+						$this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true);
116
+					} else {
117
+						$this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent);
118
+					}
102 119
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
103 120
 					$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
104 121
 					// Workaround against "ONLY_FULL_GROUP_BY" mode
@@ -112,22 +129,34 @@  discard block
 block discarded – undo
112 129
 					//$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'");
113 130
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
114 131
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER);
115
-					if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200);
116
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut);
117
-					if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true);
118
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent);
132
+					if (!isset($globalDBTimeOut)) {
133
+						$this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200);
134
+					} else {
135
+						$this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut);
136
+					}
137
+					if (!isset($globalDBPersistent)) {
138
+						$this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true);
139
+					} else {
140
+						$this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent);
141
+					}
119 142
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
120 143
 				}
121 144
 				break;
122 145
 			} catch(PDOException $e) {
123 146
 				$i++;
124
-				if (isset($globalDebug) && $globalDebug) echo $e->getMessage()."\n";
147
+				if (isset($globalDebug) && $globalDebug) {
148
+					echo $e->getMessage()."\n";
149
+				}
125 150
 				//exit;
126
-				if ($i > $globalDBretry) return false;
151
+				if ($i > $globalDBretry) {
152
+					return false;
153
+				}
127 154
 				//return false;
128 155
 			}
129 156
 		}
130
-		if ($DBname === 'default') $this->db = $this->dbs['default'];
157
+		if ($DBname === 'default') {
158
+			$this->db = $this->dbs['default'];
159
+		}
131 160
 		return true;
132 161
 	}
133 162
 
@@ -139,7 +168,9 @@  discard block
 block discarded – undo
139 168
 		} else {
140 169
 			$query = "SELECT * FROM pg_catalog.pg_tables WHERE tablename = '".$table."'";
141 170
 		}
142
-		if ($this->db == NULL) return false;
171
+		if ($this->db == NULL) {
172
+			return false;
173
+		}
143 174
 		try {
144 175
 			//$Connection = new Connection();
145 176
 			$results = $this->db->query($query);
@@ -148,21 +179,28 @@  discard block
 block discarded – undo
148 179
 		}
149 180
 		if($results->rowCount()>0) {
150 181
 		    return true; 
182
+		} else {
183
+			return false;
151 184
 		}
152
-		else return false;
153 185
 	}
154 186
 
155 187
 	public function connectionExists()
156 188
 	{
157 189
 		global $globalDBdriver, $globalDBCheckConnection;
158
-		if (isset($globalDBCheckConnection) && $globalDBCheckConnection === FALSE) return true;
190
+		if (isset($globalDBCheckConnection) && $globalDBCheckConnection === FALSE) {
191
+			return true;
192
+		}
159 193
 		$query = "SELECT 1 + 1";
160
-		if ($this->db === null) return false;
194
+		if ($this->db === null) {
195
+			return false;
196
+		}
161 197
 		try {
162 198
 			$sum = @$this->db->query($query);
163 199
 			if ($sum instanceof \PDOStatement) {
164 200
 				$sum = $sum->fetchColumn(0);
165
-			} else $sum = 0;
201
+			} else {
202
+				$sum = 0;
203
+			}
166 204
 			if (intval($sum) !== 2) {
167 205
 			     return false;
168 206
 			}
@@ -196,8 +234,9 @@  discard block
 block discarded – undo
196 234
 		}
197 235
 		if($results->rowCount()>0) {
198 236
 		    return true; 
237
+		} else {
238
+			return false;
199 239
 		}
200
-		else return false;
201 240
 	}
202 241
 
203 242
 	/*
@@ -240,9 +279,12 @@  discard block
 block discarded – undo
240 279
 				echo "error : ".$e->getMessage()."\n";
241 280
 			}
242 281
 			$result = $sth->fetch(PDO::FETCH_ASSOC);
243
-			if ($result['nb'] > 0) return true;
244
-			else return false;
245
-/*		} else {
282
+			if ($result['nb'] > 0) {
283
+				return true;
284
+			} else {
285
+				return false;
286
+			}
287
+			/*		} else {
246 288
 			$query = "SELECT * FROM ".$table." LIMIT 0";
247 289
 			try {
248 290
 				$results = $this->db->query($query);
@@ -280,7 +322,9 @@  discard block
 block discarded – undo
280 322
 				$result = $sth->fetch(PDO::FETCH_ASSOC);
281 323
 				return $result['value'];
282 324
 			}
283
-		} else return $version;
325
+		} else {
326
+			return $version;
327
+		}
284 328
 	}
285 329
 	
286 330
 	/*
@@ -288,8 +332,11 @@  discard block
 block discarded – undo
288 332
 	* @return Boolean if latest version or not
289 333
 	*/
290 334
 	public function latest() {
291
-	    if ($this->check_schema_version() == $this->latest_schema) return true;
292
-	    else return false;
335
+	    if ($this->check_schema_version() == $this->latest_schema) {
336
+	    	return true;
337
+	    } else {
338
+	    	return false;
339
+	    }
293 340
 	}
294 341
 
295 342
 }
Please login to merge, or discard this patch.
install/index.php 1 patch
Braces   +409 added lines, -106 removed lines patch added patch discarded remove patch
@@ -124,45 +124,72 @@  discard block
 block discarded – undo
124 124
 			</div>
125 125
 			<p>
126 126
 				<label for="dbhost">Database hostname</label>
127
-				<input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) print $globalDBhost; ?>" />
127
+				<input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) {
128
+	print $globalDBhost;
129
+}
130
+?>" />
128 131
 			</p>
129 132
 			<p>
130 133
 				<label for="dbport">Database port</label>
131
-				<input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) print $globalDBport; ?>" />
134
+				<input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) {
135
+	print $globalDBport;
136
+}
137
+?>" />
132 138
 				<p class="help-block">Default is 3306 for MariaDB/MySQL, 5432 for PostgreSQL</p>
133 139
 			</p>
134 140
 			<p>
135 141
 				<label for="dbname">Database name</label>
136
-				<input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) print $globalDBname; ?>" />
142
+				<input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) {
143
+	print $globalDBname;
144
+}
145
+?>" />
137 146
 			</p>
138 147
 			<p>
139 148
 				<label for="dbuser">Database user</label>
140
-				<input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) print $globalDBuser; ?>" />
149
+				<input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) {
150
+	print $globalDBuser;
151
+}
152
+?>" />
141 153
 			</p>
142 154
 			<p>
143 155
 				<label for="dbuserpass">Database user password</label>
144
-				<input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) print $globalDBpass; ?>" />
156
+				<input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) {
157
+	print $globalDBpass;
158
+}
159
+?>" />
145 160
 			</p>
146 161
 		</fieldset>
147 162
 		<fieldset id="site">
148 163
 			<legend>Site configuration</legend>
149 164
 			<p>
150 165
 				<label for="sitename">Site name</label>
151
-				<input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) print $globalName; ?>" />
166
+				<input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) {
167
+	print $globalName;
168
+}
169
+?>" />
152 170
 			</p>
153 171
 			<p>
154 172
 				<label for="siteurl">Site directory</label>
155
-				<input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) print $globalURL; ?>" />
173
+				<input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) {
174
+	print $globalURL;
175
+}
176
+?>" />
156 177
 				<p class="help-block">Can be null. ex : <i>flightairmap</i> if complete URL is <i>http://toto.com/flightairmap</i></p>
157 178
 			</p>
158 179
 			<p>
159 180
 				<label for="timezone">Timezone</label>
160
-				<input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) print $globalTimezone; ?>" />
181
+				<input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) {
182
+	print $globalTimezone;
183
+}
184
+?>" />
161 185
 				<p class="help-block">ex : UTC, Europe/Paris,...</p>
162 186
 			</p>
163 187
 			<p>
164 188
 				<label for="language">Language</label>
165
-				<input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) print $globalLanguage; ?>" />
189
+				<input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) {
190
+	print $globalLanguage;
191
+}
192
+?>" />
166 193
 				<p class="help-block">Used only when link to wikipedia for now. Can be EN,DE,FR,...</p>
167 194
 			</p>
168 195
 		</fieldset>
@@ -183,11 +210,17 @@  discard block
 block discarded – undo
183 210
 			<div id="mapbox_data">
184 211
 				<p>
185 212
 					<label for="mapboxid">Mapbox id</label>
186
-					<input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) print $globalMapboxId; ?>" />
213
+					<input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) {
214
+	print $globalMapboxId;
215
+}
216
+?>" />
187 217
 				</p>
188 218
 				<p>
189 219
 					<label for="mapboxtoken">Mapbox token</label>
190
-					<input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) print $globalMapboxToken; ?>" />
220
+					<input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) {
221
+	print $globalMapboxToken;
222
+}
223
+?>" />
191 224
 				</p>
192 225
 				<p class="help-block">Get a key <a href="https://www.mapbox.com/developers/">here</a></p>
193 226
 			</div>
@@ -195,7 +228,10 @@  discard block
 block discarded – undo
195 228
 			<div id="google_data">
196 229
 				<p>
197 230
 					<label for="googlekey">Google API key</label>
198
-					<input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) print $globalGoogleAPIKey; ?>" />
231
+					<input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) {
232
+	print $globalGoogleAPIKey;
233
+}
234
+?>" />
199 235
 					<p class="help-block">Get a key <a href="https://developers.google.com/maps/documentation/javascript/get-api-key#get-an-api-key">here</a></p>
200 236
 				</p>
201 237
 			</div>
@@ -203,7 +239,10 @@  discard block
 block discarded – undo
203 239
 			<div id="bing_data">
204 240
 				<p>
205 241
 					<label for="bingkey">Bing Map key</label>
206
-					<input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) print $globalBingMapKey; ?>" />
242
+					<input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) {
243
+	print $globalBingMapKey;
244
+}
245
+?>" />
207 246
 					<p class="help-block">Get a key <a href="https://www.bingmapsportal.com/">here</a></p>
208 247
 				</p>
209 248
 			</div>
@@ -211,7 +250,10 @@  discard block
 block discarded – undo
211 250
 			<div id="mapquest_data">
212 251
 				<p>
213 252
 					<label for="mapquestkey">MapQuest key</label>
214
-					<input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) print $globalMapQuestKey; ?>" />
253
+					<input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) {
254
+	print $globalMapQuestKey;
255
+}
256
+?>" />
215 257
 					<p class="help-block">Get a key <a href="https://developer.mapquest.com/user/me/apps">here</a></p>
216 258
 				</p>
217 259
 			</div>
@@ -219,11 +261,17 @@  discard block
 block discarded – undo
219 261
 			<div id="here_data">
220 262
 				<p>
221 263
 					<label for="hereappid">Here App_Id</label>
222
-					<input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) print $globalHereappId; ?>" />
264
+					<input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) {
265
+	print $globalHereappId;
266
+}
267
+?>" />
223 268
 				</p>
224 269
 				<p>
225 270
 					<label for="hereappcode">Here App_Code</label>
226
-					<input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) print $globalHereappCode; ?>" />
271
+					<input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) {
272
+	print $globalHereappCode;
273
+}
274
+?>" />
227 275
 				</p>
228 276
 				<p class="help-block">Get a key <a href="https://developer.here.com/rest-apis/documentation/enterprise-map-tile/topics/quick-start.html">here</a></p>
229 277
 			</div>
@@ -232,42 +280,86 @@  discard block
 block discarded – undo
232 280
 			<legend>Coverage area</legend>
233 281
 			<p>
234 282
 				<label for="latitudemax">The maximum latitude (north)</label>
235
-				<input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) print $globalLatitudeMax; ?>" />
283
+				<input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) {
284
+	print $globalLatitudeMax;
285
+}
286
+?>" />
236 287
 			</p>
237 288
 			<p>
238 289
 				<label for="latitudemin">The minimum latitude (south)</label>
239
-				<input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) print $globalLatitudeMin; ?>" />
290
+				<input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) {
291
+	print $globalLatitudeMin;
292
+}
293
+?>" />
240 294
 			</p>
241 295
 			<p>
242 296
 				<label for="longitudemax">The maximum longitude (west)</label>
243
-				<input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) print $globalLongitudeMax; ?>" />
297
+				<input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) {
298
+	print $globalLongitudeMax;
299
+}
300
+?>" />
244 301
 			</p>
245 302
 			<p>
246 303
 				<label for="longitudemin">The minimum longitude (east)</label>
247
-				<input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) print $globalLongitudeMin; ?>" />
304
+				<input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) {
305
+	print $globalLongitudeMin;
306
+}
307
+?>" />
248 308
 			</p>
249 309
 			<p>
250 310
 				<label for="latitudecenter">The latitude center</label>
251
-				<input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) print $globalCenterLatitude; ?>" />
311
+				<input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) {
312
+	print $globalCenterLatitude;
313
+}
314
+?>" />
252 315
 			</p>
253 316
 			<p>
254 317
 				<label for="longitudecenter">The longitude center</label>
255
-				<input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) print $globalCenterLongitude; ?>" />
318
+				<input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) {
319
+	print $globalCenterLongitude;
320
+}
321
+?>" />
256 322
 			</p>
257 323
 			<p>
258 324
 				<label for="livezoom">Default Zoom on live map</label>
259
-				<input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) print $globalLiveZoom; else print '9'; ?>" />
325
+				<input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) {
326
+	print $globalLiveZoom;
327
+} else {
328
+	print '9';
329
+}
330
+?>" />
260 331
 			</p>
261 332
 			<p>
262 333
 				<label for="squawk_country">Country for squawk usage</label>
263 334
 				<select name="squawk_country" id="squawk_country">
264
-					<option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') print ' selected '; ?>>UK</option>
265
-					<option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') print ' selected '; ?>>NZ</option>
266
-					<option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') print ' selected '; ?>>US</option>
267
-					<option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') print ' selected '; ?>>AU</option>
268
-					<option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') print ' selected '; ?>>NL</option>
269
-					<option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') print ' selected '; ?>>FR</option>
270
-					<option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') print ' selected '; ?>>TR</option>
335
+					<option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') {
336
+	print ' selected ';
337
+}
338
+?>>UK</option>
339
+					<option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') {
340
+	print ' selected ';
341
+}
342
+?>>NZ</option>
343
+					<option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') {
344
+	print ' selected ';
345
+}
346
+?>>US</option>
347
+					<option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') {
348
+	print ' selected ';
349
+}
350
+?>>AU</option>
351
+					<option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') {
352
+	print ' selected ';
353
+}
354
+?>>NL</option>
355
+					<option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') {
356
+	print ' selected ';
357
+}
358
+?>>FR</option>
359
+					<option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') {
360
+	print ' selected ';
361
+}
362
+?>>TR</option>
271 363
 				</select>
272 364
 			</p>
273 365
 		</fieldset>
@@ -276,15 +368,24 @@  discard block
 block discarded – undo
276 368
 			<p><i>Only put in DB flights that are inside a circle</i></p>
277 369
 			<p>
278 370
 				<label for="latitude">Center latitude</label>
279
-				<input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) echo $globalDistanceIgnore['latitude']; ?>" />
371
+				<input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) {
372
+	echo $globalDistanceIgnore['latitude'];
373
+}
374
+?>" />
280 375
 			</p>
281 376
 			<p>
282 377
 				<label for="longitude">Center longitude</label>
283
-				<input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) echo $globalDistanceIgnore['longitude']; ?>" />
378
+				<input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) {
379
+	echo $globalDistanceIgnore['longitude'];
380
+}
381
+?>" />
284 382
 			</p>
285 383
 			<p>
286 384
 				<label for="Distance">Distance (in km)</label>
287
-				<input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) echo $globalDistanceIgnore['distance']; ?>" />
385
+				<input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) {
386
+	echo $globalDistanceIgnore['distance'];
387
+}
388
+?>" />
288 389
 			</p>
289 390
 		</fieldset>
290 391
 		<fieldset id="sourceloc">
@@ -379,11 +480,17 @@  discard block
 block discarded – undo
379 480
 			<div id="flightaware_data">
380 481
 				<p>
381 482
 					<label for="flightawareusername">FlightAware username</label>
382
-					<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) print $globalFlightAwareUsername; ?>" />
483
+					<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) {
484
+	print $globalFlightAwareUsername;
485
+}
486
+?>" />
383 487
 				</p>
384 488
 				<p>
385 489
 					<label for="flightawarepassword">FlightAware password/API key</label>
386
-					<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) print $globalFlightAwarePassword; ?>" />
490
+					<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) {
491
+	print $globalFlightAwarePassword;
492
+}
493
+?>" />
387 494
 				</p>
388 495
 			</div>
389 496
 -->
@@ -442,25 +549,76 @@  discard block
 block discarded – undo
442 549
 								?>
443 550
 								<td>
444 551
 									<select name="format[]" id="format">
445
-										<option value="auto" <?php if (!isset($source['format'])) print 'selected'; ?>>Auto</option>
446
-										<option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') print 'selected'; ?>>SBS</option>
447
-										<option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') print 'selected'; ?>>TSV</option>
448
-										<option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') print 'selected'; ?>>Raw</option>
449
-										<option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') print 'selected'; ?>>APRS</option>
450
-										<option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') print 'selected'; ?>>Radarcape deltadb.txt</option>
451
-										<option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') print 'selected'; ?>>Vatsim</option>
452
-										<option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') print 'selected'; ?>>Virtual Radar Server</option>
453
-										<option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') print 'selected'; ?>>phpVMS</option>
454
-										<option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') print 'selected'; ?>>Virtual Airlines Manager</option>
455
-										<option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') print 'selected'; ?>>IVAO</option>
456
-										<option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') print 'selected'; ?>>FlightGear Multiplayer</option>
457
-										<option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') print 'selected'; ?>>FlightGear Singleplayer</option>
458
-										<option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') print 'selected'; ?>>ACARS from acarsdec/acarsdeco2 over UDP</option>
459
-										<option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') print 'selected'; ?>>ACARS over SBS-3 TCP</option>
552
+										<option value="auto" <?php if (!isset($source['format'])) {
553
+	print 'selected';
554
+}
555
+?>>Auto</option>
556
+										<option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') {
557
+	print 'selected';
558
+}
559
+?>>SBS</option>
560
+										<option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') {
561
+	print 'selected';
562
+}
563
+?>>TSV</option>
564
+										<option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') {
565
+	print 'selected';
566
+}
567
+?>>Raw</option>
568
+										<option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') {
569
+	print 'selected';
570
+}
571
+?>>APRS</option>
572
+										<option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') {
573
+	print 'selected';
574
+}
575
+?>>Radarcape deltadb.txt</option>
576
+										<option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') {
577
+	print 'selected';
578
+}
579
+?>>Vatsim</option>
580
+										<option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') {
581
+	print 'selected';
582
+}
583
+?>>Virtual Radar Server</option>
584
+										<option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') {
585
+	print 'selected';
586
+}
587
+?>>phpVMS</option>
588
+										<option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') {
589
+	print 'selected';
590
+}
591
+?>>Virtual Airlines Manager</option>
592
+										<option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') {
593
+	print 'selected';
594
+}
595
+?>>IVAO</option>
596
+										<option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') {
597
+	print 'selected';
598
+}
599
+?>>FlightGear Multiplayer</option>
600
+										<option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') {
601
+	print 'selected';
602
+}
603
+?>>FlightGear Singleplayer</option>
604
+										<option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') {
605
+	print 'selected';
606
+}
607
+?>>ACARS from acarsdec/acarsdeco2 over UDP</option>
608
+										<option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') {
609
+	print 'selected';
610
+}
611
+?>>ACARS over SBS-3 TCP</option>
460 612
 									</select>
461 613
 								</td>
462
-								<td><input type="text" name="name[]" id="name" value="<?php if (isset($source['name'])) print $source['name']; ?>" /></td>
463
-								<td><input type="checkbox" name="sourcestats[]" id="sourcestats" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) print 'checked'; ?> /></td>
614
+								<td><input type="text" name="name[]" id="name" value="<?php if (isset($source['name'])) {
615
+	print $source['name'];
616
+}
617
+?>" /></td>
618
+								<td><input type="checkbox" name="sourcestats[]" id="sourcestats" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) {
619
+	print 'checked';
620
+}
621
+?> /></td>
464 622
 								<td><input type="button" id="delhost" value="Delete" onclick="deleteRow(this)" /> <input type="button" id="addhost" value="Add" onclick="insRow()" /></td>
465 623
 							</tr>
466 624
 <?php
@@ -506,11 +664,17 @@  discard block
 block discarded – undo
506 664
 					<p>Listen UDP server for acarsdec/acarsdeco2/... with <i>daemon-acars.php</i> script</p>
507 665
 					<p>
508 666
 						<label for="acarshost">ACARS UDP host</label>
509
-						<input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) print $globalACARSHost; ?>" />
667
+						<input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) {
668
+	print $globalACARSHost;
669
+}
670
+?>" />
510 671
 					</p>
511 672
 					<p>
512 673
 						<label for="acarsport">ACARS UDP port</label>
513
-						<input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) print $globalACARSPort; ?>" />
674
+						<input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) {
675
+	print $globalACARSPort;
676
+}
677
+?>" />
514 678
 					</p>
515 679
 				</fieldset>
516 680
 			</div>
@@ -585,13 +749,19 @@  discard block
 block discarded – undo
585 749
 			<div id="schedules_options">
586 750
 				<p>
587 751
 					<label for="britishairways">British Airways API Key</label>
588
-					<input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) print $globalBritishAirwaysKey; ?>" />
752
+					<input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) {
753
+	print $globalBritishAirwaysKey;
754
+}
755
+?>" />
589 756
 					<p class="help-block">Register an account on <a href="https://developer.ba.com/">https://developer.ba.com/</a></p>
590 757
 				</p>
591 758
 				<!--
592 759
 				<p>
593 760
 					<label for="transavia">Transavia Test API Consumer Key</label>
594
-					<input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) print $globalTransaviaKey; ?>" />
761
+					<input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) {
762
+	print $globalTransaviaKey;
763
+}
764
+?>" />
595 765
 					<p class="help-block">Register an account on <a href="https://developer.transavia.com">https://developer.transavia.com</a></p>
596 766
 				</p>
597 767
 				-->
@@ -600,10 +770,16 @@  discard block
 block discarded – undo
600 770
 						<b>Lufthansa API Key</b>
601 771
 						<p>
602 772
 							<label for="lufthansakey">Key</label>
603
-							<input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) print $globalLufthansaKey['key']; ?>" />
773
+							<input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) {
774
+	print $globalLufthansaKey['key'];
775
+}
776
+?>" />
604 777
 						</p><p>
605 778
 							<label for="lufthansasecret">Secret</label>
606
-							<input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) print $globalLufthansaKey['secret']; ?>" />
779
+							<input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) {
780
+	print $globalLufthansaKey['secret'];
781
+}
782
+?>" />
607 783
 						</p>
608 784
 					</div>
609 785
 					<p class="help-block">Register an account on <a href="https://developer.lufthansa.com/page">https://developer.lufthansa.com/page</a></p>
@@ -623,7 +799,10 @@  discard block
 block discarded – undo
623 799
 			</p>
624 800
 			<p>
625 801
 				<label for="notamsource">URL of your feed from notaminfo.com</label>
626
-				<input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) print $globalNOTAMSource; ?>" />
802
+				<input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) {
803
+	print $globalNOTAMSource;
804
+}
805
+?>" />
627 806
 				<p class="help-block">If you want to use world NOTAM from FlightAirMap website, leave it blank</p>
628 807
 			</p>
629 808
 			<br />
@@ -639,14 +818,20 @@  discard block
 block discarded – undo
639 818
 			<div id="metarsrc">
640 819
 				<p>
641 820
 					<label for="metarsource">URL of your METAR source</label>
642
-					<input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) print $globalMETARurl; ?>" />
821
+					<input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) {
822
+	print $globalMETARurl;
823
+}
824
+?>" />
643 825
 					<p class="help-block">Use {icao} to specify where we replace by airport icao. ex : http://metar.vatsim.net/metar.php?id={icao}</p>
644 826
 				</p>
645 827
 			</div>
646 828
 			<br />
647 829
 			<p>
648 830
 				<label for="bitly">Bit.ly access token api (used in search page)</label>
649
-				<input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) print $globalBitlyAccessToken; ?>" />
831
+				<input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) {
832
+	print $globalBitlyAccessToken;
833
+}
834
+?>" />
650 835
 			</p>
651 836
 			<br />
652 837
 			<p>
@@ -660,7 +845,12 @@  discard block
 block discarded – undo
660 845
 			</p>
661 846
 			<p>
662 847
 				<label for="archivemonths">Generate statistics, delete or put in archive flights older than xx months</label>
663
-				<input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) print $globalArchiveMonths; else echo '0'; ?>" />
848
+				<input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) {
849
+	print $globalArchiveMonths;
850
+} else {
851
+	echo '0';
852
+}
853
+?>" />
664 854
 				<p class="help-block">0 to disable, delete old flight if <i>Archive all flights data</i> is disabled</p>
665 855
 			</p>
666 856
 			<p>
@@ -670,12 +860,22 @@  discard block
 block discarded – undo
670 860
 			</p>
671 861
 			<p>
672 862
 				<label for="archivekeepmonths">Keep flights data for xx months in archive</label>
673
-				<input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) print $globalArchiveKeepMonths; else echo '0'; ?>" />
863
+				<input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) {
864
+	print $globalArchiveKeepMonths;
865
+} else {
866
+	echo '0';
867
+}
868
+?>" />
674 869
 				<p class="help-block">0 to disable</p>
675 870
 			</p>
676 871
 			<p>
677 872
 				<label for="archivekeeptrackmonths">Keep flights track data for xx months in archive</label>
678
-				<input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) print $globalArchiveKeepTrackMonths; else echo '0'; ?>" />
873
+				<input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) {
874
+	print $globalArchiveKeepTrackMonths;
875
+} else {
876
+	echo '0';
877
+}
878
+?>" />
679 879
 				<p class="help-block">0 to disable, should be less or egal to <i>Keep flights data</i> value</p>
680 880
 			</p>
681 881
 			<br />
@@ -685,7 +885,12 @@  discard block
 block discarded – undo
685 885
 				<p class="help-block">Uncheck if the script is running as cron job</p>
686 886
 				<div id="cronends"> 
687 887
 					<label for="cronend">Run script for xx seconds</label>
688
-					<input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) print $globalCronEnd; else print '0'; ?>" />
888
+					<input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) {
889
+	print $globalCronEnd;
890
+} else {
891
+	print '0';
892
+}
893
+?>" />
689 894
 					<p class="help-block">Set to 0 to disable. Should be disabled if source is URL.</p>
690 895
 				</div>
691 896
 			</p>
@@ -725,26 +930,49 @@  discard block
 block discarded – undo
725 930
 			<br />
726 931
 			<p>
727 932
 				<label for="refresh">Show flights detected since xxx seconds</label>
728
-				<input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) echo $globalLiveInterval; else echo '200'; ?>" />
933
+				<input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) {
934
+	echo $globalLiveInterval;
935
+} else {
936
+	echo '200';
937
+}
938
+?>" />
729 939
 			</p>
730 940
 			<p>
731 941
 				<label for="maprefresh">Live map refresh (in seconds)</label>
732
-				<input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) echo $globalMapRefresh; else echo '30'; ?>" />
942
+				<input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) {
943
+	echo $globalMapRefresh;
944
+} else {
945
+	echo '30';
946
+}
947
+?>" />
733 948
 			</p>
734 949
 			<p>
735 950
 				<label for="mapidle">Map idle timeout (in minutes)</label>
736
-				<input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) echo $globalMapIdleTimeout; else echo '30'; ?>" />
951
+				<input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) {
952
+	echo $globalMapIdleTimeout;
953
+} else {
954
+	echo '30';
955
+}
956
+?>" />
737 957
 				<p class="help-block">0 to disable</p>
738 958
 			</p>
739 959
 			<br />
740 960
 			<p>
741 961
 				<label for="closestmindist">Distance to airport set as arrival (in km)</label>
742
-				<input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) echo $globalClosestMinDist; else echo '50'; ?>" />
962
+				<input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) {
963
+	echo $globalClosestMinDist;
964
+} else {
965
+	echo '50';
966
+}
967
+?>" />
743 968
 			</p>
744 969
 			<br />
745 970
 			<p>
746 971
 				<label for="aircraftsize">Size of aircraft icon on map (default to 30px if zoom > 7 else 15px), empty to default</label>
747
-				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize;?>" />
972
+				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) {
973
+	echo $globalAircraftSize;
974
+}
975
+?>" />
748 976
 			</p>
749 977
 			<br />
750 978
 			<p>
@@ -752,7 +980,12 @@  discard block
 block discarded – undo
752 980
 			    if (extension_loaded('gd') && function_exists('gd_info')) {
753 981
 			?>
754 982
 				<label for="aircrafticoncolor">Color of aircraft icon on map</label>
755
-				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) echo $globalAircraftIconColor; else echo '1a3151'; ?>" />
983
+				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) {
984
+	echo $globalAircraftIconColor;
985
+} else {
986
+	echo '1a3151';
987
+}
988
+?>" />
756 989
 			<?php
757 990
 				if (!is_writable('../cache')) {
758 991
 			?>
@@ -770,8 +1003,18 @@  discard block
 block discarded – undo
770 1003
 			<p>
771 1004
 				<label for="airportzoom">Zoom level minimum to see airports icons</label>
772 1005
 				<div class="range">
773
-					<input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?>" />
774
-					<output id="range"><?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?></output>
1006
+					<input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) {
1007
+	echo $globalAirportZoom;
1008
+} else {
1009
+	echo '7';
1010
+}
1011
+?>" />
1012
+					<output id="range"><?php if (isset($globalAirportZoom)) {
1013
+	echo $globalAirportZoom;
1014
+} else {
1015
+	echo '7';
1016
+}
1017
+?></output>
775 1018
 				</div>
776 1019
 			</p>
777 1020
 		</fieldset>
@@ -799,8 +1042,12 @@  discard block
 block discarded – undo
799 1042
 	$dbhost = filter_input(INPUT_POST,'dbhost',FILTER_SANITIZE_STRING);
800 1043
 	$dbport = filter_input(INPUT_POST,'dbport',FILTER_SANITIZE_STRING);
801 1044
 
802
-	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) $error .= 'Mysql driver for PDO must be loaded';
803
-	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) $error .= 'PosgreSQL driver for PDO must be loaded';
1045
+	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) {
1046
+		$error .= 'Mysql driver for PDO must be loaded';
1047
+	}
1048
+	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) {
1049
+		$error .= 'PosgreSQL driver for PDO must be loaded';
1050
+	}
804 1051
 	
805 1052
 	$_SESSION['database_root'] = $dbroot;
806 1053
 	$_SESSION['database_rootpass'] = $dbrootpass;
@@ -867,15 +1114,23 @@  discard block
 block discarded – undo
867 1114
 	$source_city = $_POST['source_city'];
868 1115
 	$source_country = $_POST['source_country'];
869 1116
 	$source_ref = $_POST['source_ref'];
870
-	if (isset($source_id)) $source_id = $_POST['source_id'];
871
-	else $source_id = array();
1117
+	if (isset($source_id)) {
1118
+		$source_id = $_POST['source_id'];
1119
+	} else {
1120
+		$source_id = array();
1121
+	}
872 1122
 	
873 1123
 	$sources = array();
874 1124
 	foreach ($source_name as $keys => $name) {
875
-	    if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
876
-	    else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
1125
+	    if (isset($source_id[$keys])) {
1126
+	    	$sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
1127
+	    } else {
1128
+	    	$sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
1129
+	    }
1130
+	}
1131
+	if (count($sources) > 0) {
1132
+		$_SESSION['sources'] = $sources;
877 1133
 	}
878
-	if (count($sources) > 0) $_SESSION['sources'] = $sources;
879 1134
 
880 1135
 	//$sbshost = filter_input(INPUT_POST,'sbshost',FILTER_SANITIZE_STRING);
881 1136
 	//$sbsport = filter_input(INPUT_POST,'sbsport',FILTER_SANITIZE_NUMBER_INT);
@@ -913,13 +1168,21 @@  discard block
 block discarded – undo
913 1168
 	$port = $_POST['port'];
914 1169
 	$name = $_POST['name'];
915 1170
 	$format = $_POST['format'];
916
-	if (isset($_POST['sourcestats'])) $sourcestats = $_POST['sourcestats'];
917
-	else $sourcestats = array();
1171
+	if (isset($_POST['sourcestats'])) {
1172
+		$sourcestats = $_POST['sourcestats'];
1173
+	} else {
1174
+		$sourcestats = array();
1175
+	}
918 1176
 	$gSources = array();
919 1177
 	foreach ($host as $key => $h) {
920
-		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) $cov = 'TRUE';
921
-		else $cov = 'FALSE';
922
-		if ($h != '') $gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov);
1178
+		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) {
1179
+			$cov = 'TRUE';
1180
+		} else {
1181
+			$cov = 'FALSE';
1182
+		}
1183
+		if ($h != '') {
1184
+			$gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov);
1185
+		}
923 1186
 	}
924 1187
 	$settings = array_merge($settings,array('globalSources' => $gSources));
925 1188
 
@@ -943,7 +1206,9 @@  discard block
 block discarded – undo
943 1206
 	$zoidistance = filter_input(INPUT_POST,'zoidistance',FILTER_SANITIZE_NUMBER_INT);
944 1207
 	if ($zoilatitude != '' && $zoilongitude != '' && $zoidistance != '') {
945 1208
 		$settings = array_merge($settings,array('globalDistanceIgnore' => array('latitude' => $zoilatitude,'longitude' => $zoilongitude,'distance' => $zoidistance)));
946
-	} else $settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1209
+	} else {
1210
+		$settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1211
+	}
947 1212
 
948 1213
 	$refresh = filter_input(INPUT_POST,'refresh',FILTER_SANITIZE_NUMBER_INT);
949 1214
 	$settings = array_merge($settings,array('globalLiveInterval' => $refresh));
@@ -982,7 +1247,9 @@  discard block
 block discarded – undo
982 1247
 
983 1248
 	// Create in settings.php keys not yet configurable if not already here
984 1249
 	//if (!isset($globalImageBingKey)) $settings = array_merge($settings,array('globalImageBingKey' => ''));
985
-	if (!isset($globalDebug)) $settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1250
+	if (!isset($globalDebug)) {
1251
+		$settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1252
+	}
986 1253
 
987 1254
 	$archive = filter_input(INPUT_POST,'archive',FILTER_SANITIZE_STRING);
988 1255
 	if ($archive == 'archive') {
@@ -1012,27 +1279,43 @@  discard block
 block discarded – undo
1012 1279
 	}
1013 1280
 */
1014 1281
 	$settings = array_merge($settings,array('globalFlightAware' => 'FALSE'));
1015
-	if ($globalsbs == 'sbs') $settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1016
-	else $settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1017
-	if ($globalaprs == 'aprs') $settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1018
-	else $settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1282
+	if ($globalsbs == 'sbs') {
1283
+		$settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1284
+	} else {
1285
+		$settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1286
+	}
1287
+	if ($globalaprs == 'aprs') {
1288
+		$settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1289
+	} else {
1290
+		$settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1291
+	}
1019 1292
 	if ($globalivao == 'ivao') {
1020 1293
 		//$settings = array_merge($settings,array('globalIVAO' => 'TRUE','globalVATSIM' => 'FALSE'));
1021 1294
 		$settings = array_merge($settings,array('globalIVAO' => 'TRUE'));
1022
-	} else $settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1295
+	} else {
1296
+		$settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1297
+	}
1023 1298
 	if ($globalvatsim == 'vatsim') {
1024 1299
 		//$settings = array_merge($settings,array('globalVATSIM' => 'TRUE','globalIVAO' => 'FALSE'));
1025 1300
 		$settings = array_merge($settings,array('globalVATSIM' => 'TRUE'));
1026
-	} else $settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1301
+	} else {
1302
+		$settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1303
+	}
1027 1304
 	if ($globalphpvms == 'phpvms') {
1028 1305
 		$settings = array_merge($settings,array('globalphpVMS' => 'TRUE'));
1029
-	} else $settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1306
+	} else {
1307
+		$settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1308
+	}
1030 1309
 	if ($globalvam == 'vam') {
1031 1310
 		$settings = array_merge($settings,array('globalVAM' => 'TRUE'));
1032
-	} else $settings = array_merge($settings,array('globalVAM' => 'FALSE'));
1311
+	} else {
1312
+		$settings = array_merge($settings,array('globalVAM' => 'FALSE'));
1313
+	}
1033 1314
 	if ($globalvatsim == 'vatsim' || $globalivao == 'ivao' || $globalphpvms == 'phpvms') {
1034 1315
 		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE','globalTranslationFetch' => 'FALSE'));
1035
-	} else $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1316
+	} else {
1317
+		$settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1318
+	}
1036 1319
 	
1037 1320
 
1038 1321
 
@@ -1156,7 +1439,9 @@  discard block
 block discarded – undo
1156 1439
 		$settings = array_merge($settings,array('globalWaypoints' => 'FALSE'));
1157 1440
 	}
1158 1441
 
1159
-	if (!isset($globalTransaction)) $settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
1442
+	if (!isset($globalTransaction)) {
1443
+		$settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
1444
+	}
1160 1445
 
1161 1446
 	// Set some defaults values...
1162 1447
 	if (!isset($globalAircraftImageSources)) {
@@ -1171,15 +1456,23 @@  discard block
 block discarded – undo
1171 1456
 
1172 1457
 	$settings = array_merge($settings,array('globalInstalled' => 'TRUE'));
1173 1458
 
1174
-	if ($error == '') settings::modify_settings($settings);
1175
-	if ($error == '') settings::comment_settings($settings_comment);
1459
+	if ($error == '') {
1460
+		settings::modify_settings($settings);
1461
+	}
1462
+	if ($error == '') {
1463
+		settings::comment_settings($settings_comment);
1464
+	}
1176 1465
 	if ($error != '') {
1177 1466
 		print '<div class="info column">'.$error.'</div>';
1178 1467
 		require('../footer.php');
1179 1468
 		exit;
1180 1469
 	} else {
1181
-		if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') $_SESSION['waypoints'] = 1;
1182
-		if (isset($_POST['owner']) && $_POST['owner'] == 'owner') $_SESSION['owner'] = 1;
1470
+		if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') {
1471
+			$_SESSION['waypoints'] = 1;
1472
+		}
1473
+		if (isset($_POST['owner']) && $_POST['owner'] == 'owner') {
1474
+			$_SESSION['owner'] = 1;
1475
+		}
1183 1476
 		if (isset($_POST['createdb'])) {
1184 1477
 			$_SESSION['install'] = 'database_create';
1185 1478
 		} else {
@@ -1220,10 +1513,18 @@  discard block
 block discarded – undo
1220 1513
 	$popw = false;
1221 1514
 	foreach ($_SESSION['done'] as $done) {
1222 1515
 	    print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1223
-	    if ($done == 'Create database') $pop = true;
1224
-	    if ($_SESSION['install'] == 'database_create') $pop = true;
1225
-	    if ($_SESSION['install'] == 'database_import') $popi = true;
1226
-	    if ($_SESSION['install'] == 'waypoints') $popw = true;
1516
+	    if ($done == 'Create database') {
1517
+	    	$pop = true;
1518
+	    }
1519
+	    if ($_SESSION['install'] == 'database_create') {
1520
+	    	$pop = true;
1521
+	    }
1522
+	    if ($_SESSION['install'] == 'database_import') {
1523
+	    	$popi = true;
1524
+	    }
1525
+	    if ($_SESSION['install'] == 'waypoints') {
1526
+	    	$popw = true;
1527
+	    }
1227 1528
 	}
1228 1529
 	if ($pop) {
1229 1530
 	    sleep(5);
@@ -1234,7 +1535,9 @@  discard block
 block discarded – undo
1234 1535
 	} else if ($popw) {
1235 1536
 	    sleep(5);
1236 1537
 	    print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>';
1237
-	} else print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
1538
+	} else {
1539
+		print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
1540
+	}
1238 1541
 	print '</div></ul>';
1239 1542
 	print '<div id="error"></div>';
1240 1543
 /*	foreach ($_SESSION['done'] as $done) {
Please login to merge, or discard this patch.
require/class.ACARS.php 1 patch
Braces   +409 added lines, -261 removed lines patch added patch discarded remove patch
@@ -23,14 +23,19 @@  discard block
 block discarded – undo
23 23
 	*/
24 24
 	public function ident2icao($ident) {
25 25
 		if (substr($ident,0,2) == 'AF') {
26
-			if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident;
27
-			else $icao = 'AFR'.ltrim(substr($ident,2),'0');
26
+			if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) {
27
+				$icao = $ident;
28
+			} else {
29
+				$icao = 'AFR'.ltrim(substr($ident,2),'0');
30
+			}
28 31
 		} else {
29 32
 			$Spotter = new Spotter($this->db);
30 33
 			$identicao = $Spotter->getAllAirlineInfo(substr($ident,0,2));
31 34
 			if (isset($identicao[0])) {
32 35
 				$icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0');
33
-			} else $icao = $ident;
36
+			} else {
37
+				$icao = $ident;
38
+			}
34 39
 		}
35 40
 		return $icao;
36 41
 	}
@@ -103,14 +108,24 @@  discard block
 block discarded – undo
103 108
 		$message = '';
104 109
 		$result = array();
105 110
 		$n = sscanf($data,'(null) %*d %*02d/%*02d/%*04d %*02d:%*02d:%*02d %*d %*[0-9-] %*[A-Z0-9] %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
106
-		if ($n == 0) $n = sscanf($data,'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
107
-		if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
108
-		if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
111
+		if ($n == 0) {
112
+			$n = sscanf($data,'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
113
+		}
114
+		if ($n == 0) {
115
+			$n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
116
+		}
117
+		if ($n == 0) {
118
+			$n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
119
+		}
109 120
 		if ($n != 0) {
110 121
 			$registration = str_replace('.','',$registration);
111 122
 			$result = array('registration' => $registration, 'ident' => $ident,'label' => $label, 'block_id' => $block_id,'msg_no' => $msg_no,'message' => $message);
112
-			if ($globalDebug) echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n";
113
-		} else $message = $data;
123
+			if ($globalDebug) {
124
+				echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n";
125
+			}
126
+		} else {
127
+			$message = $data;
128
+		}
114 129
 		$decode = array();
115 130
 		$found = false;
116 131
 //		if ($registration != '' && $ident != '' && $registration != '!') {
@@ -130,12 +145,21 @@  discard block
 block discarded – undo
130 145
 				if ($n > 5 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) {
131 146
 					$latitude = $la / 10000.0;
132 147
 					$longitude = $ln / 10000.0;
133
-					if ($lac == 'S') $latitude = '-'.$latitude;
134
-					if ($lnc == 'W') $longitude = '-'.$longitude;
148
+					if ($lac == 'S') {
149
+						$latitude = '-'.$latitude;
150
+					}
151
+					if ($lnc == 'W') {
152
+						$longitude = '-'.$longitude;
153
+					}
135 154
 					// Temp not always available
136
-					if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n";
137
-					if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt);
138
-					else $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C');
155
+					if ($globalDebug) {
156
+						echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n";
157
+					}
158
+					if ($temp == '') {
159
+						$decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt);
160
+					} else {
161
+						$decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C');
162
+					}
139 163
 
140 164
 					//$icao = $Translation->checkTranslation($ident);
141 165
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -149,25 +173,35 @@  discard block
 block discarded – undo
149 173
 				$ahour = '';
150 174
 				$n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr,$ahour);
151 175
 				if ($n == 4 && strlen($darr) == 4) {
152
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
153
-					if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
154
-					if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n";
176
+					if ($dhour != '') {
177
+						$dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
178
+					}
179
+					if ($ahour != '') {
180
+						$ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
181
+					}
182
+					if ($globalDebug) {
183
+						echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n";
184
+					}
155 185
 					//$icao = ACARS->ident2icao($ident);
156 186
 					//$icao = $Translation->checkTranslation($ident);
157 187
 					//$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS');
158 188
 					$decode = array('Departure airport' => $dair, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour);
159 189
 					$found = true;
160
-				}
161
-				elseif ($n == 2 || $n  == 4) {
162
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
163
-					if ($globalDebug) echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n";
190
+				} elseif ($n == 2 || $n  == 4) {
191
+					if ($dhour != '') {
192
+						$dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
193
+					}
194
+					if ($globalDebug) {
195
+						echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n";
196
+					}
164 197
 					//$icao = ACARS->ident2icao($ident);
165 198
 					//$icao = $Translation->checkTranslation($ident);
166 199
 					$decode = array('Arrival airport' => $dair, 'Arrival hour' => $dhour);
167 200
 					$found = true;
168
-				}
169
-				elseif ($n == 1) {
170
-					if ($globalDebug) echo 'airport arrival : '.$darr."\n";
201
+				} elseif ($n == 1) {
202
+					if ($globalDebug) {
203
+						echo 'airport arrival : '.$darr."\n";
204
+					}
171 205
 					//$icao = ACARS->ident2icao($ident);
172 206
 					//$icao = $Translation->checkTranslation($ident);
173 207
 					$decode = array('Arrival airport' => $darr);
@@ -185,7 +219,9 @@  discard block
 block discarded – undo
185 219
 				$darr = '';
186 220
 				$n = sscanf($message, "%4c,%4c,%*7s,%*d", $dair, $darr);
187 221
 				if ($n == 4) {
188
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
222
+					if ($globalDebug) {
223
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
224
+					}
189 225
 					//$icao = ACARS->ident2icao($ident);
190 226
 					//$icao = $Translation->checkTranslation($ident);
191 227
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -219,14 +255,23 @@  discard block
 block discarded – undo
219 255
 				$apiste = '';
220 256
 				$n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z]/%*3d/%4s/%*cSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao,$aident,$dair, $darr, $ddate, $dhour,$ahour, $aair, $apiste);
221 257
 				if ($n > 8) {
222
-					if ($globalDebug) echo 'airicao : '. $airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '. $darr.' - date depart : '.$ddate.' - departure hour : '. $dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n";
223
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
224
-					if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
258
+					if ($globalDebug) {
259
+						echo 'airicao : '. $airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '. $darr.' - date depart : '.$ddate.' - departure hour : '. $dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n";
260
+					}
261
+					if ($dhour != '') {
262
+						$dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
263
+					}
264
+					if ($ahour != '') {
265
+						$ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
266
+					}
225 267
 					$icao = trim($aident);
226 268
 
227 269
 					//$decode = 'Departure airport : '.$dair.' ('.$ddate.' at '.$dhour.') - Arrival Airport : '.$aair.' (at '.$ahour.') way '.$apiste;
228
-					if ($ahour == '') $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr);
229
-					else $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour, 'Arrival way' => $apiste);
270
+					if ($ahour == '') {
271
+						$decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr);
272
+					} else {
273
+						$decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour, 'Arrival way' => $apiste);
274
+					}
230 275
 					//$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS');
231 276
 					$decode['icao'] = $icao;
232 277
 					$found = true;
@@ -248,9 +293,15 @@  discard block
 block discarded – undo
248 293
 					$lns = $lns.'.'.$lns;
249 294
 					$latitude = $las / 1000.0;
250 295
 					$longitude = $lns / 1000.0;
251
-					if ($lac == 'S') $latitude = '-'.$latitude;
252
-					if ($lnc == 'W') $longitude = '-'.$longitude;
253
-					if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n";
296
+					if ($lac == 'S') {
297
+						$latitude = '-'.$latitude;
298
+					}
299
+					if ($lnc == 'W') {
300
+						$longitude = '-'.$longitude;
301
+					}
302
+					if ($globalDebug) {
303
+						echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n";
304
+					}
254 305
 					$decode = array('Latitude' => $latitude, 'Longitude' => $longitude);
255 306
 					$found = true;
256 307
 				}
@@ -268,7 +319,9 @@  discard block
 block discarded – undo
268 319
 				$darr = '';
269 320
 				$n = sscanf($message, "%*[0-9A-Z ]/%*s %4c/%4c .", $dair, $darr);
270 321
 				if ($n == 4) {
271
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
322
+					if ($globalDebug) {
323
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
324
+					}
272 325
 					//$icao = $Translation->checkTranslation($ident);
273 326
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
274 327
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -281,7 +334,9 @@  discard block
 block discarded – undo
281 334
 				$darr = '';
282 335
 				$n = sscanf($message, "%*[0-9],%4c,%4c,", $dair, $darr);
283 336
 				if ($n == 4) {
284
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
337
+					if ($globalDebug) {
338
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
339
+					}
285 340
 					//$icao = $Translation->checkTranslation($ident);
286 341
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
287 342
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -294,7 +349,9 @@  discard block
 block discarded – undo
294 349
 				$darr = '';
295 350
 				$n = sscanf($message, "002AF %4c %4c ", $dair, $darr);
296 351
 				if ($n == 2) {
297
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
352
+					if ($globalDebug) {
353
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
354
+					}
298 355
 					//$icao = $Translation->checkTranslation($ident);
299 356
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
300 357
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -308,7 +365,9 @@  discard block
 block discarded – undo
308 365
 				$darr = '';
309 366
 				$n = sscanf($message, "#DFBA%*02d/%*[A-Z-],%*[0-9A-Z],%*d,%4c,%4c", $dair, $darr);
310 367
 				if ($n == 6) {
311
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
368
+					if ($globalDebug) {
369
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
370
+					}
312 371
 					//$icao = $Translation->checkTranslation($ident);
313 372
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
314 373
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -321,7 +380,9 @@  discard block
 block discarded – undo
321 380
 				$darr = '';
322 381
 				$n = sscanf($message, "#DFBA%*02d/%*[0-9A-Z,]/%*[A-Z-],%*[0-9A-Z],%*d,%4c,%4c", $dair, $darr);
323 382
 				if ($n == 7) {
324
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
383
+					if ($globalDebug) {
384
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
385
+					}
325 386
 					//$icao = $Translation->checkTranslation($ident);
326 387
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
327 388
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -349,8 +410,12 @@  discard block
 block discarded – undo
349 410
 					$decode['icao'] = $icao;
350 411
 					$latitude = $las / 100.0;
351 412
 					$longitude = $lns / 100.0;
352
-					if ($lac == 'S') $latitude = '-'.$latitude;
353
-					if ($lnc == 'W') $longitude = '-'.$longitude;
413
+					if ($lac == 'S') {
414
+						$latitude = '-'.$latitude;
415
+					}
416
+					if ($lnc == 'W') {
417
+						$longitude = '-'.$longitude;
418
+					}
354 419
 
355 420
 					$decode = array('Latitude' => $latitude,'Longitude' => $longitude,'Altitude' => 'FL'.$alt,'Fuel' => $fuel,'speed' => $speed);
356 421
 					$found = true;
@@ -368,8 +433,12 @@  discard block
 block discarded – undo
368 433
 				if ($n == 4) {
369 434
 					$latitude = $las;
370 435
 					$longitude = $lns;
371
-					if ($lac == 'S') $latitude = '-'.$latitude;
372
-					if ($lnc == 'W') $longitude = '-'.$longitude;
436
+					if ($lac == 'S') {
437
+						$latitude = '-'.$latitude;
438
+					}
439
+					if ($lnc == 'W') {
440
+						$longitude = '-'.$longitude;
441
+					}
373 442
 
374 443
 					$decode = array('Latitude' => $latitude,'Longitude' => $longitude);
375 444
 					$found = true;
@@ -385,7 +454,9 @@  discard block
 block discarded – undo
385 454
 				$darr = '';
386 455
 				$n = sscanf($message, "%*[0-9A-Z] NLINFO %*d/%*d %4c/%4c .", $dair, $darr);
387 456
 				if ($n == 5) {
388
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
457
+					if ($globalDebug) {
458
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
459
+					}
389 460
 					//$icao = $Translation->checkTranslation($ident);
390 461
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
391 462
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -406,7 +477,9 @@  discard block
 block discarded – undo
406 477
 				$aident = '';
407 478
 				$n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z],,%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,%*4[A-Z],%[0-9A-Z],", $dair, $darr, $aident);
408 479
 				if ($n == 8) {
409
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
480
+					if ($globalDebug) {
481
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
482
+					}
410 483
 					$icao = trim($aident);
411 484
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
412 485
 					$decode['icao'] = $icao;
@@ -423,7 +496,9 @@  discard block
 block discarded – undo
423 496
 				$darr = '';
424 497
 				$n = sscanf($message, "%*d/%*d %4s/%4s .%*6s", $dair, $darr);
425 498
 				if ($n == 5) {
426
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
499
+					if ($globalDebug) {
500
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
501
+					}
427 502
 					//$icao = $Translation->checkTranslation($ident);
428 503
 
429 504
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -439,7 +514,9 @@  discard block
 block discarded – undo
439 514
 				$darr = '';
440 515
 				$n = sscanf($message,'%4[A-Z]%4[A-Z]%*4d',$dair,$darr);
441 516
 				if ($n == 3) {
442
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
517
+					if ($globalDebug) {
518
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
519
+					}
443 520
 					//$icao = $Translation->checkTranslation($ident);
444 521
 
445 522
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -455,7 +532,9 @@  discard block
 block discarded – undo
455 532
 				$darr = '';
456 533
 				$n = sscanf($message,'3J01 DSPTCH %*d/%*d %4s/%4s .%*6s',$dair,$darr);
457 534
 				if ($n == 3) {
458
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
535
+					if ($globalDebug) {
536
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
537
+					}
459 538
 					//$icao = $Translation->checkTranslation($ident);
460 539
 
461 540
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -466,7 +545,9 @@  discard block
 block discarded – undo
466 545
 			if (!$found) {
467 546
 				$n = sscanf($message,'MET01%4c',$airport);
468 547
 				if ($n == 1) {
469
-					if ($globalDebug) echo 'airport name : '.$airport;
548
+					if ($globalDebug) {
549
+						echo 'airport name : '.$airport;
550
+					}
470 551
 					$decode = array('Airport/Waypoint name' => $airport);
471 552
 					$found = true;
472 553
 				}
@@ -475,184 +556,126 @@  discard block
 block discarded – undo
475 556
 			if ($label == 'H1') {
476 557
 				if (preg_match('/^#CFBFLR/',$message) || preg_match('/^#CFBWRN/',$message)) {
477 558
 					$decode = array_merge(array('Message nature' => 'Equipment failure'),$decode);
478
-				}
479
-				elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) {
559
+				} elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) {
480 560
 					$decode = array_merge(array('Message nature' => 'Take off performance data'),$decode);
481
-				}
482
-				elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) {
561
+				} elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) {
483 562
 					$decode = array_merge(array('Message nature' => 'Cruise performance data'),$decode);
484
-				}
485
-				elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) {
563
+				} elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) {
486 564
 					$decode = array_merge(array('Message nature' => 'Weather observation'),$decode);
487
-				}
488
-				elseif (preg_match(':^#DFB/PIREP:',$message)) {
565
+				} elseif (preg_match(':^#DFB/PIREP:',$message)) {
489 566
 					$decode = array_merge(array('Message nature' => 'Pilot Report'),$decode);
490
-				}
491
-				elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) {
567
+				} elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) {
492 568
 					$decode = array_merge(array('Message nature' => 'Engine Data'),$decode);
493
-				}
494
-				elseif (preg_match(':^#M1AAEP:',$message)) {
569
+				} elseif (preg_match(':^#M1AAEP:',$message)) {
495 570
 					$decode = array_merge(array('Message nature' => 'Position/Weather Report'),$decode);
496
-				}
497
-				elseif (preg_match(':^#M2APWD:',$message)) {
571
+				} elseif (preg_match(':^#M2APWD:',$message)) {
498 572
 					$decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'),$decode);
499
-				}
500
-				elseif (preg_match(':^#M1BREQPWI:',$message)) {
573
+				} elseif (preg_match(':^#M1BREQPWI:',$message)) {
501 574
 					$decode = array_merge(array('Message nature' => 'Predicted wind info request'),$decode);
502
-				}
503
-				elseif (preg_match(':^#CF:',$message)) {
575
+				} elseif (preg_match(':^#CF:',$message)) {
504 576
 					$decode = array_merge(array('Message nature' => 'Central Fault Display'),$decode);
505
-				}
506
-				elseif (preg_match(':^#DF:',$message)) {
577
+				} elseif (preg_match(':^#DF:',$message)) {
507 578
 					$decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'),$decode);
508
-				}
509
-				elseif (preg_match(':^#EC:',$message)) {
579
+				} elseif (preg_match(':^#EC:',$message)) {
510 580
 					$decode = array_merge(array('Message nature' => 'Engine Display System'),$decode);
511
-				}
512
-				elseif (preg_match(':^#EI:',$message)) {
581
+				} elseif (preg_match(':^#EI:',$message)) {
513 582
 					$decode = array_merge(array('Message nature' => 'Engine Report'),$decode);
514
-				}
515
-				elseif (preg_match(':^#H1:',$message)) {
583
+				} elseif (preg_match(':^#H1:',$message)) {
516 584
 					$decode = array_merge(array('Message nature' => 'HF Data Radio - Left'),$decode);
517
-				}
518
-				elseif (preg_match(':^#H2:',$message)) {
585
+				} elseif (preg_match(':^#H2:',$message)) {
519 586
 					$decode = array_merge(array('Message nature' => 'HF Data Radio - Right'),$decode);
520
-				}
521
-				elseif (preg_match(':^#HD:',$message)) {
587
+				} elseif (preg_match(':^#HD:',$message)) {
522 588
 					$decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'),$decode);
523
-				}
524
-				elseif (preg_match(':^#M1:',$message)) {
589
+				} elseif (preg_match(':^#M1:',$message)) {
525 590
 					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'),$decode);
526
-				}
527
-				elseif (preg_match(':^#M2:',$message)) {
591
+				} elseif (preg_match(':^#M2:',$message)) {
528 592
 					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'),$decode);
529
-				}
530
-				elseif (preg_match(':^#M3:',$message)) {
593
+				} elseif (preg_match(':^#M3:',$message)) {
531 594
 					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'),$decode);
532
-				}
533
-				elseif (preg_match(':^#MD:',$message)) {
595
+				} elseif (preg_match(':^#MD:',$message)) {
534 596
 					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'),$decode);
535
-				}
536
-				elseif (preg_match(':^#PS:',$message)) {
597
+				} elseif (preg_match(':^#PS:',$message)) {
537 598
 					$decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'),$decode);
538
-				}
539
-				elseif (preg_match(':^#S1:',$message)) {
599
+				} elseif (preg_match(':^#S1:',$message)) {
540 600
 					$decode = array_merge(array('Message nature' => 'SDU - Left'),$decode);
541
-				}
542
-				elseif (preg_match(':^#S2:',$message)) {
601
+				} elseif (preg_match(':^#S2:',$message)) {
543 602
 					$decode = array_merge(array('Message nature' => 'SDU - Right'),$decode);
544
-				}
545
-				elseif (preg_match(':^#SD:',$message)) {
603
+				} elseif (preg_match(':^#SD:',$message)) {
546 604
 					$decode = array_merge(array('Message nature' => 'SDU - Selected'),$decode);
547
-				}
548
-				elseif (preg_match(':^#T[0-8]:',$message)) {
605
+				} elseif (preg_match(':^#T[0-8]:',$message)) {
549 606
 					$decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'),$decode);
550
-				}
551
-				elseif (preg_match(':^#WO:',$message)) {
607
+				} elseif (preg_match(':^#WO:',$message)) {
552 608
 					$decode = array_merge(array('Message nature' => 'Weather Observation Report'),$decode);
553
-				}
554
-				elseif (preg_match(':^#A1:',$message)) {
609
+				} elseif (preg_match(':^#A1:',$message)) {
555 610
 					$decode = array_merge(array('Message nature' => 'Oceanic Clearance'),$decode);
556
-				}
557
-				elseif (preg_match(':^#A3:',$message)) {
611
+				} elseif (preg_match(':^#A3:',$message)) {
558 612
 					$decode = array_merge(array('Message nature' => 'Departure Clearance Response'),$decode);
559
-				}
560
-				elseif (preg_match(':^#A4:',$message)) {
613
+				} elseif (preg_match(':^#A4:',$message)) {
561 614
 					$decode = array_merge(array('Message nature' => 'Flight Systems Message'),$decode);
562
-				}
563
-				elseif (preg_match(':^#A6:',$message)) {
615
+				} elseif (preg_match(':^#A6:',$message)) {
564 616
 					$decode = array_merge(array('Message nature' => 'Request ADS Reports'),$decode);
565
-				}
566
-				elseif (preg_match(':^#A8:',$message)) {
617
+				} elseif (preg_match(':^#A8:',$message)) {
567 618
 					$decode = array_merge(array('Message nature' => 'Deliver Departure Slot'),$decode);
568
-				}
569
-				elseif (preg_match(':^#A9:',$message)) {
619
+				} elseif (preg_match(':^#A9:',$message)) {
570 620
 					$decode = array_merge(array('Message nature' => 'ATIS report'),$decode);
571
-				}
572
-				elseif (preg_match(':^#A0:',$message)) {
621
+				} elseif (preg_match(':^#A0:',$message)) {
573 622
 					$decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'),$decode);
574
-				}
575
-				elseif (preg_match(':^#AA:',$message)) {
623
+				} elseif (preg_match(':^#AA:',$message)) {
576 624
 					$decode = array_merge(array('Message nature' => 'ATCComm'),$decode);
577
-				}
578
-				elseif (preg_match(':^#AB:',$message)) {
625
+				} elseif (preg_match(':^#AB:',$message)) {
579 626
 					$decode = array_merge(array('Message nature' => 'TWIP Report'),$decode);
580
-				}
581
-				elseif (preg_match(':^#AC:',$message)) {
627
+				} elseif (preg_match(':^#AC:',$message)) {
582 628
 					$decode = array_merge(array('Message nature' => 'Pushback Clearance'),$decode);
583
-				}
584
-				elseif (preg_match(':^#AD:',$message)) {
629
+				} elseif (preg_match(':^#AD:',$message)) {
585 630
 					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'),$decode);
586
-				}
587
-				elseif (preg_match(':^#AF:',$message)) {
631
+				} elseif (preg_match(':^#AF:',$message)) {
588 632
 					$decode = array_merge(array('Message nature' => 'CPC Command/Response'),$decode);
589
-				}
590
-				elseif (preg_match(':^#B1:',$message)) {
633
+				} elseif (preg_match(':^#B1:',$message)) {
591 634
 					$decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'),$decode);
592
-				}
593
-				elseif (preg_match(':^#B2:',$message)) {
635
+				} elseif (preg_match(':^#B2:',$message)) {
594 636
 					$decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'),$decode);
595
-				}
596
-				elseif (preg_match(':^#B3:',$message)) {
637
+				} elseif (preg_match(':^#B3:',$message)) {
597 638
 					$decode = array_merge(array('Message nature' => 'Request Departure Clearance'),$decode);
598
-				}
599
-				elseif (preg_match(':^#B4:',$message)) {
639
+				} elseif (preg_match(':^#B4:',$message)) {
600 640
 					$decode = array_merge(array('Message nature' => 'Departure Clearance Readback'),$decode);
601
-				}
602
-				elseif (preg_match(':^#B6:',$message)) {
641
+				} elseif (preg_match(':^#B6:',$message)) {
603 642
 					$decode = array_merge(array('Message nature' => 'Provide ADS Report'),$decode);
604
-				}
605
-				elseif (preg_match(':^#B8:',$message)) {
643
+				} elseif (preg_match(':^#B8:',$message)) {
606 644
 					$decode = array_merge(array('Message nature' => 'Request Departure Slot'),$decode);
607
-				}
608
-				elseif (preg_match(':^#B9:',$message)) {
645
+				} elseif (preg_match(':^#B9:',$message)) {
609 646
 					$decode = array_merge(array('Message nature' => 'Request ATIS Report'),$decode);
610
-				}
611
-				elseif (preg_match(':^#B0:',$message)) {
647
+				} elseif (preg_match(':^#B0:',$message)) {
612 648
 					$decode = array_merge(array('Message nature' => 'ATS Facility Notification'),$decode);
613
-				}
614
-				elseif (preg_match(':^#BA:',$message)) {
649
+				} elseif (preg_match(':^#BA:',$message)) {
615 650
 					$decode = array_merge(array('Message nature' => 'ATCComm'),$decode);
616
-				}
617
-				elseif (preg_match(':^#BB:',$message)) {
651
+				} elseif (preg_match(':^#BB:',$message)) {
618 652
 					$decode = array_merge(array('Message nature' => 'Request TWIP Report'),$decode);
619
-				}
620
-				elseif (preg_match(':^#BC:',$message)) {
653
+				} elseif (preg_match(':^#BC:',$message)) {
621 654
 					$decode = array_merge(array('Message nature' => 'Pushback Clearance Request'),$decode);
622
-				}
623
-				elseif (preg_match(':^#BD:',$message)) {
655
+				} elseif (preg_match(':^#BD:',$message)) {
624 656
 					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'),$decode);
625
-				}
626
-				elseif (preg_match(':^#BE:',$message)) {
657
+				} elseif (preg_match(':^#BE:',$message)) {
627 658
 					$decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'),$decode);
628
-				}
629
-				elseif (preg_match(':^#BF:',$message)) {
659
+				} elseif (preg_match(':^#BF:',$message)) {
630 660
 					$decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'),$decode);
631
-				}
632
-				elseif (preg_match(':^#H3:',$message)) {
661
+				} elseif (preg_match(':^#H3:',$message)) {
633 662
 					$decode = array_merge(array('Message nature' => 'Icing Report'),$decode);
634 663
 				}
635 664
 			}
636 665
 			if ($label == '10') {
637 666
 				if (preg_match(':^DTO01:',$message)) {
638 667
 					$decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'),$decode);
639
-				}
640
-				elseif (preg_match(':^AIS01:',$message)) {
668
+				} elseif (preg_match(':^AIS01:',$message)) {
641 669
 					$decode = array_merge(array('Message nature' => 'AIS Request'),$decode);
642
-				}
643
-				elseif (preg_match(':^FTX01:',$message)) {
670
+				} elseif (preg_match(':^FTX01:',$message)) {
644 671
 					$decode = array_merge(array('Message nature' => 'Free Text Downlink'),$decode);
645
-				}
646
-				elseif (preg_match(':^FPL01:',$message)) {
672
+				} elseif (preg_match(':^FPL01:',$message)) {
647 673
 					$decode = array_merge(array('Message nature' => 'Flight Plan Request'),$decode);
648
-				}
649
-				elseif (preg_match(':^WAB01:',$message)) {
674
+				} elseif (preg_match(':^WAB01:',$message)) {
650 675
 					$decode = array_merge(array('Message nature' => 'Weight & Balance Request'),$decode);
651
-				}
652
-				elseif (preg_match(':^MET01:',$message)) {
676
+				} elseif (preg_match(':^MET01:',$message)) {
653 677
 					$decode = array_merge(array('Message nature' => 'Weather Data Request'),$decode);
654
-				}
655
-				elseif (preg_match(':^WAB02:',$message)) {
678
+				} elseif (preg_match(':^WAB02:',$message)) {
656 679
 					$decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'),$decode);
657 680
 				}
658 681
 			}
@@ -667,38 +690,28 @@  discard block
 block discarded – undo
667 690
 					$vsta = array('Version' => $version);
668 691
 					if ($state == 'E') {
669 692
 						$vsta = array_merge($vsta,array('Link state' => 'Established'));
670
-					}
671
-					elseif ($state == 'L') {
693
+					} elseif ($state == 'L') {
672 694
 						$vsta = array_merge($vsta,array('Link state' => 'Lost'));
673
-					}
674
-					else {
695
+					} else {
675 696
 						$vsta = array_merge($vsta,array('Link state' => 'Unknown'));
676 697
 					}
677 698
 					if ($type == 'V') {
678 699
 						$vsta = array_merge($vsta,array('Link type' => 'VHF ACARS'));
679
-					}
680
-					elseif ($type == 'S') {
700
+					} elseif ($type == 'S') {
681 701
 						$vsta = array_merge($vsta,array('Link type' => 'Generic SATCOM'));
682
-					}
683
-					elseif ($type == 'H') {
702
+					} elseif ($type == 'H') {
684 703
 						$vsta = array_merge($vsta,array('Link type' => 'HF'));
685
-					}
686
-					elseif ($type == 'G') {
704
+					} elseif ($type == 'G') {
687 705
 						$vsta = array_merge($vsta,array('Link type' => 'GlobalStar SATCOM'));
688
-					}
689
-					elseif ($type == 'C') {
706
+					} elseif ($type == 'C') {
690 707
 						$vsta = array_merge($vsta,array('Link type' => 'ICO SATCOM'));
691
-					}
692
-					elseif ($type == '2') {
708
+					} elseif ($type == '2') {
693 709
 						$vsta = array_merge($vsta,array('Link type' => 'VDL Mode 2'));
694
-					}
695
-					elseif ($type == 'X') {
710
+					} elseif ($type == 'X') {
696 711
 						$vsta = array_merge($vsta,array('Link type' => 'Inmarsat Aero'));
697
-					}
698
-					elseif ($type == 'I') {
712
+					} elseif ($type == 'I') {
699 713
 						$vsta = array_merge($vsta,array('Link type' => 'Irridium SATCOM'));
700
-					}
701
-					else {
714
+					} else {
702 715
 						$vsta = array_merge($vsta,array('Link type' => 'Unknown'));
703 716
 					}
704 717
 					$vsta = array_merge($vsta,array('Event occured at' => implode(':',str_split($at,2))));
@@ -707,7 +720,9 @@  discard block
 block discarded – undo
707 720
 			}
708 721
 
709 722
 			$title = $this->getTitlefromLabel($label);
710
-			if ($title != '') $decode = array_merge(array('Message title' => $title),$decode);
723
+			if ($title != '') {
724
+				$decode = array_merge(array('Message title' => $title),$decode);
725
+			}
711 726
 
712 727
 			/*
713 728
 			// Business jets always use GS0001
@@ -748,14 +763,26 @@  discard block
 block discarded – undo
748 763
 			$decode = $message['decode'];
749 764
 			$registration = (string)$message['registration'];
750 765
 		
751
-			if (isset($decode['latitude'])) $latitude = $decode['latitude'];
752
-			else $latitude = '';
753
-			if (isset($decode['longitude'])) $longitude = $decode['longitude'];
754
-			else $longitude = '';
755
-			if (isset($decode['airicao'])) $airicao = $decode['airicao'];
756
-			else $airicao = '';
757
-			if (isset($decode['icao'])) $icao = $decode['icao'];
758
-			else $icao = $Translation->checkTranslation($ident);
766
+			if (isset($decode['latitude'])) {
767
+				$latitude = $decode['latitude'];
768
+			} else {
769
+				$latitude = '';
770
+			}
771
+			if (isset($decode['longitude'])) {
772
+				$longitude = $decode['longitude'];
773
+			} else {
774
+				$longitude = '';
775
+			}
776
+			if (isset($decode['airicao'])) {
777
+				$airicao = $decode['airicao'];
778
+			} else {
779
+				$airicao = '';
780
+			}
781
+			if (isset($decode['icao'])) {
782
+				$icao = $decode['icao'];
783
+			} else {
784
+				$icao = $Translation->checkTranslation($ident);
785
+			}
759 786
 		
760 787
 			$image_array = $Image->getSpotterImage($registration);
761 788
 			if (!isset($image_array[0]['registration'])) {
@@ -763,11 +790,18 @@  discard block
 block discarded – undo
763 790
 			}
764 791
 		
765 792
 			// Business jets always use GS0001
766
-			if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude);
767
-			if ($globalDebug && isset($info) && $info != '') echo $info;
793
+			if ($ident != 'GS0001') {
794
+				$info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude);
795
+			}
796
+			if ($globalDebug && isset($info) && $info != '') {
797
+				echo $info;
798
+			}
768 799
 
769
-			if (count($decode) > 0) $decode_json = json_encode($decode);
770
-			else $decode_json = '';
800
+			if (count($decode) > 0) {
801
+				$decode_json = json_encode($decode);
802
+			} else {
803
+				$decode_json = '';
804
+			}
771 805
 			if (isset($decode['Departure airport']) && isset($decode['Departure hour']) && isset($decode['Arrival airport']) && isset($decode['Arrival hour'])) {
772 806
 				$Schedule->addSchedule($icao,$decode['Departure airport'],$decode['Departure hour'],$decode['Arrival airport'],$decode['Arrival hour'],'ACARS');
773 807
 			} elseif (isset($decode['Departure airport']) && isset($decode['Arrival airport'])) {
@@ -775,8 +809,12 @@  discard block
 block discarded – undo
775 809
 			}
776 810
 
777 811
 			$result = $this->addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
778
-			if (!isset($globalACARSArchive)) $globalACARSArchive = array('10','80','81','82','3F');
779
-			if ($result && in_array($label,$globalACARSArchive)) $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
812
+			if (!isset($globalACARSArchive)) {
813
+				$globalACARSArchive = array('10','80','81','82','3F');
814
+			}
815
+			if ($result && in_array($label,$globalACARSArchive)) {
816
+				$this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
817
+			}
780 818
 
781 819
 			if ($globalDebug && count($decode) > 0) {
782 820
 				echo "Human readable data : ".implode(' - ',$decode)."\n";
@@ -801,7 +839,9 @@  discard block
 block discarded – undo
801 839
 			$Connection = new Connection($this->db);
802 840
 			$this->db = $Connection->db;
803 841
 
804
-			if ($globalDebug) echo "Test if not already in Live ACARS table...";
842
+			if ($globalDebug) {
843
+				echo "Test if not already in Live ACARS table...";
844
+			}
805 845
 			$query_test = "SELECT COUNT(*) as nb FROM acars_live WHERE ident = :ident AND registration = :registration AND message = :message";
806 846
 			$query_test_values = array(':ident' => $ident,':registration' => $registration, ':message' => $message);
807 847
 			try {
@@ -811,7 +851,9 @@  discard block
 block discarded – undo
811 851
 				return "error : ".$e->getMessage();
812 852
 			}
813 853
 			if ($stht->fetchColumn() == 0) {
814
-				if ($globalDebug) echo "Add Live ACARS data...";
854
+				if ($globalDebug) {
855
+					echo "Add Live ACARS data...";
856
+				}
815 857
 				$query = "INSERT INTO acars_live (ident,registration,label,block_id,msg_no,message,decode,date) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode,:date)";
816 858
 				$query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode,':date' => date("Y-m-d H:i:s"));
817 859
 				try {
@@ -822,10 +864,14 @@  discard block
 block discarded – undo
822 864
 					return "error : ".$e->getMessage();
823 865
 				}
824 866
 			} else {
825
-				if ($globalDebug) echo "Data already in DB...\n";
867
+				if ($globalDebug) {
868
+					echo "Data already in DB...\n";
869
+				}
826 870
 				return false;
827 871
 			}
828
-			if ($globalDebug) echo "Done\n";
872
+			if ($globalDebug) {
873
+				echo "Done\n";
874
+			}
829 875
 			return true;
830 876
 		}
831 877
 	}
@@ -857,7 +903,9 @@  discard block
 block discarded – undo
857 903
 			    	    }
858 904
 				    if ($stht->fetchColumn() == 0) {
859 905
 			*/
860
-			if ($globalDebug) echo "Add Live ACARS data...";
906
+			if ($globalDebug) {
907
+				echo "Add Live ACARS data...";
908
+			}
861 909
 			$query = "INSERT INTO acars_archive (ident,registration,label,block_id,msg_no,message,decode) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode)";
862 910
 			$query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode);
863 911
 			try {
@@ -868,7 +916,9 @@  discard block
 block discarded – undo
868 916
 				return "error : ".$e->getMessage();
869 917
 			}
870 918
 //    	    }
871
-			if ($globalDebug) echo "Done\n";
919
+			if ($globalDebug) {
920
+				echo "Done\n";
921
+			}
872 922
 		}
873 923
 	}
874 924
 
@@ -892,8 +942,11 @@  discard block
 block discarded – undo
892 942
 			die;
893 943
 		}
894 944
 		$row = $sth->fetchAll(PDO::FETCH_ASSOC);
895
-		if (count($row) > 0) return $row[0]['title'];
896
-		else return '';
945
+		if (count($row) > 0) {
946
+			return $row[0]['title'];
947
+		} else {
948
+			return '';
949
+		}
897 950
 	}
898 951
 
899 952
 	/**
@@ -913,8 +966,11 @@  discard block
 block discarded – undo
913 966
 			die;
914 967
 		}
915 968
 		$row = $sth->fetchAll(PDO::FETCH_ASSOC);
916
-		if (count($row) > 0) return $row;
917
-		else return array();
969
+		if (count($row) > 0) {
970
+			return $row;
971
+		} else {
972
+			return array();
973
+		}
918 974
 	}
919 975
 
920 976
 	/**
@@ -935,8 +991,11 @@  discard block
 block discarded – undo
935 991
 			die;
936 992
 		}
937 993
 		$row = $sth->fetchAll(PDO::FETCH_ASSOC);
938
-		if (count($row) > 0) return $row[0];
939
-		else return array();
994
+		if (count($row) > 0) {
995
+			return $row[0];
996
+		} else {
997
+			return array();
998
+		}
940 999
 	}
941 1000
 
942 1001
 	/**
@@ -988,20 +1047,36 @@  discard block
 block discarded – undo
988 1047
 			if ($row['registration'] != '') {
989 1048
 				$row['registration'] = str_replace('.','',$row['registration']);
990 1049
 				$image_array = $Image->getSpotterImage($row['registration']);
991
-				if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
992
-				else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
993
-			} else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
994
-			if ($row['registration'] == '') $row['registration'] = 'NA';
995
-			if ($row['ident'] == '') $row['ident'] = 'NA';
1050
+				if (count($image_array) > 0) {
1051
+					$data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
1052
+				} else {
1053
+					$data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1054
+				}
1055
+			} else {
1056
+				$data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1057
+			}
1058
+			if ($row['registration'] == '') {
1059
+				$row['registration'] = 'NA';
1060
+			}
1061
+			if ($row['ident'] == '') {
1062
+				$row['ident'] = 'NA';
1063
+			}
996 1064
 			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2));
997 1065
 			if (isset($identicao[0])) {
998 1066
 				if (substr($row['ident'],0,2) == 'AF') {
999
-					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
1000
-					else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1001
-				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1067
+					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) {
1068
+						$icao = $row['ident'];
1069
+					} else {
1070
+						$icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1071
+					}
1072
+				} else {
1073
+					$icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1074
+				}
1002 1075
 
1003 1076
 				$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
1004
-			} else $icao = $row['ident'];
1077
+			} else {
1078
+				$icao = $row['ident'];
1079
+			}
1005 1080
 			$icao = $Translation->checkTranslation($icao,false);
1006 1081
 
1007 1082
 			$decode = json_decode($row['decode'],true);
@@ -1027,7 +1102,9 @@  discard block
 block discarded – undo
1027 1102
 					$found = true;
1028 1103
 				}
1029 1104
 			}
1030
-			if ($found) $row['decode'] = json_encode($decode);
1105
+			if ($found) {
1106
+				$row['decode'] = json_encode($decode);
1107
+			}
1031 1108
 			$data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1032 1109
 			$result[] = $data;
1033 1110
 			$i++;
@@ -1035,8 +1112,9 @@  discard block
 block discarded – undo
1035 1112
 		if (isset($result)) {
1036 1113
 			$result[0]['query_number_rows'] = $i;
1037 1114
 			return $result;
1115
+		} else {
1116
+			return array();
1038 1117
 		}
1039
-		else return array();
1040 1118
 	}
1041 1119
 
1042 1120
 	/**
@@ -1096,20 +1174,36 @@  discard block
 block discarded – undo
1096 1174
 			if ($row['registration'] != '') {
1097 1175
 				$row['registration'] = str_replace('.','',$row['registration']);
1098 1176
 				$image_array = $Image->getSpotterImage($row['registration']);
1099
-				if (count($image_array) > 0) $data = array_merge($data,array('image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
1100
-				else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1101
-			} else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1177
+				if (count($image_array) > 0) {
1178
+					$data = array_merge($data,array('image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
1179
+				} else {
1180
+					$data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1181
+				}
1182
+			} else {
1183
+				$data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1184
+			}
1102 1185
 			$icao = '';
1103
-			if ($row['registration'] == '') $row['registration'] = 'NA';
1104
-			if ($row['ident'] == '') $row['ident'] = 'NA';
1186
+			if ($row['registration'] == '') {
1187
+				$row['registration'] = 'NA';
1188
+			}
1189
+			if ($row['ident'] == '') {
1190
+				$row['ident'] = 'NA';
1191
+			}
1105 1192
 			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2));
1106 1193
 			if (isset($identicao[0])) {
1107 1194
 				if (substr($row['ident'],0,2) == 'AF') {
1108
-					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
1109
-					else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1110
-				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1195
+					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) {
1196
+						$icao = $row['ident'];
1197
+					} else {
1198
+						$icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1199
+					}
1200
+				} else {
1201
+					$icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1202
+				}
1111 1203
 				$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
1112
-			} else $icao = $row['ident'];
1204
+			} else {
1205
+				$icao = $row['ident'];
1206
+			}
1113 1207
 			$icao = $Translation->checkTranslation($icao);
1114 1208
 
1115 1209
 
@@ -1117,12 +1211,16 @@  discard block
 block discarded – undo
1117 1211
 			$found = false;
1118 1212
 			if ($decode != '' && array_key_exists('Departure airport',$decode)) {
1119 1213
 				$airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']);
1120
-				if (isset($airport_info[0]['icao'])) $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1214
+				if (isset($airport_info[0]['icao'])) {
1215
+					$decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1216
+				}
1121 1217
 				$found = true;
1122 1218
 			}
1123 1219
 			if ($decode != '' && array_key_exists('Arrival airport',$decode)) {
1124 1220
 				$airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']);
1125
-				if (isset($airport_info[0]['icao'])) $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1221
+				if (isset($airport_info[0]['icao'])) {
1222
+					$decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1223
+				}
1126 1224
 				$found = true;
1127 1225
 			}
1128 1226
 			if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) {
@@ -1132,7 +1230,9 @@  discard block
 block discarded – undo
1132 1230
 					$found = true;
1133 1231
 				}
1134 1232
 			}
1135
-			if ($found) $row['decode'] = json_encode($decode);
1233
+			if ($found) {
1234
+				$row['decode'] = json_encode($decode);
1235
+			}
1136 1236
 
1137 1237
 			$data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1138 1238
 			$result[] = $data;
@@ -1141,7 +1241,9 @@  discard block
 block discarded – undo
1141 1241
 		if (isset($result)) {
1142 1242
 			$result[0]['query_number_rows'] = $i;
1143 1243
 			return $result;
1144
-		} else return array();
1244
+		} else {
1245
+			return array();
1246
+		}
1145 1247
 	}
1146 1248
 
1147 1249
 	/**
@@ -1157,19 +1259,29 @@  discard block
 block discarded – undo
1157 1259
 		$ident = trim($ident);
1158 1260
 		$Translation = new Translation($this->db);
1159 1261
 		$Spotter = new Spotter($this->db);
1160
-		if ($globalDebug) echo "Test if we add ModeS data...";
1262
+		if ($globalDebug) {
1263
+			echo "Test if we add ModeS data...";
1264
+		}
1161 1265
 		//if ($icao == '') $icao = ACARS->ident2icao($ident);
1162
-		if ($icao == '') $icao = $Translation->checkTranslation($ident);
1163
-		if ($globalDebug) echo '- Ident : '.$icao.' - ';
1266
+		if ($icao == '') {
1267
+			$icao = $Translation->checkTranslation($ident);
1268
+		}
1269
+		if ($globalDebug) {
1270
+			echo '- Ident : '.$icao.' - ';
1271
+		}
1164 1272
 		if ($ident == '' || $registration == '') {
1165
-			if ($globalDebug) echo "Ident or registration null, exit\n";
1273
+			if ($globalDebug) {
1274
+				echo "Ident or registration null, exit\n";
1275
+			}
1166 1276
 			return '';
1167 1277
 		}
1168 1278
 
1169 1279
 		$registration = str_replace('.','',$registration);
1170 1280
 		$ident = $Translation->ident2icao($ident);
1171 1281
 		// Check if a flight with same registration is flying now, if ok check if callsign = name in ACARS, else add it to translation
1172
-		if ($globalDebug) echo "Check if needed to add translation ".$ident.'... ';
1282
+		if ($globalDebug) {
1283
+			echo "Check if needed to add translation ".$ident.'... ';
1284
+		}
1173 1285
 		$querysi = "SELECT ident FROM spotter_live s,aircraft_modes a WHERE a.ModeS = s.ModeS AND a.Registration = :registration AND s.format_source <> 'ACARS' LIMIT 1";
1174 1286
 		$querysi_values = array(':registration' => $registration);
1175 1287
 		try {
@@ -1177,7 +1289,9 @@  discard block
 block discarded – undo
1177 1289
 			$sthsi = $this->db->prepare($querysi);
1178 1290
 			$sthsi->execute($querysi_values);
1179 1291
 		} catch(PDOException $e) {
1180
-			if ($globalDebug) echo $e->getMessage();
1292
+			if ($globalDebug) {
1293
+				echo $e->getMessage();
1294
+			}
1181 1295
 			return "error : ".$e->getMessage();
1182 1296
 		}
1183 1297
 		$resultsi = $sthsi->fetch(PDO::FETCH_ASSOC);
@@ -1186,9 +1300,14 @@  discard block
 block discarded – undo
1186 1300
 		if (count($resultsi) > 0 && $resultsi['ident'] != $ident && $resultsi['ident'] != '') {
1187 1301
 			$Translation = new Translation($this->db);
1188 1302
 			$trans_ident = $Translation->getOperator($resultsi['ident']);
1189
-			if ($globalDebug) echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' ';
1190
-			if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'],$ident,'ACARS');
1191
-			elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'],$ident,'ACARS');
1303
+			if ($globalDebug) {
1304
+				echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' ';
1305
+			}
1306
+			if ($ident != $trans_ident) {
1307
+				$Translation->addOperator($resultsi['ident'],$ident,'ACARS');
1308
+			} elseif ($trans_ident == $ident) {
1309
+				$Translation->updateOperator($resultsi['ident'],$ident,'ACARS');
1310
+			}
1192 1311
 		} else {
1193 1312
 			if ($registration != '' && $latitude != '' && $longitude != '') {
1194 1313
 				$query = "SELECT ModeS FROM aircraft_modes WHERE Registration = :registration LIMIT 1";
@@ -1197,18 +1316,25 @@  discard block
 block discarded – undo
1197 1316
 					$sth = $this->db->prepare($query);
1198 1317
 					$sth->execute($query_values);
1199 1318
 				} catch(PDOException $e) {
1200
-					if ($globalDebug) echo $e->getMessage();
1319
+					if ($globalDebug) {
1320
+						echo $e->getMessage();
1321
+					}
1201 1322
 					return "error : ".$e->getMessage();
1202 1323
 				}
1203 1324
 				$result = $sth->fetch(PDO::FETCH_ASSOC);
1204 1325
 				$sth->closeCursor();
1205
-				if (isset($result['modes'])) $hex = $result['modes'];
1206
-				else $hex = '';
1326
+				if (isset($result['modes'])) {
1327
+					$hex = $result['modes'];
1328
+				} else {
1329
+					$hex = '';
1330
+				}
1207 1331
 				$SI_data = array('hex' => $hex,'ident' => $ident,'aircraft_icao' => $ICAOTypeCode,'registration' => $registration,'latitude' => $latitude,'$longitude' => $longitude,'format_source' => 'ACARS');
1208 1332
 				$this->SI->add($SI_data);
1209 1333
 			}
1210 1334
 		}
1211
-		if ($globalDebug) echo 'Done'."\n";
1335
+		if ($globalDebug) {
1336
+			echo 'Done'."\n";
1337
+		}
1212 1338
 
1213 1339
 		$query = "SELECT flightaware_id, ModeS FROM spotter_output WHERE ident = :ident AND format_source <> 'ACARS' ORDER BY spotter_id DESC LIMIT 1";
1214 1340
 		$query_values = array(':ident' => $icao);
@@ -1217,15 +1343,20 @@  discard block
 block discarded – undo
1217 1343
 			$sth = $this->db->prepare($query);
1218 1344
 			$sth->execute($query_values);
1219 1345
 		} catch(PDOException $e) {
1220
-			if ($globalDebug) echo $e->getMessage();
1346
+			if ($globalDebug) {
1347
+				echo $e->getMessage();
1348
+			}
1221 1349
 			return "error : ".$e->getMessage();
1222 1350
 		}
1223 1351
 		$result = $sth->fetch(PDO::FETCH_ASSOC);
1224 1352
 		$sth->closeCursor();
1225 1353
 		//print_r($result);
1226 1354
 		if (isset($result['flightaware_id'])) {
1227
-			if (isset($result['ModeS'])) $ModeS = $result['ModeS'];
1228
-			else $ModeS = '';
1355
+			if (isset($result['ModeS'])) {
1356
+				$ModeS = $result['ModeS'];
1357
+			} else {
1358
+				$ModeS = '';
1359
+			}
1229 1360
 			if ($ModeS == '') {
1230 1361
 				$id = explode('-',$result['flightaware_id']);
1231 1362
 				$ModeS = $id[0];
@@ -1239,13 +1370,17 @@  discard block
 block discarded – undo
1239 1370
 					$sthc = $this->db->prepare($queryc);
1240 1371
 					$sthc->execute($queryc_values);
1241 1372
 				} catch(PDOException $e) {
1242
-					if ($globalDebug) echo $e->getMessage();
1373
+					if ($globalDebug) {
1374
+						echo $e->getMessage();
1375
+					}
1243 1376
 					return "error : ".$e->getMessage();
1244 1377
 				}
1245 1378
 				$row = $sthc->fetch(PDO::FETCH_ASSOC);
1246 1379
 				$sthc->closeCursor();
1247 1380
 				if (count($row) ==  0) {
1248
-					if ($globalDebug) echo " Add to ModeS table - ";
1381
+					if ($globalDebug) {
1382
+						echo " Add to ModeS table - ";
1383
+					}
1249 1384
 					$queryi = "INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:ModeSCountry,:Registration, :ICAOTypeCode,'ACARS')";
1250 1385
 					$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1251 1386
 					try {
@@ -1253,11 +1388,15 @@  discard block
 block discarded – undo
1253 1388
 						$sthi = $this->db->prepare($queryi);
1254 1389
 						$sthi->execute($queryi_values);
1255 1390
 					} catch(PDOException $e) {
1256
-						if ($globalDebug) echo $e->getMessage();
1391
+						if ($globalDebug) {
1392
+							echo $e->getMessage();
1393
+						}
1257 1394
 						return "error : ".$e->getMessage();
1258 1395
 					}
1259 1396
 				} else {
1260
-					if ($globalDebug) echo " Update ModeS table - ";
1397
+					if ($globalDebug) {
1398
+						echo " Update ModeS table - ";
1399
+					}
1261 1400
 					if ($ICAOTypeCode != '') {
1262 1401
 						$queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,ICAOTypeCode = :ICAOTypeCode,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS";
1263 1402
 						$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
@@ -1270,7 +1409,9 @@  discard block
 block discarded – undo
1270 1409
 						$sthi = $this->db->prepare($queryi);
1271 1410
 						$sthi->execute($queryi_values);
1272 1411
 					} catch(PDOException $e) {
1273
-						if ($globalDebug) echo $e->getMessage();
1412
+						if ($globalDebug) {
1413
+							echo $e->getMessage();
1414
+						}
1274 1415
 						return "error : ".$e->getMessage();
1275 1416
 					}
1276 1417
 				}
@@ -1292,7 +1433,9 @@  discard block
 block discarded – undo
1292 1433
 					    return "error : ".$e->getMessage();
1293 1434
 				}
1294 1435
 				*/
1295
-				if ($globalDebug) echo " Update Spotter_output table - ";
1436
+				if ($globalDebug) {
1437
+					echo " Update Spotter_output table - ";
1438
+				}
1296 1439
 				if ($ICAOTypeCode != '') {
1297 1440
 					if ($globalDBdriver == 'mysql') {
1298 1441
 						$queryi = "UPDATE spotter_output SET registration = :Registration,aircraft_icao = :ICAOTypeCode WHERE ident = :ident AND date >= date_sub(UTC_TIMESTAMP(), INTERVAL 1 HOUR)";
@@ -1303,8 +1446,7 @@  discard block
 block discarded – undo
1303 1446
 				} else {
1304 1447
 					if ($globalDBdriver == 'mysql') {
1305 1448
 						$queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= date_sub(UTC_TIMESTAMP(), INTERVAL 1 HOUR)";
1306
-					}
1307
-					elseif ($globalDBdriver == 'pgsql') {
1449
+					} elseif ($globalDBdriver == 'pgsql') {
1308 1450
 						$queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR'";
1309 1451
 					}
1310 1452
 					$queryi_values = array(':Registration' => $registration,':ident' => $icao);
@@ -1314,15 +1456,21 @@  discard block
 block discarded – undo
1314 1456
 					$sthi = $this->db->prepare($queryi);
1315 1457
 					$sthi->execute($queryi_values);
1316 1458
 				} catch(PDOException $e) {
1317
-					if ($globalDebug) echo $e->getMessage();
1459
+					if ($globalDebug) {
1460
+						echo $e->getMessage();
1461
+					}
1318 1462
 					return "error : ".$e->getMessage();
1319 1463
 				}
1320 1464
 
1321 1465
 			}
1322 1466
 		} else {
1323
-			if ($globalDebug) echo " Can't find ModeS in spotter_output - ";
1467
+			if ($globalDebug) {
1468
+				echo " Can't find ModeS in spotter_output - ";
1469
+			}
1470
+		}
1471
+		if ($globalDebug) {
1472
+			echo "Done\n";
1324 1473
 		}
1325
-		if ($globalDebug) echo "Done\n";
1326 1474
 	}
1327 1475
 }
1328 1476
 ?>
Please login to merge, or discard this patch.