@@ -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]; |
@@ -988,7 +988,7 @@ discard block |
||
| 988 | 988 | try { |
| 989 | 989 | $sth = $this->db->prepare($query); |
| 990 | 990 | $sth->execute($query_values); |
| 991 | - } catch(PDOException $e) { |
|
| 991 | + } catch (PDOException $e) { |
|
| 992 | 992 | echo "error : ".$e->getMessage(); |
| 993 | 993 | } |
| 994 | 994 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1005,19 +1005,19 @@ discard block |
||
| 1005 | 1005 | try { |
| 1006 | 1006 | $sth = $this->db->prepare($query); |
| 1007 | 1007 | $sth->execute($query_values); |
| 1008 | - } catch(PDOException $e) { |
|
| 1008 | + } catch (PDOException $e) { |
|
| 1009 | 1009 | echo "error : ".$e->getMessage(); |
| 1010 | 1010 | } |
| 1011 | 1011 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1012 | 1012 | return $all; |
| 1013 | 1013 | } |
| 1014 | 1014 | public function getAllNOTAMtext() { |
| 1015 | - $query = 'SELECT full_notam FROM notam'; |
|
| 1015 | + $query = 'SELECT full_notam FROM notam'; |
|
| 1016 | 1016 | $query_values = array(); |
| 1017 | 1017 | try { |
| 1018 | 1018 | $sth = $this->db->prepare($query); |
| 1019 | 1019 | $sth->execute($query_values); |
| 1020 | - } catch(PDOException $e) { |
|
| 1020 | + } catch (PDOException $e) { |
|
| 1021 | 1021 | echo "error : ".$e->getMessage(); |
| 1022 | 1022 | } |
| 1023 | 1023 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1026,12 +1026,12 @@ discard block |
||
| 1026 | 1026 | public function createNOTAMtextFile($filename) { |
| 1027 | 1027 | $allnotam_result = $this->getAllNOTAMtext(); |
| 1028 | 1028 | $notamtext = ''; |
| 1029 | - foreach($allnotam_result as $notam) { |
|
| 1029 | + foreach ($allnotam_result as $notam) { |
|
| 1030 | 1030 | $notamtext .= '%%'."\n"; |
| 1031 | 1031 | $notamtext .= $notam['full_notam']; |
| 1032 | 1032 | $notamtext .= "\n".'%%'."\n"; |
| 1033 | 1033 | } |
| 1034 | - file_put_contents($filename,$notamtext); |
|
| 1034 | + file_put_contents($filename, $notamtext); |
|
| 1035 | 1035 | } |
| 1036 | 1036 | public function parseNOTAMtextFile($filename) { |
| 1037 | 1037 | $data = file_get_contents($filename); |
@@ -1050,7 +1050,7 @@ discard block |
||
| 1050 | 1050 | try { |
| 1051 | 1051 | $sth = $this->db->prepare($query); |
| 1052 | 1052 | $sth->execute($query_values); |
| 1053 | - } catch(PDOException $e) { |
|
| 1053 | + } catch (PDOException $e) { |
|
| 1054 | 1054 | echo "error : ".$e->getMessage(); |
| 1055 | 1055 | } |
| 1056 | 1056 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1059,10 +1059,10 @@ discard block |
||
| 1059 | 1059 | public function getAllNOTAMbyCoord($coord) { |
| 1060 | 1060 | global $globalDBdriver; |
| 1061 | 1061 | if (is_array($coord)) { |
| 1062 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1063 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1064 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1065 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1062 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1063 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1064 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1065 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1066 | 1066 | if ($minlat > $maxlat) { |
| 1067 | 1067 | $tmplat = $minlat; |
| 1068 | 1068 | $minlat = $maxlat; |
@@ -1083,19 +1083,19 @@ discard block |
||
| 1083 | 1083 | try { |
| 1084 | 1084 | $sth = $this->db->prepare($query); |
| 1085 | 1085 | $sth->execute($query_values); |
| 1086 | - } catch(PDOException $e) { |
|
| 1086 | + } catch (PDOException $e) { |
|
| 1087 | 1087 | echo "error : ".$e->getMessage(); |
| 1088 | 1088 | } |
| 1089 | 1089 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1090 | 1090 | return $all; |
| 1091 | 1091 | } |
| 1092 | - public function getAllNOTAMbyCoordScope($coord,$scope) { |
|
| 1092 | + public function getAllNOTAMbyCoordScope($coord, $scope) { |
|
| 1093 | 1093 | global $globalDBdriver; |
| 1094 | 1094 | if (is_array($coord)) { |
| 1095 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1096 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1097 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1098 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1095 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1096 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1097 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1098 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1099 | 1099 | } else return array(); |
| 1100 | 1100 | if ($globalDBdriver == 'mysql') { |
| 1101 | 1101 | $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'; |
@@ -1106,7 +1106,7 @@ discard block |
||
| 1106 | 1106 | try { |
| 1107 | 1107 | $sth = $this->db->prepare($query); |
| 1108 | 1108 | $sth->execute($query_values); |
| 1109 | - } catch(PDOException $e) { |
|
| 1109 | + } catch (PDOException $e) { |
|
| 1110 | 1110 | echo "error : ".$e->getMessage(); |
| 1111 | 1111 | } |
| 1112 | 1112 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1118,7 +1118,7 @@ discard block |
||
| 1118 | 1118 | try { |
| 1119 | 1119 | $sth = $this->db->prepare($query); |
| 1120 | 1120 | $sth->execute($query_values); |
| 1121 | - } catch(PDOException $e) { |
|
| 1121 | + } catch (PDOException $e) { |
|
| 1122 | 1122 | return "error : ".$e->getMessage(); |
| 1123 | 1123 | } |
| 1124 | 1124 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1126,13 +1126,13 @@ discard block |
||
| 1126 | 1126 | else return array(); |
| 1127 | 1127 | } |
| 1128 | 1128 | |
| 1129 | - 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) { |
|
| 1129 | + 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 | 1130 | $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 | - $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); |
|
| 1131 | + $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); |
|
| 1132 | 1132 | try { |
| 1133 | 1133 | $sth = $this->db->prepare($query); |
| 1134 | 1134 | $sth->execute($query_values); |
| 1135 | - } catch(PDOException $e) { |
|
| 1135 | + } catch (PDOException $e) { |
|
| 1136 | 1136 | return "error : ".$e->getMessage(); |
| 1137 | 1137 | } |
| 1138 | 1138 | } |
@@ -1143,7 +1143,7 @@ discard block |
||
| 1143 | 1143 | try { |
| 1144 | 1144 | $sth = $this->db->prepare($query); |
| 1145 | 1145 | $sth->execute($query_values); |
| 1146 | - } catch(PDOException $e) { |
|
| 1146 | + } catch (PDOException $e) { |
|
| 1147 | 1147 | return "error : ".$e->getMessage(); |
| 1148 | 1148 | } |
| 1149 | 1149 | } |
@@ -1158,7 +1158,7 @@ discard block |
||
| 1158 | 1158 | try { |
| 1159 | 1159 | $sth = $this->db->prepare($query); |
| 1160 | 1160 | $sth->execute($query_values); |
| 1161 | - } catch(PDOException $e) { |
|
| 1161 | + } catch (PDOException $e) { |
|
| 1162 | 1162 | return "error : ".$e->getMessage(); |
| 1163 | 1163 | } |
| 1164 | 1164 | } |
@@ -1168,7 +1168,7 @@ discard block |
||
| 1168 | 1168 | try { |
| 1169 | 1169 | $sth = $this->db->prepare($query); |
| 1170 | 1170 | $sth->execute($query_values); |
| 1171 | - } catch(PDOException $e) { |
|
| 1171 | + } catch (PDOException $e) { |
|
| 1172 | 1172 | return "error : ".$e->getMessage(); |
| 1173 | 1173 | } |
| 1174 | 1174 | } |
@@ -1177,7 +1177,7 @@ discard block |
||
| 1177 | 1177 | try { |
| 1178 | 1178 | $sth = $this->db->prepare($query); |
| 1179 | 1179 | $sth->execute(); |
| 1180 | - } catch(PDOException $e) { |
|
| 1180 | + } catch (PDOException $e) { |
|
| 1181 | 1181 | return "error : ".$e->getMessage(); |
| 1182 | 1182 | } |
| 1183 | 1183 | } |
@@ -1186,7 +1186,7 @@ discard block |
||
| 1186 | 1186 | try { |
| 1187 | 1187 | $sth = $this->db->prepare($query); |
| 1188 | 1188 | $sth->execute(); |
| 1189 | - } catch(PDOException $e) { |
|
| 1189 | + } catch (PDOException $e) { |
|
| 1190 | 1190 | return "error : ".$e->getMessage(); |
| 1191 | 1191 | } |
| 1192 | 1192 | } |
@@ -1194,14 +1194,14 @@ discard block |
||
| 1194 | 1194 | public function updateNOTAM() { |
| 1195 | 1195 | global $globalNOTAMAirports; |
| 1196 | 1196 | if (isset($globalNOTAMAirports) && is_array($globalNOTAMAirports) && count($globalNOTAMAirports) > 0) { |
| 1197 | - foreach (array_chunk($globalNOTAMAirports,10) as $airport) { |
|
| 1198 | - $airport_icao = implode(',',$airport); |
|
| 1197 | + foreach (array_chunk($globalNOTAMAirports, 10) as $airport) { |
|
| 1198 | + $airport_icao = implode(',', $airport); |
|
| 1199 | 1199 | $alldata = $this->downloadNOTAM($airport_icao); |
| 1200 | 1200 | if (count($alldata) > 0) { |
| 1201 | 1201 | foreach ($alldata as $initial_data) { |
| 1202 | 1202 | $data = $this->parse($initial_data); |
| 1203 | 1203 | $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']); |
|
| 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']); |
|
| 1205 | 1205 | } |
| 1206 | 1206 | } |
| 1207 | 1207 | } |
@@ -1218,8 +1218,8 @@ discard block |
||
| 1218 | 1218 | $j++; |
| 1219 | 1219 | $data = $this->parse($initial_data); |
| 1220 | 1220 | $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']); |
|
| 1222 | - if ($globalTransaction && $j % 1000 == 0) { |
|
| 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']); |
|
| 1222 | + if ($globalTransaction && $j%1000 == 0) { |
|
| 1223 | 1223 | $this->db->commit(); |
| 1224 | 1224 | if ($globalDebug) echo '.'; |
| 1225 | 1225 | $this->db->beginTransaction(); |
@@ -1233,12 +1233,12 @@ discard block |
||
| 1233 | 1233 | global $globalTransaction; |
| 1234 | 1234 | $Spotter = new Spotter($this->db); |
| 1235 | 1235 | $allairports = $Spotter->getAllAirportInfo(); |
| 1236 | - foreach (array_chunk($allairports,20) as $airport) { |
|
| 1236 | + foreach (array_chunk($allairports, 20) as $airport) { |
|
| 1237 | 1237 | $airports_icao = array(); |
| 1238 | - foreach($airport as $icao) { |
|
| 1238 | + foreach ($airport as $icao) { |
|
| 1239 | 1239 | if (isset($icao['icao'])) $airports_icao[] = $icao['icao']; |
| 1240 | 1240 | } |
| 1241 | - $airport_icao = implode(',',$airports_icao); |
|
| 1241 | + $airport_icao = implode(',', $airports_icao); |
|
| 1242 | 1242 | $alldata = $this->downloadNOTAM($airport_icao); |
| 1243 | 1243 | if ($globalTransaction) $this->db->beginTransaction(); |
| 1244 | 1244 | if (count($alldata) > 0) { |
@@ -1251,7 +1251,7 @@ discard block |
||
| 1251 | 1251 | if (count($notamref) == 0) { |
| 1252 | 1252 | if (isset($data['ref_replaced'])) $this->deleteNOTAMbyRef($data['ref_replaced']); |
| 1253 | 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']); |
|
| 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']); |
|
| 1255 | 1255 | } |
| 1256 | 1256 | } |
| 1257 | 1257 | } |
@@ -1265,7 +1265,7 @@ discard block |
||
| 1265 | 1265 | date_default_timezone_set("UTC"); |
| 1266 | 1266 | $Common = new Common(); |
| 1267 | 1267 | //$url = str_replace('{icao}',$icao,'https://pilotweb.nas.faa.gov/PilotWeb/notamRetrievalByICAOAction.do?method=displayByICAOs&reportType=RAW&formatType=DOMESTIC&retrieveLocId={icao}&actionType=notamRetrievalByICAOs'); |
| 1268 | - $url = str_replace('{icao}',$icao,'https://pilotweb.nas.faa.gov/PilotWeb/notamRetrievalByICAOAction.do?method=displayByICAOs&reportType=RAW&formatType=ICAO&retrieveLocId={icao}&actionType=notamRetrievalByICAOs'); |
|
| 1268 | + $url = str_replace('{icao}', $icao, 'https://pilotweb.nas.faa.gov/PilotWeb/notamRetrievalByICAOAction.do?method=displayByICAOs&reportType=RAW&formatType=ICAO&retrieveLocId={icao}&actionType=notamRetrievalByICAOs'); |
|
| 1269 | 1269 | $data = $Common->getData($url); |
| 1270 | 1270 | preg_match_all("/<pre>(.+?)<\/pre>/is", $data, $matches); |
| 1271 | 1271 | //print_r($matches); |
@@ -1282,8 +1282,8 @@ discard block |
||
| 1282 | 1282 | $result['permanent'] = ''; |
| 1283 | 1283 | $result['date_begin'] = NULL; |
| 1284 | 1284 | $result['date_end'] = NULL; |
| 1285 | - $data = str_ireplace(array("\r","\n",'\r','\n'),' ',$data); |
|
| 1286 | - $data = preg_split('#\s(?=([A-Z]\)\s))#',$data); |
|
| 1285 | + $data = str_ireplace(array("\r", "\n", '\r', '\n'), ' ', $data); |
|
| 1286 | + $data = preg_split('#\s(?=([A-Z]\)\s))#', $data); |
|
| 1287 | 1287 | $q = false; |
| 1288 | 1288 | $a = false; |
| 1289 | 1289 | $b = false; |
@@ -1291,9 +1291,9 @@ discard block |
||
| 1291 | 1291 | $e = false; |
| 1292 | 1292 | foreach ($data as $line) { |
| 1293 | 1293 | $line = trim($line); |
| 1294 | - if (preg_match('#(^|\s)Q\) (.*)#',$line,$matches) && $q === false) { |
|
| 1295 | - $line = str_replace(' ','',$line); |
|
| 1296 | - if (preg_match('#Q\)([A-Z]{3,4})\/([A-Z]{5})\/(IV|I|V)\/([A-Z]{1,3})\/([A-Z]{1,2})\/([0-9]{3})\/([0-9]{3})\/([0-9]{4})(N|S)([0-9]{5})(E|W)([0-9]{3}|)#',$line,$matches)) { |
|
| 1294 | + if (preg_match('#(^|\s)Q\) (.*)#', $line, $matches) && $q === false) { |
|
| 1295 | + $line = str_replace(' ', '', $line); |
|
| 1296 | + if (preg_match('#Q\)([A-Z]{3,4})\/([A-Z]{5})\/(IV|I|V)\/([A-Z]{1,3})\/([A-Z]{1,2})\/([0-9]{3})\/([0-9]{3})\/([0-9]{4})(N|S)([0-9]{5})(E|W)([0-9]{3}|)#', $line, $matches)) { |
|
| 1297 | 1297 | //if (preg_match('#Q\)([A-Z]{4})\/([A-Z]{5})\/(IV|I|V)\/([A-Z]{1,3})\/([A-Z]{1,2})\/([0-9]{3})\/([0-9]{3})\/([0-9]{4})(N|S)([0-9]{5})(E|W)([0-9]{3})#',$line,$matches)) { |
| 1298 | 1298 | $result['fir'] = $matches[1]; |
| 1299 | 1299 | $result['code'] = $matches[2]; |
@@ -1338,9 +1338,9 @@ discard block |
||
| 1338 | 1338 | elseif ($matches[5] == 'AW') $result['scope'] = 'Airport/Navigation warning'; |
| 1339 | 1339 | $result['lower_limit'] = $matches[6]; |
| 1340 | 1340 | $result['upper_limit'] = $matches[7]; |
| 1341 | - $latitude = $Common->convertDec($matches[8],'latitude'); |
|
| 1341 | + $latitude = $Common->convertDec($matches[8], 'latitude'); |
|
| 1342 | 1342 | if ($matches[9] == 'S') $latitude = -$latitude; |
| 1343 | - $longitude = $Common->convertDec($matches[10],'longitude'); |
|
| 1343 | + $longitude = $Common->convertDec($matches[10], 'longitude'); |
|
| 1344 | 1344 | if ($matches[11] == 'W') $longitude = -$longitude; |
| 1345 | 1345 | $result['latitude'] = $latitude; |
| 1346 | 1346 | $result['longitude'] = $longitude; |
@@ -1352,24 +1352,24 @@ discard block |
||
| 1352 | 1352 | echo "Can't parse : ".$line."\n"; |
| 1353 | 1353 | } |
| 1354 | 1354 | } |
| 1355 | - elseif (preg_match('#(^|\s)A\) (.*)#',$line,$matches) && $a === false) { |
|
| 1355 | + elseif (preg_match('#(^|\s)A\) (.*)#', $line, $matches) && $a === false) { |
|
| 1356 | 1356 | $result['icao'] = $matches[2]; |
| 1357 | 1357 | $a = true; |
| 1358 | 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) { |
|
| 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 | 1360 | if ($matches[1] > 50) $year = '19'.$matches[2]; |
| 1361 | 1361 | else $year = '20'.$matches[2]; |
| 1362 | 1362 | $result['date_begin'] = $year.'/'.$matches[3].'/'.$matches[4].' '.$matches[5].':'.$matches[6]; |
| 1363 | 1363 | $b = true; |
| 1364 | 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) { |
|
| 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 | 1366 | if ($matches[2] > 50) $year = '19'.$matches[2]; |
| 1367 | 1367 | else $year = '20'.$matches[2]; |
| 1368 | 1368 | $result['date_end'] = $year.'/'.$matches[3].'/'.$matches[4].' '.$matches[5].':'.$matches[6]; |
| 1369 | 1369 | $result['permanent'] = 0; |
| 1370 | 1370 | $c = true; |
| 1371 | 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) { |
|
| 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 | 1373 | if ($matches[2] > 50) $year = '19'.$matches[2]; |
| 1374 | 1374 | else $year = '20'.$matches[2]; |
| 1375 | 1375 | $result['date_end'] = $year.'/'.$matches[3].'/'.$matches[4].' '.$matches[5].':'.$matches[6]; |
@@ -1379,7 +1379,7 @@ discard block |
||
| 1379 | 1379 | else $result['permanent'] = 0; |
| 1380 | 1380 | $c = true; |
| 1381 | 1381 | } |
| 1382 | - elseif (preg_match('#(^|\s)C\) (EST|PERM)$#',$line,$matches) && $c === false) { |
|
| 1382 | + elseif (preg_match('#(^|\s)C\) (EST|PERM)$#', $line, $matches) && $c === false) { |
|
| 1383 | 1383 | $result['date_end'] = '2030/12/20 12:00'; |
| 1384 | 1384 | if ($matches[2] == 'EST') $result['estimated'] = 1; |
| 1385 | 1385 | else $result['estimated'] = 0; |
@@ -1387,20 +1387,20 @@ discard block |
||
| 1387 | 1387 | else $result['permanent'] = 0; |
| 1388 | 1388 | $c = true; |
| 1389 | 1389 | } |
| 1390 | - elseif (preg_match('#(^|\s)E\) (.*)#',$line,$matches) && $e === false) { |
|
| 1390 | + elseif (preg_match('#(^|\s)E\) (.*)#', $line, $matches) && $e === false) { |
|
| 1391 | 1391 | $rtext = array(); |
| 1392 | - $text = explode(' ',$matches[2]); |
|
| 1392 | + $text = explode(' ', $matches[2]); |
|
| 1393 | 1393 | foreach ($text as $word) { |
| 1394 | 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); |
|
| 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 | 1396 | else $rtext[] = $word; |
| 1397 | 1397 | } |
| 1398 | - $result['text'] = implode(' ',$rtext); |
|
| 1398 | + $result['text'] = implode(' ', $rtext); |
|
| 1399 | 1399 | $e = true; |
| 1400 | 1400 | //} elseif (preg_match('#F\) (.*)#',$line,$matches)) { |
| 1401 | 1401 | //} elseif (preg_match('#G\) (.*)#',$line,$matches)) { |
| 1402 | - } elseif (preg_match('#(NOTAMN|NOTAMR|NOTAMC)#',$line,$matches)) { |
|
| 1403 | - $text = explode(' ',$line); |
|
| 1402 | + } elseif (preg_match('#(NOTAMN|NOTAMR|NOTAMC)#', $line, $matches)) { |
|
| 1403 | + $text = explode(' ', $line); |
|
| 1404 | 1404 | $result['ref'] = $text[0]; |
| 1405 | 1405 | if ($matches[1] == 'NOTAMN') $result['type'] = 'new'; |
| 1406 | 1406 | if ($matches[1] == 'NOTAMC') { |
@@ -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 |
@@ -42,20 +42,20 @@ discard block |
||
| 42 | 42 | * @param String $date get data for a date |
| 43 | 43 | * @return Array Return Accidents data in array |
| 44 | 44 | */ |
| 45 | - public function getAccidentData($limit = '',$type = '',$date = '') { |
|
| 45 | + public function getAccidentData($limit = '', $type = '', $date = '') { |
|
| 46 | 46 | global $globalURL, $globalDBdriver; |
| 47 | 47 | $Image = new Image($this->db); |
| 48 | 48 | $Spotter = new Spotter($this->db); |
| 49 | 49 | $Translation = new Translation($this->db); |
| 50 | - $date = filter_var($date,FILTER_SANITIZE_STRING); |
|
| 50 | + $date = filter_var($date, FILTER_SANITIZE_STRING); |
|
| 51 | 51 | date_default_timezone_set('UTC'); |
| 52 | 52 | $result = array(); |
| 53 | 53 | $limit_query = ''; |
| 54 | 54 | if ($limit != "") |
| 55 | 55 | { |
| 56 | 56 | $limit_array = explode(",", $limit); |
| 57 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 58 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 57 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 58 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 59 | 59 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 60 | 60 | { |
| 61 | 61 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
@@ -64,29 +64,29 @@ discard block |
||
| 64 | 64 | |
| 65 | 65 | if ($type != '') { |
| 66 | 66 | if ($date != '') { |
| 67 | - if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/",$date)) { |
|
| 67 | + if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $date)) { |
|
| 68 | 68 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
| 69 | 69 | //$query = "SELECT accidents.registration, accidents.ident, accidents.date, accidents.url, accidents.country, accidents.place, accidents.title, accidents.fatalities, accidents.type, accidents.ident, accidents.aircraft_manufacturer, accidents.aircraft_name, accidents.airline_name, accidents.airline_icao, spotter_output.flightaware_id FROM accidents LEFT OUTER JOIN spotter_output ON accidents.registration = spotter_output.registration WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
| 70 | - $query_values = array(':type' => $type,':date' => $date); |
|
| 71 | - } elseif (preg_match("/^[0-9]{4}-[0-9]{2}$/",$date)) { |
|
| 70 | + $query_values = array(':type' => $type, ':date' => $date); |
|
| 71 | + } elseif (preg_match("/^[0-9]{4}-[0-9]{2}$/", $date)) { |
|
| 72 | 72 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND date BETWEEN :dated AND :datef GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
| 73 | - $query_values = array(':type' => $type,':dated' => $date.'-01', ':datef' => $date.'-31'); |
|
| 74 | - } elseif (preg_match("/^[0-9]{4}$/",$date)) { |
|
| 73 | + $query_values = array(':type' => $type, ':dated' => $date.'-01', ':datef' => $date.'-31'); |
|
| 74 | + } elseif (preg_match("/^[0-9]{4}$/", $date)) { |
|
| 75 | 75 | if ($globalDBdriver == 'mysql') { |
| 76 | 76 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND YEAR(date) = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
| 77 | 77 | } else { |
| 78 | 78 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND EXTRACT(YEAR FROM date) = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
| 79 | 79 | } |
| 80 | - $query_values = array(':type' => $type,':date' => $date); |
|
| 80 | + $query_values = array(':type' => $type, ':date' => $date); |
|
| 81 | 81 | } else { |
| 82 | 82 | $date = $date.'%'; |
| 83 | 83 | if ($globalDBdriver == 'mysql') { |
| 84 | 84 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND DATE_FORMAT(date,'%Y-%m-%d') LIKE :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
| 85 | - $query_values = array(':type' => $type,':date' => $date); |
|
| 85 | + $query_values = array(':type' => $type, ':date' => $date); |
|
| 86 | 86 | } else { |
| 87 | 87 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND to_char(date,'YYYY-MM-DD') LIKE :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
| 88 | 88 | //$query = "SELECT accidents.registration, accidents.ident, accidents.date, accidents.url, accidents.country, accidents.place, accidents.title, accidents.fatalities, accidents.type, accidents.ident, accidents.aircraft_manufacturer, accidents.aircraft_name, accidents.airline_name, accidents.airline_icao, spotter_output.flightaware_id FROM accidents LEFT OUTER JOIN spotter_output ON accidents.registration = spotter_output.registration WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND to_char(date,'YYYY-MM-DD') LIKE :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
| 89 | - $query_values = array(':type' => $type,':date' => $date); |
|
| 89 | + $query_values = array(':type' => $type, ':date' => $date); |
|
| 90 | 90 | } |
| 91 | 91 | } |
| 92 | 92 | } else { |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | } |
| 98 | 98 | } else { |
| 99 | 99 | if ($date != '') { |
| 100 | - if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/",$date)) { |
|
| 100 | + if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $date)) { |
|
| 101 | 101 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
| 102 | 102 | //$query = "SELECT accidents.registration, accidents.ident, accidents.date, accidents.url, accidents.country, accidents.place, accidents.title, accidents.fatalities, accidents.type, accidents.ident, accidents.aircraft_manufacturer, accidents.aircraft_name, accidents.airline_name, accidents.airline_icao, spotter_output.flightaware_id FROM accidents LEFT OUTER JOIN spotter_output ON accidents.registration = spotter_output.registration WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
| 103 | 103 | } else { |
@@ -116,17 +116,17 @@ discard block |
||
| 116 | 116 | try { |
| 117 | 117 | $sth = $this->db->prepare($query); |
| 118 | 118 | $sth->execute($query_values); |
| 119 | - } catch(PDOException $e) { |
|
| 119 | + } catch (PDOException $e) { |
|
| 120 | 120 | echo "error : ".$e->getMessage(); |
| 121 | 121 | } |
| 122 | 122 | $i = 0; |
| 123 | 123 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
| 124 | - if (preg_match('/^[\w\-]+$/',$row['registration'])) { |
|
| 124 | + if (preg_match('/^[\w\-]+$/', $row['registration'])) { |
|
| 125 | 125 | $data = array(); |
| 126 | 126 | if ($row['registration'] != '') { |
| 127 | 127 | $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' => '')); |
|
| 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 | 130 | $aircraft_type = $Spotter->getAllAircraftTypeByRegistration($row['registration']); |
| 131 | 131 | $aircraft_info = $Spotter->getAllAircraftInfo($aircraft_type); |
| 132 | 132 | if (!empty($aircraft_info)) { |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | $data['aircraft_name'] = $aircraft_info[0]['type']; |
| 135 | 135 | $data['aircraft_manufacturer'] = $aircraft_info[0]['manufacturer']; |
| 136 | 136 | } else { |
| 137 | - $data = array_merge($data,array('aircraft_type' => 'NA')); |
|
| 137 | + $data = array_merge($data, array('aircraft_type' => 'NA')); |
|
| 138 | 138 | } |
| 139 | 139 | $owner_data = $Spotter->getAircraftOwnerByRegistration($row['registration']); |
| 140 | 140 | if (!empty($owner_data)) { |
@@ -142,18 +142,18 @@ discard block |
||
| 142 | 142 | $data['aircraft_base'] = $owner_data['base']; |
| 143 | 143 | $data['aircraft_date_first_reg'] = $owner_data['date_first_reg']; |
| 144 | 144 | } |
| 145 | - } else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 145 | + } else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
| 146 | 146 | if ($row['registration'] == '') $row['registration'] = 'NA'; |
| 147 | 147 | if ($row['ident'] == '') $row['ident'] = 'NA'; |
| 148 | - $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,3)); |
|
| 148 | + $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 3)); |
|
| 149 | 149 | if (isset($identicao[0])) { |
| 150 | - 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'); |
|
| 154 | - $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
|
| 150 | + 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'); |
|
| 154 | + $data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name'])); |
|
| 155 | 155 | } else $icao = $row['ident']; |
| 156 | - $icao = $Translation->checkTranslation($icao,false); |
|
| 156 | + $icao = $Translation->checkTranslation($icao, false); |
|
| 157 | 157 | //$data = array_merge($data,array('registration' => $row['registration'], 'date' => $row['date'], 'ident' => $icao,'url' => $row['url'])); |
| 158 | 158 | if ($row['airline_name'] != '' && !isset($data['airline_name'])) { |
| 159 | 159 | //echo 'Check airline info... for '.$row['airline_name'].' '; |
@@ -162,16 +162,16 @@ discard block |
||
| 162 | 162 | if (!empty($airline_info)) { |
| 163 | 163 | //echo 'data found !'."\n"; |
| 164 | 164 | //print_r($airline_info); |
| 165 | - $data = array_merge($data,$airline_info); |
|
| 165 | + $data = array_merge($data, $airline_info); |
|
| 166 | 166 | } |
| 167 | 167 | //else echo 'No data...'."\n"; |
| 168 | 168 | } |
| 169 | - $data = array_merge($row,$data); |
|
| 169 | + $data = array_merge($row, $data); |
|
| 170 | 170 | if ($data['ident'] == null) $data['ident'] = $icao; |
| 171 | 171 | if ($data['title'] == null) { |
| 172 | 172 | $data['message'] = $row['type'].' of '.$row['registration'].' at '.$row['place'].','.$row['country']; |
| 173 | 173 | } else $data['message'] = strtolower($data['title']); |
| 174 | - $ids = $Spotter->getAllIDByRegistration($data['registration'],true); |
|
| 174 | + $ids = $Spotter->getAllIDByRegistration($data['registration'], true); |
|
| 175 | 175 | $date = $data['date']; |
| 176 | 176 | if (isset($ids[$date])) { |
| 177 | 177 | $data['spotted'] = TRUE; |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | try { |
| 204 | 204 | $sth = $this->db->prepare($query); |
| 205 | 205 | $sth->execute(); |
| 206 | - } catch(PDOException $e) { |
|
| 206 | + } catch (PDOException $e) { |
|
| 207 | 207 | echo "Error : ".$e->getMessage(); |
| 208 | 208 | } |
| 209 | 209 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | try { |
| 224 | 224 | $sth = $this->db->prepare($query); |
| 225 | 225 | $sth->execute(); |
| 226 | - } catch(PDOException $e) { |
|
| 226 | + } catch (PDOException $e) { |
|
| 227 | 227 | echo "Error : ".$e->getMessage(); |
| 228 | 228 | } |
| 229 | 229 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -238,15 +238,15 @@ discard block |
||
| 238 | 238 | if ($globalDebug) echo 'Import '.$file."\n"; |
| 239 | 239 | $result = array(); |
| 240 | 240 | if (file_exists($file)) { |
| 241 | - if (($handle = fopen($file,'r')) !== FALSE) { |
|
| 242 | - while (($data = fgetcsv($handle,2000,",")) !== FALSE) { |
|
| 241 | + if (($handle = fopen($file, 'r')) !== FALSE) { |
|
| 242 | + while (($data = fgetcsv($handle, 2000, ",")) !== FALSE) { |
|
| 243 | 243 | if (isset($data[1]) && $data[1] != '0000-00-00 00:00:00') { |
| 244 | - $result[] = array('registration' => $data[0],'date' => strtotime($data[1]),'url' => $data[2],'country' => $data[3],'place' => $data[4],'title' => $data[5],'fatalities' => $data[6],'latitude' => $data[7],'longitude' => $data[8],'type' => $data[9],'ident' => $data[10],'aircraft_manufacturer' => $data[11],'aircraft_name' => $data[12],'operator' => $data[13],'source' => 'website_fam'); |
|
| 244 | + $result[] = array('registration' => $data[0], 'date' => strtotime($data[1]), 'url' => $data[2], 'country' => $data[3], 'place' => $data[4], 'title' => $data[5], 'fatalities' => $data[6], 'latitude' => $data[7], 'longitude' => $data[8], 'type' => $data[9], 'ident' => $data[10], 'aircraft_manufacturer' => $data[11], 'aircraft_name' => $data[12], 'operator' => $data[13], 'source' => 'website_fam'); |
|
| 245 | 245 | } |
| 246 | 246 | } |
| 247 | 247 | fclose($handle); |
| 248 | 248 | } |
| 249 | - if (!empty($result)) $this->add($result,true); |
|
| 249 | + if (!empty($result)) $this->add($result, true); |
|
| 250 | 250 | elseif ($globalDebug) echo 'Nothing to import'; |
| 251 | 251 | } |
| 252 | 252 | } |
@@ -262,8 +262,8 @@ discard block |
||
| 262 | 262 | $all_md5_new = array(); |
| 263 | 263 | if (file_exists(dirname(__FILE__).'/../install/tmp/cr-all.md5')) { |
| 264 | 264 | if ($this->check_accidents_nb() > 0) { |
| 265 | - if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5','r')) !== FALSE) { |
|
| 266 | - while (($data = fgetcsv($handle,2000,"\t")) !== FALSE) { |
|
| 265 | + if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5', 'r')) !== FALSE) { |
|
| 266 | + while (($data = fgetcsv($handle, 2000, "\t")) !== FALSE) { |
|
| 267 | 267 | if (isset($data[1])) { |
| 268 | 268 | $year = $data[0]; |
| 269 | 269 | $all_md5[$year] = $data[1]; |
@@ -273,10 +273,10 @@ discard block |
||
| 273 | 273 | } |
| 274 | 274 | } |
| 275 | 275 | } |
| 276 | - $Common->download('http://data.flightairmap.fr/data/cr/cr-all.md5',dirname(__FILE__).'/../install/tmp/cr-all.md5'); |
|
| 276 | + $Common->download('http://data.flightairmap.fr/data/cr/cr-all.md5', dirname(__FILE__).'/../install/tmp/cr-all.md5'); |
|
| 277 | 277 | if (file_exists(dirname(__FILE__).'/../install/tmp/cr-all.md5')) { |
| 278 | - if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5','r')) !== FALSE) { |
|
| 279 | - while (($data = fgetcsv($handle,2000,"\t")) !== FALSE) { |
|
| 278 | + if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5', 'r')) !== FALSE) { |
|
| 279 | + while (($data = fgetcsv($handle, 2000, "\t")) !== FALSE) { |
|
| 280 | 280 | if (isset($data[1])) { |
| 281 | 281 | $year = $data[0]; |
| 282 | 282 | $all_md5_new[$year] = $data[1]; |
@@ -285,10 +285,10 @@ discard block |
||
| 285 | 285 | fclose($handle); |
| 286 | 286 | } elseif ($globalDebug) echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5'; |
| 287 | 287 | } elseif ($globalDebug) echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.'; |
| 288 | - $result = $Common->arr_diff($all_md5_new,$all_md5); |
|
| 288 | + $result = $Common->arr_diff($all_md5_new, $all_md5); |
|
| 289 | 289 | if (empty($result) && $globalDebug) echo 'Nothing to update'; |
| 290 | 290 | foreach ($result as $file => $md5) { |
| 291 | - $Common->download('http://data.flightairmap.fr/data/cr/'.$file,dirname(__FILE__).'/../install/tmp/'.$file); |
|
| 291 | + $Common->download('http://data.flightairmap.fr/data/cr/'.$file, dirname(__FILE__).'/../install/tmp/'.$file); |
|
| 292 | 292 | if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) $this->import(dirname(__FILE__).'/../install/tmp/'.$file); |
| 293 | 293 | elseif ($globalDebug) echo 'Download '.$file.' failed'; |
| 294 | 294 | } |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | * Add data to DB |
| 299 | 299 | * @param Array $crash An array with accidents/incidents data |
| 300 | 300 | */ |
| 301 | - public function add($crash,$new = false) { |
|
| 301 | + public function add($crash, $new = false) { |
|
| 302 | 302 | global $globalTransaction, $globalDebug, $globalAircraftImageFetch; |
| 303 | 303 | require_once('class.Connection.php'); |
| 304 | 304 | require_once('class.Image.php'); |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | $sthd->execute(array(':source' => $crash[0]['source'])); |
| 315 | 315 | } |
| 316 | 316 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 317 | - $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); |
|
| 317 | + $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 | 318 | $query_check = 'SELECT COUNT(*) as nb FROM accidents WHERE registration = :registration AND date = :date AND type = :type AND source = :source'; |
| 319 | 319 | $sth_check = $Connection->db->prepare($query_check); |
| 320 | 320 | $query = 'INSERT INTO accidents (aircraft_manufacturer,aircraft_name,ident,registration,date,url,country,place,title,fatalities,latitude,longitude,type,airline_name,source) VALUES (:aircraft_manufacturer,:aircraft_name,:ident,:registration,:date,:url,:country,:place,:title,:fatalities,:latitude,:longitude,:type,:airline_name,:source)'; |
@@ -327,15 +327,15 @@ discard block |
||
| 327 | 327 | $cr = array_map(function($value) { |
| 328 | 328 | return $value === "" ? NULL : $value; |
| 329 | 329 | }, $cr); |
| 330 | - 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']); |
|
| 332 | - $query_check_values = array(':registration' => $cr['registration'],':date' => date('Y-m-d',$cr['date']),':type' => $cr['type'],':source' => $cr['source']); |
|
| 330 | + 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']); |
|
| 332 | + $query_check_values = array(':registration' => $cr['registration'], ':date' => date('Y-m-d', $cr['date']), ':type' => $cr['type'], ':source' => $cr['source']); |
|
| 333 | 333 | $sth_check->execute($query_check_values); |
| 334 | 334 | $result_check = $sth_check->fetchAll(PDO::FETCH_ASSOC); |
| 335 | 335 | if ($result_check[0]['nb'] == 0) { |
| 336 | - $query_values = array(':registration' => trim($cr['registration']),':date' => date('Y-m-d',$cr['date']),':url' => $cr['url'],':country' => $cr['country'],':place' => $cr['place'],':title' => $cr['title'],':fatalities' => $cr['fatalities'],':latitude' => $cr['latitude'],':longitude' => $cr['longitude'],':type' => $cr['type'],':source' => $cr['source'],':ident' => $cr['ident'],':aircraft_manufacturer' => $cr['aircraft_manufacturer'],':aircraft_name' => $cr['aircraft_name'],':airline_name' => $cr['operator']); |
|
| 336 | + $query_values = array(':registration' => trim($cr['registration']), ':date' => date('Y-m-d', $cr['date']), ':url' => $cr['url'], ':country' => $cr['country'], ':place' => $cr['place'], ':title' => $cr['title'], ':fatalities' => $cr['fatalities'], ':latitude' => $cr['latitude'], ':longitude' => $cr['longitude'], ':type' => $cr['type'], ':source' => $cr['source'], ':ident' => $cr['ident'], ':aircraft_manufacturer' => $cr['aircraft_manufacturer'], ':aircraft_name' => $cr['aircraft_name'], ':airline_name' => $cr['operator']); |
|
| 337 | 337 | $sth->execute($query_values); |
| 338 | - if ($globalAircraftImageFetch && $cr['date'] > time()-(30*86400)) { |
|
| 338 | + if ($globalAircraftImageFetch && $cr['date'] > time() - (30*86400)) { |
|
| 339 | 339 | $imgchk = $Image->getSpotterImage($cr['registration']); |
| 340 | 340 | if (empty($imgchk)) { |
| 341 | 341 | if ($globalDebug) echo "\t".'Get image for '.$cr['registration'].'...'; |
@@ -345,16 +345,16 @@ discard block |
||
| 345 | 345 | // elseif ($globalDebug) echo 'Image already in DB'."\n"; |
| 346 | 346 | } |
| 347 | 347 | if ($cr['title'] == '') $cr['title'] = $cr['registration'].' '.$cr['type']; |
| 348 | - $Spotter->setHighlightFlightByRegistration($cr['registration'],$cr['title'],date('Y-m-d',$cr['date'])); |
|
| 348 | + $Spotter->setHighlightFlightByRegistration($cr['registration'], $cr['title'], date('Y-m-d', $cr['date'])); |
|
| 349 | 349 | } |
| 350 | 350 | } |
| 351 | - if ($globalTransaction && $j % 1000 == 0) { |
|
| 351 | + if ($globalTransaction && $j%1000 == 0) { |
|
| 352 | 352 | $Connection->db->commit(); |
| 353 | 353 | $Connection->db->beginTransaction(); |
| 354 | 354 | } |
| 355 | 355 | } |
| 356 | 356 | if ($globalTransaction) $Connection->db->commit(); |
| 357 | - } catch(PDOException $e) { |
|
| 357 | + } catch (PDOException $e) { |
|
| 358 | 358 | if ($globalTransaction) $Connection->db->rollBack(); |
| 359 | 359 | echo $e->getMessage(); |
| 360 | 360 | } |
@@ -372,7 +372,7 @@ discard block |
||
| 372 | 372 | $Connection = new Connection(); |
| 373 | 373 | $sth = $Connection->db->prepare($query); |
| 374 | 374 | $sth->execute(); |
| 375 | - } catch(PDOException $e) { |
|
| 375 | + } catch (PDOException $e) { |
|
| 376 | 376 | return "error : ".$e->getMessage(); |
| 377 | 377 | } |
| 378 | 378 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -390,7 +390,7 @@ discard block |
||
| 390 | 390 | $Connection = new Connection(); |
| 391 | 391 | $sth = $Connection->db->prepare($query); |
| 392 | 392 | $sth->execute(); |
| 393 | - } catch(PDOException $e) { |
|
| 393 | + } catch (PDOException $e) { |
|
| 394 | 394 | return "error : ".$e->getMessage(); |
| 395 | 395 | } |
| 396 | 396 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -405,7 +405,7 @@ discard block |
||
| 405 | 405 | $Connection = new Connection(); |
| 406 | 406 | $sth = $Connection->db->prepare($query); |
| 407 | 407 | $sth->execute(); |
| 408 | - } catch(PDOException $e) { |
|
| 408 | + } catch (PDOException $e) { |
|
| 409 | 409 | return "error : ".$e->getMessage(); |
| 410 | 410 | } |
| 411 | 411 | } |
@@ -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() { |
@@ -85,38 +85,38 @@ discard block |
||
| 85 | 85 | try { |
| 86 | 86 | //$Connection = new Connection(); |
| 87 | 87 | $sth = $Connection->db->prepare($query); |
| 88 | - $sth->execute(array(':source' => $database_file)); |
|
| 89 | - } catch(PDOException $e) { |
|
| 90 | - return "error : ".$e->getMessage(); |
|
| 91 | - } |
|
| 88 | + $sth->execute(array(':source' => $database_file)); |
|
| 89 | + } catch(PDOException $e) { |
|
| 90 | + return "error : ".$e->getMessage(); |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
| 94 | - update_db::connect_sqlite($database_file); |
|
| 93 | + if ($globalDebug) echo " - Add routes to DB -"; |
|
| 94 | + update_db::connect_sqlite($database_file); |
|
| 95 | 95 | //$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 | 96 | $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"; |
| 97 | 97 | try { |
| 98 | - $sth = update_db::$db_sqlite->prepare($query); |
|
| 99 | - $sth->execute(); |
|
| 100 | - } catch(PDOException $e) { |
|
| 101 | - return "error : ".$e->getMessage(); |
|
| 102 | - } |
|
| 98 | + $sth = update_db::$db_sqlite->prepare($query); |
|
| 99 | + $sth->execute(); |
|
| 100 | + } catch(PDOException $e) { |
|
| 101 | + return "error : ".$e->getMessage(); |
|
| 102 | + } |
|
| 103 | 103 | //$query_dest = 'INSERT INTO routes (`RouteID`,`CallSign`,`Operator_ICAO`,`FromAirport_ICAO`,`ToAirport_ICAO`,`RouteStop`,`Source`) VALUES (:RouteID, :CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)'; |
| 104 | 104 | $query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,ToAirport_ICAO,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)'; |
| 105 | 105 | $Connection = new Connection(); |
| 106 | 106 | $sth_dest = $Connection->db->prepare($query_dest); |
| 107 | 107 | try { |
| 108 | 108 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 109 | - while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
| 109 | + while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
| 110 | 110 | //$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 | 111 | $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 | 112 | $sth_dest->execute($query_dest_values); |
| 113 | - } |
|
| 113 | + } |
|
| 114 | 114 | if ($globalTransaction) $Connection->db->commit(); |
| 115 | 115 | } catch(PDOException $e) { |
| 116 | 116 | if ($globalTransaction) $Connection->db->rollBack(); |
| 117 | 117 | return "error : ".$e->getMessage(); |
| 118 | 118 | } |
| 119 | - return ''; |
|
| 119 | + return ''; |
|
| 120 | 120 | } |
| 121 | 121 | public static function retrieve_route_oneworld($database_file) { |
| 122 | 122 | global $globalDebug, $globalTransaction; |
@@ -127,12 +127,12 @@ discard block |
||
| 127 | 127 | try { |
| 128 | 128 | //$Connection = new Connection(); |
| 129 | 129 | $sth = $Connection->db->prepare($query); |
| 130 | - $sth->execute(array(':source' => 'oneworld')); |
|
| 131 | - } catch(PDOException $e) { |
|
| 132 | - return "error : ".$e->getMessage(); |
|
| 133 | - } |
|
| 130 | + $sth->execute(array(':source' => 'oneworld')); |
|
| 131 | + } catch(PDOException $e) { |
|
| 132 | + return "error : ".$e->getMessage(); |
|
| 133 | + } |
|
| 134 | 134 | |
| 135 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
| 135 | + if ($globalDebug) echo " - Add routes to DB -"; |
|
| 136 | 136 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 137 | 137 | $Spotter = new Spotter(); |
| 138 | 138 | if ($fh = fopen($database_file,"r")) { |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | } |
| 157 | 157 | if ($globalTransaction) $Connection->db->commit(); |
| 158 | 158 | } |
| 159 | - return ''; |
|
| 159 | + return ''; |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | public static function retrieve_route_skyteam($database_file) { |
@@ -168,12 +168,12 @@ discard block |
||
| 168 | 168 | try { |
| 169 | 169 | //$Connection = new Connection(); |
| 170 | 170 | $sth = $Connection->db->prepare($query); |
| 171 | - $sth->execute(array(':source' => 'skyteam')); |
|
| 172 | - } catch(PDOException $e) { |
|
| 173 | - return "error : ".$e->getMessage(); |
|
| 174 | - } |
|
| 171 | + $sth->execute(array(':source' => 'skyteam')); |
|
| 172 | + } catch(PDOException $e) { |
|
| 173 | + return "error : ".$e->getMessage(); |
|
| 174 | + } |
|
| 175 | 175 | |
| 176 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
| 176 | + if ($globalDebug) echo " - Add routes to DB -"; |
|
| 177 | 177 | |
| 178 | 178 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 179 | 179 | $Spotter = new Spotter(); |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | return "error : ".$e->getMessage(); |
| 200 | 200 | } |
| 201 | 201 | } |
| 202 | - return ''; |
|
| 202 | + return ''; |
|
| 203 | 203 | } |
| 204 | 204 | public static function retrieve_modes_sqlite_to_dest($database_file) { |
| 205 | 205 | global $globalTransaction; |
@@ -208,27 +208,27 @@ discard block |
||
| 208 | 208 | try { |
| 209 | 209 | $Connection = new Connection(); |
| 210 | 210 | $sth = $Connection->db->prepare($query); |
| 211 | - $sth->execute(array(':source' => $database_file)); |
|
| 212 | - } catch(PDOException $e) { |
|
| 213 | - return "error : ".$e->getMessage(); |
|
| 214 | - } |
|
| 211 | + $sth->execute(array(':source' => $database_file)); |
|
| 212 | + } catch(PDOException $e) { |
|
| 213 | + return "error : ".$e->getMessage(); |
|
| 214 | + } |
|
| 215 | 215 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source"; |
| 216 | 216 | try { |
| 217 | 217 | $Connection = new Connection(); |
| 218 | 218 | $sth = $Connection->db->prepare($query); |
| 219 | - $sth->execute(array(':source' => $database_file)); |
|
| 220 | - } catch(PDOException $e) { |
|
| 221 | - return "error : ".$e->getMessage(); |
|
| 222 | - } |
|
| 219 | + $sth->execute(array(':source' => $database_file)); |
|
| 220 | + } catch(PDOException $e) { |
|
| 221 | + return "error : ".$e->getMessage(); |
|
| 222 | + } |
|
| 223 | 223 | |
| 224 | - update_db::connect_sqlite($database_file); |
|
| 224 | + update_db::connect_sqlite($database_file); |
|
| 225 | 225 | $query = 'select * from Aircraft'; |
| 226 | 226 | try { |
| 227 | - $sth = update_db::$db_sqlite->prepare($query); |
|
| 228 | - $sth->execute(); |
|
| 229 | - } catch(PDOException $e) { |
|
| 230 | - return "error : ".$e->getMessage(); |
|
| 231 | - } |
|
| 227 | + $sth = update_db::$db_sqlite->prepare($query); |
|
| 228 | + $sth->execute(); |
|
| 229 | + } catch(PDOException $e) { |
|
| 230 | + return "error : ".$e->getMessage(); |
|
| 231 | + } |
|
| 232 | 232 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
| 233 | 233 | $query_dest = 'INSERT INTO aircraft_modes (LastModified, ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type,:source)'; |
| 234 | 234 | |
@@ -239,17 +239,17 @@ discard block |
||
| 239 | 239 | $sth_dest_owner = $Connection->db->prepare($query_dest_owner); |
| 240 | 240 | try { |
| 241 | 241 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 242 | - while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
| 242 | + while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
| 243 | 243 | //$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 | 244 | if ($values['UserString4'] == 'M') $type = 'military'; |
| 245 | 245 | else $type = null; |
| 246 | 246 | $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 | 247 | $sth_dest->execute($query_dest_values); |
| 248 | 248 | if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') { |
| 249 | - $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']); |
|
| 250 | - $sth_dest_owner->execute($query_dest_owner_values); |
|
| 249 | + $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']); |
|
| 250 | + $sth_dest_owner->execute($query_dest_owner_values); |
|
| 251 | 251 | } |
| 252 | - } |
|
| 252 | + } |
|
| 253 | 253 | if ($globalTransaction) $Connection->db->commit(); |
| 254 | 254 | } catch(PDOException $e) { |
| 255 | 255 | return "error : ".$e->getMessage(); |
@@ -260,10 +260,10 @@ discard block |
||
| 260 | 260 | try { |
| 261 | 261 | $Connection = new Connection(); |
| 262 | 262 | $sth = $Connection->db->prepare($query); |
| 263 | - $sth->execute(array(':source' => $database_file)); |
|
| 264 | - } catch(PDOException $e) { |
|
| 265 | - return "error : ".$e->getMessage(); |
|
| 266 | - } |
|
| 263 | + $sth->execute(array(':source' => $database_file)); |
|
| 264 | + } catch(PDOException $e) { |
|
| 265 | + return "error : ".$e->getMessage(); |
|
| 266 | + } |
|
| 267 | 267 | return ''; |
| 268 | 268 | } |
| 269 | 269 | |
@@ -275,10 +275,10 @@ discard block |
||
| 275 | 275 | try { |
| 276 | 276 | $Connection = new Connection(); |
| 277 | 277 | $sth = $Connection->db->prepare($query); |
| 278 | - $sth->execute(array(':source' => $database_file)); |
|
| 279 | - } catch(PDOException $e) { |
|
| 280 | - return "error : ".$e->getMessage(); |
|
| 281 | - } |
|
| 278 | + $sth->execute(array(':source' => $database_file)); |
|
| 279 | + } catch(PDOException $e) { |
|
| 280 | + return "error : ".$e->getMessage(); |
|
| 281 | + } |
|
| 282 | 282 | |
| 283 | 283 | if ($fh = fopen($database_file,"r")) { |
| 284 | 284 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
@@ -288,26 +288,26 @@ discard block |
||
| 288 | 288 | $sth_dest = $Connection->db->prepare($query_dest); |
| 289 | 289 | try { |
| 290 | 290 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 291 | - while (!feof($fh)) { |
|
| 292 | - $values = array(); |
|
| 293 | - $line = $Common->hex2str(fgets($fh,9999)); |
|
| 291 | + while (!feof($fh)) { |
|
| 292 | + $values = array(); |
|
| 293 | + $line = $Common->hex2str(fgets($fh,9999)); |
|
| 294 | 294 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
| 295 | - $values['ModeS'] = substr($line,0,6); |
|
| 296 | - $values['Registration'] = trim(substr($line,69,6)); |
|
| 297 | - $aircraft_name = trim(substr($line,48,6)); |
|
| 298 | - // Check if we can find ICAO, else set it to GLID |
|
| 299 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
| 300 | - $search_more = ''; |
|
| 301 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 302 | - $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
| 303 | - $sth_search = $Connection->db->prepare($query_search); |
|
| 295 | + $values['ModeS'] = substr($line,0,6); |
|
| 296 | + $values['Registration'] = trim(substr($line,69,6)); |
|
| 297 | + $aircraft_name = trim(substr($line,48,6)); |
|
| 298 | + // Check if we can find ICAO, else set it to GLID |
|
| 299 | + $aircraft_name_split = explode(' ',$aircraft_name); |
|
| 300 | + $search_more = ''; |
|
| 301 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 302 | + $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
| 303 | + $sth_search = $Connection->db->prepare($query_search); |
|
| 304 | 304 | try { |
| 305 | - $sth_search->execute(); |
|
| 306 | - $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
| 307 | - //if (count($result) > 0) { |
|
| 308 | - if (isset($result['icao']) && $result['icao'] != '') { |
|
| 309 | - $values['ICAOTypeCode'] = $result['icao']; |
|
| 310 | - } |
|
| 305 | + $sth_search->execute(); |
|
| 306 | + $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
| 307 | + //if (count($result) > 0) { |
|
| 308 | + if (isset($result['icao']) && $result['icao'] != '') { |
|
| 309 | + $values['ICAOTypeCode'] = $result['icao']; |
|
| 310 | + } |
|
| 311 | 311 | } catch(PDOException $e) { |
| 312 | 312 | return "error : ".$e->getMessage(); |
| 313 | 313 | } |
@@ -330,10 +330,10 @@ discard block |
||
| 330 | 330 | try { |
| 331 | 331 | $Connection = new Connection(); |
| 332 | 332 | $sth = $Connection->db->prepare($query); |
| 333 | - $sth->execute(array(':source' => $database_file)); |
|
| 334 | - } catch(PDOException $e) { |
|
| 335 | - return "error : ".$e->getMessage(); |
|
| 336 | - } |
|
| 333 | + $sth->execute(array(':source' => $database_file)); |
|
| 334 | + } catch(PDOException $e) { |
|
| 335 | + return "error : ".$e->getMessage(); |
|
| 336 | + } |
|
| 337 | 337 | return ''; |
| 338 | 338 | } |
| 339 | 339 | |
@@ -344,10 +344,10 @@ discard block |
||
| 344 | 344 | try { |
| 345 | 345 | $Connection = new Connection(); |
| 346 | 346 | $sth = $Connection->db->prepare($query); |
| 347 | - $sth->execute(array(':source' => $database_file)); |
|
| 348 | - } catch(PDOException $e) { |
|
| 349 | - return "error : ".$e->getMessage(); |
|
| 350 | - } |
|
| 347 | + $sth->execute(array(':source' => $database_file)); |
|
| 348 | + } catch(PDOException $e) { |
|
| 349 | + return "error : ".$e->getMessage(); |
|
| 350 | + } |
|
| 351 | 351 | |
| 352 | 352 | if ($fh = fopen($database_file,"r")) { |
| 353 | 353 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
@@ -358,25 +358,25 @@ discard block |
||
| 358 | 358 | try { |
| 359 | 359 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 360 | 360 | $tmp = fgetcsv($fh,9999,',',"'"); |
| 361 | - while (!feof($fh)) { |
|
| 362 | - $line = fgetcsv($fh,9999,',',"'"); |
|
| 361 | + while (!feof($fh)) { |
|
| 362 | + $line = fgetcsv($fh,9999,',',"'"); |
|
| 363 | 363 | |
| 364 | 364 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
| 365 | 365 | //print_r($line); |
| 366 | - $values['ModeS'] = $line[1]; |
|
| 367 | - $values['Registration'] = $line[3]; |
|
| 368 | - $values['ICAOTypeCode'] = ''; |
|
| 369 | - $aircraft_name = $line[2]; |
|
| 370 | - // Check if we can find ICAO, else set it to GLID |
|
| 371 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
| 372 | - $search_more = ''; |
|
| 373 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 374 | - $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
| 375 | - $sth_search = $Connection->db->prepare($query_search); |
|
| 366 | + $values['ModeS'] = $line[1]; |
|
| 367 | + $values['Registration'] = $line[3]; |
|
| 368 | + $values['ICAOTypeCode'] = ''; |
|
| 369 | + $aircraft_name = $line[2]; |
|
| 370 | + // Check if we can find ICAO, else set it to GLID |
|
| 371 | + $aircraft_name_split = explode(' ',$aircraft_name); |
|
| 372 | + $search_more = ''; |
|
| 373 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 374 | + $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
| 375 | + $sth_search = $Connection->db->prepare($query_search); |
|
| 376 | 376 | try { |
| 377 | - $sth_search->execute(); |
|
| 378 | - $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
| 379 | - if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
|
| 377 | + $sth_search->execute(); |
|
| 378 | + $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
| 379 | + if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
|
| 380 | 380 | } catch(PDOException $e) { |
| 381 | 381 | return "error : ".$e->getMessage(); |
| 382 | 382 | } |
@@ -399,10 +399,10 @@ discard block |
||
| 399 | 399 | try { |
| 400 | 400 | $Connection = new Connection(); |
| 401 | 401 | $sth = $Connection->db->prepare($query); |
| 402 | - $sth->execute(array(':source' => $database_file)); |
|
| 403 | - } catch(PDOException $e) { |
|
| 404 | - return "error : ".$e->getMessage(); |
|
| 405 | - } |
|
| 402 | + $sth->execute(array(':source' => $database_file)); |
|
| 403 | + } catch(PDOException $e) { |
|
| 404 | + return "error : ".$e->getMessage(); |
|
| 405 | + } |
|
| 406 | 406 | return ''; |
| 407 | 407 | } |
| 408 | 408 | |
@@ -413,16 +413,16 @@ discard block |
||
| 413 | 413 | try { |
| 414 | 414 | $Connection = new Connection(); |
| 415 | 415 | $sth = $Connection->db->prepare($query); |
| 416 | - $sth->execute(array(':source' => $database_file)); |
|
| 417 | - } catch(PDOException $e) { |
|
| 418 | - return "error : ".$e->getMessage(); |
|
| 419 | - } |
|
| 416 | + $sth->execute(array(':source' => $database_file)); |
|
| 417 | + } catch(PDOException $e) { |
|
| 418 | + return "error : ".$e->getMessage(); |
|
| 419 | + } |
|
| 420 | 420 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 421 | 421 | $Spotter = new Spotter(); |
| 422 | 422 | if ($fh = fopen($database_file,"r")) { |
| 423 | 423 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
| 424 | 424 | $query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)'; |
| 425 | - $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)'; |
|
| 425 | + $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)'; |
|
| 426 | 426 | |
| 427 | 427 | $Connection = new Connection(); |
| 428 | 428 | $sth_dest = $Connection->db->prepare($query_dest); |
@@ -430,126 +430,126 @@ discard block |
||
| 430 | 430 | try { |
| 431 | 431 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 432 | 432 | $tmp = fgetcsv($fh,9999,',','"'); |
| 433 | - while (!feof($fh)) { |
|
| 434 | - $line = fgetcsv($fh,9999,',','"'); |
|
| 435 | - $values = array(); |
|
| 436 | - //print_r($line); |
|
| 437 | - if ($country == 'F') { |
|
| 438 | - $values['registration'] = $line[0]; |
|
| 439 | - $values['base'] = $line[4]; |
|
| 440 | - $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])); |
|
| 443 | - $values['cancel'] = $line[7]; |
|
| 433 | + while (!feof($fh)) { |
|
| 434 | + $line = fgetcsv($fh,9999,',','"'); |
|
| 435 | + $values = array(); |
|
| 436 | + //print_r($line); |
|
| 437 | + if ($country == 'F') { |
|
| 438 | + $values['registration'] = $line[0]; |
|
| 439 | + $values['base'] = $line[4]; |
|
| 440 | + $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])); |
|
| 443 | + $values['cancel'] = $line[7]; |
|
| 444 | 444 | } elseif ($country == 'EI') { |
| 445 | - // TODO : add modeS & reg to aircraft_modes |
|
| 446 | - $values['registration'] = $line[0]; |
|
| 447 | - $values['base'] = $line[3]; |
|
| 448 | - $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])); |
|
| 451 | - $values['cancel'] = ''; |
|
| 452 | - $values['modes'] = $line[7]; |
|
| 453 | - $values['icao'] = $line[8]; |
|
| 445 | + // TODO : add modeS & reg to aircraft_modes |
|
| 446 | + $values['registration'] = $line[0]; |
|
| 447 | + $values['base'] = $line[3]; |
|
| 448 | + $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])); |
|
| 451 | + $values['cancel'] = ''; |
|
| 452 | + $values['modes'] = $line[7]; |
|
| 453 | + $values['icao'] = $line[8]; |
|
| 454 | 454 | |
| 455 | 455 | } elseif ($country == 'HB') { |
| 456 | - // TODO : add modeS & reg to aircraft_modes |
|
| 457 | - $values['registration'] = $line[0]; |
|
| 458 | - $values['base'] = null; |
|
| 459 | - $values['owner'] = $line[5]; |
|
| 460 | - $values['date_first_reg'] = null; |
|
| 461 | - $values['cancel'] = ''; |
|
| 462 | - $values['modes'] = $line[4]; |
|
| 463 | - $values['icao'] = $line[7]; |
|
| 456 | + // TODO : add modeS & reg to aircraft_modes |
|
| 457 | + $values['registration'] = $line[0]; |
|
| 458 | + $values['base'] = null; |
|
| 459 | + $values['owner'] = $line[5]; |
|
| 460 | + $values['date_first_reg'] = null; |
|
| 461 | + $values['cancel'] = ''; |
|
| 462 | + $values['modes'] = $line[4]; |
|
| 463 | + $values['icao'] = $line[7]; |
|
| 464 | 464 | } elseif ($country == 'OK') { |
| 465 | - // TODO : add modeS & reg to aircraft_modes |
|
| 466 | - $values['registration'] = $line[3]; |
|
| 467 | - $values['base'] = null; |
|
| 468 | - $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])); |
|
| 471 | - $values['cancel'] = ''; |
|
| 465 | + // TODO : add modeS & reg to aircraft_modes |
|
| 466 | + $values['registration'] = $line[3]; |
|
| 467 | + $values['base'] = null; |
|
| 468 | + $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])); |
|
| 471 | + $values['cancel'] = ''; |
|
| 472 | 472 | } elseif ($country == 'VH') { |
| 473 | - // TODO : add modeS & reg to aircraft_modes |
|
| 474 | - $values['registration'] = $line[0]; |
|
| 475 | - $values['base'] = null; |
|
| 476 | - $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])); |
|
| 479 | - |
|
| 480 | - $values['cancel'] = $line[39]; |
|
| 473 | + // TODO : add modeS & reg to aircraft_modes |
|
| 474 | + $values['registration'] = $line[0]; |
|
| 475 | + $values['base'] = null; |
|
| 476 | + $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])); |
|
| 479 | + |
|
| 480 | + $values['cancel'] = $line[39]; |
|
| 481 | 481 | } elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { |
| 482 | - $values['registration'] = $line[0]; |
|
| 483 | - $values['base'] = null; |
|
| 484 | - $values['owner'] = $line[4]; |
|
| 485 | - $values['date_first_reg'] = null; |
|
| 486 | - $values['cancel'] = ''; |
|
| 482 | + $values['registration'] = $line[0]; |
|
| 483 | + $values['base'] = null; |
|
| 484 | + $values['owner'] = $line[4]; |
|
| 485 | + $values['date_first_reg'] = null; |
|
| 486 | + $values['cancel'] = ''; |
|
| 487 | 487 | } elseif ($country == 'CC') { |
| 488 | - $values['registration'] = $line[0]; |
|
| 489 | - $values['base'] = null; |
|
| 490 | - $values['owner'] = $line[6]; |
|
| 491 | - $values['date_first_reg'] = null; |
|
| 492 | - $values['cancel'] = ''; |
|
| 488 | + $values['registration'] = $line[0]; |
|
| 489 | + $values['base'] = null; |
|
| 490 | + $values['owner'] = $line[6]; |
|
| 491 | + $values['date_first_reg'] = null; |
|
| 492 | + $values['cancel'] = ''; |
|
| 493 | 493 | } elseif ($country == 'HJ') { |
| 494 | - $values['registration'] = $line[0]; |
|
| 495 | - $values['base'] = null; |
|
| 496 | - $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])); |
|
| 499 | - $values['cancel'] = ''; |
|
| 494 | + $values['registration'] = $line[0]; |
|
| 495 | + $values['base'] = null; |
|
| 496 | + $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])); |
|
| 499 | + $values['cancel'] = ''; |
|
| 500 | 500 | } elseif ($country == 'PP') { |
| 501 | - $values['registration'] = $line[0]; |
|
| 502 | - $values['base'] = null; |
|
| 503 | - $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])); |
|
| 506 | - $values['cancel'] = $line[7]; |
|
| 501 | + $values['registration'] = $line[0]; |
|
| 502 | + $values['base'] = null; |
|
| 503 | + $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])); |
|
| 506 | + $values['cancel'] = $line[7]; |
|
| 507 | 507 | } elseif ($country == 'E7') { |
| 508 | - $values['registration'] = $line[0]; |
|
| 509 | - $values['base'] = null; |
|
| 510 | - $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])); |
|
| 513 | - $values['cancel'] = ''; |
|
| 508 | + $values['registration'] = $line[0]; |
|
| 509 | + $values['base'] = null; |
|
| 510 | + $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])); |
|
| 513 | + $values['cancel'] = ''; |
|
| 514 | 514 | } elseif ($country == '8Q') { |
| 515 | - $values['registration'] = $line[0]; |
|
| 516 | - $values['base'] = null; |
|
| 517 | - $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])); |
|
| 520 | - $values['cancel'] = ''; |
|
| 515 | + $values['registration'] = $line[0]; |
|
| 516 | + $values['base'] = null; |
|
| 517 | + $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])); |
|
| 520 | + $values['cancel'] = ''; |
|
| 521 | 521 | } elseif ($country == 'ZK') { |
| 522 | - $values['registration'] = $line[0]; |
|
| 523 | - $values['base'] = null; |
|
| 524 | - $values['owner'] = $line[3]; |
|
| 525 | - $values['date_first_reg'] = null; |
|
| 526 | - $values['cancel'] = ''; |
|
| 527 | - $values['modes'] = $line[5]; |
|
| 528 | - $values['icao'] = $line[9]; |
|
| 522 | + $values['registration'] = $line[0]; |
|
| 523 | + $values['base'] = null; |
|
| 524 | + $values['owner'] = $line[3]; |
|
| 525 | + $values['date_first_reg'] = null; |
|
| 526 | + $values['cancel'] = ''; |
|
| 527 | + $values['modes'] = $line[5]; |
|
| 528 | + $values['icao'] = $line[9]; |
|
| 529 | 529 | } elseif ($country == 'M') { |
| 530 | - $values['registration'] = $line[0]; |
|
| 531 | - $values['base'] = null; |
|
| 532 | - $values['owner'] = $line[6]; |
|
| 533 | - $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
| 534 | - $values['cancel'] = date("Y-m-d",strtotime($line[8])); |
|
| 535 | - $values['modes'] = $line[4]; |
|
| 536 | - $values['icao'] = $line[10]; |
|
| 530 | + $values['registration'] = $line[0]; |
|
| 531 | + $values['base'] = null; |
|
| 532 | + $values['owner'] = $line[6]; |
|
| 533 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
| 534 | + $values['cancel'] = date("Y-m-d",strtotime($line[8])); |
|
| 535 | + $values['modes'] = $line[4]; |
|
| 536 | + $values['icao'] = $line[10]; |
|
| 537 | 537 | } elseif ($country == 'OY') { |
| 538 | - $values['registration'] = $line[0]; |
|
| 539 | - $values['date_first_reg'] = date("Y-m-d",strtotime($line[4])); |
|
| 540 | - $values['modes'] = $line[5]; |
|
| 541 | - $values['icao'] = $line[6]; |
|
| 538 | + $values['registration'] = $line[0]; |
|
| 539 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[4])); |
|
| 540 | + $values['modes'] = $line[5]; |
|
| 541 | + $values['icao'] = $line[6]; |
|
| 542 | 542 | } elseif ($country == 'PH') { |
| 543 | - $values['registration'] = $line[0]; |
|
| 544 | - $values['date_first_reg'] = date("Y-m-d",strtotime($line[3])); |
|
| 545 | - $values['modes'] = $line[4]; |
|
| 546 | - $values['icao'] = $line[5]; |
|
| 543 | + $values['registration'] = $line[0]; |
|
| 544 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[3])); |
|
| 545 | + $values['modes'] = $line[4]; |
|
| 546 | + $values['icao'] = $line[5]; |
|
| 547 | 547 | } elseif ($country == 'OM' || $country == 'TF') { |
| 548 | - $values['registration'] = $line[0]; |
|
| 549 | - $values['base'] = null; |
|
| 550 | - $values['owner'] = $line[3]; |
|
| 551 | - $values['date_first_reg'] = null; |
|
| 552 | - $values['cancel'] = ''; |
|
| 548 | + $values['registration'] = $line[0]; |
|
| 549 | + $values['base'] = null; |
|
| 550 | + $values['owner'] = $line[3]; |
|
| 551 | + $values['date_first_reg'] = null; |
|
| 552 | + $values['cancel'] = ''; |
|
| 553 | 553 | } |
| 554 | 554 | if (isset($values['cancel']) && $values['cancel'] == '' && $values['registration'] != null && isset($values['owner'])) { |
| 555 | 555 | $query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file); |
@@ -682,7 +682,7 @@ discard block |
||
| 682 | 682 | return "error : ".$e->getMessage(); |
| 683 | 683 | } |
| 684 | 684 | */ |
| 685 | - /* |
|
| 685 | + /* |
|
| 686 | 686 | $query = 'ALTER TABLE airport DROP INDEX icaoidx'; |
| 687 | 687 | try { |
| 688 | 688 | $Connection = new Connection(); |
@@ -927,10 +927,10 @@ discard block |
||
| 927 | 927 | try { |
| 928 | 928 | $Connection = new Connection(); |
| 929 | 929 | $sth = $Connection->db->prepare($query); |
| 930 | - $sth->execute(array(':source' => 'translation.csv')); |
|
| 931 | - } catch(PDOException $e) { |
|
| 932 | - return "error : ".$e->getMessage(); |
|
| 933 | - } |
|
| 930 | + $sth->execute(array(':source' => 'translation.csv')); |
|
| 931 | + } catch(PDOException $e) { |
|
| 932 | + return "error : ".$e->getMessage(); |
|
| 933 | + } |
|
| 934 | 934 | |
| 935 | 935 | |
| 936 | 936 | //update_db::unzip($out_file); |
@@ -949,21 +949,21 @@ discard block |
||
| 949 | 949 | $data = $row; |
| 950 | 950 | $operator = $data[2]; |
| 951 | 951 | if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) { |
| 952 | - $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2)); |
|
| 953 | - //echo substr($operator, 0, 2)."\n";; |
|
| 954 | - if (count($airline_array) > 0) { |
|
| 952 | + $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2)); |
|
| 953 | + //echo substr($operator, 0, 2)."\n";; |
|
| 954 | + if (count($airline_array) > 0) { |
|
| 955 | 955 | //print_r($airline_array); |
| 956 | 956 | $operator = $airline_array[0]['icao'].substr($operator,2); |
| 957 | - } |
|
| 958 | - } |
|
| 957 | + } |
|
| 958 | + } |
|
| 959 | 959 | |
| 960 | 960 | $operator_correct = $data[3]; |
| 961 | 961 | if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) { |
| 962 | - $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2)); |
|
| 963 | - if (count($airline_array) > 0) { |
|
| 964 | - $operator_correct = $airline_array[0]['icao'].substr($operator_correct,2); |
|
| 965 | - } |
|
| 966 | - } |
|
| 962 | + $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2)); |
|
| 963 | + if (count($airline_array) > 0) { |
|
| 964 | + $operator_correct = $airline_array[0]['icao'].substr($operator_correct,2); |
|
| 965 | + } |
|
| 966 | + } |
|
| 967 | 967 | $query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)'; |
| 968 | 968 | try { |
| 969 | 969 | $sth = $Connection->db->prepare($query); |
@@ -977,7 +977,7 @@ discard block |
||
| 977 | 977 | //$Connection->db->commit(); |
| 978 | 978 | } |
| 979 | 979 | return ''; |
| 980 | - } |
|
| 980 | + } |
|
| 981 | 981 | |
| 982 | 982 | public static function translation_fam() { |
| 983 | 983 | global $tmp_dir, $globalTransaction; |
@@ -1015,7 +1015,7 @@ discard block |
||
| 1015 | 1015 | //$Connection->db->commit(); |
| 1016 | 1016 | } |
| 1017 | 1017 | return ''; |
| 1018 | - } |
|
| 1018 | + } |
|
| 1019 | 1019 | |
| 1020 | 1020 | /* |
| 1021 | 1021 | * This function use FAA public data. |
@@ -1027,19 +1027,19 @@ discard block |
||
| 1027 | 1027 | try { |
| 1028 | 1028 | $Connection = new Connection(); |
| 1029 | 1029 | $sth = $Connection->db->prepare($query); |
| 1030 | - $sth->execute(array(':source' => 'website_faa')); |
|
| 1031 | - } catch(PDOException $e) { |
|
| 1032 | - return "error : ".$e->getMessage(); |
|
| 1033 | - } |
|
| 1030 | + $sth->execute(array(':source' => 'website_faa')); |
|
| 1031 | + } catch(PDOException $e) { |
|
| 1032 | + return "error : ".$e->getMessage(); |
|
| 1033 | + } |
|
| 1034 | 1034 | |
| 1035 | 1035 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source = :source"; |
| 1036 | 1036 | try { |
| 1037 | 1037 | $Connection = new Connection(); |
| 1038 | 1038 | $sth = $Connection->db->prepare($query); |
| 1039 | - $sth->execute(array(':source' => 'website_faa')); |
|
| 1040 | - } catch(PDOException $e) { |
|
| 1041 | - return "error : ".$e->getMessage(); |
|
| 1042 | - } |
|
| 1039 | + $sth->execute(array(':source' => 'website_faa')); |
|
| 1040 | + } catch(PDOException $e) { |
|
| 1041 | + return "error : ".$e->getMessage(); |
|
| 1042 | + } |
|
| 1043 | 1043 | |
| 1044 | 1044 | $delimiter = ","; |
| 1045 | 1045 | $mfr = array(); |
@@ -1207,7 +1207,7 @@ discard block |
||
| 1207 | 1207 | } |
| 1208 | 1208 | */ |
| 1209 | 1209 | return ''; |
| 1210 | - } |
|
| 1210 | + } |
|
| 1211 | 1211 | |
| 1212 | 1212 | public static function owner_fam() { |
| 1213 | 1213 | global $tmp_dir, $globalTransaction; |
@@ -1215,10 +1215,10 @@ discard block |
||
| 1215 | 1215 | try { |
| 1216 | 1216 | $Connection = new Connection(); |
| 1217 | 1217 | $sth = $Connection->db->prepare($query); |
| 1218 | - $sth->execute(array(':source' => 'website_fam')); |
|
| 1219 | - } catch(PDOException $e) { |
|
| 1220 | - return "error : ".$e->getMessage(); |
|
| 1221 | - } |
|
| 1218 | + $sth->execute(array(':source' => 'website_fam')); |
|
| 1219 | + } catch(PDOException $e) { |
|
| 1220 | + return "error : ".$e->getMessage(); |
|
| 1221 | + } |
|
| 1222 | 1222 | |
| 1223 | 1223 | $delimiter = "\t"; |
| 1224 | 1224 | $Connection = new Connection(); |
@@ -1244,7 +1244,7 @@ discard block |
||
| 1244 | 1244 | if ($globalTransaction) $Connection->db->commit(); |
| 1245 | 1245 | } |
| 1246 | 1246 | return ''; |
| 1247 | - } |
|
| 1247 | + } |
|
| 1248 | 1248 | |
| 1249 | 1249 | public static function routes_fam() { |
| 1250 | 1250 | global $tmp_dir, $globalTransaction, $globalDebug; |
@@ -1286,7 +1286,7 @@ discard block |
||
| 1286 | 1286 | if ($globalTransaction) $Connection->db->commit(); |
| 1287 | 1287 | } |
| 1288 | 1288 | return ''; |
| 1289 | - } |
|
| 1289 | + } |
|
| 1290 | 1290 | |
| 1291 | 1291 | public static function marine_identity_fam() { |
| 1292 | 1292 | global $tmp_dir, $globalTransaction; |
@@ -1294,10 +1294,10 @@ discard block |
||
| 1294 | 1294 | try { |
| 1295 | 1295 | $Connection = new Connection(); |
| 1296 | 1296 | $sth = $Connection->db->prepare($query); |
| 1297 | - $sth->execute(); |
|
| 1298 | - } catch(PDOException $e) { |
|
| 1299 | - return "error : ".$e->getMessage(); |
|
| 1300 | - } |
|
| 1297 | + $sth->execute(); |
|
| 1298 | + } catch(PDOException $e) { |
|
| 1299 | + return "error : ".$e->getMessage(); |
|
| 1300 | + } |
|
| 1301 | 1301 | |
| 1302 | 1302 | |
| 1303 | 1303 | //update_db::unzip($out_file); |
@@ -1327,7 +1327,7 @@ discard block |
||
| 1327 | 1327 | if ($globalTransaction) $Connection->db->commit(); |
| 1328 | 1328 | } |
| 1329 | 1329 | return ''; |
| 1330 | - } |
|
| 1330 | + } |
|
| 1331 | 1331 | |
| 1332 | 1332 | public static function satellite_fam() { |
| 1333 | 1333 | global $tmp_dir, $globalTransaction; |
@@ -1398,7 +1398,7 @@ discard block |
||
| 1398 | 1398 | if ($globalTransaction) $Connection->db->commit(); |
| 1399 | 1399 | } |
| 1400 | 1400 | return ''; |
| 1401 | - } |
|
| 1401 | + } |
|
| 1402 | 1402 | |
| 1403 | 1403 | public static function tle($filename,$tletype) { |
| 1404 | 1404 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
@@ -1409,10 +1409,10 @@ discard block |
||
| 1409 | 1409 | try { |
| 1410 | 1410 | $Connection = new Connection(); |
| 1411 | 1411 | $sth = $Connection->db->prepare($query); |
| 1412 | - $sth->execute(array(':source' => $filename)); |
|
| 1413 | - } catch(PDOException $e) { |
|
| 1414 | - return "error : ".$e->getMessage(); |
|
| 1415 | - } |
|
| 1412 | + $sth->execute(array(':source' => $filename)); |
|
| 1413 | + } catch(PDOException $e) { |
|
| 1414 | + return "error : ".$e->getMessage(); |
|
| 1415 | + } |
|
| 1416 | 1416 | |
| 1417 | 1417 | $Connection = new Connection(); |
| 1418 | 1418 | if (($handle = fopen($filename, 'r')) !== FALSE) |
@@ -1447,7 +1447,7 @@ discard block |
||
| 1447 | 1447 | //$Connection->db->commit(); |
| 1448 | 1448 | } |
| 1449 | 1449 | return ''; |
| 1450 | - } |
|
| 1450 | + } |
|
| 1451 | 1451 | |
| 1452 | 1452 | public static function satellite_ucsdb($filename) { |
| 1453 | 1453 | global $tmp_dir, $globalTransaction; |
@@ -1706,11 +1706,11 @@ discard block |
||
| 1706 | 1706 | try { |
| 1707 | 1707 | $sth = $Connection->db->prepare($query); |
| 1708 | 1708 | $sth->execute(array( |
| 1709 | - ':name' => $result['name'], ':name_alternate' => '', ':country_un' => '', ':country_owner' => $result['country_owner'], ':owner' => $result['owner'], ':users' => '', ':purpose' => '', ':purpose_detailed' => '', ':orbit' => $result['status'], |
|
| 1710 | - ':type' => '', ':longitude_geo' => NULL, ':perigee' => !empty($result['perigee']) ? $result['perigee'] : NULL, ':apogee' => !empty($result['apogee']) ? $result['apogee'] : NULL, ':eccentricity' => NULL, ':inclination' => $result['inclination'], |
|
| 1711 | - ':period' => !empty($result['period']) ? $result['period'] : NULL, ':launch_mass' => NULL, ':dry_mass' => NULL, ':power' => NULL, ':launch_date' => $result['launch_date'], ':lifetime' => $result['lifetime'], |
|
| 1712 | - ':contractor' => '',':country_contractor' => '', ':launch_site' => $result['launch_site'], ':launch_vehicule' => '', ':cospar' => $result['cospar'], ':norad' => $result['norad'], ':comments' => '', ':source_orbital' => '', ':sources' => '' |
|
| 1713 | - ) |
|
| 1709 | + ':name' => $result['name'], ':name_alternate' => '', ':country_un' => '', ':country_owner' => $result['country_owner'], ':owner' => $result['owner'], ':users' => '', ':purpose' => '', ':purpose_detailed' => '', ':orbit' => $result['status'], |
|
| 1710 | + ':type' => '', ':longitude_geo' => NULL, ':perigee' => !empty($result['perigee']) ? $result['perigee'] : NULL, ':apogee' => !empty($result['apogee']) ? $result['apogee'] : NULL, ':eccentricity' => NULL, ':inclination' => $result['inclination'], |
|
| 1711 | + ':period' => !empty($result['period']) ? $result['period'] : NULL, ':launch_mass' => NULL, ':dry_mass' => NULL, ':power' => NULL, ':launch_date' => $result['launch_date'], ':lifetime' => $result['lifetime'], |
|
| 1712 | + ':contractor' => '',':country_contractor' => '', ':launch_site' => $result['launch_site'], ':launch_vehicule' => '', ':cospar' => $result['cospar'], ':norad' => $result['norad'], ':comments' => '', ':source_orbital' => '', ':sources' => '' |
|
| 1713 | + ) |
|
| 1714 | 1714 | ); |
| 1715 | 1715 | } catch(PDOException $e) { |
| 1716 | 1716 | return "error : ".$e->getMessage(); |
@@ -1734,13 +1734,13 @@ discard block |
||
| 1734 | 1734 | //$Connection->db->commit(); |
| 1735 | 1735 | } |
| 1736 | 1736 | return ''; |
| 1737 | - } |
|
| 1737 | + } |
|
| 1738 | 1738 | |
| 1739 | 1739 | /** |
| 1740 | - * Convert a HTML table to an array |
|
| 1741 | - * @param String $data HTML page |
|
| 1742 | - * @return Array array of the tables in HTML page |
|
| 1743 | - */ |
|
| 1740 | + * Convert a HTML table to an array |
|
| 1741 | + * @param String $data HTML page |
|
| 1742 | + * @return Array array of the tables in HTML page |
|
| 1743 | + */ |
|
| 1744 | 1744 | /* |
| 1745 | 1745 | private static function table2array($data) { |
| 1746 | 1746 | $html = str_get_html($data); |
@@ -1770,11 +1770,11 @@ discard block |
||
| 1770 | 1770 | return(array_filter($tabledata)); |
| 1771 | 1771 | } |
| 1772 | 1772 | */ |
| 1773 | - /** |
|
| 1774 | - * Get data from form result |
|
| 1775 | - * @param String $url form URL |
|
| 1776 | - * @return String the result |
|
| 1777 | - */ |
|
| 1773 | + /** |
|
| 1774 | + * Get data from form result |
|
| 1775 | + * @param String $url form URL |
|
| 1776 | + * @return String the result |
|
| 1777 | + */ |
|
| 1778 | 1778 | /* |
| 1779 | 1779 | private static function getData($url) { |
| 1780 | 1780 | $ch = curl_init(); |
@@ -1924,7 +1924,7 @@ discard block |
||
| 1924 | 1924 | if ($globalTransaction) $Connection->db->commit(); |
| 1925 | 1925 | } |
| 1926 | 1926 | return ''; |
| 1927 | - } |
|
| 1927 | + } |
|
| 1928 | 1928 | |
| 1929 | 1929 | public static function update_airspace() { |
| 1930 | 1930 | global $tmp_dir, $globalDBdriver; |
@@ -1934,11 +1934,11 @@ discard block |
||
| 1934 | 1934 | $query = 'DROP TABLE airspace'; |
| 1935 | 1935 | try { |
| 1936 | 1936 | $sth = $Connection->db->prepare($query); |
| 1937 | - $sth->execute(); |
|
| 1938 | - } catch(PDOException $e) { |
|
| 1937 | + $sth->execute(); |
|
| 1938 | + } catch(PDOException $e) { |
|
| 1939 | 1939 | return "error : ".$e->getMessage(); |
| 1940 | - } |
|
| 1941 | - } |
|
| 1940 | + } |
|
| 1941 | + } |
|
| 1942 | 1942 | |
| 1943 | 1943 | |
| 1944 | 1944 | if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
@@ -2003,10 +2003,10 @@ discard block |
||
| 2003 | 2003 | $query = 'DROP TABLE countries'; |
| 2004 | 2004 | try { |
| 2005 | 2005 | $sth = $Connection->db->prepare($query); |
| 2006 | - $sth->execute(); |
|
| 2007 | - } catch(PDOException $e) { |
|
| 2008 | - echo "error : ".$e->getMessage(); |
|
| 2009 | - } |
|
| 2006 | + $sth->execute(); |
|
| 2007 | + } catch(PDOException $e) { |
|
| 2008 | + echo "error : ".$e->getMessage(); |
|
| 2009 | + } |
|
| 2010 | 2010 | } |
| 2011 | 2011 | if ($globalDBdriver == 'mysql') { |
| 2012 | 2012 | update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql'); |
@@ -2465,7 +2465,7 @@ discard block |
||
| 2465 | 2465 | $error = update_db::airlines_fam(); |
| 2466 | 2466 | update_db::insert_airlines_version($airlines_md5); |
| 2467 | 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."; |
|
| 2468 | + } else $error = "File ".$tmp_dir.'airlines.tsv.gz'." doesn't exist. Download failed."; |
|
| 2469 | 2469 | } elseif ($globalDebug) echo "No update."; |
| 2470 | 2470 | } else $error = "File ".$tmp_dir.'airlines.tsv.gz.md5'." doesn't exist. Download failed."; |
| 2471 | 2471 | if ($error != '') { |
@@ -2956,10 +2956,10 @@ discard block |
||
| 2956 | 2956 | try { |
| 2957 | 2957 | $Connection = new Connection(); |
| 2958 | 2958 | $sth = $Connection->db->prepare($query); |
| 2959 | - $sth->execute(); |
|
| 2960 | - } catch(PDOException $e) { |
|
| 2961 | - return "error : ".$e->getMessage(); |
|
| 2962 | - } |
|
| 2959 | + $sth->execute(); |
|
| 2960 | + } catch(PDOException $e) { |
|
| 2961 | + return "error : ".$e->getMessage(); |
|
| 2962 | + } |
|
| 2963 | 2963 | |
| 2964 | 2964 | $error = ''; |
| 2965 | 2965 | if ($globalDebug) echo "Notam : Download..."; |
@@ -3015,8 +3015,8 @@ discard block |
||
| 3015 | 3015 | $data['date_end'] = date("Y-m-d H:i:s",strtotime($to)); |
| 3016 | 3016 | $data['permanent'] = 0; |
| 3017 | 3017 | } else { |
| 3018 | - $data['date_end'] = NULL; |
|
| 3019 | - $data['permanent'] = 1; |
|
| 3018 | + $data['date_end'] = NULL; |
|
| 3019 | + $data['permanent'] = 1; |
|
| 3020 | 3020 | } |
| 3021 | 3021 | $data['full_notam'] = $notam['title'].'<br>'.$notam['description']; |
| 3022 | 3022 | $NOTAM = new NOTAM(); |
@@ -3090,13 +3090,13 @@ discard block |
||
| 3090 | 3090 | try { |
| 3091 | 3091 | $Connection = new Connection(); |
| 3092 | 3092 | $sth = $Connection->db->prepare($query); |
| 3093 | - $sth->execute(); |
|
| 3094 | - } catch(PDOException $e) { |
|
| 3095 | - return "error : ".$e->getMessage(); |
|
| 3096 | - } |
|
| 3097 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 3098 | - if ($row['nb'] > 0) return false; |
|
| 3099 | - else return true; |
|
| 3093 | + $sth->execute(); |
|
| 3094 | + } catch(PDOException $e) { |
|
| 3095 | + return "error : ".$e->getMessage(); |
|
| 3096 | + } |
|
| 3097 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 3098 | + if ($row['nb'] > 0) return false; |
|
| 3099 | + else return true; |
|
| 3100 | 3100 | } |
| 3101 | 3101 | |
| 3102 | 3102 | public static function insert_last_update() { |
@@ -3105,10 +3105,10 @@ discard block |
||
| 3105 | 3105 | try { |
| 3106 | 3106 | $Connection = new Connection(); |
| 3107 | 3107 | $sth = $Connection->db->prepare($query); |
| 3108 | - $sth->execute(); |
|
| 3109 | - } catch(PDOException $e) { |
|
| 3110 | - return "error : ".$e->getMessage(); |
|
| 3111 | - } |
|
| 3108 | + $sth->execute(); |
|
| 3109 | + } catch(PDOException $e) { |
|
| 3110 | + return "error : ".$e->getMessage(); |
|
| 3111 | + } |
|
| 3112 | 3112 | } |
| 3113 | 3113 | |
| 3114 | 3114 | public static function check_airspace_version($version) { |
@@ -3116,13 +3116,13 @@ discard block |
||
| 3116 | 3116 | try { |
| 3117 | 3117 | $Connection = new Connection(); |
| 3118 | 3118 | $sth = $Connection->db->prepare($query); |
| 3119 | - $sth->execute(array(':version' => $version)); |
|
| 3120 | - } catch(PDOException $e) { |
|
| 3121 | - return "error : ".$e->getMessage(); |
|
| 3122 | - } |
|
| 3123 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 3124 | - if ($row['nb'] > 0) return true; |
|
| 3125 | - else return false; |
|
| 3119 | + $sth->execute(array(':version' => $version)); |
|
| 3120 | + } catch(PDOException $e) { |
|
| 3121 | + return "error : ".$e->getMessage(); |
|
| 3122 | + } |
|
| 3123 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 3124 | + if ($row['nb'] > 0) return true; |
|
| 3125 | + else return false; |
|
| 3126 | 3126 | } |
| 3127 | 3127 | |
| 3128 | 3128 | public static function check_geoid_version($version) { |
@@ -3130,13 +3130,13 @@ discard block |
||
| 3130 | 3130 | try { |
| 3131 | 3131 | $Connection = new Connection(); |
| 3132 | 3132 | $sth = $Connection->db->prepare($query); |
| 3133 | - $sth->execute(array(':version' => $version)); |
|
| 3134 | - } catch(PDOException $e) { |
|
| 3135 | - return "error : ".$e->getMessage(); |
|
| 3136 | - } |
|
| 3137 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 3138 | - if ($row['nb'] > 0) return true; |
|
| 3139 | - else return false; |
|
| 3133 | + $sth->execute(array(':version' => $version)); |
|
| 3134 | + } catch(PDOException $e) { |
|
| 3135 | + return "error : ".$e->getMessage(); |
|
| 3136 | + } |
|
| 3137 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 3138 | + if ($row['nb'] > 0) return true; |
|
| 3139 | + else return false; |
|
| 3140 | 3140 | } |
| 3141 | 3141 | |
| 3142 | 3142 | public static function check_marine_identity_version($version) { |
@@ -3237,10 +3237,10 @@ discard block |
||
| 3237 | 3237 | try { |
| 3238 | 3238 | $Connection = new Connection(); |
| 3239 | 3239 | $sth = $Connection->db->prepare($query); |
| 3240 | - $sth->execute(array(':version' => $version)); |
|
| 3241 | - } catch(PDOException $e) { |
|
| 3242 | - return "error : ".$e->getMessage(); |
|
| 3243 | - } |
|
| 3240 | + $sth->execute(array(':version' => $version)); |
|
| 3241 | + } catch(PDOException $e) { |
|
| 3242 | + return "error : ".$e->getMessage(); |
|
| 3243 | + } |
|
| 3244 | 3244 | } |
| 3245 | 3245 | |
| 3246 | 3246 | public static function insert_marine_identity_version($version) { |
@@ -3277,13 +3277,13 @@ discard block |
||
| 3277 | 3277 | try { |
| 3278 | 3278 | $Connection = new Connection(); |
| 3279 | 3279 | $sth = $Connection->db->prepare($query); |
| 3280 | - $sth->execute(); |
|
| 3281 | - } catch(PDOException $e) { |
|
| 3282 | - return "error : ".$e->getMessage(); |
|
| 3283 | - } |
|
| 3284 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 3285 | - if ($row['nb'] > 0) return false; |
|
| 3286 | - else return true; |
|
| 3280 | + $sth->execute(); |
|
| 3281 | + } catch(PDOException $e) { |
|
| 3282 | + return "error : ".$e->getMessage(); |
|
| 3283 | + } |
|
| 3284 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 3285 | + if ($row['nb'] > 0) return false; |
|
| 3286 | + else return true; |
|
| 3287 | 3287 | } |
| 3288 | 3288 | |
| 3289 | 3289 | public static function insert_last_notam_update() { |
@@ -3292,10 +3292,10 @@ discard block |
||
| 3292 | 3292 | try { |
| 3293 | 3293 | $Connection = new Connection(); |
| 3294 | 3294 | $sth = $Connection->db->prepare($query); |
| 3295 | - $sth->execute(); |
|
| 3296 | - } catch(PDOException $e) { |
|
| 3297 | - return "error : ".$e->getMessage(); |
|
| 3298 | - } |
|
| 3295 | + $sth->execute(); |
|
| 3296 | + } catch(PDOException $e) { |
|
| 3297 | + return "error : ".$e->getMessage(); |
|
| 3298 | + } |
|
| 3299 | 3299 | } |
| 3300 | 3300 | |
| 3301 | 3301 | public static function check_last_airspace_update() { |
@@ -3308,13 +3308,13 @@ discard block |
||
| 3308 | 3308 | try { |
| 3309 | 3309 | $Connection = new Connection(); |
| 3310 | 3310 | $sth = $Connection->db->prepare($query); |
| 3311 | - $sth->execute(); |
|
| 3312 | - } catch(PDOException $e) { |
|
| 3313 | - return "error : ".$e->getMessage(); |
|
| 3314 | - } |
|
| 3315 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 3316 | - if ($row['nb'] > 0) return false; |
|
| 3317 | - else return true; |
|
| 3311 | + $sth->execute(); |
|
| 3312 | + } catch(PDOException $e) { |
|
| 3313 | + return "error : ".$e->getMessage(); |
|
| 3314 | + } |
|
| 3315 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 3316 | + if ($row['nb'] > 0) return false; |
|
| 3317 | + else return true; |
|
| 3318 | 3318 | } |
| 3319 | 3319 | |
| 3320 | 3320 | public static function insert_last_airspace_update() { |
@@ -3323,10 +3323,10 @@ discard block |
||
| 3323 | 3323 | try { |
| 3324 | 3324 | $Connection = new Connection(); |
| 3325 | 3325 | $sth = $Connection->db->prepare($query); |
| 3326 | - $sth->execute(); |
|
| 3327 | - } catch(PDOException $e) { |
|
| 3328 | - return "error : ".$e->getMessage(); |
|
| 3329 | - } |
|
| 3326 | + $sth->execute(); |
|
| 3327 | + } catch(PDOException $e) { |
|
| 3328 | + return "error : ".$e->getMessage(); |
|
| 3329 | + } |
|
| 3330 | 3330 | } |
| 3331 | 3331 | |
| 3332 | 3332 | public static function check_last_geoid_update() { |
@@ -3339,13 +3339,13 @@ discard block |
||
| 3339 | 3339 | try { |
| 3340 | 3340 | $Connection = new Connection(); |
| 3341 | 3341 | $sth = $Connection->db->prepare($query); |
| 3342 | - $sth->execute(); |
|
| 3343 | - } catch(PDOException $e) { |
|
| 3344 | - return "error : ".$e->getMessage(); |
|
| 3345 | - } |
|
| 3346 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 3347 | - if ($row['nb'] > 0) return false; |
|
| 3348 | - else return true; |
|
| 3342 | + $sth->execute(); |
|
| 3343 | + } catch(PDOException $e) { |
|
| 3344 | + return "error : ".$e->getMessage(); |
|
| 3345 | + } |
|
| 3346 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 3347 | + if ($row['nb'] > 0) return false; |
|
| 3348 | + else return true; |
|
| 3349 | 3349 | } |
| 3350 | 3350 | |
| 3351 | 3351 | public static function insert_last_geoid_update() { |
@@ -3354,10 +3354,10 @@ discard block |
||
| 3354 | 3354 | try { |
| 3355 | 3355 | $Connection = new Connection(); |
| 3356 | 3356 | $sth = $Connection->db->prepare($query); |
| 3357 | - $sth->execute(); |
|
| 3358 | - } catch(PDOException $e) { |
|
| 3359 | - return "error : ".$e->getMessage(); |
|
| 3360 | - } |
|
| 3357 | + $sth->execute(); |
|
| 3358 | + } catch(PDOException $e) { |
|
| 3359 | + return "error : ".$e->getMessage(); |
|
| 3360 | + } |
|
| 3361 | 3361 | } |
| 3362 | 3362 | |
| 3363 | 3363 | public static function check_last_owner_update() { |
@@ -3463,13 +3463,13 @@ discard block |
||
| 3463 | 3463 | try { |
| 3464 | 3464 | $Connection = new Connection(); |
| 3465 | 3465 | $sth = $Connection->db->prepare($query); |
| 3466 | - $sth->execute(); |
|
| 3467 | - } catch(PDOException $e) { |
|
| 3468 | - return "error : ".$e->getMessage(); |
|
| 3469 | - } |
|
| 3470 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 3471 | - if ($row['nb'] > 0) return false; |
|
| 3472 | - else return true; |
|
| 3466 | + $sth->execute(); |
|
| 3467 | + } catch(PDOException $e) { |
|
| 3468 | + return "error : ".$e->getMessage(); |
|
| 3469 | + } |
|
| 3470 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 3471 | + if ($row['nb'] > 0) return false; |
|
| 3472 | + else return true; |
|
| 3473 | 3473 | } |
| 3474 | 3474 | |
| 3475 | 3475 | public static function insert_last_schedules_update() { |
@@ -3649,10 +3649,10 @@ discard block |
||
| 3649 | 3649 | try { |
| 3650 | 3650 | $Connection = new Connection(); |
| 3651 | 3651 | $sth = $Connection->db->prepare($query); |
| 3652 | - $sth->execute(); |
|
| 3653 | - } catch(PDOException $e) { |
|
| 3654 | - return "error : ".$e->getMessage(); |
|
| 3655 | - } |
|
| 3652 | + $sth->execute(); |
|
| 3653 | + } catch(PDOException $e) { |
|
| 3654 | + return "error : ".$e->getMessage(); |
|
| 3655 | + } |
|
| 3656 | 3656 | } |
| 3657 | 3657 | public static function delete_duplicateowner() { |
| 3658 | 3658 | global $globalDBdriver; |
@@ -3664,10 +3664,10 @@ discard block |
||
| 3664 | 3664 | try { |
| 3665 | 3665 | $Connection = new Connection(); |
| 3666 | 3666 | $sth = $Connection->db->prepare($query); |
| 3667 | - $sth->execute(); |
|
| 3668 | - } catch(PDOException $e) { |
|
| 3669 | - return "error : ".$e->getMessage(); |
|
| 3670 | - } |
|
| 3667 | + $sth->execute(); |
|
| 3668 | + } catch(PDOException $e) { |
|
| 3669 | + return "error : ".$e->getMessage(); |
|
| 3670 | + } |
|
| 3671 | 3671 | } |
| 3672 | 3672 | |
| 3673 | 3673 | public static function update_all() { |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | $ch = curl_init(); |
| 17 | 17 | curl_setopt($ch, CURLOPT_URL, $url); |
| 18 | 18 | if (isset($globalForceIPv4) && $globalForceIPv4) { |
| 19 | - if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')){ |
|
| 19 | + if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')) { |
|
| 20 | 20 | curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); |
| 21 | 21 | } |
| 22 | 22 | } |
@@ -34,20 +34,20 @@ discard block |
||
| 34 | 34 | fclose($fp); |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - public static function gunzip($in_file,$out_file_name = '') { |
|
| 37 | + public static function gunzip($in_file, $out_file_name = '') { |
|
| 38 | 38 | //echo $in_file.' -> '.$out_file_name."\n"; |
| 39 | 39 | $buffer_size = 4096; // read 4kb at a time |
| 40 | 40 | if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); |
| 41 | 41 | if ($in_file != '' && file_exists($in_file)) { |
| 42 | 42 | // 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'); |
|
| 43 | + if (function_exists('gzopen')) $file = gzopen($in_file, 'rb'); |
|
| 44 | + elseif (function_exists('gzopen64')) $file = gzopen64($in_file, 'rb'); |
|
| 45 | 45 | else { |
| 46 | 46 | echo 'gzopen not available'; |
| 47 | 47 | die; |
| 48 | 48 | } |
| 49 | 49 | $out_file = fopen($out_file_name, 'wb'); |
| 50 | - while(!gzeof($file)) { |
|
| 50 | + while (!gzeof($file)) { |
|
| 51 | 51 | fwrite($out_file, gzread($file, $buffer_size)); |
| 52 | 52 | } |
| 53 | 53 | fclose($out_file); |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | try { |
| 72 | 72 | self::$db_sqlite = new PDO('sqlite:'.$database); |
| 73 | 73 | self::$db_sqlite->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
| 74 | - } catch(PDOException $e) { |
|
| 74 | + } catch (PDOException $e) { |
|
| 75 | 75 | return "error : ".$e->getMessage(); |
| 76 | 76 | } |
| 77 | 77 | } |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | //$Connection = new Connection(); |
| 87 | 87 | $sth = $Connection->db->prepare($query); |
| 88 | 88 | $sth->execute(array(':source' => $database_file)); |
| 89 | - } catch(PDOException $e) { |
|
| 89 | + } catch (PDOException $e) { |
|
| 90 | 90 | return "error : ".$e->getMessage(); |
| 91 | 91 | } |
| 92 | 92 | |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | try { |
| 98 | 98 | $sth = update_db::$db_sqlite->prepare($query); |
| 99 | 99 | $sth->execute(); |
| 100 | - } catch(PDOException $e) { |
|
| 100 | + } catch (PDOException $e) { |
|
| 101 | 101 | return "error : ".$e->getMessage(); |
| 102 | 102 | } |
| 103 | 103 | //$query_dest = 'INSERT INTO routes (`RouteID`,`CallSign`,`Operator_ICAO`,`FromAirport_ICAO`,`ToAirport_ICAO`,`RouteStop`,`Source`) VALUES (:RouteID, :CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)'; |
@@ -108,11 +108,11 @@ discard block |
||
| 108 | 108 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 109 | 109 | while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
| 110 | 110 | //$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 | - $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); |
|
| 111 | + $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 | 112 | $sth_dest->execute($query_dest_values); |
| 113 | 113 | } |
| 114 | 114 | if ($globalTransaction) $Connection->db->commit(); |
| 115 | - } catch(PDOException $e) { |
|
| 115 | + } catch (PDOException $e) { |
|
| 116 | 116 | if ($globalTransaction) $Connection->db->rollBack(); |
| 117 | 117 | return "error : ".$e->getMessage(); |
| 118 | 118 | } |
@@ -128,26 +128,26 @@ discard block |
||
| 128 | 128 | //$Connection = new Connection(); |
| 129 | 129 | $sth = $Connection->db->prepare($query); |
| 130 | 130 | $sth->execute(array(':source' => 'oneworld')); |
| 131 | - } catch(PDOException $e) { |
|
| 131 | + } catch (PDOException $e) { |
|
| 132 | 132 | return "error : ".$e->getMessage(); |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | if ($globalDebug) echo " - Add routes to DB -"; |
| 136 | 136 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 137 | 137 | $Spotter = new Spotter(); |
| 138 | - if ($fh = fopen($database_file,"r")) { |
|
| 138 | + if ($fh = fopen($database_file, "r")) { |
|
| 139 | 139 | $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 | 140 | $Connection = new Connection(); |
| 141 | 141 | $sth_dest = $Connection->db->prepare($query_dest); |
| 142 | 142 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 143 | 143 | while (!feof($fh)) { |
| 144 | - $line = fgetcsv($fh,9999,','); |
|
| 144 | + $line = fgetcsv($fh, 9999, ','); |
|
| 145 | 145 | if ($line[0] != '') { |
| 146 | 146 | if (($line[2] == '-' || ($line[2] != '-' && (strtotime($line[2]) > time()))) && ($line[3] == '-' || ($line[3] != '-' && (strtotime($line[3]) < time())))) { |
| 147 | 147 | try { |
| 148 | - $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'); |
|
| 148 | + $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 | 149 | $sth_dest->execute($query_dest_values); |
| 150 | - } catch(PDOException $e) { |
|
| 150 | + } catch (PDOException $e) { |
|
| 151 | 151 | if ($globalTransaction) $Connection->db->rollBack(); |
| 152 | 152 | return "error : ".$e->getMessage(); |
| 153 | 153 | } |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | //$Connection = new Connection(); |
| 170 | 170 | $sth = $Connection->db->prepare($query); |
| 171 | 171 | $sth->execute(array(':source' => 'skyteam')); |
| 172 | - } catch(PDOException $e) { |
|
| 172 | + } catch (PDOException $e) { |
|
| 173 | 173 | return "error : ".$e->getMessage(); |
| 174 | 174 | } |
| 175 | 175 | |
@@ -177,24 +177,24 @@ discard block |
||
| 177 | 177 | |
| 178 | 178 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 179 | 179 | $Spotter = new Spotter(); |
| 180 | - if ($fh = fopen($database_file,"r")) { |
|
| 180 | + if ($fh = fopen($database_file, "r")) { |
|
| 181 | 181 | $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)'; |
| 182 | 182 | $Connection = new Connection(); |
| 183 | 183 | $sth_dest = $Connection->db->prepare($query_dest); |
| 184 | 184 | try { |
| 185 | 185 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 186 | 186 | while (!feof($fh)) { |
| 187 | - $line = fgetcsv($fh,9999,','); |
|
| 187 | + $line = fgetcsv($fh, 9999, ','); |
|
| 188 | 188 | if ($line[0] != '') { |
| 189 | - $datebe = explode(' - ',$line[2]); |
|
| 189 | + $datebe = explode(' - ', $line[2]); |
|
| 190 | 190 | if (strtotime($datebe[0]) > time() && strtotime($datebe[1]) < time()) { |
| 191 | - $query_dest_values = array(':CallSign' => str_replace('*','',$line[6]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[4],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[5],':routestop' => '',':source' => 'skyteam'); |
|
| 191 | + $query_dest_values = array(':CallSign' => str_replace('*', '', $line[6]), ':Operator_ICAO' => '', ':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]), ':FromAirport_Time' => $line[4], ':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]), ':ToAirport_Time' => $line[5], ':routestop' => '', ':source' => 'skyteam'); |
|
| 192 | 192 | $sth_dest->execute($query_dest_values); |
| 193 | 193 | } |
| 194 | 194 | } |
| 195 | 195 | } |
| 196 | 196 | if ($globalTransaction) $Connection->db->commit(); |
| 197 | - } catch(PDOException $e) { |
|
| 197 | + } catch (PDOException $e) { |
|
| 198 | 198 | if ($globalTransaction) $Connection->db->rollBack(); |
| 199 | 199 | return "error : ".$e->getMessage(); |
| 200 | 200 | } |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | $Connection = new Connection(); |
| 210 | 210 | $sth = $Connection->db->prepare($query); |
| 211 | 211 | $sth->execute(array(':source' => $database_file)); |
| 212 | - } catch(PDOException $e) { |
|
| 212 | + } catch (PDOException $e) { |
|
| 213 | 213 | return "error : ".$e->getMessage(); |
| 214 | 214 | } |
| 215 | 215 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source"; |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | $Connection = new Connection(); |
| 218 | 218 | $sth = $Connection->db->prepare($query); |
| 219 | 219 | $sth->execute(array(':source' => $database_file)); |
| 220 | - } catch(PDOException $e) { |
|
| 220 | + } catch (PDOException $e) { |
|
| 221 | 221 | return "error : ".$e->getMessage(); |
| 222 | 222 | } |
| 223 | 223 | |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | try { |
| 227 | 227 | $sth = update_db::$db_sqlite->prepare($query); |
| 228 | 228 | $sth->execute(); |
| 229 | - } catch(PDOException $e) { |
|
| 229 | + } catch (PDOException $e) { |
|
| 230 | 230 | return "error : ".$e->getMessage(); |
| 231 | 231 | } |
| 232 | 232 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
@@ -243,15 +243,15 @@ discard block |
||
| 243 | 243 | //$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 | 244 | if ($values['UserString4'] == 'M') $type = 'military'; |
| 245 | 245 | else $type = null; |
| 246 | - $query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type); |
|
| 246 | + $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 | 247 | $sth_dest->execute($query_dest_values); |
| 248 | 248 | if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') { |
| 249 | - $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']); |
|
| 249 | + $query_dest_owner_values = array(':registration' => $values['Registration'], ':source' => $database_file, ':owner' => $values['RegisteredOwners']); |
|
| 250 | 250 | $sth_dest_owner->execute($query_dest_owner_values); |
| 251 | 251 | } |
| 252 | 252 | } |
| 253 | 253 | if ($globalTransaction) $Connection->db->commit(); |
| 254 | - } catch(PDOException $e) { |
|
| 254 | + } catch (PDOException $e) { |
|
| 255 | 255 | return "error : ".$e->getMessage(); |
| 256 | 256 | } |
| 257 | 257 | |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | $Connection = new Connection(); |
| 262 | 262 | $sth = $Connection->db->prepare($query); |
| 263 | 263 | $sth->execute(array(':source' => $database_file)); |
| 264 | - } catch(PDOException $e) { |
|
| 264 | + } catch (PDOException $e) { |
|
| 265 | 265 | return "error : ".$e->getMessage(); |
| 266 | 266 | } |
| 267 | 267 | return ''; |
@@ -276,11 +276,11 @@ discard block |
||
| 276 | 276 | $Connection = new Connection(); |
| 277 | 277 | $sth = $Connection->db->prepare($query); |
| 278 | 278 | $sth->execute(array(':source' => $database_file)); |
| 279 | - } catch(PDOException $e) { |
|
| 279 | + } catch (PDOException $e) { |
|
| 280 | 280 | return "error : ".$e->getMessage(); |
| 281 | 281 | } |
| 282 | 282 | |
| 283 | - if ($fh = fopen($database_file,"r")) { |
|
| 283 | + if ($fh = fopen($database_file, "r")) { |
|
| 284 | 284 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
| 285 | 285 | $query_dest = 'INSERT INTO aircraft_modes (ModeS,Registration,ICAOTypeCode,Source,source_type) VALUES (:ModeS,:Registration,:ICAOTypeCode,:source,:source_type)'; |
| 286 | 286 | |
@@ -290,13 +290,13 @@ discard block |
||
| 290 | 290 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 291 | 291 | while (!feof($fh)) { |
| 292 | 292 | $values = array(); |
| 293 | - $line = $Common->hex2str(fgets($fh,9999)); |
|
| 293 | + $line = $Common->hex2str(fgets($fh, 9999)); |
|
| 294 | 294 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
| 295 | - $values['ModeS'] = substr($line,0,6); |
|
| 296 | - $values['Registration'] = trim(substr($line,69,6)); |
|
| 297 | - $aircraft_name = trim(substr($line,48,6)); |
|
| 295 | + $values['ModeS'] = substr($line, 0, 6); |
|
| 296 | + $values['Registration'] = trim(substr($line, 69, 6)); |
|
| 297 | + $aircraft_name = trim(substr($line, 48, 6)); |
|
| 298 | 298 | // Check if we can find ICAO, else set it to GLID |
| 299 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
| 299 | + $aircraft_name_split = explode(' ', $aircraft_name); |
|
| 300 | 300 | $search_more = ''; |
| 301 | 301 | if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
| 302 | 302 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
@@ -308,20 +308,20 @@ discard block |
||
| 308 | 308 | if (isset($result['icao']) && $result['icao'] != '') { |
| 309 | 309 | $values['ICAOTypeCode'] = $result['icao']; |
| 310 | 310 | } |
| 311 | - } catch(PDOException $e) { |
|
| 311 | + } catch (PDOException $e) { |
|
| 312 | 312 | return "error : ".$e->getMessage(); |
| 313 | 313 | } |
| 314 | 314 | if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID'; |
| 315 | 315 | // Add data to db |
| 316 | 316 | if ($values['Registration'] != '' && $values['Registration'] != '0000') { |
| 317 | 317 | //$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']); |
| 318 | - $query_dest_values = array(':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':source_type' => 'flarm'); |
|
| 318 | + $query_dest_values = array(':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':source_type' => 'flarm'); |
|
| 319 | 319 | //print_r($query_dest_values); |
| 320 | 320 | $sth_dest->execute($query_dest_values); |
| 321 | 321 | } |
| 322 | 322 | } |
| 323 | 323 | if ($globalTransaction) $Connection->db->commit(); |
| 324 | - } catch(PDOException $e) { |
|
| 324 | + } catch (PDOException $e) { |
|
| 325 | 325 | return "error : ".$e->getMessage(); |
| 326 | 326 | } |
| 327 | 327 | } |
@@ -331,7 +331,7 @@ discard block |
||
| 331 | 331 | $Connection = new Connection(); |
| 332 | 332 | $sth = $Connection->db->prepare($query); |
| 333 | 333 | $sth->execute(array(':source' => $database_file)); |
| 334 | - } catch(PDOException $e) { |
|
| 334 | + } catch (PDOException $e) { |
|
| 335 | 335 | return "error : ".$e->getMessage(); |
| 336 | 336 | } |
| 337 | 337 | return ''; |
@@ -345,11 +345,11 @@ discard block |
||
| 345 | 345 | $Connection = new Connection(); |
| 346 | 346 | $sth = $Connection->db->prepare($query); |
| 347 | 347 | $sth->execute(array(':source' => $database_file)); |
| 348 | - } catch(PDOException $e) { |
|
| 348 | + } catch (PDOException $e) { |
|
| 349 | 349 | return "error : ".$e->getMessage(); |
| 350 | 350 | } |
| 351 | 351 | |
| 352 | - if ($fh = fopen($database_file,"r")) { |
|
| 352 | + if ($fh = fopen($database_file, "r")) { |
|
| 353 | 353 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
| 354 | 354 | $query_dest = 'INSERT INTO aircraft_modes (LastModified,ModeS,Registration,ICAOTypeCode,Source,source_type) VALUES (:lastmodified,:ModeS,:Registration,:ICAOTypeCode,:source,:source_type)'; |
| 355 | 355 | |
@@ -357,9 +357,9 @@ discard block |
||
| 357 | 357 | $sth_dest = $Connection->db->prepare($query_dest); |
| 358 | 358 | try { |
| 359 | 359 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 360 | - $tmp = fgetcsv($fh,9999,',',"'"); |
|
| 360 | + $tmp = fgetcsv($fh, 9999, ',', "'"); |
|
| 361 | 361 | while (!feof($fh)) { |
| 362 | - $line = fgetcsv($fh,9999,',',"'"); |
|
| 362 | + $line = fgetcsv($fh, 9999, ',', "'"); |
|
| 363 | 363 | |
| 364 | 364 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
| 365 | 365 | //print_r($line); |
@@ -368,7 +368,7 @@ discard block |
||
| 368 | 368 | $values['ICAOTypeCode'] = ''; |
| 369 | 369 | $aircraft_name = $line[2]; |
| 370 | 370 | // Check if we can find ICAO, else set it to GLID |
| 371 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
| 371 | + $aircraft_name_split = explode(' ', $aircraft_name); |
|
| 372 | 372 | $search_more = ''; |
| 373 | 373 | if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
| 374 | 374 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
@@ -377,20 +377,20 @@ discard block |
||
| 377 | 377 | $sth_search->execute(); |
| 378 | 378 | $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
| 379 | 379 | if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
| 380 | - } catch(PDOException $e) { |
|
| 380 | + } catch (PDOException $e) { |
|
| 381 | 381 | return "error : ".$e->getMessage(); |
| 382 | 382 | } |
| 383 | 383 | //if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID'; |
| 384 | 384 | // Add data to db |
| 385 | 385 | if ($values['Registration'] != '' && $values['Registration'] != '0000' && $values['ICAOTypeCode'] != '') { |
| 386 | 386 | //$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']); |
| 387 | - $query_dest_values = array(':lastmodified' => date('Y-m-d H:m:s'),':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':source_type' => 'flarm'); |
|
| 387 | + $query_dest_values = array(':lastmodified' => date('Y-m-d H:m:s'), ':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':source_type' => 'flarm'); |
|
| 388 | 388 | //print_r($query_dest_values); |
| 389 | 389 | $sth_dest->execute($query_dest_values); |
| 390 | 390 | } |
| 391 | 391 | } |
| 392 | 392 | if ($globalTransaction) $Connection->db->commit(); |
| 393 | - } catch(PDOException $e) { |
|
| 393 | + } catch (PDOException $e) { |
|
| 394 | 394 | return "error : ".$e->getMessage(); |
| 395 | 395 | } |
| 396 | 396 | } |
@@ -400,13 +400,13 @@ discard block |
||
| 400 | 400 | $Connection = new Connection(); |
| 401 | 401 | $sth = $Connection->db->prepare($query); |
| 402 | 402 | $sth->execute(array(':source' => $database_file)); |
| 403 | - } catch(PDOException $e) { |
|
| 403 | + } catch (PDOException $e) { |
|
| 404 | 404 | return "error : ".$e->getMessage(); |
| 405 | 405 | } |
| 406 | 406 | return ''; |
| 407 | 407 | } |
| 408 | 408 | |
| 409 | - public static function retrieve_owner($database_file,$country = 'F') { |
|
| 409 | + public static function retrieve_owner($database_file, $country = 'F') { |
|
| 410 | 410 | global $globalTransaction, $globalMasterSource; |
| 411 | 411 | //$query = 'TRUNCATE TABLE aircraft_modes'; |
| 412 | 412 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source; DELETE FROM aircraft_modes WHERE Source = :source;"; |
@@ -414,12 +414,12 @@ discard block |
||
| 414 | 414 | $Connection = new Connection(); |
| 415 | 415 | $sth = $Connection->db->prepare($query); |
| 416 | 416 | $sth->execute(array(':source' => $database_file)); |
| 417 | - } catch(PDOException $e) { |
|
| 417 | + } catch (PDOException $e) { |
|
| 418 | 418 | return "error : ".$e->getMessage(); |
| 419 | 419 | } |
| 420 | 420 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 421 | 421 | $Spotter = new Spotter(); |
| 422 | - if ($fh = fopen($database_file,"r")) { |
|
| 422 | + if ($fh = fopen($database_file, "r")) { |
|
| 423 | 423 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
| 424 | 424 | $query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)'; |
| 425 | 425 | $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)'; |
@@ -429,9 +429,9 @@ discard block |
||
| 429 | 429 | $sth_modes = $Connection->db->prepare($query_modes); |
| 430 | 430 | try { |
| 431 | 431 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 432 | - $tmp = fgetcsv($fh,9999,',','"'); |
|
| 432 | + $tmp = fgetcsv($fh, 9999, ',', '"'); |
|
| 433 | 433 | while (!feof($fh)) { |
| 434 | - $line = fgetcsv($fh,9999,',','"'); |
|
| 434 | + $line = fgetcsv($fh, 9999, ',', '"'); |
|
| 435 | 435 | $values = array(); |
| 436 | 436 | //print_r($line); |
| 437 | 437 | if ($country == 'F') { |
@@ -439,7 +439,7 @@ discard block |
||
| 439 | 439 | $values['base'] = $line[4]; |
| 440 | 440 | $values['owner'] = $line[5]; |
| 441 | 441 | if ($line[6] == '') $values['date_first_reg'] = null; |
| 442 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 442 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6])); |
|
| 443 | 443 | $values['cancel'] = $line[7]; |
| 444 | 444 | } elseif ($country == 'EI') { |
| 445 | 445 | // TODO : add modeS & reg to aircraft_modes |
@@ -447,7 +447,7 @@ discard block |
||
| 447 | 447 | $values['base'] = $line[3]; |
| 448 | 448 | $values['owner'] = $line[2]; |
| 449 | 449 | if ($line[1] == '') $values['date_first_reg'] = null; |
| 450 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
| 450 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[1])); |
|
| 451 | 451 | $values['cancel'] = ''; |
| 452 | 452 | $values['modes'] = $line[7]; |
| 453 | 453 | $values['icao'] = $line[8]; |
@@ -467,7 +467,7 @@ discard block |
||
| 467 | 467 | $values['base'] = null; |
| 468 | 468 | $values['owner'] = $line[5]; |
| 469 | 469 | if ($line[18] == '') $values['date_first_reg'] = null; |
| 470 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
| 470 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[18])); |
|
| 471 | 471 | $values['cancel'] = ''; |
| 472 | 472 | } elseif ($country == 'VH') { |
| 473 | 473 | // TODO : add modeS & reg to aircraft_modes |
@@ -475,7 +475,7 @@ discard block |
||
| 475 | 475 | $values['base'] = null; |
| 476 | 476 | $values['owner'] = $line[12]; |
| 477 | 477 | if ($line[28] == '') $values['date_first_reg'] = null; |
| 478 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
| 478 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[28])); |
|
| 479 | 479 | |
| 480 | 480 | $values['cancel'] = $line[39]; |
| 481 | 481 | } elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { |
@@ -495,28 +495,28 @@ discard block |
||
| 495 | 495 | $values['base'] = null; |
| 496 | 496 | $values['owner'] = $line[8]; |
| 497 | 497 | if ($line[7] == '') $values['date_first_reg'] = null; |
| 498 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 498 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7])); |
|
| 499 | 499 | $values['cancel'] = ''; |
| 500 | 500 | } elseif ($country == 'PP') { |
| 501 | 501 | $values['registration'] = $line[0]; |
| 502 | 502 | $values['base'] = null; |
| 503 | 503 | $values['owner'] = $line[4]; |
| 504 | 504 | if ($line[6] == '') $values['date_first_reg'] = null; |
| 505 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 505 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6])); |
|
| 506 | 506 | $values['cancel'] = $line[7]; |
| 507 | 507 | } elseif ($country == 'E7') { |
| 508 | 508 | $values['registration'] = $line[0]; |
| 509 | 509 | $values['base'] = null; |
| 510 | 510 | $values['owner'] = $line[4]; |
| 511 | 511 | if ($line[5] == '') $values['date_first_reg'] = null; |
| 512 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
| 512 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[5])); |
|
| 513 | 513 | $values['cancel'] = ''; |
| 514 | 514 | } elseif ($country == '8Q') { |
| 515 | 515 | $values['registration'] = $line[0]; |
| 516 | 516 | $values['base'] = null; |
| 517 | 517 | $values['owner'] = $line[3]; |
| 518 | 518 | if ($line[7] == '') $values['date_first_reg'] = null; |
| 519 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 519 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7])); |
|
| 520 | 520 | $values['cancel'] = ''; |
| 521 | 521 | } elseif ($country == 'ZK') { |
| 522 | 522 | $values['registration'] = $line[0]; |
@@ -530,18 +530,18 @@ discard block |
||
| 530 | 530 | $values['registration'] = $line[0]; |
| 531 | 531 | $values['base'] = null; |
| 532 | 532 | $values['owner'] = $line[6]; |
| 533 | - $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
| 534 | - $values['cancel'] = date("Y-m-d",strtotime($line[8])); |
|
| 533 | + $values['date_first_reg'] = date("Y-m-d", strtotime($line[5])); |
|
| 534 | + $values['cancel'] = date("Y-m-d", strtotime($line[8])); |
|
| 535 | 535 | $values['modes'] = $line[4]; |
| 536 | 536 | $values['icao'] = $line[10]; |
| 537 | 537 | } elseif ($country == 'OY') { |
| 538 | 538 | $values['registration'] = $line[0]; |
| 539 | - $values['date_first_reg'] = date("Y-m-d",strtotime($line[4])); |
|
| 539 | + $values['date_first_reg'] = date("Y-m-d", strtotime($line[4])); |
|
| 540 | 540 | $values['modes'] = $line[5]; |
| 541 | 541 | $values['icao'] = $line[6]; |
| 542 | 542 | } elseif ($country == 'PH') { |
| 543 | 543 | $values['registration'] = $line[0]; |
| 544 | - $values['date_first_reg'] = date("Y-m-d",strtotime($line[3])); |
|
| 544 | + $values['date_first_reg'] = date("Y-m-d", strtotime($line[3])); |
|
| 545 | 545 | $values['modes'] = $line[4]; |
| 546 | 546 | $values['icao'] = $line[5]; |
| 547 | 547 | } elseif ($country == 'OM' || $country == 'TF') { |
@@ -552,17 +552,17 @@ discard block |
||
| 552 | 552 | $values['cancel'] = ''; |
| 553 | 553 | } |
| 554 | 554 | if (isset($values['cancel']) && $values['cancel'] == '' && $values['registration'] != null && isset($values['owner'])) { |
| 555 | - $query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file); |
|
| 555 | + $query_dest_values = array(':registration' => $values['registration'], ':base' => $values['base'], ':date_first_reg' => $values['date_first_reg'], ':owner' => $values['owner'], ':source' => $database_file); |
|
| 556 | 556 | $sth_dest->execute($query_dest_values); |
| 557 | 557 | } |
| 558 | 558 | if ($globalMasterSource && $values['registration'] != null && isset($values['modes']) && $values['modes'] != '') { |
| 559 | 559 | $modescountry = $Spotter->countryFromAircraftRegistration($values['registration']); |
| 560 | - $query_modes_values = array(':registration' => $values['registration'],':modes' => $values['modes'],':modescountry' => $modescountry,':icaotypecode' => $values['icao'],':source' => $database_file); |
|
| 560 | + $query_modes_values = array(':registration' => $values['registration'], ':modes' => $values['modes'], ':modescountry' => $modescountry, ':icaotypecode' => $values['icao'], ':source' => $database_file); |
|
| 561 | 561 | $sth_modes->execute($query_modes_values); |
| 562 | 562 | } |
| 563 | 563 | } |
| 564 | 564 | if ($globalTransaction) $Connection->db->commit(); |
| 565 | - } catch(PDOException $e) { |
|
| 565 | + } catch (PDOException $e) { |
|
| 566 | 566 | return "error : ".$e->getMessage(); |
| 567 | 567 | } |
| 568 | 568 | } |
@@ -700,7 +700,7 @@ discard block |
||
| 700 | 700 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 701 | 701 | |
| 702 | 702 | $i = 0; |
| 703 | - while($row = sparql_fetch_array($result)) |
|
| 703 | + while ($row = sparql_fetch_array($result)) |
|
| 704 | 704 | { |
| 705 | 705 | if ($i >= 1) { |
| 706 | 706 | //print_r($row); |
@@ -720,33 +720,33 @@ discard block |
||
| 720 | 720 | $row['image'] = ''; |
| 721 | 721 | $row['image_thumb'] = ''; |
| 722 | 722 | } else { |
| 723 | - $image = str_replace(' ','_',$row['image']); |
|
| 723 | + $image = str_replace(' ', '_', $row['image']); |
|
| 724 | 724 | $digest = md5($image); |
| 725 | - $folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image . '/220px-' . $image; |
|
| 726 | - $row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/' . $folder; |
|
| 727 | - $folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image; |
|
| 728 | - $row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/' . $folder; |
|
| 725 | + $folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image.'/220px-'.$image; |
|
| 726 | + $row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/'.$folder; |
|
| 727 | + $folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image; |
|
| 728 | + $row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/'.$folder; |
|
| 729 | 729 | } |
| 730 | 730 | |
| 731 | - $country = explode('-',$row['country']); |
|
| 731 | + $country = explode('-', $row['country']); |
|
| 732 | 732 | $row['country'] = $country[0]; |
| 733 | 733 | |
| 734 | 734 | $row['type'] = trim($row['type']); |
| 735 | - if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i',$row['name'])) { |
|
| 735 | + if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i', $row['name'])) { |
|
| 736 | 736 | $row['type'] = 'military'; |
| 737 | 737 | } elseif ($row['type'] == 'http://dbpedia.org/resource/Airport' || $row['type'] == 'Civil' || $row['type'] == 'Public use' || $row['type'] == 'Public' || $row['type'] == 'http://dbpedia.org/resource/Civilian' || $row['type'] == 'Public, Civilian' || $row['type'] == 'Public / Military' || $row['type'] == 'Private & Civilian' || $row['type'] == 'Civilian and Military' || $row['type'] == 'Public/military' || $row['type'] == 'Active With Few Facilities' || $row['type'] == '?ivilian' || $row['type'] == 'Civil/Military' || $row['type'] == 'NA' || $row['type'] == 'Public/Military') { |
| 738 | 738 | $row['type'] = 'small_airport'; |
| 739 | 739 | } |
| 740 | 740 | |
| 741 | - $row['city'] = urldecode(str_replace('_',' ',str_replace('http://dbpedia.org/resource/','',$row['city']))); |
|
| 742 | - $query_dest_values = array(':name' => $row['name'],':iata' => $row['iata'],':icao' => $row['icao'],':latitude' => $row['latitude'],':longitude' => $row['longitude'],':altitude' => round($row['altitude']),':type' => $row['type'],':city' => $row['city'],':country' => $row['country'],':home_link' => $row['homepage'],':wikipedia_link' => $row['wikipedia_page'],':image' => $row['image'],':image_thumb' => $row['image_thumb']); |
|
| 741 | + $row['city'] = urldecode(str_replace('_', ' ', str_replace('http://dbpedia.org/resource/', '', $row['city']))); |
|
| 742 | + $query_dest_values = array(':name' => $row['name'], ':iata' => $row['iata'], ':icao' => $row['icao'], ':latitude' => $row['latitude'], ':longitude' => $row['longitude'], ':altitude' => round($row['altitude']), ':type' => $row['type'], ':city' => $row['city'], ':country' => $row['country'], ':home_link' => $row['homepage'], ':wikipedia_link' => $row['wikipedia_page'], ':image' => $row['image'], ':image_thumb' => $row['image_thumb']); |
|
| 743 | 743 | //print_r($query_dest_values); |
| 744 | 744 | |
| 745 | 745 | if ($row['icao'] != '') { |
| 746 | 746 | try { |
| 747 | 747 | $sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE icao = :icao'); |
| 748 | 748 | $sth->execute(array(':icao' => $row['icao'])); |
| 749 | - } catch(PDOException $e) { |
|
| 749 | + } catch (PDOException $e) { |
|
| 750 | 750 | return "error : ".$e->getMessage(); |
| 751 | 751 | } |
| 752 | 752 | if ($sth->fetchColumn() > 0) { |
@@ -754,15 +754,15 @@ discard block |
||
| 754 | 754 | $query = 'UPDATE airport SET type = :type WHERE icao = :icao'; |
| 755 | 755 | try { |
| 756 | 756 | $sth = $Connection->db->prepare($query); |
| 757 | - $sth->execute(array(':icao' => $row['icao'],':type' => $row['type'])); |
|
| 758 | - } catch(PDOException $e) { |
|
| 757 | + $sth->execute(array(':icao' => $row['icao'], ':type' => $row['type'])); |
|
| 758 | + } catch (PDOException $e) { |
|
| 759 | 759 | return "error : ".$e->getMessage(); |
| 760 | 760 | } |
| 761 | 761 | echo $row['icao'].' : '.$row['type']."\n"; |
| 762 | 762 | } else { |
| 763 | 763 | try { |
| 764 | 764 | $sth_dest->execute($query_dest_values); |
| 765 | - } catch(PDOException $e) { |
|
| 765 | + } catch (PDOException $e) { |
|
| 766 | 766 | return "error : ".$e->getMessage(); |
| 767 | 767 | } |
| 768 | 768 | } |
@@ -813,7 +813,7 @@ discard block |
||
| 813 | 813 | echo "Download data from ourairports.com...\n"; |
| 814 | 814 | $delimiter = ','; |
| 815 | 815 | $out_file = $tmp_dir.'airports.csv'; |
| 816 | - update_db::download('http://ourairports.com/data/airports.csv',$out_file); |
|
| 816 | + update_db::download('http://ourairports.com/data/airports.csv', $out_file); |
|
| 817 | 817 | if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
| 818 | 818 | echo "Add data from ourairports.com...\n"; |
| 819 | 819 | |
@@ -824,33 +824,33 @@ discard block |
||
| 824 | 824 | //$Connection->db->beginTransaction(); |
| 825 | 825 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 826 | 826 | { |
| 827 | - if(!$header) $header = $row; |
|
| 827 | + if (!$header) $header = $row; |
|
| 828 | 828 | else { |
| 829 | 829 | $data = array(); |
| 830 | 830 | $data = array_combine($header, $row); |
| 831 | 831 | try { |
| 832 | 832 | $sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE icao = :icao'); |
| 833 | 833 | $sth->execute(array(':icao' => $data['ident'])); |
| 834 | - } catch(PDOException $e) { |
|
| 834 | + } catch (PDOException $e) { |
|
| 835 | 835 | return "error : ".$e->getMessage(); |
| 836 | 836 | } |
| 837 | 837 | if ($sth->fetchColumn() > 0) { |
| 838 | 838 | $query = 'UPDATE airport SET type = :type WHERE icao = :icao'; |
| 839 | 839 | try { |
| 840 | 840 | $sth = $Connection->db->prepare($query); |
| 841 | - $sth->execute(array(':icao' => $data['ident'],':type' => $data['type'])); |
|
| 842 | - } catch(PDOException $e) { |
|
| 841 | + $sth->execute(array(':icao' => $data['ident'], ':type' => $data['type'])); |
|
| 842 | + } catch (PDOException $e) { |
|
| 843 | 843 | return "error : ".$e->getMessage(); |
| 844 | 844 | } |
| 845 | 845 | } else { |
| 846 | 846 | if ($data['gps_code'] == $data['ident']) { |
| 847 | 847 | $query = "INSERT INTO airport (name,city,country,iata,icao,latitude,longitude,altitude,type,home_link,wikipedia_link) |
| 848 | 848 | VALUES (:name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link)"; |
| 849 | - $query_values = array(':name' => $data['name'],':iata' => $data['iata_code'],':icao' => $data['gps_code'],':latitude' => $data['latitude_deg'],':longitude' => $data['longitude_deg'],':altitude' => round($data['elevation_ft']),':type' => $data['type'],':city' => $data['municipality'],':country' => $data['iso_country'],':home_link' => $data['home_link'],':wikipedia_link' => $data['wikipedia_link']); |
|
| 849 | + $query_values = array(':name' => $data['name'], ':iata' => $data['iata_code'], ':icao' => $data['gps_code'], ':latitude' => $data['latitude_deg'], ':longitude' => $data['longitude_deg'], ':altitude' => round($data['elevation_ft']), ':type' => $data['type'], ':city' => $data['municipality'], ':country' => $data['iso_country'], ':home_link' => $data['home_link'], ':wikipedia_link' => $data['wikipedia_link']); |
|
| 850 | 850 | try { |
| 851 | 851 | $sth = $Connection->db->prepare($query); |
| 852 | 852 | $sth->execute($query_values); |
| 853 | - } catch(PDOException $e) { |
|
| 853 | + } catch (PDOException $e) { |
|
| 854 | 854 | return "error : ".$e->getMessage(); |
| 855 | 855 | } |
| 856 | 856 | $i++; |
@@ -865,7 +865,7 @@ discard block |
||
| 865 | 865 | |
| 866 | 866 | echo "Download data from another free database...\n"; |
| 867 | 867 | $out_file = $tmp_dir.'GlobalAirportDatabase.zip'; |
| 868 | - update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file); |
|
| 868 | + update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip', $out_file); |
|
| 869 | 869 | if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
| 870 | 870 | update_db::unzip($out_file); |
| 871 | 871 | $header = NULL; |
@@ -877,15 +877,15 @@ discard block |
||
| 877 | 877 | //$Connection->db->beginTransaction(); |
| 878 | 878 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 879 | 879 | { |
| 880 | - if(!$header) $header = $row; |
|
| 880 | + if (!$header) $header = $row; |
|
| 881 | 881 | else { |
| 882 | 882 | $data = $row; |
| 883 | 883 | |
| 884 | 884 | $query = 'UPDATE airport SET city = :city, country = :country WHERE icao = :icao'; |
| 885 | 885 | try { |
| 886 | 886 | $sth = $Connection->db->prepare($query); |
| 887 | - $sth->execute(array(':icao' => $data[0],':city' => ucwords(strtolower($data[3])),':country' => ucwords(strtolower($data[4])))); |
|
| 888 | - } catch(PDOException $e) { |
|
| 887 | + $sth->execute(array(':icao' => $data[0], ':city' => ucwords(strtolower($data[3])), ':country' => ucwords(strtolower($data[4])))); |
|
| 888 | + } catch (PDOException $e) { |
|
| 889 | 889 | return "error : ".$e->getMessage(); |
| 890 | 890 | } |
| 891 | 891 | } |
@@ -899,15 +899,15 @@ discard block |
||
| 899 | 899 | try { |
| 900 | 900 | $sth = $Connection->db->prepare("SELECT icao FROM airport WHERE name LIKE '%Air Base%'"); |
| 901 | 901 | $sth->execute(); |
| 902 | - } catch(PDOException $e) { |
|
| 902 | + } catch (PDOException $e) { |
|
| 903 | 903 | return "error : ".$e->getMessage(); |
| 904 | 904 | } |
| 905 | 905 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
| 906 | 906 | $query2 = 'UPDATE airport SET type = :type WHERE icao = :icao'; |
| 907 | 907 | try { |
| 908 | 908 | $sth2 = $Connection->db->prepare($query2); |
| 909 | - $sth2->execute(array(':icao' => $row['icao'],':type' => 'military')); |
|
| 910 | - } catch(PDOException $e) { |
|
| 909 | + $sth2->execute(array(':icao' => $row['icao'], ':type' => 'military')); |
|
| 910 | + } catch (PDOException $e) { |
|
| 911 | 911 | return "error : ".$e->getMessage(); |
| 912 | 912 | } |
| 913 | 913 | } |
@@ -928,7 +928,7 @@ discard block |
||
| 928 | 928 | $Connection = new Connection(); |
| 929 | 929 | $sth = $Connection->db->prepare($query); |
| 930 | 930 | $sth->execute(array(':source' => 'translation.csv')); |
| 931 | - } catch(PDOException $e) { |
|
| 931 | + } catch (PDOException $e) { |
|
| 932 | 932 | return "error : ".$e->getMessage(); |
| 933 | 933 | } |
| 934 | 934 | |
@@ -945,7 +945,7 @@ discard block |
||
| 945 | 945 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 946 | 946 | { |
| 947 | 947 | $i++; |
| 948 | - if($i > 12) { |
|
| 948 | + if ($i > 12) { |
|
| 949 | 949 | $data = $row; |
| 950 | 950 | $operator = $data[2]; |
| 951 | 951 | if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) { |
@@ -953,7 +953,7 @@ discard block |
||
| 953 | 953 | //echo substr($operator, 0, 2)."\n";; |
| 954 | 954 | if (count($airline_array) > 0) { |
| 955 | 955 | //print_r($airline_array); |
| 956 | - $operator = $airline_array[0]['icao'].substr($operator,2); |
|
| 956 | + $operator = $airline_array[0]['icao'].substr($operator, 2); |
|
| 957 | 957 | } |
| 958 | 958 | } |
| 959 | 959 | |
@@ -961,14 +961,14 @@ discard block |
||
| 961 | 961 | if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) { |
| 962 | 962 | $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2)); |
| 963 | 963 | if (count($airline_array) > 0) { |
| 964 | - $operator_correct = $airline_array[0]['icao'].substr($operator_correct,2); |
|
| 964 | + $operator_correct = $airline_array[0]['icao'].substr($operator_correct, 2); |
|
| 965 | 965 | } |
| 966 | 966 | } |
| 967 | 967 | $query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)'; |
| 968 | 968 | try { |
| 969 | 969 | $sth = $Connection->db->prepare($query); |
| 970 | - $sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $operator,':Operator_correct' => $operator_correct, ':source' => 'translation.csv')); |
|
| 971 | - } catch(PDOException $e) { |
|
| 970 | + $sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $operator, ':Operator_correct' => $operator_correct, ':source' => 'translation.csv')); |
|
| 971 | + } catch (PDOException $e) { |
|
| 972 | 972 | return "error : ".$e->getMessage(); |
| 973 | 973 | } |
| 974 | 974 | } |
@@ -986,7 +986,7 @@ discard block |
||
| 986 | 986 | $Connection = new Connection(); |
| 987 | 987 | $sth = $Connection->db->prepare($query); |
| 988 | 988 | $sth->execute(array(':source' => 'website_fam')); |
| 989 | - } catch(PDOException $e) { |
|
| 989 | + } catch (PDOException $e) { |
|
| 990 | 990 | return "error : ".$e->getMessage(); |
| 991 | 991 | } |
| 992 | 992 | //update_db::unzip($out_file); |
@@ -1004,8 +1004,8 @@ discard block |
||
| 1004 | 1004 | $query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)'; |
| 1005 | 1005 | try { |
| 1006 | 1006 | $sth = $Connection->db->prepare($query); |
| 1007 | - $sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $data[2],':Operator_correct' => $data[3], ':source' => 'website_fam')); |
|
| 1008 | - } catch(PDOException $e) { |
|
| 1007 | + $sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $data[2], ':Operator_correct' => $data[3], ':source' => 'website_fam')); |
|
| 1008 | + } catch (PDOException $e) { |
|
| 1009 | 1009 | return "error : ".$e->getMessage(); |
| 1010 | 1010 | } |
| 1011 | 1011 | } |
@@ -1028,7 +1028,7 @@ discard block |
||
| 1028 | 1028 | $Connection = new Connection(); |
| 1029 | 1029 | $sth = $Connection->db->prepare($query); |
| 1030 | 1030 | $sth->execute(array(':source' => 'website_faa')); |
| 1031 | - } catch(PDOException $e) { |
|
| 1031 | + } catch (PDOException $e) { |
|
| 1032 | 1032 | return "error : ".$e->getMessage(); |
| 1033 | 1033 | } |
| 1034 | 1034 | |
@@ -1037,7 +1037,7 @@ discard block |
||
| 1037 | 1037 | $Connection = new Connection(); |
| 1038 | 1038 | $sth = $Connection->db->prepare($query); |
| 1039 | 1039 | $sth->execute(array(':source' => 'website_faa')); |
| 1040 | - } catch(PDOException $e) { |
|
| 1040 | + } catch (PDOException $e) { |
|
| 1041 | 1041 | return "error : ".$e->getMessage(); |
| 1042 | 1042 | } |
| 1043 | 1043 | |
@@ -1054,8 +1054,8 @@ discard block |
||
| 1054 | 1054 | $query_search = 'SELECT icaotypecode FROM aircraft_modes WHERE registration = :registration AND Source <> :source LIMIT 1'; |
| 1055 | 1055 | try { |
| 1056 | 1056 | $sths = $Connection->db->prepare($query_search); |
| 1057 | - $sths->execute(array(':registration' => 'N'.$data[0],':source' => 'website_faa')); |
|
| 1058 | - } catch(PDOException $e) { |
|
| 1057 | + $sths->execute(array(':registration' => 'N'.$data[0], ':source' => 'website_faa')); |
|
| 1058 | + } catch (PDOException $e) { |
|
| 1059 | 1059 | return "error s : ".$e->getMessage(); |
| 1060 | 1060 | } |
| 1061 | 1061 | $result_search = $sths->fetchAll(PDO::FETCH_ASSOC); |
@@ -1068,8 +1068,8 @@ discard block |
||
| 1068 | 1068 | //} |
| 1069 | 1069 | try { |
| 1070 | 1070 | $sthi = $Connection->db->prepare($queryi); |
| 1071 | - $sthi->execute(array(':mfr' => $data[2],':icao' => $result_search[0]['icaotypecode'])); |
|
| 1072 | - } catch(PDOException $e) { |
|
| 1071 | + $sthi->execute(array(':mfr' => $data[2], ':icao' => $result_search[0]['icaotypecode'])); |
|
| 1072 | + } catch (PDOException $e) { |
|
| 1073 | 1073 | return "error u : ".$e->getMessage(); |
| 1074 | 1074 | } |
| 1075 | 1075 | } else { |
@@ -1077,7 +1077,7 @@ discard block |
||
| 1077 | 1077 | try { |
| 1078 | 1078 | $sthsm = $Connection->db->prepare($query_search_mfr); |
| 1079 | 1079 | $sthsm->execute(array(':mfr' => $data[2])); |
| 1080 | - } catch(PDOException $e) { |
|
| 1080 | + } catch (PDOException $e) { |
|
| 1081 | 1081 | return "error mfr : ".$e->getMessage(); |
| 1082 | 1082 | } |
| 1083 | 1083 | $result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC); |
@@ -1087,8 +1087,8 @@ discard block |
||
| 1087 | 1087 | $queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)'; |
| 1088 | 1088 | try { |
| 1089 | 1089 | $sthf = $Connection->db->prepare($queryf); |
| 1090 | - $sthf->execute(array(':FirstCreated' => $data[16],':LastModified' => $data[15],':ModeS' => $data[33],':ModeSCountry' => $data[14], ':Registration' => 'N'.$data[0],':ICAOTypeCode' => $result_search_mfr[0]['icao'],':source' => 'website_faa')); |
|
| 1091 | - } catch(PDOException $e) { |
|
| 1090 | + $sthf->execute(array(':FirstCreated' => $data[16], ':LastModified' => $data[15], ':ModeS' => $data[33], ':ModeSCountry' => $data[14], ':Registration' => 'N'.$data[0], ':ICAOTypeCode' => $result_search_mfr[0]['icao'], ':source' => 'website_faa')); |
|
| 1091 | + } catch (PDOException $e) { |
|
| 1092 | 1092 | return "error f : ".$e->getMessage(); |
| 1093 | 1093 | } |
| 1094 | 1094 | } |
@@ -1098,13 +1098,13 @@ discard block |
||
| 1098 | 1098 | $query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)'; |
| 1099 | 1099 | try { |
| 1100 | 1100 | $sth = $Connection->db->prepare($query); |
| 1101 | - $sth->execute(array(':registration' => 'N'.$data[0],':base' => $data[9],':owner' => ucwords(strtolower($data[6])),':date_first_reg' => date('Y-m-d',strtotime($data[23])), ':source' => 'website_faa')); |
|
| 1102 | - } catch(PDOException $e) { |
|
| 1101 | + $sth->execute(array(':registration' => 'N'.$data[0], ':base' => $data[9], ':owner' => ucwords(strtolower($data[6])), ':date_first_reg' => date('Y-m-d', strtotime($data[23])), ':source' => 'website_faa')); |
|
| 1102 | + } catch (PDOException $e) { |
|
| 1103 | 1103 | return "error i : ".$e->getMessage(); |
| 1104 | 1104 | } |
| 1105 | 1105 | } |
| 1106 | 1106 | } |
| 1107 | - if ($i % 90 == 0) { |
|
| 1107 | + if ($i%90 == 0) { |
|
| 1108 | 1108 | if ($globalTransaction) $Connection->db->commit(); |
| 1109 | 1109 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 1110 | 1110 | } |
@@ -1123,7 +1123,7 @@ discard block |
||
| 1123 | 1123 | $Connection = new Connection(); |
| 1124 | 1124 | $sth = $Connection->db->prepare($query); |
| 1125 | 1125 | $sth->execute(array(':source' => 'website_fam')); |
| 1126 | - } catch(PDOException $e) { |
|
| 1126 | + } catch (PDOException $e) { |
|
| 1127 | 1127 | return "error : ".$e->getMessage(); |
| 1128 | 1128 | } |
| 1129 | 1129 | $delimiter = "\t"; |
@@ -1139,8 +1139,8 @@ discard block |
||
| 1139 | 1139 | $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 | 1140 | try { |
| 1141 | 1141 | $sth = $Connection->db->prepare($query); |
| 1142 | - $sth->execute(array(':FirstCreated' => $data[0],':LastModified' => $data[1],':ModeS' => $data[2],':ModeSCountry' => $data[3], ':Registration' => $data[4],':ICAOTypeCode' => $data[5],':type_flight' => $data[6],':source' => 'website_fam')); |
|
| 1143 | - } catch(PDOException $e) { |
|
| 1142 | + $sth->execute(array(':FirstCreated' => $data[0], ':LastModified' => $data[1], ':ModeS' => $data[2], ':ModeSCountry' => $data[3], ':Registration' => $data[4], ':ICAOTypeCode' => $data[5], ':type_flight' => $data[6], ':source' => 'website_fam')); |
|
| 1143 | + } catch (PDOException $e) { |
|
| 1144 | 1144 | return "error : ".$e->getMessage(); |
| 1145 | 1145 | } |
| 1146 | 1146 | } |
@@ -1172,7 +1172,7 @@ discard block |
||
| 1172 | 1172 | try { |
| 1173 | 1173 | $sth = $Connection->db->prepare($query); |
| 1174 | 1174 | $sth->execute(); |
| 1175 | - } catch(PDOException $e) { |
|
| 1175 | + } catch (PDOException $e) { |
|
| 1176 | 1176 | return "error : ".$e->getMessage(); |
| 1177 | 1177 | } |
| 1178 | 1178 | $delimiter = "\t"; |
@@ -1187,8 +1187,8 @@ discard block |
||
| 1187 | 1187 | $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 | 1188 | try { |
| 1189 | 1189 | $sth = $Connection->db->prepare($query); |
| 1190 | - $sth->execute(array(':name' => $data[0],':alias' => $data[1],':iata' => $data[2],':icao' => $data[3], ':callsign' => $data[4],':country' => $data[5],':active' => $data[6],':type' => $data[7],':home' => $data[8],':wikipedia_link' => $data[9],':alliance' => $data[10],':ban_eu' => $data[11])); |
|
| 1191 | - } catch(PDOException $e) { |
|
| 1190 | + $sth->execute(array(':name' => $data[0], ':alias' => $data[1], ':iata' => $data[2], ':icao' => $data[3], ':callsign' => $data[4], ':country' => $data[5], ':active' => $data[6], ':type' => $data[7], ':home' => $data[8], ':wikipedia_link' => $data[9], ':alliance' => $data[10], ':ban_eu' => $data[11])); |
|
| 1191 | + } catch (PDOException $e) { |
|
| 1192 | 1192 | return "error : ".$e->getMessage(); |
| 1193 | 1193 | } |
| 1194 | 1194 | } |
@@ -1216,7 +1216,7 @@ discard block |
||
| 1216 | 1216 | $Connection = new Connection(); |
| 1217 | 1217 | $sth = $Connection->db->prepare($query); |
| 1218 | 1218 | $sth->execute(array(':source' => 'website_fam')); |
| 1219 | - } catch(PDOException $e) { |
|
| 1219 | + } catch (PDOException $e) { |
|
| 1220 | 1220 | return "error : ".$e->getMessage(); |
| 1221 | 1221 | } |
| 1222 | 1222 | |
@@ -1232,8 +1232,8 @@ discard block |
||
| 1232 | 1232 | $query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,NULL,:source)'; |
| 1233 | 1233 | try { |
| 1234 | 1234 | $sth = $Connection->db->prepare($query); |
| 1235 | - $sth->execute(array(':registration' => $data[0],':base' => $data[1],':owner' => $data[2], ':source' => 'website_fam')); |
|
| 1236 | - } catch(PDOException $e) { |
|
| 1235 | + $sth->execute(array(':registration' => $data[0], ':base' => $data[1], ':owner' => $data[2], ':source' => 'website_fam')); |
|
| 1236 | + } catch (PDOException $e) { |
|
| 1237 | 1237 | //print_r($data); |
| 1238 | 1238 | return "error : ".$e->getMessage(); |
| 1239 | 1239 | } |
@@ -1253,7 +1253,7 @@ discard block |
||
| 1253 | 1253 | $Connection = new Connection(); |
| 1254 | 1254 | $sth = $Connection->db->prepare($query); |
| 1255 | 1255 | $sth->execute(array(':source' => 'website_fam')); |
| 1256 | - } catch(PDOException $e) { |
|
| 1256 | + } catch (PDOException $e) { |
|
| 1257 | 1257 | return "error : ".$e->getMessage(); |
| 1258 | 1258 | } |
| 1259 | 1259 | $delimiter = "\t"; |
@@ -1269,13 +1269,13 @@ discard block |
||
| 1269 | 1269 | $query = '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)'; |
| 1270 | 1270 | try { |
| 1271 | 1271 | $sth = $Connection->db->prepare($query); |
| 1272 | - $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 | - } catch(PDOException $e) { |
|
| 1274 | - if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".implode(',',$data); |
|
| 1272 | + $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 | + } catch (PDOException $e) { |
|
| 1274 | + if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".implode(',', $data); |
|
| 1275 | 1275 | die(); |
| 1276 | 1276 | } |
| 1277 | 1277 | } |
| 1278 | - if ($globalTransaction && $i % 2000 == 0) { |
|
| 1278 | + if ($globalTransaction && $i%2000 == 0) { |
|
| 1279 | 1279 | $Connection->db->commit(); |
| 1280 | 1280 | if ($globalDebug) echo '.'; |
| 1281 | 1281 | $Connection->db->beginTransaction(); |
@@ -1295,7 +1295,7 @@ discard block |
||
| 1295 | 1295 | $Connection = new Connection(); |
| 1296 | 1296 | $sth = $Connection->db->prepare($query); |
| 1297 | 1297 | $sth->execute(); |
| 1298 | - } catch(PDOException $e) { |
|
| 1298 | + } catch (PDOException $e) { |
|
| 1299 | 1299 | return "error : ".$e->getMessage(); |
| 1300 | 1300 | } |
| 1301 | 1301 | |
@@ -1316,8 +1316,8 @@ discard block |
||
| 1316 | 1316 | $query = 'INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,length,gross_tonnage,dead_weight,width,country,engine_power,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:length,:gross_tonnage,:dead_weight,:width,:country,:engine_power,:type)'; |
| 1317 | 1317 | try { |
| 1318 | 1318 | $sth = $Connection->db->prepare($query); |
| 1319 | - $sth->execute(array(':mmsi' => $data[0],':imo' => $data[1],':call_sign' => $data[2],':ship_name' => $data[3], ':length' => $data[4],':gross_tonnage' => $data[5],':dead_weight' => $data[6],':width' => $data[7],':country' => $data[8],':engine_power' => $data[9],':type' => $data[10])); |
|
| 1320 | - } catch(PDOException $e) { |
|
| 1319 | + $sth->execute(array(':mmsi' => $data[0], ':imo' => $data[1], ':call_sign' => $data[2], ':ship_name' => $data[3], ':length' => $data[4], ':gross_tonnage' => $data[5], ':dead_weight' => $data[6], ':width' => $data[7], ':country' => $data[8], ':engine_power' => $data[9], ':type' => $data[10])); |
|
| 1320 | + } catch (PDOException $e) { |
|
| 1321 | 1321 | return "error : ".$e->getMessage(); |
| 1322 | 1322 | } |
| 1323 | 1323 | } |
@@ -1336,7 +1336,7 @@ discard block |
||
| 1336 | 1336 | $Connection = new Connection(); |
| 1337 | 1337 | $sth = $Connection->db->prepare($query); |
| 1338 | 1338 | $sth->execute(); |
| 1339 | - } catch(PDOException $e) { |
|
| 1339 | + } catch (PDOException $e) { |
|
| 1340 | 1340 | return "error : ".$e->getMessage(); |
| 1341 | 1341 | } |
| 1342 | 1342 | $delimiter = "\t"; |
@@ -1353,8 +1353,8 @@ discard block |
||
| 1353 | 1353 | VALUES (:name, :name_alternate, :country_un, :country_owner, :owner, :users, :purpose, :purpose_detailed, :orbit, :type, :longitude_geo, :perigee, :apogee, :eccentricity, :inclination, :period, :launch_mass, :dry_mass, :power, :launch_date, :lifetime, :contractor, :country_contractor, :launch_site, :launch_vehicule, :cospar, :norad, :comments, :source_orbital, :sources)'; |
| 1354 | 1354 | try { |
| 1355 | 1355 | $sth = $Connection->db->prepare($query); |
| 1356 | - $sth->execute(array(':name' => $data[0], ':name_alternate' => $data[1], ':country_un' => $data[2], ':country_owner' => $data[3], ':owner' => $data[4], ':users' => $data[5], ':purpose' => $data[6], ':purpose_detailed' => $data[7], ':orbit' => $data[8], ':type' => $data[9], ':longitude_geo' => $data[10], ':perigee' => !empty($data[11]) ? $data[11] : NULL, ':apogee' => !empty($data[12]) ? $data[12] : NULL, ':eccentricity' => $data[13], ':inclination' => $data[14], ':period' => !empty($data[15]) ? $data[15] : NULL, ':launch_mass' => !empty($data[16]) ? $data[16] : NULL, ':dry_mass' => !empty($data[17]) ? $data[17] : NULL, ':power' => !empty($data[18]) ? $data[18] : NULL, ':launch_date' => $data[19], ':lifetime' => $data[20], ':contractor' => $data[21],':country_contractor' => $data[22], ':launch_site' => $data[23], ':launch_vehicule' => $data[24], ':cospar' => $data[25], ':norad' => $data[26], ':comments' => $data[27], ':source_orbital' => $data[28], ':sources' => $data[29])); |
|
| 1357 | - } catch(PDOException $e) { |
|
| 1356 | + $sth->execute(array(':name' => $data[0], ':name_alternate' => $data[1], ':country_un' => $data[2], ':country_owner' => $data[3], ':owner' => $data[4], ':users' => $data[5], ':purpose' => $data[6], ':purpose_detailed' => $data[7], ':orbit' => $data[8], ':type' => $data[9], ':longitude_geo' => $data[10], ':perigee' => !empty($data[11]) ? $data[11] : NULL, ':apogee' => !empty($data[12]) ? $data[12] : NULL, ':eccentricity' => $data[13], ':inclination' => $data[14], ':period' => !empty($data[15]) ? $data[15] : NULL, ':launch_mass' => !empty($data[16]) ? $data[16] : NULL, ':dry_mass' => !empty($data[17]) ? $data[17] : NULL, ':power' => !empty($data[18]) ? $data[18] : NULL, ':launch_date' => $data[19], ':lifetime' => $data[20], ':contractor' => $data[21], ':country_contractor' => $data[22], ':launch_site' => $data[23], ':launch_vehicule' => $data[24], ':cospar' => $data[25], ':norad' => $data[26], ':comments' => $data[27], ':source_orbital' => $data[28], ':sources' => $data[29])); |
|
| 1357 | + } catch (PDOException $e) { |
|
| 1358 | 1358 | return "error : ".$e->getMessage(); |
| 1359 | 1359 | } |
| 1360 | 1360 | } |
@@ -1373,7 +1373,7 @@ discard block |
||
| 1373 | 1373 | $Connection = new Connection(); |
| 1374 | 1374 | $sth = $Connection->db->prepare($query); |
| 1375 | 1375 | $sth->execute(); |
| 1376 | - } catch(PDOException $e) { |
|
| 1376 | + } catch (PDOException $e) { |
|
| 1377 | 1377 | return "error : ".$e->getMessage(); |
| 1378 | 1378 | } |
| 1379 | 1379 | |
@@ -1389,7 +1389,7 @@ discard block |
||
| 1389 | 1389 | try { |
| 1390 | 1390 | $sth = $Connection->db->prepare($query); |
| 1391 | 1391 | $sth->execute(array(':icao' => $icao)); |
| 1392 | - } catch(PDOException $e) { |
|
| 1392 | + } catch (PDOException $e) { |
|
| 1393 | 1393 | return "error : ".$e->getMessage(); |
| 1394 | 1394 | } |
| 1395 | 1395 | } |
@@ -1400,7 +1400,7 @@ discard block |
||
| 1400 | 1400 | return ''; |
| 1401 | 1401 | } |
| 1402 | 1402 | |
| 1403 | - public static function tle($filename,$tletype) { |
|
| 1403 | + public static function tle($filename, $tletype) { |
|
| 1404 | 1404 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 1405 | 1405 | global $tmp_dir, $globalTransaction; |
| 1406 | 1406 | //$Spotter = new Spotter(); |
@@ -1410,7 +1410,7 @@ discard block |
||
| 1410 | 1410 | $Connection = new Connection(); |
| 1411 | 1411 | $sth = $Connection->db->prepare($query); |
| 1412 | 1412 | $sth->execute(array(':source' => $filename)); |
| 1413 | - } catch(PDOException $e) { |
|
| 1413 | + } catch (PDOException $e) { |
|
| 1414 | 1414 | return "error : ".$e->getMessage(); |
| 1415 | 1415 | } |
| 1416 | 1416 | |
@@ -1435,8 +1435,8 @@ discard block |
||
| 1435 | 1435 | $query = 'INSERT INTO tle (tle_name,tle_tle1,tle_tle2,tle_type,tle_source) VALUES (:name, :tle1, :tle2, :type, :source)'; |
| 1436 | 1436 | try { |
| 1437 | 1437 | $sth = $Connection->db->prepare($query); |
| 1438 | - $sth->execute(array(':name' => $dbdata['name'],':tle1' => $dbdata['tle1'],':tle2' => $dbdata['tle2'], ':type' => $tletype,':source' => $filename)); |
|
| 1439 | - } catch(PDOException $e) { |
|
| 1438 | + $sth->execute(array(':name' => $dbdata['name'], ':tle1' => $dbdata['tle1'], ':tle2' => $dbdata['tle2'], ':type' => $tletype, ':source' => $filename)); |
|
| 1439 | + } catch (PDOException $e) { |
|
| 1440 | 1440 | return "error : ".$e->getMessage(); |
| 1441 | 1441 | } |
| 1442 | 1442 | |
@@ -1456,7 +1456,7 @@ discard block |
||
| 1456 | 1456 | $Connection = new Connection(); |
| 1457 | 1457 | $sth = $Connection->db->prepare($query); |
| 1458 | 1458 | $sth->execute(array(':source' => $filename)); |
| 1459 | - } catch(PDOException $e) { |
|
| 1459 | + } catch (PDOException $e) { |
|
| 1460 | 1460 | return "error : ".$e->getMessage(); |
| 1461 | 1461 | } |
| 1462 | 1462 | |
@@ -1466,13 +1466,13 @@ discard block |
||
| 1466 | 1466 | $i = 0; |
| 1467 | 1467 | //$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE); |
| 1468 | 1468 | //$Connection->db->beginTransaction(); |
| 1469 | - while (($data = fgetcsv($handle, 1000,"\t")) !== FALSE) |
|
| 1469 | + while (($data = fgetcsv($handle, 1000, "\t")) !== FALSE) |
|
| 1470 | 1470 | { |
| 1471 | 1471 | if ($i > 0 && $data[0] != '') { |
| 1472 | 1472 | $sources = trim($data[28].' '.$data[29].' '.$data[30].' '.$data[31].' '.$data[32].' '.$data[33]); |
| 1473 | - $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])); |
|
| 1473 | + $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 | 1476 | else $launch_date = NULL; |
| 1477 | 1477 | $data = array_map(function($value) { |
| 1478 | 1478 | return trim($value) === '' ? null : $value; |
@@ -1482,8 +1482,8 @@ discard block |
||
| 1482 | 1482 | VALUES (:name, :name_alternate, :country_un, :country_owner, :owner, :users, :purpose, :purpose_detailed, :orbit, :type, :longitude_geo, :perigee, :apogee, :eccentricity, :inclination, :period, :launch_mass, :dry_mass, :power, :launch_date, :lifetime, :contractor, :country_contractor, :launch_site, :launch_vehicule, :cospar, :norad, :comments, :source_orbital, :sources)'; |
| 1483 | 1483 | try { |
| 1484 | 1484 | $sth = $Connection->db->prepare($query); |
| 1485 | - $sth->execute(array(':name' => $data[0], ':name_alternate' => '', ':country_un' => $data[1], ':country_owner' => $data[2], ':owner' => $data[3], ':users' => $data[4], ':purpose' => $data[5], ':purpose_detailed' => $data[6], ':orbit' => $data[7], ':type' => $data[8], ':longitude_geo' => $data[9], ':perigee' => !empty($data[10]) ? str_replace(',','',$data[10]) : NULL, ':apogee' => !empty($data[11]) ? str_replace(',','',$data[11]) : NULL, ':eccentricity' => $data[12], ':inclination' => $data[13], ':period' => !empty($period) ? $period : NULL, ':launch_mass' => !empty($data[15]) ? str_replace(array('+',','),'',$data[15]) : NULL, ':dry_mass' => !empty($data[16]) ? str_replace(array(',','-1900',' (BOL)',' (EOL)'),'',$data[16]) : NULL, ':power' => !empty($data[17]) ? str_replace(array(',',' (BOL)',' (EOL)'),'',$data[17]) : NULL, ':launch_date' => $launch_date, ':lifetime' => $data[19], ':contractor' => $data[20],':country_contractor' => $data[21], ':launch_site' => $data[22], ':launch_vehicule' => $data[23], ':cospar' => $data[24], ':norad' => $data[25], ':comments' => $data[26], ':source_orbital' => $data[27], ':sources' => $sources)); |
|
| 1486 | - } catch(PDOException $e) { |
|
| 1485 | + $sth->execute(array(':name' => $data[0], ':name_alternate' => '', ':country_un' => $data[1], ':country_owner' => $data[2], ':owner' => $data[3], ':users' => $data[4], ':purpose' => $data[5], ':purpose_detailed' => $data[6], ':orbit' => $data[7], ':type' => $data[8], ':longitude_geo' => $data[9], ':perigee' => !empty($data[10]) ? str_replace(',', '', $data[10]) : NULL, ':apogee' => !empty($data[11]) ? str_replace(',', '', $data[11]) : NULL, ':eccentricity' => $data[12], ':inclination' => $data[13], ':period' => !empty($period) ? $period : NULL, ':launch_mass' => !empty($data[15]) ? str_replace(array('+', ','), '', $data[15]) : NULL, ':dry_mass' => !empty($data[16]) ? str_replace(array(',', '-1900', ' (BOL)', ' (EOL)'), '', $data[16]) : NULL, ':power' => !empty($data[17]) ? str_replace(array(',', ' (BOL)', ' (EOL)'), '', $data[17]) : NULL, ':launch_date' => $launch_date, ':lifetime' => $data[19], ':contractor' => $data[20], ':country_contractor' => $data[21], ':launch_site' => $data[22], ':launch_vehicule' => $data[23], ':cospar' => $data[24], ':norad' => $data[25], ':comments' => $data[26], ':source_orbital' => $data[27], ':sources' => $sources)); |
|
| 1486 | + } catch (PDOException $e) { |
|
| 1487 | 1487 | return "error : ".$e->getMessage(); |
| 1488 | 1488 | } |
| 1489 | 1489 | } |
@@ -1523,7 +1523,7 @@ discard block |
||
| 1523 | 1523 | 'EGYP' => array('country' => 'Egypt', 'owner' => ''), |
| 1524 | 1524 | 'ESA' => array('country' => 'Multinational', 'owner' => 'European Space Agency'), |
| 1525 | 1525 | 'ESRO' => array('country' => 'Multinational', 'owner' => 'European Space Research Organization'), |
| 1526 | - 'EST' => array('country' => 'Estonia','owner' => ''), |
|
| 1526 | + 'EST' => array('country' => 'Estonia', 'owner' => ''), |
|
| 1527 | 1527 | 'EUME' => array('country' => 'Multinational', 'owner' => 'EUMETSAT (European Organization for the Exploitation of Meteorological Satellites)'), |
| 1528 | 1528 | 'EUTE' => array('country' => 'Multinational', 'owner' => 'European Telecommunications Satellite Consortium (EUTELSAT)'), |
| 1529 | 1529 | 'FGER' => array('country' => 'France/Germany', 'owner' => ''), |
@@ -1647,10 +1647,10 @@ discard block |
||
| 1647 | 1647 | { |
| 1648 | 1648 | if ($data != '') { |
| 1649 | 1649 | $result = array(); |
| 1650 | - $result['cospar'] = trim(substr($data,0,11)); |
|
| 1651 | - $result['norad'] = trim(substr($data,13,6)); |
|
| 1652 | - $result['operational'] = trim(substr($data,21,1)); |
|
| 1653 | - $result['name'] = trim(substr($data,23,24)); |
|
| 1650 | + $result['cospar'] = trim(substr($data, 0, 11)); |
|
| 1651 | + $result['norad'] = trim(substr($data, 13, 6)); |
|
| 1652 | + $result['operational'] = trim(substr($data, 21, 1)); |
|
| 1653 | + $result['name'] = trim(substr($data, 23, 24)); |
|
| 1654 | 1654 | /* |
| 1655 | 1655 | * R/B(1) = Rocket body, first stage |
| 1656 | 1656 | * R/B(2) = Rocket body, second stage |
@@ -1662,29 +1662,29 @@ discard block |
||
| 1662 | 1662 | * An ampersand (&) indicates two or more objects are attached |
| 1663 | 1663 | */ |
| 1664 | 1664 | |
| 1665 | - $owner_code = trim(substr($data,49,5)); |
|
| 1665 | + $owner_code = trim(substr($data, 49, 5)); |
|
| 1666 | 1666 | |
| 1667 | 1667 | if (!isset($satcat_sources[$owner_code])) { |
| 1668 | 1668 | echo $data; |
| 1669 | 1669 | echo 'owner_code: '.$owner_code."\n"; |
| 1670 | 1670 | } |
| 1671 | - if (!isset($satcat_launch_site[trim(substr($data,68,5))])) { |
|
| 1672 | - echo 'launch_site_code: '.trim(substr($data,68,5))."\n"; |
|
| 1671 | + if (!isset($satcat_launch_site[trim(substr($data, 68, 5))])) { |
|
| 1672 | + echo 'launch_site_code: '.trim(substr($data, 68, 5))."\n"; |
|
| 1673 | 1673 | } |
| 1674 | 1674 | |
| 1675 | - if ($owner_code != 'TBD' && isset($satcat_sources[$owner_code]) && isset($satcat_launch_site[trim(substr($data,68,5))])) { |
|
| 1675 | + if ($owner_code != 'TBD' && isset($satcat_sources[$owner_code]) && isset($satcat_launch_site[trim(substr($data, 68, 5))])) { |
|
| 1676 | 1676 | $result['country_owner'] = $satcat_sources[$owner_code]['country']; |
| 1677 | 1677 | $result['owner'] = $satcat_sources[$owner_code]['owner']; |
| 1678 | - $result['launch_date'] = trim(substr($data,56,10)); |
|
| 1679 | - $launch_site_code = trim(substr($data,68,5)); |
|
| 1678 | + $result['launch_date'] = trim(substr($data, 56, 10)); |
|
| 1679 | + $launch_site_code = trim(substr($data, 68, 5)); |
|
| 1680 | 1680 | $result['launch_site'] = $satcat_launch_site[$launch_site_code]; |
| 1681 | - $result['lifetime'] = trim(substr($data,75,10)); |
|
| 1682 | - $result['period'] = trim(substr($data,87,7)); |
|
| 1683 | - $result['inclination'] = trim(substr($data,96,5)); |
|
| 1684 | - $result['apogee'] = trim(substr($data,103,6)); |
|
| 1685 | - $result['perigee'] = trim(substr($data,111,6)); |
|
| 1681 | + $result['lifetime'] = trim(substr($data, 75, 10)); |
|
| 1682 | + $result['period'] = trim(substr($data, 87, 7)); |
|
| 1683 | + $result['inclination'] = trim(substr($data, 96, 5)); |
|
| 1684 | + $result['apogee'] = trim(substr($data, 103, 6)); |
|
| 1685 | + $result['perigee'] = trim(substr($data, 111, 6)); |
|
| 1686 | 1686 | //$result['radarcross'] = trim(substr($data,119,8)); |
| 1687 | - $result['status'] = trim(substr($data,129,3)); |
|
| 1687 | + $result['status'] = trim(substr($data, 129, 3)); |
|
| 1688 | 1688 | //print_r($result); |
| 1689 | 1689 | $result = array_map(function($value) { |
| 1690 | 1690 | return trim($value) === '' ? null : $value; |
@@ -1697,7 +1697,7 @@ discard block |
||
| 1697 | 1697 | $sth = $Connection->db->prepare($query); |
| 1698 | 1698 | $sth->execute(array(':cospar' => $result['cospar'])); |
| 1699 | 1699 | $exist = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1700 | - } catch(PDOException $e) { |
|
| 1700 | + } catch (PDOException $e) { |
|
| 1701 | 1701 | return "error : ".$e->getMessage(); |
| 1702 | 1702 | } |
| 1703 | 1703 | if (empty($exist)) { |
@@ -1709,10 +1709,10 @@ discard block |
||
| 1709 | 1709 | ':name' => $result['name'], ':name_alternate' => '', ':country_un' => '', ':country_owner' => $result['country_owner'], ':owner' => $result['owner'], ':users' => '', ':purpose' => '', ':purpose_detailed' => '', ':orbit' => $result['status'], |
| 1710 | 1710 | ':type' => '', ':longitude_geo' => NULL, ':perigee' => !empty($result['perigee']) ? $result['perigee'] : NULL, ':apogee' => !empty($result['apogee']) ? $result['apogee'] : NULL, ':eccentricity' => NULL, ':inclination' => $result['inclination'], |
| 1711 | 1711 | ':period' => !empty($result['period']) ? $result['period'] : NULL, ':launch_mass' => NULL, ':dry_mass' => NULL, ':power' => NULL, ':launch_date' => $result['launch_date'], ':lifetime' => $result['lifetime'], |
| 1712 | - ':contractor' => '',':country_contractor' => '', ':launch_site' => $result['launch_site'], ':launch_vehicule' => '', ':cospar' => $result['cospar'], ':norad' => $result['norad'], ':comments' => '', ':source_orbital' => '', ':sources' => '' |
|
| 1712 | + ':contractor' => '', ':country_contractor' => '', ':launch_site' => $result['launch_site'], ':launch_vehicule' => '', ':cospar' => $result['cospar'], ':norad' => $result['norad'], ':comments' => '', ':source_orbital' => '', ':sources' => '' |
|
| 1713 | 1713 | ) |
| 1714 | 1714 | ); |
| 1715 | - } catch(PDOException $e) { |
|
| 1715 | + } catch (PDOException $e) { |
|
| 1716 | 1716 | return "error : ".$e->getMessage(); |
| 1717 | 1717 | } |
| 1718 | 1718 | } elseif ($exist[0]['name'] != $result['name'] && $exist[0]['name_alternate'] != $result['name']) { |
@@ -1720,8 +1720,8 @@ discard block |
||
| 1720 | 1720 | try { |
| 1721 | 1721 | $Connection = new Connection(); |
| 1722 | 1722 | $sth = $Connection->db->prepare($query); |
| 1723 | - $sth->execute(array(':name_alternate' => $result['name'],':cospar' => $result['cospar'])); |
|
| 1724 | - } catch(PDOException $e) { |
|
| 1723 | + $sth->execute(array(':name_alternate' => $result['name'], ':cospar' => $result['cospar'])); |
|
| 1724 | + } catch (PDOException $e) { |
|
| 1725 | 1725 | return "error : ".$e->getMessage(); |
| 1726 | 1726 | } |
| 1727 | 1727 | } |
@@ -1840,13 +1840,13 @@ discard block |
||
| 1840 | 1840 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1841 | 1841 | { |
| 1842 | 1842 | $i++; |
| 1843 | - if($i > 3 && count($row) > 2) { |
|
| 1843 | + if ($i > 3 && count($row) > 2) { |
|
| 1844 | 1844 | $data = array_values(array_filter($row)); |
| 1845 | 1845 | $cntdata = count($data); |
| 1846 | 1846 | if ($cntdata > 10) { |
| 1847 | 1847 | $value = $data[9]; |
| 1848 | 1848 | |
| 1849 | - for ($i =10;$i < $cntdata;$i++) { |
|
| 1849 | + for ($i = 10; $i < $cntdata; $i++) { |
|
| 1850 | 1850 | $value .= ' '.$data[$i]; |
| 1851 | 1851 | } |
| 1852 | 1852 | $data[9] = $value; |
@@ -1856,8 +1856,8 @@ discard block |
||
| 1856 | 1856 | $query = 'INSERT INTO waypoints (name_begin,latitude_begin,longitude_begin,name_end,latitude_end,longitude_end,high,base,top,segment_name) VALUES (:name_begin, :latitude_begin, :longitude_begin, :name_end, :latitude_end, :longitude_end, :high, :base, :top, :segment_name)'; |
| 1857 | 1857 | try { |
| 1858 | 1858 | $sth = $Connection->db->prepare($query); |
| 1859 | - $sth->execute(array(':name_begin' => $data[0],':latitude_begin' => $data[1],':longitude_begin' => $data[2],':name_end' => $data[3], ':latitude_end' => $data[4], ':longitude_end' => $data[5], ':high' => $data[6], ':base' => $data[7], ':top' => $data[8], ':segment_name' => $data[9])); |
|
| 1860 | - } catch(PDOException $e) { |
|
| 1859 | + $sth->execute(array(':name_begin' => $data[0], ':latitude_begin' => $data[1], ':longitude_begin' => $data[2], ':name_end' => $data[3], ':latitude_end' => $data[4], ':longitude_end' => $data[5], ':high' => $data[6], ':base' => $data[7], ':top' => $data[8], ':segment_name' => $data[9])); |
|
| 1860 | + } catch (PDOException $e) { |
|
| 1861 | 1861 | return "error : ".$e->getMessage(); |
| 1862 | 1862 | } |
| 1863 | 1863 | } |
@@ -1874,16 +1874,16 @@ discard block |
||
| 1874 | 1874 | require_once(dirname(__FILE__).'/../require/class.Source.php'); |
| 1875 | 1875 | $delimiter = ','; |
| 1876 | 1876 | $Common = new Common(); |
| 1877 | - $Common->download('http://firms.modaps.eosdis.nasa.gov/active_fire/viirs/text/VNP14IMGTDL_NRT_Global_24h.csv',$tmp_dir.'fires.csv'); |
|
| 1877 | + $Common->download('http://firms.modaps.eosdis.nasa.gov/active_fire/viirs/text/VNP14IMGTDL_NRT_Global_24h.csv', $tmp_dir.'fires.csv'); |
|
| 1878 | 1878 | $Connection = new Connection(); |
| 1879 | 1879 | $Source = new Source(); |
| 1880 | 1880 | $Source->deleteLocationByType('fires'); |
| 1881 | 1881 | $i = 0; |
| 1882 | - if (($handle = fopen($tmp_dir.'fires.csv','r')) !== false) { |
|
| 1883 | - while (($row = fgetcsv($handle,1000)) !== false) { |
|
| 1882 | + if (($handle = fopen($tmp_dir.'fires.csv', 'r')) !== false) { |
|
| 1883 | + while (($row = fgetcsv($handle, 1000)) !== false) { |
|
| 1884 | 1884 | if ($i > 0 && $row[0] != '' && $row[8] != 'low') { |
| 1885 | - $description = array('bright_t14' => $row[2],'scan' => $row[3],'track' => $row[4],'sat' => $row[7],'confidence' => $row[8],'version' => $row[9],'bright_t15' => $row[10],'frp' => $row[11],'daynight' => $row[12]); |
|
| 1886 | - $Source->addLocation('',$row[0],$row[1],null,'','','fires','fire.png','fires',0,0,$row[5].' '.substr($row[6],0,2).':'.substr($row[6],2,2),json_encode($description)); |
|
| 1885 | + $description = array('bright_t14' => $row[2], 'scan' => $row[3], 'track' => $row[4], 'sat' => $row[7], 'confidence' => $row[8], 'version' => $row[9], 'bright_t15' => $row[10], 'frp' => $row[11], 'daynight' => $row[12]); |
|
| 1886 | + $Source->addLocation('', $row[0], $row[1], null, '', '', 'fires', 'fire.png', 'fires', 0, 0, $row[5].' '.substr($row[6], 0, 2).':'.substr($row[6], 2, 2), json_encode($description)); |
|
| 1887 | 1887 | } |
| 1888 | 1888 | $i++; |
| 1889 | 1889 | } |
@@ -1899,7 +1899,7 @@ discard block |
||
| 1899 | 1899 | $Connection = new Connection(); |
| 1900 | 1900 | $sth = $Connection->db->prepare($query); |
| 1901 | 1901 | $sth->execute(); |
| 1902 | - } catch(PDOException $e) { |
|
| 1902 | + } catch (PDOException $e) { |
|
| 1903 | 1903 | return "error : ".$e->getMessage(); |
| 1904 | 1904 | } |
| 1905 | 1905 | $header = NULL; |
@@ -1910,12 +1910,12 @@ discard block |
||
| 1910 | 1910 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 1911 | 1911 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1912 | 1912 | { |
| 1913 | - if(count($row) > 1) { |
|
| 1913 | + if (count($row) > 1) { |
|
| 1914 | 1914 | $query = "INSERT INTO airlines (name,icao,active,forsource) VALUES (:name, :icao, 'Y','ivao')"; |
| 1915 | 1915 | try { |
| 1916 | 1916 | $sth = $Connection->db->prepare($query); |
| 1917 | - $sth->execute(array(':name' => $row[1],':icao' => $row[0])); |
|
| 1918 | - } catch(PDOException $e) { |
|
| 1917 | + $sth->execute(array(':name' => $row[1], ':icao' => $row[0])); |
|
| 1918 | + } catch (PDOException $e) { |
|
| 1919 | 1919 | return "error : ".$e->getMessage(); |
| 1920 | 1920 | } |
| 1921 | 1921 | } |
@@ -1935,21 +1935,21 @@ discard block |
||
| 1935 | 1935 | try { |
| 1936 | 1936 | $sth = $Connection->db->prepare($query); |
| 1937 | 1937 | $sth->execute(); |
| 1938 | - } catch(PDOException $e) { |
|
| 1938 | + } catch (PDOException $e) { |
|
| 1939 | 1939 | return "error : ".$e->getMessage(); |
| 1940 | 1940 | } |
| 1941 | 1941 | } |
| 1942 | 1942 | |
| 1943 | 1943 | |
| 1944 | - if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
| 1944 | + if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz', $tmp_dir.'airspace.sql'); |
|
| 1945 | 1945 | else { |
| 1946 | - update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
| 1946 | + update_db::gunzip('../db/pgsql/airspace.sql.gz', $tmp_dir.'airspace.sql'); |
|
| 1947 | 1947 | $query = "CREATE EXTENSION postgis"; |
| 1948 | - $Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']); |
|
| 1948 | + $Connection = new Connection(null, null, $_SESSION['database_root'], $_SESSION['database_rootpass']); |
|
| 1949 | 1949 | try { |
| 1950 | 1950 | $sth = $Connection->db->prepare($query); |
| 1951 | 1951 | $sth->execute(); |
| 1952 | - } catch(PDOException $e) { |
|
| 1952 | + } catch (PDOException $e) { |
|
| 1953 | 1953 | return "error : ".$e->getMessage(); |
| 1954 | 1954 | } |
| 1955 | 1955 | } |
@@ -1962,13 +1962,13 @@ discard block |
||
| 1962 | 1962 | include_once('class.create_db.php'); |
| 1963 | 1963 | require_once(dirname(__FILE__).'/../require/class.NOTAM.php'); |
| 1964 | 1964 | if ($globalDebug) echo "NOTAM from FlightAirMap website : Download..."; |
| 1965 | - update_db::download('http://data.flightairmap.com/data/notam.txt.gz.md5',$tmp_dir.'notam.txt.gz.md5'); |
|
| 1965 | + update_db::download('http://data.flightairmap.com/data/notam.txt.gz.md5', $tmp_dir.'notam.txt.gz.md5'); |
|
| 1966 | 1966 | $error = ''; |
| 1967 | 1967 | if (file_exists($tmp_dir.'notam.txt.gz.md5')) { |
| 1968 | - $notam_md5_file = explode(' ',file_get_contents($tmp_dir.'notam.txt.gz.md5')); |
|
| 1968 | + $notam_md5_file = explode(' ', file_get_contents($tmp_dir.'notam.txt.gz.md5')); |
|
| 1969 | 1969 | $notam_md5 = $notam_md5_file[0]; |
| 1970 | 1970 | if (!update_db::check_notam_version($notam_md5)) { |
| 1971 | - update_db::download('http://data.flightairmap.com/data/notam.txt.gz',$tmp_dir.'notam.txt.gz'); |
|
| 1971 | + update_db::download('http://data.flightairmap.com/data/notam.txt.gz', $tmp_dir.'notam.txt.gz'); |
|
| 1972 | 1972 | if (file_exists($tmp_dir.'notam.txt.gz')) { |
| 1973 | 1973 | if (md5_file($tmp_dir.'notam.txt.gz') == $notam_md5) { |
| 1974 | 1974 | if ($globalDebug) echo "Gunzip..."; |
@@ -2004,14 +2004,14 @@ discard block |
||
| 2004 | 2004 | try { |
| 2005 | 2005 | $sth = $Connection->db->prepare($query); |
| 2006 | 2006 | $sth->execute(); |
| 2007 | - } catch(PDOException $e) { |
|
| 2007 | + } catch (PDOException $e) { |
|
| 2008 | 2008 | echo "error : ".$e->getMessage(); |
| 2009 | 2009 | } |
| 2010 | 2010 | } |
| 2011 | 2011 | if ($globalDBdriver == 'mysql') { |
| 2012 | - update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql'); |
|
| 2012 | + update_db::gunzip('../db/countries.sql.gz', $tmp_dir.'countries.sql'); |
|
| 2013 | 2013 | } else { |
| 2014 | - update_db::gunzip('../db/pgsql/countries.sql.gz',$tmp_dir.'countries.sql'); |
|
| 2014 | + update_db::gunzip('../db/pgsql/countries.sql.gz', $tmp_dir.'countries.sql'); |
|
| 2015 | 2015 | } |
| 2016 | 2016 | $error = create_db::import_file($tmp_dir.'countries.sql'); |
| 2017 | 2017 | return $error; |
@@ -2024,7 +2024,7 @@ discard block |
||
| 2024 | 2024 | // update_db::unzip($tmp_dir.'AptNav.zip'); |
| 2025 | 2025 | // update_db::download('https://gitorious.org/fg/fgdata/raw/e81f8a15424a175a7b715f8f7eb8f4147b802a27:Navaids/awy.dat.gz',$tmp_dir.'awy.dat.gz'); |
| 2026 | 2026 | // update_db::download('http://sourceforge.net/p/flightgear/fgdata/ci/next/tree/Navaids/awy.dat.gz?format=raw',$tmp_dir.'awy.dat.gz','http://sourceforge.net'); |
| 2027 | - update_db::download('http://pkgs.fedoraproject.org/repo/extras/FlightGear-Atlas/awy.dat.gz/f530c9d1c4b31a288ba88dcc8224268b/awy.dat.gz',$tmp_dir.'awy.dat.gz','http://sourceforge.net'); |
|
| 2027 | + update_db::download('http://pkgs.fedoraproject.org/repo/extras/FlightGear-Atlas/awy.dat.gz/f530c9d1c4b31a288ba88dcc8224268b/awy.dat.gz', $tmp_dir.'awy.dat.gz', 'http://sourceforge.net'); |
|
| 2028 | 2028 | update_db::gunzip($tmp_dir.'awy.dat.gz'); |
| 2029 | 2029 | $error = update_db::waypoints($tmp_dir.'awy.dat'); |
| 2030 | 2030 | return $error; |
@@ -2045,7 +2045,7 @@ discard block |
||
| 2045 | 2045 | update_db::ivao_airlines($tmp_dir.'data/airlines.dat'); |
| 2046 | 2046 | if ($globalDebug) echo "Copy airlines logos to airlines images directory..."; |
| 2047 | 2047 | if (is_writable(dirname(__FILE__).'/../images/airlines')) { |
| 2048 | - if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
| 2048 | + if (!$Common->xcopy($tmp_dir.'logos/', dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
| 2049 | 2049 | } else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
| 2050 | 2050 | } else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
| 2051 | 2051 | } else $error = "ZIP module not loaded but required for IVAO."; |
@@ -2059,7 +2059,7 @@ discard block |
||
| 2059 | 2059 | global $tmp_dir, $globalDebug; |
| 2060 | 2060 | $error = ''; |
| 2061 | 2061 | if ($globalDebug) echo "Routes : Download..."; |
| 2062 | - update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz'); |
|
| 2062 | + update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz', $tmp_dir.'StandingData.sqb.gz'); |
|
| 2063 | 2063 | if (file_exists($tmp_dir.'StandingData.sqb.gz')) { |
| 2064 | 2064 | if ($globalDebug) echo "Gunzip..."; |
| 2065 | 2065 | update_db::gunzip($tmp_dir.'StandingData.sqb.gz'); |
@@ -2075,7 +2075,7 @@ discard block |
||
| 2075 | 2075 | global $tmp_dir, $globalDebug; |
| 2076 | 2076 | $error = ''; |
| 2077 | 2077 | if ($globalDebug) echo "Schedules Oneworld : Download..."; |
| 2078 | - update_db::download('http://data.flightairmap.com/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz'); |
|
| 2078 | + update_db::download('http://data.flightairmap.com/data/schedules/oneworld.csv.gz', $tmp_dir.'oneworld.csv.gz'); |
|
| 2079 | 2079 | if (file_exists($tmp_dir.'oneworld.csv.gz')) { |
| 2080 | 2080 | if ($globalDebug) echo "Gunzip..."; |
| 2081 | 2081 | update_db::gunzip($tmp_dir.'oneworld.csv.gz'); |
@@ -2091,7 +2091,7 @@ discard block |
||
| 2091 | 2091 | global $tmp_dir, $globalDebug; |
| 2092 | 2092 | $error = ''; |
| 2093 | 2093 | if ($globalDebug) echo "Schedules Skyteam : Download..."; |
| 2094 | - update_db::download('http://data.flightairmap.com/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz'); |
|
| 2094 | + update_db::download('http://data.flightairmap.com/data/schedules/skyteam.csv.gz', $tmp_dir.'skyteam.csv.gz'); |
|
| 2095 | 2095 | if (file_exists($tmp_dir.'skyteam.csv.gz')) { |
| 2096 | 2096 | if ($globalDebug) echo "Gunzip..."; |
| 2097 | 2097 | update_db::gunzip($tmp_dir.'skyteam.csv.gz'); |
@@ -2119,7 +2119,7 @@ discard block |
||
| 2119 | 2119 | */ |
| 2120 | 2120 | if ($globalDebug) echo "Modes : Download..."; |
| 2121 | 2121 | // update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
| 2122 | - update_db::download('http://data.flightairmap.com/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz'); |
|
| 2122 | + update_db::download('http://data.flightairmap.com/data/BaseStation.sqb.gz', $tmp_dir.'BaseStation.sqb.gz'); |
|
| 2123 | 2123 | |
| 2124 | 2124 | // if (file_exists($tmp_dir.'basestation_latest.zip')) { |
| 2125 | 2125 | if (file_exists($tmp_dir.'BaseStation.sqb.gz')) { |
@@ -2139,7 +2139,7 @@ discard block |
||
| 2139 | 2139 | public static function update_ModeS_faa() { |
| 2140 | 2140 | global $tmp_dir, $globalDebug; |
| 2141 | 2141 | if ($globalDebug) echo "Modes FAA: Download..."; |
| 2142 | - update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip'); |
|
| 2142 | + update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip', $tmp_dir.'ReleasableAircraft.zip'); |
|
| 2143 | 2143 | if (file_exists($tmp_dir.'ReleasableAircraft.zip')) { |
| 2144 | 2144 | if ($globalDebug) echo "Unzip..."; |
| 2145 | 2145 | update_db::unzip($tmp_dir.'ReleasableAircraft.zip'); |
@@ -2155,7 +2155,7 @@ discard block |
||
| 2155 | 2155 | public static function update_ModeS_flarm() { |
| 2156 | 2156 | global $tmp_dir, $globalDebug; |
| 2157 | 2157 | if ($globalDebug) echo "Modes Flarmnet: Download..."; |
| 2158 | - update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln'); |
|
| 2158 | + update_db::download('http://flarmnet.org/files/data.fln', $tmp_dir.'data.fln'); |
|
| 2159 | 2159 | if (file_exists($tmp_dir.'data.fln')) { |
| 2160 | 2160 | if ($globalDebug) echo "Add to DB..."; |
| 2161 | 2161 | $error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln'); |
@@ -2169,7 +2169,7 @@ discard block |
||
| 2169 | 2169 | public static function update_ModeS_ogn() { |
| 2170 | 2170 | global $tmp_dir, $globalDebug; |
| 2171 | 2171 | if ($globalDebug) echo "Modes OGN: Download..."; |
| 2172 | - update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv'); |
|
| 2172 | + update_db::download('http://ddb.glidernet.org/download/', $tmp_dir.'ogn.csv'); |
|
| 2173 | 2173 | if (file_exists($tmp_dir.'ogn.csv')) { |
| 2174 | 2174 | if ($globalDebug) echo "Add to DB..."; |
| 2175 | 2175 | $error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv'); |
@@ -2184,201 +2184,201 @@ discard block |
||
| 2184 | 2184 | global $tmp_dir, $globalDebug, $globalMasterSource; |
| 2185 | 2185 | |
| 2186 | 2186 | if ($globalDebug) echo "Owner France: Download..."; |
| 2187 | - update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv'); |
|
| 2187 | + update_db::download('http://antonakis.co.uk/registers/France.txt', $tmp_dir.'owner_f.csv'); |
|
| 2188 | 2188 | if (file_exists($tmp_dir.'owner_f.csv')) { |
| 2189 | 2189 | if ($globalDebug) echo "Add to DB..."; |
| 2190 | - $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F'); |
|
| 2190 | + $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv', 'F'); |
|
| 2191 | 2191 | } else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
| 2192 | 2192 | if ($error != '') { |
| 2193 | 2193 | return $error; |
| 2194 | 2194 | } elseif ($globalDebug) echo "Done\n"; |
| 2195 | 2195 | |
| 2196 | 2196 | if ($globalDebug) echo "Owner Ireland: Download..."; |
| 2197 | - update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv'); |
|
| 2197 | + update_db::download('http://antonakis.co.uk/registers/Ireland.txt', $tmp_dir.'owner_ei.csv'); |
|
| 2198 | 2198 | if (file_exists($tmp_dir.'owner_ei.csv')) { |
| 2199 | 2199 | if ($globalDebug) echo "Add to DB..."; |
| 2200 | - $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI'); |
|
| 2200 | + $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv', 'EI'); |
|
| 2201 | 2201 | } else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
| 2202 | 2202 | if ($error != '') { |
| 2203 | 2203 | return $error; |
| 2204 | 2204 | } elseif ($globalDebug) echo "Done\n"; |
| 2205 | 2205 | if ($globalDebug) echo "Owner Switzerland: Download..."; |
| 2206 | - update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv'); |
|
| 2206 | + update_db::download('http://antonakis.co.uk/registers/Switzerland.txt', $tmp_dir.'owner_hb.csv'); |
|
| 2207 | 2207 | if (file_exists($tmp_dir.'owner_hb.csv')) { |
| 2208 | 2208 | if ($globalDebug) echo "Add to DB..."; |
| 2209 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB'); |
|
| 2209 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv', 'HB'); |
|
| 2210 | 2210 | } else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
| 2211 | 2211 | if ($error != '') { |
| 2212 | 2212 | return $error; |
| 2213 | 2213 | } elseif ($globalDebug) echo "Done\n"; |
| 2214 | 2214 | if ($globalDebug) echo "Owner Czech Republic: Download..."; |
| 2215 | - update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv'); |
|
| 2215 | + update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt', $tmp_dir.'owner_ok.csv'); |
|
| 2216 | 2216 | if (file_exists($tmp_dir.'owner_ok.csv')) { |
| 2217 | 2217 | if ($globalDebug) echo "Add to DB..."; |
| 2218 | - $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK'); |
|
| 2218 | + $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv', 'OK'); |
|
| 2219 | 2219 | } else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
| 2220 | 2220 | if ($error != '') { |
| 2221 | 2221 | return $error; |
| 2222 | 2222 | } elseif ($globalDebug) echo "Done\n"; |
| 2223 | 2223 | if ($globalDebug) echo "Owner Australia: Download..."; |
| 2224 | - update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv'); |
|
| 2224 | + update_db::download('http://antonakis.co.uk/registers/Australia.txt', $tmp_dir.'owner_vh.csv'); |
|
| 2225 | 2225 | if (file_exists($tmp_dir.'owner_vh.csv')) { |
| 2226 | 2226 | if ($globalDebug) echo "Add to DB..."; |
| 2227 | - $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH'); |
|
| 2227 | + $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv', 'VH'); |
|
| 2228 | 2228 | } else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
| 2229 | 2229 | if ($error != '') { |
| 2230 | 2230 | return $error; |
| 2231 | 2231 | } elseif ($globalDebug) echo "Done\n"; |
| 2232 | 2232 | if ($globalDebug) echo "Owner Austria: Download..."; |
| 2233 | - update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv'); |
|
| 2233 | + update_db::download('http://antonakis.co.uk/registers/Austria.txt', $tmp_dir.'owner_oe.csv'); |
|
| 2234 | 2234 | if (file_exists($tmp_dir.'owner_oe.csv')) { |
| 2235 | 2235 | if ($globalDebug) echo "Add to DB..."; |
| 2236 | - $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE'); |
|
| 2236 | + $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv', 'OE'); |
|
| 2237 | 2237 | } else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
| 2238 | 2238 | if ($error != '') { |
| 2239 | 2239 | return $error; |
| 2240 | 2240 | } elseif ($globalDebug) echo "Done\n"; |
| 2241 | 2241 | if ($globalDebug) echo "Owner Chile: Download..."; |
| 2242 | - update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv'); |
|
| 2242 | + update_db::download('http://antonakis.co.uk/registers/Chile.txt', $tmp_dir.'owner_cc.csv'); |
|
| 2243 | 2243 | if (file_exists($tmp_dir.'owner_cc.csv')) { |
| 2244 | 2244 | if ($globalDebug) echo "Add to DB..."; |
| 2245 | - $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC'); |
|
| 2245 | + $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv', 'CC'); |
|
| 2246 | 2246 | } else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
| 2247 | 2247 | if ($error != '') { |
| 2248 | 2248 | return $error; |
| 2249 | 2249 | } elseif ($globalDebug) echo "Done\n"; |
| 2250 | 2250 | if ($globalDebug) echo "Owner Colombia: Download..."; |
| 2251 | - update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv'); |
|
| 2251 | + update_db::download('http://antonakis.co.uk/registers/Colombia.txt', $tmp_dir.'owner_hj.csv'); |
|
| 2252 | 2252 | if (file_exists($tmp_dir.'owner_hj.csv')) { |
| 2253 | 2253 | if ($globalDebug) echo "Add to DB..."; |
| 2254 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ'); |
|
| 2254 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv', 'HJ'); |
|
| 2255 | 2255 | } else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
| 2256 | 2256 | if ($error != '') { |
| 2257 | 2257 | return $error; |
| 2258 | 2258 | } elseif ($globalDebug) echo "Done\n"; |
| 2259 | 2259 | if ($globalDebug) echo "Owner Bosnia Herzegobina: Download..."; |
| 2260 | - update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv'); |
|
| 2260 | + update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt', $tmp_dir.'owner_e7.csv'); |
|
| 2261 | 2261 | if (file_exists($tmp_dir.'owner_e7.csv')) { |
| 2262 | 2262 | if ($globalDebug) echo "Add to DB..."; |
| 2263 | - $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7'); |
|
| 2263 | + $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv', 'E7'); |
|
| 2264 | 2264 | } else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
| 2265 | 2265 | if ($error != '') { |
| 2266 | 2266 | return $error; |
| 2267 | 2267 | } elseif ($globalDebug) echo "Done\n"; |
| 2268 | 2268 | if ($globalDebug) echo "Owner Brazil: Download..."; |
| 2269 | - update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv'); |
|
| 2269 | + update_db::download('http://antonakis.co.uk/registers/Brazil.txt', $tmp_dir.'owner_pp.csv'); |
|
| 2270 | 2270 | if (file_exists($tmp_dir.'owner_pp.csv')) { |
| 2271 | 2271 | if ($globalDebug) echo "Add to DB..."; |
| 2272 | - $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP'); |
|
| 2272 | + $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv', 'PP'); |
|
| 2273 | 2273 | } else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
| 2274 | 2274 | if ($error != '') { |
| 2275 | 2275 | return $error; |
| 2276 | 2276 | } elseif ($globalDebug) echo "Done\n"; |
| 2277 | 2277 | if ($globalDebug) echo "Owner Cayman Islands: Download..."; |
| 2278 | - update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv'); |
|
| 2278 | + update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt', $tmp_dir.'owner_vp.csv'); |
|
| 2279 | 2279 | if (file_exists($tmp_dir.'owner_vp.csv')) { |
| 2280 | 2280 | if ($globalDebug) echo "Add to DB..."; |
| 2281 | - $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP'); |
|
| 2281 | + $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv', 'VP'); |
|
| 2282 | 2282 | } else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
| 2283 | 2283 | if ($error != '') { |
| 2284 | 2284 | return $error; |
| 2285 | 2285 | } elseif ($globalDebug) echo "Done\n"; |
| 2286 | 2286 | if ($globalDebug) echo "Owner Croatia: Download..."; |
| 2287 | - update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv'); |
|
| 2287 | + update_db::download('http://antonakis.co.uk/registers/Croatia.txt', $tmp_dir.'owner_9a.csv'); |
|
| 2288 | 2288 | if (file_exists($tmp_dir.'owner_9a.csv')) { |
| 2289 | 2289 | if ($globalDebug) echo "Add to DB..."; |
| 2290 | - $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A'); |
|
| 2290 | + $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv', '9A'); |
|
| 2291 | 2291 | } else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
| 2292 | 2292 | if ($error != '') { |
| 2293 | 2293 | return $error; |
| 2294 | 2294 | } elseif ($globalDebug) echo "Done\n"; |
| 2295 | 2295 | if ($globalDebug) echo "Owner Luxembourg: Download..."; |
| 2296 | - update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv'); |
|
| 2296 | + update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt', $tmp_dir.'owner_lx.csv'); |
|
| 2297 | 2297 | if (file_exists($tmp_dir.'owner_lx.csv')) { |
| 2298 | 2298 | if ($globalDebug) echo "Add to DB..."; |
| 2299 | - $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX'); |
|
| 2299 | + $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv', 'LX'); |
|
| 2300 | 2300 | } else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
| 2301 | 2301 | if ($error != '') { |
| 2302 | 2302 | return $error; |
| 2303 | 2303 | } elseif ($globalDebug) echo "Done\n"; |
| 2304 | 2304 | if ($globalDebug) echo "Owner Maldives: Download..."; |
| 2305 | - update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv'); |
|
| 2305 | + update_db::download('http://antonakis.co.uk/registers/Maldives.txt', $tmp_dir.'owner_8q.csv'); |
|
| 2306 | 2306 | if (file_exists($tmp_dir.'owner_8q.csv')) { |
| 2307 | 2307 | if ($globalDebug) echo "Add to DB..."; |
| 2308 | - $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q'); |
|
| 2308 | + $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv', '8Q'); |
|
| 2309 | 2309 | } else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
| 2310 | 2310 | if ($error != '') { |
| 2311 | 2311 | return $error; |
| 2312 | 2312 | } elseif ($globalDebug) echo "Done\n"; |
| 2313 | 2313 | if ($globalDebug) echo "Owner New Zealand: Download..."; |
| 2314 | - update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv'); |
|
| 2314 | + update_db::download('http://antonakis.co.uk/registers/NewZealand.txt', $tmp_dir.'owner_zk.csv'); |
|
| 2315 | 2315 | if (file_exists($tmp_dir.'owner_zk.csv')) { |
| 2316 | 2316 | if ($globalDebug) echo "Add to DB..."; |
| 2317 | - $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK'); |
|
| 2317 | + $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv', 'ZK'); |
|
| 2318 | 2318 | } else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
| 2319 | 2319 | if ($error != '') { |
| 2320 | 2320 | return $error; |
| 2321 | 2321 | } elseif ($globalDebug) echo "Done\n"; |
| 2322 | 2322 | if ($globalDebug) echo "Owner Papua New Guinea: Download..."; |
| 2323 | - update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv'); |
|
| 2323 | + update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt', $tmp_dir.'owner_p2.csv'); |
|
| 2324 | 2324 | if (file_exists($tmp_dir.'owner_p2.csv')) { |
| 2325 | 2325 | if ($globalDebug) echo "Add to DB..."; |
| 2326 | - $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2'); |
|
| 2326 | + $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv', 'P2'); |
|
| 2327 | 2327 | } else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
| 2328 | 2328 | if ($error != '') { |
| 2329 | 2329 | return $error; |
| 2330 | 2330 | } elseif ($globalDebug) echo "Done\n"; |
| 2331 | 2331 | if ($globalDebug) echo "Owner Slovakia: Download..."; |
| 2332 | - update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv'); |
|
| 2332 | + update_db::download('http://antonakis.co.uk/registers/Slovakia.txt', $tmp_dir.'owner_om.csv'); |
|
| 2333 | 2333 | if (file_exists($tmp_dir.'owner_om.csv')) { |
| 2334 | 2334 | if ($globalDebug) echo "Add to DB..."; |
| 2335 | - $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM'); |
|
| 2335 | + $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv', 'OM'); |
|
| 2336 | 2336 | } else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
| 2337 | 2337 | if ($error != '') { |
| 2338 | 2338 | return $error; |
| 2339 | 2339 | } elseif ($globalDebug) echo "Done\n"; |
| 2340 | 2340 | if ($globalDebug) echo "Owner Ecuador: Download..."; |
| 2341 | - update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv'); |
|
| 2341 | + update_db::download('http://antonakis.co.uk/registers/Ecuador.txt', $tmp_dir.'owner_hc.csv'); |
|
| 2342 | 2342 | if (file_exists($tmp_dir.'owner_hc.csv')) { |
| 2343 | 2343 | if ($globalDebug) echo "Add to DB..."; |
| 2344 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC'); |
|
| 2344 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv', 'HC'); |
|
| 2345 | 2345 | } else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
| 2346 | 2346 | if ($error != '') { |
| 2347 | 2347 | return $error; |
| 2348 | 2348 | } elseif ($globalDebug) echo "Done\n"; |
| 2349 | 2349 | if ($globalDebug) echo "Owner Iceland: Download..."; |
| 2350 | - update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv'); |
|
| 2350 | + update_db::download('http://antonakis.co.uk/registers/Iceland.txt', $tmp_dir.'owner_tf.csv'); |
|
| 2351 | 2351 | if (file_exists($tmp_dir.'owner_tf.csv')) { |
| 2352 | 2352 | if ($globalDebug) echo "Add to DB..."; |
| 2353 | - $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF'); |
|
| 2353 | + $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv', 'TF'); |
|
| 2354 | 2354 | } else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
| 2355 | 2355 | if ($error != '') { |
| 2356 | 2356 | return $error; |
| 2357 | 2357 | } elseif ($globalDebug) echo "Done\n"; |
| 2358 | 2358 | if ($globalDebug) echo "Owner Isle of Man: Download..."; |
| 2359 | - update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv'); |
|
| 2359 | + update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt', $tmp_dir.'owner_m.csv'); |
|
| 2360 | 2360 | if (file_exists($tmp_dir.'owner_m.csv')) { |
| 2361 | 2361 | if ($globalDebug) echo "Add to DB..."; |
| 2362 | - $error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M'); |
|
| 2362 | + $error = update_db::retrieve_owner($tmp_dir.'owner_m.csv', 'M'); |
|
| 2363 | 2363 | } else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed."; |
| 2364 | 2364 | if ($error != '') { |
| 2365 | 2365 | return $error; |
| 2366 | 2366 | } elseif ($globalDebug) echo "Done\n"; |
| 2367 | 2367 | if ($globalMasterSource) { |
| 2368 | 2368 | if ($globalDebug) echo "ModeS Netherlands: Download..."; |
| 2369 | - update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv'); |
|
| 2369 | + update_db::download('http://antonakis.co.uk/registers/Netherlands.txt', $tmp_dir.'owner_ph.csv'); |
|
| 2370 | 2370 | if (file_exists($tmp_dir.'owner_ph.csv')) { |
| 2371 | 2371 | if ($globalDebug) echo "Add to DB..."; |
| 2372 | - $error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH'); |
|
| 2372 | + $error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv', 'PH'); |
|
| 2373 | 2373 | } else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed."; |
| 2374 | 2374 | if ($error != '') { |
| 2375 | 2375 | return $error; |
| 2376 | 2376 | } elseif ($globalDebug) echo "Done\n"; |
| 2377 | 2377 | if ($globalDebug) echo "ModeS Denmark: Download..."; |
| 2378 | - update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv'); |
|
| 2378 | + update_db::download('http://antonakis.co.uk/registers/Denmark.txt', $tmp_dir.'owner_oy.csv'); |
|
| 2379 | 2379 | if (file_exists($tmp_dir.'owner_oy.csv')) { |
| 2380 | 2380 | if ($globalDebug) echo "Add to DB..."; |
| 2381 | - $error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY'); |
|
| 2381 | + $error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv', 'OY'); |
|
| 2382 | 2382 | } else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed."; |
| 2383 | 2383 | if ($error != '') { |
| 2384 | 2384 | return $error; |
@@ -2391,7 +2391,7 @@ discard block |
||
| 2391 | 2391 | global $tmp_dir, $globalDebug; |
| 2392 | 2392 | $error = ''; |
| 2393 | 2393 | if ($globalDebug) echo "Translation : Download..."; |
| 2394 | - update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip'); |
|
| 2394 | + update_db::download('http://www.acarsd.org/download/translation.php', $tmp_dir.'translation.zip'); |
|
| 2395 | 2395 | if (file_exists($tmp_dir.'translation.zip')) { |
| 2396 | 2396 | if ($globalDebug) echo "Unzip..."; |
| 2397 | 2397 | update_db::unzip($tmp_dir.'translation.zip'); |
@@ -2408,10 +2408,10 @@ discard block |
||
| 2408 | 2408 | global $tmp_dir, $globalDebug; |
| 2409 | 2409 | $error = ''; |
| 2410 | 2410 | if ($globalDebug) echo "Translation from FlightAirMap website : Download..."; |
| 2411 | - update_db::download('http://data.flightairmap.com/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz'); |
|
| 2412 | - update_db::download('http://data.flightairmap.com/data/translation.tsv.gz.md5',$tmp_dir.'translation.tsv.gz.md5'); |
|
| 2411 | + update_db::download('http://data.flightairmap.com/data/translation.tsv.gz', $tmp_dir.'translation.tsv.gz'); |
|
| 2412 | + update_db::download('http://data.flightairmap.com/data/translation.tsv.gz.md5', $tmp_dir.'translation.tsv.gz.md5'); |
|
| 2413 | 2413 | if (file_exists($tmp_dir.'translation.tsv.gz') && file_exists($tmp_dir.'translation.tsv.gz')) { |
| 2414 | - $translation_md5_file = explode(' ',file_get_contents($tmp_dir.'translation.tsv.gz.md5')); |
|
| 2414 | + $translation_md5_file = explode(' ', file_get_contents($tmp_dir.'translation.tsv.gz.md5')); |
|
| 2415 | 2415 | $translation_md5 = $translation_md5_file[0]; |
| 2416 | 2416 | if (md5_file($tmp_dir.'translation.tsv.gz') == $translation_md5) { |
| 2417 | 2417 | if ($globalDebug) echo "Gunzip..."; |
@@ -2429,10 +2429,10 @@ discard block |
||
| 2429 | 2429 | global $tmp_dir, $globalDebug; |
| 2430 | 2430 | $error = ''; |
| 2431 | 2431 | if ($globalDebug) echo "ModeS from FlightAirMap website : Download..."; |
| 2432 | - update_db::download('http://data.flightairmap.com/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz'); |
|
| 2433 | - update_db::download('http://data.flightairmap.com/data/modes.tsv.gz.md5',$tmp_dir.'modes.tsv.gz.md5'); |
|
| 2432 | + update_db::download('http://data.flightairmap.com/data/modes.tsv.gz', $tmp_dir.'modes.tsv.gz'); |
|
| 2433 | + update_db::download('http://data.flightairmap.com/data/modes.tsv.gz.md5', $tmp_dir.'modes.tsv.gz.md5'); |
|
| 2434 | 2434 | if (file_exists($tmp_dir.'modes.tsv.gz') && file_exists($tmp_dir.'modes.tsv.gz.md5')) { |
| 2435 | - $modes_md5_file = explode(' ',file_get_contents($tmp_dir.'modes.tsv.gz.md5')); |
|
| 2435 | + $modes_md5_file = explode(' ', file_get_contents($tmp_dir.'modes.tsv.gz.md5')); |
|
| 2436 | 2436 | $modes_md5 = $modes_md5_file[0]; |
| 2437 | 2437 | if (md5_file($tmp_dir.'modes.tsv.gz') == $modes_md5) { |
| 2438 | 2438 | if ($globalDebug) echo "Gunzip..."; |
@@ -2451,12 +2451,12 @@ discard block |
||
| 2451 | 2451 | global $tmp_dir, $globalDebug; |
| 2452 | 2452 | $error = ''; |
| 2453 | 2453 | if ($globalDebug) echo "Airlines from FlightAirMap website : Download..."; |
| 2454 | - update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz.md5',$tmp_dir.'airlines.tsv.gz.md5'); |
|
| 2454 | + update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz.md5', $tmp_dir.'airlines.tsv.gz.md5'); |
|
| 2455 | 2455 | if (file_exists($tmp_dir.'airlines.tsv.gz.md5')) { |
| 2456 | - $airlines_md5_file = explode(' ',file_get_contents($tmp_dir.'airlines.tsv.gz.md5')); |
|
| 2456 | + $airlines_md5_file = explode(' ', file_get_contents($tmp_dir.'airlines.tsv.gz.md5')); |
|
| 2457 | 2457 | $airlines_md5 = $airlines_md5_file[0]; |
| 2458 | 2458 | if (!update_db::check_airlines_version($airlines_md5)) { |
| 2459 | - update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz',$tmp_dir.'airlines.tsv.gz'); |
|
| 2459 | + update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz', $tmp_dir.'airlines.tsv.gz'); |
|
| 2460 | 2460 | if (file_exists($tmp_dir.'airlines.tsv.gz')) { |
| 2461 | 2461 | if (md5_file($tmp_dir.'airlines.tsv.gz') == $airlines_md5) { |
| 2462 | 2462 | if ($globalDebug) echo "Gunzip..."; |
@@ -2481,14 +2481,14 @@ discard block |
||
| 2481 | 2481 | if ($globalDebug) echo "owner from FlightAirMap website : Download..."; |
| 2482 | 2482 | $error = ''; |
| 2483 | 2483 | if ($globalOwner === TRUE) { |
| 2484 | - update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz'); |
|
| 2485 | - update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz.md5',$tmp_dir.'owners.tsv.gz.md5'); |
|
| 2484 | + update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz', $tmp_dir.'owners.tsv.gz'); |
|
| 2485 | + update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz.md5', $tmp_dir.'owners.tsv.gz.md5'); |
|
| 2486 | 2486 | } else { |
| 2487 | - update_db::download('http://data.flightairmap.com/data/owners.tsv.gz',$tmp_dir.'owners.tsv.gz'); |
|
| 2488 | - update_db::download('http://data.flightairmap.com/data/owners.tsv.gz.md5',$tmp_dir.'owners.tsv.gz.md5'); |
|
| 2487 | + update_db::download('http://data.flightairmap.com/data/owners.tsv.gz', $tmp_dir.'owners.tsv.gz'); |
|
| 2488 | + update_db::download('http://data.flightairmap.com/data/owners.tsv.gz.md5', $tmp_dir.'owners.tsv.gz.md5'); |
|
| 2489 | 2489 | } |
| 2490 | 2490 | if (file_exists($tmp_dir.'owners.tsv.gz') && file_exists($tmp_dir.'owners.tsv.gz.md5')) { |
| 2491 | - $owners_md5_file = explode(' ',file_get_contents($tmp_dir.'owners.tsv.gz.md5')); |
|
| 2491 | + $owners_md5_file = explode(' ', file_get_contents($tmp_dir.'owners.tsv.gz.md5')); |
|
| 2492 | 2492 | $owners_md5 = $owners_md5_file[0]; |
| 2493 | 2493 | if (md5_file($tmp_dir.'owners.tsv.gz') == $owners_md5) { |
| 2494 | 2494 | if ($globalDebug) echo "Gunzip..."; |
@@ -2505,10 +2505,10 @@ discard block |
||
| 2505 | 2505 | public static function update_routes_fam() { |
| 2506 | 2506 | global $tmp_dir, $globalDebug; |
| 2507 | 2507 | if ($globalDebug) echo "Routes from FlightAirMap website : Download..."; |
| 2508 | - update_db::download('http://data.flightairmap.com/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz'); |
|
| 2509 | - update_db::download('http://data.flightairmap.com/data/routes.tsv.gz.md5',$tmp_dir.'routes.tsv.gz.md5'); |
|
| 2508 | + update_db::download('http://data.flightairmap.com/data/routes.tsv.gz', $tmp_dir.'routes.tsv.gz'); |
|
| 2509 | + update_db::download('http://data.flightairmap.com/data/routes.tsv.gz.md5', $tmp_dir.'routes.tsv.gz.md5'); |
|
| 2510 | 2510 | if (file_exists($tmp_dir.'routes.tsv.gz') && file_exists($tmp_dir.'routes.tsv.gz.md5')) { |
| 2511 | - $routes_md5_file = explode(' ',file_get_contents($tmp_dir.'routes.tsv.gz.md5')); |
|
| 2511 | + $routes_md5_file = explode(' ', file_get_contents($tmp_dir.'routes.tsv.gz.md5')); |
|
| 2512 | 2512 | $routes_md5 = $routes_md5_file[0]; |
| 2513 | 2513 | if (md5_file($tmp_dir.'routes.tsv.gz') == $routes_md5) { |
| 2514 | 2514 | if ($globalDebug) echo "Gunzip..."; |
@@ -2524,13 +2524,13 @@ discard block |
||
| 2524 | 2524 | } |
| 2525 | 2525 | public static function update_marine_identity_fam() { |
| 2526 | 2526 | global $tmp_dir, $globalDebug; |
| 2527 | - update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz.md5',$tmp_dir.'marine_identity.tsv.gz.md5'); |
|
| 2527 | + update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz.md5', $tmp_dir.'marine_identity.tsv.gz.md5'); |
|
| 2528 | 2528 | if (file_exists($tmp_dir.'marine_identity.tsv.gz.md5')) { |
| 2529 | - $marine_identity_md5_file = explode(' ',file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5')); |
|
| 2529 | + $marine_identity_md5_file = explode(' ', file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5')); |
|
| 2530 | 2530 | $marine_identity_md5 = $marine_identity_md5_file[0]; |
| 2531 | 2531 | if (!update_db::check_marine_identity_version($marine_identity_md5)) { |
| 2532 | 2532 | if ($globalDebug) echo "Marine identity from FlightAirMap website : Download..."; |
| 2533 | - update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz',$tmp_dir.'marine_identity.tsv.gz'); |
|
| 2533 | + update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz', $tmp_dir.'marine_identity.tsv.gz'); |
|
| 2534 | 2534 | if (file_exists($tmp_dir.'marine_identity.tsv.gz')) { |
| 2535 | 2535 | if (md5_file($tmp_dir.'marine_identity.tsv.gz') == $marine_identity_md5) { |
| 2536 | 2536 | if ($globalDebug) echo "Gunzip..."; |
@@ -2552,13 +2552,13 @@ discard block |
||
| 2552 | 2552 | |
| 2553 | 2553 | public static function update_satellite_fam() { |
| 2554 | 2554 | global $tmp_dir, $globalDebug; |
| 2555 | - update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz.md5',$tmp_dir.'satellite.tsv.gz.md5'); |
|
| 2555 | + update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz.md5', $tmp_dir.'satellite.tsv.gz.md5'); |
|
| 2556 | 2556 | if (file_exists($tmp_dir.'satellite.tsv.gz.md5')) { |
| 2557 | - $satellite_md5_file = explode(' ',file_get_contents($tmp_dir.'satellite.tsv.gz.md5')); |
|
| 2557 | + $satellite_md5_file = explode(' ', file_get_contents($tmp_dir.'satellite.tsv.gz.md5')); |
|
| 2558 | 2558 | $satellite_md5 = $satellite_md5_file[0]; |
| 2559 | 2559 | if (!update_db::check_satellite_version($satellite_md5)) { |
| 2560 | 2560 | if ($globalDebug) echo "Satellite from FlightAirMap website : Download..."; |
| 2561 | - update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz',$tmp_dir.'satellite.tsv.gz'); |
|
| 2561 | + update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz', $tmp_dir.'satellite.tsv.gz'); |
|
| 2562 | 2562 | if (file_exists($tmp_dir.'satellite.tsv.gz')) { |
| 2563 | 2563 | if (md5_file($tmp_dir.'satellite.tsv.gz') == $satellite_md5) { |
| 2564 | 2564 | if ($globalDebug) echo "Gunzip..."; |
@@ -2580,7 +2580,7 @@ discard block |
||
| 2580 | 2580 | public static function update_banned_fam() { |
| 2581 | 2581 | global $tmp_dir, $globalDebug; |
| 2582 | 2582 | if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download..."; |
| 2583 | - update_db::download('http://data.flightairmap.com/data/ban-eu.csv',$tmp_dir.'ban_eu.csv'); |
|
| 2583 | + update_db::download('http://data.flightairmap.com/data/ban-eu.csv', $tmp_dir.'ban_eu.csv'); |
|
| 2584 | 2584 | if (file_exists($tmp_dir.'ban_eu.csv')) { |
| 2585 | 2585 | //if ($globalDebug) echo "Gunzip..."; |
| 2586 | 2586 | //update_db::gunzip($tmp_dir.'ban_ue.csv'); |
@@ -2599,18 +2599,18 @@ discard block |
||
| 2599 | 2599 | $error = ''; |
| 2600 | 2600 | if ($globalDebug) echo "Airspace from FlightAirMap website : Download..."; |
| 2601 | 2601 | if ($globalDBdriver == 'mysql') { |
| 2602 | - update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); |
|
| 2602 | + update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5'); |
|
| 2603 | 2603 | } else { |
| 2604 | - update_db::download('http://data.flightairmap.com/data/airspace_pgsql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); |
|
| 2604 | + update_db::download('http://data.flightairmap.com/data/airspace_pgsql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5'); |
|
| 2605 | 2605 | } |
| 2606 | 2606 | if (file_exists($tmp_dir.'airspace.sql.gz.md5')) { |
| 2607 | - $airspace_md5_file = explode(' ',file_get_contents($tmp_dir.'airspace.sql.gz.md5')); |
|
| 2607 | + $airspace_md5_file = explode(' ', file_get_contents($tmp_dir.'airspace.sql.gz.md5')); |
|
| 2608 | 2608 | $airspace_md5 = $airspace_md5_file[0]; |
| 2609 | 2609 | if (!update_db::check_airspace_version($airspace_md5)) { |
| 2610 | 2610 | if ($globalDBdriver == 'mysql') { |
| 2611 | - update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz',$tmp_dir.'airspace.sql.gz'); |
|
| 2611 | + update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz', $tmp_dir.'airspace.sql.gz'); |
|
| 2612 | 2612 | } else { |
| 2613 | - update_db::download('http://data.flightairmap.com/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz'); |
|
| 2613 | + update_db::download('http://data.flightairmap.com/data/airspace_pgsql.sql.gz', $tmp_dir.'airspace.sql.gz'); |
|
| 2614 | 2614 | } |
| 2615 | 2615 | if (file_exists($tmp_dir.'airspace.sql.gz')) { |
| 2616 | 2616 | if (md5_file($tmp_dir.'airspace.sql.gz') == $airspace_md5) { |
@@ -2623,7 +2623,7 @@ discard block |
||
| 2623 | 2623 | try { |
| 2624 | 2624 | $sth = $Connection->db->prepare($query); |
| 2625 | 2625 | $sth->execute(); |
| 2626 | - } catch(PDOException $e) { |
|
| 2626 | + } catch (PDOException $e) { |
|
| 2627 | 2627 | return "error : ".$e->getMessage(); |
| 2628 | 2628 | } |
| 2629 | 2629 | } |
@@ -2643,16 +2643,16 @@ discard block |
||
| 2643 | 2643 | global $tmp_dir, $globalDebug, $globalGeoidSource; |
| 2644 | 2644 | $error = ''; |
| 2645 | 2645 | if ($globalDebug) echo "Geoid from FlightAirMap website : Download..."; |
| 2646 | - update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5',$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'); |
|
| 2646 | + update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5', $tmp_dir.$globalGeoidSource.'.pgm.gz.md5'); |
|
| 2647 | 2647 | if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')) { |
| 2648 | - $geoid_md5_file = explode(' ',file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')); |
|
| 2648 | + $geoid_md5_file = explode(' ', file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')); |
|
| 2649 | 2649 | $geoid_md5 = $geoid_md5_file[0]; |
| 2650 | 2650 | if (!update_db::check_geoid_version($geoid_md5)) { |
| 2651 | - update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz',$tmp_dir.$globalGeoidSource.'.pgm.gz'); |
|
| 2651 | + update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz', $tmp_dir.$globalGeoidSource.'.pgm.gz'); |
|
| 2652 | 2652 | if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz')) { |
| 2653 | 2653 | if (md5_file($tmp_dir.$globalGeoidSource.'.pgm.gz') == $geoid_md5) { |
| 2654 | 2654 | if ($globalDebug) echo "Gunzip..."; |
| 2655 | - update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz',dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm'); |
|
| 2655 | + update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz', dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm'); |
|
| 2656 | 2656 | if (file_exists(dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm')) { |
| 2657 | 2657 | update_db::insert_geoid_version($geoid_md5); |
| 2658 | 2658 | } |
@@ -2669,15 +2669,15 @@ discard block |
||
| 2669 | 2669 | public static function update_tle() { |
| 2670 | 2670 | global $tmp_dir, $globalDebug; |
| 2671 | 2671 | if ($globalDebug) echo "Download TLE : Download..."; |
| 2672 | - $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 | - '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 | - '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'); |
|
| 2672 | + $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 | + '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 | + '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 | 2675 | foreach ($alltle as $filename) { |
| 2676 | 2676 | if ($globalDebug) echo "downloading ".$filename.'...'; |
| 2677 | - update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename); |
|
| 2677 | + update_db::download('http://celestrak.com/NORAD/elements/'.$filename, $tmp_dir.$filename); |
|
| 2678 | 2678 | if (file_exists($tmp_dir.$filename)) { |
| 2679 | 2679 | if ($globalDebug) echo "Add to DB ".$filename."..."; |
| 2680 | - $error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename)); |
|
| 2680 | + $error = update_db::tle($tmp_dir.$filename, str_replace('.txt', '', $filename)); |
|
| 2681 | 2681 | } else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
| 2682 | 2682 | if ($error != '') { |
| 2683 | 2683 | echo $error."\n"; |
@@ -2689,7 +2689,7 @@ discard block |
||
| 2689 | 2689 | public static function update_ucsdb() { |
| 2690 | 2690 | global $tmp_dir, $globalDebug; |
| 2691 | 2691 | if ($globalDebug) echo "Download UCS DB : Download..."; |
| 2692 | - 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'); |
|
| 2692 | + 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 | 2693 | if (file_exists($tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt')) { |
| 2694 | 2694 | if ($globalDebug) echo "Add to DB..."; |
| 2695 | 2695 | $error = update_db::satellite_ucsdb($tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt'); |
@@ -2703,7 +2703,7 @@ discard block |
||
| 2703 | 2703 | public static function update_celestrak() { |
| 2704 | 2704 | global $tmp_dir, $globalDebug; |
| 2705 | 2705 | if ($globalDebug) echo "Download Celestrak DB : Download..."; |
| 2706 | - update_db::download('http://celestrak.com/pub/satcat.txt',$tmp_dir.'satcat.txt'); |
|
| 2706 | + update_db::download('http://celestrak.com/pub/satcat.txt', $tmp_dir.'satcat.txt'); |
|
| 2707 | 2707 | if (file_exists($tmp_dir.'satcat.txt')) { |
| 2708 | 2708 | if ($globalDebug) echo "Add to DB..."; |
| 2709 | 2709 | $error = update_db::satellite_celestrak($tmp_dir.'satcat.txt'); |
@@ -2718,63 +2718,63 @@ discard block |
||
| 2718 | 2718 | global $tmp_dir, $globalDebug; |
| 2719 | 2719 | $error = ''; |
| 2720 | 2720 | if ($globalDebug) echo "Models from FlightAirMap website : Download..."; |
| 2721 | - update_db::download('http://data.flightairmap.com/data/models/models.md5sum',$tmp_dir.'models.md5sum'); |
|
| 2721 | + update_db::download('http://data.flightairmap.com/data/models/models.md5sum', $tmp_dir.'models.md5sum'); |
|
| 2722 | 2722 | if (file_exists($tmp_dir.'models.md5sum')) { |
| 2723 | 2723 | if ($globalDebug) echo "Check files...\n"; |
| 2724 | 2724 | $newmodelsdb = array(); |
| 2725 | - if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) { |
|
| 2726 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
| 2725 | + if (($handle = fopen($tmp_dir.'models.md5sum', 'r')) !== FALSE) { |
|
| 2726 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
| 2727 | 2727 | $model = trim($row[2]); |
| 2728 | 2728 | $newmodelsdb[$model] = trim($row[0]); |
| 2729 | 2729 | } |
| 2730 | 2730 | } |
| 2731 | 2731 | $modelsdb = array(); |
| 2732 | 2732 | if (file_exists(dirname(__FILE__).'/../models/models.md5sum')) { |
| 2733 | - if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum','r')) !== FALSE) { |
|
| 2734 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
| 2733 | + if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum', 'r')) !== FALSE) { |
|
| 2734 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
| 2735 | 2735 | $model = trim($row[2]); |
| 2736 | 2736 | $modelsdb[$model] = trim($row[0]); |
| 2737 | 2737 | } |
| 2738 | 2738 | } |
| 2739 | 2739 | } |
| 2740 | - $diff = array_diff($newmodelsdb,$modelsdb); |
|
| 2740 | + $diff = array_diff($newmodelsdb, $modelsdb); |
|
| 2741 | 2741 | foreach ($diff as $key => $value) { |
| 2742 | 2742 | if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n"; |
| 2743 | - update_db::download('http://data.flightairmap.com/data/models/'.$key,dirname(__FILE__).'/../models/'.$key); |
|
| 2743 | + update_db::download('http://data.flightairmap.com/data/models/'.$key, dirname(__FILE__).'/../models/'.$key); |
|
| 2744 | 2744 | |
| 2745 | 2745 | } |
| 2746 | - update_db::download('http://data.flightairmap.com/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum'); |
|
| 2746 | + update_db::download('http://data.flightairmap.com/data/models/models.md5sum', dirname(__FILE__).'/../models/models.md5sum'); |
|
| 2747 | 2747 | } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
| 2748 | 2748 | if ($error != '') { |
| 2749 | 2749 | return $error; |
| 2750 | 2750 | } elseif ($globalDebug) echo "Done\n"; |
| 2751 | 2751 | if ($globalDebug) echo "glTF 2.0 Models from FlightAirMap website : Download..."; |
| 2752 | - update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum',$tmp_dir.'modelsgltf2.md5sum'); |
|
| 2752 | + update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum', $tmp_dir.'modelsgltf2.md5sum'); |
|
| 2753 | 2753 | if (file_exists($tmp_dir.'modelsgltf2.md5sum')) { |
| 2754 | 2754 | if ($globalDebug) echo "Check files...\n"; |
| 2755 | 2755 | $newmodelsdb = array(); |
| 2756 | - if (($handle = fopen($tmp_dir.'modelsgltf2.md5sum','r')) !== FALSE) { |
|
| 2757 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
| 2756 | + if (($handle = fopen($tmp_dir.'modelsgltf2.md5sum', 'r')) !== FALSE) { |
|
| 2757 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
| 2758 | 2758 | $model = trim($row[2]); |
| 2759 | 2759 | $newmodelsdb[$model] = trim($row[0]); |
| 2760 | 2760 | } |
| 2761 | 2761 | } |
| 2762 | 2762 | $modelsdb = array(); |
| 2763 | 2763 | if (file_exists(dirname(__FILE__).'/../models/gltf2/models.md5sum')) { |
| 2764 | - if (($handle = fopen(dirname(__FILE__).'/../models/gltf2/models.md5sum','r')) !== FALSE) { |
|
| 2765 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
| 2764 | + if (($handle = fopen(dirname(__FILE__).'/../models/gltf2/models.md5sum', 'r')) !== FALSE) { |
|
| 2765 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
| 2766 | 2766 | $model = trim($row[2]); |
| 2767 | 2767 | $modelsdb[$model] = trim($row[0]); |
| 2768 | 2768 | } |
| 2769 | 2769 | } |
| 2770 | 2770 | } |
| 2771 | - $diff = array_diff($newmodelsdb,$modelsdb); |
|
| 2771 | + $diff = array_diff($newmodelsdb, $modelsdb); |
|
| 2772 | 2772 | foreach ($diff as $key => $value) { |
| 2773 | 2773 | if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n"; |
| 2774 | - update_db::download('http://data.flightairmap.com/data/models/gltf2/'.$key,dirname(__FILE__).'/../models/gltf2/'.$key); |
|
| 2774 | + update_db::download('http://data.flightairmap.com/data/models/gltf2/'.$key, dirname(__FILE__).'/../models/gltf2/'.$key); |
|
| 2775 | 2775 | |
| 2776 | 2776 | } |
| 2777 | - update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum',dirname(__FILE__).'/../models/gltf2/models.md5sum'); |
|
| 2777 | + update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum', dirname(__FILE__).'/../models/gltf2/models.md5sum'); |
|
| 2778 | 2778 | } else $error = "File ".$tmp_dir.'modelsgltf2.md5sum'." doesn't exist. Download failed."; |
| 2779 | 2779 | if ($error != '') { |
| 2780 | 2780 | return $error; |
@@ -2786,32 +2786,32 @@ discard block |
||
| 2786 | 2786 | global $tmp_dir, $globalDebug; |
| 2787 | 2787 | $error = ''; |
| 2788 | 2788 | if ($globalDebug) echo "Liveries from FlightAirMap website : Download..."; |
| 2789 | - update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum',$tmp_dir.'liveries.md5sum'); |
|
| 2789 | + update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum', $tmp_dir.'liveries.md5sum'); |
|
| 2790 | 2790 | if (file_exists($tmp_dir.'liveries.md5sum')) { |
| 2791 | 2791 | if ($globalDebug) echo "Check files...\n"; |
| 2792 | 2792 | $newmodelsdb = array(); |
| 2793 | - if (($handle = fopen($tmp_dir.'liveries.md5sum','r')) !== FALSE) { |
|
| 2794 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
| 2793 | + if (($handle = fopen($tmp_dir.'liveries.md5sum', 'r')) !== FALSE) { |
|
| 2794 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
| 2795 | 2795 | $model = trim($row[2]); |
| 2796 | 2796 | $newmodelsdb[$model] = trim($row[0]); |
| 2797 | 2797 | } |
| 2798 | 2798 | } |
| 2799 | 2799 | $modelsdb = array(); |
| 2800 | 2800 | if (file_exists(dirname(__FILE__).'/../models/gltf2/liveries/liveries.md5sum')) { |
| 2801 | - if (($handle = fopen(dirname(__FILE__).'/../models/gltf2/liveries/liveries.md5sum','r')) !== FALSE) { |
|
| 2802 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
| 2801 | + if (($handle = fopen(dirname(__FILE__).'/../models/gltf2/liveries/liveries.md5sum', 'r')) !== FALSE) { |
|
| 2802 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
| 2803 | 2803 | $model = trim($row[2]); |
| 2804 | 2804 | $modelsdb[$model] = trim($row[0]); |
| 2805 | 2805 | } |
| 2806 | 2806 | } |
| 2807 | 2807 | } |
| 2808 | - $diff = array_diff($newmodelsdb,$modelsdb); |
|
| 2808 | + $diff = array_diff($newmodelsdb, $modelsdb); |
|
| 2809 | 2809 | foreach ($diff as $key => $value) { |
| 2810 | 2810 | if ($globalDebug) echo 'Downloading liveries '.$key.' ...'."\n"; |
| 2811 | - update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/'.$key,dirname(__FILE__).'/../models/gltf2/liveries/'.$key); |
|
| 2811 | + update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/'.$key, dirname(__FILE__).'/../models/gltf2/liveries/'.$key); |
|
| 2812 | 2812 | |
| 2813 | 2813 | } |
| 2814 | - update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum',dirname(__FILE__).'/../models/gltf2/liveries/liveries.md5sum'); |
|
| 2814 | + update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum', dirname(__FILE__).'/../models/gltf2/liveries/liveries.md5sum'); |
|
| 2815 | 2815 | } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
| 2816 | 2816 | if ($error != '') { |
| 2817 | 2817 | return $error; |
@@ -2823,32 +2823,32 @@ discard block |
||
| 2823 | 2823 | global $tmp_dir, $globalDebug; |
| 2824 | 2824 | $error = ''; |
| 2825 | 2825 | if ($globalDebug) echo "Space models from FlightAirMap website : Download..."; |
| 2826 | - update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum'); |
|
| 2826 | + update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum', $tmp_dir.'space_models.md5sum'); |
|
| 2827 | 2827 | if (file_exists($tmp_dir.'space_models.md5sum')) { |
| 2828 | 2828 | if ($globalDebug) echo "Check files...\n"; |
| 2829 | 2829 | $newmodelsdb = array(); |
| 2830 | - if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) { |
|
| 2831 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
| 2830 | + if (($handle = fopen($tmp_dir.'space_models.md5sum', 'r')) !== FALSE) { |
|
| 2831 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
| 2832 | 2832 | $model = trim($row[2]); |
| 2833 | 2833 | $newmodelsdb[$model] = trim($row[0]); |
| 2834 | 2834 | } |
| 2835 | 2835 | } |
| 2836 | 2836 | $modelsdb = array(); |
| 2837 | 2837 | if (file_exists(dirname(__FILE__).'/../models/space/space_models.md5sum')) { |
| 2838 | - if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum','r')) !== FALSE) { |
|
| 2839 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
| 2838 | + if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum', 'r')) !== FALSE) { |
|
| 2839 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
| 2840 | 2840 | $model = trim($row[2]); |
| 2841 | 2841 | $modelsdb[$model] = trim($row[0]); |
| 2842 | 2842 | } |
| 2843 | 2843 | } |
| 2844 | 2844 | } |
| 2845 | - $diff = array_diff($newmodelsdb,$modelsdb); |
|
| 2845 | + $diff = array_diff($newmodelsdb, $modelsdb); |
|
| 2846 | 2846 | foreach ($diff as $key => $value) { |
| 2847 | 2847 | if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n"; |
| 2848 | - update_db::download('http://data.flightairmap.com/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key); |
|
| 2848 | + update_db::download('http://data.flightairmap.com/data/models/space/'.$key, dirname(__FILE__).'/../models/space/'.$key); |
|
| 2849 | 2849 | |
| 2850 | 2850 | } |
| 2851 | - update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum'); |
|
| 2851 | + update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum', dirname(__FILE__).'/../models/space/space_models.md5sum'); |
|
| 2852 | 2852 | } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
| 2853 | 2853 | if ($error != '') { |
| 2854 | 2854 | return $error; |
@@ -2860,32 +2860,32 @@ discard block |
||
| 2860 | 2860 | global $tmp_dir, $globalDebug; |
| 2861 | 2861 | $error = ''; |
| 2862 | 2862 | if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download..."; |
| 2863 | - update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum'); |
|
| 2863 | + update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum', $tmp_dir.'vehicules_models.md5sum'); |
|
| 2864 | 2864 | if (file_exists($tmp_dir.'vehicules_models.md5sum')) { |
| 2865 | 2865 | if ($globalDebug) echo "Check files...\n"; |
| 2866 | 2866 | $newmodelsdb = array(); |
| 2867 | - if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) { |
|
| 2868 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
| 2867 | + if (($handle = fopen($tmp_dir.'vehicules_models.md5sum', 'r')) !== FALSE) { |
|
| 2868 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
| 2869 | 2869 | $model = trim($row[2]); |
| 2870 | 2870 | $newmodelsdb[$model] = trim($row[0]); |
| 2871 | 2871 | } |
| 2872 | 2872 | } |
| 2873 | 2873 | $modelsdb = array(); |
| 2874 | 2874 | if (file_exists(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum')) { |
| 2875 | - if (($handle = fopen(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum','r')) !== FALSE) { |
|
| 2876 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
| 2875 | + if (($handle = fopen(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum', 'r')) !== FALSE) { |
|
| 2876 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
| 2877 | 2877 | $model = trim($row[2]); |
| 2878 | 2878 | $modelsdb[$model] = trim($row[0]); |
| 2879 | 2879 | } |
| 2880 | 2880 | } |
| 2881 | 2881 | } |
| 2882 | - $diff = array_diff($newmodelsdb,$modelsdb); |
|
| 2882 | + $diff = array_diff($newmodelsdb, $modelsdb); |
|
| 2883 | 2883 | foreach ($diff as $key => $value) { |
| 2884 | 2884 | if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n"; |
| 2885 | - update_db::download('http://data.flightairmap.com/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key); |
|
| 2885 | + update_db::download('http://data.flightairmap.com/data/models/vehicules/'.$key, dirname(__FILE__).'/../models/vehicules/'.$key); |
|
| 2886 | 2886 | |
| 2887 | 2887 | } |
| 2888 | - update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum'); |
|
| 2888 | + update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum', dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum'); |
|
| 2889 | 2889 | } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
| 2890 | 2890 | if ($error != '') { |
| 2891 | 2891 | return $error; |
@@ -2897,8 +2897,8 @@ discard block |
||
| 2897 | 2897 | global $tmp_dir, $globalDebug; |
| 2898 | 2898 | date_default_timezone_set('UTC'); |
| 2899 | 2899 | $Common = new Common(); |
| 2900 | - $data = $Common->getData('https://www4.icao.int/doc8643/External/AircraftTypes','post',array('X-Requested-With: XMLHttpRequest','Accept: application/json, text/javascript, */*; q=0.01','Host: www4.icao.int','Origin: https://www.icao.int','Content-Length: 0'),'','','https://www.icao.int/publications/DOC8643/Pages/Search.aspx',60); |
|
| 2901 | - $all = json_decode($data,true); |
|
| 2900 | + $data = $Common->getData('https://www4.icao.int/doc8643/External/AircraftTypes', 'post', array('X-Requested-With: XMLHttpRequest', 'Accept: application/json, text/javascript, */*; q=0.01', 'Host: www4.icao.int', 'Origin: https://www.icao.int', 'Content-Length: 0'), '', '', 'https://www.icao.int/publications/DOC8643/Pages/Search.aspx', 60); |
|
| 2901 | + $all = json_decode($data, true); |
|
| 2902 | 2902 | $Connection = new Connection(); |
| 2903 | 2903 | $querychk = "SELECT COUNT(1) as nb FROM aircraft WHERE icao = :icao"; |
| 2904 | 2904 | $sth = $Connection->db->prepare($querychk); |
@@ -2910,8 +2910,8 @@ discard block |
||
| 2910 | 2910 | foreach ($all as $model) { |
| 2911 | 2911 | $icao = $model['Designator']; |
| 2912 | 2912 | if (!isset($allicao[$icao])) { |
| 2913 | - $aircraft_shadow = 'generic_'.substr($model['EngineType'],0,1).$model['EngineCount'].$model['WTC'].'.png'; |
|
| 2914 | - $allicao[$icao] = array(':icao' => $icao,':type' => $model['ModelFullName'],':manufacturer' => $model['ManufacturerCode'],':aircraft_shadow' => $aircraft_shadow,':aircraft_description' => $model['AircraftDescription'],':engine_type' => $model['EngineType'],':engine_count' => $model['EngineCount'],':wake_category' => $model['WTC']); |
|
| 2913 | + $aircraft_shadow = 'generic_'.substr($model['EngineType'], 0, 1).$model['EngineCount'].$model['WTC'].'.png'; |
|
| 2914 | + $allicao[$icao] = array(':icao' => $icao, ':type' => $model['ModelFullName'], ':manufacturer' => $model['ManufacturerCode'], ':aircraft_shadow' => $aircraft_shadow, ':aircraft_description' => $model['AircraftDescription'], ':engine_type' => $model['EngineType'], ':engine_count' => $model['EngineCount'], ':wake_category' => $model['WTC']); |
|
| 2915 | 2915 | } else { |
| 2916 | 2916 | $allicao[$icao][':type'] = $allicao[$icao][':type'].'/'.$model['ModelFullName']; |
| 2917 | 2917 | } |
@@ -2923,9 +2923,9 @@ discard block |
||
| 2923 | 2923 | if ($exist[0]['nb'] == 0) { |
| 2924 | 2924 | $sthins->execute($airdata); |
| 2925 | 2925 | } else { |
| 2926 | - $sthup->execute(array(':type' => $airdata[':type'],':icao' => $icao)); |
|
| 2926 | + $sthup->execute(array(':type' => $airdata[':type'], ':icao' => $icao)); |
|
| 2927 | 2927 | } |
| 2928 | - } catch(PDOException $e) { |
|
| 2928 | + } catch (PDOException $e) { |
|
| 2929 | 2929 | return "error : ".$e->getMessage(); |
| 2930 | 2930 | } |
| 2931 | 2931 | } |
@@ -2957,23 +2957,23 @@ discard block |
||
| 2957 | 2957 | $Connection = new Connection(); |
| 2958 | 2958 | $sth = $Connection->db->prepare($query); |
| 2959 | 2959 | $sth->execute(); |
| 2960 | - } catch(PDOException $e) { |
|
| 2960 | + } catch (PDOException $e) { |
|
| 2961 | 2961 | return "error : ".$e->getMessage(); |
| 2962 | 2962 | } |
| 2963 | 2963 | |
| 2964 | 2964 | $error = ''; |
| 2965 | 2965 | if ($globalDebug) echo "Notam : Download..."; |
| 2966 | - update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss'); |
|
| 2966 | + update_db::download($globalNOTAMSource, $tmp_dir.'notam.rss'); |
|
| 2967 | 2967 | if (file_exists($tmp_dir.'notam.rss')) { |
| 2968 | - $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true); |
|
| 2968 | + $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')), true); |
|
| 2969 | 2969 | foreach ($notams['channel']['item'] as $notam) { |
| 2970 | - $title = explode(':',$notam['title']); |
|
| 2970 | + $title = explode(':', $notam['title']); |
|
| 2971 | 2971 | $data['ref'] = trim($title[0]); |
| 2972 | 2972 | unset($title[0]); |
| 2973 | - $data['title'] = trim(implode(':',$title)); |
|
| 2974 | - $description = strip_tags($notam['description'],'<pre>'); |
|
| 2975 | - preg_match(':^(.*?)<pre>:',$description,$match); |
|
| 2976 | - $q = explode('/',$match[1]); |
|
| 2973 | + $data['title'] = trim(implode(':', $title)); |
|
| 2974 | + $description = strip_tags($notam['description'], '<pre>'); |
|
| 2975 | + preg_match(':^(.*?)<pre>:', $description, $match); |
|
| 2976 | + $q = explode('/', $match[1]); |
|
| 2977 | 2977 | $data['fir'] = $q[0]; |
| 2978 | 2978 | $data['code'] = $q[1]; |
| 2979 | 2979 | $ifrvfr = $q[2]; |
@@ -2989,30 +2989,30 @@ discard block |
||
| 2989 | 2989 | $data['lower_limit'] = $q[5]; |
| 2990 | 2990 | $data['upper_limit'] = $q[6]; |
| 2991 | 2991 | $latlonrad = $q[7]; |
| 2992 | - sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius); |
|
| 2993 | - $latitude = $Common->convertDec($las,'latitude'); |
|
| 2994 | - $longitude = $Common->convertDec($lns,'longitude'); |
|
| 2992 | + sscanf($latlonrad, '%4c%c%5c%c%3d', $las, $lac, $lns, $lnc, $radius); |
|
| 2993 | + $latitude = $Common->convertDec($las, 'latitude'); |
|
| 2994 | + $longitude = $Common->convertDec($lns, 'longitude'); |
|
| 2995 | 2995 | if ($lac == 'S') $latitude = '-'.$latitude; |
| 2996 | 2996 | if ($lnc == 'W') $longitude = '-'.$longitude; |
| 2997 | 2997 | $data['center_latitude'] = $latitude; |
| 2998 | 2998 | $data['center_longitude'] = $longitude; |
| 2999 | 2999 | $data['radius'] = intval($radius); |
| 3000 | 3000 | |
| 3001 | - preg_match(':<pre>(.*?)</pre>:',$description,$match); |
|
| 3001 | + preg_match(':<pre>(.*?)</pre>:', $description, $match); |
|
| 3002 | 3002 | $data['text'] = $match[1]; |
| 3003 | - preg_match(':</pre>(.*?)$:',$description,$match); |
|
| 3003 | + preg_match(':</pre>(.*?)$:', $description, $match); |
|
| 3004 | 3004 | $fromto = $match[1]; |
| 3005 | - preg_match('#FROM:(.*?)TO:#',$fromto,$match); |
|
| 3005 | + preg_match('#FROM:(.*?)TO:#', $fromto, $match); |
|
| 3006 | 3006 | $fromall = trim($match[1]); |
| 3007 | - preg_match('#^(.*?) \((.*?)\)$#',$fromall,$match); |
|
| 3007 | + preg_match('#^(.*?) \((.*?)\)$#', $fromall, $match); |
|
| 3008 | 3008 | $from = trim($match[1]); |
| 3009 | - $data['date_begin'] = date("Y-m-d H:i:s",strtotime($from)); |
|
| 3010 | - preg_match('#TO:(.*?)$#',$fromto,$match); |
|
| 3009 | + $data['date_begin'] = date("Y-m-d H:i:s", strtotime($from)); |
|
| 3010 | + preg_match('#TO:(.*?)$#', $fromto, $match); |
|
| 3011 | 3011 | $toall = trim($match[1]); |
| 3012 | - if (!preg_match(':Permanent:',$toall)) { |
|
| 3013 | - preg_match('#^(.*?) \((.*?)\)#',$toall,$match); |
|
| 3012 | + if (!preg_match(':Permanent:', $toall)) { |
|
| 3013 | + preg_match('#^(.*?) \((.*?)\)#', $toall, $match); |
|
| 3014 | 3014 | $to = trim($match[1]); |
| 3015 | - $data['date_end'] = date("Y-m-d H:i:s",strtotime($to)); |
|
| 3015 | + $data['date_end'] = date("Y-m-d H:i:s", strtotime($to)); |
|
| 3016 | 3016 | $data['permanent'] = 0; |
| 3017 | 3017 | } else { |
| 3018 | 3018 | $data['date_end'] = NULL; |
@@ -3020,7 +3020,7 @@ discard block |
||
| 3020 | 3020 | } |
| 3021 | 3021 | $data['full_notam'] = $notam['title'].'<br>'.$notam['description']; |
| 3022 | 3022 | $NOTAM = new NOTAM(); |
| 3023 | - $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']); |
|
| 3023 | + $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 | 3024 | unset($data); |
| 3025 | 3025 | } |
| 3026 | 3026 | } else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
@@ -3043,16 +3043,16 @@ discard block |
||
| 3043 | 3043 | $Connection = new Connection(); |
| 3044 | 3044 | $sth = $Connection->db->prepare($query); |
| 3045 | 3045 | $sth->execute(); |
| 3046 | - } catch(PDOException $e) { |
|
| 3046 | + } catch (PDOException $e) { |
|
| 3047 | 3047 | return "error : ".$e->getMessage(); |
| 3048 | 3048 | } |
| 3049 | 3049 | } |
| 3050 | 3050 | $Common = new Common(); |
| 3051 | 3051 | $airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json'); |
| 3052 | - $airspace_json = json_decode($airspace_lst,true); |
|
| 3052 | + $airspace_json = json_decode($airspace_lst, true); |
|
| 3053 | 3053 | foreach ($airspace_json['records'] as $airspace) { |
| 3054 | 3054 | if ($globalDebug) echo $airspace['name']."...\n"; |
| 3055 | - update_db::download($airspace['uri'],$tmp_dir.$airspace['name']); |
|
| 3055 | + update_db::download($airspace['uri'], $tmp_dir.$airspace['name']); |
|
| 3056 | 3056 | if (file_exists($tmp_dir.$airspace['name'])) { |
| 3057 | 3057 | file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name']))); |
| 3058 | 3058 | //system('recode l9..utf8 '.$tmp_dir.$airspace['name']); |
@@ -3074,7 +3074,7 @@ discard block |
||
| 3074 | 3074 | $Connection = new Connection(); |
| 3075 | 3075 | $sth = $Connection->db->prepare($query); |
| 3076 | 3076 | $sth->execute(array(':new' => $new, ':old' => $old)); |
| 3077 | - } catch(PDOException $e) { |
|
| 3077 | + } catch (PDOException $e) { |
|
| 3078 | 3078 | return "error : ".$e->getMessage(); |
| 3079 | 3079 | } |
| 3080 | 3080 | } |
@@ -3091,7 +3091,7 @@ discard block |
||
| 3091 | 3091 | $Connection = new Connection(); |
| 3092 | 3092 | $sth = $Connection->db->prepare($query); |
| 3093 | 3093 | $sth->execute(); |
| 3094 | - } catch(PDOException $e) { |
|
| 3094 | + } catch (PDOException $e) { |
|
| 3095 | 3095 | return "error : ".$e->getMessage(); |
| 3096 | 3096 | } |
| 3097 | 3097 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -3106,7 +3106,7 @@ discard block |
||
| 3106 | 3106 | $Connection = new Connection(); |
| 3107 | 3107 | $sth = $Connection->db->prepare($query); |
| 3108 | 3108 | $sth->execute(); |
| 3109 | - } catch(PDOException $e) { |
|
| 3109 | + } catch (PDOException $e) { |
|
| 3110 | 3110 | return "error : ".$e->getMessage(); |
| 3111 | 3111 | } |
| 3112 | 3112 | } |
@@ -3117,7 +3117,7 @@ discard block |
||
| 3117 | 3117 | $Connection = new Connection(); |
| 3118 | 3118 | $sth = $Connection->db->prepare($query); |
| 3119 | 3119 | $sth->execute(array(':version' => $version)); |
| 3120 | - } catch(PDOException $e) { |
|
| 3120 | + } catch (PDOException $e) { |
|
| 3121 | 3121 | return "error : ".$e->getMessage(); |
| 3122 | 3122 | } |
| 3123 | 3123 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -3131,7 +3131,7 @@ discard block |
||
| 3131 | 3131 | $Connection = new Connection(); |
| 3132 | 3132 | $sth = $Connection->db->prepare($query); |
| 3133 | 3133 | $sth->execute(array(':version' => $version)); |
| 3134 | - } catch(PDOException $e) { |
|
| 3134 | + } catch (PDOException $e) { |
|
| 3135 | 3135 | return "error : ".$e->getMessage(); |
| 3136 | 3136 | } |
| 3137 | 3137 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -3145,7 +3145,7 @@ discard block |
||
| 3145 | 3145 | $Connection = new Connection(); |
| 3146 | 3146 | $sth = $Connection->db->prepare($query); |
| 3147 | 3147 | $sth->execute(array(':version' => $version)); |
| 3148 | - } catch(PDOException $e) { |
|
| 3148 | + } catch (PDOException $e) { |
|
| 3149 | 3149 | return "error : ".$e->getMessage(); |
| 3150 | 3150 | } |
| 3151 | 3151 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -3159,7 +3159,7 @@ discard block |
||
| 3159 | 3159 | $Connection = new Connection(); |
| 3160 | 3160 | $sth = $Connection->db->prepare($query); |
| 3161 | 3161 | $sth->execute(array(':version' => $version)); |
| 3162 | - } catch(PDOException $e) { |
|
| 3162 | + } catch (PDOException $e) { |
|
| 3163 | 3163 | return "error : ".$e->getMessage(); |
| 3164 | 3164 | } |
| 3165 | 3165 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -3173,7 +3173,7 @@ discard block |
||
| 3173 | 3173 | $Connection = new Connection(); |
| 3174 | 3174 | $sth = $Connection->db->prepare($query); |
| 3175 | 3175 | $sth->execute(array(':version' => $version)); |
| 3176 | - } catch(PDOException $e) { |
|
| 3176 | + } catch (PDOException $e) { |
|
| 3177 | 3177 | return "error : ".$e->getMessage(); |
| 3178 | 3178 | } |
| 3179 | 3179 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -3187,7 +3187,7 @@ discard block |
||
| 3187 | 3187 | $Connection = new Connection(); |
| 3188 | 3188 | $sth = $Connection->db->prepare($query); |
| 3189 | 3189 | $sth->execute(array(':version' => $version)); |
| 3190 | - } catch(PDOException $e) { |
|
| 3190 | + } catch (PDOException $e) { |
|
| 3191 | 3191 | return "error : ".$e->getMessage(); |
| 3192 | 3192 | } |
| 3193 | 3193 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -3202,7 +3202,7 @@ discard block |
||
| 3202 | 3202 | $Connection = new Connection(); |
| 3203 | 3203 | $sth = $Connection->db->prepare($query); |
| 3204 | 3204 | $sth->execute(array(':version' => $version)); |
| 3205 | - } catch(PDOException $e) { |
|
| 3205 | + } catch (PDOException $e) { |
|
| 3206 | 3206 | return "error : ".$e->getMessage(); |
| 3207 | 3207 | } |
| 3208 | 3208 | } |
@@ -3214,7 +3214,7 @@ discard block |
||
| 3214 | 3214 | $Connection = new Connection(); |
| 3215 | 3215 | $sth = $Connection->db->prepare($query); |
| 3216 | 3216 | $sth->execute(array(':version' => $version)); |
| 3217 | - } catch(PDOException $e) { |
|
| 3217 | + } catch (PDOException $e) { |
|
| 3218 | 3218 | return "error : ".$e->getMessage(); |
| 3219 | 3219 | } |
| 3220 | 3220 | } |
@@ -3226,7 +3226,7 @@ discard block |
||
| 3226 | 3226 | $Connection = new Connection(); |
| 3227 | 3227 | $sth = $Connection->db->prepare($query); |
| 3228 | 3228 | $sth->execute(array(':version' => $version)); |
| 3229 | - } catch(PDOException $e) { |
|
| 3229 | + } catch (PDOException $e) { |
|
| 3230 | 3230 | return "error : ".$e->getMessage(); |
| 3231 | 3231 | } |
| 3232 | 3232 | } |
@@ -3238,7 +3238,7 @@ discard block |
||
| 3238 | 3238 | $Connection = new Connection(); |
| 3239 | 3239 | $sth = $Connection->db->prepare($query); |
| 3240 | 3240 | $sth->execute(array(':version' => $version)); |
| 3241 | - } catch(PDOException $e) { |
|
| 3241 | + } catch (PDOException $e) { |
|
| 3242 | 3242 | return "error : ".$e->getMessage(); |
| 3243 | 3243 | } |
| 3244 | 3244 | } |
@@ -3250,7 +3250,7 @@ discard block |
||
| 3250 | 3250 | $Connection = new Connection(); |
| 3251 | 3251 | $sth = $Connection->db->prepare($query); |
| 3252 | 3252 | $sth->execute(array(':version' => $version)); |
| 3253 | - } catch(PDOException $e) { |
|
| 3253 | + } catch (PDOException $e) { |
|
| 3254 | 3254 | return "error : ".$e->getMessage(); |
| 3255 | 3255 | } |
| 3256 | 3256 | } |
@@ -3262,7 +3262,7 @@ discard block |
||
| 3262 | 3262 | $Connection = new Connection(); |
| 3263 | 3263 | $sth = $Connection->db->prepare($query); |
| 3264 | 3264 | $sth->execute(array(':version' => $version)); |
| 3265 | - } catch(PDOException $e) { |
|
| 3265 | + } catch (PDOException $e) { |
|
| 3266 | 3266 | return "error : ".$e->getMessage(); |
| 3267 | 3267 | } |
| 3268 | 3268 | } |
@@ -3278,7 +3278,7 @@ discard block |
||
| 3278 | 3278 | $Connection = new Connection(); |
| 3279 | 3279 | $sth = $Connection->db->prepare($query); |
| 3280 | 3280 | $sth->execute(); |
| 3281 | - } catch(PDOException $e) { |
|
| 3281 | + } catch (PDOException $e) { |
|
| 3282 | 3282 | return "error : ".$e->getMessage(); |
| 3283 | 3283 | } |
| 3284 | 3284 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -3293,7 +3293,7 @@ discard block |
||
| 3293 | 3293 | $Connection = new Connection(); |
| 3294 | 3294 | $sth = $Connection->db->prepare($query); |
| 3295 | 3295 | $sth->execute(); |
| 3296 | - } catch(PDOException $e) { |
|
| 3296 | + } catch (PDOException $e) { |
|
| 3297 | 3297 | return "error : ".$e->getMessage(); |
| 3298 | 3298 | } |
| 3299 | 3299 | } |
@@ -3309,7 +3309,7 @@ discard block |
||
| 3309 | 3309 | $Connection = new Connection(); |
| 3310 | 3310 | $sth = $Connection->db->prepare($query); |
| 3311 | 3311 | $sth->execute(); |
| 3312 | - } catch(PDOException $e) { |
|
| 3312 | + } catch (PDOException $e) { |
|
| 3313 | 3313 | return "error : ".$e->getMessage(); |
| 3314 | 3314 | } |
| 3315 | 3315 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -3324,7 +3324,7 @@ discard block |
||
| 3324 | 3324 | $Connection = new Connection(); |
| 3325 | 3325 | $sth = $Connection->db->prepare($query); |
| 3326 | 3326 | $sth->execute(); |
| 3327 | - } catch(PDOException $e) { |
|
| 3327 | + } catch (PDOException $e) { |
|
| 3328 | 3328 | return "error : ".$e->getMessage(); |
| 3329 | 3329 | } |
| 3330 | 3330 | } |
@@ -3340,7 +3340,7 @@ discard block |
||
| 3340 | 3340 | $Connection = new Connection(); |
| 3341 | 3341 | $sth = $Connection->db->prepare($query); |
| 3342 | 3342 | $sth->execute(); |
| 3343 | - } catch(PDOException $e) { |
|
| 3343 | + } catch (PDOException $e) { |
|
| 3344 | 3344 | return "error : ".$e->getMessage(); |
| 3345 | 3345 | } |
| 3346 | 3346 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -3355,7 +3355,7 @@ discard block |
||
| 3355 | 3355 | $Connection = new Connection(); |
| 3356 | 3356 | $sth = $Connection->db->prepare($query); |
| 3357 | 3357 | $sth->execute(); |
| 3358 | - } catch(PDOException $e) { |
|
| 3358 | + } catch (PDOException $e) { |
|
| 3359 | 3359 | return "error : ".$e->getMessage(); |
| 3360 | 3360 | } |
| 3361 | 3361 | } |
@@ -3371,7 +3371,7 @@ discard block |
||
| 3371 | 3371 | $Connection = new Connection(); |
| 3372 | 3372 | $sth = $Connection->db->prepare($query); |
| 3373 | 3373 | $sth->execute(); |
| 3374 | - } catch(PDOException $e) { |
|
| 3374 | + } catch (PDOException $e) { |
|
| 3375 | 3375 | return "error : ".$e->getMessage(); |
| 3376 | 3376 | } |
| 3377 | 3377 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -3386,7 +3386,7 @@ discard block |
||
| 3386 | 3386 | $Connection = new Connection(); |
| 3387 | 3387 | $sth = $Connection->db->prepare($query); |
| 3388 | 3388 | $sth->execute(); |
| 3389 | - } catch(PDOException $e) { |
|
| 3389 | + } catch (PDOException $e) { |
|
| 3390 | 3390 | return "error : ".$e->getMessage(); |
| 3391 | 3391 | } |
| 3392 | 3392 | } |
@@ -3402,7 +3402,7 @@ discard block |
||
| 3402 | 3402 | $Connection = new Connection(); |
| 3403 | 3403 | $sth = $Connection->db->prepare($query); |
| 3404 | 3404 | $sth->execute(); |
| 3405 | - } catch(PDOException $e) { |
|
| 3405 | + } catch (PDOException $e) { |
|
| 3406 | 3406 | return "error : ".$e->getMessage(); |
| 3407 | 3407 | } |
| 3408 | 3408 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -3417,7 +3417,7 @@ discard block |
||
| 3417 | 3417 | $Connection = new Connection(); |
| 3418 | 3418 | $sth = $Connection->db->prepare($query); |
| 3419 | 3419 | $sth->execute(); |
| 3420 | - } catch(PDOException $e) { |
|
| 3420 | + } catch (PDOException $e) { |
|
| 3421 | 3421 | return "error : ".$e->getMessage(); |
| 3422 | 3422 | } |
| 3423 | 3423 | } |
@@ -3433,7 +3433,7 @@ discard block |
||
| 3433 | 3433 | $Connection = new Connection(); |
| 3434 | 3434 | $sth = $Connection->db->prepare($query); |
| 3435 | 3435 | $sth->execute(); |
| 3436 | - } catch(PDOException $e) { |
|
| 3436 | + } catch (PDOException $e) { |
|
| 3437 | 3437 | return "error : ".$e->getMessage(); |
| 3438 | 3438 | } |
| 3439 | 3439 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -3448,7 +3448,7 @@ discard block |
||
| 3448 | 3448 | $Connection = new Connection(); |
| 3449 | 3449 | $sth = $Connection->db->prepare($query); |
| 3450 | 3450 | $sth->execute(); |
| 3451 | - } catch(PDOException $e) { |
|
| 3451 | + } catch (PDOException $e) { |
|
| 3452 | 3452 | return "error : ".$e->getMessage(); |
| 3453 | 3453 | } |
| 3454 | 3454 | } |
@@ -3464,7 +3464,7 @@ discard block |
||
| 3464 | 3464 | $Connection = new Connection(); |
| 3465 | 3465 | $sth = $Connection->db->prepare($query); |
| 3466 | 3466 | $sth->execute(); |
| 3467 | - } catch(PDOException $e) { |
|
| 3467 | + } catch (PDOException $e) { |
|
| 3468 | 3468 | return "error : ".$e->getMessage(); |
| 3469 | 3469 | } |
| 3470 | 3470 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -3479,7 +3479,7 @@ discard block |
||
| 3479 | 3479 | $Connection = new Connection(); |
| 3480 | 3480 | $sth = $Connection->db->prepare($query); |
| 3481 | 3481 | $sth->execute(); |
| 3482 | - } catch(PDOException $e) { |
|
| 3482 | + } catch (PDOException $e) { |
|
| 3483 | 3483 | return "error : ".$e->getMessage(); |
| 3484 | 3484 | } |
| 3485 | 3485 | } |
@@ -3495,7 +3495,7 @@ discard block |
||
| 3495 | 3495 | $Connection = new Connection(); |
| 3496 | 3496 | $sth = $Connection->db->prepare($query); |
| 3497 | 3497 | $sth->execute(); |
| 3498 | - } catch(PDOException $e) { |
|
| 3498 | + } catch (PDOException $e) { |
|
| 3499 | 3499 | return "error : ".$e->getMessage(); |
| 3500 | 3500 | } |
| 3501 | 3501 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -3510,7 +3510,7 @@ discard block |
||
| 3510 | 3510 | $Connection = new Connection(); |
| 3511 | 3511 | $sth = $Connection->db->prepare($query); |
| 3512 | 3512 | $sth->execute(); |
| 3513 | - } catch(PDOException $e) { |
|
| 3513 | + } catch (PDOException $e) { |
|
| 3514 | 3514 | return "error : ".$e->getMessage(); |
| 3515 | 3515 | } |
| 3516 | 3516 | } |
@@ -3526,7 +3526,7 @@ discard block |
||
| 3526 | 3526 | $Connection = new Connection(); |
| 3527 | 3527 | $sth = $Connection->db->prepare($query); |
| 3528 | 3528 | $sth->execute(); |
| 3529 | - } catch(PDOException $e) { |
|
| 3529 | + } catch (PDOException $e) { |
|
| 3530 | 3530 | return "error : ".$e->getMessage(); |
| 3531 | 3531 | } |
| 3532 | 3532 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -3541,7 +3541,7 @@ discard block |
||
| 3541 | 3541 | $Connection = new Connection(); |
| 3542 | 3542 | $sth = $Connection->db->prepare($query); |
| 3543 | 3543 | $sth->execute(); |
| 3544 | - } catch(PDOException $e) { |
|
| 3544 | + } catch (PDOException $e) { |
|
| 3545 | 3545 | return "error : ".$e->getMessage(); |
| 3546 | 3546 | } |
| 3547 | 3547 | } |
@@ -3557,7 +3557,7 @@ discard block |
||
| 3557 | 3557 | $Connection = new Connection(); |
| 3558 | 3558 | $sth = $Connection->db->prepare($query); |
| 3559 | 3559 | $sth->execute(); |
| 3560 | - } catch(PDOException $e) { |
|
| 3560 | + } catch (PDOException $e) { |
|
| 3561 | 3561 | return "error : ".$e->getMessage(); |
| 3562 | 3562 | } |
| 3563 | 3563 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -3572,7 +3572,7 @@ discard block |
||
| 3572 | 3572 | $Connection = new Connection(); |
| 3573 | 3573 | $sth = $Connection->db->prepare($query); |
| 3574 | 3574 | $sth->execute(); |
| 3575 | - } catch(PDOException $e) { |
|
| 3575 | + } catch (PDOException $e) { |
|
| 3576 | 3576 | return "error : ".$e->getMessage(); |
| 3577 | 3577 | } |
| 3578 | 3578 | } |
@@ -3588,7 +3588,7 @@ discard block |
||
| 3588 | 3588 | $Connection = new Connection(); |
| 3589 | 3589 | $sth = $Connection->db->prepare($query); |
| 3590 | 3590 | $sth->execute(); |
| 3591 | - } catch(PDOException $e) { |
|
| 3591 | + } catch (PDOException $e) { |
|
| 3592 | 3592 | return "error : ".$e->getMessage(); |
| 3593 | 3593 | } |
| 3594 | 3594 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -3607,7 +3607,7 @@ discard block |
||
| 3607 | 3607 | $Connection = new Connection(); |
| 3608 | 3608 | $sth = $Connection->db->prepare($query); |
| 3609 | 3609 | $sth->execute(); |
| 3610 | - } catch(PDOException $e) { |
|
| 3610 | + } catch (PDOException $e) { |
|
| 3611 | 3611 | return "error : ".$e->getMessage(); |
| 3612 | 3612 | } |
| 3613 | 3613 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -3622,7 +3622,7 @@ discard block |
||
| 3622 | 3622 | $Connection = new Connection(); |
| 3623 | 3623 | $sth = $Connection->db->prepare($query); |
| 3624 | 3624 | $sth->execute(); |
| 3625 | - } catch(PDOException $e) { |
|
| 3625 | + } catch (PDOException $e) { |
|
| 3626 | 3626 | return "error : ".$e->getMessage(); |
| 3627 | 3627 | } |
| 3628 | 3628 | } |
@@ -3634,7 +3634,7 @@ discard block |
||
| 3634 | 3634 | $Connection = new Connection(); |
| 3635 | 3635 | $sth = $Connection->db->prepare($query); |
| 3636 | 3636 | $sth->execute(); |
| 3637 | - } catch(PDOException $e) { |
|
| 3637 | + } catch (PDOException $e) { |
|
| 3638 | 3638 | return "error : ".$e->getMessage(); |
| 3639 | 3639 | } |
| 3640 | 3640 | } |
@@ -3650,7 +3650,7 @@ discard block |
||
| 3650 | 3650 | $Connection = new Connection(); |
| 3651 | 3651 | $sth = $Connection->db->prepare($query); |
| 3652 | 3652 | $sth->execute(); |
| 3653 | - } catch(PDOException $e) { |
|
| 3653 | + } catch (PDOException $e) { |
|
| 3654 | 3654 | return "error : ".$e->getMessage(); |
| 3655 | 3655 | } |
| 3656 | 3656 | } |
@@ -3665,7 +3665,7 @@ discard block |
||
| 3665 | 3665 | $Connection = new Connection(); |
| 3666 | 3666 | $sth = $Connection->db->prepare($query); |
| 3667 | 3667 | $sth->execute(); |
| 3668 | - } catch(PDOException $e) { |
|
| 3668 | + } catch (PDOException $e) { |
|
| 3669 | 3669 | return "error : ".$e->getMessage(); |
| 3670 | 3670 | } |
| 3671 | 3671 | } |
@@ -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() { |