@@ -1126,6 +1126,10 @@ discard block |
||
| 1126 | 1126 | else return array(); |
| 1127 | 1127 | } |
| 1128 | 1128 | |
| 1129 | + /** |
|
| 1130 | + * @param string $type |
|
| 1131 | + * @param string $rules |
|
| 1132 | + */ |
|
| 1129 | 1133 | 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) { |
| 1130 | 1134 | $query = "INSERT INTO notam (ref,title,notam_type,fir,code,rules,scope,lower_limit,upper_limit,center_latitude,center_longitude,radius,date_begin,date_end,permanent,notam_text,full_notam) VALUES (:ref,:title,:type,:fir,:code,:rules,:scope,:lower_limit,:upper_limit,:center_latitude,:center_longitude,:radius,:date_begin,:date_end,:permanent,:text,:full_notam)"; |
| 1131 | 1135 | $query_values = array(':ref' => $ref,':title' => $title,':type' => $type,':fir' => $fir,':code' => $code,':rules' => $rules,':scope' => $scope,':lower_limit' => $lower_limit,':upper_limit' => $upper_limit,':center_latitude' => $center_latitude,':center_longitude' => $center_longitude,':radius' => $radius,':date_begin' => $date_begin,':date_end' => $date_end,':permanent' => $permanent,':text' => $text,':full_notam' => $full_notam); |
@@ -1207,6 +1211,10 @@ discard block |
||
| 1207 | 1211 | } |
| 1208 | 1212 | } |
| 1209 | 1213 | } |
| 1214 | + |
|
| 1215 | + /** |
|
| 1216 | + * @param string $filename |
|
| 1217 | + */ |
|
| 1210 | 1218 | public function updateNOTAMfromTextFile($filename) { |
| 1211 | 1219 | global $globalTransaction, $globalDebug; |
| 1212 | 1220 | $alldata = $this->parseNOTAMtextFile($filename); |
@@ -1261,6 +1269,9 @@ discard block |
||
| 1261 | 1269 | } |
| 1262 | 1270 | } |
| 1263 | 1271 | |
| 1272 | + /** |
|
| 1273 | + * @param string $icao |
|
| 1274 | + */ |
|
| 1264 | 1275 | public function downloadNOTAM($icao) { |
| 1265 | 1276 | date_default_timezone_set("UTC"); |
| 1266 | 1277 | $Common = new Common(); |
@@ -1416,6 +1427,9 @@ discard block |
||
| 1416 | 1427 | return $result; |
| 1417 | 1428 | } |
| 1418 | 1429 | |
| 1430 | + /** |
|
| 1431 | + * @param string $code |
|
| 1432 | + */ |
|
| 1419 | 1433 | public function parse_code($code) { |
| 1420 | 1434 | $code = str_split($code); |
| 1421 | 1435 | $code_fp = $code[1].$code[2]; |
@@ -1036,8 +1036,11 @@ discard block |
||
| 1036 | 1036 | public function parseNOTAMtextFile($filename) { |
| 1037 | 1037 | $data = file_get_contents($filename); |
| 1038 | 1038 | preg_match_all("/%%(.+?)%%/is", $data, $matches); |
| 1039 | - if (isset($matches[1])) return $matches[1]; |
|
| 1040 | - else return array(); |
|
| 1039 | + if (isset($matches[1])) { |
|
| 1040 | + return $matches[1]; |
|
| 1041 | + } else { |
|
| 1042 | + return array(); |
|
| 1043 | + } |
|
| 1041 | 1044 | } |
| 1042 | 1045 | public function getAllNOTAMbyScope($scope) { |
| 1043 | 1046 | global $globalDBdriver; |
@@ -1073,7 +1076,9 @@ discard block |
||
| 1073 | 1076 | $minlong = $maxlong; |
| 1074 | 1077 | $maxlong = $tmplong; |
| 1075 | 1078 | } |
| 1076 | - } else return array(); |
|
| 1079 | + } else { |
|
| 1080 | + return array(); |
|
| 1081 | + } |
|
| 1077 | 1082 | if ($globalDBdriver == 'mysql') { |
| 1078 | 1083 | $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()'; |
| 1079 | 1084 | } else { |
@@ -1096,7 +1101,9 @@ discard block |
||
| 1096 | 1101 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 1097 | 1102 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 1098 | 1103 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 1099 | - } else return array(); |
|
| 1104 | + } else { |
|
| 1105 | + return array(); |
|
| 1106 | + } |
|
| 1100 | 1107 | if ($globalDBdriver == 'mysql') { |
| 1101 | 1108 | $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'; |
| 1102 | 1109 | } else { |
@@ -1122,8 +1129,11 @@ discard block |
||
| 1122 | 1129 | return "error : ".$e->getMessage(); |
| 1123 | 1130 | } |
| 1124 | 1131 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1125 | - if (isset($all[0])) return $all[0]; |
|
| 1126 | - else return array(); |
|
| 1132 | + if (isset($all[0])) { |
|
| 1133 | + return $all[0]; |
|
| 1134 | + } else { |
|
| 1135 | + return array(); |
|
| 1136 | + } |
|
| 1127 | 1137 | } |
| 1128 | 1138 | |
| 1129 | 1139 | 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) { |
@@ -1201,7 +1211,9 @@ discard block |
||
| 1201 | 1211 | foreach ($alldata as $initial_data) { |
| 1202 | 1212 | $data = $this->parse($initial_data); |
| 1203 | 1213 | $notamref = $this->getNOTAMbyRef($data['ref']); |
| 1204 | - 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']); |
|
| 1214 | + if (count($notamref) == 0) { |
|
| 1215 | + $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']); |
|
| 1216 | + } |
|
| 1205 | 1217 | } |
| 1206 | 1218 | } |
| 1207 | 1219 | } |
@@ -1212,20 +1224,28 @@ discard block |
||
| 1212 | 1224 | $alldata = $this->parseNOTAMtextFile($filename); |
| 1213 | 1225 | if (count($alldata) > 0) { |
| 1214 | 1226 | $this->deleteOldNOTAM(); |
| 1215 | - if ($globalTransaction) $this->db->beginTransaction(); |
|
| 1227 | + if ($globalTransaction) { |
|
| 1228 | + $this->db->beginTransaction(); |
|
| 1229 | + } |
|
| 1216 | 1230 | $j = 0; |
| 1217 | 1231 | foreach ($alldata as $initial_data) { |
| 1218 | 1232 | $j++; |
| 1219 | 1233 | $data = $this->parse($initial_data); |
| 1220 | 1234 | $notamref = $this->getNOTAMbyRef($data['ref']); |
| 1221 | - 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']); |
|
| 1235 | + if (!isset($notamref['notam_id'])) { |
|
| 1236 | + $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']); |
|
| 1237 | + } |
|
| 1222 | 1238 | if ($globalTransaction && $j % 1000 == 0) { |
| 1223 | 1239 | $this->db->commit(); |
| 1224 | - if ($globalDebug) echo '.'; |
|
| 1240 | + if ($globalDebug) { |
|
| 1241 | + echo '.'; |
|
| 1242 | + } |
|
| 1225 | 1243 | $this->db->beginTransaction(); |
| 1226 | 1244 | } |
| 1227 | 1245 | } |
| 1228 | - if ($globalTransaction) $this->db->commit(); |
|
| 1246 | + if ($globalTransaction) { |
|
| 1247 | + $this->db->commit(); |
|
| 1248 | + } |
|
| 1229 | 1249 | } |
| 1230 | 1250 | } |
| 1231 | 1251 | |
@@ -1236,11 +1256,15 @@ discard block |
||
| 1236 | 1256 | foreach (array_chunk($allairports,20) as $airport) { |
| 1237 | 1257 | $airports_icao = array(); |
| 1238 | 1258 | foreach($airport as $icao) { |
| 1239 | - if (isset($icao['icao'])) $airports_icao[] = $icao['icao']; |
|
| 1259 | + if (isset($icao['icao'])) { |
|
| 1260 | + $airports_icao[] = $icao['icao']; |
|
| 1261 | + } |
|
| 1240 | 1262 | } |
| 1241 | 1263 | $airport_icao = implode(',',$airports_icao); |
| 1242 | 1264 | $alldata = $this->downloadNOTAM($airport_icao); |
| 1243 | - if ($globalTransaction) $this->db->beginTransaction(); |
|
| 1265 | + if ($globalTransaction) { |
|
| 1266 | + $this->db->beginTransaction(); |
|
| 1267 | + } |
|
| 1244 | 1268 | if (count($alldata) > 0) { |
| 1245 | 1269 | foreach ($alldata as $initial_data) { |
| 1246 | 1270 | //print_r($initial_data); |
@@ -1249,14 +1273,23 @@ discard block |
||
| 1249 | 1273 | if (isset($data['ref'])) { |
| 1250 | 1274 | $notamref = $this->getNOTAMbyRef($data['ref']); |
| 1251 | 1275 | if (count($notamref) == 0) { |
| 1252 | - if (isset($data['ref_replaced'])) $this->deleteNOTAMbyRef($data['ref_replaced']); |
|
| 1253 | - if (isset($data['ref_cancelled'])) $this->deleteNOTAMbyRef($data['ref_cancelled']); |
|
| 1254 | - 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']); |
|
| 1276 | + if (isset($data['ref_replaced'])) { |
|
| 1277 | + $this->deleteNOTAMbyRef($data['ref_replaced']); |
|
| 1278 | + } |
|
| 1279 | + if (isset($data['ref_cancelled'])) { |
|
| 1280 | + $this->deleteNOTAMbyRef($data['ref_cancelled']); |
|
| 1281 | + } elseif (isset($data['latitude']) && isset($data['scope']) && isset($data['text']) && isset($data['permanent'])) { |
|
| 1282 | + 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']); |
|
| 1283 | + } |
|
| 1255 | 1284 | } |
| 1256 | 1285 | } |
| 1257 | 1286 | } |
| 1258 | - } else echo 'Error on download. Nothing matches for '.$airport_icao."\n"; |
|
| 1259 | - if ($globalTransaction) $this->db->commit(); |
|
| 1287 | + } else { |
|
| 1288 | + echo 'Error on download. Nothing matches for '.$airport_icao."\n"; |
|
| 1289 | + } |
|
| 1290 | + if ($globalTransaction) { |
|
| 1291 | + $this->db->commit(); |
|
| 1292 | + } |
|
| 1260 | 1293 | sleep(5); |
| 1261 | 1294 | } |
| 1262 | 1295 | } |
@@ -1269,8 +1302,11 @@ discard block |
||
| 1269 | 1302 | $data = $Common->getData($url); |
| 1270 | 1303 | preg_match_all("/<pre>(.+?)<\/pre>/is", $data, $matches); |
| 1271 | 1304 | //print_r($matches); |
| 1272 | - if (isset($matches[1])) return $matches[1]; |
|
| 1273 | - else return array(); |
|
| 1305 | + if (isset($matches[1])) { |
|
| 1306 | + return $matches[1]; |
|
| 1307 | + } else { |
|
| 1308 | + return array(); |
|
| 1309 | + } |
|
| 1274 | 1310 | } |
| 1275 | 1311 | |
| 1276 | 1312 | public function parse($data) { |
@@ -1301,99 +1337,156 @@ discard block |
||
| 1301 | 1337 | $rules = str_split($matches[3]); |
| 1302 | 1338 | foreach ($rules as $rule) { |
| 1303 | 1339 | if ($rule == 'I') { |
| 1304 | - if (isset($result['rules'])) $result['rules'] = $result['rules'].'/IFR'; |
|
| 1305 | - else $result['rules'] = 'IFR'; |
|
| 1340 | + if (isset($result['rules'])) { |
|
| 1341 | + $result['rules'] = $result['rules'].'/IFR'; |
|
| 1342 | + } else { |
|
| 1343 | + $result['rules'] = 'IFR'; |
|
| 1344 | + } |
|
| 1306 | 1345 | } elseif ($rule == 'V') { |
| 1307 | - if (isset($result['rules'])) $result['rules'] = $result['rules'].'/VFR'; |
|
| 1308 | - else $result['rules'] = 'VFR'; |
|
| 1346 | + if (isset($result['rules'])) { |
|
| 1347 | + $result['rules'] = $result['rules'].'/VFR'; |
|
| 1348 | + } else { |
|
| 1349 | + $result['rules'] = 'VFR'; |
|
| 1350 | + } |
|
| 1309 | 1351 | } elseif ($rule == 'K') { |
| 1310 | - if (isset($result['rules'])) $result['rules'] = $result['rules'].'/Checklist'; |
|
| 1311 | - else $result['rules'] = 'Checklist'; |
|
| 1352 | + if (isset($result['rules'])) { |
|
| 1353 | + $result['rules'] = $result['rules'].'/Checklist'; |
|
| 1354 | + } else { |
|
| 1355 | + $result['rules'] = 'Checklist'; |
|
| 1356 | + } |
|
| 1312 | 1357 | } |
| 1313 | 1358 | } |
| 1314 | 1359 | $attentions = str_split($matches[4]); |
| 1315 | 1360 | foreach ($attentions as $attention) { |
| 1316 | 1361 | if ($attention == 'N') { |
| 1317 | - if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Immediate attention'; |
|
| 1318 | - else $result['rules'] = 'Immediate attention'; |
|
| 1362 | + if (isset($result['attention'])) { |
|
| 1363 | + $result['attention'] = $result['attention'].' / Immediate attention'; |
|
| 1364 | + } else { |
|
| 1365 | + $result['rules'] = 'Immediate attention'; |
|
| 1366 | + } |
|
| 1319 | 1367 | } elseif ($attention == 'B') { |
| 1320 | - if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Operational significance'; |
|
| 1321 | - else $result['rules'] = 'Operational significance'; |
|
| 1368 | + if (isset($result['attention'])) { |
|
| 1369 | + $result['attention'] = $result['attention'].' / Operational significance'; |
|
| 1370 | + } else { |
|
| 1371 | + $result['rules'] = 'Operational significance'; |
|
| 1372 | + } |
|
| 1322 | 1373 | } elseif ($attention == 'O') { |
| 1323 | - if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Flight operations'; |
|
| 1324 | - else $result['rules'] = 'Flight operations'; |
|
| 1374 | + if (isset($result['attention'])) { |
|
| 1375 | + $result['attention'] = $result['attention'].' / Flight operations'; |
|
| 1376 | + } else { |
|
| 1377 | + $result['rules'] = 'Flight operations'; |
|
| 1378 | + } |
|
| 1325 | 1379 | } elseif ($attention == 'M') { |
| 1326 | - if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Misc'; |
|
| 1327 | - else $result['rules'] = 'Misc'; |
|
| 1380 | + if (isset($result['attention'])) { |
|
| 1381 | + $result['attention'] = $result['attention'].' / Misc'; |
|
| 1382 | + } else { |
|
| 1383 | + $result['rules'] = 'Misc'; |
|
| 1384 | + } |
|
| 1328 | 1385 | } elseif ($attention == 'K') { |
| 1329 | - if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Checklist'; |
|
| 1330 | - else $result['rules'] = 'Checklist'; |
|
| 1386 | + if (isset($result['attention'])) { |
|
| 1387 | + $result['attention'] = $result['attention'].' / Checklist'; |
|
| 1388 | + } else { |
|
| 1389 | + $result['rules'] = 'Checklist'; |
|
| 1390 | + } |
|
| 1331 | 1391 | } |
| 1332 | 1392 | } |
| 1333 | - if ($matches[5] == 'A') $result['scope'] = 'Airport warning'; |
|
| 1334 | - elseif ($matches[5] == 'E') $result['scope'] = 'Enroute warning'; |
|
| 1335 | - elseif ($matches[5] == 'W') $result['scope'] = 'Navigation warning'; |
|
| 1336 | - elseif ($matches[5] == 'K') $result['scope'] = 'Checklist'; |
|
| 1337 | - elseif ($matches[5] == 'AE') $result['scope'] = 'Airport/Enroute warning'; |
|
| 1338 | - elseif ($matches[5] == 'AW') $result['scope'] = 'Airport/Navigation warning'; |
|
| 1393 | + if ($matches[5] == 'A') { |
|
| 1394 | + $result['scope'] = 'Airport warning'; |
|
| 1395 | + } elseif ($matches[5] == 'E') { |
|
| 1396 | + $result['scope'] = 'Enroute warning'; |
|
| 1397 | + } elseif ($matches[5] == 'W') { |
|
| 1398 | + $result['scope'] = 'Navigation warning'; |
|
| 1399 | + } elseif ($matches[5] == 'K') { |
|
| 1400 | + $result['scope'] = 'Checklist'; |
|
| 1401 | + } elseif ($matches[5] == 'AE') { |
|
| 1402 | + $result['scope'] = 'Airport/Enroute warning'; |
|
| 1403 | + } elseif ($matches[5] == 'AW') { |
|
| 1404 | + $result['scope'] = 'Airport/Navigation warning'; |
|
| 1405 | + } |
|
| 1339 | 1406 | $result['lower_limit'] = $matches[6]; |
| 1340 | 1407 | $result['upper_limit'] = $matches[7]; |
| 1341 | 1408 | $latitude = $Common->convertDec($matches[8],'latitude'); |
| 1342 | - if ($matches[9] == 'S') $latitude = -$latitude; |
|
| 1409 | + if ($matches[9] == 'S') { |
|
| 1410 | + $latitude = -$latitude; |
|
| 1411 | + } |
|
| 1343 | 1412 | $longitude = $Common->convertDec($matches[10],'longitude'); |
| 1344 | - if ($matches[11] == 'W') $longitude = -$longitude; |
|
| 1413 | + if ($matches[11] == 'W') { |
|
| 1414 | + $longitude = -$longitude; |
|
| 1415 | + } |
|
| 1345 | 1416 | $result['latitude'] = $latitude; |
| 1346 | 1417 | $result['longitude'] = $longitude; |
| 1347 | - if ($matches[12] != '') $result['radius'] = intval($matches[12]); |
|
| 1348 | - else $result['radius'] = 0; |
|
| 1418 | + if ($matches[12] != '') { |
|
| 1419 | + $result['radius'] = intval($matches[12]); |
|
| 1420 | + } else { |
|
| 1421 | + $result['radius'] = 0; |
|
| 1422 | + } |
|
| 1349 | 1423 | $q = true; |
| 1350 | 1424 | } elseif ($globalDebug) { |
| 1351 | 1425 | echo 'NOTAM error : '.$result['full_notam']."\n"; |
| 1352 | 1426 | echo "Can't parse : ".$line."\n"; |
| 1353 | 1427 | } |
| 1354 | - } |
|
| 1355 | - elseif (preg_match('#(^|\s)A\) (.*)#',$line,$matches) && $a === false) { |
|
| 1428 | + } elseif (preg_match('#(^|\s)A\) (.*)#',$line,$matches) && $a === false) { |
|
| 1356 | 1429 | $result['icao'] = $matches[2]; |
| 1357 | 1430 | $a = true; |
| 1358 | - } |
|
| 1359 | - elseif (preg_match('#(^|\s)B\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})#',$line,$matches) && $b === false) { |
|
| 1360 | - if ($matches[1] > 50) $year = '19'.$matches[2]; |
|
| 1361 | - else $year = '20'.$matches[2]; |
|
| 1431 | + } elseif (preg_match('#(^|\s)B\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})#',$line,$matches) && $b === false) { |
|
| 1432 | + if ($matches[1] > 50) { |
|
| 1433 | + $year = '19'.$matches[2]; |
|
| 1434 | + } else { |
|
| 1435 | + $year = '20'.$matches[2]; |
|
| 1436 | + } |
|
| 1362 | 1437 | $result['date_begin'] = $year.'/'.$matches[3].'/'.$matches[4].' '.$matches[5].':'.$matches[6]; |
| 1363 | 1438 | $b = true; |
| 1364 | - } |
|
| 1365 | - elseif (preg_match('#(^|\s)C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#',$line,$matches) && $c === false) { |
|
| 1366 | - if ($matches[2] > 50) $year = '19'.$matches[2]; |
|
| 1367 | - else $year = '20'.$matches[2]; |
|
| 1439 | + } elseif (preg_match('#(^|\s)C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#',$line,$matches) && $c === false) { |
|
| 1440 | + if ($matches[2] > 50) { |
|
| 1441 | + $year = '19'.$matches[2]; |
|
| 1442 | + } else { |
|
| 1443 | + $year = '20'.$matches[2]; |
|
| 1444 | + } |
|
| 1368 | 1445 | $result['date_end'] = $year.'/'.$matches[3].'/'.$matches[4].' '.$matches[5].':'.$matches[6]; |
| 1369 | 1446 | $result['permanent'] = 0; |
| 1370 | 1447 | $c = true; |
| 1371 | - } |
|
| 1372 | - elseif (preg_match('#(^|\s)C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2}) (EST|PERM)$#',$line,$matches) && $c === false) { |
|
| 1373 | - if ($matches[2] > 50) $year = '19'.$matches[2]; |
|
| 1374 | - else $year = '20'.$matches[2]; |
|
| 1448 | + } elseif (preg_match('#(^|\s)C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2}) (EST|PERM)$#',$line,$matches) && $c === false) { |
|
| 1449 | + if ($matches[2] > 50) { |
|
| 1450 | + $year = '19'.$matches[2]; |
|
| 1451 | + } else { |
|
| 1452 | + $year = '20'.$matches[2]; |
|
| 1453 | + } |
|
| 1375 | 1454 | $result['date_end'] = $year.'/'.$matches[3].'/'.$matches[4].' '.$matches[5].':'.$matches[6]; |
| 1376 | - if ($matches[7] == 'EST') $result['estimated'] = 1; |
|
| 1377 | - else $result['estimated'] = 0; |
|
| 1378 | - if ($matches[7] == 'PERM') $result['permanent'] = 1; |
|
| 1379 | - else $result['permanent'] = 0; |
|
| 1455 | + if ($matches[7] == 'EST') { |
|
| 1456 | + $result['estimated'] = 1; |
|
| 1457 | + } else { |
|
| 1458 | + $result['estimated'] = 0; |
|
| 1459 | + } |
|
| 1460 | + if ($matches[7] == 'PERM') { |
|
| 1461 | + $result['permanent'] = 1; |
|
| 1462 | + } else { |
|
| 1463 | + $result['permanent'] = 0; |
|
| 1464 | + } |
|
| 1380 | 1465 | $c = true; |
| 1381 | - } |
|
| 1382 | - elseif (preg_match('#(^|\s)C\) (EST|PERM)$#',$line,$matches) && $c === false) { |
|
| 1466 | + } elseif (preg_match('#(^|\s)C\) (EST|PERM)$#',$line,$matches) && $c === false) { |
|
| 1383 | 1467 | $result['date_end'] = '2030/12/20 12:00'; |
| 1384 | - if ($matches[2] == 'EST') $result['estimated'] = 1; |
|
| 1385 | - else $result['estimated'] = 0; |
|
| 1386 | - if ($matches[2] == 'PERM') $result['permanent'] = 1; |
|
| 1387 | - else $result['permanent'] = 0; |
|
| 1468 | + if ($matches[2] == 'EST') { |
|
| 1469 | + $result['estimated'] = 1; |
|
| 1470 | + } else { |
|
| 1471 | + $result['estimated'] = 0; |
|
| 1472 | + } |
|
| 1473 | + if ($matches[2] == 'PERM') { |
|
| 1474 | + $result['permanent'] = 1; |
|
| 1475 | + } else { |
|
| 1476 | + $result['permanent'] = 0; |
|
| 1477 | + } |
|
| 1388 | 1478 | $c = true; |
| 1389 | - } |
|
| 1390 | - elseif (preg_match('#(^|\s)E\) (.*)#',$line,$matches) && $e === false) { |
|
| 1479 | + } elseif (preg_match('#(^|\s)E\) (.*)#',$line,$matches) && $e === false) { |
|
| 1391 | 1480 | $rtext = array(); |
| 1392 | 1481 | $text = explode(' ',$matches[2]); |
| 1393 | 1482 | foreach ($text as $word) { |
| 1394 | - if (isset($this->abbr[$word])) $rtext[] = strtoupper($this->abbr[$word]); |
|
| 1395 | - 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); |
|
| 1396 | - else $rtext[] = $word; |
|
| 1483 | + if (isset($this->abbr[$word])) { |
|
| 1484 | + $rtext[] = strtoupper($this->abbr[$word]); |
|
| 1485 | + } elseif (ctype_digit(strval(substr($word,3))) && isset($this->abbr[substr($word,0,3)])) { |
|
| 1486 | + $rtext[] = strtoupper($this->abbr[substr($word,0,3)]).' '.substr($word,3); |
|
| 1487 | + } else { |
|
| 1488 | + $rtext[] = $word; |
|
| 1489 | + } |
|
| 1397 | 1490 | } |
| 1398 | 1491 | $result['text'] = implode(' ',$rtext); |
| 1399 | 1492 | $e = true; |
@@ -1402,7 +1495,9 @@ discard block |
||
| 1402 | 1495 | } elseif (preg_match('#(NOTAMN|NOTAMR|NOTAMC)#',$line,$matches)) { |
| 1403 | 1496 | $text = explode(' ',$line); |
| 1404 | 1497 | $result['ref'] = $text[0]; |
| 1405 | - if ($matches[1] == 'NOTAMN') $result['type'] = 'new'; |
|
| 1498 | + if ($matches[1] == 'NOTAMN') { |
|
| 1499 | + $result['type'] = 'new'; |
|
| 1500 | + } |
|
| 1406 | 1501 | if ($matches[1] == 'NOTAMC') { |
| 1407 | 1502 | $result['type'] = 'cancel'; |
| 1408 | 1503 | $result['ref_cancelled'] = $text[2]; |
@@ -1424,69 +1519,101 @@ discard block |
||
| 1424 | 1519 | switch ($code[1]) { |
| 1425 | 1520 | case 'A': |
| 1426 | 1521 | $result = 'Airspace organization '; |
| 1427 | - if (isset($this->code_airspace[$code_fp])) $result .= $this->code_airspace[$code_fp]; |
|
| 1522 | + if (isset($this->code_airspace[$code_fp])) { |
|
| 1523 | + $result .= $this->code_airspace[$code_fp]; |
|
| 1524 | + } |
|
| 1428 | 1525 | break; |
| 1429 | 1526 | case 'C': |
| 1430 | 1527 | $result = 'Communications and radar facilities '; |
| 1431 | - if (isset($this->code_comradar[$code_fp])) $result .= $this->code_comradar[$code_fp]; |
|
| 1528 | + if (isset($this->code_comradar[$code_fp])) { |
|
| 1529 | + $result .= $this->code_comradar[$code_fp]; |
|
| 1530 | + } |
|
| 1432 | 1531 | break; |
| 1433 | 1532 | case 'F': |
| 1434 | 1533 | $result = 'Facilities and services '; |
| 1435 | - if (isset($this->code_facilities[$code_fp])) $result .= $this->code_facilities[$code_fp]; |
|
| 1534 | + if (isset($this->code_facilities[$code_fp])) { |
|
| 1535 | + $result .= $this->code_facilities[$code_fp]; |
|
| 1536 | + } |
|
| 1436 | 1537 | break; |
| 1437 | 1538 | case 'I': |
| 1438 | 1539 | $result = 'Instrument and Microwave Landing System '; |
| 1439 | - if (isset($this->code_instrumentlanding[$code_fp])) $result .= $this->code_instrumentlanding[$code_fp]; |
|
| 1540 | + if (isset($this->code_instrumentlanding[$code_fp])) { |
|
| 1541 | + $result .= $this->code_instrumentlanding[$code_fp]; |
|
| 1542 | + } |
|
| 1440 | 1543 | break; |
| 1441 | 1544 | case 'L': |
| 1442 | 1545 | $result = 'Lighting facilities '; |
| 1443 | - if (isset($this->code_lightingfacilities[$code_fp])) $result .= $this->code_lightingfacilities[$code_fp]; |
|
| 1546 | + if (isset($this->code_lightingfacilities[$code_fp])) { |
|
| 1547 | + $result .= $this->code_lightingfacilities[$code_fp]; |
|
| 1548 | + } |
|
| 1444 | 1549 | break; |
| 1445 | 1550 | case 'M': |
| 1446 | 1551 | $result = 'Movement and landing areas '; |
| 1447 | - if (isset($this->code_movementareas[$code_fp])) $result .= $this->code_movementareas[$code_fp]; |
|
| 1552 | + if (isset($this->code_movementareas[$code_fp])) { |
|
| 1553 | + $result .= $this->code_movementareas[$code_fp]; |
|
| 1554 | + } |
|
| 1448 | 1555 | break; |
| 1449 | 1556 | case 'N': |
| 1450 | 1557 | $result = 'Terminal and En Route Navigation Facilities '; |
| 1451 | - if (isset($this->code_terminalfacilities[$code_fp])) $result .= $this->code_terminalfacilities[$code_fp]; |
|
| 1558 | + if (isset($this->code_terminalfacilities[$code_fp])) { |
|
| 1559 | + $result .= $this->code_terminalfacilities[$code_fp]; |
|
| 1560 | + } |
|
| 1452 | 1561 | break; |
| 1453 | 1562 | case 'O': |
| 1454 | 1563 | $result = 'Other information '; |
| 1455 | - if (isset($this->code_information[$code_fp])) $result .= $this->code_information[$code_fp]; |
|
| 1564 | + if (isset($this->code_information[$code_fp])) { |
|
| 1565 | + $result .= $this->code_information[$code_fp]; |
|
| 1566 | + } |
|
| 1456 | 1567 | break; |
| 1457 | 1568 | case 'P': |
| 1458 | 1569 | $result = 'Air Traffic procedures '; |
| 1459 | - if (isset($this->code_airtraffic[$code_fp])) $result .= $this->code_airtraffic[$code_fp]; |
|
| 1570 | + if (isset($this->code_airtraffic[$code_fp])) { |
|
| 1571 | + $result .= $this->code_airtraffic[$code_fp]; |
|
| 1572 | + } |
|
| 1460 | 1573 | break; |
| 1461 | 1574 | case 'R': |
| 1462 | 1575 | $result = 'Navigation Warnings: Airspace Restrictions '; |
| 1463 | - if (isset($this->code_navigationw[$code_fp])) $result .= $this->code_navigationw[$code_fp]; |
|
| 1576 | + if (isset($this->code_navigationw[$code_fp])) { |
|
| 1577 | + $result .= $this->code_navigationw[$code_fp]; |
|
| 1578 | + } |
|
| 1464 | 1579 | break; |
| 1465 | 1580 | case 'S': |
| 1466 | 1581 | $result = 'Air Traffic and VOLMET Services '; |
| 1467 | - if (isset($this->code_volmet[$code_fp])) $result .= $this->code_volmet[$code_fp]; |
|
| 1582 | + if (isset($this->code_volmet[$code_fp])) { |
|
| 1583 | + $result .= $this->code_volmet[$code_fp]; |
|
| 1584 | + } |
|
| 1468 | 1585 | break; |
| 1469 | 1586 | case 'W': |
| 1470 | 1587 | $result = 'Navigation Warnings: Warnings '; |
| 1471 | - if (isset($this->code_warnings[$code_fp])) $result .= $this->code_warnings[$code_fp]; |
|
| 1588 | + if (isset($this->code_warnings[$code_fp])) { |
|
| 1589 | + $result .= $this->code_warnings[$code_fp]; |
|
| 1590 | + } |
|
| 1472 | 1591 | break; |
| 1473 | 1592 | } |
| 1474 | 1593 | switch ($code[3]) { |
| 1475 | 1594 | case 'A': |
| 1476 | 1595 | // Availability |
| 1477 | - if (isset($this->code_sp_availabity[$code_sp])) $result .= ' '.$this->code_sp_availabity[$code_sp]; |
|
| 1596 | + if (isset($this->code_sp_availabity[$code_sp])) { |
|
| 1597 | + $result .= ' '.$this->code_sp_availabity[$code_sp]; |
|
| 1598 | + } |
|
| 1478 | 1599 | break; |
| 1479 | 1600 | case 'C': |
| 1480 | 1601 | // Changes |
| 1481 | - if (isset($this->code_sp_changes[$code_sp])) $result .= ' '.$this->code_sp_changes[$code_sp]; |
|
| 1602 | + if (isset($this->code_sp_changes[$code_sp])) { |
|
| 1603 | + $result .= ' '.$this->code_sp_changes[$code_sp]; |
|
| 1604 | + } |
|
| 1482 | 1605 | break; |
| 1483 | 1606 | case 'H': |
| 1484 | 1607 | // Hazardous conditions |
| 1485 | - if (isset($this->code_sp_hazardous[$code_sp])) $result .= ' '.$this->code_sp_hazardous[$code_sp]; |
|
| 1608 | + if (isset($this->code_sp_hazardous[$code_sp])) { |
|
| 1609 | + $result .= ' '.$this->code_sp_hazardous[$code_sp]; |
|
| 1610 | + } |
|
| 1486 | 1611 | break; |
| 1487 | 1612 | case 'L': |
| 1488 | 1613 | // Limitations |
| 1489 | - if (isset($this->code_sp_limitations[$code_sp])) $result .= ' '.$this->code_sp_limitations[$code_sp]; |
|
| 1614 | + if (isset($this->code_sp_limitations[$code_sp])) { |
|
| 1615 | + $result .= ' '.$this->code_sp_limitations[$code_sp]; |
|
| 1616 | + } |
|
| 1490 | 1617 | break; |
| 1491 | 1618 | case 'X': |
| 1492 | 1619 | // Other Information |
@@ -20,7 +20,9 @@ discard block |
||
| 20 | 20 | public function __construct($dbc = null) { |
| 21 | 21 | $Connection = new Connection($dbc); |
| 22 | 22 | $this->db = $Connection->db(); |
| 23 | - if ($this->db === null) die('Error: No DB connection. (Accident)'); |
|
| 23 | + if ($this->db === null) { |
|
| 24 | + die('Error: No DB connection. (Accident)'); |
|
| 25 | + } |
|
| 24 | 26 | } |
| 25 | 27 | |
| 26 | 28 | /* |
@@ -125,8 +127,11 @@ discard block |
||
| 125 | 127 | $data = array(); |
| 126 | 128 | if ($row['registration'] != '') { |
| 127 | 129 | $image_array = $Image->getSpotterImage($row['registration']); |
| 128 | - 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'])); |
|
| 129 | - else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 130 | + if (count($image_array) > 0) { |
|
| 131 | + $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'])); |
|
| 132 | + } else { |
|
| 133 | + $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 134 | + } |
|
| 130 | 135 | $aircraft_type = $Spotter->getAllAircraftTypeByRegistration($row['registration']); |
| 131 | 136 | $aircraft_info = $Spotter->getAllAircraftInfo($aircraft_type); |
| 132 | 137 | if (!empty($aircraft_info)) { |
@@ -142,17 +147,30 @@ discard block |
||
| 142 | 147 | $data['aircraft_base'] = $owner_data['base']; |
| 143 | 148 | $data['aircraft_date_first_reg'] = $owner_data['date_first_reg']; |
| 144 | 149 | } |
| 145 | - } else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 146 | - if ($row['registration'] == '') $row['registration'] = 'NA'; |
|
| 147 | - if ($row['ident'] == '') $row['ident'] = 'NA'; |
|
| 150 | + } else { |
|
| 151 | + $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 152 | + } |
|
| 153 | + if ($row['registration'] == '') { |
|
| 154 | + $row['registration'] = 'NA'; |
|
| 155 | + } |
|
| 156 | + if ($row['ident'] == '') { |
|
| 157 | + $row['ident'] = 'NA'; |
|
| 158 | + } |
|
| 148 | 159 | $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,3)); |
| 149 | 160 | if (isset($identicao[0])) { |
| 150 | 161 | if (substr($row['ident'],0,2) == 'AF') { |
| 151 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
| 152 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
| 153 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
| 162 | + if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) { |
|
| 163 | + $icao = $row['ident']; |
|
| 164 | + } else { |
|
| 165 | + $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
| 166 | + } |
|
| 167 | + } else { |
|
| 168 | + $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
| 169 | + } |
|
| 154 | 170 | $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
| 155 | - } else $icao = $row['ident']; |
|
| 171 | + } else { |
|
| 172 | + $icao = $row['ident']; |
|
| 173 | + } |
|
| 156 | 174 | $icao = $Translation->checkTranslation($icao,false); |
| 157 | 175 | //$data = array_merge($data,array('registration' => $row['registration'], 'date' => $row['date'], 'ident' => $icao,'url' => $row['url'])); |
| 158 | 176 | if ($row['airline_name'] != '' && !isset($data['airline_name'])) { |
@@ -167,10 +185,14 @@ discard block |
||
| 167 | 185 | //else echo 'No data...'."\n"; |
| 168 | 186 | } |
| 169 | 187 | $data = array_merge($row,$data); |
| 170 | - if ($data['ident'] == null) $data['ident'] = $icao; |
|
| 188 | + if ($data['ident'] == null) { |
|
| 189 | + $data['ident'] = $icao; |
|
| 190 | + } |
|
| 171 | 191 | if ($data['title'] == null) { |
| 172 | 192 | $data['message'] = $row['type'].' of '.$row['registration'].' at '.$row['place'].','.$row['country']; |
| 173 | - } else $data['message'] = strtolower($data['title']); |
|
| 193 | + } else { |
|
| 194 | + $data['message'] = strtolower($data['title']); |
|
| 195 | + } |
|
| 174 | 196 | $ids = $Spotter->getAllIDByRegistration($data['registration'],true); |
| 175 | 197 | $date = $data['date']; |
| 176 | 198 | if (isset($ids[$date])) { |
@@ -189,8 +211,9 @@ discard block |
||
| 189 | 211 | if (isset($result)) { |
| 190 | 212 | $result[0]['query_number_rows'] = $i; |
| 191 | 213 | return $result; |
| 214 | + } else { |
|
| 215 | + return array(); |
|
| 192 | 216 | } |
| 193 | - else return array(); |
|
| 194 | 217 | } |
| 195 | 218 | |
| 196 | 219 | /* |
@@ -235,7 +258,9 @@ discard block |
||
| 235 | 258 | */ |
| 236 | 259 | public function import($file) { |
| 237 | 260 | global $globalTransaction, $globalDebug; |
| 238 | - if ($globalDebug) echo 'Import '.$file."\n"; |
|
| 261 | + if ($globalDebug) { |
|
| 262 | + echo 'Import '.$file."\n"; |
|
| 263 | + } |
|
| 239 | 264 | $result = array(); |
| 240 | 265 | if (file_exists($file)) { |
| 241 | 266 | if (($handle = fopen($file,'r')) !== FALSE) { |
@@ -246,8 +271,11 @@ discard block |
||
| 246 | 271 | } |
| 247 | 272 | fclose($handle); |
| 248 | 273 | } |
| 249 | - if (!empty($result)) $this->add($result,true); |
|
| 250 | - elseif ($globalDebug) echo 'Nothing to import'; |
|
| 274 | + if (!empty($result)) { |
|
| 275 | + $this->add($result,true); |
|
| 276 | + } elseif ($globalDebug) { |
|
| 277 | + echo 'Nothing to import'; |
|
| 278 | + } |
|
| 251 | 279 | } |
| 252 | 280 | } |
| 253 | 281 | |
@@ -283,14 +311,23 @@ discard block |
||
| 283 | 311 | } |
| 284 | 312 | } |
| 285 | 313 | fclose($handle); |
| 286 | - } elseif ($globalDebug) echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5'; |
|
| 287 | - } elseif ($globalDebug) echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.'; |
|
| 314 | + } elseif ($globalDebug) { |
|
| 315 | + echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5'; |
|
| 316 | + } |
|
| 317 | + } elseif ($globalDebug) { |
|
| 318 | + echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.'; |
|
| 319 | + } |
|
| 288 | 320 | $result = $Common->arr_diff($all_md5_new,$all_md5); |
| 289 | - if (empty($result) && $globalDebug) echo 'Nothing to update'; |
|
| 321 | + if (empty($result) && $globalDebug) { |
|
| 322 | + echo 'Nothing to update'; |
|
| 323 | + } |
|
| 290 | 324 | foreach ($result as $file => $md5) { |
| 291 | 325 | $Common->download('http://data.flightairmap.fr/data/cr/'.$file,dirname(__FILE__).'/../install/tmp/'.$file); |
| 292 | - if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) $this->import(dirname(__FILE__).'/../install/tmp/'.$file); |
|
| 293 | - elseif ($globalDebug) echo 'Download '.$file.' failed'; |
|
| 326 | + if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) { |
|
| 327 | + $this->import(dirname(__FILE__).'/../install/tmp/'.$file); |
|
| 328 | + } elseif ($globalDebug) { |
|
| 329 | + echo 'Download '.$file.' failed'; |
|
| 330 | + } |
|
| 294 | 331 | } |
| 295 | 332 | } |
| 296 | 333 | |
@@ -307,13 +344,17 @@ discard block |
||
| 307 | 344 | $Image = new Image($this->db); |
| 308 | 345 | $Spotter = new Spotter($this->db); |
| 309 | 346 | |
| 310 | - if (empty($crash)) return false; |
|
| 347 | + if (empty($crash)) { |
|
| 348 | + return false; |
|
| 349 | + } |
|
| 311 | 350 | if (!$new) { |
| 312 | 351 | $query_delete = 'DELETE FROM accidents WHERE source = :source'; |
| 313 | 352 | $sthd = $Connection->db->prepare($query_delete); |
| 314 | 353 | $sthd->execute(array(':source' => $crash[0]['source'])); |
| 315 | 354 | } |
| 316 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 355 | + if ($globalTransaction) { |
|
| 356 | + $Connection->db->beginTransaction(); |
|
| 357 | + } |
|
| 317 | 358 | $initial_array = array('ident' => null,'type' => 'accident','url' => null,'registration' => null, 'date' => null, 'place' => null,'country' => null, 'latitude' => null, 'longitude' => null, 'fatalities' => null, 'title' => '','source' => '','aircraft_manufacturer' => null,'aircraft_name' => null,'operator' => null); |
| 318 | 359 | $query_check = 'SELECT COUNT(*) as nb FROM accidents WHERE registration = :registration AND date = :date AND type = :type AND source = :source'; |
| 319 | 360 | $sth_check = $Connection->db->prepare($query_check); |
@@ -328,7 +369,9 @@ discard block |
||
| 328 | 369 | return $value === "" ? NULL : $value; |
| 329 | 370 | }, $cr); |
| 330 | 371 | if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/',$cr['registration'])) { |
| 331 | - if (strpos($cr['registration'],'-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']); |
|
| 372 | + if (strpos($cr['registration'],'-') === FALSE) { |
|
| 373 | + $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']); |
|
| 374 | + } |
|
| 332 | 375 | $query_check_values = array(':registration' => $cr['registration'],':date' => date('Y-m-d',$cr['date']),':type' => $cr['type'],':source' => $cr['source']); |
| 333 | 376 | $sth_check->execute($query_check_values); |
| 334 | 377 | $result_check = $sth_check->fetchAll(PDO::FETCH_ASSOC); |
@@ -338,13 +381,19 @@ discard block |
||
| 338 | 381 | if ($globalAircraftImageFetch && $cr['date'] > time()-(30*86400)) { |
| 339 | 382 | $imgchk = $Image->getSpotterImage($cr['registration']); |
| 340 | 383 | if (empty($imgchk)) { |
| 341 | - if ($globalDebug) echo "\t".'Get image for '.$cr['registration'].'...'; |
|
| 384 | + if ($globalDebug) { |
|
| 385 | + echo "\t".'Get image for '.$cr['registration'].'...'; |
|
| 386 | + } |
|
| 342 | 387 | $Image->addSpotterImage($cr['registration']); |
| 343 | - if ($globalDebug) echo "\t".'Done'."\n"; |
|
| 388 | + if ($globalDebug) { |
|
| 389 | + echo "\t".'Done'."\n"; |
|
| 390 | + } |
|
| 344 | 391 | } |
| 345 | 392 | // elseif ($globalDebug) echo 'Image already in DB'."\n"; |
| 346 | 393 | } |
| 347 | - if ($cr['title'] == '') $cr['title'] = $cr['registration'].' '.$cr['type']; |
|
| 394 | + if ($cr['title'] == '') { |
|
| 395 | + $cr['title'] = $cr['registration'].' '.$cr['type']; |
|
| 396 | + } |
|
| 348 | 397 | $Spotter->setHighlightFlightByRegistration($cr['registration'],$cr['title'],date('Y-m-d',$cr['date'])); |
| 349 | 398 | } |
| 350 | 399 | } |
@@ -353,9 +402,13 @@ discard block |
||
| 353 | 402 | $Connection->db->beginTransaction(); |
| 354 | 403 | } |
| 355 | 404 | } |
| 356 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 405 | + if ($globalTransaction) { |
|
| 406 | + $Connection->db->commit(); |
|
| 407 | + } |
|
| 357 | 408 | } catch(PDOException $e) { |
| 358 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
| 409 | + if ($globalTransaction) { |
|
| 410 | + $Connection->db->rollBack(); |
|
| 411 | + } |
|
| 359 | 412 | echo $e->getMessage(); |
| 360 | 413 | } |
| 361 | 414 | $sth_check->closeCursor(); |
@@ -394,8 +447,11 @@ discard block |
||
| 394 | 447 | return "error : ".$e->getMessage(); |
| 395 | 448 | } |
| 396 | 449 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 397 | - if ($row['nb'] > 0) return false; |
|
| 398 | - else return true; |
|
| 450 | + if ($row['nb'] > 0) { |
|
| 451 | + return false; |
|
| 452 | + } else { |
|
| 453 | + return true; |
|
| 454 | + } |
|
| 399 | 455 | } |
| 400 | 456 | |
| 401 | 457 | public static function insert_last_accidents_update() { |
@@ -26,7 +26,9 @@ discard block |
||
| 26 | 26 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
| 27 | 27 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
| 28 | 28 | curl_setopt($ch, CURLOPT_TIMEOUT, 200); |
| 29 | - if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
| 29 | + if ($referer != '') { |
|
| 30 | + curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
| 31 | + } |
|
| 30 | 32 | 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'); |
| 31 | 33 | curl_setopt($ch, CURLOPT_FILE, $fp); |
| 32 | 34 | curl_exec($ch); |
@@ -37,12 +39,16 @@ discard block |
||
| 37 | 39 | public static function gunzip($in_file,$out_file_name = '') { |
| 38 | 40 | //echo $in_file.' -> '.$out_file_name."\n"; |
| 39 | 41 | $buffer_size = 4096; // read 4kb at a time |
| 40 | - if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); |
|
| 42 | + if ($out_file_name == '') { |
|
| 43 | + $out_file_name = str_replace('.gz', '', $in_file); |
|
| 44 | + } |
|
| 41 | 45 | if ($in_file != '' && file_exists($in_file)) { |
| 42 | 46 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
| 43 | - if (function_exists('gzopen')) $file = gzopen($in_file,'rb'); |
|
| 44 | - elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb'); |
|
| 45 | - else { |
|
| 47 | + if (function_exists('gzopen')) { |
|
| 48 | + $file = gzopen($in_file,'rb'); |
|
| 49 | + } elseif (function_exists('gzopen64')) { |
|
| 50 | + $file = gzopen64($in_file,'rb'); |
|
| 51 | + } else { |
|
| 46 | 52 | echo 'gzopen not available'; |
| 47 | 53 | die; |
| 48 | 54 | } |
@@ -63,8 +69,12 @@ discard block |
||
| 63 | 69 | if ($res === TRUE) { |
| 64 | 70 | $zip->extractTo($path); |
| 65 | 71 | $zip->close(); |
| 66 | - } else return false; |
|
| 67 | - } else return false; |
|
| 72 | + } else { |
|
| 73 | + return false; |
|
| 74 | + } |
|
| 75 | + } else { |
|
| 76 | + return false; |
|
| 77 | + } |
|
| 68 | 78 | } |
| 69 | 79 | |
| 70 | 80 | public static function connect_sqlite($database) { |
@@ -79,7 +89,9 @@ discard block |
||
| 79 | 89 | public static function retrieve_route_sqlite_to_dest($database_file) { |
| 80 | 90 | global $globalDebug, $globalTransaction; |
| 81 | 91 | //$query = 'TRUNCATE TABLE routes'; |
| 82 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
| 92 | + if ($globalDebug) { |
|
| 93 | + echo " - Delete previous routes from DB -"; |
|
| 94 | + } |
|
| 83 | 95 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
| 84 | 96 | $Connection = new Connection(); |
| 85 | 97 | try { |
@@ -90,7 +102,9 @@ discard block |
||
| 90 | 102 | return "error : ".$e->getMessage(); |
| 91 | 103 | } |
| 92 | 104 | |
| 93 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
| 105 | + if ($globalDebug) { |
|
| 106 | + echo " - Add routes to DB -"; |
|
| 107 | + } |
|
| 94 | 108 | update_db::connect_sqlite($database_file); |
| 95 | 109 | //$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'; |
| 96 | 110 | $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"; |
@@ -105,15 +119,21 @@ discard block |
||
| 105 | 119 | $Connection = new Connection(); |
| 106 | 120 | $sth_dest = $Connection->db->prepare($query_dest); |
| 107 | 121 | try { |
| 108 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 122 | + if ($globalTransaction) { |
|
| 123 | + $Connection->db->beginTransaction(); |
|
| 124 | + } |
|
| 109 | 125 | while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
| 110 | 126 | //$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); |
| 111 | 127 | $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); |
| 112 | 128 | $sth_dest->execute($query_dest_values); |
| 113 | 129 | } |
| 114 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 130 | + if ($globalTransaction) { |
|
| 131 | + $Connection->db->commit(); |
|
| 132 | + } |
|
| 115 | 133 | } catch(PDOException $e) { |
| 116 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
| 134 | + if ($globalTransaction) { |
|
| 135 | + $Connection->db->rollBack(); |
|
| 136 | + } |
|
| 117 | 137 | return "error : ".$e->getMessage(); |
| 118 | 138 | } |
| 119 | 139 | return ''; |
@@ -121,7 +141,9 @@ discard block |
||
| 121 | 141 | public static function retrieve_route_oneworld($database_file) { |
| 122 | 142 | global $globalDebug, $globalTransaction; |
| 123 | 143 | //$query = 'TRUNCATE TABLE routes'; |
| 124 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
| 144 | + if ($globalDebug) { |
|
| 145 | + echo " - Delete previous routes from DB -"; |
|
| 146 | + } |
|
| 125 | 147 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
| 126 | 148 | $Connection = new Connection(); |
| 127 | 149 | try { |
@@ -132,14 +154,18 @@ discard block |
||
| 132 | 154 | return "error : ".$e->getMessage(); |
| 133 | 155 | } |
| 134 | 156 | |
| 135 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
| 157 | + if ($globalDebug) { |
|
| 158 | + echo " - Add routes to DB -"; |
|
| 159 | + } |
|
| 136 | 160 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 137 | 161 | $Spotter = new Spotter(); |
| 138 | 162 | if ($fh = fopen($database_file,"r")) { |
| 139 | 163 | $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)'; |
| 140 | 164 | $Connection = new Connection(); |
| 141 | 165 | $sth_dest = $Connection->db->prepare($query_dest); |
| 142 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 166 | + if ($globalTransaction) { |
|
| 167 | + $Connection->db->beginTransaction(); |
|
| 168 | + } |
|
| 143 | 169 | while (!feof($fh)) { |
| 144 | 170 | $line = fgetcsv($fh,9999,','); |
| 145 | 171 | if ($line[0] != '') { |
@@ -148,13 +174,17 @@ discard block |
||
| 148 | 174 | $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'); |
| 149 | 175 | $sth_dest->execute($query_dest_values); |
| 150 | 176 | } catch(PDOException $e) { |
| 151 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
| 177 | + if ($globalTransaction) { |
|
| 178 | + $Connection->db->rollBack(); |
|
| 179 | + } |
|
| 152 | 180 | return "error : ".$e->getMessage(); |
| 153 | 181 | } |
| 154 | 182 | } |
| 155 | 183 | } |
| 156 | 184 | } |
| 157 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 185 | + if ($globalTransaction) { |
|
| 186 | + $Connection->db->commit(); |
|
| 187 | + } |
|
| 158 | 188 | } |
| 159 | 189 | return ''; |
| 160 | 190 | } |
@@ -162,7 +192,9 @@ discard block |
||
| 162 | 192 | public static function retrieve_route_skyteam($database_file) { |
| 163 | 193 | global $globalDebug, $globalTransaction; |
| 164 | 194 | //$query = 'TRUNCATE TABLE routes'; |
| 165 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
| 195 | + if ($globalDebug) { |
|
| 196 | + echo " - Delete previous routes from DB -"; |
|
| 197 | + } |
|
| 166 | 198 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
| 167 | 199 | $Connection = new Connection(); |
| 168 | 200 | try { |
@@ -173,7 +205,9 @@ discard block |
||
| 173 | 205 | return "error : ".$e->getMessage(); |
| 174 | 206 | } |
| 175 | 207 | |
| 176 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
| 208 | + if ($globalDebug) { |
|
| 209 | + echo " - Add routes to DB -"; |
|
| 210 | + } |
|
| 177 | 211 | |
| 178 | 212 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 179 | 213 | $Spotter = new Spotter(); |
@@ -182,7 +216,9 @@ discard block |
||
| 182 | 216 | $Connection = new Connection(); |
| 183 | 217 | $sth_dest = $Connection->db->prepare($query_dest); |
| 184 | 218 | try { |
| 185 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 219 | + if ($globalTransaction) { |
|
| 220 | + $Connection->db->beginTransaction(); |
|
| 221 | + } |
|
| 186 | 222 | while (!feof($fh)) { |
| 187 | 223 | $line = fgetcsv($fh,9999,','); |
| 188 | 224 | if ($line[0] != '') { |
@@ -193,9 +229,13 @@ discard block |
||
| 193 | 229 | } |
| 194 | 230 | } |
| 195 | 231 | } |
| 196 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 232 | + if ($globalTransaction) { |
|
| 233 | + $Connection->db->commit(); |
|
| 234 | + } |
|
| 197 | 235 | } catch(PDOException $e) { |
| 198 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
| 236 | + if ($globalTransaction) { |
|
| 237 | + $Connection->db->rollBack(); |
|
| 238 | + } |
|
| 199 | 239 | return "error : ".$e->getMessage(); |
| 200 | 240 | } |
| 201 | 241 | } |
@@ -238,11 +278,16 @@ discard block |
||
| 238 | 278 | $sth_dest = $Connection->db->prepare($query_dest); |
| 239 | 279 | $sth_dest_owner = $Connection->db->prepare($query_dest_owner); |
| 240 | 280 | try { |
| 241 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 281 | + if ($globalTransaction) { |
|
| 282 | + $Connection->db->beginTransaction(); |
|
| 283 | + } |
|
| 242 | 284 | while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
| 243 | 285 | //$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']); |
| 244 | - if ($values['UserString4'] == 'M') $type = 'military'; |
|
| 245 | - else $type = null; |
|
| 286 | + if ($values['UserString4'] == 'M') { |
|
| 287 | + $type = 'military'; |
|
| 288 | + } else { |
|
| 289 | + $type = null; |
|
| 290 | + } |
|
| 246 | 291 | $query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type); |
| 247 | 292 | $sth_dest->execute($query_dest_values); |
| 248 | 293 | if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') { |
@@ -250,7 +295,9 @@ discard block |
||
| 250 | 295 | $sth_dest_owner->execute($query_dest_owner_values); |
| 251 | 296 | } |
| 252 | 297 | } |
| 253 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 298 | + if ($globalTransaction) { |
|
| 299 | + $Connection->db->commit(); |
|
| 300 | + } |
|
| 254 | 301 | } catch(PDOException $e) { |
| 255 | 302 | return "error : ".$e->getMessage(); |
| 256 | 303 | } |
@@ -287,7 +334,9 @@ discard block |
||
| 287 | 334 | $Connection = new Connection(); |
| 288 | 335 | $sth_dest = $Connection->db->prepare($query_dest); |
| 289 | 336 | try { |
| 290 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 337 | + if ($globalTransaction) { |
|
| 338 | + $Connection->db->beginTransaction(); |
|
| 339 | + } |
|
| 291 | 340 | while (!feof($fh)) { |
| 292 | 341 | $values = array(); |
| 293 | 342 | $line = $Common->hex2str(fgets($fh,9999)); |
@@ -298,7 +347,9 @@ discard block |
||
| 298 | 347 | // Check if we can find ICAO, else set it to GLID |
| 299 | 348 | $aircraft_name_split = explode(' ',$aircraft_name); |
| 300 | 349 | $search_more = ''; |
| 301 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 350 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) { |
|
| 351 | + $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 352 | + } |
|
| 302 | 353 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
| 303 | 354 | $sth_search = $Connection->db->prepare($query_search); |
| 304 | 355 | try { |
@@ -311,7 +362,9 @@ discard block |
||
| 311 | 362 | } catch(PDOException $e) { |
| 312 | 363 | return "error : ".$e->getMessage(); |
| 313 | 364 | } |
| 314 | - if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID'; |
|
| 365 | + if (!isset($values['ICAOTypeCode'])) { |
|
| 366 | + $values['ICAOTypeCode'] = 'GLID'; |
|
| 367 | + } |
|
| 315 | 368 | // Add data to db |
| 316 | 369 | if ($values['Registration'] != '' && $values['Registration'] != '0000') { |
| 317 | 370 | //$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']); |
@@ -320,7 +373,9 @@ discard block |
||
| 320 | 373 | $sth_dest->execute($query_dest_values); |
| 321 | 374 | } |
| 322 | 375 | } |
| 323 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 376 | + if ($globalTransaction) { |
|
| 377 | + $Connection->db->commit(); |
|
| 378 | + } |
|
| 324 | 379 | } catch(PDOException $e) { |
| 325 | 380 | return "error : ".$e->getMessage(); |
| 326 | 381 | } |
@@ -356,7 +411,9 @@ discard block |
||
| 356 | 411 | $Connection = new Connection(); |
| 357 | 412 | $sth_dest = $Connection->db->prepare($query_dest); |
| 358 | 413 | try { |
| 359 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 414 | + if ($globalTransaction) { |
|
| 415 | + $Connection->db->beginTransaction(); |
|
| 416 | + } |
|
| 360 | 417 | $tmp = fgetcsv($fh,9999,',',"'"); |
| 361 | 418 | while (!feof($fh)) { |
| 362 | 419 | $line = fgetcsv($fh,9999,',',"'"); |
@@ -370,13 +427,17 @@ discard block |
||
| 370 | 427 | // Check if we can find ICAO, else set it to GLID |
| 371 | 428 | $aircraft_name_split = explode(' ',$aircraft_name); |
| 372 | 429 | $search_more = ''; |
| 373 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 430 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) { |
|
| 431 | + $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 432 | + } |
|
| 374 | 433 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
| 375 | 434 | $sth_search = $Connection->db->prepare($query_search); |
| 376 | 435 | try { |
| 377 | 436 | $sth_search->execute(); |
| 378 | 437 | $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
| 379 | - if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
|
| 438 | + if (isset($result['icao']) && $result['icao'] != '') { |
|
| 439 | + $values['ICAOTypeCode'] = $result['icao']; |
|
| 440 | + } |
|
| 380 | 441 | } catch(PDOException $e) { |
| 381 | 442 | return "error : ".$e->getMessage(); |
| 382 | 443 | } |
@@ -389,7 +450,9 @@ discard block |
||
| 389 | 450 | $sth_dest->execute($query_dest_values); |
| 390 | 451 | } |
| 391 | 452 | } |
| 392 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 453 | + if ($globalTransaction) { |
|
| 454 | + $Connection->db->commit(); |
|
| 455 | + } |
|
| 393 | 456 | } catch(PDOException $e) { |
| 394 | 457 | return "error : ".$e->getMessage(); |
| 395 | 458 | } |
@@ -428,7 +491,9 @@ discard block |
||
| 428 | 491 | $sth_dest = $Connection->db->prepare($query_dest); |
| 429 | 492 | $sth_modes = $Connection->db->prepare($query_modes); |
| 430 | 493 | try { |
| 431 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 494 | + if ($globalTransaction) { |
|
| 495 | + $Connection->db->beginTransaction(); |
|
| 496 | + } |
|
| 432 | 497 | $tmp = fgetcsv($fh,9999,',','"'); |
| 433 | 498 | while (!feof($fh)) { |
| 434 | 499 | $line = fgetcsv($fh,9999,',','"'); |
@@ -438,16 +503,22 @@ discard block |
||
| 438 | 503 | $values['registration'] = $line[0]; |
| 439 | 504 | $values['base'] = $line[4]; |
| 440 | 505 | $values['owner'] = $line[5]; |
| 441 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
| 442 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 506 | + if ($line[6] == '') { |
|
| 507 | + $values['date_first_reg'] = null; |
|
| 508 | + } else { |
|
| 509 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 510 | + } |
|
| 443 | 511 | $values['cancel'] = $line[7]; |
| 444 | 512 | } elseif ($country == 'EI') { |
| 445 | 513 | // TODO : add modeS & reg to aircraft_modes |
| 446 | 514 | $values['registration'] = $line[0]; |
| 447 | 515 | $values['base'] = $line[3]; |
| 448 | 516 | $values['owner'] = $line[2]; |
| 449 | - if ($line[1] == '') $values['date_first_reg'] = null; |
|
| 450 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
| 517 | + if ($line[1] == '') { |
|
| 518 | + $values['date_first_reg'] = null; |
|
| 519 | + } else { |
|
| 520 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
| 521 | + } |
|
| 451 | 522 | $values['cancel'] = ''; |
| 452 | 523 | $values['modes'] = $line[7]; |
| 453 | 524 | $values['icao'] = $line[8]; |
@@ -466,16 +537,22 @@ discard block |
||
| 466 | 537 | $values['registration'] = $line[3]; |
| 467 | 538 | $values['base'] = null; |
| 468 | 539 | $values['owner'] = $line[5]; |
| 469 | - if ($line[18] == '') $values['date_first_reg'] = null; |
|
| 470 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
| 540 | + if ($line[18] == '') { |
|
| 541 | + $values['date_first_reg'] = null; |
|
| 542 | + } else { |
|
| 543 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
| 544 | + } |
|
| 471 | 545 | $values['cancel'] = ''; |
| 472 | 546 | } elseif ($country == 'VH') { |
| 473 | 547 | // TODO : add modeS & reg to aircraft_modes |
| 474 | 548 | $values['registration'] = $line[0]; |
| 475 | 549 | $values['base'] = null; |
| 476 | 550 | $values['owner'] = $line[12]; |
| 477 | - if ($line[28] == '') $values['date_first_reg'] = null; |
|
| 478 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
| 551 | + if ($line[28] == '') { |
|
| 552 | + $values['date_first_reg'] = null; |
|
| 553 | + } else { |
|
| 554 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
| 555 | + } |
|
| 479 | 556 | |
| 480 | 557 | $values['cancel'] = $line[39]; |
| 481 | 558 | } elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { |
@@ -494,29 +571,41 @@ discard block |
||
| 494 | 571 | $values['registration'] = $line[0]; |
| 495 | 572 | $values['base'] = null; |
| 496 | 573 | $values['owner'] = $line[8]; |
| 497 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
| 498 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 574 | + if ($line[7] == '') { |
|
| 575 | + $values['date_first_reg'] = null; |
|
| 576 | + } else { |
|
| 577 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 578 | + } |
|
| 499 | 579 | $values['cancel'] = ''; |
| 500 | 580 | } elseif ($country == 'PP') { |
| 501 | 581 | $values['registration'] = $line[0]; |
| 502 | 582 | $values['base'] = null; |
| 503 | 583 | $values['owner'] = $line[4]; |
| 504 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
| 505 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 584 | + if ($line[6] == '') { |
|
| 585 | + $values['date_first_reg'] = null; |
|
| 586 | + } else { |
|
| 587 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 588 | + } |
|
| 506 | 589 | $values['cancel'] = $line[7]; |
| 507 | 590 | } elseif ($country == 'E7') { |
| 508 | 591 | $values['registration'] = $line[0]; |
| 509 | 592 | $values['base'] = null; |
| 510 | 593 | $values['owner'] = $line[4]; |
| 511 | - if ($line[5] == '') $values['date_first_reg'] = null; |
|
| 512 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
| 594 | + if ($line[5] == '') { |
|
| 595 | + $values['date_first_reg'] = null; |
|
| 596 | + } else { |
|
| 597 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
| 598 | + } |
|
| 513 | 599 | $values['cancel'] = ''; |
| 514 | 600 | } elseif ($country == '8Q') { |
| 515 | 601 | $values['registration'] = $line[0]; |
| 516 | 602 | $values['base'] = null; |
| 517 | 603 | $values['owner'] = $line[3]; |
| 518 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
| 519 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 604 | + if ($line[7] == '') { |
|
| 605 | + $values['date_first_reg'] = null; |
|
| 606 | + } else { |
|
| 607 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 608 | + } |
|
| 520 | 609 | $values['cancel'] = ''; |
| 521 | 610 | } elseif ($country == 'ZK') { |
| 522 | 611 | $values['registration'] = $line[0]; |
@@ -561,7 +650,9 @@ discard block |
||
| 561 | 650 | $sth_modes->execute($query_modes_values); |
| 562 | 651 | } |
| 563 | 652 | } |
| 564 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 653 | + if ($globalTransaction) { |
|
| 654 | + $Connection->db->commit(); |
|
| 655 | + } |
|
| 565 | 656 | } catch(PDOException $e) { |
| 566 | 657 | return "error : ".$e->getMessage(); |
| 567 | 658 | } |
@@ -697,25 +788,45 @@ discard block |
||
| 697 | 788 | VALUES (:name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)"; |
| 698 | 789 | $Connection = new Connection(); |
| 699 | 790 | $sth_dest = $Connection->db->prepare($query_dest); |
| 700 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 791 | + if ($globalTransaction) { |
|
| 792 | + $Connection->db->beginTransaction(); |
|
| 793 | + } |
|
| 701 | 794 | |
| 702 | 795 | $i = 0; |
| 703 | 796 | while($row = sparql_fetch_array($result)) |
| 704 | 797 | { |
| 705 | 798 | if ($i >= 1) { |
| 706 | 799 | //print_r($row); |
| 707 | - if (!isset($row['iata'])) $row['iata'] = ''; |
|
| 708 | - if (!isset($row['icao'])) $row['icao'] = ''; |
|
| 709 | - if (!isset($row['type'])) $row['type'] = ''; |
|
| 710 | - if (!isset($row['altitude'])) $row['altitude'] = ''; |
|
| 800 | + if (!isset($row['iata'])) { |
|
| 801 | + $row['iata'] = ''; |
|
| 802 | + } |
|
| 803 | + if (!isset($row['icao'])) { |
|
| 804 | + $row['icao'] = ''; |
|
| 805 | + } |
|
| 806 | + if (!isset($row['type'])) { |
|
| 807 | + $row['type'] = ''; |
|
| 808 | + } |
|
| 809 | + if (!isset($row['altitude'])) { |
|
| 810 | + $row['altitude'] = ''; |
|
| 811 | + } |
|
| 711 | 812 | if (isset($row['city_bis'])) { |
| 712 | 813 | $row['city'] = $row['city_bis']; |
| 713 | 814 | } |
| 714 | - if (!isset($row['city'])) $row['city'] = ''; |
|
| 715 | - if (!isset($row['country'])) $row['country'] = ''; |
|
| 716 | - if (!isset($row['homepage'])) $row['homepage'] = ''; |
|
| 717 | - if (!isset($row['wikipedia_page'])) $row['wikipedia_page'] = ''; |
|
| 718 | - if (!isset($row['name'])) continue; |
|
| 815 | + if (!isset($row['city'])) { |
|
| 816 | + $row['city'] = ''; |
|
| 817 | + } |
|
| 818 | + if (!isset($row['country'])) { |
|
| 819 | + $row['country'] = ''; |
|
| 820 | + } |
|
| 821 | + if (!isset($row['homepage'])) { |
|
| 822 | + $row['homepage'] = ''; |
|
| 823 | + } |
|
| 824 | + if (!isset($row['wikipedia_page'])) { |
|
| 825 | + $row['wikipedia_page'] = ''; |
|
| 826 | + } |
|
| 827 | + if (!isset($row['name'])) { |
|
| 828 | + continue; |
|
| 829 | + } |
|
| 719 | 830 | if (!isset($row['image'])) { |
| 720 | 831 | $row['image'] = ''; |
| 721 | 832 | $row['image_thumb'] = ''; |
@@ -771,7 +882,9 @@ discard block |
||
| 771 | 882 | |
| 772 | 883 | $i++; |
| 773 | 884 | } |
| 774 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 885 | + if ($globalTransaction) { |
|
| 886 | + $Connection->db->commit(); |
|
| 887 | + } |
|
| 775 | 888 | /* |
| 776 | 889 | echo "Delete duplicate rows...\n"; |
| 777 | 890 | $query = 'ALTER IGNORE TABLE airport ADD UNIQUE INDEX icaoidx (icao)'; |
@@ -814,7 +927,9 @@ discard block |
||
| 814 | 927 | $delimiter = ','; |
| 815 | 928 | $out_file = $tmp_dir.'airports.csv'; |
| 816 | 929 | update_db::download('http://ourairports.com/data/airports.csv',$out_file); |
| 817 | - if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
|
| 930 | + if (!file_exists($out_file) || !is_readable($out_file)) { |
|
| 931 | + return FALSE; |
|
| 932 | + } |
|
| 818 | 933 | echo "Add data from ourairports.com...\n"; |
| 819 | 934 | |
| 820 | 935 | $header = NULL; |
@@ -824,8 +939,9 @@ discard block |
||
| 824 | 939 | //$Connection->db->beginTransaction(); |
| 825 | 940 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 826 | 941 | { |
| 827 | - if(!$header) $header = $row; |
|
| 828 | - else { |
|
| 942 | + if(!$header) { |
|
| 943 | + $header = $row; |
|
| 944 | + } else { |
|
| 829 | 945 | $data = array(); |
| 830 | 946 | $data = array_combine($header, $row); |
| 831 | 947 | try { |
@@ -866,7 +982,9 @@ discard block |
||
| 866 | 982 | echo "Download data from another free database...\n"; |
| 867 | 983 | $out_file = $tmp_dir.'GlobalAirportDatabase.zip'; |
| 868 | 984 | update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file); |
| 869 | - if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
|
| 985 | + if (!file_exists($out_file) || !is_readable($out_file)) { |
|
| 986 | + return FALSE; |
|
| 987 | + } |
|
| 870 | 988 | update_db::unzip($out_file); |
| 871 | 989 | $header = NULL; |
| 872 | 990 | echo "Add data from another free database...\n"; |
@@ -877,8 +995,9 @@ discard block |
||
| 877 | 995 | //$Connection->db->beginTransaction(); |
| 878 | 996 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 879 | 997 | { |
| 880 | - if(!$header) $header = $row; |
|
| 881 | - else { |
|
| 998 | + if(!$header) { |
|
| 999 | + $header = $row; |
|
| 1000 | + } else { |
|
| 882 | 1001 | $data = $row; |
| 883 | 1002 | |
| 884 | 1003 | $query = 'UPDATE airport SET city = :city, country = :country WHERE icao = :icao'; |
@@ -1047,7 +1166,9 @@ discard block |
||
| 1047 | 1166 | if (($handle = fopen($tmp_dir.'MASTER.txt', 'r')) !== FALSE) |
| 1048 | 1167 | { |
| 1049 | 1168 | $i = 0; |
| 1050 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1169 | + if ($globalTransaction) { |
|
| 1170 | + $Connection->db->beginTransaction(); |
|
| 1171 | + } |
|
| 1051 | 1172 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1052 | 1173 | { |
| 1053 | 1174 | if ($i > 0) { |
@@ -1060,7 +1181,9 @@ discard block |
||
| 1060 | 1181 | } |
| 1061 | 1182 | $result_search = $sths->fetchAll(PDO::FETCH_ASSOC); |
| 1062 | 1183 | if (!empty($result_search)) { |
| 1063 | - if ($globalDebug) echo '.'; |
|
| 1184 | + if ($globalDebug) { |
|
| 1185 | + echo '.'; |
|
| 1186 | + } |
|
| 1064 | 1187 | //if ($globalDBdriver == 'mysql') { |
| 1065 | 1188 | // $queryi = 'INSERT INTO faamfr (mfr,icao) VALUES (:mfr,:icao) ON DUPLICATE KEY UPDATE icao = :icao'; |
| 1066 | 1189 | //} else { |
@@ -1082,8 +1205,12 @@ discard block |
||
| 1082 | 1205 | } |
| 1083 | 1206 | $result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC); |
| 1084 | 1207 | if (!empty($result_search_mfr)) { |
| 1085 | - if (trim($data[16]) == '' && trim($data[23]) != '') $data[16] = $data[23]; |
|
| 1086 | - if (trim($data[16]) == '' && trim($data[15]) != '') $data[16] = $data[15]; |
|
| 1208 | + if (trim($data[16]) == '' && trim($data[23]) != '') { |
|
| 1209 | + $data[16] = $data[23]; |
|
| 1210 | + } |
|
| 1211 | + if (trim($data[16]) == '' && trim($data[15]) != '') { |
|
| 1212 | + $data[16] = $data[15]; |
|
| 1213 | + } |
|
| 1087 | 1214 | $queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)'; |
| 1088 | 1215 | try { |
| 1089 | 1216 | $sthf = $Connection->db->prepare($queryf); |
@@ -1094,7 +1221,9 @@ discard block |
||
| 1094 | 1221 | } |
| 1095 | 1222 | } |
| 1096 | 1223 | if (strtotime($data[29]) > time()) { |
| 1097 | - if ($globalDebug) echo 'i'; |
|
| 1224 | + if ($globalDebug) { |
|
| 1225 | + echo 'i'; |
|
| 1226 | + } |
|
| 1098 | 1227 | $query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)'; |
| 1099 | 1228 | try { |
| 1100 | 1229 | $sth = $Connection->db->prepare($query); |
@@ -1105,13 +1234,19 @@ discard block |
||
| 1105 | 1234 | } |
| 1106 | 1235 | } |
| 1107 | 1236 | if ($i % 90 == 0) { |
| 1108 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1109 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1237 | + if ($globalTransaction) { |
|
| 1238 | + $Connection->db->commit(); |
|
| 1239 | + } |
|
| 1240 | + if ($globalTransaction) { |
|
| 1241 | + $Connection->db->beginTransaction(); |
|
| 1242 | + } |
|
| 1110 | 1243 | } |
| 1111 | 1244 | $i++; |
| 1112 | 1245 | } |
| 1113 | 1246 | fclose($handle); |
| 1114 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1247 | + if ($globalTransaction) { |
|
| 1248 | + $Connection->db->commit(); |
|
| 1249 | + } |
|
| 1115 | 1250 | } |
| 1116 | 1251 | return ''; |
| 1117 | 1252 | } |
@@ -1131,11 +1266,15 @@ discard block |
||
| 1131 | 1266 | if (($handle = fopen($tmp_dir.'modes.tsv', 'r')) !== FALSE) |
| 1132 | 1267 | { |
| 1133 | 1268 | $i = 0; |
| 1134 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1269 | + if ($globalTransaction) { |
|
| 1270 | + $Connection->db->beginTransaction(); |
|
| 1271 | + } |
|
| 1135 | 1272 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1136 | 1273 | { |
| 1137 | 1274 | if ($i > 0) { |
| 1138 | - if ($data[1] == 'NULL') $data[1] = $data[0]; |
|
| 1275 | + if ($data[1] == 'NULL') { |
|
| 1276 | + $data[1] = $data[0]; |
|
| 1277 | + } |
|
| 1139 | 1278 | $query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)'; |
| 1140 | 1279 | try { |
| 1141 | 1280 | $sth = $Connection->db->prepare($query); |
@@ -1147,7 +1286,9 @@ discard block |
||
| 1147 | 1286 | $i++; |
| 1148 | 1287 | } |
| 1149 | 1288 | fclose($handle); |
| 1150 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1289 | + if ($globalTransaction) { |
|
| 1290 | + $Connection->db->commit(); |
|
| 1291 | + } |
|
| 1151 | 1292 | } |
| 1152 | 1293 | return ''; |
| 1153 | 1294 | } |
@@ -1179,11 +1320,15 @@ discard block |
||
| 1179 | 1320 | if (($handle = fopen($tmp_dir.'airlines.tsv', 'r')) !== FALSE) |
| 1180 | 1321 | { |
| 1181 | 1322 | $i = 0; |
| 1182 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1323 | + if ($globalTransaction) { |
|
| 1324 | + $Connection->db->beginTransaction(); |
|
| 1325 | + } |
|
| 1183 | 1326 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1184 | 1327 | { |
| 1185 | 1328 | if ($i > 0) { |
| 1186 | - if ($data[1] == 'NULL') $data[1] = $data[0]; |
|
| 1329 | + if ($data[1] == 'NULL') { |
|
| 1330 | + $data[1] = $data[0]; |
|
| 1331 | + } |
|
| 1187 | 1332 | $query = 'INSERT INTO airlines (airline_id,name,alias,iata,icao,callsign,country,active,type,home_link,wikipedia_link,alliance,ban_eu) VALUES (0,:name,:alias,:iata,:icao,:callsign,:country,:active,:type,:home,:wikipedia_link,:alliance,:ban_eu)'; |
| 1188 | 1333 | try { |
| 1189 | 1334 | $sth = $Connection->db->prepare($query); |
@@ -1195,7 +1340,9 @@ discard block |
||
| 1195 | 1340 | $i++; |
| 1196 | 1341 | } |
| 1197 | 1342 | fclose($handle); |
| 1198 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1343 | + if ($globalTransaction) { |
|
| 1344 | + $Connection->db->commit(); |
|
| 1345 | + } |
|
| 1199 | 1346 | } |
| 1200 | 1347 | /* |
| 1201 | 1348 | $query = "UNLOCK TABLES"; |
@@ -1225,7 +1372,9 @@ discard block |
||
| 1225 | 1372 | if (($handle = fopen($tmp_dir.'owners.tsv', 'r')) !== FALSE) |
| 1226 | 1373 | { |
| 1227 | 1374 | $i = 0; |
| 1228 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1375 | + if ($globalTransaction) { |
|
| 1376 | + $Connection->db->beginTransaction(); |
|
| 1377 | + } |
|
| 1229 | 1378 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1230 | 1379 | { |
| 1231 | 1380 | if ($i > 0) { |
@@ -1241,7 +1390,9 @@ discard block |
||
| 1241 | 1390 | $i++; |
| 1242 | 1391 | } |
| 1243 | 1392 | fclose($handle); |
| 1244 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1393 | + if ($globalTransaction) { |
|
| 1394 | + $Connection->db->commit(); |
|
| 1395 | + } |
|
| 1245 | 1396 | } |
| 1246 | 1397 | return ''; |
| 1247 | 1398 | } |
@@ -1261,7 +1412,9 @@ discard block |
||
| 1261 | 1412 | if (($handle = fopen($tmp_dir.'routes.tsv', 'r')) !== FALSE) |
| 1262 | 1413 | { |
| 1263 | 1414 | $i = 0; |
| 1264 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1415 | + if ($globalTransaction) { |
|
| 1416 | + $Connection->db->beginTransaction(); |
|
| 1417 | + } |
|
| 1265 | 1418 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1266 | 1419 | { |
| 1267 | 1420 | if ($i > 0) { |
@@ -1271,19 +1424,25 @@ discard block |
||
| 1271 | 1424 | $sth = $Connection->db->prepare($query); |
| 1272 | 1425 | $sth->execute(array(':CallSign' => $data[0],':Operator_ICAO' => $data[1],':FromAirport_ICAO' => $data[2],':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4],':ToAirport_Time' => $data[5],':RouteStop' => $data[6],':source' => 'website_fam')); |
| 1273 | 1426 | } catch(PDOException $e) { |
| 1274 | - if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".implode(',',$data); |
|
| 1427 | + if ($globalDebug) { |
|
| 1428 | + echo "error: ".$e->getMessage()." - data: ".implode(',',$data); |
|
| 1429 | + } |
|
| 1275 | 1430 | die(); |
| 1276 | 1431 | } |
| 1277 | 1432 | } |
| 1278 | 1433 | if ($globalTransaction && $i % 2000 == 0) { |
| 1279 | 1434 | $Connection->db->commit(); |
| 1280 | - if ($globalDebug) echo '.'; |
|
| 1435 | + if ($globalDebug) { |
|
| 1436 | + echo '.'; |
|
| 1437 | + } |
|
| 1281 | 1438 | $Connection->db->beginTransaction(); |
| 1282 | 1439 | } |
| 1283 | 1440 | $i++; |
| 1284 | 1441 | } |
| 1285 | 1442 | fclose($handle); |
| 1286 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1443 | + if ($globalTransaction) { |
|
| 1444 | + $Connection->db->commit(); |
|
| 1445 | + } |
|
| 1287 | 1446 | } |
| 1288 | 1447 | return ''; |
| 1289 | 1448 | } |
@@ -1308,7 +1467,9 @@ discard block |
||
| 1308 | 1467 | $i = 0; |
| 1309 | 1468 | //$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE); |
| 1310 | 1469 | //$Connection->db->beginTransaction(); |
| 1311 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1470 | + if ($globalTransaction) { |
|
| 1471 | + $Connection->db->beginTransaction(); |
|
| 1472 | + } |
|
| 1312 | 1473 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1313 | 1474 | { |
| 1314 | 1475 | if ($i > 0) { |
@@ -1324,7 +1485,9 @@ discard block |
||
| 1324 | 1485 | $i++; |
| 1325 | 1486 | } |
| 1326 | 1487 | fclose($handle); |
| 1327 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1488 | + if ($globalTransaction) { |
|
| 1489 | + $Connection->db->commit(); |
|
| 1490 | + } |
|
| 1328 | 1491 | } |
| 1329 | 1492 | return ''; |
| 1330 | 1493 | } |
@@ -1344,7 +1507,9 @@ discard block |
||
| 1344 | 1507 | if (($handle = fopen($tmp_dir.'satellite.tsv', 'r')) !== FALSE) |
| 1345 | 1508 | { |
| 1346 | 1509 | $i = 0; |
| 1347 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1510 | + if ($globalTransaction) { |
|
| 1511 | + $Connection->db->beginTransaction(); |
|
| 1512 | + } |
|
| 1348 | 1513 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1349 | 1514 | { |
| 1350 | 1515 | if ($i > 0) { |
@@ -1361,7 +1526,9 @@ discard block |
||
| 1361 | 1526 | $i++; |
| 1362 | 1527 | } |
| 1363 | 1528 | fclose($handle); |
| 1364 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1529 | + if ($globalTransaction) { |
|
| 1530 | + $Connection->db->commit(); |
|
| 1531 | + } |
|
| 1365 | 1532 | } |
| 1366 | 1533 | return ''; |
| 1367 | 1534 | } |
@@ -1380,7 +1547,9 @@ discard block |
||
| 1380 | 1547 | $Connection = new Connection(); |
| 1381 | 1548 | if (($handle = fopen($tmp_dir.'ban_eu.csv', 'r')) !== FALSE) |
| 1382 | 1549 | { |
| 1383 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1550 | + if ($globalTransaction) { |
|
| 1551 | + $Connection->db->beginTransaction(); |
|
| 1552 | + } |
|
| 1384 | 1553 | while (($data = fgetcsv($handle, 1000)) !== FALSE) |
| 1385 | 1554 | { |
| 1386 | 1555 | $query = 'UPDATE airlines SET ban_eu = 1 WHERE icao = :icao AND forsource IS NULL'; |
@@ -1395,7 +1564,9 @@ discard block |
||
| 1395 | 1564 | } |
| 1396 | 1565 | } |
| 1397 | 1566 | fclose($handle); |
| 1398 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1567 | + if ($globalTransaction) { |
|
| 1568 | + $Connection->db->commit(); |
|
| 1569 | + } |
|
| 1399 | 1570 | } |
| 1400 | 1571 | return ''; |
| 1401 | 1572 | } |
@@ -1471,9 +1642,14 @@ discard block |
||
| 1471 | 1642 | if ($i > 0 && $data[0] != '') { |
| 1472 | 1643 | $sources = trim($data[28].' '.$data[29].' '.$data[30].' '.$data[31].' '.$data[32].' '.$data[33]); |
| 1473 | 1644 | $period = str_replace(',','',$data[14]); |
| 1474 | - if (!empty($period) && strpos($period,'days')) $period = str_replace(' days','',$period)*24*60; |
|
| 1475 | - if ($data[18] != '') $launch_date = date('Y-m-d',strtotime($data[18])); |
|
| 1476 | - else $launch_date = NULL; |
|
| 1645 | + if (!empty($period) && strpos($period,'days')) { |
|
| 1646 | + $period = str_replace(' days','',$period)*24*60; |
|
| 1647 | + } |
|
| 1648 | + if ($data[18] != '') { |
|
| 1649 | + $launch_date = date('Y-m-d',strtotime($data[18])); |
|
| 1650 | + } else { |
|
| 1651 | + $launch_date = NULL; |
|
| 1652 | + } |
|
| 1477 | 1653 | $data = array_map(function($value) { |
| 1478 | 1654 | return trim($value) === '' ? null : $value; |
| 1479 | 1655 | }, $data); |
@@ -1836,7 +2012,9 @@ discard block |
||
| 1836 | 2012 | if (($handle = fopen($filename, 'r')) !== FALSE) |
| 1837 | 2013 | { |
| 1838 | 2014 | $i = 0; |
| 1839 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 2015 | + if ($globalTransaction) { |
|
| 2016 | + $Connection->db->beginTransaction(); |
|
| 2017 | + } |
|
| 1840 | 2018 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1841 | 2019 | { |
| 1842 | 2020 | $i++; |
@@ -1864,7 +2042,9 @@ discard block |
||
| 1864 | 2042 | } |
| 1865 | 2043 | } |
| 1866 | 2044 | fclose($handle); |
| 1867 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 2045 | + if ($globalTransaction) { |
|
| 2046 | + $Connection->db->commit(); |
|
| 2047 | + } |
|
| 1868 | 2048 | } |
| 1869 | 2049 | return ''; |
| 1870 | 2050 | } |
@@ -1907,7 +2087,9 @@ discard block |
||
| 1907 | 2087 | $Connection = new Connection(); |
| 1908 | 2088 | if (($handle = fopen($filename, 'r')) !== FALSE) |
| 1909 | 2089 | { |
| 1910 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 2090 | + if ($globalTransaction) { |
|
| 2091 | + $Connection->db->beginTransaction(); |
|
| 2092 | + } |
|
| 1911 | 2093 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1912 | 2094 | { |
| 1913 | 2095 | if(count($row) > 1) { |
@@ -1921,7 +2103,9 @@ discard block |
||
| 1921 | 2103 | } |
| 1922 | 2104 | } |
| 1923 | 2105 | fclose($handle); |
| 1924 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 2106 | + if ($globalTransaction) { |
|
| 2107 | + $Connection->db->commit(); |
|
| 2108 | + } |
|
| 1925 | 2109 | } |
| 1926 | 2110 | return ''; |
| 1927 | 2111 | } |
@@ -1941,8 +2125,9 @@ discard block |
||
| 1941 | 2125 | } |
| 1942 | 2126 | |
| 1943 | 2127 | |
| 1944 | - if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
| 1945 | - else { |
|
| 2128 | + if ($globalDBdriver == 'mysql') { |
|
| 2129 | + update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
| 2130 | + } else { |
|
| 1946 | 2131 | update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
| 1947 | 2132 | $query = "CREATE EXTENSION postgis"; |
| 1948 | 2133 | $Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']); |
@@ -1961,7 +2146,9 @@ discard block |
||
| 1961 | 2146 | global $tmp_dir, $globalDebug; |
| 1962 | 2147 | include_once('class.create_db.php'); |
| 1963 | 2148 | require_once(dirname(__FILE__).'/../require/class.NOTAM.php'); |
| 1964 | - if ($globalDebug) echo "NOTAM from FlightAirMap website : Download..."; |
|
| 2149 | + if ($globalDebug) { |
|
| 2150 | + echo "NOTAM from FlightAirMap website : Download..."; |
|
| 2151 | + } |
|
| 1965 | 2152 | update_db::download('http://data.flightairmap.com/data/notam.txt.gz.md5',$tmp_dir.'notam.txt.gz.md5'); |
| 1966 | 2153 | $error = ''; |
| 1967 | 2154 | if (file_exists($tmp_dir.'notam.txt.gz.md5')) { |
@@ -1971,20 +2158,34 @@ discard block |
||
| 1971 | 2158 | update_db::download('http://data.flightairmap.com/data/notam.txt.gz',$tmp_dir.'notam.txt.gz'); |
| 1972 | 2159 | if (file_exists($tmp_dir.'notam.txt.gz')) { |
| 1973 | 2160 | if (md5_file($tmp_dir.'notam.txt.gz') == $notam_md5) { |
| 1974 | - if ($globalDebug) echo "Gunzip..."; |
|
| 2161 | + if ($globalDebug) { |
|
| 2162 | + echo "Gunzip..."; |
|
| 2163 | + } |
|
| 1975 | 2164 | update_db::gunzip($tmp_dir.'notam.txt.gz'); |
| 1976 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2165 | + if ($globalDebug) { |
|
| 2166 | + echo "Add to DB..."; |
|
| 2167 | + } |
|
| 1977 | 2168 | //$error = create_db::import_file($tmp_dir.'notam.sql'); |
| 1978 | 2169 | $NOTAM = new NOTAM(); |
| 1979 | 2170 | $NOTAM->updateNOTAMfromTextFile($tmp_dir.'notam.txt'); |
| 1980 | 2171 | update_db::insert_notam_version($notam_md5); |
| 1981 | - } else $error = "File ".$tmp_dir.'notam.txt.gz'." md5 failed. Download failed."; |
|
| 1982 | - } else $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed."; |
|
| 1983 | - } elseif ($globalDebug) echo "No new version."; |
|
| 1984 | - } else $error = "File ".$tmp_dir.'notam.txt.gz.md5'." doesn't exist. Download failed."; |
|
| 2172 | + } else { |
|
| 2173 | + $error = "File ".$tmp_dir.'notam.txt.gz'." md5 failed. Download failed."; |
|
| 2174 | + } |
|
| 2175 | + } else { |
|
| 2176 | + $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed."; |
|
| 2177 | + } |
|
| 2178 | + } elseif ($globalDebug) { |
|
| 2179 | + echo "No new version."; |
|
| 2180 | + } |
|
| 2181 | + } else { |
|
| 2182 | + $error = "File ".$tmp_dir.'notam.txt.gz.md5'." doesn't exist. Download failed."; |
|
| 2183 | + } |
|
| 1985 | 2184 | if ($error != '') { |
| 1986 | 2185 | return $error; |
| 1987 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2186 | + } elseif ($globalDebug) { |
|
| 2187 | + echo "Done\n"; |
|
| 2188 | + } |
|
| 1988 | 2189 | return ''; |
| 1989 | 2190 | } |
| 1990 | 2191 | |
@@ -2039,68 +2240,114 @@ discard block |
||
| 2039 | 2240 | //update_db::download('http://fr.mirror.ivao.aero/software/ivae_feb2013.zip',$tmp_dir.'ivae_feb2013.zip'); |
| 2040 | 2241 | if (extension_loaded('zip')) { |
| 2041 | 2242 | if (file_exists($tmp_dir.'ivae_feb2013.zip')) { |
| 2042 | - if ($globalDebug) echo "Unzip..."; |
|
| 2243 | + if ($globalDebug) { |
|
| 2244 | + echo "Unzip..."; |
|
| 2245 | + } |
|
| 2043 | 2246 | update_db::unzip($tmp_dir.'ivae_feb2013.zip'); |
| 2044 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2247 | + if ($globalDebug) { |
|
| 2248 | + echo "Add to DB..."; |
|
| 2249 | + } |
|
| 2045 | 2250 | update_db::ivao_airlines($tmp_dir.'data/airlines.dat'); |
| 2046 | - if ($globalDebug) echo "Copy airlines logos to airlines images directory..."; |
|
| 2251 | + if ($globalDebug) { |
|
| 2252 | + echo "Copy airlines logos to airlines images directory..."; |
|
| 2253 | + } |
|
| 2047 | 2254 | if (is_writable(dirname(__FILE__).'/../images/airlines')) { |
| 2048 | - if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
| 2049 | - } else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
|
| 2050 | - } else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
|
| 2051 | - } else $error = "ZIP module not loaded but required for IVAO."; |
|
| 2255 | + if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) { |
|
| 2256 | + $error = "Failed to copy airlines logo."; |
|
| 2257 | + } |
|
| 2258 | + } else { |
|
| 2259 | + $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
|
| 2260 | + } |
|
| 2261 | + } else { |
|
| 2262 | + $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
|
| 2263 | + } |
|
| 2264 | + } else { |
|
| 2265 | + $error = "ZIP module not loaded but required for IVAO."; |
|
| 2266 | + } |
|
| 2052 | 2267 | if ($error != '') { |
| 2053 | 2268 | return $error; |
| 2054 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2269 | + } elseif ($globalDebug) { |
|
| 2270 | + echo "Done\n"; |
|
| 2271 | + } |
|
| 2055 | 2272 | return ''; |
| 2056 | 2273 | } |
| 2057 | 2274 | |
| 2058 | 2275 | public static function update_routes() { |
| 2059 | 2276 | global $tmp_dir, $globalDebug; |
| 2060 | 2277 | $error = ''; |
| 2061 | - if ($globalDebug) echo "Routes : Download..."; |
|
| 2278 | + if ($globalDebug) { |
|
| 2279 | + echo "Routes : Download..."; |
|
| 2280 | + } |
|
| 2062 | 2281 | update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz'); |
| 2063 | 2282 | if (file_exists($tmp_dir.'StandingData.sqb.gz')) { |
| 2064 | - if ($globalDebug) echo "Gunzip..."; |
|
| 2283 | + if ($globalDebug) { |
|
| 2284 | + echo "Gunzip..."; |
|
| 2285 | + } |
|
| 2065 | 2286 | update_db::gunzip($tmp_dir.'StandingData.sqb.gz'); |
| 2066 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2287 | + if ($globalDebug) { |
|
| 2288 | + echo "Add to DB..."; |
|
| 2289 | + } |
|
| 2067 | 2290 | $error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb'); |
| 2068 | - } else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed."; |
|
| 2291 | + } else { |
|
| 2292 | + $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed."; |
|
| 2293 | + } |
|
| 2069 | 2294 | if ($error != '') { |
| 2070 | 2295 | return $error; |
| 2071 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2296 | + } elseif ($globalDebug) { |
|
| 2297 | + echo "Done\n"; |
|
| 2298 | + } |
|
| 2072 | 2299 | return ''; |
| 2073 | 2300 | } |
| 2074 | 2301 | public static function update_oneworld() { |
| 2075 | 2302 | global $tmp_dir, $globalDebug; |
| 2076 | 2303 | $error = ''; |
| 2077 | - if ($globalDebug) echo "Schedules Oneworld : Download..."; |
|
| 2304 | + if ($globalDebug) { |
|
| 2305 | + echo "Schedules Oneworld : Download..."; |
|
| 2306 | + } |
|
| 2078 | 2307 | update_db::download('http://data.flightairmap.com/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz'); |
| 2079 | 2308 | if (file_exists($tmp_dir.'oneworld.csv.gz')) { |
| 2080 | - if ($globalDebug) echo "Gunzip..."; |
|
| 2309 | + if ($globalDebug) { |
|
| 2310 | + echo "Gunzip..."; |
|
| 2311 | + } |
|
| 2081 | 2312 | update_db::gunzip($tmp_dir.'oneworld.csv.gz'); |
| 2082 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2313 | + if ($globalDebug) { |
|
| 2314 | + echo "Add to DB..."; |
|
| 2315 | + } |
|
| 2083 | 2316 | $error = update_db::retrieve_route_oneworld($tmp_dir.'oneworld.csv'); |
| 2084 | - } else $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed."; |
|
| 2317 | + } else { |
|
| 2318 | + $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed."; |
|
| 2319 | + } |
|
| 2085 | 2320 | if ($error != '') { |
| 2086 | 2321 | return $error; |
| 2087 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2322 | + } elseif ($globalDebug) { |
|
| 2323 | + echo "Done\n"; |
|
| 2324 | + } |
|
| 2088 | 2325 | return ''; |
| 2089 | 2326 | } |
| 2090 | 2327 | public static function update_skyteam() { |
| 2091 | 2328 | global $tmp_dir, $globalDebug; |
| 2092 | 2329 | $error = ''; |
| 2093 | - if ($globalDebug) echo "Schedules Skyteam : Download..."; |
|
| 2330 | + if ($globalDebug) { |
|
| 2331 | + echo "Schedules Skyteam : Download..."; |
|
| 2332 | + } |
|
| 2094 | 2333 | update_db::download('http://data.flightairmap.com/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz'); |
| 2095 | 2334 | if (file_exists($tmp_dir.'skyteam.csv.gz')) { |
| 2096 | - if ($globalDebug) echo "Gunzip..."; |
|
| 2335 | + if ($globalDebug) { |
|
| 2336 | + echo "Gunzip..."; |
|
| 2337 | + } |
|
| 2097 | 2338 | update_db::gunzip($tmp_dir.'skyteam.csv.gz'); |
| 2098 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2339 | + if ($globalDebug) { |
|
| 2340 | + echo "Add to DB..."; |
|
| 2341 | + } |
|
| 2099 | 2342 | $error = update_db::retrieve_route_skyteam($tmp_dir.'skyteam.csv'); |
| 2100 | - } else $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed."; |
|
| 2343 | + } else { |
|
| 2344 | + $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed."; |
|
| 2345 | + } |
|
| 2101 | 2346 | if ($error != '') { |
| 2102 | 2347 | return $error; |
| 2103 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2348 | + } elseif ($globalDebug) { |
|
| 2349 | + echo "Done\n"; |
|
| 2350 | + } |
|
| 2104 | 2351 | return ''; |
| 2105 | 2352 | } |
| 2106 | 2353 | public static function update_ModeS() { |
@@ -2117,340 +2364,590 @@ discard block |
||
| 2117 | 2364 | exit; |
| 2118 | 2365 | } elseif ($globalDebug) echo "Done\n"; |
| 2119 | 2366 | */ |
| 2120 | - if ($globalDebug) echo "Modes : Download..."; |
|
| 2121 | -// update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
|
| 2367 | + if ($globalDebug) { |
|
| 2368 | + echo "Modes : Download..."; |
|
| 2369 | + } |
|
| 2370 | + // update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
|
| 2122 | 2371 | update_db::download('http://data.flightairmap.com/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz'); |
| 2123 | 2372 | |
| 2124 | 2373 | // if (file_exists($tmp_dir.'basestation_latest.zip')) { |
| 2125 | 2374 | if (file_exists($tmp_dir.'BaseStation.sqb.gz')) { |
| 2126 | - if ($globalDebug) echo "Unzip..."; |
|
| 2127 | -// update_db::unzip($tmp_dir.'basestation_latest.zip'); |
|
| 2375 | + if ($globalDebug) { |
|
| 2376 | + echo "Unzip..."; |
|
| 2377 | + } |
|
| 2378 | + // update_db::unzip($tmp_dir.'basestation_latest.zip'); |
|
| 2128 | 2379 | update_db::gunzip($tmp_dir.'BaseStation.sqb.gz'); |
| 2129 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2380 | + if ($globalDebug) { |
|
| 2381 | + echo "Add to DB..."; |
|
| 2382 | + } |
|
| 2130 | 2383 | $error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb'); |
| 2131 | 2384 | // $error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'basestation.sqb'); |
| 2132 | - } else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed."; |
|
| 2385 | + } else { |
|
| 2386 | + $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed."; |
|
| 2387 | + } |
|
| 2133 | 2388 | if ($error != '') { |
| 2134 | 2389 | return $error; |
| 2135 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2390 | + } elseif ($globalDebug) { |
|
| 2391 | + echo "Done\n"; |
|
| 2392 | + } |
|
| 2136 | 2393 | return ''; |
| 2137 | 2394 | } |
| 2138 | 2395 | |
| 2139 | 2396 | public static function update_ModeS_faa() { |
| 2140 | 2397 | global $tmp_dir, $globalDebug; |
| 2141 | - if ($globalDebug) echo "Modes FAA: Download..."; |
|
| 2398 | + if ($globalDebug) { |
|
| 2399 | + echo "Modes FAA: Download..."; |
|
| 2400 | + } |
|
| 2142 | 2401 | update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip'); |
| 2143 | 2402 | if (file_exists($tmp_dir.'ReleasableAircraft.zip')) { |
| 2144 | - if ($globalDebug) echo "Unzip..."; |
|
| 2403 | + if ($globalDebug) { |
|
| 2404 | + echo "Unzip..."; |
|
| 2405 | + } |
|
| 2145 | 2406 | update_db::unzip($tmp_dir.'ReleasableAircraft.zip'); |
| 2146 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2407 | + if ($globalDebug) { |
|
| 2408 | + echo "Add to DB..."; |
|
| 2409 | + } |
|
| 2147 | 2410 | $error = update_db::modes_faa(); |
| 2148 | - } else $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed."; |
|
| 2411 | + } else { |
|
| 2412 | + $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed."; |
|
| 2413 | + } |
|
| 2149 | 2414 | if ($error != '') { |
| 2150 | 2415 | return $error; |
| 2151 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2416 | + } elseif ($globalDebug) { |
|
| 2417 | + echo "Done\n"; |
|
| 2418 | + } |
|
| 2152 | 2419 | return ''; |
| 2153 | 2420 | } |
| 2154 | 2421 | |
| 2155 | 2422 | public static function update_ModeS_flarm() { |
| 2156 | 2423 | global $tmp_dir, $globalDebug; |
| 2157 | - if ($globalDebug) echo "Modes Flarmnet: Download..."; |
|
| 2424 | + if ($globalDebug) { |
|
| 2425 | + echo "Modes Flarmnet: Download..."; |
|
| 2426 | + } |
|
| 2158 | 2427 | update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln'); |
| 2159 | 2428 | if (file_exists($tmp_dir.'data.fln')) { |
| 2160 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2429 | + if ($globalDebug) { |
|
| 2430 | + echo "Add to DB..."; |
|
| 2431 | + } |
|
| 2161 | 2432 | $error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln'); |
| 2162 | - } else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed."; |
|
| 2433 | + } else { |
|
| 2434 | + $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed."; |
|
| 2435 | + } |
|
| 2163 | 2436 | if ($error != '') { |
| 2164 | 2437 | return $error; |
| 2165 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2438 | + } elseif ($globalDebug) { |
|
| 2439 | + echo "Done\n"; |
|
| 2440 | + } |
|
| 2166 | 2441 | return ''; |
| 2167 | 2442 | } |
| 2168 | 2443 | |
| 2169 | 2444 | public static function update_ModeS_ogn() { |
| 2170 | 2445 | global $tmp_dir, $globalDebug; |
| 2171 | - if ($globalDebug) echo "Modes OGN: Download..."; |
|
| 2446 | + if ($globalDebug) { |
|
| 2447 | + echo "Modes OGN: Download..."; |
|
| 2448 | + } |
|
| 2172 | 2449 | update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv'); |
| 2173 | 2450 | if (file_exists($tmp_dir.'ogn.csv')) { |
| 2174 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2451 | + if ($globalDebug) { |
|
| 2452 | + echo "Add to DB..."; |
|
| 2453 | + } |
|
| 2175 | 2454 | $error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv'); |
| 2176 | - } else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed."; |
|
| 2455 | + } else { |
|
| 2456 | + $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed."; |
|
| 2457 | + } |
|
| 2177 | 2458 | if ($error != '') { |
| 2178 | 2459 | return $error; |
| 2179 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2460 | + } elseif ($globalDebug) { |
|
| 2461 | + echo "Done\n"; |
|
| 2462 | + } |
|
| 2180 | 2463 | return ''; |
| 2181 | 2464 | } |
| 2182 | 2465 | |
| 2183 | 2466 | public static function update_owner() { |
| 2184 | 2467 | global $tmp_dir, $globalDebug, $globalMasterSource; |
| 2185 | 2468 | |
| 2186 | - if ($globalDebug) echo "Owner France: Download..."; |
|
| 2469 | + if ($globalDebug) { |
|
| 2470 | + echo "Owner France: Download..."; |
|
| 2471 | + } |
|
| 2187 | 2472 | update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv'); |
| 2188 | 2473 | if (file_exists($tmp_dir.'owner_f.csv')) { |
| 2189 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2474 | + if ($globalDebug) { |
|
| 2475 | + echo "Add to DB..."; |
|
| 2476 | + } |
|
| 2190 | 2477 | $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F'); |
| 2191 | - } else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
|
| 2478 | + } else { |
|
| 2479 | + $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
|
| 2480 | + } |
|
| 2192 | 2481 | if ($error != '') { |
| 2193 | 2482 | return $error; |
| 2194 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2483 | + } elseif ($globalDebug) { |
|
| 2484 | + echo "Done\n"; |
|
| 2485 | + } |
|
| 2195 | 2486 | |
| 2196 | - if ($globalDebug) echo "Owner Ireland: Download..."; |
|
| 2487 | + if ($globalDebug) { |
|
| 2488 | + echo "Owner Ireland: Download..."; |
|
| 2489 | + } |
|
| 2197 | 2490 | update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv'); |
| 2198 | 2491 | if (file_exists($tmp_dir.'owner_ei.csv')) { |
| 2199 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2492 | + if ($globalDebug) { |
|
| 2493 | + echo "Add to DB..."; |
|
| 2494 | + } |
|
| 2200 | 2495 | $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI'); |
| 2201 | - } else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
|
| 2496 | + } else { |
|
| 2497 | + $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
|
| 2498 | + } |
|
| 2202 | 2499 | if ($error != '') { |
| 2203 | 2500 | return $error; |
| 2204 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2205 | - if ($globalDebug) echo "Owner Switzerland: Download..."; |
|
| 2501 | + } elseif ($globalDebug) { |
|
| 2502 | + echo "Done\n"; |
|
| 2503 | + } |
|
| 2504 | + if ($globalDebug) { |
|
| 2505 | + echo "Owner Switzerland: Download..."; |
|
| 2506 | + } |
|
| 2206 | 2507 | update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv'); |
| 2207 | 2508 | if (file_exists($tmp_dir.'owner_hb.csv')) { |
| 2208 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2509 | + if ($globalDebug) { |
|
| 2510 | + echo "Add to DB..."; |
|
| 2511 | + } |
|
| 2209 | 2512 | $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB'); |
| 2210 | - } else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
|
| 2513 | + } else { |
|
| 2514 | + $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
|
| 2515 | + } |
|
| 2211 | 2516 | if ($error != '') { |
| 2212 | 2517 | return $error; |
| 2213 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2214 | - if ($globalDebug) echo "Owner Czech Republic: Download..."; |
|
| 2518 | + } elseif ($globalDebug) { |
|
| 2519 | + echo "Done\n"; |
|
| 2520 | + } |
|
| 2521 | + if ($globalDebug) { |
|
| 2522 | + echo "Owner Czech Republic: Download..."; |
|
| 2523 | + } |
|
| 2215 | 2524 | update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv'); |
| 2216 | 2525 | if (file_exists($tmp_dir.'owner_ok.csv')) { |
| 2217 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2526 | + if ($globalDebug) { |
|
| 2527 | + echo "Add to DB..."; |
|
| 2528 | + } |
|
| 2218 | 2529 | $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK'); |
| 2219 | - } else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
|
| 2530 | + } else { |
|
| 2531 | + $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
|
| 2532 | + } |
|
| 2220 | 2533 | if ($error != '') { |
| 2221 | 2534 | return $error; |
| 2222 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2223 | - if ($globalDebug) echo "Owner Australia: Download..."; |
|
| 2535 | + } elseif ($globalDebug) { |
|
| 2536 | + echo "Done\n"; |
|
| 2537 | + } |
|
| 2538 | + if ($globalDebug) { |
|
| 2539 | + echo "Owner Australia: Download..."; |
|
| 2540 | + } |
|
| 2224 | 2541 | update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv'); |
| 2225 | 2542 | if (file_exists($tmp_dir.'owner_vh.csv')) { |
| 2226 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2543 | + if ($globalDebug) { |
|
| 2544 | + echo "Add to DB..."; |
|
| 2545 | + } |
|
| 2227 | 2546 | $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH'); |
| 2228 | - } else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
|
| 2547 | + } else { |
|
| 2548 | + $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
|
| 2549 | + } |
|
| 2229 | 2550 | if ($error != '') { |
| 2230 | 2551 | return $error; |
| 2231 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2232 | - if ($globalDebug) echo "Owner Austria: Download..."; |
|
| 2552 | + } elseif ($globalDebug) { |
|
| 2553 | + echo "Done\n"; |
|
| 2554 | + } |
|
| 2555 | + if ($globalDebug) { |
|
| 2556 | + echo "Owner Austria: Download..."; |
|
| 2557 | + } |
|
| 2233 | 2558 | update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv'); |
| 2234 | 2559 | if (file_exists($tmp_dir.'owner_oe.csv')) { |
| 2235 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2560 | + if ($globalDebug) { |
|
| 2561 | + echo "Add to DB..."; |
|
| 2562 | + } |
|
| 2236 | 2563 | $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE'); |
| 2237 | - } else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
|
| 2564 | + } else { |
|
| 2565 | + $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
|
| 2566 | + } |
|
| 2238 | 2567 | if ($error != '') { |
| 2239 | 2568 | return $error; |
| 2240 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2241 | - if ($globalDebug) echo "Owner Chile: Download..."; |
|
| 2569 | + } elseif ($globalDebug) { |
|
| 2570 | + echo "Done\n"; |
|
| 2571 | + } |
|
| 2572 | + if ($globalDebug) { |
|
| 2573 | + echo "Owner Chile: Download..."; |
|
| 2574 | + } |
|
| 2242 | 2575 | update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv'); |
| 2243 | 2576 | if (file_exists($tmp_dir.'owner_cc.csv')) { |
| 2244 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2577 | + if ($globalDebug) { |
|
| 2578 | + echo "Add to DB..."; |
|
| 2579 | + } |
|
| 2245 | 2580 | $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC'); |
| 2246 | - } else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
|
| 2581 | + } else { |
|
| 2582 | + $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
|
| 2583 | + } |
|
| 2247 | 2584 | if ($error != '') { |
| 2248 | 2585 | return $error; |
| 2249 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2250 | - if ($globalDebug) echo "Owner Colombia: Download..."; |
|
| 2586 | + } elseif ($globalDebug) { |
|
| 2587 | + echo "Done\n"; |
|
| 2588 | + } |
|
| 2589 | + if ($globalDebug) { |
|
| 2590 | + echo "Owner Colombia: Download..."; |
|
| 2591 | + } |
|
| 2251 | 2592 | update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv'); |
| 2252 | 2593 | if (file_exists($tmp_dir.'owner_hj.csv')) { |
| 2253 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2594 | + if ($globalDebug) { |
|
| 2595 | + echo "Add to DB..."; |
|
| 2596 | + } |
|
| 2254 | 2597 | $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ'); |
| 2255 | - } else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
|
| 2598 | + } else { |
|
| 2599 | + $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
|
| 2600 | + } |
|
| 2256 | 2601 | if ($error != '') { |
| 2257 | 2602 | return $error; |
| 2258 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2259 | - if ($globalDebug) echo "Owner Bosnia Herzegobina: Download..."; |
|
| 2603 | + } elseif ($globalDebug) { |
|
| 2604 | + echo "Done\n"; |
|
| 2605 | + } |
|
| 2606 | + if ($globalDebug) { |
|
| 2607 | + echo "Owner Bosnia Herzegobina: Download..."; |
|
| 2608 | + } |
|
| 2260 | 2609 | update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv'); |
| 2261 | 2610 | if (file_exists($tmp_dir.'owner_e7.csv')) { |
| 2262 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2611 | + if ($globalDebug) { |
|
| 2612 | + echo "Add to DB..."; |
|
| 2613 | + } |
|
| 2263 | 2614 | $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7'); |
| 2264 | - } else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
|
| 2615 | + } else { |
|
| 2616 | + $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
|
| 2617 | + } |
|
| 2265 | 2618 | if ($error != '') { |
| 2266 | 2619 | return $error; |
| 2267 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2268 | - if ($globalDebug) echo "Owner Brazil: Download..."; |
|
| 2620 | + } elseif ($globalDebug) { |
|
| 2621 | + echo "Done\n"; |
|
| 2622 | + } |
|
| 2623 | + if ($globalDebug) { |
|
| 2624 | + echo "Owner Brazil: Download..."; |
|
| 2625 | + } |
|
| 2269 | 2626 | update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv'); |
| 2270 | 2627 | if (file_exists($tmp_dir.'owner_pp.csv')) { |
| 2271 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2628 | + if ($globalDebug) { |
|
| 2629 | + echo "Add to DB..."; |
|
| 2630 | + } |
|
| 2272 | 2631 | $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP'); |
| 2273 | - } else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
|
| 2632 | + } else { |
|
| 2633 | + $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
|
| 2634 | + } |
|
| 2274 | 2635 | if ($error != '') { |
| 2275 | 2636 | return $error; |
| 2276 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2277 | - if ($globalDebug) echo "Owner Cayman Islands: Download..."; |
|
| 2637 | + } elseif ($globalDebug) { |
|
| 2638 | + echo "Done\n"; |
|
| 2639 | + } |
|
| 2640 | + if ($globalDebug) { |
|
| 2641 | + echo "Owner Cayman Islands: Download..."; |
|
| 2642 | + } |
|
| 2278 | 2643 | update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv'); |
| 2279 | 2644 | if (file_exists($tmp_dir.'owner_vp.csv')) { |
| 2280 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2645 | + if ($globalDebug) { |
|
| 2646 | + echo "Add to DB..."; |
|
| 2647 | + } |
|
| 2281 | 2648 | $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP'); |
| 2282 | - } else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
|
| 2649 | + } else { |
|
| 2650 | + $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
|
| 2651 | + } |
|
| 2283 | 2652 | if ($error != '') { |
| 2284 | 2653 | return $error; |
| 2285 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2286 | - if ($globalDebug) echo "Owner Croatia: Download..."; |
|
| 2654 | + } elseif ($globalDebug) { |
|
| 2655 | + echo "Done\n"; |
|
| 2656 | + } |
|
| 2657 | + if ($globalDebug) { |
|
| 2658 | + echo "Owner Croatia: Download..."; |
|
| 2659 | + } |
|
| 2287 | 2660 | update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv'); |
| 2288 | 2661 | if (file_exists($tmp_dir.'owner_9a.csv')) { |
| 2289 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2662 | + if ($globalDebug) { |
|
| 2663 | + echo "Add to DB..."; |
|
| 2664 | + } |
|
| 2290 | 2665 | $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A'); |
| 2291 | - } else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
|
| 2666 | + } else { |
|
| 2667 | + $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
|
| 2668 | + } |
|
| 2292 | 2669 | if ($error != '') { |
| 2293 | 2670 | return $error; |
| 2294 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2295 | - if ($globalDebug) echo "Owner Luxembourg: Download..."; |
|
| 2671 | + } elseif ($globalDebug) { |
|
| 2672 | + echo "Done\n"; |
|
| 2673 | + } |
|
| 2674 | + if ($globalDebug) { |
|
| 2675 | + echo "Owner Luxembourg: Download..."; |
|
| 2676 | + } |
|
| 2296 | 2677 | update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv'); |
| 2297 | 2678 | if (file_exists($tmp_dir.'owner_lx.csv')) { |
| 2298 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2679 | + if ($globalDebug) { |
|
| 2680 | + echo "Add to DB..."; |
|
| 2681 | + } |
|
| 2299 | 2682 | $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX'); |
| 2300 | - } else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
|
| 2683 | + } else { |
|
| 2684 | + $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
|
| 2685 | + } |
|
| 2301 | 2686 | if ($error != '') { |
| 2302 | 2687 | return $error; |
| 2303 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2304 | - if ($globalDebug) echo "Owner Maldives: Download..."; |
|
| 2688 | + } elseif ($globalDebug) { |
|
| 2689 | + echo "Done\n"; |
|
| 2690 | + } |
|
| 2691 | + if ($globalDebug) { |
|
| 2692 | + echo "Owner Maldives: Download..."; |
|
| 2693 | + } |
|
| 2305 | 2694 | update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv'); |
| 2306 | 2695 | if (file_exists($tmp_dir.'owner_8q.csv')) { |
| 2307 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2696 | + if ($globalDebug) { |
|
| 2697 | + echo "Add to DB..."; |
|
| 2698 | + } |
|
| 2308 | 2699 | $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q'); |
| 2309 | - } else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
|
| 2700 | + } else { |
|
| 2701 | + $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
|
| 2702 | + } |
|
| 2310 | 2703 | if ($error != '') { |
| 2311 | 2704 | return $error; |
| 2312 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2313 | - if ($globalDebug) echo "Owner New Zealand: Download..."; |
|
| 2705 | + } elseif ($globalDebug) { |
|
| 2706 | + echo "Done\n"; |
|
| 2707 | + } |
|
| 2708 | + if ($globalDebug) { |
|
| 2709 | + echo "Owner New Zealand: Download..."; |
|
| 2710 | + } |
|
| 2314 | 2711 | update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv'); |
| 2315 | 2712 | if (file_exists($tmp_dir.'owner_zk.csv')) { |
| 2316 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2713 | + if ($globalDebug) { |
|
| 2714 | + echo "Add to DB..."; |
|
| 2715 | + } |
|
| 2317 | 2716 | $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK'); |
| 2318 | - } else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
|
| 2717 | + } else { |
|
| 2718 | + $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
|
| 2719 | + } |
|
| 2319 | 2720 | if ($error != '') { |
| 2320 | 2721 | return $error; |
| 2321 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2322 | - if ($globalDebug) echo "Owner Papua New Guinea: Download..."; |
|
| 2722 | + } elseif ($globalDebug) { |
|
| 2723 | + echo "Done\n"; |
|
| 2724 | + } |
|
| 2725 | + if ($globalDebug) { |
|
| 2726 | + echo "Owner Papua New Guinea: Download..."; |
|
| 2727 | + } |
|
| 2323 | 2728 | update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv'); |
| 2324 | 2729 | if (file_exists($tmp_dir.'owner_p2.csv')) { |
| 2325 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2730 | + if ($globalDebug) { |
|
| 2731 | + echo "Add to DB..."; |
|
| 2732 | + } |
|
| 2326 | 2733 | $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2'); |
| 2327 | - } else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
|
| 2734 | + } else { |
|
| 2735 | + $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
|
| 2736 | + } |
|
| 2328 | 2737 | if ($error != '') { |
| 2329 | 2738 | return $error; |
| 2330 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2331 | - if ($globalDebug) echo "Owner Slovakia: Download..."; |
|
| 2739 | + } elseif ($globalDebug) { |
|
| 2740 | + echo "Done\n"; |
|
| 2741 | + } |
|
| 2742 | + if ($globalDebug) { |
|
| 2743 | + echo "Owner Slovakia: Download..."; |
|
| 2744 | + } |
|
| 2332 | 2745 | update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv'); |
| 2333 | 2746 | if (file_exists($tmp_dir.'owner_om.csv')) { |
| 2334 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2747 | + if ($globalDebug) { |
|
| 2748 | + echo "Add to DB..."; |
|
| 2749 | + } |
|
| 2335 | 2750 | $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM'); |
| 2336 | - } else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
|
| 2751 | + } else { |
|
| 2752 | + $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
|
| 2753 | + } |
|
| 2337 | 2754 | if ($error != '') { |
| 2338 | 2755 | return $error; |
| 2339 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2340 | - if ($globalDebug) echo "Owner Ecuador: Download..."; |
|
| 2756 | + } elseif ($globalDebug) { |
|
| 2757 | + echo "Done\n"; |
|
| 2758 | + } |
|
| 2759 | + if ($globalDebug) { |
|
| 2760 | + echo "Owner Ecuador: Download..."; |
|
| 2761 | + } |
|
| 2341 | 2762 | update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv'); |
| 2342 | 2763 | if (file_exists($tmp_dir.'owner_hc.csv')) { |
| 2343 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2764 | + if ($globalDebug) { |
|
| 2765 | + echo "Add to DB..."; |
|
| 2766 | + } |
|
| 2344 | 2767 | $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC'); |
| 2345 | - } else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
|
| 2768 | + } else { |
|
| 2769 | + $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
|
| 2770 | + } |
|
| 2346 | 2771 | if ($error != '') { |
| 2347 | 2772 | return $error; |
| 2348 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2349 | - if ($globalDebug) echo "Owner Iceland: Download..."; |
|
| 2773 | + } elseif ($globalDebug) { |
|
| 2774 | + echo "Done\n"; |
|
| 2775 | + } |
|
| 2776 | + if ($globalDebug) { |
|
| 2777 | + echo "Owner Iceland: Download..."; |
|
| 2778 | + } |
|
| 2350 | 2779 | update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv'); |
| 2351 | 2780 | if (file_exists($tmp_dir.'owner_tf.csv')) { |
| 2352 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2781 | + if ($globalDebug) { |
|
| 2782 | + echo "Add to DB..."; |
|
| 2783 | + } |
|
| 2353 | 2784 | $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF'); |
| 2354 | - } else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
|
| 2785 | + } else { |
|
| 2786 | + $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
|
| 2787 | + } |
|
| 2355 | 2788 | if ($error != '') { |
| 2356 | 2789 | return $error; |
| 2357 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2358 | - if ($globalDebug) echo "Owner Isle of Man: Download..."; |
|
| 2790 | + } elseif ($globalDebug) { |
|
| 2791 | + echo "Done\n"; |
|
| 2792 | + } |
|
| 2793 | + if ($globalDebug) { |
|
| 2794 | + echo "Owner Isle of Man: Download..."; |
|
| 2795 | + } |
|
| 2359 | 2796 | update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv'); |
| 2360 | 2797 | if (file_exists($tmp_dir.'owner_m.csv')) { |
| 2361 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2798 | + if ($globalDebug) { |
|
| 2799 | + echo "Add to DB..."; |
|
| 2800 | + } |
|
| 2362 | 2801 | $error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M'); |
| 2363 | - } else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed."; |
|
| 2802 | + } else { |
|
| 2803 | + $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed."; |
|
| 2804 | + } |
|
| 2364 | 2805 | if ($error != '') { |
| 2365 | 2806 | return $error; |
| 2366 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2807 | + } elseif ($globalDebug) { |
|
| 2808 | + echo "Done\n"; |
|
| 2809 | + } |
|
| 2367 | 2810 | if ($globalMasterSource) { |
| 2368 | - if ($globalDebug) echo "ModeS Netherlands: Download..."; |
|
| 2811 | + if ($globalDebug) { |
|
| 2812 | + echo "ModeS Netherlands: Download..."; |
|
| 2813 | + } |
|
| 2369 | 2814 | update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv'); |
| 2370 | 2815 | if (file_exists($tmp_dir.'owner_ph.csv')) { |
| 2371 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2816 | + if ($globalDebug) { |
|
| 2817 | + echo "Add to DB..."; |
|
| 2818 | + } |
|
| 2372 | 2819 | $error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH'); |
| 2373 | - } else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed."; |
|
| 2820 | + } else { |
|
| 2821 | + $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed."; |
|
| 2822 | + } |
|
| 2374 | 2823 | if ($error != '') { |
| 2375 | 2824 | return $error; |
| 2376 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2377 | - if ($globalDebug) echo "ModeS Denmark: Download..."; |
|
| 2825 | + } elseif ($globalDebug) { |
|
| 2826 | + echo "Done\n"; |
|
| 2827 | + } |
|
| 2828 | + if ($globalDebug) { |
|
| 2829 | + echo "ModeS Denmark: Download..."; |
|
| 2830 | + } |
|
| 2378 | 2831 | update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv'); |
| 2379 | 2832 | if (file_exists($tmp_dir.'owner_oy.csv')) { |
| 2380 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2833 | + if ($globalDebug) { |
|
| 2834 | + echo "Add to DB..."; |
|
| 2835 | + } |
|
| 2381 | 2836 | $error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY'); |
| 2382 | - } else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed."; |
|
| 2837 | + } else { |
|
| 2838 | + $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed."; |
|
| 2839 | + } |
|
| 2383 | 2840 | if ($error != '') { |
| 2384 | 2841 | return $error; |
| 2385 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2386 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2842 | + } elseif ($globalDebug) { |
|
| 2843 | + echo "Done\n"; |
|
| 2844 | + } |
|
| 2845 | + } elseif ($globalDebug) { |
|
| 2846 | + echo "Done\n"; |
|
| 2847 | + } |
|
| 2387 | 2848 | return ''; |
| 2388 | 2849 | } |
| 2389 | 2850 | |
| 2390 | 2851 | public static function update_translation() { |
| 2391 | 2852 | global $tmp_dir, $globalDebug; |
| 2392 | 2853 | $error = ''; |
| 2393 | - if ($globalDebug) echo "Translation : Download..."; |
|
| 2854 | + if ($globalDebug) { |
|
| 2855 | + echo "Translation : Download..."; |
|
| 2856 | + } |
|
| 2394 | 2857 | update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip'); |
| 2395 | 2858 | if (file_exists($tmp_dir.'translation.zip')) { |
| 2396 | - if ($globalDebug) echo "Unzip..."; |
|
| 2859 | + if ($globalDebug) { |
|
| 2860 | + echo "Unzip..."; |
|
| 2861 | + } |
|
| 2397 | 2862 | update_db::unzip($tmp_dir.'translation.zip'); |
| 2398 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2863 | + if ($globalDebug) { |
|
| 2864 | + echo "Add to DB..."; |
|
| 2865 | + } |
|
| 2399 | 2866 | $error = update_db::translation(); |
| 2400 | - } else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed."; |
|
| 2867 | + } else { |
|
| 2868 | + $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed."; |
|
| 2869 | + } |
|
| 2401 | 2870 | if ($error != '') { |
| 2402 | 2871 | return $error; |
| 2403 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2872 | + } elseif ($globalDebug) { |
|
| 2873 | + echo "Done\n"; |
|
| 2874 | + } |
|
| 2404 | 2875 | return ''; |
| 2405 | 2876 | } |
| 2406 | 2877 | |
| 2407 | 2878 | public static function update_translation_fam() { |
| 2408 | 2879 | global $tmp_dir, $globalDebug; |
| 2409 | 2880 | $error = ''; |
| 2410 | - if ($globalDebug) echo "Translation from FlightAirMap website : Download..."; |
|
| 2881 | + if ($globalDebug) { |
|
| 2882 | + echo "Translation from FlightAirMap website : Download..."; |
|
| 2883 | + } |
|
| 2411 | 2884 | update_db::download('http://data.flightairmap.com/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz'); |
| 2412 | 2885 | update_db::download('http://data.flightairmap.com/data/translation.tsv.gz.md5',$tmp_dir.'translation.tsv.gz.md5'); |
| 2413 | 2886 | if (file_exists($tmp_dir.'translation.tsv.gz') && file_exists($tmp_dir.'translation.tsv.gz')) { |
| 2414 | 2887 | $translation_md5_file = explode(' ',file_get_contents($tmp_dir.'translation.tsv.gz.md5')); |
| 2415 | 2888 | $translation_md5 = $translation_md5_file[0]; |
| 2416 | 2889 | if (md5_file($tmp_dir.'translation.tsv.gz') == $translation_md5) { |
| 2417 | - if ($globalDebug) echo "Gunzip..."; |
|
| 2890 | + if ($globalDebug) { |
|
| 2891 | + echo "Gunzip..."; |
|
| 2892 | + } |
|
| 2418 | 2893 | update_db::gunzip($tmp_dir.'translation.tsv.gz'); |
| 2419 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2894 | + if ($globalDebug) { |
|
| 2895 | + echo "Add to DB..."; |
|
| 2896 | + } |
|
| 2420 | 2897 | $error = update_db::translation_fam(); |
| 2421 | - } else $error = "File ".$tmp_dir.'translation.tsv.gz'." md5 failed. Download failed."; |
|
| 2422 | - } else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed."; |
|
| 2898 | + } else { |
|
| 2899 | + $error = "File ".$tmp_dir.'translation.tsv.gz'." md5 failed. Download failed."; |
|
| 2900 | + } |
|
| 2901 | + } else { |
|
| 2902 | + $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed."; |
|
| 2903 | + } |
|
| 2423 | 2904 | if ($error != '') { |
| 2424 | 2905 | return $error; |
| 2425 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2906 | + } elseif ($globalDebug) { |
|
| 2907 | + echo "Done\n"; |
|
| 2908 | + } |
|
| 2426 | 2909 | return ''; |
| 2427 | 2910 | } |
| 2428 | 2911 | public static function update_ModeS_fam() { |
| 2429 | 2912 | global $tmp_dir, $globalDebug; |
| 2430 | 2913 | $error = ''; |
| 2431 | - if ($globalDebug) echo "ModeS from FlightAirMap website : Download..."; |
|
| 2914 | + if ($globalDebug) { |
|
| 2915 | + echo "ModeS from FlightAirMap website : Download..."; |
|
| 2916 | + } |
|
| 2432 | 2917 | update_db::download('http://data.flightairmap.com/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz'); |
| 2433 | 2918 | update_db::download('http://data.flightairmap.com/data/modes.tsv.gz.md5',$tmp_dir.'modes.tsv.gz.md5'); |
| 2434 | 2919 | if (file_exists($tmp_dir.'modes.tsv.gz') && file_exists($tmp_dir.'modes.tsv.gz.md5')) { |
| 2435 | 2920 | $modes_md5_file = explode(' ',file_get_contents($tmp_dir.'modes.tsv.gz.md5')); |
| 2436 | 2921 | $modes_md5 = $modes_md5_file[0]; |
| 2437 | 2922 | if (md5_file($tmp_dir.'modes.tsv.gz') == $modes_md5) { |
| 2438 | - if ($globalDebug) echo "Gunzip..."; |
|
| 2923 | + if ($globalDebug) { |
|
| 2924 | + echo "Gunzip..."; |
|
| 2925 | + } |
|
| 2439 | 2926 | update_db::gunzip($tmp_dir.'modes.tsv.gz'); |
| 2440 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2927 | + if ($globalDebug) { |
|
| 2928 | + echo "Add to DB..."; |
|
| 2929 | + } |
|
| 2441 | 2930 | $error = update_db::modes_fam(); |
| 2442 | - } else $error = "File ".$tmp_dir.'modes.tsv.gz'." md5 failed. Download failed."; |
|
| 2443 | - } else $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed."; |
|
| 2931 | + } else { |
|
| 2932 | + $error = "File ".$tmp_dir.'modes.tsv.gz'." md5 failed. Download failed."; |
|
| 2933 | + } |
|
| 2934 | + } else { |
|
| 2935 | + $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed."; |
|
| 2936 | + } |
|
| 2444 | 2937 | if ($error != '') { |
| 2445 | 2938 | return $error; |
| 2446 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2939 | + } elseif ($globalDebug) { |
|
| 2940 | + echo "Done\n"; |
|
| 2941 | + } |
|
| 2447 | 2942 | return ''; |
| 2448 | 2943 | } |
| 2449 | 2944 | |
| 2450 | 2945 | public static function update_airlines_fam() { |
| 2451 | 2946 | global $tmp_dir, $globalDebug; |
| 2452 | 2947 | $error = ''; |
| 2453 | - if ($globalDebug) echo "Airlines from FlightAirMap website : Download..."; |
|
| 2948 | + if ($globalDebug) { |
|
| 2949 | + echo "Airlines from FlightAirMap website : Download..."; |
|
| 2950 | + } |
|
| 2454 | 2951 | update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz.md5',$tmp_dir.'airlines.tsv.gz.md5'); |
| 2455 | 2952 | if (file_exists($tmp_dir.'airlines.tsv.gz.md5')) { |
| 2456 | 2953 | $airlines_md5_file = explode(' ',file_get_contents($tmp_dir.'airlines.tsv.gz.md5')); |
@@ -2459,26 +2956,42 @@ discard block |
||
| 2459 | 2956 | update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz',$tmp_dir.'airlines.tsv.gz'); |
| 2460 | 2957 | if (file_exists($tmp_dir.'airlines.tsv.gz')) { |
| 2461 | 2958 | if (md5_file($tmp_dir.'airlines.tsv.gz') == $airlines_md5) { |
| 2462 | - if ($globalDebug) echo "Gunzip..."; |
|
| 2959 | + if ($globalDebug) { |
|
| 2960 | + echo "Gunzip..."; |
|
| 2961 | + } |
|
| 2463 | 2962 | update_db::gunzip($tmp_dir.'airlines.tsv.gz'); |
| 2464 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2963 | + if ($globalDebug) { |
|
| 2964 | + echo "Add to DB..."; |
|
| 2965 | + } |
|
| 2465 | 2966 | $error = update_db::airlines_fam(); |
| 2466 | 2967 | update_db::insert_airlines_version($airlines_md5); |
| 2467 | - } else $error = "File ".$tmp_dir.'airlines.tsv.gz'." md5 failed. Download failed."; |
|
| 2468 | - } else $error = "File ".$tmp_dir.'airlines.tsv.gz'." doesn't exist. Download failed."; |
|
| 2469 | - } elseif ($globalDebug) echo "No update."; |
|
| 2470 | - } else $error = "File ".$tmp_dir.'airlines.tsv.gz.md5'." doesn't exist. Download failed."; |
|
| 2968 | + } else { |
|
| 2969 | + $error = "File ".$tmp_dir.'airlines.tsv.gz'." md5 failed. Download failed."; |
|
| 2970 | + } |
|
| 2971 | + } else { |
|
| 2972 | + $error = "File ".$tmp_dir.'airlines.tsv.gz'." doesn't exist. Download failed."; |
|
| 2973 | + } |
|
| 2974 | + } elseif ($globalDebug) { |
|
| 2975 | + echo "No update."; |
|
| 2976 | + } |
|
| 2977 | + } else { |
|
| 2978 | + $error = "File ".$tmp_dir.'airlines.tsv.gz.md5'." doesn't exist. Download failed."; |
|
| 2979 | + } |
|
| 2471 | 2980 | if ($error != '') { |
| 2472 | 2981 | return $error; |
| 2473 | 2982 | } else { |
| 2474 | - if ($globalDebug) echo "Done\n"; |
|
| 2983 | + if ($globalDebug) { |
|
| 2984 | + echo "Done\n"; |
|
| 2985 | + } |
|
| 2475 | 2986 | } |
| 2476 | 2987 | return ''; |
| 2477 | 2988 | } |
| 2478 | 2989 | |
| 2479 | 2990 | public static function update_owner_fam() { |
| 2480 | 2991 | global $tmp_dir, $globalDebug, $globalOwner; |
| 2481 | - if ($globalDebug) echo "owner from FlightAirMap website : Download..."; |
|
| 2992 | + if ($globalDebug) { |
|
| 2993 | + echo "owner from FlightAirMap website : Download..."; |
|
| 2994 | + } |
|
| 2482 | 2995 | $error = ''; |
| 2483 | 2996 | if ($globalOwner === TRUE) { |
| 2484 | 2997 | update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz'); |
@@ -2491,35 +3004,57 @@ discard block |
||
| 2491 | 3004 | $owners_md5_file = explode(' ',file_get_contents($tmp_dir.'owners.tsv.gz.md5')); |
| 2492 | 3005 | $owners_md5 = $owners_md5_file[0]; |
| 2493 | 3006 | if (md5_file($tmp_dir.'owners.tsv.gz') == $owners_md5) { |
| 2494 | - if ($globalDebug) echo "Gunzip..."; |
|
| 3007 | + if ($globalDebug) { |
|
| 3008 | + echo "Gunzip..."; |
|
| 3009 | + } |
|
| 2495 | 3010 | update_db::gunzip($tmp_dir.'owners.tsv.gz'); |
| 2496 | - if ($globalDebug) echo "Add to DB..."; |
|
| 3011 | + if ($globalDebug) { |
|
| 3012 | + echo "Add to DB..."; |
|
| 3013 | + } |
|
| 2497 | 3014 | $error = update_db::owner_fam(); |
| 2498 | - } else $error = "File ".$tmp_dir.'owners.tsv.gz'." md5 failed. Download failed."; |
|
| 2499 | - } else $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed."; |
|
| 3015 | + } else { |
|
| 3016 | + $error = "File ".$tmp_dir.'owners.tsv.gz'." md5 failed. Download failed."; |
|
| 3017 | + } |
|
| 3018 | + } else { |
|
| 3019 | + $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed."; |
|
| 3020 | + } |
|
| 2500 | 3021 | if ($error != '') { |
| 2501 | 3022 | return $error; |
| 2502 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 3023 | + } elseif ($globalDebug) { |
|
| 3024 | + echo "Done\n"; |
|
| 3025 | + } |
|
| 2503 | 3026 | return ''; |
| 2504 | 3027 | } |
| 2505 | 3028 | public static function update_routes_fam() { |
| 2506 | 3029 | global $tmp_dir, $globalDebug; |
| 2507 | - if ($globalDebug) echo "Routes from FlightAirMap website : Download..."; |
|
| 3030 | + if ($globalDebug) { |
|
| 3031 | + echo "Routes from FlightAirMap website : Download..."; |
|
| 3032 | + } |
|
| 2508 | 3033 | update_db::download('http://data.flightairmap.com/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz'); |
| 2509 | 3034 | update_db::download('http://data.flightairmap.com/data/routes.tsv.gz.md5',$tmp_dir.'routes.tsv.gz.md5'); |
| 2510 | 3035 | if (file_exists($tmp_dir.'routes.tsv.gz') && file_exists($tmp_dir.'routes.tsv.gz.md5')) { |
| 2511 | 3036 | $routes_md5_file = explode(' ',file_get_contents($tmp_dir.'routes.tsv.gz.md5')); |
| 2512 | 3037 | $routes_md5 = $routes_md5_file[0]; |
| 2513 | 3038 | if (md5_file($tmp_dir.'routes.tsv.gz') == $routes_md5) { |
| 2514 | - if ($globalDebug) echo "Gunzip..."; |
|
| 3039 | + if ($globalDebug) { |
|
| 3040 | + echo "Gunzip..."; |
|
| 3041 | + } |
|
| 2515 | 3042 | update_db::gunzip($tmp_dir.'routes.tsv.gz'); |
| 2516 | - if ($globalDebug) echo "Add to DB..."; |
|
| 3043 | + if ($globalDebug) { |
|
| 3044 | + echo "Add to DB..."; |
|
| 3045 | + } |
|
| 2517 | 3046 | $error = update_db::routes_fam(); |
| 2518 | - } else $error = "File ".$tmp_dir.'routes.tsv.gz'." md5 failed. Download failed."; |
|
| 2519 | - } else $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed."; |
|
| 3047 | + } else { |
|
| 3048 | + $error = "File ".$tmp_dir.'routes.tsv.gz'." md5 failed. Download failed."; |
|
| 3049 | + } |
|
| 3050 | + } else { |
|
| 3051 | + $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed."; |
|
| 3052 | + } |
|
| 2520 | 3053 | if ($error != '') { |
| 2521 | 3054 | return $error; |
| 2522 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 3055 | + } elseif ($globalDebug) { |
|
| 3056 | + echo "Done\n"; |
|
| 3057 | + } |
|
| 2523 | 3058 | return ''; |
| 2524 | 3059 | } |
| 2525 | 3060 | public static function update_marine_identity_fam() { |
@@ -2529,21 +3064,33 @@ discard block |
||
| 2529 | 3064 | $marine_identity_md5_file = explode(' ',file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5')); |
| 2530 | 3065 | $marine_identity_md5 = $marine_identity_md5_file[0]; |
| 2531 | 3066 | if (!update_db::check_marine_identity_version($marine_identity_md5)) { |
| 2532 | - if ($globalDebug) echo "Marine identity from FlightAirMap website : Download..."; |
|
| 3067 | + if ($globalDebug) { |
|
| 3068 | + echo "Marine identity from FlightAirMap website : Download..."; |
|
| 3069 | + } |
|
| 2533 | 3070 | update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz',$tmp_dir.'marine_identity.tsv.gz'); |
| 2534 | 3071 | if (file_exists($tmp_dir.'marine_identity.tsv.gz')) { |
| 2535 | 3072 | if (md5_file($tmp_dir.'marine_identity.tsv.gz') == $marine_identity_md5) { |
| 2536 | - if ($globalDebug) echo "Gunzip..."; |
|
| 3073 | + if ($globalDebug) { |
|
| 3074 | + echo "Gunzip..."; |
|
| 3075 | + } |
|
| 2537 | 3076 | update_db::gunzip($tmp_dir.'marine_identity.tsv.gz'); |
| 2538 | - if ($globalDebug) echo "Add to DB..."; |
|
| 3077 | + if ($globalDebug) { |
|
| 3078 | + echo "Add to DB..."; |
|
| 3079 | + } |
|
| 2539 | 3080 | $error = update_db::marine_identity_fam(); |
| 2540 | - } else $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." md5 failed. Download failed."; |
|
| 2541 | - } else $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed."; |
|
| 3081 | + } else { |
|
| 3082 | + $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." md5 failed. Download failed."; |
|
| 3083 | + } |
|
| 3084 | + } else { |
|
| 3085 | + $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed."; |
|
| 3086 | + } |
|
| 2542 | 3087 | if ($error != '') { |
| 2543 | 3088 | return $error; |
| 2544 | 3089 | } else { |
| 2545 | 3090 | update_db::insert_marine_identity_version($marine_identity_md5); |
| 2546 | - if ($globalDebug) echo "Done\n"; |
|
| 3091 | + if ($globalDebug) { |
|
| 3092 | + echo "Done\n"; |
|
| 3093 | + } |
|
| 2547 | 3094 | } |
| 2548 | 3095 | } |
| 2549 | 3096 | } |
@@ -2557,21 +3104,33 @@ discard block |
||
| 2557 | 3104 | $satellite_md5_file = explode(' ',file_get_contents($tmp_dir.'satellite.tsv.gz.md5')); |
| 2558 | 3105 | $satellite_md5 = $satellite_md5_file[0]; |
| 2559 | 3106 | if (!update_db::check_satellite_version($satellite_md5)) { |
| 2560 | - if ($globalDebug) echo "Satellite from FlightAirMap website : Download..."; |
|
| 3107 | + if ($globalDebug) { |
|
| 3108 | + echo "Satellite from FlightAirMap website : Download..."; |
|
| 3109 | + } |
|
| 2561 | 3110 | update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz',$tmp_dir.'satellite.tsv.gz'); |
| 2562 | 3111 | if (file_exists($tmp_dir.'satellite.tsv.gz')) { |
| 2563 | 3112 | if (md5_file($tmp_dir.'satellite.tsv.gz') == $satellite_md5) { |
| 2564 | - if ($globalDebug) echo "Gunzip..."; |
|
| 3113 | + if ($globalDebug) { |
|
| 3114 | + echo "Gunzip..."; |
|
| 3115 | + } |
|
| 2565 | 3116 | update_db::gunzip($tmp_dir.'satellite.tsv.gz'); |
| 2566 | - if ($globalDebug) echo "Add to DB..."; |
|
| 3117 | + if ($globalDebug) { |
|
| 3118 | + echo "Add to DB..."; |
|
| 3119 | + } |
|
| 2567 | 3120 | $error = update_db::satellite_fam(); |
| 2568 | - } else $error = "File ".$tmp_dir.'satellite.tsv.gz'." md5 failed. Download failed."; |
|
| 2569 | - } else $error = "File ".$tmp_dir.'satellite.tsv.gz'." doesn't exist. Download failed."; |
|
| 3121 | + } else { |
|
| 3122 | + $error = "File ".$tmp_dir.'satellite.tsv.gz'." md5 failed. Download failed."; |
|
| 3123 | + } |
|
| 3124 | + } else { |
|
| 3125 | + $error = "File ".$tmp_dir.'satellite.tsv.gz'." doesn't exist. Download failed."; |
|
| 3126 | + } |
|
| 2570 | 3127 | if ($error != '') { |
| 2571 | 3128 | return $error; |
| 2572 | 3129 | } else { |
| 2573 | 3130 | update_db::insert_satellite_version($satellite_md5); |
| 2574 | - if ($globalDebug) echo "Done\n"; |
|
| 3131 | + if ($globalDebug) { |
|
| 3132 | + echo "Done\n"; |
|
| 3133 | + } |
|
| 2575 | 3134 | } |
| 2576 | 3135 | } |
| 2577 | 3136 | } |
@@ -2579,17 +3138,25 @@ discard block |
||
| 2579 | 3138 | } |
| 2580 | 3139 | public static function update_banned_fam() { |
| 2581 | 3140 | global $tmp_dir, $globalDebug; |
| 2582 | - if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download..."; |
|
| 3141 | + if ($globalDebug) { |
|
| 3142 | + echo "Banned airlines in Europe from FlightAirMap website : Download..."; |
|
| 3143 | + } |
|
| 2583 | 3144 | update_db::download('http://data.flightairmap.com/data/ban-eu.csv',$tmp_dir.'ban_eu.csv'); |
| 2584 | 3145 | if (file_exists($tmp_dir.'ban_eu.csv')) { |
| 2585 | 3146 | //if ($globalDebug) echo "Gunzip..."; |
| 2586 | 3147 | //update_db::gunzip($tmp_dir.'ban_ue.csv'); |
| 2587 | - if ($globalDebug) echo "Add to DB..."; |
|
| 3148 | + if ($globalDebug) { |
|
| 3149 | + echo "Add to DB..."; |
|
| 3150 | + } |
|
| 2588 | 3151 | $error = update_db::banned_fam(); |
| 2589 | - } else $error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed."; |
|
| 3152 | + } else { |
|
| 3153 | + $error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed."; |
|
| 3154 | + } |
|
| 2590 | 3155 | if ($error != '') { |
| 2591 | 3156 | return $error; |
| 2592 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 3157 | + } elseif ($globalDebug) { |
|
| 3158 | + echo "Done\n"; |
|
| 3159 | + } |
|
| 2593 | 3160 | return ''; |
| 2594 | 3161 | } |
| 2595 | 3162 | |
@@ -2597,7 +3164,9 @@ discard block |
||
| 2597 | 3164 | global $tmp_dir, $globalDebug, $globalDBdriver; |
| 2598 | 3165 | include_once('class.create_db.php'); |
| 2599 | 3166 | $error = ''; |
| 2600 | - if ($globalDebug) echo "Airspace from FlightAirMap website : Download..."; |
|
| 3167 | + if ($globalDebug) { |
|
| 3168 | + echo "Airspace from FlightAirMap website : Download..."; |
|
| 3169 | + } |
|
| 2601 | 3170 | if ($globalDBdriver == 'mysql') { |
| 2602 | 3171 | update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); |
| 2603 | 3172 | } else { |
@@ -2614,9 +3183,13 @@ discard block |
||
| 2614 | 3183 | } |
| 2615 | 3184 | if (file_exists($tmp_dir.'airspace.sql.gz')) { |
| 2616 | 3185 | if (md5_file($tmp_dir.'airspace.sql.gz') == $airspace_md5) { |
| 2617 | - if ($globalDebug) echo "Gunzip..."; |
|
| 3186 | + if ($globalDebug) { |
|
| 3187 | + echo "Gunzip..."; |
|
| 3188 | + } |
|
| 2618 | 3189 | update_db::gunzip($tmp_dir.'airspace.sql.gz'); |
| 2619 | - if ($globalDebug) echo "Add to DB..."; |
|
| 3190 | + if ($globalDebug) { |
|
| 3191 | + echo "Add to DB..."; |
|
| 3192 | + } |
|
| 2620 | 3193 | $Connection = new Connection(); |
| 2621 | 3194 | if ($Connection->tableExists('airspace')) { |
| 2622 | 3195 | $query = 'DROP TABLE airspace'; |
@@ -2629,20 +3202,30 @@ discard block |
||
| 2629 | 3202 | } |
| 2630 | 3203 | $error = create_db::import_file($tmp_dir.'airspace.sql'); |
| 2631 | 3204 | update_db::insert_airspace_version($airspace_md5); |
| 2632 | - } else $error = "File ".$tmp_dir.'airspace.sql.gz'." md5 failed. Download failed."; |
|
| 2633 | - } else $error = "File ".$tmp_dir.'airspace.sql.gz'." doesn't exist. Download failed."; |
|
| 3205 | + } else { |
|
| 3206 | + $error = "File ".$tmp_dir.'airspace.sql.gz'." md5 failed. Download failed."; |
|
| 3207 | + } |
|
| 3208 | + } else { |
|
| 3209 | + $error = "File ".$tmp_dir.'airspace.sql.gz'." doesn't exist. Download failed."; |
|
| 3210 | + } |
|
| 2634 | 3211 | } |
| 2635 | - } else $error = "File ".$tmp_dir.'airspace.sql.gz.md5'." doesn't exist. Download failed."; |
|
| 3212 | + } else { |
|
| 3213 | + $error = "File ".$tmp_dir.'airspace.sql.gz.md5'." doesn't exist. Download failed."; |
|
| 3214 | + } |
|
| 2636 | 3215 | if ($error != '') { |
| 2637 | 3216 | return $error; |
| 2638 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 3217 | + } elseif ($globalDebug) { |
|
| 3218 | + echo "Done\n"; |
|
| 3219 | + } |
|
| 2639 | 3220 | return ''; |
| 2640 | 3221 | } |
| 2641 | 3222 | |
| 2642 | 3223 | public static function update_geoid_fam() { |
| 2643 | 3224 | global $tmp_dir, $globalDebug, $globalGeoidSource; |
| 2644 | 3225 | $error = ''; |
| 2645 | - if ($globalDebug) echo "Geoid from FlightAirMap website : Download..."; |
|
| 3226 | + if ($globalDebug) { |
|
| 3227 | + echo "Geoid from FlightAirMap website : Download..."; |
|
| 3228 | + } |
|
| 2646 | 3229 | update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5',$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'); |
| 2647 | 3230 | if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')) { |
| 2648 | 3231 | $geoid_md5_file = explode(' ',file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')); |
@@ -2651,76 +3234,116 @@ discard block |
||
| 2651 | 3234 | update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz',$tmp_dir.$globalGeoidSource.'.pgm.gz'); |
| 2652 | 3235 | if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz')) { |
| 2653 | 3236 | if (md5_file($tmp_dir.$globalGeoidSource.'.pgm.gz') == $geoid_md5) { |
| 2654 | - if ($globalDebug) echo "Gunzip..."; |
|
| 3237 | + if ($globalDebug) { |
|
| 3238 | + echo "Gunzip..."; |
|
| 3239 | + } |
|
| 2655 | 3240 | update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz',dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm'); |
| 2656 | 3241 | if (file_exists(dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm')) { |
| 2657 | 3242 | update_db::insert_geoid_version($geoid_md5); |
| 2658 | 3243 | } |
| 2659 | - } else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." md5 failed. Download failed."; |
|
| 2660 | - } else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed."; |
|
| 3244 | + } else { |
|
| 3245 | + $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." md5 failed. Download failed."; |
|
| 3246 | + } |
|
| 3247 | + } else { |
|
| 3248 | + $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed."; |
|
| 3249 | + } |
|
| 2661 | 3250 | } |
| 2662 | - } else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed."; |
|
| 3251 | + } else { |
|
| 3252 | + $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed."; |
|
| 3253 | + } |
|
| 2663 | 3254 | if ($error != '') { |
| 2664 | 3255 | return $error; |
| 2665 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 3256 | + } elseif ($globalDebug) { |
|
| 3257 | + echo "Done\n"; |
|
| 3258 | + } |
|
| 2666 | 3259 | return ''; |
| 2667 | 3260 | } |
| 2668 | 3261 | |
| 2669 | 3262 | public static function update_tle() { |
| 2670 | 3263 | global $tmp_dir, $globalDebug; |
| 2671 | - if ($globalDebug) echo "Download TLE : Download..."; |
|
| 3264 | + if ($globalDebug) { |
|
| 3265 | + echo "Download TLE : Download..."; |
|
| 3266 | + } |
|
| 2672 | 3267 | $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', |
| 2673 | 3268 | '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', |
| 2674 | 3269 | 'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt','visual.txt','sarsat.txt','argos.txt','ses.txt','iridium-NEXT.txt','beidou.txt'); |
| 2675 | 3270 | foreach ($alltle as $filename) { |
| 2676 | - if ($globalDebug) echo "downloading ".$filename.'...'; |
|
| 3271 | + if ($globalDebug) { |
|
| 3272 | + echo "downloading ".$filename.'...'; |
|
| 3273 | + } |
|
| 2677 | 3274 | update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename); |
| 2678 | 3275 | if (file_exists($tmp_dir.$filename)) { |
| 2679 | - if ($globalDebug) echo "Add to DB ".$filename."..."; |
|
| 3276 | + if ($globalDebug) { |
|
| 3277 | + echo "Add to DB ".$filename."..."; |
|
| 3278 | + } |
|
| 2680 | 3279 | $error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename)); |
| 2681 | - } else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
|
| 3280 | + } else { |
|
| 3281 | + $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
|
| 3282 | + } |
|
| 2682 | 3283 | if ($error != '') { |
| 2683 | 3284 | echo $error."\n"; |
| 2684 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 3285 | + } elseif ($globalDebug) { |
|
| 3286 | + echo "Done\n"; |
|
| 3287 | + } |
|
| 2685 | 3288 | } |
| 2686 | 3289 | return ''; |
| 2687 | 3290 | } |
| 2688 | 3291 | |
| 2689 | 3292 | public static function update_ucsdb() { |
| 2690 | 3293 | global $tmp_dir, $globalDebug; |
| 2691 | - if ($globalDebug) echo "Download UCS DB : Download..."; |
|
| 3294 | + if ($globalDebug) { |
|
| 3295 | + echo "Download UCS DB : Download..."; |
|
| 3296 | + } |
|
| 2692 | 3297 | update_db::download('https://s3.amazonaws.com/ucs-documents/nuclear-weapons/sat-database/4-11-17-update/UCS_Satellite_Database_officialname_1-1-17.txt',$tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt'); |
| 2693 | 3298 | if (file_exists($tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt')) { |
| 2694 | - if ($globalDebug) echo "Add to DB..."; |
|
| 3299 | + if ($globalDebug) { |
|
| 3300 | + echo "Add to DB..."; |
|
| 3301 | + } |
|
| 2695 | 3302 | $error = update_db::satellite_ucsdb($tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt'); |
| 2696 | - } else $error = "File ".$tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt'." doesn't exist. Download failed."; |
|
| 3303 | + } else { |
|
| 3304 | + $error = "File ".$tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt'." doesn't exist. Download failed."; |
|
| 3305 | + } |
|
| 2697 | 3306 | if ($error != '') { |
| 2698 | 3307 | echo $error."\n"; |
| 2699 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 3308 | + } elseif ($globalDebug) { |
|
| 3309 | + echo "Done\n"; |
|
| 3310 | + } |
|
| 2700 | 3311 | return ''; |
| 2701 | 3312 | } |
| 2702 | 3313 | |
| 2703 | 3314 | public static function update_celestrak() { |
| 2704 | 3315 | global $tmp_dir, $globalDebug; |
| 2705 | - if ($globalDebug) echo "Download Celestrak DB : Download..."; |
|
| 3316 | + if ($globalDebug) { |
|
| 3317 | + echo "Download Celestrak DB : Download..."; |
|
| 3318 | + } |
|
| 2706 | 3319 | update_db::download('http://celestrak.com/pub/satcat.txt',$tmp_dir.'satcat.txt'); |
| 2707 | 3320 | if (file_exists($tmp_dir.'satcat.txt')) { |
| 2708 | - if ($globalDebug) echo "Add to DB..."; |
|
| 3321 | + if ($globalDebug) { |
|
| 3322 | + echo "Add to DB..."; |
|
| 3323 | + } |
|
| 2709 | 3324 | $error = update_db::satellite_celestrak($tmp_dir.'satcat.txt'); |
| 2710 | - } else $error = "File ".$tmp_dir.'satcat.txt'." doesn't exist. Download failed."; |
|
| 3325 | + } else { |
|
| 3326 | + $error = "File ".$tmp_dir.'satcat.txt'." doesn't exist. Download failed."; |
|
| 3327 | + } |
|
| 2711 | 3328 | if ($error != '') { |
| 2712 | 3329 | echo $error."\n"; |
| 2713 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 3330 | + } elseif ($globalDebug) { |
|
| 3331 | + echo "Done\n"; |
|
| 3332 | + } |
|
| 2714 | 3333 | return ''; |
| 2715 | 3334 | } |
| 2716 | 3335 | |
| 2717 | 3336 | public static function update_models() { |
| 2718 | 3337 | global $tmp_dir, $globalDebug; |
| 2719 | 3338 | $error = ''; |
| 2720 | - if ($globalDebug) echo "Models from FlightAirMap website : Download..."; |
|
| 3339 | + if ($globalDebug) { |
|
| 3340 | + echo "Models from FlightAirMap website : Download..."; |
|
| 3341 | + } |
|
| 2721 | 3342 | update_db::download('http://data.flightairmap.com/data/models/models.md5sum',$tmp_dir.'models.md5sum'); |
| 2722 | 3343 | if (file_exists($tmp_dir.'models.md5sum')) { |
| 2723 | - if ($globalDebug) echo "Check files...\n"; |
|
| 3344 | + if ($globalDebug) { |
|
| 3345 | + echo "Check files...\n"; |
|
| 3346 | + } |
|
| 2724 | 3347 | $newmodelsdb = array(); |
| 2725 | 3348 | if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) { |
| 2726 | 3349 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2739,19 +3362,29 @@ discard block |
||
| 2739 | 3362 | } |
| 2740 | 3363 | $diff = array_diff($newmodelsdb,$modelsdb); |
| 2741 | 3364 | foreach ($diff as $key => $value) { |
| 2742 | - if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n"; |
|
| 3365 | + if ($globalDebug) { |
|
| 3366 | + echo 'Downloading model '.$key.' ...'."\n"; |
|
| 3367 | + } |
|
| 2743 | 3368 | update_db::download('http://data.flightairmap.com/data/models/'.$key,dirname(__FILE__).'/../models/'.$key); |
| 2744 | 3369 | |
| 2745 | 3370 | } |
| 2746 | 3371 | update_db::download('http://data.flightairmap.com/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum'); |
| 2747 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 3372 | + } else { |
|
| 3373 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 3374 | + } |
|
| 2748 | 3375 | if ($error != '') { |
| 2749 | 3376 | return $error; |
| 2750 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2751 | - if ($globalDebug) echo "glTF 2.0 Models from FlightAirMap website : Download..."; |
|
| 3377 | + } elseif ($globalDebug) { |
|
| 3378 | + echo "Done\n"; |
|
| 3379 | + } |
|
| 3380 | + if ($globalDebug) { |
|
| 3381 | + echo "glTF 2.0 Models from FlightAirMap website : Download..."; |
|
| 3382 | + } |
|
| 2752 | 3383 | update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum',$tmp_dir.'modelsgltf2.md5sum'); |
| 2753 | 3384 | if (file_exists($tmp_dir.'modelsgltf2.md5sum')) { |
| 2754 | - if ($globalDebug) echo "Check files...\n"; |
|
| 3385 | + if ($globalDebug) { |
|
| 3386 | + echo "Check files...\n"; |
|
| 3387 | + } |
|
| 2755 | 3388 | $newmodelsdb = array(); |
| 2756 | 3389 | if (($handle = fopen($tmp_dir.'modelsgltf2.md5sum','r')) !== FALSE) { |
| 2757 | 3390 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2770,25 +3403,35 @@ discard block |
||
| 2770 | 3403 | } |
| 2771 | 3404 | $diff = array_diff($newmodelsdb,$modelsdb); |
| 2772 | 3405 | foreach ($diff as $key => $value) { |
| 2773 | - if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n"; |
|
| 3406 | + if ($globalDebug) { |
|
| 3407 | + echo 'Downloading model '.$key.' ...'."\n"; |
|
| 3408 | + } |
|
| 2774 | 3409 | update_db::download('http://data.flightairmap.com/data/models/gltf2/'.$key,dirname(__FILE__).'/../models/gltf2/'.$key); |
| 2775 | 3410 | |
| 2776 | 3411 | } |
| 2777 | 3412 | update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum',dirname(__FILE__).'/../models/gltf2/models.md5sum'); |
| 2778 | - } else $error = "File ".$tmp_dir.'modelsgltf2.md5sum'." doesn't exist. Download failed."; |
|
| 3413 | + } else { |
|
| 3414 | + $error = "File ".$tmp_dir.'modelsgltf2.md5sum'." doesn't exist. Download failed."; |
|
| 3415 | + } |
|
| 2779 | 3416 | if ($error != '') { |
| 2780 | 3417 | return $error; |
| 2781 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 3418 | + } elseif ($globalDebug) { |
|
| 3419 | + echo "Done\n"; |
|
| 3420 | + } |
|
| 2782 | 3421 | return ''; |
| 2783 | 3422 | } |
| 2784 | 3423 | |
| 2785 | 3424 | public static function update_liveries() { |
| 2786 | 3425 | global $tmp_dir, $globalDebug; |
| 2787 | 3426 | $error = ''; |
| 2788 | - if ($globalDebug) echo "Liveries from FlightAirMap website : Download..."; |
|
| 3427 | + if ($globalDebug) { |
|
| 3428 | + echo "Liveries from FlightAirMap website : Download..."; |
|
| 3429 | + } |
|
| 2789 | 3430 | update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum',$tmp_dir.'liveries.md5sum'); |
| 2790 | 3431 | if (file_exists($tmp_dir.'liveries.md5sum')) { |
| 2791 | - if ($globalDebug) echo "Check files...\n"; |
|
| 3432 | + if ($globalDebug) { |
|
| 3433 | + echo "Check files...\n"; |
|
| 3434 | + } |
|
| 2792 | 3435 | $newmodelsdb = array(); |
| 2793 | 3436 | if (($handle = fopen($tmp_dir.'liveries.md5sum','r')) !== FALSE) { |
| 2794 | 3437 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2807,25 +3450,35 @@ discard block |
||
| 2807 | 3450 | } |
| 2808 | 3451 | $diff = array_diff($newmodelsdb,$modelsdb); |
| 2809 | 3452 | foreach ($diff as $key => $value) { |
| 2810 | - if ($globalDebug) echo 'Downloading liveries '.$key.' ...'."\n"; |
|
| 3453 | + if ($globalDebug) { |
|
| 3454 | + echo 'Downloading liveries '.$key.' ...'."\n"; |
|
| 3455 | + } |
|
| 2811 | 3456 | update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/'.$key,dirname(__FILE__).'/../models/gltf2/liveries/'.$key); |
| 2812 | 3457 | |
| 2813 | 3458 | } |
| 2814 | 3459 | update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum',dirname(__FILE__).'/../models/gltf2/liveries/liveries.md5sum'); |
| 2815 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 3460 | + } else { |
|
| 3461 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 3462 | + } |
|
| 2816 | 3463 | if ($error != '') { |
| 2817 | 3464 | return $error; |
| 2818 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 3465 | + } elseif ($globalDebug) { |
|
| 3466 | + echo "Done\n"; |
|
| 3467 | + } |
|
| 2819 | 3468 | return ''; |
| 2820 | 3469 | } |
| 2821 | 3470 | |
| 2822 | 3471 | public static function update_space_models() { |
| 2823 | 3472 | global $tmp_dir, $globalDebug; |
| 2824 | 3473 | $error = ''; |
| 2825 | - if ($globalDebug) echo "Space models from FlightAirMap website : Download..."; |
|
| 3474 | + if ($globalDebug) { |
|
| 3475 | + echo "Space models from FlightAirMap website : Download..."; |
|
| 3476 | + } |
|
| 2826 | 3477 | update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum'); |
| 2827 | 3478 | if (file_exists($tmp_dir.'space_models.md5sum')) { |
| 2828 | - if ($globalDebug) echo "Check files...\n"; |
|
| 3479 | + if ($globalDebug) { |
|
| 3480 | + echo "Check files...\n"; |
|
| 3481 | + } |
|
| 2829 | 3482 | $newmodelsdb = array(); |
| 2830 | 3483 | if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) { |
| 2831 | 3484 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2844,25 +3497,35 @@ discard block |
||
| 2844 | 3497 | } |
| 2845 | 3498 | $diff = array_diff($newmodelsdb,$modelsdb); |
| 2846 | 3499 | foreach ($diff as $key => $value) { |
| 2847 | - if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n"; |
|
| 3500 | + if ($globalDebug) { |
|
| 3501 | + echo 'Downloading space model '.$key.' ...'."\n"; |
|
| 3502 | + } |
|
| 2848 | 3503 | update_db::download('http://data.flightairmap.com/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key); |
| 2849 | 3504 | |
| 2850 | 3505 | } |
| 2851 | 3506 | update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum'); |
| 2852 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 3507 | + } else { |
|
| 3508 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 3509 | + } |
|
| 2853 | 3510 | if ($error != '') { |
| 2854 | 3511 | return $error; |
| 2855 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 3512 | + } elseif ($globalDebug) { |
|
| 3513 | + echo "Done\n"; |
|
| 3514 | + } |
|
| 2856 | 3515 | return ''; |
| 2857 | 3516 | } |
| 2858 | 3517 | |
| 2859 | 3518 | public static function update_vehicules_models() { |
| 2860 | 3519 | global $tmp_dir, $globalDebug; |
| 2861 | 3520 | $error = ''; |
| 2862 | - if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download..."; |
|
| 3521 | + if ($globalDebug) { |
|
| 3522 | + echo "Vehicules models from FlightAirMap website : Download..."; |
|
| 3523 | + } |
|
| 2863 | 3524 | update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum'); |
| 2864 | 3525 | if (file_exists($tmp_dir.'vehicules_models.md5sum')) { |
| 2865 | - if ($globalDebug) echo "Check files...\n"; |
|
| 3526 | + if ($globalDebug) { |
|
| 3527 | + echo "Check files...\n"; |
|
| 3528 | + } |
|
| 2866 | 3529 | $newmodelsdb = array(); |
| 2867 | 3530 | if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) { |
| 2868 | 3531 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2881,15 +3544,21 @@ discard block |
||
| 2881 | 3544 | } |
| 2882 | 3545 | $diff = array_diff($newmodelsdb,$modelsdb); |
| 2883 | 3546 | foreach ($diff as $key => $value) { |
| 2884 | - if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n"; |
|
| 3547 | + if ($globalDebug) { |
|
| 3548 | + echo 'Downloading vehicules model '.$key.' ...'."\n"; |
|
| 3549 | + } |
|
| 2885 | 3550 | update_db::download('http://data.flightairmap.com/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key); |
| 2886 | 3551 | |
| 2887 | 3552 | } |
| 2888 | 3553 | update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum'); |
| 2889 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 3554 | + } else { |
|
| 3555 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 3556 | + } |
|
| 2890 | 3557 | if ($error != '') { |
| 2891 | 3558 | return $error; |
| 2892 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 3559 | + } elseif ($globalDebug) { |
|
| 3560 | + echo "Done\n"; |
|
| 3561 | + } |
|
| 2893 | 3562 | return ''; |
| 2894 | 3563 | } |
| 2895 | 3564 | |
@@ -2962,7 +3631,9 @@ discard block |
||
| 2962 | 3631 | } |
| 2963 | 3632 | |
| 2964 | 3633 | $error = ''; |
| 2965 | - if ($globalDebug) echo "Notam : Download..."; |
|
| 3634 | + if ($globalDebug) { |
|
| 3635 | + echo "Notam : Download..."; |
|
| 3636 | + } |
|
| 2966 | 3637 | update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss'); |
| 2967 | 3638 | if (file_exists($tmp_dir.'notam.rss')) { |
| 2968 | 3639 | $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true); |
@@ -2977,14 +3648,30 @@ discard block |
||
| 2977 | 3648 | $data['fir'] = $q[0]; |
| 2978 | 3649 | $data['code'] = $q[1]; |
| 2979 | 3650 | $ifrvfr = $q[2]; |
| 2980 | - if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR'; |
|
| 2981 | - if ($ifrvfr == 'I') $data['rules'] = 'IFR'; |
|
| 2982 | - if ($ifrvfr == 'V') $data['rules'] = 'VFR'; |
|
| 2983 | - if ($q[4] == 'A') $data['scope'] = 'Airport warning'; |
|
| 2984 | - if ($q[4] == 'E') $data['scope'] = 'Enroute warning'; |
|
| 2985 | - if ($q[4] == 'W') $data['scope'] = 'Navigation warning'; |
|
| 2986 | - if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning'; |
|
| 2987 | - if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning'; |
|
| 3651 | + if ($ifrvfr == 'IV') { |
|
| 3652 | + $data['rules'] = 'IFR/VFR'; |
|
| 3653 | + } |
|
| 3654 | + if ($ifrvfr == 'I') { |
|
| 3655 | + $data['rules'] = 'IFR'; |
|
| 3656 | + } |
|
| 3657 | + if ($ifrvfr == 'V') { |
|
| 3658 | + $data['rules'] = 'VFR'; |
|
| 3659 | + } |
|
| 3660 | + if ($q[4] == 'A') { |
|
| 3661 | + $data['scope'] = 'Airport warning'; |
|
| 3662 | + } |
|
| 3663 | + if ($q[4] == 'E') { |
|
| 3664 | + $data['scope'] = 'Enroute warning'; |
|
| 3665 | + } |
|
| 3666 | + if ($q[4] == 'W') { |
|
| 3667 | + $data['scope'] = 'Navigation warning'; |
|
| 3668 | + } |
|
| 3669 | + if ($q[4] == 'AE') { |
|
| 3670 | + $data['scope'] = 'Airport/Enroute warning'; |
|
| 3671 | + } |
|
| 3672 | + if ($q[4] == 'AW') { |
|
| 3673 | + $data['scope'] = 'Airport/Navigation warning'; |
|
| 3674 | + } |
|
| 2988 | 3675 | //$data['scope'] = $q[4]; |
| 2989 | 3676 | $data['lower_limit'] = $q[5]; |
| 2990 | 3677 | $data['upper_limit'] = $q[6]; |
@@ -2992,8 +3679,12 @@ discard block |
||
| 2992 | 3679 | sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius); |
| 2993 | 3680 | $latitude = $Common->convertDec($las,'latitude'); |
| 2994 | 3681 | $longitude = $Common->convertDec($lns,'longitude'); |
| 2995 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
| 2996 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
| 3682 | + if ($lac == 'S') { |
|
| 3683 | + $latitude = '-'.$latitude; |
|
| 3684 | + } |
|
| 3685 | + if ($lnc == 'W') { |
|
| 3686 | + $longitude = '-'.$longitude; |
|
| 3687 | + } |
|
| 2997 | 3688 | $data['center_latitude'] = $latitude; |
| 2998 | 3689 | $data['center_longitude'] = $longitude; |
| 2999 | 3690 | $data['radius'] = intval($radius); |
@@ -3023,10 +3714,14 @@ discard block |
||
| 3023 | 3714 | $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']); |
| 3024 | 3715 | unset($data); |
| 3025 | 3716 | } |
| 3026 | - } else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
|
| 3717 | + } else { |
|
| 3718 | + $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
|
| 3719 | + } |
|
| 3027 | 3720 | if ($error != '') { |
| 3028 | 3721 | return $error; |
| 3029 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 3722 | + } elseif ($globalDebug) { |
|
| 3723 | + echo "Done\n"; |
|
| 3724 | + } |
|
| 3030 | 3725 | return ''; |
| 3031 | 3726 | } |
| 3032 | 3727 | |
@@ -3051,7 +3746,9 @@ discard block |
||
| 3051 | 3746 | $airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json'); |
| 3052 | 3747 | $airspace_json = json_decode($airspace_lst,true); |
| 3053 | 3748 | foreach ($airspace_json['records'] as $airspace) { |
| 3054 | - if ($globalDebug) echo $airspace['name']."...\n"; |
|
| 3749 | + if ($globalDebug) { |
|
| 3750 | + echo $airspace['name']."...\n"; |
|
| 3751 | + } |
|
| 3055 | 3752 | update_db::download($airspace['uri'],$tmp_dir.$airspace['name']); |
| 3056 | 3753 | if (file_exists($tmp_dir.$airspace['name'])) { |
| 3057 | 3754 | file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name']))); |
@@ -3095,8 +3792,11 @@ discard block |
||
| 3095 | 3792 | return "error : ".$e->getMessage(); |
| 3096 | 3793 | } |
| 3097 | 3794 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3098 | - if ($row['nb'] > 0) return false; |
|
| 3099 | - else return true; |
|
| 3795 | + if ($row['nb'] > 0) { |
|
| 3796 | + return false; |
|
| 3797 | + } else { |
|
| 3798 | + return true; |
|
| 3799 | + } |
|
| 3100 | 3800 | } |
| 3101 | 3801 | |
| 3102 | 3802 | public static function insert_last_update() { |
@@ -3121,8 +3821,11 @@ discard block |
||
| 3121 | 3821 | return "error : ".$e->getMessage(); |
| 3122 | 3822 | } |
| 3123 | 3823 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3124 | - if ($row['nb'] > 0) return true; |
|
| 3125 | - else return false; |
|
| 3824 | + if ($row['nb'] > 0) { |
|
| 3825 | + return true; |
|
| 3826 | + } else { |
|
| 3827 | + return false; |
|
| 3828 | + } |
|
| 3126 | 3829 | } |
| 3127 | 3830 | |
| 3128 | 3831 | public static function check_geoid_version($version) { |
@@ -3135,8 +3838,11 @@ discard block |
||
| 3135 | 3838 | return "error : ".$e->getMessage(); |
| 3136 | 3839 | } |
| 3137 | 3840 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3138 | - if ($row['nb'] > 0) return true; |
|
| 3139 | - else return false; |
|
| 3841 | + if ($row['nb'] > 0) { |
|
| 3842 | + return true; |
|
| 3843 | + } else { |
|
| 3844 | + return false; |
|
| 3845 | + } |
|
| 3140 | 3846 | } |
| 3141 | 3847 | |
| 3142 | 3848 | public static function check_marine_identity_version($version) { |
@@ -3149,8 +3855,11 @@ discard block |
||
| 3149 | 3855 | return "error : ".$e->getMessage(); |
| 3150 | 3856 | } |
| 3151 | 3857 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3152 | - if ($row['nb'] > 0) return true; |
|
| 3153 | - else return false; |
|
| 3858 | + if ($row['nb'] > 0) { |
|
| 3859 | + return true; |
|
| 3860 | + } else { |
|
| 3861 | + return false; |
|
| 3862 | + } |
|
| 3154 | 3863 | } |
| 3155 | 3864 | |
| 3156 | 3865 | public static function check_satellite_version($version) { |
@@ -3163,8 +3872,11 @@ discard block |
||
| 3163 | 3872 | return "error : ".$e->getMessage(); |
| 3164 | 3873 | } |
| 3165 | 3874 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3166 | - if ($row['nb'] > 0) return true; |
|
| 3167 | - else return false; |
|
| 3875 | + if ($row['nb'] > 0) { |
|
| 3876 | + return true; |
|
| 3877 | + } else { |
|
| 3878 | + return false; |
|
| 3879 | + } |
|
| 3168 | 3880 | } |
| 3169 | 3881 | |
| 3170 | 3882 | public static function check_airlines_version($version) { |
@@ -3177,8 +3889,11 @@ discard block |
||
| 3177 | 3889 | return "error : ".$e->getMessage(); |
| 3178 | 3890 | } |
| 3179 | 3891 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3180 | - if ($row['nb'] > 0) return true; |
|
| 3181 | - else return false; |
|
| 3892 | + if ($row['nb'] > 0) { |
|
| 3893 | + return true; |
|
| 3894 | + } else { |
|
| 3895 | + return false; |
|
| 3896 | + } |
|
| 3182 | 3897 | } |
| 3183 | 3898 | |
| 3184 | 3899 | public static function check_notam_version($version) { |
@@ -3191,8 +3906,11 @@ discard block |
||
| 3191 | 3906 | return "error : ".$e->getMessage(); |
| 3192 | 3907 | } |
| 3193 | 3908 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3194 | - if ($row['nb'] > 0) return true; |
|
| 3195 | - else return false; |
|
| 3909 | + if ($row['nb'] > 0) { |
|
| 3910 | + return true; |
|
| 3911 | + } else { |
|
| 3912 | + return false; |
|
| 3913 | + } |
|
| 3196 | 3914 | } |
| 3197 | 3915 | |
| 3198 | 3916 | public static function insert_airlines_version($version) { |
@@ -3282,8 +4000,11 @@ discard block |
||
| 3282 | 4000 | return "error : ".$e->getMessage(); |
| 3283 | 4001 | } |
| 3284 | 4002 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3285 | - if ($row['nb'] > 0) return false; |
|
| 3286 | - else return true; |
|
| 4003 | + if ($row['nb'] > 0) { |
|
| 4004 | + return false; |
|
| 4005 | + } else { |
|
| 4006 | + return true; |
|
| 4007 | + } |
|
| 3287 | 4008 | } |
| 3288 | 4009 | |
| 3289 | 4010 | public static function insert_last_notam_update() { |
@@ -3313,8 +4034,11 @@ discard block |
||
| 3313 | 4034 | return "error : ".$e->getMessage(); |
| 3314 | 4035 | } |
| 3315 | 4036 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3316 | - if ($row['nb'] > 0) return false; |
|
| 3317 | - else return true; |
|
| 4037 | + if ($row['nb'] > 0) { |
|
| 4038 | + return false; |
|
| 4039 | + } else { |
|
| 4040 | + return true; |
|
| 4041 | + } |
|
| 3318 | 4042 | } |
| 3319 | 4043 | |
| 3320 | 4044 | public static function insert_last_airspace_update() { |
@@ -3344,8 +4068,11 @@ discard block |
||
| 3344 | 4068 | return "error : ".$e->getMessage(); |
| 3345 | 4069 | } |
| 3346 | 4070 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3347 | - if ($row['nb'] > 0) return false; |
|
| 3348 | - else return true; |
|
| 4071 | + if ($row['nb'] > 0) { |
|
| 4072 | + return false; |
|
| 4073 | + } else { |
|
| 4074 | + return true; |
|
| 4075 | + } |
|
| 3349 | 4076 | } |
| 3350 | 4077 | |
| 3351 | 4078 | public static function insert_last_geoid_update() { |
@@ -3375,8 +4102,11 @@ discard block |
||
| 3375 | 4102 | return "error : ".$e->getMessage(); |
| 3376 | 4103 | } |
| 3377 | 4104 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3378 | - if ($row['nb'] > 0) return false; |
|
| 3379 | - else return true; |
|
| 4105 | + if ($row['nb'] > 0) { |
|
| 4106 | + return false; |
|
| 4107 | + } else { |
|
| 4108 | + return true; |
|
| 4109 | + } |
|
| 3380 | 4110 | } |
| 3381 | 4111 | |
| 3382 | 4112 | public static function insert_last_owner_update() { |
@@ -3406,8 +4136,11 @@ discard block |
||
| 3406 | 4136 | return "error : ".$e->getMessage(); |
| 3407 | 4137 | } |
| 3408 | 4138 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3409 | - if ($row['nb'] > 0) return false; |
|
| 3410 | - else return true; |
|
| 4139 | + if ($row['nb'] > 0) { |
|
| 4140 | + return false; |
|
| 4141 | + } else { |
|
| 4142 | + return true; |
|
| 4143 | + } |
|
| 3411 | 4144 | } |
| 3412 | 4145 | |
| 3413 | 4146 | public static function insert_last_fires_update() { |
@@ -3437,8 +4170,11 @@ discard block |
||
| 3437 | 4170 | return "error : ".$e->getMessage(); |
| 3438 | 4171 | } |
| 3439 | 4172 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3440 | - if ($row['nb'] > 0) return false; |
|
| 3441 | - else return true; |
|
| 4173 | + if ($row['nb'] > 0) { |
|
| 4174 | + return false; |
|
| 4175 | + } else { |
|
| 4176 | + return true; |
|
| 4177 | + } |
|
| 3442 | 4178 | } |
| 3443 | 4179 | |
| 3444 | 4180 | public static function insert_last_airlines_update() { |
@@ -3468,8 +4204,11 @@ discard block |
||
| 3468 | 4204 | return "error : ".$e->getMessage(); |
| 3469 | 4205 | } |
| 3470 | 4206 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3471 | - if ($row['nb'] > 0) return false; |
|
| 3472 | - else return true; |
|
| 4207 | + if ($row['nb'] > 0) { |
|
| 4208 | + return false; |
|
| 4209 | + } else { |
|
| 4210 | + return true; |
|
| 4211 | + } |
|
| 3473 | 4212 | } |
| 3474 | 4213 | |
| 3475 | 4214 | public static function insert_last_schedules_update() { |
@@ -3499,8 +4238,11 @@ discard block |
||
| 3499 | 4238 | return "error : ".$e->getMessage(); |
| 3500 | 4239 | } |
| 3501 | 4240 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3502 | - if ($row['nb'] > 0) return false; |
|
| 3503 | - else return true; |
|
| 4241 | + if ($row['nb'] > 0) { |
|
| 4242 | + return false; |
|
| 4243 | + } else { |
|
| 4244 | + return true; |
|
| 4245 | + } |
|
| 3504 | 4246 | } |
| 3505 | 4247 | |
| 3506 | 4248 | public static function insert_last_tle_update() { |
@@ -3530,8 +4272,11 @@ discard block |
||
| 3530 | 4272 | return "error : ".$e->getMessage(); |
| 3531 | 4273 | } |
| 3532 | 4274 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3533 | - if ($row['nb'] > 0) return false; |
|
| 3534 | - else return true; |
|
| 4275 | + if ($row['nb'] > 0) { |
|
| 4276 | + return false; |
|
| 4277 | + } else { |
|
| 4278 | + return true; |
|
| 4279 | + } |
|
| 3535 | 4280 | } |
| 3536 | 4281 | |
| 3537 | 4282 | public static function insert_last_ucsdb_update() { |
@@ -3561,8 +4306,11 @@ discard block |
||
| 3561 | 4306 | return "error : ".$e->getMessage(); |
| 3562 | 4307 | } |
| 3563 | 4308 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3564 | - if ($row['nb'] > 0) return false; |
|
| 3565 | - else return true; |
|
| 4309 | + if ($row['nb'] > 0) { |
|
| 4310 | + return false; |
|
| 4311 | + } else { |
|
| 4312 | + return true; |
|
| 4313 | + } |
|
| 3566 | 4314 | } |
| 3567 | 4315 | |
| 3568 | 4316 | public static function insert_last_celestrak_update() { |
@@ -3592,8 +4340,11 @@ discard block |
||
| 3592 | 4340 | return "error : ".$e->getMessage(); |
| 3593 | 4341 | } |
| 3594 | 4342 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3595 | - if ($row['nb'] > 0) return false; |
|
| 3596 | - else return true; |
|
| 4343 | + if ($row['nb'] > 0) { |
|
| 4344 | + return false; |
|
| 4345 | + } else { |
|
| 4346 | + return true; |
|
| 4347 | + } |
|
| 3597 | 4348 | } |
| 3598 | 4349 | |
| 3599 | 4350 | public static function check_last_satellite_update() { |
@@ -3611,8 +4362,11 @@ discard block |
||
| 3611 | 4362 | return "error : ".$e->getMessage(); |
| 3612 | 4363 | } |
| 3613 | 4364 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3614 | - if ($row['nb'] > 0) return false; |
|
| 3615 | - else return true; |
|
| 4365 | + if ($row['nb'] > 0) { |
|
| 4366 | + return false; |
|
| 4367 | + } else { |
|
| 4368 | + return true; |
|
| 4369 | + } |
|
| 3616 | 4370 | } |
| 3617 | 4371 | |
| 3618 | 4372 | public static function insert_last_marine_identity_update() { |