@@ -1098,6 +1098,10 @@ discard block |
||
| 1098 | 1098 | else return array(); |
| 1099 | 1099 | } |
| 1100 | 1100 | |
| 1101 | + /** |
|
| 1102 | + * @param string $type |
|
| 1103 | + * @param string $rules |
|
| 1104 | + */ |
|
| 1101 | 1105 | 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) { |
| 1102 | 1106 | $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)"; |
| 1103 | 1107 | $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); |
@@ -1179,6 +1183,10 @@ discard block |
||
| 1179 | 1183 | } |
| 1180 | 1184 | } |
| 1181 | 1185 | } |
| 1186 | + |
|
| 1187 | + /** |
|
| 1188 | + * @param string $filename |
|
| 1189 | + */ |
|
| 1182 | 1190 | public function updateNOTAMfromTextFile($filename) { |
| 1183 | 1191 | $alldata = $this->parseNOTAMtextFile($filename); |
| 1184 | 1192 | if (count($alldata) > 0) { |
@@ -1223,6 +1231,9 @@ discard block |
||
| 1223 | 1231 | } |
| 1224 | 1232 | } |
| 1225 | 1233 | |
| 1234 | + /** |
|
| 1235 | + * @param string $icao |
|
| 1236 | + */ |
|
| 1226 | 1237 | public function downloadNOTAM($icao) { |
| 1227 | 1238 | date_default_timezone_set("UTC"); |
| 1228 | 1239 | $Common = new Common(); |
@@ -1359,6 +1370,9 @@ discard block |
||
| 1359 | 1370 | return $result; |
| 1360 | 1371 | } |
| 1361 | 1372 | |
| 1373 | + /** |
|
| 1374 | + * @param string $code |
|
| 1375 | + */ |
|
| 1362 | 1376 | public function parse_code($code) { |
| 1363 | 1377 | $code = str_split($code); |
| 1364 | 1378 | $code_fp = $code[1].$code[2]; |
@@ -982,19 +982,19 @@ discard block |
||
| 982 | 982 | try { |
| 983 | 983 | $sth = $this->db->prepare($query); |
| 984 | 984 | $sth->execute($query_values); |
| 985 | - } catch(PDOException $e) { |
|
| 985 | + } catch (PDOException $e) { |
|
| 986 | 986 | echo "error : ".$e->getMessage(); |
| 987 | 987 | } |
| 988 | 988 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 989 | 989 | return $all; |
| 990 | 990 | } |
| 991 | 991 | public function getAllNOTAMtext() { |
| 992 | - $query = 'SELECT full_notam FROM notam'; |
|
| 992 | + $query = 'SELECT full_notam FROM notam'; |
|
| 993 | 993 | $query_values = array(); |
| 994 | 994 | try { |
| 995 | 995 | $sth = $this->db->prepare($query); |
| 996 | 996 | $sth->execute($query_values); |
| 997 | - } catch(PDOException $e) { |
|
| 997 | + } catch (PDOException $e) { |
|
| 998 | 998 | echo "error : ".$e->getMessage(); |
| 999 | 999 | } |
| 1000 | 1000 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1003,13 +1003,13 @@ discard block |
||
| 1003 | 1003 | public function createNOTAMtextFile($filename) { |
| 1004 | 1004 | $allnotam_result = $this->getAllNOTAMtext(); |
| 1005 | 1005 | $notamtext = ''; |
| 1006 | - foreach($allnotam_result as $notam) { |
|
| 1006 | + foreach ($allnotam_result as $notam) { |
|
| 1007 | 1007 | $notamtext .= '%%'."\n"; |
| 1008 | 1008 | $notamtext .= $notam['full_notam']; |
| 1009 | 1009 | $notamtext .= "\n".'%%'."\n"; |
| 1010 | 1010 | } |
| 1011 | 1011 | //$allnotam = implode('\n%%%%\n',$allnotam_result); |
| 1012 | - file_put_contents($filename,$notamtext); |
|
| 1012 | + file_put_contents($filename, $notamtext); |
|
| 1013 | 1013 | } |
| 1014 | 1014 | public function parseNOTAMtextFile($filename) { |
| 1015 | 1015 | $data = file_get_contents($filename); |
@@ -1030,7 +1030,7 @@ discard block |
||
| 1030 | 1030 | try { |
| 1031 | 1031 | $sth = $this->db->prepare($query); |
| 1032 | 1032 | $sth->execute($query_values); |
| 1033 | - } catch(PDOException $e) { |
|
| 1033 | + } catch (PDOException $e) { |
|
| 1034 | 1034 | echo "error : ".$e->getMessage(); |
| 1035 | 1035 | } |
| 1036 | 1036 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1039,10 +1039,10 @@ discard block |
||
| 1039 | 1039 | public function getAllNOTAMbyCoord($coord) { |
| 1040 | 1040 | global $globalDBdriver; |
| 1041 | 1041 | if (is_array($coord)) { |
| 1042 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1043 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1044 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1045 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1042 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1043 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1044 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1045 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1046 | 1046 | } else return array(); |
| 1047 | 1047 | if ($globalDBdriver == 'mysql') { |
| 1048 | 1048 | $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()'; |
@@ -1054,19 +1054,19 @@ discard block |
||
| 1054 | 1054 | try { |
| 1055 | 1055 | $sth = $this->db->prepare($query); |
| 1056 | 1056 | $sth->execute($query_values); |
| 1057 | - } catch(PDOException $e) { |
|
| 1057 | + } catch (PDOException $e) { |
|
| 1058 | 1058 | echo "error : ".$e->getMessage(); |
| 1059 | 1059 | } |
| 1060 | 1060 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1061 | 1061 | return $all; |
| 1062 | 1062 | } |
| 1063 | - public function getAllNOTAMbyCoordScope($coord,$scope) { |
|
| 1063 | + public function getAllNOTAMbyCoordScope($coord, $scope) { |
|
| 1064 | 1064 | global $globalDBdriver; |
| 1065 | 1065 | if (is_array($coord)) { |
| 1066 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1067 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1068 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1069 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1066 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1067 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1068 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1069 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1070 | 1070 | } else return array(); |
| 1071 | 1071 | if ($globalDBdriver == 'mysql') { |
| 1072 | 1072 | $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'; |
@@ -1078,7 +1078,7 @@ discard block |
||
| 1078 | 1078 | try { |
| 1079 | 1079 | $sth = $this->db->prepare($query); |
| 1080 | 1080 | $sth->execute($query_values); |
| 1081 | - } catch(PDOException $e) { |
|
| 1081 | + } catch (PDOException $e) { |
|
| 1082 | 1082 | echo "error : ".$e->getMessage(); |
| 1083 | 1083 | } |
| 1084 | 1084 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1090,7 +1090,7 @@ discard block |
||
| 1090 | 1090 | try { |
| 1091 | 1091 | $sth = $this->db->prepare($query); |
| 1092 | 1092 | $sth->execute($query_values); |
| 1093 | - } catch(PDOException $e) { |
|
| 1093 | + } catch (PDOException $e) { |
|
| 1094 | 1094 | return "error : ".$e->getMessage(); |
| 1095 | 1095 | } |
| 1096 | 1096 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1098,13 +1098,13 @@ discard block |
||
| 1098 | 1098 | else return array(); |
| 1099 | 1099 | } |
| 1100 | 1100 | |
| 1101 | - 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) { |
|
| 1101 | + 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) { |
|
| 1102 | 1102 | $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)"; |
| 1103 | - $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); |
|
| 1103 | + $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); |
|
| 1104 | 1104 | try { |
| 1105 | 1105 | $sth = $this->db->prepare($query); |
| 1106 | 1106 | $sth->execute($query_values); |
| 1107 | - } catch(PDOException $e) { |
|
| 1107 | + } catch (PDOException $e) { |
|
| 1108 | 1108 | return "error : ".$e->getMessage(); |
| 1109 | 1109 | } |
| 1110 | 1110 | } |
@@ -1115,7 +1115,7 @@ discard block |
||
| 1115 | 1115 | try { |
| 1116 | 1116 | $sth = $this->db->prepare($query); |
| 1117 | 1117 | $sth->execute($query_values); |
| 1118 | - } catch(PDOException $e) { |
|
| 1118 | + } catch (PDOException $e) { |
|
| 1119 | 1119 | return "error : ".$e->getMessage(); |
| 1120 | 1120 | } |
| 1121 | 1121 | } |
@@ -1130,7 +1130,7 @@ discard block |
||
| 1130 | 1130 | try { |
| 1131 | 1131 | $sth = $this->db->prepare($query); |
| 1132 | 1132 | $sth->execute($query_values); |
| 1133 | - } catch(PDOException $e) { |
|
| 1133 | + } catch (PDOException $e) { |
|
| 1134 | 1134 | return "error : ".$e->getMessage(); |
| 1135 | 1135 | } |
| 1136 | 1136 | } |
@@ -1140,7 +1140,7 @@ discard block |
||
| 1140 | 1140 | try { |
| 1141 | 1141 | $sth = $this->db->prepare($query); |
| 1142 | 1142 | $sth->execute($query_values); |
| 1143 | - } catch(PDOException $e) { |
|
| 1143 | + } catch (PDOException $e) { |
|
| 1144 | 1144 | return "error : ".$e->getMessage(); |
| 1145 | 1145 | } |
| 1146 | 1146 | } |
@@ -1149,7 +1149,7 @@ discard block |
||
| 1149 | 1149 | try { |
| 1150 | 1150 | $sth = $this->db->prepare($query); |
| 1151 | 1151 | $sth->execute(); |
| 1152 | - } catch(PDOException $e) { |
|
| 1152 | + } catch (PDOException $e) { |
|
| 1153 | 1153 | return "error : ".$e->getMessage(); |
| 1154 | 1154 | } |
| 1155 | 1155 | } |
@@ -1158,7 +1158,7 @@ discard block |
||
| 1158 | 1158 | try { |
| 1159 | 1159 | $sth = $this->db->prepare($query); |
| 1160 | 1160 | $sth->execute(); |
| 1161 | - } catch(PDOException $e) { |
|
| 1161 | + } catch (PDOException $e) { |
|
| 1162 | 1162 | return "error : ".$e->getMessage(); |
| 1163 | 1163 | } |
| 1164 | 1164 | } |
@@ -1166,14 +1166,14 @@ discard block |
||
| 1166 | 1166 | public function updateNOTAM() { |
| 1167 | 1167 | global $globalNOTAMAirports; |
| 1168 | 1168 | if (isset($globalNOTAMAirports) && is_array($globalNOTAMAirports) && count($globalNOTAMAirports) > 0) { |
| 1169 | - foreach (array_chunk($globalNOTAMAirports,10) as $airport) { |
|
| 1170 | - $airport_icao = implode(',',$airport); |
|
| 1169 | + foreach (array_chunk($globalNOTAMAirports, 10) as $airport) { |
|
| 1170 | + $airport_icao = implode(',', $airport); |
|
| 1171 | 1171 | $alldata = $this->downloadNOTAM($airport_icao); |
| 1172 | 1172 | if (count($alldata) > 0) { |
| 1173 | 1173 | foreach ($alldata as $initial_data) { |
| 1174 | 1174 | $data = $this->parse($initial_data); |
| 1175 | 1175 | $notamref = $this->getNOTAMbyRef($data['ref']); |
| 1176 | - if (count($notamref) == 0) $this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
| 1176 | + if (count($notamref) == 0) $this->addNOTAM($data['ref'], $data['title'], '', $data['fir'], $data['code'], '', $data['scope'], $data['lower_limit'], $data['upper_limit'], $data['latitude'], $data['longitude'], $data['radius'], $data['date_begin'], $data['date_end'], $data['permanent'], $data['text'], $data['full_notam']); |
|
| 1177 | 1177 | } |
| 1178 | 1178 | } |
| 1179 | 1179 | } |
@@ -1186,7 +1186,7 @@ discard block |
||
| 1186 | 1186 | foreach ($alldata as $initial_data) { |
| 1187 | 1187 | $data = $this->parse($initial_data); |
| 1188 | 1188 | $notamref = $this->getNOTAMbyRef($data['ref']); |
| 1189 | - 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']); |
|
| 1189 | + 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']); |
|
| 1190 | 1190 | } |
| 1191 | 1191 | } |
| 1192 | 1192 | } |
@@ -1195,12 +1195,12 @@ discard block |
||
| 1195 | 1195 | global $globalTransaction; |
| 1196 | 1196 | $Spotter = new Spotter(); |
| 1197 | 1197 | $allairports = $Spotter->getAllAirportInfo(); |
| 1198 | - foreach (array_chunk($allairports,20) as $airport) { |
|
| 1198 | + foreach (array_chunk($allairports, 20) as $airport) { |
|
| 1199 | 1199 | $airports_icao = array(); |
| 1200 | - foreach($airport as $icao) { |
|
| 1200 | + foreach ($airport as $icao) { |
|
| 1201 | 1201 | if (isset($icao['icao'])) $airports_icao[] = $icao['icao']; |
| 1202 | 1202 | } |
| 1203 | - $airport_icao = implode(',',$airports_icao); |
|
| 1203 | + $airport_icao = implode(',', $airports_icao); |
|
| 1204 | 1204 | $alldata = $this->downloadNOTAM($airport_icao); |
| 1205 | 1205 | if ($globalTransaction) $this->db->beginTransaction(); |
| 1206 | 1206 | if (count($alldata) > 0) { |
@@ -1213,7 +1213,7 @@ discard block |
||
| 1213 | 1213 | if (count($notamref) == 0) { |
| 1214 | 1214 | if (isset($data['ref_replaced'])) $this->deleteNOTAMbyRef($data['ref_replaced']); |
| 1215 | 1215 | if (isset($data['ref_cancelled'])) $this->deleteNOTAMbyRef($data['ref_cancelled']); |
| 1216 | - elseif (isset($data['latitude']) && isset($data['scope']) && isset($data['text']) && isset($data['permanent'])) echo $this->addNOTAM($data['ref'],'','',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
| 1216 | + elseif (isset($data['latitude']) && isset($data['scope']) && isset($data['text']) && isset($data['permanent'])) echo $this->addNOTAM($data['ref'], '', '', $data['fir'], $data['code'], '', $data['scope'], $data['lower_limit'], $data['upper_limit'], $data['latitude'], $data['longitude'], $data['radius'], $data['date_begin'], $data['date_end'], $data['permanent'], $data['text'], $data['full_notam']); |
|
| 1217 | 1217 | } |
| 1218 | 1218 | } |
| 1219 | 1219 | } |
@@ -1227,7 +1227,7 @@ discard block |
||
| 1227 | 1227 | date_default_timezone_set("UTC"); |
| 1228 | 1228 | $Common = new Common(); |
| 1229 | 1229 | //$url = str_replace('{icao}',$icao,'https://pilotweb.nas.faa.gov/PilotWeb/notamRetrievalByICAOAction.do?method=displayByICAOs&reportType=RAW&formatType=DOMESTIC&retrieveLocId={icao}&actionType=notamRetrievalByICAOs'); |
| 1230 | - $url = str_replace('{icao}',$icao,'https://pilotweb.nas.faa.gov/PilotWeb/notamRetrievalByICAOAction.do?method=displayByICAOs&reportType=RAW&formatType=ICAO&retrieveLocId={icao}&actionType=notamRetrievalByICAOs'); |
|
| 1230 | + $url = str_replace('{icao}', $icao, 'https://pilotweb.nas.faa.gov/PilotWeb/notamRetrievalByICAOAction.do?method=displayByICAOs&reportType=RAW&formatType=ICAO&retrieveLocId={icao}&actionType=notamRetrievalByICAOs'); |
|
| 1231 | 1231 | $data = $Common->getData($url); |
| 1232 | 1232 | preg_match_all("/<pre>(.+?)<\/pre>/is", $data, $matches); |
| 1233 | 1233 | //print_r($matches); |
@@ -1239,14 +1239,14 @@ discard block |
||
| 1239 | 1239 | $Common = new Common(); |
| 1240 | 1240 | $result = array(); |
| 1241 | 1241 | $result['full_notam'] = $data; |
| 1242 | - $data = str_ireplace(array("\r","\n",'\r','\n'),' ',$data); |
|
| 1243 | - $data = preg_split('#(?=([A-Z]\)\s))#',$data); |
|
| 1242 | + $data = str_ireplace(array("\r", "\n", '\r', '\n'), ' ', $data); |
|
| 1243 | + $data = preg_split('#(?=([A-Z]\)\s))#', $data); |
|
| 1244 | 1244 | //print_r($data); |
| 1245 | 1245 | foreach ($data as $line) { |
| 1246 | 1246 | $line = trim($line); |
| 1247 | - if (preg_match('#Q\) (.*)#',$line,$matches)) { |
|
| 1248 | - $line = str_replace(' ','',$line); |
|
| 1249 | - 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)) { |
|
| 1247 | + if (preg_match('#Q\) (.*)#', $line, $matches)) { |
|
| 1248 | + $line = str_replace(' ', '', $line); |
|
| 1249 | + 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)) { |
|
| 1250 | 1250 | //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)) { |
| 1251 | 1251 | //print_r($matches); |
| 1252 | 1252 | $result['fir'] = $matches[1]; |
@@ -1292,30 +1292,30 @@ discard block |
||
| 1292 | 1292 | elseif ($matches[5] == 'AW') $result['scope'] = 'Airport/Navigation warning'; |
| 1293 | 1293 | $result['lower_limit'] = $matches[6]; |
| 1294 | 1294 | $result['upper_limit'] = $matches[7]; |
| 1295 | - $latitude = $Common->convertDec($matches[8],'latitude'); |
|
| 1295 | + $latitude = $Common->convertDec($matches[8], 'latitude'); |
|
| 1296 | 1296 | if ($matches[9] == 'S') $latitude = -$latitude; |
| 1297 | - $longitude = $Common->convertDec($matches[10],'longitude'); |
|
| 1297 | + $longitude = $Common->convertDec($matches[10], 'longitude'); |
|
| 1298 | 1298 | if ($matches[11] == 'W') $longitude = -$longitude; |
| 1299 | 1299 | $result['latitude'] = $latitude; |
| 1300 | 1300 | $result['longitude'] = $longitude; |
| 1301 | 1301 | $result['radius'] = intval($matches[12]); |
| 1302 | 1302 | } else echo 'ERROR : '.$line."\n"; |
| 1303 | 1303 | } |
| 1304 | - elseif (preg_match('#A\) (.*)#',$line,$matches)) { |
|
| 1304 | + elseif (preg_match('#A\) (.*)#', $line, $matches)) { |
|
| 1305 | 1305 | $result['icao'] = $matches[1]; |
| 1306 | 1306 | } |
| 1307 | - elseif (preg_match('#B\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})#',$line,$matches)) { |
|
| 1307 | + elseif (preg_match('#B\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})#', $line, $matches)) { |
|
| 1308 | 1308 | if ($matches[1] > 50) $year = '19'.$matches[1]; |
| 1309 | 1309 | else $year = '20'.$matches[1]; |
| 1310 | 1310 | $result['date_begin'] = $year.'/'.$matches[2].'/'.$matches[3].' '.$matches[4].':'.$matches[5]; |
| 1311 | 1311 | } |
| 1312 | - elseif (preg_match('#C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#',$line,$matches)) { |
|
| 1312 | + elseif (preg_match('#C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#', $line, $matches)) { |
|
| 1313 | 1313 | if ($matches[1] > 50) $year = '19'.$matches[1]; |
| 1314 | 1314 | else $year = '20'.$matches[1]; |
| 1315 | 1315 | $result['date_end'] = $year.'/'.$matches[2].'/'.$matches[3].' '.$matches[4].':'.$matches[5]; |
| 1316 | 1316 | $result['permanent'] = 0; |
| 1317 | 1317 | } |
| 1318 | - elseif (preg_match('#C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2}) (EST|PERM)$#',$line,$matches)) { |
|
| 1318 | + elseif (preg_match('#C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2}) (EST|PERM)$#', $line, $matches)) { |
|
| 1319 | 1319 | if ($matches[1] > 50) $year = '19'.$matches[1]; |
| 1320 | 1320 | else $year = '20'.$matches[1]; |
| 1321 | 1321 | $result['date_end'] = $year.'/'.$matches[2].'/'.$matches[3].' '.$matches[4].':'.$matches[5]; |
@@ -1324,26 +1324,26 @@ discard block |
||
| 1324 | 1324 | if ($matches[6] == 'PERM') $result['permanent'] = 1; |
| 1325 | 1325 | else $result['permanent'] = 0; |
| 1326 | 1326 | } |
| 1327 | - elseif (preg_match('#C\) (EST|PERM)$#',$line,$matches)) { |
|
| 1327 | + elseif (preg_match('#C\) (EST|PERM)$#', $line, $matches)) { |
|
| 1328 | 1328 | $result['date_end'] = '2030/12/20 12:00'; |
| 1329 | 1329 | if ($matches[1] == 'EST') $result['estimated'] = 1; |
| 1330 | 1330 | else $result['estimated'] = 0; |
| 1331 | 1331 | if ($matches[1] == 'PERM') $result['permanent'] = 1; |
| 1332 | 1332 | else $result['permanent'] = 0; |
| 1333 | 1333 | } |
| 1334 | - elseif (preg_match('#E\) (.*)#',$line,$matches)) { |
|
| 1334 | + elseif (preg_match('#E\) (.*)#', $line, $matches)) { |
|
| 1335 | 1335 | $rtext = array(); |
| 1336 | - $text = explode(' ',$matches[1]); |
|
| 1336 | + $text = explode(' ', $matches[1]); |
|
| 1337 | 1337 | foreach ($text as $word) { |
| 1338 | 1338 | if (isset($this->abbr[$word])) $rtext[] = strtoupper($this->abbr[$word]); |
| 1339 | - elseif (ctype_digit(strval(substr($word,3))) && isset($this->abbr[substr($word,0,3)])) $rtext[] = strtoupper($this->abbr[substr($word,0,3)]).' '.substr($word,3); |
|
| 1339 | + elseif (ctype_digit(strval(substr($word, 3))) && isset($this->abbr[substr($word, 0, 3)])) $rtext[] = strtoupper($this->abbr[substr($word, 0, 3)]).' '.substr($word, 3); |
|
| 1340 | 1340 | else $rtext[] = $word; |
| 1341 | 1341 | } |
| 1342 | - $result['text'] = implode(' ',$rtext); |
|
| 1342 | + $result['text'] = implode(' ', $rtext); |
|
| 1343 | 1343 | //} elseif (preg_match('#F\) (.*)#',$line,$matches)) { |
| 1344 | 1344 | //} elseif (preg_match('#G\) (.*)#',$line,$matches)) { |
| 1345 | - } elseif (preg_match('#(NOTAMN|NOTAMR|NOTAMC)#',$line,$matches)) { |
|
| 1346 | - $text = explode(' ',$line); |
|
| 1345 | + } elseif (preg_match('#(NOTAMN|NOTAMR|NOTAMC)#', $line, $matches)) { |
|
| 1346 | + $text = explode(' ', $line); |
|
| 1347 | 1347 | $result['ref'] = $text[0]; |
| 1348 | 1348 | if ($matches[1] == 'NOTAMN') $result['type'] = 'new'; |
| 1349 | 1349 | if ($matches[1] == 'NOTAMC') { |
@@ -1015,8 +1015,11 @@ discard block |
||
| 1015 | 1015 | $data = file_get_contents($filename); |
| 1016 | 1016 | preg_match_all("/%%(.+?)%%/is", $data, $matches); |
| 1017 | 1017 | //print_r($matches); |
| 1018 | - if (isset($matches[1])) return $matches[1]; |
|
| 1019 | - else return array(); |
|
| 1018 | + if (isset($matches[1])) { |
|
| 1019 | + return $matches[1]; |
|
| 1020 | + } else { |
|
| 1021 | + return array(); |
|
| 1022 | + } |
|
| 1020 | 1023 | } |
| 1021 | 1024 | public function getAllNOTAMbyScope($scope) { |
| 1022 | 1025 | global $globalDBdriver; |
@@ -1043,7 +1046,9 @@ discard block |
||
| 1043 | 1046 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 1044 | 1047 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 1045 | 1048 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 1046 | - } else return array(); |
|
| 1049 | + } else { |
|
| 1050 | + return array(); |
|
| 1051 | + } |
|
| 1047 | 1052 | if ($globalDBdriver == 'mysql') { |
| 1048 | 1053 | $query = 'SELECT * FROM notam WHERE center_latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND center_longitude BETWEEN '.$minlong.' AND '.$maxlong.' AND radius > 0 AND date_end > UTC_TIMESTAMP() AND date_begin < UTC_TIMESTAMP()'; |
| 1049 | 1054 | } else { |
@@ -1067,7 +1072,9 @@ discard block |
||
| 1067 | 1072 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 1068 | 1073 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 1069 | 1074 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 1070 | - } else return array(); |
|
| 1075 | + } else { |
|
| 1076 | + return array(); |
|
| 1077 | + } |
|
| 1071 | 1078 | if ($globalDBdriver == 'mysql') { |
| 1072 | 1079 | $query = 'SELECT * FROM notam WHERE center_latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND center_longitude BETWEEN '.$minlong.' AND '.$maxlong.' AND radius > 0 AND date_end > UTC_TIMESTAMP() AND date_begin < UTC_TIMESTAMP() AND scope = :scope'; |
| 1073 | 1080 | } else { |
@@ -1094,8 +1101,11 @@ discard block |
||
| 1094 | 1101 | return "error : ".$e->getMessage(); |
| 1095 | 1102 | } |
| 1096 | 1103 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1097 | - if (isset($all[0])) return $all[0]; |
|
| 1098 | - else return array(); |
|
| 1104 | + if (isset($all[0])) { |
|
| 1105 | + return $all[0]; |
|
| 1106 | + } else { |
|
| 1107 | + return array(); |
|
| 1108 | + } |
|
| 1099 | 1109 | } |
| 1100 | 1110 | |
| 1101 | 1111 | public function addNOTAM($ref,$title,$type,$fir,$code,$rules,$scope,$lower_limit,$upper_limit,$center_latitude,$center_longitude,$radius,$date_begin,$date_end,$permanent,$text,$full_notam) { |
@@ -1173,7 +1183,9 @@ discard block |
||
| 1173 | 1183 | foreach ($alldata as $initial_data) { |
| 1174 | 1184 | $data = $this->parse($initial_data); |
| 1175 | 1185 | $notamref = $this->getNOTAMbyRef($data['ref']); |
| 1176 | - if (count($notamref) == 0) $this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
| 1186 | + if (count($notamref) == 0) { |
|
| 1187 | + $this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
| 1188 | + } |
|
| 1177 | 1189 | } |
| 1178 | 1190 | } |
| 1179 | 1191 | } |
@@ -1186,7 +1198,9 @@ discard block |
||
| 1186 | 1198 | foreach ($alldata as $initial_data) { |
| 1187 | 1199 | $data = $this->parse($initial_data); |
| 1188 | 1200 | $notamref = $this->getNOTAMbyRef($data['ref']); |
| 1189 | - 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']); |
|
| 1201 | + if (count($notamref) == 0) { |
|
| 1202 | + $this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
| 1203 | + } |
|
| 1190 | 1204 | } |
| 1191 | 1205 | } |
| 1192 | 1206 | } |
@@ -1198,11 +1212,15 @@ discard block |
||
| 1198 | 1212 | foreach (array_chunk($allairports,20) as $airport) { |
| 1199 | 1213 | $airports_icao = array(); |
| 1200 | 1214 | foreach($airport as $icao) { |
| 1201 | - if (isset($icao['icao'])) $airports_icao[] = $icao['icao']; |
|
| 1215 | + if (isset($icao['icao'])) { |
|
| 1216 | + $airports_icao[] = $icao['icao']; |
|
| 1217 | + } |
|
| 1202 | 1218 | } |
| 1203 | 1219 | $airport_icao = implode(',',$airports_icao); |
| 1204 | 1220 | $alldata = $this->downloadNOTAM($airport_icao); |
| 1205 | - if ($globalTransaction) $this->db->beginTransaction(); |
|
| 1221 | + if ($globalTransaction) { |
|
| 1222 | + $this->db->beginTransaction(); |
|
| 1223 | + } |
|
| 1206 | 1224 | if (count($alldata) > 0) { |
| 1207 | 1225 | foreach ($alldata as $initial_data) { |
| 1208 | 1226 | //print_r($initial_data); |
@@ -1211,14 +1229,23 @@ discard block |
||
| 1211 | 1229 | if (isset($data['ref'])) { |
| 1212 | 1230 | $notamref = $this->getNOTAMbyRef($data['ref']); |
| 1213 | 1231 | if (count($notamref) == 0) { |
| 1214 | - if (isset($data['ref_replaced'])) $this->deleteNOTAMbyRef($data['ref_replaced']); |
|
| 1215 | - if (isset($data['ref_cancelled'])) $this->deleteNOTAMbyRef($data['ref_cancelled']); |
|
| 1216 | - elseif (isset($data['latitude']) && isset($data['scope']) && isset($data['text']) && isset($data['permanent'])) echo $this->addNOTAM($data['ref'],'','',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
| 1232 | + if (isset($data['ref_replaced'])) { |
|
| 1233 | + $this->deleteNOTAMbyRef($data['ref_replaced']); |
|
| 1234 | + } |
|
| 1235 | + if (isset($data['ref_cancelled'])) { |
|
| 1236 | + $this->deleteNOTAMbyRef($data['ref_cancelled']); |
|
| 1237 | + } elseif (isset($data['latitude']) && isset($data['scope']) && isset($data['text']) && isset($data['permanent'])) { |
|
| 1238 | + echo $this->addNOTAM($data['ref'],'','',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
| 1239 | + } |
|
| 1217 | 1240 | } |
| 1218 | 1241 | } |
| 1219 | 1242 | } |
| 1220 | - } else echo 'Error on download. Nothing matches for '.$airport_icao."\n"; |
|
| 1221 | - if ($globalTransaction) $this->db->commit(); |
|
| 1243 | + } else { |
|
| 1244 | + echo 'Error on download. Nothing matches for '.$airport_icao."\n"; |
|
| 1245 | + } |
|
| 1246 | + if ($globalTransaction) { |
|
| 1247 | + $this->db->commit(); |
|
| 1248 | + } |
|
| 1222 | 1249 | sleep(5); |
| 1223 | 1250 | } |
| 1224 | 1251 | } |
@@ -1231,8 +1258,11 @@ discard block |
||
| 1231 | 1258 | $data = $Common->getData($url); |
| 1232 | 1259 | preg_match_all("/<pre>(.+?)<\/pre>/is", $data, $matches); |
| 1233 | 1260 | //print_r($matches); |
| 1234 | - if (isset($matches[1])) return $matches[1]; |
|
| 1235 | - else return array(); |
|
| 1261 | + if (isset($matches[1])) { |
|
| 1262 | + return $matches[1]; |
|
| 1263 | + } else { |
|
| 1264 | + return array(); |
|
| 1265 | + } |
|
| 1236 | 1266 | } |
| 1237 | 1267 | |
| 1238 | 1268 | public function parse($data) { |
@@ -1255,89 +1285,145 @@ discard block |
||
| 1255 | 1285 | $rules = str_split($matches[3]); |
| 1256 | 1286 | foreach ($rules as $rule) { |
| 1257 | 1287 | if ($rule == 'I') { |
| 1258 | - if (isset($result['rules'])) $result['rules'] = $result['rules'].'/IFR'; |
|
| 1259 | - else $result['rules'] = 'IFR'; |
|
| 1288 | + if (isset($result['rules'])) { |
|
| 1289 | + $result['rules'] = $result['rules'].'/IFR'; |
|
| 1290 | + } else { |
|
| 1291 | + $result['rules'] = 'IFR'; |
|
| 1292 | + } |
|
| 1260 | 1293 | } elseif ($rule == 'V') { |
| 1261 | - if (isset($result['rules'])) $result['rules'] = $result['rules'].'/VFR'; |
|
| 1262 | - else $result['rules'] = 'VFR'; |
|
| 1294 | + if (isset($result['rules'])) { |
|
| 1295 | + $result['rules'] = $result['rules'].'/VFR'; |
|
| 1296 | + } else { |
|
| 1297 | + $result['rules'] = 'VFR'; |
|
| 1298 | + } |
|
| 1263 | 1299 | } elseif ($rule == 'K') { |
| 1264 | - if (isset($result['rules'])) $result['rules'] = $result['rules'].'/Checklist'; |
|
| 1265 | - else $result['rules'] = 'Checklist'; |
|
| 1300 | + if (isset($result['rules'])) { |
|
| 1301 | + $result['rules'] = $result['rules'].'/Checklist'; |
|
| 1302 | + } else { |
|
| 1303 | + $result['rules'] = 'Checklist'; |
|
| 1304 | + } |
|
| 1266 | 1305 | } |
| 1267 | 1306 | } |
| 1268 | 1307 | $attentions = str_split($matches[4]); |
| 1269 | 1308 | foreach ($attentions as $attention) { |
| 1270 | 1309 | if ($attention == 'N') { |
| 1271 | - if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Immediate attention'; |
|
| 1272 | - else $result['rules'] = 'Immediate attention'; |
|
| 1310 | + if (isset($result['attention'])) { |
|
| 1311 | + $result['attention'] = $result['attention'].' / Immediate attention'; |
|
| 1312 | + } else { |
|
| 1313 | + $result['rules'] = 'Immediate attention'; |
|
| 1314 | + } |
|
| 1273 | 1315 | } elseif ($attention == 'B') { |
| 1274 | - if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Operational significance'; |
|
| 1275 | - else $result['rules'] = 'Operational significance'; |
|
| 1316 | + if (isset($result['attention'])) { |
|
| 1317 | + $result['attention'] = $result['attention'].' / Operational significance'; |
|
| 1318 | + } else { |
|
| 1319 | + $result['rules'] = 'Operational significance'; |
|
| 1320 | + } |
|
| 1276 | 1321 | } elseif ($attention == 'O') { |
| 1277 | - if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Flight operations'; |
|
| 1278 | - else $result['rules'] = 'Flight operations'; |
|
| 1322 | + if (isset($result['attention'])) { |
|
| 1323 | + $result['attention'] = $result['attention'].' / Flight operations'; |
|
| 1324 | + } else { |
|
| 1325 | + $result['rules'] = 'Flight operations'; |
|
| 1326 | + } |
|
| 1279 | 1327 | } elseif ($attention == 'M') { |
| 1280 | - if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Misc'; |
|
| 1281 | - else $result['rules'] = 'Misc'; |
|
| 1328 | + if (isset($result['attention'])) { |
|
| 1329 | + $result['attention'] = $result['attention'].' / Misc'; |
|
| 1330 | + } else { |
|
| 1331 | + $result['rules'] = 'Misc'; |
|
| 1332 | + } |
|
| 1282 | 1333 | } elseif ($attention == 'K') { |
| 1283 | - if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Checklist'; |
|
| 1284 | - else $result['rules'] = 'Checklist'; |
|
| 1334 | + if (isset($result['attention'])) { |
|
| 1335 | + $result['attention'] = $result['attention'].' / Checklist'; |
|
| 1336 | + } else { |
|
| 1337 | + $result['rules'] = 'Checklist'; |
|
| 1338 | + } |
|
| 1285 | 1339 | } |
| 1286 | 1340 | } |
| 1287 | - if ($matches[5] == 'A') $result['scope'] = 'Airport warning'; |
|
| 1288 | - elseif ($matches[5] == 'E') $result['scope'] = 'Enroute warning'; |
|
| 1289 | - elseif ($matches[5] == 'W') $result['scope'] = 'Navigation warning'; |
|
| 1290 | - elseif ($matches[5] == 'K') $result['scope'] = 'Checklist'; |
|
| 1291 | - elseif ($matches[5] == 'AE') $result['scope'] = 'Airport/Enroute warning'; |
|
| 1292 | - elseif ($matches[5] == 'AW') $result['scope'] = 'Airport/Navigation warning'; |
|
| 1341 | + if ($matches[5] == 'A') { |
|
| 1342 | + $result['scope'] = 'Airport warning'; |
|
| 1343 | + } elseif ($matches[5] == 'E') { |
|
| 1344 | + $result['scope'] = 'Enroute warning'; |
|
| 1345 | + } elseif ($matches[5] == 'W') { |
|
| 1346 | + $result['scope'] = 'Navigation warning'; |
|
| 1347 | + } elseif ($matches[5] == 'K') { |
|
| 1348 | + $result['scope'] = 'Checklist'; |
|
| 1349 | + } elseif ($matches[5] == 'AE') { |
|
| 1350 | + $result['scope'] = 'Airport/Enroute warning'; |
|
| 1351 | + } elseif ($matches[5] == 'AW') { |
|
| 1352 | + $result['scope'] = 'Airport/Navigation warning'; |
|
| 1353 | + } |
|
| 1293 | 1354 | $result['lower_limit'] = $matches[6]; |
| 1294 | 1355 | $result['upper_limit'] = $matches[7]; |
| 1295 | 1356 | $latitude = $Common->convertDec($matches[8],'latitude'); |
| 1296 | - if ($matches[9] == 'S') $latitude = -$latitude; |
|
| 1357 | + if ($matches[9] == 'S') { |
|
| 1358 | + $latitude = -$latitude; |
|
| 1359 | + } |
|
| 1297 | 1360 | $longitude = $Common->convertDec($matches[10],'longitude'); |
| 1298 | - if ($matches[11] == 'W') $longitude = -$longitude; |
|
| 1361 | + if ($matches[11] == 'W') { |
|
| 1362 | + $longitude = -$longitude; |
|
| 1363 | + } |
|
| 1299 | 1364 | $result['latitude'] = $latitude; |
| 1300 | 1365 | $result['longitude'] = $longitude; |
| 1301 | 1366 | $result['radius'] = intval($matches[12]); |
| 1302 | - } else echo 'ERROR : '.$line."\n"; |
|
| 1303 | - } |
|
| 1304 | - elseif (preg_match('#A\) (.*)#',$line,$matches)) { |
|
| 1367 | + } else { |
|
| 1368 | + echo 'ERROR : '.$line."\n"; |
|
| 1369 | + } |
|
| 1370 | + } elseif (preg_match('#A\) (.*)#',$line,$matches)) { |
|
| 1305 | 1371 | $result['icao'] = $matches[1]; |
| 1306 | - } |
|
| 1307 | - elseif (preg_match('#B\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})#',$line,$matches)) { |
|
| 1308 | - if ($matches[1] > 50) $year = '19'.$matches[1]; |
|
| 1309 | - else $year = '20'.$matches[1]; |
|
| 1372 | + } elseif (preg_match('#B\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})#',$line,$matches)) { |
|
| 1373 | + if ($matches[1] > 50) { |
|
| 1374 | + $year = '19'.$matches[1]; |
|
| 1375 | + } else { |
|
| 1376 | + $year = '20'.$matches[1]; |
|
| 1377 | + } |
|
| 1310 | 1378 | $result['date_begin'] = $year.'/'.$matches[2].'/'.$matches[3].' '.$matches[4].':'.$matches[5]; |
| 1311 | - } |
|
| 1312 | - elseif (preg_match('#C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#',$line,$matches)) { |
|
| 1313 | - if ($matches[1] > 50) $year = '19'.$matches[1]; |
|
| 1314 | - else $year = '20'.$matches[1]; |
|
| 1379 | + } elseif (preg_match('#C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#',$line,$matches)) { |
|
| 1380 | + if ($matches[1] > 50) { |
|
| 1381 | + $year = '19'.$matches[1]; |
|
| 1382 | + } else { |
|
| 1383 | + $year = '20'.$matches[1]; |
|
| 1384 | + } |
|
| 1315 | 1385 | $result['date_end'] = $year.'/'.$matches[2].'/'.$matches[3].' '.$matches[4].':'.$matches[5]; |
| 1316 | 1386 | $result['permanent'] = 0; |
| 1317 | - } |
|
| 1318 | - elseif (preg_match('#C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2}) (EST|PERM)$#',$line,$matches)) { |
|
| 1319 | - if ($matches[1] > 50) $year = '19'.$matches[1]; |
|
| 1320 | - else $year = '20'.$matches[1]; |
|
| 1387 | + } elseif (preg_match('#C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2}) (EST|PERM)$#',$line,$matches)) { |
|
| 1388 | + if ($matches[1] > 50) { |
|
| 1389 | + $year = '19'.$matches[1]; |
|
| 1390 | + } else { |
|
| 1391 | + $year = '20'.$matches[1]; |
|
| 1392 | + } |
|
| 1321 | 1393 | $result['date_end'] = $year.'/'.$matches[2].'/'.$matches[3].' '.$matches[4].':'.$matches[5]; |
| 1322 | - if ($matches[6] == 'EST') $result['estimated'] = 1; |
|
| 1323 | - else $result['estimated'] = 0; |
|
| 1324 | - if ($matches[6] == 'PERM') $result['permanent'] = 1; |
|
| 1325 | - else $result['permanent'] = 0; |
|
| 1326 | - } |
|
| 1327 | - elseif (preg_match('#C\) (EST|PERM)$#',$line,$matches)) { |
|
| 1394 | + if ($matches[6] == 'EST') { |
|
| 1395 | + $result['estimated'] = 1; |
|
| 1396 | + } else { |
|
| 1397 | + $result['estimated'] = 0; |
|
| 1398 | + } |
|
| 1399 | + if ($matches[6] == 'PERM') { |
|
| 1400 | + $result['permanent'] = 1; |
|
| 1401 | + } else { |
|
| 1402 | + $result['permanent'] = 0; |
|
| 1403 | + } |
|
| 1404 | + } elseif (preg_match('#C\) (EST|PERM)$#',$line,$matches)) { |
|
| 1328 | 1405 | $result['date_end'] = '2030/12/20 12:00'; |
| 1329 | - if ($matches[1] == 'EST') $result['estimated'] = 1; |
|
| 1330 | - else $result['estimated'] = 0; |
|
| 1331 | - if ($matches[1] == 'PERM') $result['permanent'] = 1; |
|
| 1332 | - else $result['permanent'] = 0; |
|
| 1333 | - } |
|
| 1334 | - elseif (preg_match('#E\) (.*)#',$line,$matches)) { |
|
| 1406 | + if ($matches[1] == 'EST') { |
|
| 1407 | + $result['estimated'] = 1; |
|
| 1408 | + } else { |
|
| 1409 | + $result['estimated'] = 0; |
|
| 1410 | + } |
|
| 1411 | + if ($matches[1] == 'PERM') { |
|
| 1412 | + $result['permanent'] = 1; |
|
| 1413 | + } else { |
|
| 1414 | + $result['permanent'] = 0; |
|
| 1415 | + } |
|
| 1416 | + } elseif (preg_match('#E\) (.*)#',$line,$matches)) { |
|
| 1335 | 1417 | $rtext = array(); |
| 1336 | 1418 | $text = explode(' ',$matches[1]); |
| 1337 | 1419 | foreach ($text as $word) { |
| 1338 | - if (isset($this->abbr[$word])) $rtext[] = strtoupper($this->abbr[$word]); |
|
| 1339 | - elseif (ctype_digit(strval(substr($word,3))) && isset($this->abbr[substr($word,0,3)])) $rtext[] = strtoupper($this->abbr[substr($word,0,3)]).' '.substr($word,3); |
|
| 1340 | - else $rtext[] = $word; |
|
| 1420 | + if (isset($this->abbr[$word])) { |
|
| 1421 | + $rtext[] = strtoupper($this->abbr[$word]); |
|
| 1422 | + } elseif (ctype_digit(strval(substr($word,3))) && isset($this->abbr[substr($word,0,3)])) { |
|
| 1423 | + $rtext[] = strtoupper($this->abbr[substr($word,0,3)]).' '.substr($word,3); |
|
| 1424 | + } else { |
|
| 1425 | + $rtext[] = $word; |
|
| 1426 | + } |
|
| 1341 | 1427 | } |
| 1342 | 1428 | $result['text'] = implode(' ',$rtext); |
| 1343 | 1429 | //} elseif (preg_match('#F\) (.*)#',$line,$matches)) { |
@@ -1345,7 +1431,9 @@ discard block |
||
| 1345 | 1431 | } elseif (preg_match('#(NOTAMN|NOTAMR|NOTAMC)#',$line,$matches)) { |
| 1346 | 1432 | $text = explode(' ',$line); |
| 1347 | 1433 | $result['ref'] = $text[0]; |
| 1348 | - if ($matches[1] == 'NOTAMN') $result['type'] = 'new'; |
|
| 1434 | + if ($matches[1] == 'NOTAMN') { |
|
| 1435 | + $result['type'] = 'new'; |
|
| 1436 | + } |
|
| 1349 | 1437 | if ($matches[1] == 'NOTAMC') { |
| 1350 | 1438 | $result['type'] = 'cancel'; |
| 1351 | 1439 | $result['ref_cancelled'] = $text[2]; |
@@ -1367,69 +1455,101 @@ discard block |
||
| 1367 | 1455 | switch ($code[1]) { |
| 1368 | 1456 | case 'A': |
| 1369 | 1457 | $result = 'Airspace organization '; |
| 1370 | - if (isset($this->code_airspace[$code_fp])) $result .= $this->code_airspace[$code_fp]; |
|
| 1458 | + if (isset($this->code_airspace[$code_fp])) { |
|
| 1459 | + $result .= $this->code_airspace[$code_fp]; |
|
| 1460 | + } |
|
| 1371 | 1461 | break; |
| 1372 | 1462 | case 'C': |
| 1373 | 1463 | $result = 'Communications and radar facilities '; |
| 1374 | - if (isset($this->code_comradar[$code_fp])) $result .= $this->code_comradar[$code_fp]; |
|
| 1464 | + if (isset($this->code_comradar[$code_fp])) { |
|
| 1465 | + $result .= $this->code_comradar[$code_fp]; |
|
| 1466 | + } |
|
| 1375 | 1467 | break; |
| 1376 | 1468 | case 'F': |
| 1377 | 1469 | $result = 'Facilities and services '; |
| 1378 | - if (isset($this->code_facilities[$code_fp])) $result .= $this->code_facilities[$code_fp]; |
|
| 1470 | + if (isset($this->code_facilities[$code_fp])) { |
|
| 1471 | + $result .= $this->code_facilities[$code_fp]; |
|
| 1472 | + } |
|
| 1379 | 1473 | break; |
| 1380 | 1474 | case 'I': |
| 1381 | 1475 | $result = 'Instrument and Microwave Landing System '; |
| 1382 | - if (isset($this->code_instrumentlanding[$code_fp])) $result .= $this->code_instrumentlanding[$code_fp]; |
|
| 1476 | + if (isset($this->code_instrumentlanding[$code_fp])) { |
|
| 1477 | + $result .= $this->code_instrumentlanding[$code_fp]; |
|
| 1478 | + } |
|
| 1383 | 1479 | break; |
| 1384 | 1480 | case 'L': |
| 1385 | 1481 | $result = 'Lighting facilities '; |
| 1386 | - if (isset($this->code_lightingfacilities[$code_fp])) $result .= $this->code_lightingfacilities[$code_fp]; |
|
| 1482 | + if (isset($this->code_lightingfacilities[$code_fp])) { |
|
| 1483 | + $result .= $this->code_lightingfacilities[$code_fp]; |
|
| 1484 | + } |
|
| 1387 | 1485 | break; |
| 1388 | 1486 | case 'M': |
| 1389 | 1487 | $result = 'Movement and landing areas '; |
| 1390 | - if (isset($this->code_movementareas[$code_fp])) $result .= $this->code_movementareas[$code_fp]; |
|
| 1488 | + if (isset($this->code_movementareas[$code_fp])) { |
|
| 1489 | + $result .= $this->code_movementareas[$code_fp]; |
|
| 1490 | + } |
|
| 1391 | 1491 | break; |
| 1392 | 1492 | case 'N': |
| 1393 | 1493 | $result = 'Terminal and En Route Navigation Facilities '; |
| 1394 | - if (isset($this->code_terminalfacilities[$code_fp])) $result .= $this->code_terminalfacilities[$code_fp]; |
|
| 1494 | + if (isset($this->code_terminalfacilities[$code_fp])) { |
|
| 1495 | + $result .= $this->code_terminalfacilities[$code_fp]; |
|
| 1496 | + } |
|
| 1395 | 1497 | break; |
| 1396 | 1498 | case 'O': |
| 1397 | 1499 | $result = 'Other information '; |
| 1398 | - if (isset($this->code_information[$code_fp])) $result .= $this->code_information[$code_fp]; |
|
| 1500 | + if (isset($this->code_information[$code_fp])) { |
|
| 1501 | + $result .= $this->code_information[$code_fp]; |
|
| 1502 | + } |
|
| 1399 | 1503 | break; |
| 1400 | 1504 | case 'P': |
| 1401 | 1505 | $result = 'Air Traffic procedures '; |
| 1402 | - if (isset($this->code_airtraffic[$code_fp])) $result .= $this->code_airtraffic[$code_fp]; |
|
| 1506 | + if (isset($this->code_airtraffic[$code_fp])) { |
|
| 1507 | + $result .= $this->code_airtraffic[$code_fp]; |
|
| 1508 | + } |
|
| 1403 | 1509 | break; |
| 1404 | 1510 | case 'R': |
| 1405 | 1511 | $result = 'Navigation Warnings: Airspace Restrictions '; |
| 1406 | - if (isset($this->code_navigationw[$code_fp])) $result .= $this->code_navigationw[$code_fp]; |
|
| 1512 | + if (isset($this->code_navigationw[$code_fp])) { |
|
| 1513 | + $result .= $this->code_navigationw[$code_fp]; |
|
| 1514 | + } |
|
| 1407 | 1515 | break; |
| 1408 | 1516 | case 'S': |
| 1409 | 1517 | $result = 'Air Traffic and VOLMET Services '; |
| 1410 | - if (isset($this->code_volmet[$code_fp])) $result .= $this->code_volmet[$code_fp]; |
|
| 1518 | + if (isset($this->code_volmet[$code_fp])) { |
|
| 1519 | + $result .= $this->code_volmet[$code_fp]; |
|
| 1520 | + } |
|
| 1411 | 1521 | break; |
| 1412 | 1522 | case 'W': |
| 1413 | 1523 | $result = 'Navigation Warnings: Warnings '; |
| 1414 | - if (isset($this->code_warnings[$code_fp])) $result .= $this->code_warnings[$code_fp]; |
|
| 1524 | + if (isset($this->code_warnings[$code_fp])) { |
|
| 1525 | + $result .= $this->code_warnings[$code_fp]; |
|
| 1526 | + } |
|
| 1415 | 1527 | break; |
| 1416 | 1528 | } |
| 1417 | 1529 | switch ($code[3]) { |
| 1418 | 1530 | case 'A': |
| 1419 | 1531 | // Availability |
| 1420 | - if (isset($this->code_sp_availabity[$code_sp])) $result .= ' '.$this->code_sp_availabity[$code_sp]; |
|
| 1532 | + if (isset($this->code_sp_availabity[$code_sp])) { |
|
| 1533 | + $result .= ' '.$this->code_sp_availabity[$code_sp]; |
|
| 1534 | + } |
|
| 1421 | 1535 | break; |
| 1422 | 1536 | case 'C': |
| 1423 | 1537 | // Changes |
| 1424 | - if (isset($this->code_sp_changes[$code_sp])) $result .= ' '.$this->code_sp_changes[$code_sp]; |
|
| 1538 | + if (isset($this->code_sp_changes[$code_sp])) { |
|
| 1539 | + $result .= ' '.$this->code_sp_changes[$code_sp]; |
|
| 1540 | + } |
|
| 1425 | 1541 | break; |
| 1426 | 1542 | case 'H': |
| 1427 | 1543 | // Hazardous conditions |
| 1428 | - if (isset($this->code_sp_hazardous[$code_sp])) $result .= ' '.$this->code_sp_hazardous[$code_sp]; |
|
| 1544 | + if (isset($this->code_sp_hazardous[$code_sp])) { |
|
| 1545 | + $result .= ' '.$this->code_sp_hazardous[$code_sp]; |
|
| 1546 | + } |
|
| 1429 | 1547 | break; |
| 1430 | 1548 | case 'L': |
| 1431 | 1549 | // Limitations |
| 1432 | - if (isset($this->code_sp_limitations[$code_sp])) $result .= ' '.$this->code_sp_limitations[$code_sp]; |
|
| 1550 | + if (isset($this->code_sp_limitations[$code_sp])) { |
|
| 1551 | + $result .= ' '.$this->code_sp_limitations[$code_sp]; |
|
| 1552 | + } |
|
| 1433 | 1553 | break; |
| 1434 | 1554 | case 'X': |
| 1435 | 1555 | // Other Information |
@@ -14,11 +14,11 @@ discard block |
||
| 14 | 14 | try { |
| 15 | 15 | $sth = $Connection->db->prepare($query); |
| 16 | 16 | $sth->execute(); |
| 17 | - } catch(PDOException $e) { |
|
| 17 | + } catch (PDOException $e) { |
|
| 18 | 18 | return "error : ".$e->getMessage()."\n"; |
| 19 | 19 | } |
| 20 | 20 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
| 21 | - $Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']); |
|
| 21 | + $Schedule->addSchedule($row['ident'], $row['departure_airport_icao'], $row['departure_airport_time'], $row['arrival_airport_icao'], $row['arrival_airport_time']); |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | } |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | try { |
| 51 | 51 | $sth = $Connection->db->prepare($query); |
| 52 | 52 | $sth->execute(); |
| 53 | - } catch(PDOException $e) { |
|
| 53 | + } catch (PDOException $e) { |
|
| 54 | 54 | return "error (add new columns to routes table) : ".$e->getMessage()."\n"; |
| 55 | 55 | } |
| 56 | 56 | // Copy schedules data to routes table |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | try { |
| 61 | 61 | $sth = $Connection->db->prepare($query); |
| 62 | 62 | $sth->execute(); |
| 63 | - } catch(PDOException $e) { |
|
| 63 | + } catch (PDOException $e) { |
|
| 64 | 64 | return "error (delete schedule table) : ".$e->getMessage()."\n"; |
| 65 | 65 | } |
| 66 | 66 | // Add source column |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | try { |
| 69 | 69 | $sth = $Connection->db->prepare($query); |
| 70 | 70 | $sth->execute(); |
| 71 | - } catch(PDOException $e) { |
|
| 71 | + } catch (PDOException $e) { |
|
| 72 | 72 | return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n"; |
| 73 | 73 | } |
| 74 | 74 | // Delete unused column |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | try { |
| 77 | 77 | $sth = $Connection->db->prepare($query); |
| 78 | 78 | $sth->execute(); |
| 79 | - } catch(PDOException $e) { |
|
| 79 | + } catch (PDOException $e) { |
|
| 80 | 80 | return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n"; |
| 81 | 81 | } |
| 82 | 82 | // Add ModeS column |
@@ -84,14 +84,14 @@ discard block |
||
| 84 | 84 | try { |
| 85 | 85 | $sth = $Connection->db->prepare($query); |
| 86 | 86 | $sth->execute(); |
| 87 | - } catch(PDOException $e) { |
|
| 87 | + } catch (PDOException $e) { |
|
| 88 | 88 | return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n"; |
| 89 | 89 | } |
| 90 | 90 | $query = "ALTER TABLE `spotter_live` ADD `ModeS` VARCHAR(255)"; |
| 91 | 91 | try { |
| 92 | 92 | $sth = $Connection->db->prepare($query); |
| 93 | 93 | $sth->execute(); |
| 94 | - } catch(PDOException $e) { |
|
| 94 | + } catch (PDOException $e) { |
|
| 95 | 95 | return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n"; |
| 96 | 96 | } |
| 97 | 97 | // Add auto_increment for aircraft_modes |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | try { |
| 100 | 100 | $sth = $Connection->db->prepare($query); |
| 101 | 101 | $sth->execute(); |
| 102 | - } catch(PDOException $e) { |
|
| 102 | + } catch (PDOException $e) { |
|
| 103 | 103 | return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n"; |
| 104 | 104 | } |
| 105 | 105 | $error = ''; |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | try { |
| 111 | 111 | $sth = $Connection->db->prepare($query); |
| 112 | 112 | $sth->execute(); |
| 113 | - } catch(PDOException $e) { |
|
| 113 | + } catch (PDOException $e) { |
|
| 114 | 114 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 115 | 115 | } |
| 116 | 116 | return $error; |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | try { |
| 124 | 124 | $sth = $Connection->db->prepare($query); |
| 125 | 125 | $sth->execute(); |
| 126 | - } catch(PDOException $e) { |
|
| 126 | + } catch (PDOException $e) { |
|
| 127 | 127 | return "error (add new columns to routes table) : ".$e->getMessage()."\n"; |
| 128 | 128 | } |
| 129 | 129 | $error = ''; |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | try { |
| 135 | 135 | $sth = $Connection->db->prepare($query); |
| 136 | 136 | $sth->execute(); |
| 137 | - } catch(PDOException $e) { |
|
| 137 | + } catch (PDOException $e) { |
|
| 138 | 138 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 139 | 139 | } |
| 140 | 140 | return $error; |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | try { |
| 148 | 148 | $sth = $Connection->db->prepare($query); |
| 149 | 149 | $sth->execute(); |
| 150 | - } catch(PDOException $e) { |
|
| 150 | + } catch (PDOException $e) { |
|
| 151 | 151 | return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n"; |
| 152 | 152 | } |
| 153 | 153 | // Add image_source_website column to spotter_image |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | try { |
| 156 | 156 | $sth = $Connection->db->prepare($query); |
| 157 | 157 | $sth->execute(); |
| 158 | - } catch(PDOException $e) { |
|
| 158 | + } catch (PDOException $e) { |
|
| 159 | 159 | return "error (add new columns to spotter_image) : ".$e->getMessage()."\n"; |
| 160 | 160 | } |
| 161 | 161 | $error = ''; |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | try { |
| 165 | 165 | $sth = $Connection->db->prepare($query); |
| 166 | 166 | $sth->execute(); |
| 167 | - } catch(PDOException $e) { |
|
| 167 | + } catch (PDOException $e) { |
|
| 168 | 168 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 169 | 169 | } |
| 170 | 170 | return $error; |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | try { |
| 183 | 183 | $sth = $Connection->db->prepare($query); |
| 184 | 184 | $sth->execute(); |
| 185 | - } catch(PDOException $e) { |
|
| 185 | + } catch (PDOException $e) { |
|
| 186 | 186 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 187 | 187 | } |
| 188 | 188 | } |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | try { |
| 197 | 197 | $sth = $Connection->db->prepare($query); |
| 198 | 198 | $sth->execute(); |
| 199 | - } catch(PDOException $e) { |
|
| 199 | + } catch (PDOException $e) { |
|
| 200 | 200 | return "error (add new columns to translation) : ".$e->getMessage()."\n"; |
| 201 | 201 | } |
| 202 | 202 | // Add aircraft_shadow column to aircraft |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | try { |
| 205 | 205 | $sth = $Connection->db->prepare($query); |
| 206 | 206 | $sth->execute(); |
| 207 | - } catch(PDOException $e) { |
|
| 207 | + } catch (PDOException $e) { |
|
| 208 | 208 | return "error (add new column to aircraft) : ".$e->getMessage()."\n"; |
| 209 | 209 | } |
| 210 | 210 | // Add aircraft_shadow column to spotter_live |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | try { |
| 213 | 213 | $sth = $Connection->db->prepare($query); |
| 214 | 214 | $sth->execute(); |
| 215 | - } catch(PDOException $e) { |
|
| 215 | + } catch (PDOException $e) { |
|
| 216 | 216 | return "error (add new column to spotter_live) : ".$e->getMessage()."\n"; |
| 217 | 217 | } |
| 218 | 218 | $error = ''; |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | try { |
| 226 | 226 | $sth = $Connection->db->prepare($query); |
| 227 | 227 | $sth->execute(); |
| 228 | - } catch(PDOException $e) { |
|
| 228 | + } catch (PDOException $e) { |
|
| 229 | 229 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 230 | 230 | } |
| 231 | 231 | return $error; |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | |
| 234 | 234 | private static function update_from_6() { |
| 235 | 235 | $Connection = new Connection(); |
| 236 | - if (!$Connection->indexExists('spotter_output','flightaware_id')) { |
|
| 236 | + if (!$Connection->indexExists('spotter_output', 'flightaware_id')) { |
|
| 237 | 237 | $query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id); |
| 238 | 238 | ALTER TABLE spotter_output ADD INDEX(date); |
| 239 | 239 | ALTER TABLE spotter_output ADD INDEX(ident); |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | try { |
| 251 | 251 | $sth = $Connection->db->prepare($query); |
| 252 | 252 | $sth->execute(); |
| 253 | - } catch(PDOException $e) { |
|
| 253 | + } catch (PDOException $e) { |
|
| 254 | 254 | return "error (add some indexes) : ".$e->getMessage()."\n"; |
| 255 | 255 | } |
| 256 | 256 | } |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | try { |
| 266 | 266 | $sth = $Connection->db->prepare($query); |
| 267 | 267 | $sth->execute(); |
| 268 | - } catch(PDOException $e) { |
|
| 268 | + } catch (PDOException $e) { |
|
| 269 | 269 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 270 | 270 | } |
| 271 | 271 | return $error; |
@@ -274,12 +274,12 @@ discard block |
||
| 274 | 274 | private static function update_from_7() { |
| 275 | 275 | global $globalDBname, $globalDBdriver; |
| 276 | 276 | $Connection = new Connection(); |
| 277 | - $query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL; |
|
| 277 | + $query = "ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL; |
|
| 278 | 278 | ALTER TABLE spotter_output ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;"; |
| 279 | 279 | try { |
| 280 | 280 | $sth = $Connection->db->prepare($query); |
| 281 | 281 | $sth->execute(); |
| 282 | - } catch(PDOException $e) { |
|
| 282 | + } catch (PDOException $e) { |
|
| 283 | 283 | return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; |
| 284 | 284 | } |
| 285 | 285 | if ($globalDBdriver == 'mysql') { |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | try { |
| 288 | 288 | $sth = $Connection->db->prepare($query); |
| 289 | 289 | $sth->execute(); |
| 290 | - } catch(PDOException $e) { |
|
| 290 | + } catch (PDOException $e) { |
|
| 291 | 291 | return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n"; |
| 292 | 292 | } |
| 293 | 293 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -299,15 +299,15 @@ discard block |
||
| 299 | 299 | DROP TABLE spotter_archive; |
| 300 | 300 | RENAME TABLE copy TO spotter_archive;"; |
| 301 | 301 | } else { |
| 302 | - $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
| 302 | + $query = "ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
| 303 | 303 | } |
| 304 | 304 | } else { |
| 305 | - $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
| 305 | + $query = "ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
| 306 | 306 | } |
| 307 | 307 | try { |
| 308 | 308 | $sth = $Connection->db->prepare($query); |
| 309 | 309 | $sth->execute(); |
| 310 | - } catch(PDOException $e) { |
|
| 310 | + } catch (PDOException $e) { |
|
| 311 | 311 | return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n"; |
| 312 | 312 | } |
| 313 | 313 | |
@@ -320,7 +320,7 @@ discard block |
||
| 320 | 320 | try { |
| 321 | 321 | $sth = $Connection->db->prepare($query); |
| 322 | 322 | $sth->execute(); |
| 323 | - } catch(PDOException $e) { |
|
| 323 | + } catch (PDOException $e) { |
|
| 324 | 324 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 325 | 325 | } |
| 326 | 326 | return $error; |
@@ -339,14 +339,14 @@ discard block |
||
| 339 | 339 | try { |
| 340 | 340 | $sth = $Connection->db->prepare($query); |
| 341 | 341 | $sth->execute(); |
| 342 | - } catch(PDOException $e) { |
|
| 342 | + } catch (PDOException $e) { |
|
| 343 | 343 | return "error (insert last_update values) : ".$e->getMessage()."\n"; |
| 344 | 344 | } |
| 345 | 345 | $query = "UPDATE `config` SET `value` = '9' WHERE `name` = 'schema_version'"; |
| 346 | 346 | try { |
| 347 | 347 | $sth = $Connection->db->prepare($query); |
| 348 | 348 | $sth->execute(); |
| 349 | - } catch(PDOException $e) { |
|
| 349 | + } catch (PDOException $e) { |
|
| 350 | 350 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 351 | 351 | } |
| 352 | 352 | return $error; |
@@ -354,12 +354,12 @@ discard block |
||
| 354 | 354 | |
| 355 | 355 | private static function update_from_9() { |
| 356 | 356 | $Connection = new Connection(); |
| 357 | - $query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL; |
|
| 357 | + $query = "ALTER TABLE spotter_live ADD verticalrate INT(11) NULL; |
|
| 358 | 358 | ALTER TABLE spotter_output ADD verticalrate INT(11) NULL;"; |
| 359 | 359 | try { |
| 360 | 360 | $sth = $Connection->db->prepare($query); |
| 361 | 361 | $sth->execute(); |
| 362 | - } catch(PDOException $e) { |
|
| 362 | + } catch (PDOException $e) { |
|
| 363 | 363 | return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; |
| 364 | 364 | } |
| 365 | 365 | $error = ''; |
@@ -371,7 +371,7 @@ discard block |
||
| 371 | 371 | try { |
| 372 | 372 | $sth = $Connection->db->prepare($query); |
| 373 | 373 | $sth->execute(); |
| 374 | - } catch(PDOException $e) { |
|
| 374 | + } catch (PDOException $e) { |
|
| 375 | 375 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 376 | 376 | } |
| 377 | 377 | return $error; |
@@ -379,11 +379,11 @@ discard block |
||
| 379 | 379 | |
| 380 | 380 | private static function update_from_10() { |
| 381 | 381 | $Connection = new Connection(); |
| 382 | - $query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL"; |
|
| 382 | + $query = "ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL"; |
|
| 383 | 383 | try { |
| 384 | 384 | $sth = $Connection->db->prepare($query); |
| 385 | 385 | $sth->execute(); |
| 386 | - } catch(PDOException $e) { |
|
| 386 | + } catch (PDOException $e) { |
|
| 387 | 387 | return "error (add new enum to ATC table) : ".$e->getMessage()."\n"; |
| 388 | 388 | } |
| 389 | 389 | $error = ''; |
@@ -401,7 +401,7 @@ discard block |
||
| 401 | 401 | try { |
| 402 | 402 | $sth = $Connection->db->prepare($query); |
| 403 | 403 | $sth->execute(); |
| 404 | - } catch(PDOException $e) { |
|
| 404 | + } catch (PDOException $e) { |
|
| 405 | 405 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 406 | 406 | } |
| 407 | 407 | return $error; |
@@ -410,18 +410,18 @@ discard block |
||
| 410 | 410 | private static function update_from_11() { |
| 411 | 411 | global $globalDBdriver, $globalDBname; |
| 412 | 412 | $Connection = new Connection(); |
| 413 | - $query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)"; |
|
| 413 | + $query = "ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)"; |
|
| 414 | 414 | try { |
| 415 | 415 | $sth = $Connection->db->prepare($query); |
| 416 | 416 | $sth->execute(); |
| 417 | - } catch(PDOException $e) { |
|
| 417 | + } catch (PDOException $e) { |
|
| 418 | 418 | return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n"; |
| 419 | 419 | } |
| 420 | - $query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
| 420 | + $query = "ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
| 421 | 421 | try { |
| 422 | 422 | $sth = $Connection->db->prepare($query); |
| 423 | 423 | $sth->execute(); |
| 424 | - } catch(PDOException $e) { |
|
| 424 | + } catch (PDOException $e) { |
|
| 425 | 425 | return "error (format_source column to spotter_live) : ".$e->getMessage()."\n"; |
| 426 | 426 | } |
| 427 | 427 | if ($globalDBdriver == 'mysql') { |
@@ -429,7 +429,7 @@ discard block |
||
| 429 | 429 | try { |
| 430 | 430 | $sth = $Connection->db->prepare($query); |
| 431 | 431 | $sth->execute(); |
| 432 | - } catch(PDOException $e) { |
|
| 432 | + } catch (PDOException $e) { |
|
| 433 | 433 | return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n"; |
| 434 | 434 | } |
| 435 | 435 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -441,15 +441,15 @@ discard block |
||
| 441 | 441 | DROP TABLE spotter_archive; |
| 442 | 442 | RENAME TABLE copy TO spotter_archive;"; |
| 443 | 443 | } else { |
| 444 | - $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
| 444 | + $query = "ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
| 445 | 445 | } |
| 446 | 446 | } else { |
| 447 | - $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
| 447 | + $query = "ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
| 448 | 448 | } |
| 449 | 449 | try { |
| 450 | 450 | $sth = $Connection->db->prepare($query); |
| 451 | 451 | $sth->execute(); |
| 452 | - } catch(PDOException $e) { |
|
| 452 | + } catch (PDOException $e) { |
|
| 453 | 453 | return "error (add columns to spotter_archive) : ".$e->getMessage()."\n"; |
| 454 | 454 | } |
| 455 | 455 | |
@@ -459,7 +459,7 @@ discard block |
||
| 459 | 459 | try { |
| 460 | 460 | $sth = $Connection->db->prepare($query); |
| 461 | 461 | $sth->execute(); |
| 462 | - } catch(PDOException $e) { |
|
| 462 | + } catch (PDOException $e) { |
|
| 463 | 463 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 464 | 464 | } |
| 465 | 465 | return $error; |
@@ -487,7 +487,7 @@ discard block |
||
| 487 | 487 | try { |
| 488 | 488 | $sth = $Connection->db->prepare($query); |
| 489 | 489 | $sth->execute(); |
| 490 | - } catch(PDOException $e) { |
|
| 490 | + } catch (PDOException $e) { |
|
| 491 | 491 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 492 | 492 | } |
| 493 | 493 | return $error; |
@@ -495,12 +495,12 @@ discard block |
||
| 495 | 495 | |
| 496 | 496 | private static function update_from_13() { |
| 497 | 497 | $Connection = new Connection(); |
| 498 | - if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) { |
|
| 499 | - $query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)"; |
|
| 498 | + if (!$Connection->checkColumnName('spotter_archive_output', 'real_departure_airport_icao')) { |
|
| 499 | + $query = "ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)"; |
|
| 500 | 500 | try { |
| 501 | 501 | $sth = $Connection->db->prepare($query); |
| 502 | 502 | $sth->execute(); |
| 503 | - } catch(PDOException $e) { |
|
| 503 | + } catch (PDOException $e) { |
|
| 504 | 504 | return "error (update spotter_archive_output) : ".$e->getMessage()."\n"; |
| 505 | 505 | } |
| 506 | 506 | } |
@@ -509,7 +509,7 @@ discard block |
||
| 509 | 509 | try { |
| 510 | 510 | $sth = $Connection->db->prepare($query); |
| 511 | 511 | $sth->execute(); |
| 512 | - } catch(PDOException $e) { |
|
| 512 | + } catch (PDOException $e) { |
|
| 513 | 513 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 514 | 514 | } |
| 515 | 515 | return $error; |
@@ -527,7 +527,7 @@ discard block |
||
| 527 | 527 | try { |
| 528 | 528 | $sth = $Connection->db->prepare($query); |
| 529 | 529 | $sth->execute(); |
| 530 | - } catch(PDOException $e) { |
|
| 530 | + } catch (PDOException $e) { |
|
| 531 | 531 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 532 | 532 | } |
| 533 | 533 | return $error; |
@@ -538,11 +538,11 @@ discard block |
||
| 538 | 538 | $Connection = new Connection(); |
| 539 | 539 | $error = ''; |
| 540 | 540 | // Add tables |
| 541 | - $query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP"; |
|
| 541 | + $query = "ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP"; |
|
| 542 | 542 | try { |
| 543 | 543 | $sth = $Connection->db->prepare($query); |
| 544 | 544 | $sth->execute(); |
| 545 | - } catch(PDOException $e) { |
|
| 545 | + } catch (PDOException $e) { |
|
| 546 | 546 | return "error (update stats) : ".$e->getMessage()."\n"; |
| 547 | 547 | } |
| 548 | 548 | if ($error != '') return $error; |
@@ -550,7 +550,7 @@ discard block |
||
| 550 | 550 | try { |
| 551 | 551 | $sth = $Connection->db->prepare($query); |
| 552 | 552 | $sth->execute(); |
| 553 | - } catch(PDOException $e) { |
|
| 553 | + } catch (PDOException $e) { |
|
| 554 | 554 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 555 | 555 | } |
| 556 | 556 | return $error; |
@@ -571,7 +571,7 @@ discard block |
||
| 571 | 571 | try { |
| 572 | 572 | $sth = $Connection->db->prepare($query); |
| 573 | 573 | $sth->execute(); |
| 574 | - } catch(PDOException $e) { |
|
| 574 | + } catch (PDOException $e) { |
|
| 575 | 575 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 576 | 576 | } |
| 577 | 577 | return $error; |
@@ -589,7 +589,7 @@ discard block |
||
| 589 | 589 | try { |
| 590 | 590 | $sth = $Connection->db->prepare($query); |
| 591 | 591 | $sth->execute(); |
| 592 | - } catch(PDOException $e) { |
|
| 592 | + } catch (PDOException $e) { |
|
| 593 | 593 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 594 | 594 | } |
| 595 | 595 | return $error; |
@@ -598,12 +598,12 @@ discard block |
||
| 598 | 598 | $Connection = new Connection(); |
| 599 | 599 | $error = ''; |
| 600 | 600 | // Modify stats_airport table |
| 601 | - if (!$Connection->checkColumnName('stats_airport','airport_name')) { |
|
| 601 | + if (!$Connection->checkColumnName('stats_airport', 'airport_name')) { |
|
| 602 | 602 | $query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)"; |
| 603 | 603 | try { |
| 604 | 604 | $sth = $Connection->db->prepare($query); |
| 605 | 605 | $sth->execute(); |
| 606 | - } catch(PDOException $e) { |
|
| 606 | + } catch (PDOException $e) { |
|
| 607 | 607 | return "error (update stats) : ".$e->getMessage()."\n"; |
| 608 | 608 | } |
| 609 | 609 | } |
@@ -612,7 +612,7 @@ discard block |
||
| 612 | 612 | try { |
| 613 | 613 | $sth = $Connection->db->prepare($query); |
| 614 | 614 | $sth->execute(); |
| 615 | - } catch(PDOException $e) { |
|
| 615 | + } catch (PDOException $e) { |
|
| 616 | 616 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 617 | 617 | } |
| 618 | 618 | return $error; |
@@ -629,73 +629,73 @@ discard block |
||
| 629 | 629 | try { |
| 630 | 630 | $sth = $Connection->db->prepare($query); |
| 631 | 631 | $sth->execute(); |
| 632 | - } catch(PDOException $e) { |
|
| 632 | + } catch (PDOException $e) { |
|
| 633 | 633 | return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n"; |
| 634 | 634 | } |
| 635 | 635 | $query = "alter table spotter_archive add spotter_archive_id INT(11)"; |
| 636 | 636 | try { |
| 637 | 637 | $sth = $Connection->db->prepare($query); |
| 638 | 638 | $sth->execute(); |
| 639 | - } catch(PDOException $e) { |
|
| 639 | + } catch (PDOException $e) { |
|
| 640 | 640 | return "error (add id again on spotter_archive) : ".$e->getMessage()."\n"; |
| 641 | 641 | } |
| 642 | - if (!$Connection->checkColumnName('spotter_archive','over_country')) { |
|
| 642 | + if (!$Connection->checkColumnName('spotter_archive', 'over_country')) { |
|
| 643 | 643 | // Add column over_country |
| 644 | 644 | $query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL"; |
| 645 | 645 | try { |
| 646 | 646 | $sth = $Connection->db->prepare($query); |
| 647 | 647 | $sth->execute(); |
| 648 | - } catch(PDOException $e) { |
|
| 648 | + } catch (PDOException $e) { |
|
| 649 | 649 | return "error (add over_country) : ".$e->getMessage()."\n"; |
| 650 | 650 | } |
| 651 | 651 | } |
| 652 | - if (!$Connection->checkColumnName('spotter_live','over_country')) { |
|
| 652 | + if (!$Connection->checkColumnName('spotter_live', 'over_country')) { |
|
| 653 | 653 | // Add column over_country |
| 654 | 654 | $query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL"; |
| 655 | 655 | try { |
| 656 | 656 | $sth = $Connection->db->prepare($query); |
| 657 | 657 | $sth->execute(); |
| 658 | - } catch(PDOException $e) { |
|
| 658 | + } catch (PDOException $e) { |
|
| 659 | 659 | return "error (add over_country) : ".$e->getMessage()."\n"; |
| 660 | 660 | } |
| 661 | 661 | } |
| 662 | - if (!$Connection->checkColumnName('spotter_output','source_name')) { |
|
| 662 | + if (!$Connection->checkColumnName('spotter_output', 'source_name')) { |
|
| 663 | 663 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
| 664 | 664 | $query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
| 665 | 665 | try { |
| 666 | 666 | $sth = $Connection->db->prepare($query); |
| 667 | 667 | $sth->execute(); |
| 668 | - } catch(PDOException $e) { |
|
| 668 | + } catch (PDOException $e) { |
|
| 669 | 669 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
| 670 | 670 | } |
| 671 | 671 | } |
| 672 | - if (!$Connection->checkColumnName('spotter_live','source_name')) { |
|
| 672 | + if (!$Connection->checkColumnName('spotter_live', 'source_name')) { |
|
| 673 | 673 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
| 674 | 674 | $query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
| 675 | 675 | try { |
| 676 | 676 | $sth = $Connection->db->prepare($query); |
| 677 | 677 | $sth->execute(); |
| 678 | - } catch(PDOException $e) { |
|
| 678 | + } catch (PDOException $e) { |
|
| 679 | 679 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
| 680 | 680 | } |
| 681 | 681 | } |
| 682 | - if (!$Connection->checkColumnName('spotter_archive_output','source_name')) { |
|
| 682 | + if (!$Connection->checkColumnName('spotter_archive_output', 'source_name')) { |
|
| 683 | 683 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
| 684 | 684 | $query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
| 685 | 685 | try { |
| 686 | 686 | $sth = $Connection->db->prepare($query); |
| 687 | 687 | $sth->execute(); |
| 688 | - } catch(PDOException $e) { |
|
| 688 | + } catch (PDOException $e) { |
|
| 689 | 689 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
| 690 | 690 | } |
| 691 | 691 | } |
| 692 | - if (!$Connection->checkColumnName('spotter_archive','source_name')) { |
|
| 692 | + if (!$Connection->checkColumnName('spotter_archive', 'source_name')) { |
|
| 693 | 693 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
| 694 | 694 | $query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;"; |
| 695 | 695 | try { |
| 696 | 696 | $sth = $Connection->db->prepare($query); |
| 697 | 697 | $sth->execute(); |
| 698 | - } catch(PDOException $e) { |
|
| 698 | + } catch (PDOException $e) { |
|
| 699 | 699 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
| 700 | 700 | } |
| 701 | 701 | } |
@@ -704,7 +704,7 @@ discard block |
||
| 704 | 704 | try { |
| 705 | 705 | $sth = $Connection->db->prepare($query); |
| 706 | 706 | $sth->execute(); |
| 707 | - } catch(PDOException $e) { |
|
| 707 | + } catch (PDOException $e) { |
|
| 708 | 708 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 709 | 709 | } |
| 710 | 710 | return $error; |
@@ -719,13 +719,13 @@ discard block |
||
| 719 | 719 | $error .= create_db::import_file('../db/airlines.sql'); |
| 720 | 720 | if ($error != '') return 'Import airlines.sql : '.$error; |
| 721 | 721 | } |
| 722 | - if (!$Connection->checkColumnName('aircraft_modes','type_flight')) { |
|
| 722 | + if (!$Connection->checkColumnName('aircraft_modes', 'type_flight')) { |
|
| 723 | 723 | // Add column over_country |
| 724 | 724 | $query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;"; |
| 725 | 725 | try { |
| 726 | 726 | $sth = $Connection->db->prepare($query); |
| 727 | 727 | $sth->execute(); |
| 728 | - } catch(PDOException $e) { |
|
| 728 | + } catch (PDOException $e) { |
|
| 729 | 729 | return "error (add over_country) : ".$e->getMessage()."\n"; |
| 730 | 730 | } |
| 731 | 731 | } |
@@ -741,7 +741,7 @@ discard block |
||
| 741 | 741 | try { |
| 742 | 742 | $sth = $Connection->db->prepare($query); |
| 743 | 743 | $sth->execute(); |
| 744 | - } catch(PDOException $e) { |
|
| 744 | + } catch (PDOException $e) { |
|
| 745 | 745 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 746 | 746 | } |
| 747 | 747 | return $error; |
@@ -750,13 +750,13 @@ discard block |
||
| 750 | 750 | private static function update_from_21() { |
| 751 | 751 | $Connection = new Connection(); |
| 752 | 752 | $error = ''; |
| 753 | - if (!$Connection->checkColumnName('stats_airport','stats_type')) { |
|
| 753 | + if (!$Connection->checkColumnName('stats_airport', 'stats_type')) { |
|
| 754 | 754 | // Rename type to stats_type |
| 755 | 755 | $query = "ALTER TABLE `stats_airport` CHANGE `type` `stats_type` VARCHAR(50);ALTER TABLE `stats` CHANGE `type` `stats_type` VARCHAR(50);ALTER TABLE `stats_flight` CHANGE `type` `stats_type` VARCHAR(50);"; |
| 756 | 756 | try { |
| 757 | 757 | $sth = $Connection->db->prepare($query); |
| 758 | 758 | $sth->execute(); |
| 759 | - } catch(PDOException $e) { |
|
| 759 | + } catch (PDOException $e) { |
|
| 760 | 760 | return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n"; |
| 761 | 761 | } |
| 762 | 762 | if ($error != '') return $error; |
@@ -765,7 +765,7 @@ discard block |
||
| 765 | 765 | try { |
| 766 | 766 | $sth = $Connection->db->prepare($query); |
| 767 | 767 | $sth->execute(); |
| 768 | - } catch(PDOException $e) { |
|
| 768 | + } catch (PDOException $e) { |
|
| 769 | 769 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 770 | 770 | } |
| 771 | 771 | return $error; |
@@ -788,7 +788,7 @@ discard block |
||
| 788 | 788 | try { |
| 789 | 789 | $sth = $Connection->db->prepare($query); |
| 790 | 790 | $sth->execute(); |
| 791 | - } catch(PDOException $e) { |
|
| 791 | + } catch (PDOException $e) { |
|
| 792 | 792 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 793 | 793 | } |
| 794 | 794 | return $error; |
@@ -815,17 +815,17 @@ discard block |
||
| 815 | 815 | try { |
| 816 | 816 | $sth = $Connection->db->prepare($query); |
| 817 | 817 | $sth->execute(); |
| 818 | - } catch(PDOException $e) { |
|
| 818 | + } catch (PDOException $e) { |
|
| 819 | 819 | return "error (create index on spotter_archive) : ".$e->getMessage()."\n"; |
| 820 | 820 | } |
| 821 | 821 | } |
| 822 | - if (!$Connection->checkColumnName('stats_aircraft','aircraft_manufacturer')) { |
|
| 822 | + if (!$Connection->checkColumnName('stats_aircraft', 'aircraft_manufacturer')) { |
|
| 823 | 823 | // Add aircraft_manufacturer to stats_aircraft |
| 824 | 824 | $query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL"; |
| 825 | 825 | try { |
| 826 | 826 | $sth = $Connection->db->prepare($query); |
| 827 | 827 | $sth->execute(); |
| 828 | - } catch(PDOException $e) { |
|
| 828 | + } catch (PDOException $e) { |
|
| 829 | 829 | return "error (add aircraft_manufacturer column) : ".$e->getMessage()."\n"; |
| 830 | 830 | } |
| 831 | 831 | } |
@@ -834,7 +834,7 @@ discard block |
||
| 834 | 834 | try { |
| 835 | 835 | $sth = $Connection->db->prepare($query); |
| 836 | 836 | $sth->execute(); |
| 837 | - } catch(PDOException $e) { |
|
| 837 | + } catch (PDOException $e) { |
|
| 838 | 838 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 839 | 839 | } |
| 840 | 840 | return $error; |
@@ -850,23 +850,23 @@ discard block |
||
| 850 | 850 | $error .= create_db::import_file('../db/pgsql/airlines.sql'); |
| 851 | 851 | } |
| 852 | 852 | if ($error != '') return 'Import airlines.sql : '.$error; |
| 853 | - if (!$Connection->checkColumnName('airlines','forsource')) { |
|
| 853 | + if (!$Connection->checkColumnName('airlines', 'forsource')) { |
|
| 854 | 854 | // Add forsource to airlines |
| 855 | 855 | $query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL"; |
| 856 | 856 | try { |
| 857 | 857 | $sth = $Connection->db->prepare($query); |
| 858 | 858 | $sth->execute(); |
| 859 | - } catch(PDOException $e) { |
|
| 859 | + } catch (PDOException $e) { |
|
| 860 | 860 | return "error (add forsource column) : ".$e->getMessage()."\n"; |
| 861 | 861 | } |
| 862 | 862 | } |
| 863 | - if (!$Connection->checkColumnName('stats_aircraft','stats_airline')) { |
|
| 863 | + if (!$Connection->checkColumnName('stats_aircraft', 'stats_airline')) { |
|
| 864 | 864 | // Add forsource to airlines |
| 865 | 865 | $query = "ALTER TABLE stats_aircraft ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
| 866 | 866 | try { |
| 867 | 867 | $sth = $Connection->db->prepare($query); |
| 868 | 868 | $sth->execute(); |
| 869 | - } catch(PDOException $e) { |
|
| 869 | + } catch (PDOException $e) { |
|
| 870 | 870 | return "error (add stats_airline & filter_name column in stats_aircraft) : ".$e->getMessage()."\n"; |
| 871 | 871 | } |
| 872 | 872 | // Add unique key |
@@ -878,17 +878,17 @@ discard block |
||
| 878 | 878 | try { |
| 879 | 879 | $sth = $Connection->db->prepare($query); |
| 880 | 880 | $sth->execute(); |
| 881 | - } catch(PDOException $e) { |
|
| 881 | + } catch (PDOException $e) { |
|
| 882 | 882 | return "error (add unique key in stats_aircraft) : ".$e->getMessage()."\n"; |
| 883 | 883 | } |
| 884 | 884 | } |
| 885 | - if (!$Connection->checkColumnName('stats_airport','stats_airline')) { |
|
| 885 | + if (!$Connection->checkColumnName('stats_airport', 'stats_airline')) { |
|
| 886 | 886 | // Add forsource to airlines |
| 887 | 887 | $query = "ALTER TABLE stats_airport ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
| 888 | 888 | try { |
| 889 | 889 | $sth = $Connection->db->prepare($query); |
| 890 | 890 | $sth->execute(); |
| 891 | - } catch(PDOException $e) { |
|
| 891 | + } catch (PDOException $e) { |
|
| 892 | 892 | return "error (add filter_name column in stats_airport) : ".$e->getMessage()."\n"; |
| 893 | 893 | } |
| 894 | 894 | // Add unique key |
@@ -900,17 +900,17 @@ discard block |
||
| 900 | 900 | try { |
| 901 | 901 | $sth = $Connection->db->prepare($query); |
| 902 | 902 | $sth->execute(); |
| 903 | - } catch(PDOException $e) { |
|
| 903 | + } catch (PDOException $e) { |
|
| 904 | 904 | return "error (add unique key in stats_airport) : ".$e->getMessage()."\n"; |
| 905 | 905 | } |
| 906 | 906 | } |
| 907 | - if (!$Connection->checkColumnName('stats_country','stats_airline')) { |
|
| 907 | + if (!$Connection->checkColumnName('stats_country', 'stats_airline')) { |
|
| 908 | 908 | // Add forsource to airlines |
| 909 | 909 | $query = "ALTER TABLE stats_country ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
| 910 | 910 | try { |
| 911 | 911 | $sth = $Connection->db->prepare($query); |
| 912 | 912 | $sth->execute(); |
| 913 | - } catch(PDOException $e) { |
|
| 913 | + } catch (PDOException $e) { |
|
| 914 | 914 | return "error (add stats_airline & filter_name column in stats_country) : ".$e->getMessage()."\n"; |
| 915 | 915 | } |
| 916 | 916 | // Add unique key |
@@ -922,37 +922,37 @@ discard block |
||
| 922 | 922 | try { |
| 923 | 923 | $sth = $Connection->db->prepare($query); |
| 924 | 924 | $sth->execute(); |
| 925 | - } catch(PDOException $e) { |
|
| 925 | + } catch (PDOException $e) { |
|
| 926 | 926 | return "error (add unique key in stats_airline) : ".$e->getMessage()."\n"; |
| 927 | 927 | } |
| 928 | 928 | } |
| 929 | - if (!$Connection->checkColumnName('stats_flight','stats_airline')) { |
|
| 929 | + if (!$Connection->checkColumnName('stats_flight', 'stats_airline')) { |
|
| 930 | 930 | // Add forsource to airlines |
| 931 | 931 | $query = "ALTER TABLE stats_flight ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
| 932 | 932 | try { |
| 933 | 933 | $sth = $Connection->db->prepare($query); |
| 934 | 934 | $sth->execute(); |
| 935 | - } catch(PDOException $e) { |
|
| 935 | + } catch (PDOException $e) { |
|
| 936 | 936 | return "error (add stats_airline & filter_name column in stats_flight) : ".$e->getMessage()."\n"; |
| 937 | 937 | } |
| 938 | 938 | } |
| 939 | - if (!$Connection->checkColumnName('stats','stats_airline')) { |
|
| 939 | + if (!$Connection->checkColumnName('stats', 'stats_airline')) { |
|
| 940 | 940 | // Add forsource to airlines |
| 941 | 941 | $query = "ALTER TABLE stats ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
| 942 | 942 | try { |
| 943 | 943 | $sth = $Connection->db->prepare($query); |
| 944 | 944 | $sth->execute(); |
| 945 | - } catch(PDOException $e) { |
|
| 945 | + } catch (PDOException $e) { |
|
| 946 | 946 | return "error (add stats_airline & filter_name column in stats) : ".$e->getMessage()."\n"; |
| 947 | 947 | } |
| 948 | 948 | } |
| 949 | - if ($globalDBdriver == 'mysql' && $Connection->indexExists('stats','type')) { |
|
| 949 | + if ($globalDBdriver == 'mysql' && $Connection->indexExists('stats', 'type')) { |
|
| 950 | 950 | // Add unique key |
| 951 | 951 | $query = "drop index type on stats;ALTER TABLE stats ADD UNIQUE stats_type (stats_type,stats_date,stats_airline,filter_name);"; |
| 952 | 952 | try { |
| 953 | 953 | $sth = $Connection->db->prepare($query); |
| 954 | 954 | $sth->execute(); |
| 955 | - } catch(PDOException $e) { |
|
| 955 | + } catch (PDOException $e) { |
|
| 956 | 956 | return "error (add unique key in stats) : ".$e->getMessage()."\n"; |
| 957 | 957 | } |
| 958 | 958 | |
@@ -966,17 +966,17 @@ discard block |
||
| 966 | 966 | try { |
| 967 | 967 | $sth = $Connection->db->prepare($query); |
| 968 | 968 | $sth->execute(); |
| 969 | - } catch(PDOException $e) { |
|
| 969 | + } catch (PDOException $e) { |
|
| 970 | 970 | return "error (add unique key in stats) : ".$e->getMessage()."\n"; |
| 971 | 971 | } |
| 972 | 972 | } |
| 973 | - if (!$Connection->checkColumnName('stats_registration','stats_airline')) { |
|
| 973 | + if (!$Connection->checkColumnName('stats_registration', 'stats_airline')) { |
|
| 974 | 974 | // Add forsource to airlines |
| 975 | 975 | $query = "ALTER TABLE stats_registration ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
| 976 | 976 | try { |
| 977 | 977 | $sth = $Connection->db->prepare($query); |
| 978 | 978 | $sth->execute(); |
| 979 | - } catch(PDOException $e) { |
|
| 979 | + } catch (PDOException $e) { |
|
| 980 | 980 | return "error (add stats_airline & filter_name column in stats_registration) : ".$e->getMessage()."\n"; |
| 981 | 981 | } |
| 982 | 982 | // Add unique key |
@@ -988,17 +988,17 @@ discard block |
||
| 988 | 988 | try { |
| 989 | 989 | $sth = $Connection->db->prepare($query); |
| 990 | 990 | $sth->execute(); |
| 991 | - } catch(PDOException $e) { |
|
| 991 | + } catch (PDOException $e) { |
|
| 992 | 992 | return "error (add unique key in stats_registration) : ".$e->getMessage()."\n"; |
| 993 | 993 | } |
| 994 | 994 | } |
| 995 | - if (!$Connection->checkColumnName('stats_callsign','filter_name')) { |
|
| 995 | + if (!$Connection->checkColumnName('stats_callsign', 'filter_name')) { |
|
| 996 | 996 | // Add forsource to airlines |
| 997 | 997 | $query = "ALTER TABLE stats_callsign ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
| 998 | 998 | try { |
| 999 | 999 | $sth = $Connection->db->prepare($query); |
| 1000 | 1000 | $sth->execute(); |
| 1001 | - } catch(PDOException $e) { |
|
| 1001 | + } catch (PDOException $e) { |
|
| 1002 | 1002 | return "error (add filter_name column in stats_callsign) : ".$e->getMessage()."\n"; |
| 1003 | 1003 | } |
| 1004 | 1004 | // Add unique key |
@@ -1010,17 +1010,17 @@ discard block |
||
| 1010 | 1010 | try { |
| 1011 | 1011 | $sth = $Connection->db->prepare($query); |
| 1012 | 1012 | $sth->execute(); |
| 1013 | - } catch(PDOException $e) { |
|
| 1013 | + } catch (PDOException $e) { |
|
| 1014 | 1014 | return "error (add unique key in stats_callsign) : ".$e->getMessage()."\n"; |
| 1015 | 1015 | } |
| 1016 | 1016 | } |
| 1017 | - if (!$Connection->checkColumnName('stats_airline','filter_name')) { |
|
| 1017 | + if (!$Connection->checkColumnName('stats_airline', 'filter_name')) { |
|
| 1018 | 1018 | // Add forsource to airlines |
| 1019 | 1019 | $query = "ALTER TABLE stats_airline ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
| 1020 | 1020 | try { |
| 1021 | 1021 | $sth = $Connection->db->prepare($query); |
| 1022 | 1022 | $sth->execute(); |
| 1023 | - } catch(PDOException $e) { |
|
| 1023 | + } catch (PDOException $e) { |
|
| 1024 | 1024 | return "error (add filter_name column in stats_airline) : ".$e->getMessage()."\n"; |
| 1025 | 1025 | } |
| 1026 | 1026 | // Add unique key |
@@ -1032,7 +1032,7 @@ discard block |
||
| 1032 | 1032 | try { |
| 1033 | 1033 | $sth = $Connection->db->prepare($query); |
| 1034 | 1034 | $sth->execute(); |
| 1035 | - } catch(PDOException $e) { |
|
| 1035 | + } catch (PDOException $e) { |
|
| 1036 | 1036 | return "error (add unique key in stats_callsign) : ".$e->getMessage()."\n"; |
| 1037 | 1037 | } |
| 1038 | 1038 | } |
@@ -1041,7 +1041,7 @@ discard block |
||
| 1041 | 1041 | try { |
| 1042 | 1042 | $sth = $Connection->db->prepare($query); |
| 1043 | 1043 | $sth->execute(); |
| 1044 | - } catch(PDOException $e) { |
|
| 1044 | + } catch (PDOException $e) { |
|
| 1045 | 1045 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 1046 | 1046 | } |
| 1047 | 1047 | return $error; |
@@ -1051,13 +1051,13 @@ discard block |
||
| 1051 | 1051 | global $globalDBdriver; |
| 1052 | 1052 | $Connection = new Connection(); |
| 1053 | 1053 | $error = ''; |
| 1054 | - if (!$Connection->checkColumnName('stats_owner','stats_airline')) { |
|
| 1054 | + if (!$Connection->checkColumnName('stats_owner', 'stats_airline')) { |
|
| 1055 | 1055 | // Add forsource to airlines |
| 1056 | 1056 | $query = "ALTER TABLE stats_owner ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
| 1057 | 1057 | try { |
| 1058 | 1058 | $sth = $Connection->db->prepare($query); |
| 1059 | 1059 | $sth->execute(); |
| 1060 | - } catch(PDOException $e) { |
|
| 1060 | + } catch (PDOException $e) { |
|
| 1061 | 1061 | return "error (add stats_airline & filter_name column in stats_owner) : ".$e->getMessage()."\n"; |
| 1062 | 1062 | } |
| 1063 | 1063 | // Add unique key |
@@ -1069,17 +1069,17 @@ discard block |
||
| 1069 | 1069 | try { |
| 1070 | 1070 | $sth = $Connection->db->prepare($query); |
| 1071 | 1071 | $sth->execute(); |
| 1072 | - } catch(PDOException $e) { |
|
| 1072 | + } catch (PDOException $e) { |
|
| 1073 | 1073 | return "error (add unique key in stats_owner) : ".$e->getMessage()."\n"; |
| 1074 | 1074 | } |
| 1075 | 1075 | } |
| 1076 | - if (!$Connection->checkColumnName('stats_pilot','stats_airline')) { |
|
| 1076 | + if (!$Connection->checkColumnName('stats_pilot', 'stats_airline')) { |
|
| 1077 | 1077 | // Add forsource to airlines |
| 1078 | 1078 | $query = "ALTER TABLE stats_pilot ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
| 1079 | 1079 | try { |
| 1080 | 1080 | $sth = $Connection->db->prepare($query); |
| 1081 | 1081 | $sth->execute(); |
| 1082 | - } catch(PDOException $e) { |
|
| 1082 | + } catch (PDOException $e) { |
|
| 1083 | 1083 | return "error (add stats_airline & filter_name column in stats_pilot) : ".$e->getMessage()."\n"; |
| 1084 | 1084 | } |
| 1085 | 1085 | // Add unique key |
@@ -1091,7 +1091,7 @@ discard block |
||
| 1091 | 1091 | try { |
| 1092 | 1092 | $sth = $Connection->db->prepare($query); |
| 1093 | 1093 | $sth->execute(); |
| 1094 | - } catch(PDOException $e) { |
|
| 1094 | + } catch (PDOException $e) { |
|
| 1095 | 1095 | return "error (add unique key in stats_pilot) : ".$e->getMessage()."\n"; |
| 1096 | 1096 | } |
| 1097 | 1097 | } |
@@ -1099,7 +1099,7 @@ discard block |
||
| 1099 | 1099 | try { |
| 1100 | 1100 | $sth = $Connection->db->prepare($query); |
| 1101 | 1101 | $sth->execute(); |
| 1102 | - } catch(PDOException $e) { |
|
| 1102 | + } catch (PDOException $e) { |
|
| 1103 | 1103 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
| 1104 | 1104 | } |
| 1105 | 1105 | return $error; |
@@ -1122,7 +1122,7 @@ discard block |
||
| 1122 | 1122 | try { |
| 1123 | 1123 | $sth = $Connection->db->prepare($query); |
| 1124 | 1124 | $sth->execute(); |
| 1125 | - } catch(PDOException $e) { |
|
| 1125 | + } catch (PDOException $e) { |
|
| 1126 | 1126 | return "error : ".$e->getMessage()."\n"; |
| 1127 | 1127 | } |
| 1128 | 1128 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -24,20 +24,20 @@ discard block |
||
| 24 | 24 | fclose($fp); |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - public static function gunzip($in_file,$out_file_name = '') { |
|
| 27 | + public static function gunzip($in_file, $out_file_name = '') { |
|
| 28 | 28 | //echo $in_file.' -> '.$out_file_name."\n"; |
| 29 | 29 | $buffer_size = 4096; // read 4kb at a time |
| 30 | 30 | if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); |
| 31 | 31 | if ($in_file != '' && file_exists($in_file)) { |
| 32 | 32 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
| 33 | - if (function_exists('gzopen')) $file = gzopen($in_file,'rb'); |
|
| 34 | - elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb'); |
|
| 33 | + if (function_exists('gzopen')) $file = gzopen($in_file, 'rb'); |
|
| 34 | + elseif (function_exists('gzopen64')) $file = gzopen64($in_file, 'rb'); |
|
| 35 | 35 | else { |
| 36 | 36 | echo 'gzopen not available'; |
| 37 | 37 | die; |
| 38 | 38 | } |
| 39 | 39 | $out_file = fopen($out_file_name, 'wb'); |
| 40 | - while(!gzeof($file)) { |
|
| 40 | + while (!gzeof($file)) { |
|
| 41 | 41 | fwrite($out_file, gzread($file, $buffer_size)); |
| 42 | 42 | } |
| 43 | 43 | fclose($out_file); |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | try { |
| 62 | 62 | self::$db_sqlite = new PDO('sqlite:'.$database); |
| 63 | 63 | self::$db_sqlite->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
| 64 | - } catch(PDOException $e) { |
|
| 64 | + } catch (PDOException $e) { |
|
| 65 | 65 | return "error : ".$e->getMessage(); |
| 66 | 66 | } |
| 67 | 67 | } |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | //$Connection = new Connection(); |
| 77 | 77 | $sth = $Connection->db->prepare($query); |
| 78 | 78 | $sth->execute(array(':source' => $database_file)); |
| 79 | - } catch(PDOException $e) { |
|
| 79 | + } catch (PDOException $e) { |
|
| 80 | 80 | return "error : ".$e->getMessage(); |
| 81 | 81 | } |
| 82 | 82 | |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | try { |
| 88 | 88 | $sth = update_db::$db_sqlite->prepare($query); |
| 89 | 89 | $sth->execute(); |
| 90 | - } catch(PDOException $e) { |
|
| 90 | + } catch (PDOException $e) { |
|
| 91 | 91 | return "error : ".$e->getMessage(); |
| 92 | 92 | } |
| 93 | 93 | //$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)'; |
@@ -98,11 +98,11 @@ discard block |
||
| 98 | 98 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 99 | 99 | while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
| 100 | 100 | //$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
| 101 | - $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); |
|
| 101 | + $query_dest_values = array(':CallSign' => $values['Callsign'], ':Operator_ICAO' => $values['operator_icao'], ':FromAirport_ICAO' => $values['FromAirportIcao'], ':ToAirport_ICAO' => $values['ToAirportIcao'], ':routestop' => $values['AllStop'], ':source' => $database_file); |
|
| 102 | 102 | $sth_dest->execute($query_dest_values); |
| 103 | 103 | } |
| 104 | 104 | if ($globalTransaction) $Connection->db->commit(); |
| 105 | - } catch(PDOException $e) { |
|
| 105 | + } catch (PDOException $e) { |
|
| 106 | 106 | if ($globalTransaction) $Connection->db->rollBack(); |
| 107 | 107 | return "error : ".$e->getMessage(); |
| 108 | 108 | } |
@@ -118,26 +118,26 @@ discard block |
||
| 118 | 118 | //$Connection = new Connection(); |
| 119 | 119 | $sth = $Connection->db->prepare($query); |
| 120 | 120 | $sth->execute(array(':source' => 'oneworld')); |
| 121 | - } catch(PDOException $e) { |
|
| 121 | + } catch (PDOException $e) { |
|
| 122 | 122 | return "error : ".$e->getMessage(); |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | if ($globalDebug) echo " - Add routes to DB -"; |
| 126 | 126 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 127 | 127 | $Spotter = new Spotter(); |
| 128 | - if ($fh = fopen($database_file,"r")) { |
|
| 128 | + if ($fh = fopen($database_file, "r")) { |
|
| 129 | 129 | $query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)'; |
| 130 | 130 | $Connection = new Connection(); |
| 131 | 131 | $sth_dest = $Connection->db->prepare($query_dest); |
| 132 | 132 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 133 | 133 | while (!feof($fh)) { |
| 134 | - $line = fgetcsv($fh,9999,','); |
|
| 134 | + $line = fgetcsv($fh, 9999, ','); |
|
| 135 | 135 | if ($line[0] != '') { |
| 136 | 136 | if (($line[2] == '-' || ($line[2] != '-' && (strtotime($line[2]) > time()))) && ($line[3] == '-' || ($line[3] != '-' && (strtotime($line[3]) < time())))) { |
| 137 | 137 | try { |
| 138 | - $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'); |
|
| 138 | + $query_dest_values = array(':CallSign' => str_replace('*', '', $line[7]), ':Operator_ICAO' => '', ':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]), ':FromAirport_Time' => $line[5], ':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]), ':ToAirport_Time' => $line[6], ':routestop' => '', ':source' => 'oneworld'); |
|
| 139 | 139 | $sth_dest->execute($query_dest_values); |
| 140 | - } catch(PDOException $e) { |
|
| 140 | + } catch (PDOException $e) { |
|
| 141 | 141 | if ($globalTransaction) $Connection->db->rollBack(); |
| 142 | 142 | return "error : ".$e->getMessage(); |
| 143 | 143 | } |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | //$Connection = new Connection(); |
| 160 | 160 | $sth = $Connection->db->prepare($query); |
| 161 | 161 | $sth->execute(array(':source' => 'skyteam')); |
| 162 | - } catch(PDOException $e) { |
|
| 162 | + } catch (PDOException $e) { |
|
| 163 | 163 | return "error : ".$e->getMessage(); |
| 164 | 164 | } |
| 165 | 165 | |
@@ -167,24 +167,24 @@ discard block |
||
| 167 | 167 | |
| 168 | 168 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 169 | 169 | $Spotter = new Spotter(); |
| 170 | - if ($fh = fopen($database_file,"r")) { |
|
| 170 | + if ($fh = fopen($database_file, "r")) { |
|
| 171 | 171 | $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)'; |
| 172 | 172 | $Connection = new Connection(); |
| 173 | 173 | $sth_dest = $Connection->db->prepare($query_dest); |
| 174 | 174 | try { |
| 175 | 175 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 176 | 176 | while (!feof($fh)) { |
| 177 | - $line = fgetcsv($fh,9999,','); |
|
| 177 | + $line = fgetcsv($fh, 9999, ','); |
|
| 178 | 178 | if ($line[0] != '') { |
| 179 | 179 | //$datebe = explode(' - ',$line[2]); |
| 180 | 180 | //if (strtotime($datebe[0]) > time() && strtotime($datebe[1]) < time()) { |
| 181 | - $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'); |
|
| 181 | + $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'); |
|
| 182 | 182 | $sth_dest->execute($query_dest_values); |
| 183 | 183 | //} |
| 184 | 184 | } |
| 185 | 185 | } |
| 186 | 186 | if ($globalTransaction) $Connection->db->commit(); |
| 187 | - } catch(PDOException $e) { |
|
| 187 | + } catch (PDOException $e) { |
|
| 188 | 188 | if ($globalTransaction) $Connection->db->rollBack(); |
| 189 | 189 | return "error : ".$e->getMessage(); |
| 190 | 190 | } |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | $Connection = new Connection(); |
| 200 | 200 | $sth = $Connection->db->prepare($query); |
| 201 | 201 | $sth->execute(array(':source' => $database_file)); |
| 202 | - } catch(PDOException $e) { |
|
| 202 | + } catch (PDOException $e) { |
|
| 203 | 203 | return "error : ".$e->getMessage(); |
| 204 | 204 | } |
| 205 | 205 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source"; |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | $Connection = new Connection(); |
| 208 | 208 | $sth = $Connection->db->prepare($query); |
| 209 | 209 | $sth->execute(array(':source' => $database_file)); |
| 210 | - } catch(PDOException $e) { |
|
| 210 | + } catch (PDOException $e) { |
|
| 211 | 211 | return "error : ".$e->getMessage(); |
| 212 | 212 | } |
| 213 | 213 | |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | try { |
| 217 | 217 | $sth = update_db::$db_sqlite->prepare($query); |
| 218 | 218 | $sth->execute(); |
| 219 | - } catch(PDOException $e) { |
|
| 219 | + } catch (PDOException $e) { |
|
| 220 | 220 | return "error : ".$e->getMessage(); |
| 221 | 221 | } |
| 222 | 222 | //$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,15 +233,15 @@ discard block |
||
| 233 | 233 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
| 234 | 234 | if ($values['UserString4'] == 'M') $type = 'military'; |
| 235 | 235 | else $type = null; |
| 236 | - $query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type); |
|
| 236 | + $query_dest_values = array(':LastModified' => $values['LastModified'], ':ModeS' => $values['ModeS'], ':ModeSCountry' => $values['ModeSCountry'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':type' => $type); |
|
| 237 | 237 | $sth_dest->execute($query_dest_values); |
| 238 | 238 | if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') { |
| 239 | - $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']); |
|
| 239 | + $query_dest_owner_values = array(':registration' => $values['Registration'], ':source' => $database_file, ':owner' => $values['RegisteredOwners']); |
|
| 240 | 240 | $sth_dest_owner->execute($query_dest_owner_values); |
| 241 | 241 | } |
| 242 | 242 | } |
| 243 | 243 | if ($globalTransaction) $Connection->db->commit(); |
| 244 | - } catch(PDOException $e) { |
|
| 244 | + } catch (PDOException $e) { |
|
| 245 | 245 | return "error : ".$e->getMessage(); |
| 246 | 246 | } |
| 247 | 247 | |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | $Connection = new Connection(); |
| 251 | 251 | $sth = $Connection->db->prepare($query); |
| 252 | 252 | $sth->execute(array(':source' => $database_file)); |
| 253 | - } catch(PDOException $e) { |
|
| 253 | + } catch (PDOException $e) { |
|
| 254 | 254 | return "error : ".$e->getMessage(); |
| 255 | 255 | } |
| 256 | 256 | return ''; |
@@ -265,11 +265,11 @@ discard block |
||
| 265 | 265 | $Connection = new Connection(); |
| 266 | 266 | $sth = $Connection->db->prepare($query); |
| 267 | 267 | $sth->execute(array(':source' => $database_file)); |
| 268 | - } catch(PDOException $e) { |
|
| 268 | + } catch (PDOException $e) { |
|
| 269 | 269 | return "error : ".$e->getMessage(); |
| 270 | 270 | } |
| 271 | 271 | |
| 272 | - if ($fh = fopen($database_file,"r")) { |
|
| 272 | + if ($fh = fopen($database_file, "r")) { |
|
| 273 | 273 | //$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)'; |
| 274 | 274 | $query_dest = 'INSERT INTO aircraft_modes (ModeS,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:Registration,:ICAOTypeCode,:source)'; |
| 275 | 275 | |
@@ -279,13 +279,13 @@ discard block |
||
| 279 | 279 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 280 | 280 | while (!feof($fh)) { |
| 281 | 281 | $values = array(); |
| 282 | - $line = $Common->hex2str(fgets($fh,9999)); |
|
| 282 | + $line = $Common->hex2str(fgets($fh, 9999)); |
|
| 283 | 283 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
| 284 | - $values['ModeS'] = substr($line,0,6); |
|
| 285 | - $values['Registration'] = trim(substr($line,69,6)); |
|
| 286 | - $aircraft_name = trim(substr($line,48,6)); |
|
| 284 | + $values['ModeS'] = substr($line, 0, 6); |
|
| 285 | + $values['Registration'] = trim(substr($line, 69, 6)); |
|
| 286 | + $aircraft_name = trim(substr($line, 48, 6)); |
|
| 287 | 287 | // Check if we can find ICAO, else set it to GLID |
| 288 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
| 288 | + $aircraft_name_split = explode(' ', $aircraft_name); |
|
| 289 | 289 | $search_more = ''; |
| 290 | 290 | if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
| 291 | 291 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
@@ -297,20 +297,20 @@ discard block |
||
| 297 | 297 | if (isset($result['icao']) && $result['icao'] != '') { |
| 298 | 298 | $values['ICAOTypeCode'] = $result['icao']; |
| 299 | 299 | } |
| 300 | - } catch(PDOException $e) { |
|
| 300 | + } catch (PDOException $e) { |
|
| 301 | 301 | return "error : ".$e->getMessage(); |
| 302 | 302 | } |
| 303 | 303 | if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID'; |
| 304 | 304 | // Add data to db |
| 305 | 305 | if ($values['ModeS'] != '' && $values['Registration'] != '' && $values['Registration'] != '0000') { |
| 306 | 306 | //$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']); |
| 307 | - $query_dest_values = array(':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file); |
|
| 307 | + $query_dest_values = array(':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file); |
|
| 308 | 308 | //print_r($query_dest_values); |
| 309 | 309 | $sth_dest->execute($query_dest_values); |
| 310 | 310 | } |
| 311 | 311 | } |
| 312 | 312 | if ($globalTransaction) $Connection->db->commit(); |
| 313 | - } catch(PDOException $e) { |
|
| 313 | + } catch (PDOException $e) { |
|
| 314 | 314 | return "error : ".$e->getMessage(); |
| 315 | 315 | } |
| 316 | 316 | } |
@@ -320,7 +320,7 @@ discard block |
||
| 320 | 320 | $Connection = new Connection(); |
| 321 | 321 | $sth = $Connection->db->prepare($query); |
| 322 | 322 | $sth->execute(array(':source' => $database_file)); |
| 323 | - } catch(PDOException $e) { |
|
| 323 | + } catch (PDOException $e) { |
|
| 324 | 324 | return "error : ".$e->getMessage(); |
| 325 | 325 | } |
| 326 | 326 | return ''; |
@@ -334,11 +334,11 @@ discard block |
||
| 334 | 334 | $Connection = new Connection(); |
| 335 | 335 | $sth = $Connection->db->prepare($query); |
| 336 | 336 | $sth->execute(array(':source' => $database_file)); |
| 337 | - } catch(PDOException $e) { |
|
| 337 | + } catch (PDOException $e) { |
|
| 338 | 338 | return "error : ".$e->getMessage(); |
| 339 | 339 | } |
| 340 | 340 | |
| 341 | - if ($fh = fopen($database_file,"r")) { |
|
| 341 | + if ($fh = fopen($database_file, "r")) { |
|
| 342 | 342 | //$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)'; |
| 343 | 343 | $query_dest = 'INSERT INTO aircraft_modes (ModeS,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:Registration,:ICAOTypeCode,:source)'; |
| 344 | 344 | |
@@ -346,9 +346,9 @@ discard block |
||
| 346 | 346 | $sth_dest = $Connection->db->prepare($query_dest); |
| 347 | 347 | try { |
| 348 | 348 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 349 | - $tmp = fgetcsv($fh,9999,',',"'"); |
|
| 349 | + $tmp = fgetcsv($fh, 9999, ',', "'"); |
|
| 350 | 350 | while (!feof($fh)) { |
| 351 | - $line = fgetcsv($fh,9999,',',"'"); |
|
| 351 | + $line = fgetcsv($fh, 9999, ',', "'"); |
|
| 352 | 352 | |
| 353 | 353 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
| 354 | 354 | //print_r($line); |
@@ -356,7 +356,7 @@ discard block |
||
| 356 | 356 | $values['Registration'] = $line[3]; |
| 357 | 357 | $aircraft_name = $line[2]; |
| 358 | 358 | // Check if we can find ICAO, else set it to GLID |
| 359 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
| 359 | + $aircraft_name_split = explode(' ', $aircraft_name); |
|
| 360 | 360 | $search_more = ''; |
| 361 | 361 | if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
| 362 | 362 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
@@ -365,20 +365,20 @@ discard block |
||
| 365 | 365 | $sth_search->execute(); |
| 366 | 366 | $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
| 367 | 367 | if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
| 368 | - } catch(PDOException $e) { |
|
| 368 | + } catch (PDOException $e) { |
|
| 369 | 369 | return "error : ".$e->getMessage(); |
| 370 | 370 | } |
| 371 | 371 | //if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID'; |
| 372 | 372 | // Add data to db |
| 373 | 373 | if ($values['ModeS'] != '' && $values['Registration'] != '' && $values['Registration'] != '0000' && $values['ICAOTypeCode'] != '') { |
| 374 | 374 | //$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']); |
| 375 | - $query_dest_values = array(':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file); |
|
| 375 | + $query_dest_values = array(':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file); |
|
| 376 | 376 | //print_r($query_dest_values); |
| 377 | 377 | $sth_dest->execute($query_dest_values); |
| 378 | 378 | } |
| 379 | 379 | } |
| 380 | 380 | if ($globalTransaction) $Connection->db->commit(); |
| 381 | - } catch(PDOException $e) { |
|
| 381 | + } catch (PDOException $e) { |
|
| 382 | 382 | return "error : ".$e->getMessage(); |
| 383 | 383 | } |
| 384 | 384 | } |
@@ -388,13 +388,13 @@ discard block |
||
| 388 | 388 | $Connection = new Connection(); |
| 389 | 389 | $sth = $Connection->db->prepare($query); |
| 390 | 390 | $sth->execute(array(':source' => $database_file)); |
| 391 | - } catch(PDOException $e) { |
|
| 391 | + } catch (PDOException $e) { |
|
| 392 | 392 | return "error : ".$e->getMessage(); |
| 393 | 393 | } |
| 394 | 394 | return ''; |
| 395 | 395 | } |
| 396 | 396 | |
| 397 | - public static function retrieve_owner($database_file,$country = 'F') { |
|
| 397 | + public static function retrieve_owner($database_file, $country = 'F') { |
|
| 398 | 398 | global $globalTransaction; |
| 399 | 399 | //$query = 'TRUNCATE TABLE aircraft_modes'; |
| 400 | 400 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source"; |
@@ -402,11 +402,11 @@ discard block |
||
| 402 | 402 | $Connection = new Connection(); |
| 403 | 403 | $sth = $Connection->db->prepare($query); |
| 404 | 404 | $sth->execute(array(':source' => $database_file)); |
| 405 | - } catch(PDOException $e) { |
|
| 405 | + } catch (PDOException $e) { |
|
| 406 | 406 | return "error : ".$e->getMessage(); |
| 407 | 407 | } |
| 408 | 408 | |
| 409 | - if ($fh = fopen($database_file,"r")) { |
|
| 409 | + if ($fh = fopen($database_file, "r")) { |
|
| 410 | 410 | //$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)'; |
| 411 | 411 | $query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)'; |
| 412 | 412 | |
@@ -414,9 +414,9 @@ discard block |
||
| 414 | 414 | $sth_dest = $Connection->db->prepare($query_dest); |
| 415 | 415 | try { |
| 416 | 416 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 417 | - $tmp = fgetcsv($fh,9999,',','"'); |
|
| 417 | + $tmp = fgetcsv($fh, 9999, ',', '"'); |
|
| 418 | 418 | while (!feof($fh)) { |
| 419 | - $line = fgetcsv($fh,9999,',','"'); |
|
| 419 | + $line = fgetcsv($fh, 9999, ',', '"'); |
|
| 420 | 420 | $values = array(); |
| 421 | 421 | //print_r($line); |
| 422 | 422 | if ($country == 'F') { |
@@ -424,7 +424,7 @@ discard block |
||
| 424 | 424 | $values['base'] = $line[4]; |
| 425 | 425 | $values['owner'] = $line[5]; |
| 426 | 426 | if ($line[6] == '') $values['date_first_reg'] = null; |
| 427 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 427 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6])); |
|
| 428 | 428 | $values['cancel'] = $line[7]; |
| 429 | 429 | } elseif ($country == 'EI') { |
| 430 | 430 | // TODO : add modeS & reg to aircraft_modes |
@@ -432,7 +432,7 @@ discard block |
||
| 432 | 432 | $values['base'] = $line[3]; |
| 433 | 433 | $values['owner'] = $line[2]; |
| 434 | 434 | if ($line[1] == '') $values['date_first_reg'] = null; |
| 435 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
| 435 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[1])); |
|
| 436 | 436 | $values['cancel'] = ''; |
| 437 | 437 | } elseif ($country == 'HB') { |
| 438 | 438 | // TODO : add modeS & reg to aircraft_modes |
@@ -447,7 +447,7 @@ discard block |
||
| 447 | 447 | $values['base'] = null; |
| 448 | 448 | $values['owner'] = $line[5]; |
| 449 | 449 | if ($line[18] == '') $values['date_first_reg'] = null; |
| 450 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
| 450 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[18])); |
|
| 451 | 451 | $values['cancel'] = ''; |
| 452 | 452 | } elseif ($country == 'VH') { |
| 453 | 453 | // TODO : add modeS & reg to aircraft_modes |
@@ -455,7 +455,7 @@ discard block |
||
| 455 | 455 | $values['base'] = null; |
| 456 | 456 | $values['owner'] = $line[12]; |
| 457 | 457 | if ($line[28] == '') $values['date_first_reg'] = null; |
| 458 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
| 458 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[28])); |
|
| 459 | 459 | |
| 460 | 460 | $values['cancel'] = $line[39]; |
| 461 | 461 | } elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { |
@@ -475,28 +475,28 @@ discard block |
||
| 475 | 475 | $values['base'] = null; |
| 476 | 476 | $values['owner'] = $line[8]; |
| 477 | 477 | if ($line[7] == '') $values['date_first_reg'] = null; |
| 478 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 478 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7])); |
|
| 479 | 479 | $values['cancel'] = ''; |
| 480 | 480 | } elseif ($country == 'PP') { |
| 481 | 481 | $values['registration'] = $line[0]; |
| 482 | 482 | $values['base'] = null; |
| 483 | 483 | $values['owner'] = $line[4]; |
| 484 | 484 | if ($line[6] == '') $values['date_first_reg'] = null; |
| 485 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 485 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6])); |
|
| 486 | 486 | $values['cancel'] = $line[7]; |
| 487 | 487 | } elseif ($country == 'E7') { |
| 488 | 488 | $values['registration'] = $line[0]; |
| 489 | 489 | $values['base'] = null; |
| 490 | 490 | $values['owner'] = $line[4]; |
| 491 | 491 | if ($line[5] == '') $values['date_first_reg'] = null; |
| 492 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
| 492 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[5])); |
|
| 493 | 493 | $values['cancel'] = ''; |
| 494 | 494 | } elseif ($country == '8Q') { |
| 495 | 495 | $values['registration'] = $line[0]; |
| 496 | 496 | $values['base'] = null; |
| 497 | 497 | $values['owner'] = $line[3]; |
| 498 | 498 | if ($line[7] == '') $values['date_first_reg'] = null; |
| 499 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 499 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7])); |
|
| 500 | 500 | $values['cancel'] = ''; |
| 501 | 501 | } elseif ($country == 'ZK' || $country == 'OM' || $country == 'TF') { |
| 502 | 502 | $values['registration'] = $line[0]; |
@@ -506,12 +506,12 @@ discard block |
||
| 506 | 506 | $values['cancel'] = ''; |
| 507 | 507 | } |
| 508 | 508 | if ($values['cancel'] == '' && $values['registration'] != null) { |
| 509 | - $query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file); |
|
| 509 | + $query_dest_values = array(':registration' => $values['registration'], ':base' => $values['base'], ':date_first_reg' => $values['date_first_reg'], ':owner' => $values['owner'], ':source' => $database_file); |
|
| 510 | 510 | $sth_dest->execute($query_dest_values); |
| 511 | 511 | } |
| 512 | 512 | } |
| 513 | 513 | if ($globalTransaction) $Connection->db->commit(); |
| 514 | - } catch(PDOException $e) { |
|
| 514 | + } catch (PDOException $e) { |
|
| 515 | 515 | return "error : ".$e->getMessage(); |
| 516 | 516 | } |
| 517 | 517 | } |
@@ -626,7 +626,7 @@ discard block |
||
| 626 | 626 | $Connection = new Connection(); |
| 627 | 627 | $sth = $Connection->db->prepare($query); |
| 628 | 628 | $sth->execute(); |
| 629 | - } catch(PDOException $e) { |
|
| 629 | + } catch (PDOException $e) { |
|
| 630 | 630 | return "error : ".$e->getMessage(); |
| 631 | 631 | } |
| 632 | 632 | |
@@ -636,7 +636,7 @@ discard block |
||
| 636 | 636 | $Connection = new Connection(); |
| 637 | 637 | $sth = $Connection->db->prepare($query); |
| 638 | 638 | $sth->execute(); |
| 639 | - } catch(PDOException $e) { |
|
| 639 | + } catch (PDOException $e) { |
|
| 640 | 640 | return "error : ".$e->getMessage(); |
| 641 | 641 | } |
| 642 | 642 | |
@@ -647,7 +647,7 @@ discard block |
||
| 647 | 647 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 648 | 648 | |
| 649 | 649 | $i = 0; |
| 650 | - while($row = sparql_fetch_array($result)) |
|
| 650 | + while ($row = sparql_fetch_array($result)) |
|
| 651 | 651 | { |
| 652 | 652 | if ($i >= 1) { |
| 653 | 653 | //print_r($row); |
@@ -667,31 +667,31 @@ discard block |
||
| 667 | 667 | $row['image'] = ''; |
| 668 | 668 | $row['image_thumb'] = ''; |
| 669 | 669 | } else { |
| 670 | - $image = str_replace(' ','_',$row['image']); |
|
| 670 | + $image = str_replace(' ', '_', $row['image']); |
|
| 671 | 671 | $digest = md5($image); |
| 672 | - $folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image . '/220px-' . $image; |
|
| 673 | - $row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/' . $folder; |
|
| 674 | - $folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image; |
|
| 675 | - $row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/' . $folder; |
|
| 672 | + $folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image.'/220px-'.$image; |
|
| 673 | + $row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/'.$folder; |
|
| 674 | + $folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image; |
|
| 675 | + $row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/'.$folder; |
|
| 676 | 676 | } |
| 677 | 677 | |
| 678 | - $country = explode('-',$row['country']); |
|
| 678 | + $country = explode('-', $row['country']); |
|
| 679 | 679 | $row['country'] = $country[0]; |
| 680 | 680 | |
| 681 | 681 | $row['type'] = trim($row['type']); |
| 682 | - 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'])) { |
|
| 682 | + 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'])) { |
|
| 683 | 683 | $row['type'] = 'Military'; |
| 684 | 684 | } 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') { |
| 685 | 685 | $row['type'] = 'small_airport'; |
| 686 | 686 | } |
| 687 | 687 | |
| 688 | - $row['city'] = urldecode(str_replace('_',' ',str_replace('http://dbpedia.org/resource/','',$row['city']))); |
|
| 689 | - $query_dest_values = array(':airport_id' => $i, ':name' => $row['name'],':iata' => $row['iata'],':icao' => $row['icao'],':latitude' => $row['latitude'],':longitude' => $row['longitude'],':altitude' => $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']); |
|
| 688 | + $row['city'] = urldecode(str_replace('_', ' ', str_replace('http://dbpedia.org/resource/', '', $row['city']))); |
|
| 689 | + $query_dest_values = array(':airport_id' => $i, ':name' => $row['name'], ':iata' => $row['iata'], ':icao' => $row['icao'], ':latitude' => $row['latitude'], ':longitude' => $row['longitude'], ':altitude' => $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']); |
|
| 690 | 690 | //print_r($query_dest_values); |
| 691 | 691 | |
| 692 | 692 | try { |
| 693 | 693 | $sth_dest->execute($query_dest_values); |
| 694 | - } catch(PDOException $e) { |
|
| 694 | + } catch (PDOException $e) { |
|
| 695 | 695 | return "error : ".$e->getMessage(); |
| 696 | 696 | } |
| 697 | 697 | } |
@@ -705,7 +705,7 @@ discard block |
||
| 705 | 705 | $Connection = new Connection(); |
| 706 | 706 | $sth = $Connection->db->prepare($query); |
| 707 | 707 | $sth->execute(); |
| 708 | - } catch(PDOException $e) { |
|
| 708 | + } catch (PDOException $e) { |
|
| 709 | 709 | return "error : ".$e->getMessage(); |
| 710 | 710 | } |
| 711 | 711 | |
@@ -713,12 +713,12 @@ discard block |
||
| 713 | 713 | if ($globalDebug) echo "Insert Not available Airport...\n"; |
| 714 | 714 | $query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image`,`image_thumb`) |
| 715 | 715 | VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image, :image_thumb)"; |
| 716 | - $query_values = array(':airport_id' => $i, ':name' => 'Not available',':iata' => 'NA',':icao' => 'NA',':latitude' => '0',':longitude' => '0',':altitude' => '0',':type' => 'NA',':city' => 'N/A',':country' => 'N/A',':home_link' => '',':wikipedia_link' => '',':image' => '',':image_thumb' => ''); |
|
| 716 | + $query_values = array(':airport_id' => $i, ':name' => 'Not available', ':iata' => 'NA', ':icao' => 'NA', ':latitude' => '0', ':longitude' => '0', ':altitude' => '0', ':type' => 'NA', ':city' => 'N/A', ':country' => 'N/A', ':home_link' => '', ':wikipedia_link' => '', ':image' => '', ':image_thumb' => ''); |
|
| 717 | 717 | try { |
| 718 | 718 | $Connection = new Connection(); |
| 719 | 719 | $sth = $Connection->db->prepare($query); |
| 720 | 720 | $sth->execute($query_values); |
| 721 | - } catch(PDOException $e) { |
|
| 721 | + } catch (PDOException $e) { |
|
| 722 | 722 | return "error : ".$e->getMessage(); |
| 723 | 723 | } |
| 724 | 724 | $i++; |
@@ -736,7 +736,7 @@ discard block |
||
| 736 | 736 | echo "Download data from ourairports.com...\n"; |
| 737 | 737 | $delimiter = ','; |
| 738 | 738 | $out_file = $tmp_dir.'airports.csv'; |
| 739 | - update_db::download('http://ourairports.com/data/airports.csv',$out_file); |
|
| 739 | + update_db::download('http://ourairports.com/data/airports.csv', $out_file); |
|
| 740 | 740 | if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
| 741 | 741 | echo "Add data from ourairports.com...\n"; |
| 742 | 742 | |
@@ -747,32 +747,32 @@ discard block |
||
| 747 | 747 | //$Connection->db->beginTransaction(); |
| 748 | 748 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 749 | 749 | { |
| 750 | - if(!$header) $header = $row; |
|
| 750 | + if (!$header) $header = $row; |
|
| 751 | 751 | else { |
| 752 | 752 | $data = array(); |
| 753 | 753 | $data = array_combine($header, $row); |
| 754 | 754 | try { |
| 755 | 755 | $sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE `icao` = :icao'); |
| 756 | 756 | $sth->execute(array(':icao' => $data['gps_code'])); |
| 757 | - } catch(PDOException $e) { |
|
| 757 | + } catch (PDOException $e) { |
|
| 758 | 758 | return "error : ".$e->getMessage(); |
| 759 | 759 | } |
| 760 | 760 | if ($sth->fetchColumn() > 0) { |
| 761 | 761 | $query = 'UPDATE airport SET `type` = :type WHERE icao = :icao'; |
| 762 | 762 | try { |
| 763 | 763 | $sth = $Connection->db->prepare($query); |
| 764 | - $sth->execute(array(':icao' => $data['gps_code'],':type' => $data['type'])); |
|
| 765 | - } catch(PDOException $e) { |
|
| 764 | + $sth->execute(array(':icao' => $data['gps_code'], ':type' => $data['type'])); |
|
| 765 | + } catch (PDOException $e) { |
|
| 766 | 766 | return "error : ".$e->getMessage(); |
| 767 | 767 | } |
| 768 | 768 | } else { |
| 769 | 769 | $query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`) |
| 770 | 770 | VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link)"; |
| 771 | - $query_values = array(':airport_id' => $i, ':name' => $data['name'],':iata' => $data['iata_code'],':icao' => $data['gps_code'],':latitude' => $data['latitude_deg'],':longitude' => $data['longitude_deg'],':altitude' => $data['elevation_ft'],':type' => $data['type'],':city' => $data['municipality'],':country' => $data['iso_country'],':home_link' => $data['home_link'],':wikipedia_link' => $data['wikipedia_link']); |
|
| 771 | + $query_values = array(':airport_id' => $i, ':name' => $data['name'], ':iata' => $data['iata_code'], ':icao' => $data['gps_code'], ':latitude' => $data['latitude_deg'], ':longitude' => $data['longitude_deg'], ':altitude' => $data['elevation_ft'], ':type' => $data['type'], ':city' => $data['municipality'], ':country' => $data['iso_country'], ':home_link' => $data['home_link'], ':wikipedia_link' => $data['wikipedia_link']); |
|
| 772 | 772 | try { |
| 773 | 773 | $sth = $Connection->db->prepare($query); |
| 774 | 774 | $sth->execute($query_values); |
| 775 | - } catch(PDOException $e) { |
|
| 775 | + } catch (PDOException $e) { |
|
| 776 | 776 | return "error : ".$e->getMessage(); |
| 777 | 777 | } |
| 778 | 778 | $i++; |
@@ -785,7 +785,7 @@ discard block |
||
| 785 | 785 | |
| 786 | 786 | echo "Download data from another free database...\n"; |
| 787 | 787 | $out_file = $tmp_dir.'GlobalAirportDatabase.zip'; |
| 788 | - update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file); |
|
| 788 | + update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip', $out_file); |
|
| 789 | 789 | if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
| 790 | 790 | update_db::unzip($out_file); |
| 791 | 791 | $header = NULL; |
@@ -797,15 +797,15 @@ discard block |
||
| 797 | 797 | //$Connection->db->beginTransaction(); |
| 798 | 798 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 799 | 799 | { |
| 800 | - if(!$header) $header = $row; |
|
| 800 | + if (!$header) $header = $row; |
|
| 801 | 801 | else { |
| 802 | 802 | $data = $row; |
| 803 | 803 | |
| 804 | 804 | $query = 'UPDATE airport SET `city` = :city, `country` = :country WHERE icao = :icao'; |
| 805 | 805 | try { |
| 806 | 806 | $sth = $Connection->db->prepare($query); |
| 807 | - $sth->execute(array(':icao' => $data[0],':city' => ucwords(strtolower($data[3])),':country' => ucwords(strtolower($data[4])))); |
|
| 808 | - } catch(PDOException $e) { |
|
| 807 | + $sth->execute(array(':icao' => $data[0], ':city' => ucwords(strtolower($data[3])), ':country' => ucwords(strtolower($data[4])))); |
|
| 808 | + } catch (PDOException $e) { |
|
| 809 | 809 | return "error : ".$e->getMessage(); |
| 810 | 810 | } |
| 811 | 811 | } |
@@ -819,15 +819,15 @@ discard block |
||
| 819 | 819 | try { |
| 820 | 820 | $sth = $Connection->db->prepare("SELECT icao FROM airport WHERE `name` LIKE '%Air Base%'"); |
| 821 | 821 | $sth->execute(); |
| 822 | - } catch(PDOException $e) { |
|
| 822 | + } catch (PDOException $e) { |
|
| 823 | 823 | return "error : ".$e->getMessage(); |
| 824 | 824 | } |
| 825 | 825 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
| 826 | 826 | $query2 = 'UPDATE airport SET `type` = :type WHERE icao = :icao'; |
| 827 | 827 | try { |
| 828 | 828 | $sth2 = $Connection->db->prepare($query2); |
| 829 | - $sth2->execute(array(':icao' => $row['icao'],':type' => 'military')); |
|
| 830 | - } catch(PDOException $e) { |
|
| 829 | + $sth2->execute(array(':icao' => $row['icao'], ':type' => 'military')); |
|
| 830 | + } catch (PDOException $e) { |
|
| 831 | 831 | return "error : ".$e->getMessage(); |
| 832 | 832 | } |
| 833 | 833 | } |
@@ -851,7 +851,7 @@ discard block |
||
| 851 | 851 | $Connection = new Connection(); |
| 852 | 852 | $sth = $Connection->db->prepare($query); |
| 853 | 853 | $sth->execute(array(':source' => 'translation.csv')); |
| 854 | - } catch(PDOException $e) { |
|
| 854 | + } catch (PDOException $e) { |
|
| 855 | 855 | return "error : ".$e->getMessage(); |
| 856 | 856 | } |
| 857 | 857 | |
@@ -868,7 +868,7 @@ discard block |
||
| 868 | 868 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 869 | 869 | { |
| 870 | 870 | $i++; |
| 871 | - if($i > 12) { |
|
| 871 | + if ($i > 12) { |
|
| 872 | 872 | $data = $row; |
| 873 | 873 | $operator = $data[2]; |
| 874 | 874 | if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) { |
@@ -876,7 +876,7 @@ discard block |
||
| 876 | 876 | //echo substr($operator, 0, 2)."\n";; |
| 877 | 877 | if (count($airline_array) > 0) { |
| 878 | 878 | //print_r($airline_array); |
| 879 | - $operator = $airline_array[0]['icao'].substr($operator,2); |
|
| 879 | + $operator = $airline_array[0]['icao'].substr($operator, 2); |
|
| 880 | 880 | } |
| 881 | 881 | } |
| 882 | 882 | |
@@ -884,14 +884,14 @@ discard block |
||
| 884 | 884 | if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) { |
| 885 | 885 | $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2)); |
| 886 | 886 | if (count($airline_array) > 0) { |
| 887 | - $operator_correct = $airline_array[0]['icao'].substr($operator_correct,2); |
|
| 887 | + $operator_correct = $airline_array[0]['icao'].substr($operator_correct, 2); |
|
| 888 | 888 | } |
| 889 | 889 | } |
| 890 | 890 | $query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)'; |
| 891 | 891 | try { |
| 892 | 892 | $sth = $Connection->db->prepare($query); |
| 893 | - $sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $operator,':Operator_correct' => $operator_correct, ':source' => 'translation.csv')); |
|
| 894 | - } catch(PDOException $e) { |
|
| 893 | + $sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $operator, ':Operator_correct' => $operator_correct, ':source' => 'translation.csv')); |
|
| 894 | + } catch (PDOException $e) { |
|
| 895 | 895 | return "error : ".$e->getMessage(); |
| 896 | 896 | } |
| 897 | 897 | } |
@@ -911,7 +911,7 @@ discard block |
||
| 911 | 911 | $Connection = new Connection(); |
| 912 | 912 | $sth = $Connection->db->prepare($query); |
| 913 | 913 | $sth->execute(array(':source' => 'website_fam')); |
| 914 | - } catch(PDOException $e) { |
|
| 914 | + } catch (PDOException $e) { |
|
| 915 | 915 | return "error : ".$e->getMessage(); |
| 916 | 916 | } |
| 917 | 917 | |
@@ -931,8 +931,8 @@ discard block |
||
| 931 | 931 | $query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)'; |
| 932 | 932 | try { |
| 933 | 933 | $sth = $Connection->db->prepare($query); |
| 934 | - $sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $data[2],':Operator_correct' => $data[3], ':source' => 'website_fam')); |
|
| 935 | - } catch(PDOException $e) { |
|
| 934 | + $sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $data[2], ':Operator_correct' => $data[3], ':source' => 'website_fam')); |
|
| 935 | + } catch (PDOException $e) { |
|
| 936 | 936 | return "error : ".$e->getMessage(); |
| 937 | 937 | } |
| 938 | 938 | } |
@@ -944,7 +944,7 @@ discard block |
||
| 944 | 944 | return ''; |
| 945 | 945 | } |
| 946 | 946 | |
| 947 | - public static function tle($filename,$tletype) { |
|
| 947 | + public static function tle($filename, $tletype) { |
|
| 948 | 948 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 949 | 949 | global $tmp_dir, $globalTransaction; |
| 950 | 950 | //$Spotter = new Spotter(); |
@@ -954,7 +954,7 @@ discard block |
||
| 954 | 954 | $Connection = new Connection(); |
| 955 | 955 | $sth = $Connection->db->prepare($query); |
| 956 | 956 | $sth->execute(array(':source' => $filename)); |
| 957 | - } catch(PDOException $e) { |
|
| 957 | + } catch (PDOException $e) { |
|
| 958 | 958 | return "error : ".$e->getMessage(); |
| 959 | 959 | } |
| 960 | 960 | |
@@ -979,8 +979,8 @@ discard block |
||
| 979 | 979 | $query = 'INSERT INTO tle (tle_name,tle_tle1,tle_tle2,tle_type,tle_source) VALUES (:name, :tle1, :tle2, :type, :source)'; |
| 980 | 980 | try { |
| 981 | 981 | $sth = $Connection->db->prepare($query); |
| 982 | - $sth->execute(array(':name' => $dbdata['name'],':tle1' => $dbdata['tle1'],':tle2' => $dbdata['tle2'], ':type' => $tletype,':source' => $filename)); |
|
| 983 | - } catch(PDOException $e) { |
|
| 982 | + $sth->execute(array(':name' => $dbdata['name'], ':tle1' => $dbdata['tle1'], ':tle2' => $dbdata['tle2'], ':type' => $tletype, ':source' => $filename)); |
|
| 983 | + } catch (PDOException $e) { |
|
| 984 | 984 | return "error : ".$e->getMessage(); |
| 985 | 985 | } |
| 986 | 986 | |
@@ -1000,28 +1000,28 @@ discard block |
||
| 1000 | 1000 | */ |
| 1001 | 1001 | private static function table2array($data) { |
| 1002 | 1002 | $html = str_get_html($data); |
| 1003 | - $tabledata=array(); |
|
| 1004 | - foreach($html->find('tr') as $element) |
|
| 1003 | + $tabledata = array(); |
|
| 1004 | + foreach ($html->find('tr') as $element) |
|
| 1005 | 1005 | { |
| 1006 | 1006 | $td = array(); |
| 1007 | - foreach( $element->find('th') as $row) |
|
| 1007 | + foreach ($element->find('th') as $row) |
|
| 1008 | 1008 | { |
| 1009 | 1009 | $td [] = trim($row->plaintext); |
| 1010 | 1010 | } |
| 1011 | - $td=array_filter($td); |
|
| 1011 | + $td = array_filter($td); |
|
| 1012 | 1012 | $tabledata[] = $td; |
| 1013 | 1013 | |
| 1014 | 1014 | $td = array(); |
| 1015 | 1015 | $tdi = array(); |
| 1016 | - foreach( $element->find('td') as $row) |
|
| 1016 | + foreach ($element->find('td') as $row) |
|
| 1017 | 1017 | { |
| 1018 | 1018 | $td [] = trim($row->plaintext); |
| 1019 | 1019 | $tdi [] = trim($row->innertext); |
| 1020 | 1020 | } |
| 1021 | - $td=array_filter($td); |
|
| 1022 | - $tdi=array_filter($tdi); |
|
| 1021 | + $td = array_filter($td); |
|
| 1022 | + $tdi = array_filter($tdi); |
|
| 1023 | 1023 | // $tabledata[]=array_merge($td,$tdi); |
| 1024 | - $tabledata[]=$td; |
|
| 1024 | + $tabledata[] = $td; |
|
| 1025 | 1025 | } |
| 1026 | 1026 | return(array_filter($tabledata)); |
| 1027 | 1027 | } |
@@ -1094,13 +1094,13 @@ discard block |
||
| 1094 | 1094 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1095 | 1095 | { |
| 1096 | 1096 | $i++; |
| 1097 | - if($i > 3 && count($row) > 2) { |
|
| 1097 | + if ($i > 3 && count($row) > 2) { |
|
| 1098 | 1098 | $data = array_values(array_filter($row)); |
| 1099 | 1099 | $cntdata = count($data); |
| 1100 | 1100 | if ($cntdata > 10) { |
| 1101 | 1101 | $value = $data[9]; |
| 1102 | 1102 | |
| 1103 | - for ($i =10;$i < $cntdata;$i++) { |
|
| 1103 | + for ($i = 10; $i < $cntdata; $i++) { |
|
| 1104 | 1104 | $value .= ' '.$data[$i]; |
| 1105 | 1105 | } |
| 1106 | 1106 | $data[9] = $value; |
@@ -1110,8 +1110,8 @@ discard block |
||
| 1110 | 1110 | $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)'; |
| 1111 | 1111 | try { |
| 1112 | 1112 | $sth = $Connection->db->prepare($query); |
| 1113 | - $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])); |
|
| 1114 | - } catch(PDOException $e) { |
|
| 1113 | + $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])); |
|
| 1114 | + } catch (PDOException $e) { |
|
| 1115 | 1115 | return "error : ".$e->getMessage(); |
| 1116 | 1116 | } |
| 1117 | 1117 | } |
@@ -1132,7 +1132,7 @@ discard block |
||
| 1132 | 1132 | $Connection = new Connection(); |
| 1133 | 1133 | $sth = $Connection->db->prepare($query); |
| 1134 | 1134 | $sth->execute(); |
| 1135 | - } catch(PDOException $e) { |
|
| 1135 | + } catch (PDOException $e) { |
|
| 1136 | 1136 | return "error : ".$e->getMessage(); |
| 1137 | 1137 | } |
| 1138 | 1138 | |
@@ -1144,12 +1144,12 @@ discard block |
||
| 1144 | 1144 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 1145 | 1145 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1146 | 1146 | { |
| 1147 | - if(count($row) > 1) { |
|
| 1147 | + if (count($row) > 1) { |
|
| 1148 | 1148 | $query = "INSERT INTO airlines (name,icao,active,forsource) VALUES (:name, :icao, 'Y','ivao')"; |
| 1149 | 1149 | try { |
| 1150 | 1150 | $sth = $Connection->db->prepare($query); |
| 1151 | - $sth->execute(array(':name' => $row[1],':icao' => $row[0])); |
|
| 1152 | - } catch(PDOException $e) { |
|
| 1151 | + $sth->execute(array(':name' => $row[1], ':icao' => $row[0])); |
|
| 1152 | + } catch (PDOException $e) { |
|
| 1153 | 1153 | return "error : ".$e->getMessage(); |
| 1154 | 1154 | } |
| 1155 | 1155 | } |
@@ -1169,21 +1169,21 @@ discard block |
||
| 1169 | 1169 | try { |
| 1170 | 1170 | $sth = $Connection->db->prepare($query); |
| 1171 | 1171 | $sth->execute(); |
| 1172 | - } catch(PDOException $e) { |
|
| 1172 | + } catch (PDOException $e) { |
|
| 1173 | 1173 | return "error : ".$e->getMessage(); |
| 1174 | 1174 | } |
| 1175 | 1175 | } |
| 1176 | 1176 | |
| 1177 | 1177 | |
| 1178 | - if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
| 1178 | + if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz', $tmp_dir.'airspace.sql'); |
|
| 1179 | 1179 | else { |
| 1180 | - update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
| 1180 | + update_db::gunzip('../db/pgsql/airspace.sql.gz', $tmp_dir.'airspace.sql'); |
|
| 1181 | 1181 | $query = "CREATE EXTENSION postgis"; |
| 1182 | - $Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']); |
|
| 1182 | + $Connection = new Connection(null, null, $_SESSION['database_root'], $_SESSION['database_rootpass']); |
|
| 1183 | 1183 | try { |
| 1184 | 1184 | $sth = $Connection->db->prepare($query); |
| 1185 | 1185 | $sth->execute(); |
| 1186 | - } catch(PDOException $e) { |
|
| 1186 | + } catch (PDOException $e) { |
|
| 1187 | 1187 | return "error : ".$e->getMessage(); |
| 1188 | 1188 | } |
| 1189 | 1189 | } |
@@ -1196,7 +1196,7 @@ discard block |
||
| 1196 | 1196 | include_once('class.create_db.php'); |
| 1197 | 1197 | require_once(dirname(__FILE__).'/../require/class.NOTAM.php'); |
| 1198 | 1198 | if ($globalDebug) echo "NOTAM from FlightAirMap website : Download..."; |
| 1199 | - update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz'); |
|
| 1199 | + update_db::download('http://data.flightairmap.fr/data/notam.txt.gz', $tmp_dir.'notam.txt.gz'); |
|
| 1200 | 1200 | if (file_exists($tmp_dir.'notam.txt.gz')) { |
| 1201 | 1201 | if ($globalDebug) echo "Gunzip..."; |
| 1202 | 1202 | update_db::gunzip($tmp_dir.'notam.txt.gz'); |
@@ -1227,14 +1227,14 @@ discard block |
||
| 1227 | 1227 | try { |
| 1228 | 1228 | $sth = $Connection->db->prepare($query); |
| 1229 | 1229 | $sth->execute(); |
| 1230 | - } catch(PDOException $e) { |
|
| 1230 | + } catch (PDOException $e) { |
|
| 1231 | 1231 | echo "error : ".$e->getMessage(); |
| 1232 | 1232 | } |
| 1233 | 1233 | } |
| 1234 | 1234 | if ($globalDBdriver == 'mysql') { |
| 1235 | - update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql'); |
|
| 1235 | + update_db::gunzip('../db/countries.sql.gz', $tmp_dir.'countries.sql'); |
|
| 1236 | 1236 | } else { |
| 1237 | - update_db::gunzip('../db/pgsql/countries.sql.gz',$tmp_dir.'countries.sql'); |
|
| 1237 | + update_db::gunzip('../db/pgsql/countries.sql.gz', $tmp_dir.'countries.sql'); |
|
| 1238 | 1238 | } |
| 1239 | 1239 | $error = create_db::import_file($tmp_dir.'countries.sql'); |
| 1240 | 1240 | return $error; |
@@ -1247,7 +1247,7 @@ discard block |
||
| 1247 | 1247 | // update_db::unzip($tmp_dir.'AptNav.zip'); |
| 1248 | 1248 | // update_db::download('https://gitorious.org/fg/fgdata/raw/e81f8a15424a175a7b715f8f7eb8f4147b802a27:Navaids/awy.dat.gz',$tmp_dir.'awy.dat.gz'); |
| 1249 | 1249 | // 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'); |
| 1250 | - 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'); |
|
| 1250 | + 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'); |
|
| 1251 | 1251 | update_db::gunzip($tmp_dir.'awy.dat.gz'); |
| 1252 | 1252 | $error = update_db::waypoints($tmp_dir.'awy.dat'); |
| 1253 | 1253 | return $error; |
@@ -1267,7 +1267,7 @@ discard block |
||
| 1267 | 1267 | update_db::ivao_airlines($tmp_dir.'data/airlines.dat'); |
| 1268 | 1268 | if ($globalDebug) echo "Copy airlines logos to airlines images directory..."; |
| 1269 | 1269 | if (is_writable(dirname(__FILE__).'/../images/airlines')) { |
| 1270 | - if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
| 1270 | + if (!$Common->xcopy($tmp_dir.'logos/', dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
| 1271 | 1271 | } else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
| 1272 | 1272 | } else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
| 1273 | 1273 | if ($error != '') { |
@@ -1280,7 +1280,7 @@ discard block |
||
| 1280 | 1280 | global $tmp_dir, $globalDebug; |
| 1281 | 1281 | $error = ''; |
| 1282 | 1282 | if ($globalDebug) echo "Routes : Download..."; |
| 1283 | - update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz'); |
|
| 1283 | + update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz', $tmp_dir.'StandingData.sqb.gz'); |
|
| 1284 | 1284 | if (file_exists($tmp_dir.'StandingData.sqb.gz')) { |
| 1285 | 1285 | if ($globalDebug) echo "Gunzip..."; |
| 1286 | 1286 | update_db::gunzip($tmp_dir.'StandingData.sqb.gz'); |
@@ -1296,7 +1296,7 @@ discard block |
||
| 1296 | 1296 | global $tmp_dir, $globalDebug; |
| 1297 | 1297 | $error = ''; |
| 1298 | 1298 | if ($globalDebug) echo "Schedules Oneworld : Download..."; |
| 1299 | - update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz'); |
|
| 1299 | + update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz', $tmp_dir.'oneworld.csv.gz'); |
|
| 1300 | 1300 | if (file_exists($tmp_dir.'oneworld.csv.gz')) { |
| 1301 | 1301 | if ($globalDebug) echo "Gunzip..."; |
| 1302 | 1302 | update_db::gunzip($tmp_dir.'oneworld.csv.gz'); |
@@ -1312,7 +1312,7 @@ discard block |
||
| 1312 | 1312 | global $tmp_dir, $globalDebug; |
| 1313 | 1313 | $error = ''; |
| 1314 | 1314 | if ($globalDebug) echo "Schedules Skyteam : Download..."; |
| 1315 | - update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz'); |
|
| 1315 | + update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz', $tmp_dir.'skyteam.csv.gz'); |
|
| 1316 | 1316 | if (file_exists($tmp_dir.'skyteam.csv.gz')) { |
| 1317 | 1317 | if ($globalDebug) echo "Gunzip..."; |
| 1318 | 1318 | update_db::gunzip($tmp_dir.'skyteam.csv.gz'); |
@@ -1339,7 +1339,7 @@ discard block |
||
| 1339 | 1339 | } elseif ($globalDebug) echo "Done\n"; |
| 1340 | 1340 | */ |
| 1341 | 1341 | if ($globalDebug) echo "Modes : Download..."; |
| 1342 | - update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
|
| 1342 | + update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip', $tmp_dir.'basestation_latest.zip', 'http://planebase.biz/bstnsqb'); |
|
| 1343 | 1343 | if (file_exists($tmp_dir.'basestation_latest.zip')) { |
| 1344 | 1344 | if ($globalDebug) echo "Unzip..."; |
| 1345 | 1345 | update_db::unzip($tmp_dir.'basestation_latest.zip'); |
@@ -1355,7 +1355,7 @@ discard block |
||
| 1355 | 1355 | public static function update_ModeS_flarm() { |
| 1356 | 1356 | global $tmp_dir, $globalDebug; |
| 1357 | 1357 | if ($globalDebug) echo "Modes Flarmnet: Download..."; |
| 1358 | - update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln'); |
|
| 1358 | + update_db::download('http://flarmnet.org/files/data.fln', $tmp_dir.'data.fln'); |
|
| 1359 | 1359 | if (file_exists($tmp_dir.'data.fln')) { |
| 1360 | 1360 | if ($globalDebug) echo "Add to DB..."; |
| 1361 | 1361 | $error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln'); |
@@ -1369,7 +1369,7 @@ discard block |
||
| 1369 | 1369 | public static function update_ModeS_ogn() { |
| 1370 | 1370 | global $tmp_dir, $globalDebug; |
| 1371 | 1371 | if ($globalDebug) echo "Modes OGN: Download..."; |
| 1372 | - update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv'); |
|
| 1372 | + update_db::download('http://ddb.glidernet.org/download/', $tmp_dir.'ogn.csv'); |
|
| 1373 | 1373 | if (file_exists($tmp_dir.'ogn.csv')) { |
| 1374 | 1374 | if ($globalDebug) echo "Add to DB..."; |
| 1375 | 1375 | $error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv'); |
@@ -1384,173 +1384,173 @@ discard block |
||
| 1384 | 1384 | global $tmp_dir, $globalDebug; |
| 1385 | 1385 | |
| 1386 | 1386 | if ($globalDebug) echo "Owner France: Download..."; |
| 1387 | - update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv'); |
|
| 1387 | + update_db::download('http://antonakis.co.uk/registers/France.txt', $tmp_dir.'owner_f.csv'); |
|
| 1388 | 1388 | if (file_exists($tmp_dir.'owner_f.csv')) { |
| 1389 | 1389 | if ($globalDebug) echo "Add to DB..."; |
| 1390 | - $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F'); |
|
| 1390 | + $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv', 'F'); |
|
| 1391 | 1391 | } else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
| 1392 | 1392 | if ($error != '') { |
| 1393 | 1393 | return $error; |
| 1394 | 1394 | } elseif ($globalDebug) echo "Done\n"; |
| 1395 | 1395 | |
| 1396 | 1396 | if ($globalDebug) echo "Owner Ireland: Download..."; |
| 1397 | - update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv'); |
|
| 1397 | + update_db::download('http://antonakis.co.uk/registers/Ireland.txt', $tmp_dir.'owner_ei.csv'); |
|
| 1398 | 1398 | if (file_exists($tmp_dir.'owner_ei.csv')) { |
| 1399 | 1399 | if ($globalDebug) echo "Add to DB..."; |
| 1400 | - $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI'); |
|
| 1400 | + $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv', 'EI'); |
|
| 1401 | 1401 | } else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
| 1402 | 1402 | if ($error != '') { |
| 1403 | 1403 | return $error; |
| 1404 | 1404 | } elseif ($globalDebug) echo "Done\n"; |
| 1405 | 1405 | if ($globalDebug) echo "Owner Switzerland: Download..."; |
| 1406 | - update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv'); |
|
| 1406 | + update_db::download('http://antonakis.co.uk/registers/Switzerland.txt', $tmp_dir.'owner_hb.csv'); |
|
| 1407 | 1407 | if (file_exists($tmp_dir.'owner_hb.csv')) { |
| 1408 | 1408 | if ($globalDebug) echo "Add to DB..."; |
| 1409 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB'); |
|
| 1409 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv', 'HB'); |
|
| 1410 | 1410 | } else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
| 1411 | 1411 | if ($error != '') { |
| 1412 | 1412 | return $error; |
| 1413 | 1413 | } elseif ($globalDebug) echo "Done\n"; |
| 1414 | 1414 | if ($globalDebug) echo "Owner Czech Republic: Download..."; |
| 1415 | - update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv'); |
|
| 1415 | + update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt', $tmp_dir.'owner_ok.csv'); |
|
| 1416 | 1416 | if (file_exists($tmp_dir.'owner_ok.csv')) { |
| 1417 | 1417 | if ($globalDebug) echo "Add to DB..."; |
| 1418 | - $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK'); |
|
| 1418 | + $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv', 'OK'); |
|
| 1419 | 1419 | } else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
| 1420 | 1420 | if ($error != '') { |
| 1421 | 1421 | return $error; |
| 1422 | 1422 | } elseif ($globalDebug) echo "Done\n"; |
| 1423 | 1423 | if ($globalDebug) echo "Owner Australia: Download..."; |
| 1424 | - update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv'); |
|
| 1424 | + update_db::download('http://antonakis.co.uk/registers/Australia.txt', $tmp_dir.'owner_vh.csv'); |
|
| 1425 | 1425 | if (file_exists($tmp_dir.'owner_vh.csv')) { |
| 1426 | 1426 | if ($globalDebug) echo "Add to DB..."; |
| 1427 | - $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH'); |
|
| 1427 | + $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv', 'VH'); |
|
| 1428 | 1428 | } else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
| 1429 | 1429 | if ($error != '') { |
| 1430 | 1430 | return $error; |
| 1431 | 1431 | } elseif ($globalDebug) echo "Done\n"; |
| 1432 | 1432 | if ($globalDebug) echo "Owner Austria: Download..."; |
| 1433 | - update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv'); |
|
| 1433 | + update_db::download('http://antonakis.co.uk/registers/Austria.txt', $tmp_dir.'owner_oe.csv'); |
|
| 1434 | 1434 | if (file_exists($tmp_dir.'owner_oe.csv')) { |
| 1435 | 1435 | if ($globalDebug) echo "Add to DB..."; |
| 1436 | - $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE'); |
|
| 1436 | + $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv', 'OE'); |
|
| 1437 | 1437 | } else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
| 1438 | 1438 | if ($error != '') { |
| 1439 | 1439 | return $error; |
| 1440 | 1440 | } elseif ($globalDebug) echo "Done\n"; |
| 1441 | 1441 | if ($globalDebug) echo "Owner Chile: Download..."; |
| 1442 | - update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv'); |
|
| 1442 | + update_db::download('http://antonakis.co.uk/registers/Chile.txt', $tmp_dir.'owner_cc.csv'); |
|
| 1443 | 1443 | if (file_exists($tmp_dir.'owner_cc.csv')) { |
| 1444 | 1444 | if ($globalDebug) echo "Add to DB..."; |
| 1445 | - $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC'); |
|
| 1445 | + $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv', 'CC'); |
|
| 1446 | 1446 | } else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
| 1447 | 1447 | if ($error != '') { |
| 1448 | 1448 | return $error; |
| 1449 | 1449 | } elseif ($globalDebug) echo "Done\n"; |
| 1450 | 1450 | if ($globalDebug) echo "Owner Colombia: Download..."; |
| 1451 | - update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv'); |
|
| 1451 | + update_db::download('http://antonakis.co.uk/registers/Colombia.txt', $tmp_dir.'owner_hj.csv'); |
|
| 1452 | 1452 | if (file_exists($tmp_dir.'owner_hj.csv')) { |
| 1453 | 1453 | if ($globalDebug) echo "Add to DB..."; |
| 1454 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ'); |
|
| 1454 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv', 'HJ'); |
|
| 1455 | 1455 | } else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
| 1456 | 1456 | if ($error != '') { |
| 1457 | 1457 | return $error; |
| 1458 | 1458 | } elseif ($globalDebug) echo "Done\n"; |
| 1459 | 1459 | if ($globalDebug) echo "Owner Bosnia Herzegobina: Download..."; |
| 1460 | - update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv'); |
|
| 1460 | + update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt', $tmp_dir.'owner_e7.csv'); |
|
| 1461 | 1461 | if (file_exists($tmp_dir.'owner_e7.csv')) { |
| 1462 | 1462 | if ($globalDebug) echo "Add to DB..."; |
| 1463 | - $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7'); |
|
| 1463 | + $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv', 'E7'); |
|
| 1464 | 1464 | } else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
| 1465 | 1465 | if ($error != '') { |
| 1466 | 1466 | return $error; |
| 1467 | 1467 | } elseif ($globalDebug) echo "Done\n"; |
| 1468 | 1468 | if ($globalDebug) echo "Owner Brazil: Download..."; |
| 1469 | - update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv'); |
|
| 1469 | + update_db::download('http://antonakis.co.uk/registers/Brazil.txt', $tmp_dir.'owner_pp.csv'); |
|
| 1470 | 1470 | if (file_exists($tmp_dir.'owner_pp.csv')) { |
| 1471 | 1471 | if ($globalDebug) echo "Add to DB..."; |
| 1472 | - $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP'); |
|
| 1472 | + $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv', 'PP'); |
|
| 1473 | 1473 | } else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
| 1474 | 1474 | if ($error != '') { |
| 1475 | 1475 | return $error; |
| 1476 | 1476 | } elseif ($globalDebug) echo "Done\n"; |
| 1477 | 1477 | if ($globalDebug) echo "Owner Cayman Islands: Download..."; |
| 1478 | - update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv'); |
|
| 1478 | + update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt', $tmp_dir.'owner_vp.csv'); |
|
| 1479 | 1479 | if (file_exists($tmp_dir.'owner_vp.csv')) { |
| 1480 | 1480 | if ($globalDebug) echo "Add to DB..."; |
| 1481 | - $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP'); |
|
| 1481 | + $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv', 'VP'); |
|
| 1482 | 1482 | } else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
| 1483 | 1483 | if ($error != '') { |
| 1484 | 1484 | return $error; |
| 1485 | 1485 | } elseif ($globalDebug) echo "Done\n"; |
| 1486 | 1486 | if ($globalDebug) echo "Owner Croatia: Download..."; |
| 1487 | - update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv'); |
|
| 1487 | + update_db::download('http://antonakis.co.uk/registers/Croatia.txt', $tmp_dir.'owner_9a.csv'); |
|
| 1488 | 1488 | if (file_exists($tmp_dir.'owner_9a.csv')) { |
| 1489 | 1489 | if ($globalDebug) echo "Add to DB..."; |
| 1490 | - $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A'); |
|
| 1490 | + $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv', '9A'); |
|
| 1491 | 1491 | } else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
| 1492 | 1492 | if ($error != '') { |
| 1493 | 1493 | return $error; |
| 1494 | 1494 | } elseif ($globalDebug) echo "Done\n"; |
| 1495 | 1495 | if ($globalDebug) echo "Owner Luxembourg: Download..."; |
| 1496 | - update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv'); |
|
| 1496 | + update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt', $tmp_dir.'owner_lx.csv'); |
|
| 1497 | 1497 | if (file_exists($tmp_dir.'owner_lx.csv')) { |
| 1498 | 1498 | if ($globalDebug) echo "Add to DB..."; |
| 1499 | - $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX'); |
|
| 1499 | + $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv', 'LX'); |
|
| 1500 | 1500 | } else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
| 1501 | 1501 | if ($error != '') { |
| 1502 | 1502 | return $error; |
| 1503 | 1503 | } elseif ($globalDebug) echo "Done\n"; |
| 1504 | 1504 | if ($globalDebug) echo "Owner Maldives: Download..."; |
| 1505 | - update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv'); |
|
| 1505 | + update_db::download('http://antonakis.co.uk/registers/Maldives.txt', $tmp_dir.'owner_8q.csv'); |
|
| 1506 | 1506 | if (file_exists($tmp_dir.'owner_8q.csv')) { |
| 1507 | 1507 | if ($globalDebug) echo "Add to DB..."; |
| 1508 | - $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q'); |
|
| 1508 | + $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv', '8Q'); |
|
| 1509 | 1509 | } else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
| 1510 | 1510 | if ($error != '') { |
| 1511 | 1511 | return $error; |
| 1512 | 1512 | } elseif ($globalDebug) echo "Done\n"; |
| 1513 | 1513 | if ($globalDebug) echo "Owner New Zealand: Download..."; |
| 1514 | - update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv'); |
|
| 1514 | + update_db::download('http://antonakis.co.uk/registers/NewZealand.txt', $tmp_dir.'owner_zk.csv'); |
|
| 1515 | 1515 | if (file_exists($tmp_dir.'owner_zk.csv')) { |
| 1516 | 1516 | if ($globalDebug) echo "Add to DB..."; |
| 1517 | - $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK'); |
|
| 1517 | + $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv', 'ZK'); |
|
| 1518 | 1518 | } else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
| 1519 | 1519 | if ($error != '') { |
| 1520 | 1520 | return $error; |
| 1521 | 1521 | } elseif ($globalDebug) echo "Done\n"; |
| 1522 | 1522 | if ($globalDebug) echo "Owner Papua New Guinea: Download..."; |
| 1523 | - update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv'); |
|
| 1523 | + update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt', $tmp_dir.'owner_p2.csv'); |
|
| 1524 | 1524 | if (file_exists($tmp_dir.'owner_p2.csv')) { |
| 1525 | 1525 | if ($globalDebug) echo "Add to DB..."; |
| 1526 | - $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2'); |
|
| 1526 | + $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv', 'P2'); |
|
| 1527 | 1527 | } else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
| 1528 | 1528 | if ($error != '') { |
| 1529 | 1529 | return $error; |
| 1530 | 1530 | } elseif ($globalDebug) echo "Done\n"; |
| 1531 | 1531 | if ($globalDebug) echo "Owner Slovakia: Download..."; |
| 1532 | - update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv'); |
|
| 1532 | + update_db::download('http://antonakis.co.uk/registers/Slovakia.txt', $tmp_dir.'owner_om.csv'); |
|
| 1533 | 1533 | if (file_exists($tmp_dir.'owner_om.csv')) { |
| 1534 | 1534 | if ($globalDebug) echo "Add to DB..."; |
| 1535 | - $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM'); |
|
| 1535 | + $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv', 'OM'); |
|
| 1536 | 1536 | } else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
| 1537 | 1537 | if ($error != '') { |
| 1538 | 1538 | return $error; |
| 1539 | 1539 | } elseif ($globalDebug) echo "Done\n"; |
| 1540 | 1540 | if ($globalDebug) echo "Owner Ecuador: Download..."; |
| 1541 | - update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv'); |
|
| 1541 | + update_db::download('http://antonakis.co.uk/registers/Ecuador.txt', $tmp_dir.'owner_hc.csv'); |
|
| 1542 | 1542 | if (file_exists($tmp_dir.'owner_hc.csv')) { |
| 1543 | 1543 | if ($globalDebug) echo "Add to DB..."; |
| 1544 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC'); |
|
| 1544 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv', 'HC'); |
|
| 1545 | 1545 | } else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
| 1546 | 1546 | if ($error != '') { |
| 1547 | 1547 | return $error; |
| 1548 | 1548 | } elseif ($globalDebug) echo "Done\n"; |
| 1549 | 1549 | if ($globalDebug) echo "Owner Iceland: Download..."; |
| 1550 | - update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv'); |
|
| 1550 | + update_db::download('http://antonakis.co.uk/registers/Iceland.txt', $tmp_dir.'owner_tf.csv'); |
|
| 1551 | 1551 | if (file_exists($tmp_dir.'owner_tf.csv')) { |
| 1552 | 1552 | if ($globalDebug) echo "Add to DB..."; |
| 1553 | - $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF'); |
|
| 1553 | + $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv', 'TF'); |
|
| 1554 | 1554 | } else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
| 1555 | 1555 | if ($error != '') { |
| 1556 | 1556 | return $error; |
@@ -1562,7 +1562,7 @@ discard block |
||
| 1562 | 1562 | global $tmp_dir, $globalDebug; |
| 1563 | 1563 | $error = ''; |
| 1564 | 1564 | if ($globalDebug) echo "Translation : Download..."; |
| 1565 | - update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip'); |
|
| 1565 | + update_db::download('http://www.acarsd.org/download/translation.php', $tmp_dir.'translation.zip'); |
|
| 1566 | 1566 | if (file_exists($tmp_dir.'translation.zip')) { |
| 1567 | 1567 | if ($globalDebug) echo "Unzip..."; |
| 1568 | 1568 | update_db::unzip($tmp_dir.'translation.zip'); |
@@ -1578,7 +1578,7 @@ discard block |
||
| 1578 | 1578 | public static function update_translation_fam() { |
| 1579 | 1579 | global $tmp_dir, $globalDebug; |
| 1580 | 1580 | if ($globalDebug) echo "Translation from FlightAirMap website : Download..."; |
| 1581 | - update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz'); |
|
| 1581 | + update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz', $tmp_dir.'translation.tsv.gz'); |
|
| 1582 | 1582 | if (file_exists($tmp_dir.'translation.tsv.gz')) { |
| 1583 | 1583 | if ($globalDebug) echo "Gunzip..."; |
| 1584 | 1584 | update_db::gunzip($tmp_dir.'translation.tsv.gz'); |
@@ -1594,15 +1594,15 @@ discard block |
||
| 1594 | 1594 | public static function update_tle() { |
| 1595 | 1595 | global $tmp_dir, $globalDebug; |
| 1596 | 1596 | if ($globalDebug) echo "Download TLE : Download..."; |
| 1597 | - $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', |
|
| 1598 | - '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', |
|
| 1599 | - 'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt'); |
|
| 1597 | + $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', |
|
| 1598 | + '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', |
|
| 1599 | + 'engineering.txt', 'education.txt', 'military.txt', 'radar.txt', 'cubesat.txt', 'other.txt', 'tle-new.txt'); |
|
| 1600 | 1600 | foreach ($alltle as $filename) { |
| 1601 | 1601 | if ($globalDebug) echo "downloading ".$filename.'...'; |
| 1602 | - update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename); |
|
| 1602 | + update_db::download('http://celestrak.com/NORAD/elements/'.$filename, $tmp_dir.$filename); |
|
| 1603 | 1603 | if (file_exists($tmp_dir.$filename)) { |
| 1604 | 1604 | if ($globalDebug) echo "Add to DB ".$filename."..."; |
| 1605 | - $error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename)); |
|
| 1605 | + $error = update_db::tle($tmp_dir.$filename, str_replace('.txt', '', $filename)); |
|
| 1606 | 1606 | } else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
| 1607 | 1607 | if ($error != '') { |
| 1608 | 1608 | echo $error."\n"; |
@@ -1615,32 +1615,32 @@ discard block |
||
| 1615 | 1615 | global $tmp_dir, $globalDebug; |
| 1616 | 1616 | $error = ''; |
| 1617 | 1617 | if ($globalDebug) echo "Models from FlightAirMap website : Download..."; |
| 1618 | - update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum'); |
|
| 1618 | + update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', $tmp_dir.'models.md5sum'); |
|
| 1619 | 1619 | if (file_exists($tmp_dir.'models.md5sum')) { |
| 1620 | 1620 | if ($globalDebug) echo "Check files...\n"; |
| 1621 | 1621 | $newmodelsdb = array(); |
| 1622 | - if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) { |
|
| 1623 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
| 1622 | + if (($handle = fopen($tmp_dir.'models.md5sum', 'r')) !== FALSE) { |
|
| 1623 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
| 1624 | 1624 | $model = trim($row[2]); |
| 1625 | 1625 | $newmodelsdb[$model] = trim($row[0]); |
| 1626 | 1626 | } |
| 1627 | 1627 | } |
| 1628 | 1628 | $modelsdb = array(); |
| 1629 | 1629 | if (file_exists(dirname(__FILE__).'/../models/models.md5sum')) { |
| 1630 | - if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum','r')) !== FALSE) { |
|
| 1631 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
| 1630 | + if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum', 'r')) !== FALSE) { |
|
| 1631 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
| 1632 | 1632 | $model = trim($row[2]); |
| 1633 | 1633 | $modelsdb[$model] = trim($row[0]); |
| 1634 | 1634 | } |
| 1635 | 1635 | } |
| 1636 | 1636 | } |
| 1637 | - $diff = array_diff($newmodelsdb,$modelsdb); |
|
| 1637 | + $diff = array_diff($newmodelsdb, $modelsdb); |
|
| 1638 | 1638 | foreach ($diff as $key => $value) { |
| 1639 | 1639 | if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n"; |
| 1640 | - update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key); |
|
| 1640 | + update_db::download('http://data.flightairmap.fr/data/models/'.$key, dirname(__FILE__).'/../models/'.$key); |
|
| 1641 | 1641 | |
| 1642 | 1642 | } |
| 1643 | - update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum'); |
|
| 1643 | + update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', dirname(__FILE__).'/../models/models.md5sum'); |
|
| 1644 | 1644 | } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
| 1645 | 1645 | if ($error != '') { |
| 1646 | 1646 | return $error; |
@@ -1652,32 +1652,32 @@ discard block |
||
| 1652 | 1652 | global $tmp_dir, $globalDebug; |
| 1653 | 1653 | $error = ''; |
| 1654 | 1654 | if ($globalDebug) echo "Space models from FlightAirMap website : Download..."; |
| 1655 | - update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum'); |
|
| 1655 | + update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', $tmp_dir.'space_models.md5sum'); |
|
| 1656 | 1656 | if (file_exists($tmp_dir.'space_models.md5sum')) { |
| 1657 | 1657 | if ($globalDebug) echo "Check files...\n"; |
| 1658 | 1658 | $newmodelsdb = array(); |
| 1659 | - if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) { |
|
| 1660 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
| 1659 | + if (($handle = fopen($tmp_dir.'space_models.md5sum', 'r')) !== FALSE) { |
|
| 1660 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
| 1661 | 1661 | $model = trim($row[2]); |
| 1662 | 1662 | $newmodelsdb[$model] = trim($row[0]); |
| 1663 | 1663 | } |
| 1664 | 1664 | } |
| 1665 | 1665 | $modelsdb = array(); |
| 1666 | 1666 | if (file_exists(dirname(__FILE__).'/../models/space/space_models.md5sum')) { |
| 1667 | - if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum','r')) !== FALSE) { |
|
| 1668 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
| 1667 | + if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum', 'r')) !== FALSE) { |
|
| 1668 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
| 1669 | 1669 | $model = trim($row[2]); |
| 1670 | 1670 | $modelsdb[$model] = trim($row[0]); |
| 1671 | 1671 | } |
| 1672 | 1672 | } |
| 1673 | 1673 | } |
| 1674 | - $diff = array_diff($newmodelsdb,$modelsdb); |
|
| 1674 | + $diff = array_diff($newmodelsdb, $modelsdb); |
|
| 1675 | 1675 | foreach ($diff as $key => $value) { |
| 1676 | 1676 | if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n"; |
| 1677 | - update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key); |
|
| 1677 | + update_db::download('http://data.flightairmap.fr/data/models/space/'.$key, dirname(__FILE__).'/../models/space/'.$key); |
|
| 1678 | 1678 | |
| 1679 | 1679 | } |
| 1680 | - update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum'); |
|
| 1680 | + update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', dirname(__FILE__).'/../models/space/space_models.md5sum'); |
|
| 1681 | 1681 | } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
| 1682 | 1682 | if ($error != '') { |
| 1683 | 1683 | return $error; |
@@ -1700,8 +1700,8 @@ discard block |
||
| 1700 | 1700 | */ |
| 1701 | 1701 | if (file_exists($tmp_dir.'aircrafts.html')) { |
| 1702 | 1702 | //var_dump(file_get_html($tmp_dir.'aircrafts.html')); |
| 1703 | - $fh = fopen($tmp_dir.'aircrafts.html',"r"); |
|
| 1704 | - $result = fread($fh,100000000); |
|
| 1703 | + $fh = fopen($tmp_dir.'aircrafts.html', "r"); |
|
| 1704 | + $result = fread($fh, 100000000); |
|
| 1705 | 1705 | //echo $result; |
| 1706 | 1706 | //var_dump(str_get_html($result)); |
| 1707 | 1707 | //print_r(self::table2array($result)); |
@@ -1719,23 +1719,23 @@ discard block |
||
| 1719 | 1719 | $Connection = new Connection(); |
| 1720 | 1720 | $sth = $Connection->db->prepare($query); |
| 1721 | 1721 | $sth->execute(); |
| 1722 | - } catch(PDOException $e) { |
|
| 1722 | + } catch (PDOException $e) { |
|
| 1723 | 1723 | return "error : ".$e->getMessage(); |
| 1724 | 1724 | } |
| 1725 | 1725 | |
| 1726 | 1726 | $error = ''; |
| 1727 | 1727 | if ($globalDebug) echo "Notam : Download..."; |
| 1728 | - update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss'); |
|
| 1728 | + update_db::download($globalNOTAMSource, $tmp_dir.'notam.rss'); |
|
| 1729 | 1729 | if (file_exists($tmp_dir.'notam.rss')) { |
| 1730 | - $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true); |
|
| 1730 | + $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')), true); |
|
| 1731 | 1731 | foreach ($notams['channel']['item'] as $notam) { |
| 1732 | - $title = explode(':',$notam['title']); |
|
| 1732 | + $title = explode(':', $notam['title']); |
|
| 1733 | 1733 | $data['ref'] = trim($title[0]); |
| 1734 | 1734 | unset($title[0]); |
| 1735 | - $data['title'] = trim(implode(':',$title)); |
|
| 1736 | - $description = strip_tags($notam['description'],'<pre>'); |
|
| 1737 | - preg_match(':^(.*?)<pre>:',$description,$match); |
|
| 1738 | - $q = explode('/',$match[1]); |
|
| 1735 | + $data['title'] = trim(implode(':', $title)); |
|
| 1736 | + $description = strip_tags($notam['description'], '<pre>'); |
|
| 1737 | + preg_match(':^(.*?)<pre>:', $description, $match); |
|
| 1738 | + $q = explode('/', $match[1]); |
|
| 1739 | 1739 | $data['fir'] = $q[0]; |
| 1740 | 1740 | $data['code'] = $q[1]; |
| 1741 | 1741 | $ifrvfr = $q[2]; |
@@ -1751,30 +1751,30 @@ discard block |
||
| 1751 | 1751 | $data['lower_limit'] = $q[5]; |
| 1752 | 1752 | $data['upper_limit'] = $q[6]; |
| 1753 | 1753 | $latlonrad = $q[7]; |
| 1754 | - sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius); |
|
| 1755 | - $latitude = $Common->convertDec($las,'latitude'); |
|
| 1756 | - $longitude = $Common->convertDec($lns,'longitude'); |
|
| 1754 | + sscanf($latlonrad, '%4c%c%5c%c%3d', $las, $lac, $lns, $lnc, $radius); |
|
| 1755 | + $latitude = $Common->convertDec($las, 'latitude'); |
|
| 1756 | + $longitude = $Common->convertDec($lns, 'longitude'); |
|
| 1757 | 1757 | if ($lac == 'S') $latitude = '-'.$latitude; |
| 1758 | 1758 | if ($lnc == 'W') $longitude = '-'.$longitude; |
| 1759 | 1759 | $data['center_latitude'] = $latitude; |
| 1760 | 1760 | $data['center_longitude'] = $longitude; |
| 1761 | 1761 | $data['radius'] = intval($radius); |
| 1762 | 1762 | |
| 1763 | - preg_match(':<pre>(.*?)</pre>:',$description,$match); |
|
| 1763 | + preg_match(':<pre>(.*?)</pre>:', $description, $match); |
|
| 1764 | 1764 | $data['text'] = $match[1]; |
| 1765 | - preg_match(':</pre>(.*?)$:',$description,$match); |
|
| 1765 | + preg_match(':</pre>(.*?)$:', $description, $match); |
|
| 1766 | 1766 | $fromto = $match[1]; |
| 1767 | - preg_match('#FROM:(.*?)TO:#',$fromto,$match); |
|
| 1767 | + preg_match('#FROM:(.*?)TO:#', $fromto, $match); |
|
| 1768 | 1768 | $fromall = trim($match[1]); |
| 1769 | - preg_match('#^(.*?) \((.*?)\)$#',$fromall,$match); |
|
| 1769 | + preg_match('#^(.*?) \((.*?)\)$#', $fromall, $match); |
|
| 1770 | 1770 | $from = trim($match[1]); |
| 1771 | - $data['date_begin'] = date("Y-m-d H:i:s",strtotime($from)); |
|
| 1772 | - preg_match('#TO:(.*?)$#',$fromto,$match); |
|
| 1771 | + $data['date_begin'] = date("Y-m-d H:i:s", strtotime($from)); |
|
| 1772 | + preg_match('#TO:(.*?)$#', $fromto, $match); |
|
| 1773 | 1773 | $toall = trim($match[1]); |
| 1774 | - if (!preg_match(':Permanent:',$toall)) { |
|
| 1775 | - preg_match('#^(.*?) \((.*?)\)#',$toall,$match); |
|
| 1774 | + if (!preg_match(':Permanent:', $toall)) { |
|
| 1775 | + preg_match('#^(.*?) \((.*?)\)#', $toall, $match); |
|
| 1776 | 1776 | $to = trim($match[1]); |
| 1777 | - $data['date_end'] = date("Y-m-d H:i:s",strtotime($to)); |
|
| 1777 | + $data['date_end'] = date("Y-m-d H:i:s", strtotime($to)); |
|
| 1778 | 1778 | $data['permanent'] = 0; |
| 1779 | 1779 | } else { |
| 1780 | 1780 | $data['date_end'] = NULL; |
@@ -1782,7 +1782,7 @@ discard block |
||
| 1782 | 1782 | } |
| 1783 | 1783 | $data['full_notam'] = $notam['title'].'<br>'.$notam['description']; |
| 1784 | 1784 | $NOTAM = new NOTAM(); |
| 1785 | - $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']); |
|
| 1785 | + $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']); |
|
| 1786 | 1786 | unset($data); |
| 1787 | 1787 | } |
| 1788 | 1788 | } else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
@@ -1803,7 +1803,7 @@ discard block |
||
| 1803 | 1803 | $Connection = new Connection(); |
| 1804 | 1804 | $sth = $Connection->db->prepare($query); |
| 1805 | 1805 | $sth->execute(); |
| 1806 | - } catch(PDOException $e) { |
|
| 1806 | + } catch (PDOException $e) { |
|
| 1807 | 1807 | return "error : ".$e->getMessage(); |
| 1808 | 1808 | } |
| 1809 | 1809 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -1818,7 +1818,7 @@ discard block |
||
| 1818 | 1818 | $Connection = new Connection(); |
| 1819 | 1819 | $sth = $Connection->db->prepare($query); |
| 1820 | 1820 | $sth->execute(); |
| 1821 | - } catch(PDOException $e) { |
|
| 1821 | + } catch (PDOException $e) { |
|
| 1822 | 1822 | return "error : ".$e->getMessage(); |
| 1823 | 1823 | } |
| 1824 | 1824 | } |
@@ -1834,7 +1834,7 @@ discard block |
||
| 1834 | 1834 | $Connection = new Connection(); |
| 1835 | 1835 | $sth = $Connection->db->prepare($query); |
| 1836 | 1836 | $sth->execute(); |
| 1837 | - } catch(PDOException $e) { |
|
| 1837 | + } catch (PDOException $e) { |
|
| 1838 | 1838 | return "error : ".$e->getMessage(); |
| 1839 | 1839 | } |
| 1840 | 1840 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -1849,7 +1849,7 @@ discard block |
||
| 1849 | 1849 | $Connection = new Connection(); |
| 1850 | 1850 | $sth = $Connection->db->prepare($query); |
| 1851 | 1851 | $sth->execute(); |
| 1852 | - } catch(PDOException $e) { |
|
| 1852 | + } catch (PDOException $e) { |
|
| 1853 | 1853 | return "error : ".$e->getMessage(); |
| 1854 | 1854 | } |
| 1855 | 1855 | } |
@@ -1865,7 +1865,7 @@ discard block |
||
| 1865 | 1865 | $Connection = new Connection(); |
| 1866 | 1866 | $sth = $Connection->db->prepare($query); |
| 1867 | 1867 | $sth->execute(); |
| 1868 | - } catch(PDOException $e) { |
|
| 1868 | + } catch (PDOException $e) { |
|
| 1869 | 1869 | return "error : ".$e->getMessage(); |
| 1870 | 1870 | } |
| 1871 | 1871 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -1880,7 +1880,7 @@ discard block |
||
| 1880 | 1880 | $Connection = new Connection(); |
| 1881 | 1881 | $sth = $Connection->db->prepare($query); |
| 1882 | 1882 | $sth->execute(); |
| 1883 | - } catch(PDOException $e) { |
|
| 1883 | + } catch (PDOException $e) { |
|
| 1884 | 1884 | return "error : ".$e->getMessage(); |
| 1885 | 1885 | } |
| 1886 | 1886 | } |
@@ -1895,7 +1895,7 @@ discard block |
||
| 1895 | 1895 | $Connection = new Connection(); |
| 1896 | 1896 | $sth = $Connection->db->prepare($query); |
| 1897 | 1897 | $sth->execute(); |
| 1898 | - } catch(PDOException $e) { |
|
| 1898 | + } catch (PDOException $e) { |
|
| 1899 | 1899 | return "error : ".$e->getMessage(); |
| 1900 | 1900 | } |
| 1901 | 1901 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -1910,7 +1910,7 @@ discard block |
||
| 1910 | 1910 | $Connection = new Connection(); |
| 1911 | 1911 | $sth = $Connection->db->prepare($query); |
| 1912 | 1912 | $sth->execute(); |
| 1913 | - } catch(PDOException $e) { |
|
| 1913 | + } catch (PDOException $e) { |
|
| 1914 | 1914 | return "error : ".$e->getMessage(); |
| 1915 | 1915 | } |
| 1916 | 1916 | } |
@@ -1925,7 +1925,7 @@ discard block |
||
| 1925 | 1925 | $Connection = new Connection(); |
| 1926 | 1926 | $sth = $Connection->db->prepare($query); |
| 1927 | 1927 | $sth->execute(); |
| 1928 | - } catch(PDOException $e) { |
|
| 1928 | + } catch (PDOException $e) { |
|
| 1929 | 1929 | return "error : ".$e->getMessage(); |
| 1930 | 1930 | } |
| 1931 | 1931 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -1940,7 +1940,7 @@ discard block |
||
| 1940 | 1940 | $Connection = new Connection(); |
| 1941 | 1941 | $sth = $Connection->db->prepare($query); |
| 1942 | 1942 | $sth->execute(); |
| 1943 | - } catch(PDOException $e) { |
|
| 1943 | + } catch (PDOException $e) { |
|
| 1944 | 1944 | return "error : ".$e->getMessage(); |
| 1945 | 1945 | } |
| 1946 | 1946 | } |
@@ -16,7 +16,9 @@ discard block |
||
| 16 | 16 | curl_setopt($ch, CURLOPT_URL, $url); |
| 17 | 17 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
| 18 | 18 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
| 19 | - if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
| 19 | + if ($referer != '') { |
|
| 20 | + curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
| 21 | + } |
|
| 20 | 22 | curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5'); |
| 21 | 23 | curl_setopt($ch, CURLOPT_FILE, $fp); |
| 22 | 24 | curl_exec($ch); |
@@ -27,12 +29,16 @@ discard block |
||
| 27 | 29 | public static function gunzip($in_file,$out_file_name = '') { |
| 28 | 30 | //echo $in_file.' -> '.$out_file_name."\n"; |
| 29 | 31 | $buffer_size = 4096; // read 4kb at a time |
| 30 | - if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); |
|
| 32 | + if ($out_file_name == '') { |
|
| 33 | + $out_file_name = str_replace('.gz', '', $in_file); |
|
| 34 | + } |
|
| 31 | 35 | if ($in_file != '' && file_exists($in_file)) { |
| 32 | 36 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
| 33 | - if (function_exists('gzopen')) $file = gzopen($in_file,'rb'); |
|
| 34 | - elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb'); |
|
| 35 | - else { |
|
| 37 | + if (function_exists('gzopen')) { |
|
| 38 | + $file = gzopen($in_file,'rb'); |
|
| 39 | + } elseif (function_exists('gzopen64')) { |
|
| 40 | + $file = gzopen64($in_file,'rb'); |
|
| 41 | + } else { |
|
| 36 | 42 | echo 'gzopen not available'; |
| 37 | 43 | die; |
| 38 | 44 | } |
@@ -53,8 +59,12 @@ discard block |
||
| 53 | 59 | if ($res === TRUE) { |
| 54 | 60 | $zip->extractTo($path); |
| 55 | 61 | $zip->close(); |
| 56 | - } else return false; |
|
| 57 | - } else return false; |
|
| 62 | + } else { |
|
| 63 | + return false; |
|
| 64 | + } |
|
| 65 | + } else { |
|
| 66 | + return false; |
|
| 67 | + } |
|
| 58 | 68 | } |
| 59 | 69 | |
| 60 | 70 | public static function connect_sqlite($database) { |
@@ -69,7 +79,9 @@ discard block |
||
| 69 | 79 | public static function retrieve_route_sqlite_to_dest($database_file) { |
| 70 | 80 | global $globalDebug, $globalTransaction; |
| 71 | 81 | //$query = 'TRUNCATE TABLE routes'; |
| 72 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
| 82 | + if ($globalDebug) { |
|
| 83 | + echo " - Delete previous routes from DB -"; |
|
| 84 | + } |
|
| 73 | 85 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
| 74 | 86 | $Connection = new Connection(); |
| 75 | 87 | try { |
@@ -80,7 +92,9 @@ discard block |
||
| 80 | 92 | return "error : ".$e->getMessage(); |
| 81 | 93 | } |
| 82 | 94 | |
| 83 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
| 95 | + if ($globalDebug) { |
|
| 96 | + echo " - Add routes to DB -"; |
|
| 97 | + } |
|
| 84 | 98 | update_db::connect_sqlite($database_file); |
| 85 | 99 | //$query = 'select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID'; |
| 86 | 100 | $query = "select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao, rstp.allstop AS AllStop from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID LEFT JOIN (select RouteId,GROUP_CONCAT(icao,' ') as allstop from routestop left join Airport as air ON routestop.AirportId = air.AirportID group by RouteID) AS rstp ON Route.RouteID = rstp.RouteID"; |
@@ -95,15 +109,21 @@ discard block |
||
| 95 | 109 | $Connection = new Connection(); |
| 96 | 110 | $sth_dest = $Connection->db->prepare($query_dest); |
| 97 | 111 | try { |
| 98 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 112 | + if ($globalTransaction) { |
|
| 113 | + $Connection->db->beginTransaction(); |
|
| 114 | + } |
|
| 99 | 115 | while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
| 100 | 116 | //$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
| 101 | 117 | $query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
| 102 | 118 | $sth_dest->execute($query_dest_values); |
| 103 | 119 | } |
| 104 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 120 | + if ($globalTransaction) { |
|
| 121 | + $Connection->db->commit(); |
|
| 122 | + } |
|
| 105 | 123 | } catch(PDOException $e) { |
| 106 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
| 124 | + if ($globalTransaction) { |
|
| 125 | + $Connection->db->rollBack(); |
|
| 126 | + } |
|
| 107 | 127 | return "error : ".$e->getMessage(); |
| 108 | 128 | } |
| 109 | 129 | return ''; |
@@ -111,7 +131,9 @@ discard block |
||
| 111 | 131 | public static function retrieve_route_oneworld($database_file) { |
| 112 | 132 | global $globalDebug, $globalTransaction; |
| 113 | 133 | //$query = 'TRUNCATE TABLE routes'; |
| 114 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
| 134 | + if ($globalDebug) { |
|
| 135 | + echo " - Delete previous routes from DB -"; |
|
| 136 | + } |
|
| 115 | 137 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
| 116 | 138 | $Connection = new Connection(); |
| 117 | 139 | try { |
@@ -122,14 +144,18 @@ discard block |
||
| 122 | 144 | return "error : ".$e->getMessage(); |
| 123 | 145 | } |
| 124 | 146 | |
| 125 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
| 147 | + if ($globalDebug) { |
|
| 148 | + echo " - Add routes to DB -"; |
|
| 149 | + } |
|
| 126 | 150 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 127 | 151 | $Spotter = new Spotter(); |
| 128 | 152 | if ($fh = fopen($database_file,"r")) { |
| 129 | 153 | $query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)'; |
| 130 | 154 | $Connection = new Connection(); |
| 131 | 155 | $sth_dest = $Connection->db->prepare($query_dest); |
| 132 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 156 | + if ($globalTransaction) { |
|
| 157 | + $Connection->db->beginTransaction(); |
|
| 158 | + } |
|
| 133 | 159 | while (!feof($fh)) { |
| 134 | 160 | $line = fgetcsv($fh,9999,','); |
| 135 | 161 | if ($line[0] != '') { |
@@ -138,13 +164,17 @@ discard block |
||
| 138 | 164 | $query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld'); |
| 139 | 165 | $sth_dest->execute($query_dest_values); |
| 140 | 166 | } catch(PDOException $e) { |
| 141 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
| 167 | + if ($globalTransaction) { |
|
| 168 | + $Connection->db->rollBack(); |
|
| 169 | + } |
|
| 142 | 170 | return "error : ".$e->getMessage(); |
| 143 | 171 | } |
| 144 | 172 | } |
| 145 | 173 | } |
| 146 | 174 | } |
| 147 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 175 | + if ($globalTransaction) { |
|
| 176 | + $Connection->db->commit(); |
|
| 177 | + } |
|
| 148 | 178 | } |
| 149 | 179 | return ''; |
| 150 | 180 | } |
@@ -152,7 +182,9 @@ discard block |
||
| 152 | 182 | public static function retrieve_route_skyteam($database_file) { |
| 153 | 183 | global $globalDebug, $globalTransaction; |
| 154 | 184 | //$query = 'TRUNCATE TABLE routes'; |
| 155 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
| 185 | + if ($globalDebug) { |
|
| 186 | + echo " - Delete previous routes from DB -"; |
|
| 187 | + } |
|
| 156 | 188 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
| 157 | 189 | $Connection = new Connection(); |
| 158 | 190 | try { |
@@ -163,7 +195,9 @@ discard block |
||
| 163 | 195 | return "error : ".$e->getMessage(); |
| 164 | 196 | } |
| 165 | 197 | |
| 166 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
| 198 | + if ($globalDebug) { |
|
| 199 | + echo " - Add routes to DB -"; |
|
| 200 | + } |
|
| 167 | 201 | |
| 168 | 202 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 169 | 203 | $Spotter = new Spotter(); |
@@ -172,7 +206,9 @@ discard block |
||
| 172 | 206 | $Connection = new Connection(); |
| 173 | 207 | $sth_dest = $Connection->db->prepare($query_dest); |
| 174 | 208 | try { |
| 175 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 209 | + if ($globalTransaction) { |
|
| 210 | + $Connection->db->beginTransaction(); |
|
| 211 | + } |
|
| 176 | 212 | while (!feof($fh)) { |
| 177 | 213 | $line = fgetcsv($fh,9999,','); |
| 178 | 214 | if ($line[0] != '') { |
@@ -183,9 +219,13 @@ discard block |
||
| 183 | 219 | //} |
| 184 | 220 | } |
| 185 | 221 | } |
| 186 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 222 | + if ($globalTransaction) { |
|
| 223 | + $Connection->db->commit(); |
|
| 224 | + } |
|
| 187 | 225 | } catch(PDOException $e) { |
| 188 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
| 226 | + if ($globalTransaction) { |
|
| 227 | + $Connection->db->rollBack(); |
|
| 228 | + } |
|
| 189 | 229 | return "error : ".$e->getMessage(); |
| 190 | 230 | } |
| 191 | 231 | } |
@@ -228,11 +268,16 @@ discard block |
||
| 228 | 268 | $sth_dest = $Connection->db->prepare($query_dest); |
| 229 | 269 | $sth_dest_owner = $Connection->db->prepare($query_dest_owner); |
| 230 | 270 | try { |
| 231 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 271 | + if ($globalTransaction) { |
|
| 272 | + $Connection->db->beginTransaction(); |
|
| 273 | + } |
|
| 232 | 274 | while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
| 233 | 275 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
| 234 | - if ($values['UserString4'] == 'M') $type = 'military'; |
|
| 235 | - else $type = null; |
|
| 276 | + if ($values['UserString4'] == 'M') { |
|
| 277 | + $type = 'military'; |
|
| 278 | + } else { |
|
| 279 | + $type = null; |
|
| 280 | + } |
|
| 236 | 281 | $query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type); |
| 237 | 282 | $sth_dest->execute($query_dest_values); |
| 238 | 283 | if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') { |
@@ -240,7 +285,9 @@ discard block |
||
| 240 | 285 | $sth_dest_owner->execute($query_dest_owner_values); |
| 241 | 286 | } |
| 242 | 287 | } |
| 243 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 288 | + if ($globalTransaction) { |
|
| 289 | + $Connection->db->commit(); |
|
| 290 | + } |
|
| 244 | 291 | } catch(PDOException $e) { |
| 245 | 292 | return "error : ".$e->getMessage(); |
| 246 | 293 | } |
@@ -276,7 +323,9 @@ discard block |
||
| 276 | 323 | $Connection = new Connection(); |
| 277 | 324 | $sth_dest = $Connection->db->prepare($query_dest); |
| 278 | 325 | try { |
| 279 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 326 | + if ($globalTransaction) { |
|
| 327 | + $Connection->db->beginTransaction(); |
|
| 328 | + } |
|
| 280 | 329 | while (!feof($fh)) { |
| 281 | 330 | $values = array(); |
| 282 | 331 | $line = $Common->hex2str(fgets($fh,9999)); |
@@ -287,7 +336,9 @@ discard block |
||
| 287 | 336 | // Check if we can find ICAO, else set it to GLID |
| 288 | 337 | $aircraft_name_split = explode(' ',$aircraft_name); |
| 289 | 338 | $search_more = ''; |
| 290 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 339 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) { |
|
| 340 | + $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 341 | + } |
|
| 291 | 342 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
| 292 | 343 | $sth_search = $Connection->db->prepare($query_search); |
| 293 | 344 | try { |
@@ -300,7 +351,9 @@ discard block |
||
| 300 | 351 | } catch(PDOException $e) { |
| 301 | 352 | return "error : ".$e->getMessage(); |
| 302 | 353 | } |
| 303 | - if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID'; |
|
| 354 | + if (!isset($values['ICAOTypeCode'])) { |
|
| 355 | + $values['ICAOTypeCode'] = 'GLID'; |
|
| 356 | + } |
|
| 304 | 357 | // Add data to db |
| 305 | 358 | if ($values['ModeS'] != '' && $values['Registration'] != '' && $values['Registration'] != '0000') { |
| 306 | 359 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
@@ -309,7 +362,9 @@ discard block |
||
| 309 | 362 | $sth_dest->execute($query_dest_values); |
| 310 | 363 | } |
| 311 | 364 | } |
| 312 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 365 | + if ($globalTransaction) { |
|
| 366 | + $Connection->db->commit(); |
|
| 367 | + } |
|
| 313 | 368 | } catch(PDOException $e) { |
| 314 | 369 | return "error : ".$e->getMessage(); |
| 315 | 370 | } |
@@ -345,7 +400,9 @@ discard block |
||
| 345 | 400 | $Connection = new Connection(); |
| 346 | 401 | $sth_dest = $Connection->db->prepare($query_dest); |
| 347 | 402 | try { |
| 348 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 403 | + if ($globalTransaction) { |
|
| 404 | + $Connection->db->beginTransaction(); |
|
| 405 | + } |
|
| 349 | 406 | $tmp = fgetcsv($fh,9999,',',"'"); |
| 350 | 407 | while (!feof($fh)) { |
| 351 | 408 | $line = fgetcsv($fh,9999,',',"'"); |
@@ -358,13 +415,17 @@ discard block |
||
| 358 | 415 | // Check if we can find ICAO, else set it to GLID |
| 359 | 416 | $aircraft_name_split = explode(' ',$aircraft_name); |
| 360 | 417 | $search_more = ''; |
| 361 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 418 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) { |
|
| 419 | + $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 420 | + } |
|
| 362 | 421 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
| 363 | 422 | $sth_search = $Connection->db->prepare($query_search); |
| 364 | 423 | try { |
| 365 | 424 | $sth_search->execute(); |
| 366 | 425 | $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
| 367 | - if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
|
| 426 | + if (isset($result['icao']) && $result['icao'] != '') { |
|
| 427 | + $values['ICAOTypeCode'] = $result['icao']; |
|
| 428 | + } |
|
| 368 | 429 | } catch(PDOException $e) { |
| 369 | 430 | return "error : ".$e->getMessage(); |
| 370 | 431 | } |
@@ -377,7 +438,9 @@ discard block |
||
| 377 | 438 | $sth_dest->execute($query_dest_values); |
| 378 | 439 | } |
| 379 | 440 | } |
| 380 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 441 | + if ($globalTransaction) { |
|
| 442 | + $Connection->db->commit(); |
|
| 443 | + } |
|
| 381 | 444 | } catch(PDOException $e) { |
| 382 | 445 | return "error : ".$e->getMessage(); |
| 383 | 446 | } |
@@ -413,7 +476,9 @@ discard block |
||
| 413 | 476 | $Connection = new Connection(); |
| 414 | 477 | $sth_dest = $Connection->db->prepare($query_dest); |
| 415 | 478 | try { |
| 416 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 479 | + if ($globalTransaction) { |
|
| 480 | + $Connection->db->beginTransaction(); |
|
| 481 | + } |
|
| 417 | 482 | $tmp = fgetcsv($fh,9999,',','"'); |
| 418 | 483 | while (!feof($fh)) { |
| 419 | 484 | $line = fgetcsv($fh,9999,',','"'); |
@@ -423,16 +488,22 @@ discard block |
||
| 423 | 488 | $values['registration'] = $line[0]; |
| 424 | 489 | $values['base'] = $line[4]; |
| 425 | 490 | $values['owner'] = $line[5]; |
| 426 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
| 427 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 491 | + if ($line[6] == '') { |
|
| 492 | + $values['date_first_reg'] = null; |
|
| 493 | + } else { |
|
| 494 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 495 | + } |
|
| 428 | 496 | $values['cancel'] = $line[7]; |
| 429 | 497 | } elseif ($country == 'EI') { |
| 430 | 498 | // TODO : add modeS & reg to aircraft_modes |
| 431 | 499 | $values['registration'] = $line[0]; |
| 432 | 500 | $values['base'] = $line[3]; |
| 433 | 501 | $values['owner'] = $line[2]; |
| 434 | - if ($line[1] == '') $values['date_first_reg'] = null; |
|
| 435 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
| 502 | + if ($line[1] == '') { |
|
| 503 | + $values['date_first_reg'] = null; |
|
| 504 | + } else { |
|
| 505 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
| 506 | + } |
|
| 436 | 507 | $values['cancel'] = ''; |
| 437 | 508 | } elseif ($country == 'HB') { |
| 438 | 509 | // TODO : add modeS & reg to aircraft_modes |
@@ -446,16 +517,22 @@ discard block |
||
| 446 | 517 | $values['registration'] = $line[3]; |
| 447 | 518 | $values['base'] = null; |
| 448 | 519 | $values['owner'] = $line[5]; |
| 449 | - if ($line[18] == '') $values['date_first_reg'] = null; |
|
| 450 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
| 520 | + if ($line[18] == '') { |
|
| 521 | + $values['date_first_reg'] = null; |
|
| 522 | + } else { |
|
| 523 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
| 524 | + } |
|
| 451 | 525 | $values['cancel'] = ''; |
| 452 | 526 | } elseif ($country == 'VH') { |
| 453 | 527 | // TODO : add modeS & reg to aircraft_modes |
| 454 | 528 | $values['registration'] = $line[0]; |
| 455 | 529 | $values['base'] = null; |
| 456 | 530 | $values['owner'] = $line[12]; |
| 457 | - if ($line[28] == '') $values['date_first_reg'] = null; |
|
| 458 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
| 531 | + if ($line[28] == '') { |
|
| 532 | + $values['date_first_reg'] = null; |
|
| 533 | + } else { |
|
| 534 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
| 535 | + } |
|
| 459 | 536 | |
| 460 | 537 | $values['cancel'] = $line[39]; |
| 461 | 538 | } elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { |
@@ -474,29 +551,41 @@ discard block |
||
| 474 | 551 | $values['registration'] = $line[0]; |
| 475 | 552 | $values['base'] = null; |
| 476 | 553 | $values['owner'] = $line[8]; |
| 477 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
| 478 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 554 | + if ($line[7] == '') { |
|
| 555 | + $values['date_first_reg'] = null; |
|
| 556 | + } else { |
|
| 557 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 558 | + } |
|
| 479 | 559 | $values['cancel'] = ''; |
| 480 | 560 | } elseif ($country == 'PP') { |
| 481 | 561 | $values['registration'] = $line[0]; |
| 482 | 562 | $values['base'] = null; |
| 483 | 563 | $values['owner'] = $line[4]; |
| 484 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
| 485 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 564 | + if ($line[6] == '') { |
|
| 565 | + $values['date_first_reg'] = null; |
|
| 566 | + } else { |
|
| 567 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 568 | + } |
|
| 486 | 569 | $values['cancel'] = $line[7]; |
| 487 | 570 | } elseif ($country == 'E7') { |
| 488 | 571 | $values['registration'] = $line[0]; |
| 489 | 572 | $values['base'] = null; |
| 490 | 573 | $values['owner'] = $line[4]; |
| 491 | - if ($line[5] == '') $values['date_first_reg'] = null; |
|
| 492 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
| 574 | + if ($line[5] == '') { |
|
| 575 | + $values['date_first_reg'] = null; |
|
| 576 | + } else { |
|
| 577 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
| 578 | + } |
|
| 493 | 579 | $values['cancel'] = ''; |
| 494 | 580 | } elseif ($country == '8Q') { |
| 495 | 581 | $values['registration'] = $line[0]; |
| 496 | 582 | $values['base'] = null; |
| 497 | 583 | $values['owner'] = $line[3]; |
| 498 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
| 499 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 584 | + if ($line[7] == '') { |
|
| 585 | + $values['date_first_reg'] = null; |
|
| 586 | + } else { |
|
| 587 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 588 | + } |
|
| 500 | 589 | $values['cancel'] = ''; |
| 501 | 590 | } elseif ($country == 'ZK' || $country == 'OM' || $country == 'TF') { |
| 502 | 591 | $values['registration'] = $line[0]; |
@@ -510,7 +599,9 @@ discard block |
||
| 510 | 599 | $sth_dest->execute($query_dest_values); |
| 511 | 600 | } |
| 512 | 601 | } |
| 513 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 602 | + if ($globalTransaction) { |
|
| 603 | + $Connection->db->commit(); |
|
| 604 | + } |
|
| 514 | 605 | } catch(PDOException $e) { |
| 515 | 606 | return "error : ".$e->getMessage(); |
| 516 | 607 | } |
@@ -644,25 +735,45 @@ discard block |
||
| 644 | 735 | VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)"; |
| 645 | 736 | $Connection = new Connection(); |
| 646 | 737 | $sth_dest = $Connection->db->prepare($query_dest); |
| 647 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 738 | + if ($globalTransaction) { |
|
| 739 | + $Connection->db->beginTransaction(); |
|
| 740 | + } |
|
| 648 | 741 | |
| 649 | 742 | $i = 0; |
| 650 | 743 | while($row = sparql_fetch_array($result)) |
| 651 | 744 | { |
| 652 | 745 | if ($i >= 1) { |
| 653 | 746 | //print_r($row); |
| 654 | - if (!isset($row['iata'])) $row['iata'] = ''; |
|
| 655 | - if (!isset($row['icao'])) $row['icao'] = ''; |
|
| 656 | - if (!isset($row['type'])) $row['type'] = ''; |
|
| 657 | - if (!isset($row['altitude'])) $row['altitude'] = ''; |
|
| 747 | + if (!isset($row['iata'])) { |
|
| 748 | + $row['iata'] = ''; |
|
| 749 | + } |
|
| 750 | + if (!isset($row['icao'])) { |
|
| 751 | + $row['icao'] = ''; |
|
| 752 | + } |
|
| 753 | + if (!isset($row['type'])) { |
|
| 754 | + $row['type'] = ''; |
|
| 755 | + } |
|
| 756 | + if (!isset($row['altitude'])) { |
|
| 757 | + $row['altitude'] = ''; |
|
| 758 | + } |
|
| 658 | 759 | if (isset($row['city_bis'])) { |
| 659 | 760 | $row['city'] = $row['city_bis']; |
| 660 | 761 | } |
| 661 | - if (!isset($row['city'])) $row['city'] = ''; |
|
| 662 | - if (!isset($row['country'])) $row['country'] = ''; |
|
| 663 | - if (!isset($row['homepage'])) $row['homepage'] = ''; |
|
| 664 | - if (!isset($row['wikipedia_page'])) $row['wikipedia_page'] = ''; |
|
| 665 | - if (!isset($row['name'])) continue; |
|
| 762 | + if (!isset($row['city'])) { |
|
| 763 | + $row['city'] = ''; |
|
| 764 | + } |
|
| 765 | + if (!isset($row['country'])) { |
|
| 766 | + $row['country'] = ''; |
|
| 767 | + } |
|
| 768 | + if (!isset($row['homepage'])) { |
|
| 769 | + $row['homepage'] = ''; |
|
| 770 | + } |
|
| 771 | + if (!isset($row['wikipedia_page'])) { |
|
| 772 | + $row['wikipedia_page'] = ''; |
|
| 773 | + } |
|
| 774 | + if (!isset($row['name'])) { |
|
| 775 | + continue; |
|
| 776 | + } |
|
| 666 | 777 | if (!isset($row['image'])) { |
| 667 | 778 | $row['image'] = ''; |
| 668 | 779 | $row['image_thumb'] = ''; |
@@ -698,7 +809,9 @@ discard block |
||
| 698 | 809 | |
| 699 | 810 | $i++; |
| 700 | 811 | } |
| 701 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 812 | + if ($globalTransaction) { |
|
| 813 | + $Connection->db->commit(); |
|
| 814 | + } |
|
| 702 | 815 | echo "Delete duplicate rows...\n"; |
| 703 | 816 | $query = 'ALTER IGNORE TABLE airport ADD UNIQUE INDEX icaoidx (icao)'; |
| 704 | 817 | try { |
@@ -710,7 +823,9 @@ discard block |
||
| 710 | 823 | } |
| 711 | 824 | |
| 712 | 825 | |
| 713 | - if ($globalDebug) echo "Insert Not available Airport...\n"; |
|
| 826 | + if ($globalDebug) { |
|
| 827 | + echo "Insert Not available Airport...\n"; |
|
| 828 | + } |
|
| 714 | 829 | $query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image`,`image_thumb`) |
| 715 | 830 | VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image, :image_thumb)"; |
| 716 | 831 | $query_values = array(':airport_id' => $i, ':name' => 'Not available',':iata' => 'NA',':icao' => 'NA',':latitude' => '0',':longitude' => '0',':altitude' => '0',':type' => 'NA',':city' => 'N/A',':country' => 'N/A',':home_link' => '',':wikipedia_link' => '',':image' => '',':image_thumb' => ''); |
@@ -737,7 +852,9 @@ discard block |
||
| 737 | 852 | $delimiter = ','; |
| 738 | 853 | $out_file = $tmp_dir.'airports.csv'; |
| 739 | 854 | update_db::download('http://ourairports.com/data/airports.csv',$out_file); |
| 740 | - if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
|
| 855 | + if (!file_exists($out_file) || !is_readable($out_file)) { |
|
| 856 | + return FALSE; |
|
| 857 | + } |
|
| 741 | 858 | echo "Add data from ourairports.com...\n"; |
| 742 | 859 | |
| 743 | 860 | $header = NULL; |
@@ -747,8 +864,9 @@ discard block |
||
| 747 | 864 | //$Connection->db->beginTransaction(); |
| 748 | 865 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 749 | 866 | { |
| 750 | - if(!$header) $header = $row; |
|
| 751 | - else { |
|
| 867 | + if(!$header) { |
|
| 868 | + $header = $row; |
|
| 869 | + } else { |
|
| 752 | 870 | $data = array(); |
| 753 | 871 | $data = array_combine($header, $row); |
| 754 | 872 | try { |
@@ -786,7 +904,9 @@ discard block |
||
| 786 | 904 | echo "Download data from another free database...\n"; |
| 787 | 905 | $out_file = $tmp_dir.'GlobalAirportDatabase.zip'; |
| 788 | 906 | update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file); |
| 789 | - if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
|
| 907 | + if (!file_exists($out_file) || !is_readable($out_file)) { |
|
| 908 | + return FALSE; |
|
| 909 | + } |
|
| 790 | 910 | update_db::unzip($out_file); |
| 791 | 911 | $header = NULL; |
| 792 | 912 | echo "Add data from another free database...\n"; |
@@ -797,8 +917,9 @@ discard block |
||
| 797 | 917 | //$Connection->db->beginTransaction(); |
| 798 | 918 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 799 | 919 | { |
| 800 | - if(!$header) $header = $row; |
|
| 801 | - else { |
|
| 920 | + if(!$header) { |
|
| 921 | + $header = $row; |
|
| 922 | + } else { |
|
| 802 | 923 | $data = $row; |
| 803 | 924 | |
| 804 | 925 | $query = 'UPDATE airport SET `city` = :city, `country` = :country WHERE icao = :icao'; |
@@ -1090,7 +1211,9 @@ discard block |
||
| 1090 | 1211 | if (($handle = fopen($filename, 'r')) !== FALSE) |
| 1091 | 1212 | { |
| 1092 | 1213 | $i = 0; |
| 1093 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1214 | + if ($globalTransaction) { |
|
| 1215 | + $Connection->db->beginTransaction(); |
|
| 1216 | + } |
|
| 1094 | 1217 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1095 | 1218 | { |
| 1096 | 1219 | $i++; |
@@ -1118,7 +1241,9 @@ discard block |
||
| 1118 | 1241 | } |
| 1119 | 1242 | } |
| 1120 | 1243 | fclose($handle); |
| 1121 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1244 | + if ($globalTransaction) { |
|
| 1245 | + $Connection->db->commit(); |
|
| 1246 | + } |
|
| 1122 | 1247 | } |
| 1123 | 1248 | return ''; |
| 1124 | 1249 | } |
@@ -1141,7 +1266,9 @@ discard block |
||
| 1141 | 1266 | $Connection = new Connection(); |
| 1142 | 1267 | if (($handle = fopen($filename, 'r')) !== FALSE) |
| 1143 | 1268 | { |
| 1144 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1269 | + if ($globalTransaction) { |
|
| 1270 | + $Connection->db->beginTransaction(); |
|
| 1271 | + } |
|
| 1145 | 1272 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1146 | 1273 | { |
| 1147 | 1274 | if(count($row) > 1) { |
@@ -1155,7 +1282,9 @@ discard block |
||
| 1155 | 1282 | } |
| 1156 | 1283 | } |
| 1157 | 1284 | fclose($handle); |
| 1158 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1285 | + if ($globalTransaction) { |
|
| 1286 | + $Connection->db->commit(); |
|
| 1287 | + } |
|
| 1159 | 1288 | } |
| 1160 | 1289 | return ''; |
| 1161 | 1290 | } |
@@ -1175,8 +1304,9 @@ discard block |
||
| 1175 | 1304 | } |
| 1176 | 1305 | |
| 1177 | 1306 | |
| 1178 | - if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
| 1179 | - else { |
|
| 1307 | + if ($globalDBdriver == 'mysql') { |
|
| 1308 | + update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
| 1309 | + } else { |
|
| 1180 | 1310 | update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
| 1181 | 1311 | $query = "CREATE EXTENSION postgis"; |
| 1182 | 1312 | $Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']); |
@@ -1195,19 +1325,29 @@ discard block |
||
| 1195 | 1325 | global $tmp_dir, $globalDebug; |
| 1196 | 1326 | include_once('class.create_db.php'); |
| 1197 | 1327 | require_once(dirname(__FILE__).'/../require/class.NOTAM.php'); |
| 1198 | - if ($globalDebug) echo "NOTAM from FlightAirMap website : Download..."; |
|
| 1328 | + if ($globalDebug) { |
|
| 1329 | + echo "NOTAM from FlightAirMap website : Download..."; |
|
| 1330 | + } |
|
| 1199 | 1331 | update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz'); |
| 1200 | 1332 | if (file_exists($tmp_dir.'notam.txt.gz')) { |
| 1201 | - if ($globalDebug) echo "Gunzip..."; |
|
| 1333 | + if ($globalDebug) { |
|
| 1334 | + echo "Gunzip..."; |
|
| 1335 | + } |
|
| 1202 | 1336 | update_db::gunzip($tmp_dir.'notam.txt.gz'); |
| 1203 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1337 | + if ($globalDebug) { |
|
| 1338 | + echo "Add to DB..."; |
|
| 1339 | + } |
|
| 1204 | 1340 | //$error = create_db::import_file($tmp_dir.'notam.sql'); |
| 1205 | 1341 | $NOTAM = new NOTAM(); |
| 1206 | 1342 | $NOTAM->updateNOTAMfromTextFile($tmp_dir.'notam.txt'); |
| 1207 | - } else $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed."; |
|
| 1343 | + } else { |
|
| 1344 | + $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed."; |
|
| 1345 | + } |
|
| 1208 | 1346 | if ($error != '') { |
| 1209 | 1347 | return $error; |
| 1210 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1348 | + } elseif ($globalDebug) { |
|
| 1349 | + echo "Done\n"; |
|
| 1350 | + } |
|
| 1211 | 1351 | return ''; |
| 1212 | 1352 | } |
| 1213 | 1353 | |
@@ -1261,67 +1401,111 @@ discard block |
||
| 1261 | 1401 | //if ($globalDebug) echo "IVAO : Download..."; |
| 1262 | 1402 | //update_db::download('http://fr.mirror.ivao.aero/software/ivae_feb2013.zip',$tmp_dir.'ivae_feb2013.zip'); |
| 1263 | 1403 | if (file_exists($tmp_dir.'ivae_feb2013.zip')) { |
| 1264 | - if ($globalDebug) echo "Unzip..."; |
|
| 1404 | + if ($globalDebug) { |
|
| 1405 | + echo "Unzip..."; |
|
| 1406 | + } |
|
| 1265 | 1407 | update_db::unzip($tmp_dir.'ivae_feb2013.zip'); |
| 1266 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1408 | + if ($globalDebug) { |
|
| 1409 | + echo "Add to DB..."; |
|
| 1410 | + } |
|
| 1267 | 1411 | update_db::ivao_airlines($tmp_dir.'data/airlines.dat'); |
| 1268 | - if ($globalDebug) echo "Copy airlines logos to airlines images directory..."; |
|
| 1412 | + if ($globalDebug) { |
|
| 1413 | + echo "Copy airlines logos to airlines images directory..."; |
|
| 1414 | + } |
|
| 1269 | 1415 | if (is_writable(dirname(__FILE__).'/../images/airlines')) { |
| 1270 | - if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
| 1271 | - } else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
|
| 1272 | - } else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
|
| 1416 | + if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) { |
|
| 1417 | + $error = "Failed to copy airlines logo."; |
|
| 1418 | + } |
|
| 1419 | + } else { |
|
| 1420 | + $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
|
| 1421 | + } |
|
| 1422 | + } else { |
|
| 1423 | + $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
|
| 1424 | + } |
|
| 1273 | 1425 | if ($error != '') { |
| 1274 | 1426 | return $error; |
| 1275 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1427 | + } elseif ($globalDebug) { |
|
| 1428 | + echo "Done\n"; |
|
| 1429 | + } |
|
| 1276 | 1430 | return ''; |
| 1277 | 1431 | } |
| 1278 | 1432 | |
| 1279 | 1433 | public static function update_routes() { |
| 1280 | 1434 | global $tmp_dir, $globalDebug; |
| 1281 | 1435 | $error = ''; |
| 1282 | - if ($globalDebug) echo "Routes : Download..."; |
|
| 1436 | + if ($globalDebug) { |
|
| 1437 | + echo "Routes : Download..."; |
|
| 1438 | + } |
|
| 1283 | 1439 | update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz'); |
| 1284 | 1440 | if (file_exists($tmp_dir.'StandingData.sqb.gz')) { |
| 1285 | - if ($globalDebug) echo "Gunzip..."; |
|
| 1441 | + if ($globalDebug) { |
|
| 1442 | + echo "Gunzip..."; |
|
| 1443 | + } |
|
| 1286 | 1444 | update_db::gunzip($tmp_dir.'StandingData.sqb.gz'); |
| 1287 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1445 | + if ($globalDebug) { |
|
| 1446 | + echo "Add to DB..."; |
|
| 1447 | + } |
|
| 1288 | 1448 | $error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb'); |
| 1289 | - } else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed."; |
|
| 1449 | + } else { |
|
| 1450 | + $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed."; |
|
| 1451 | + } |
|
| 1290 | 1452 | if ($error != '') { |
| 1291 | 1453 | return $error; |
| 1292 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1454 | + } elseif ($globalDebug) { |
|
| 1455 | + echo "Done\n"; |
|
| 1456 | + } |
|
| 1293 | 1457 | return ''; |
| 1294 | 1458 | } |
| 1295 | 1459 | public static function update_oneworld() { |
| 1296 | 1460 | global $tmp_dir, $globalDebug; |
| 1297 | 1461 | $error = ''; |
| 1298 | - if ($globalDebug) echo "Schedules Oneworld : Download..."; |
|
| 1462 | + if ($globalDebug) { |
|
| 1463 | + echo "Schedules Oneworld : Download..."; |
|
| 1464 | + } |
|
| 1299 | 1465 | update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz'); |
| 1300 | 1466 | if (file_exists($tmp_dir.'oneworld.csv.gz')) { |
| 1301 | - if ($globalDebug) echo "Gunzip..."; |
|
| 1467 | + if ($globalDebug) { |
|
| 1468 | + echo "Gunzip..."; |
|
| 1469 | + } |
|
| 1302 | 1470 | update_db::gunzip($tmp_dir.'oneworld.csv.gz'); |
| 1303 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1471 | + if ($globalDebug) { |
|
| 1472 | + echo "Add to DB..."; |
|
| 1473 | + } |
|
| 1304 | 1474 | $error = update_db::retrieve_route_oneworld($tmp_dir.'oneworld.csv'); |
| 1305 | - } else $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed."; |
|
| 1475 | + } else { |
|
| 1476 | + $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed."; |
|
| 1477 | + } |
|
| 1306 | 1478 | if ($error != '') { |
| 1307 | 1479 | return $error; |
| 1308 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1480 | + } elseif ($globalDebug) { |
|
| 1481 | + echo "Done\n"; |
|
| 1482 | + } |
|
| 1309 | 1483 | return ''; |
| 1310 | 1484 | } |
| 1311 | 1485 | public static function update_skyteam() { |
| 1312 | 1486 | global $tmp_dir, $globalDebug; |
| 1313 | 1487 | $error = ''; |
| 1314 | - if ($globalDebug) echo "Schedules Skyteam : Download..."; |
|
| 1488 | + if ($globalDebug) { |
|
| 1489 | + echo "Schedules Skyteam : Download..."; |
|
| 1490 | + } |
|
| 1315 | 1491 | update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz'); |
| 1316 | 1492 | if (file_exists($tmp_dir.'skyteam.csv.gz')) { |
| 1317 | - if ($globalDebug) echo "Gunzip..."; |
|
| 1493 | + if ($globalDebug) { |
|
| 1494 | + echo "Gunzip..."; |
|
| 1495 | + } |
|
| 1318 | 1496 | update_db::gunzip($tmp_dir.'skyteam.csv.gz'); |
| 1319 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1497 | + if ($globalDebug) { |
|
| 1498 | + echo "Add to DB..."; |
|
| 1499 | + } |
|
| 1320 | 1500 | $error = update_db::retrieve_route_skyteam($tmp_dir.'skyteam.csv'); |
| 1321 | - } else $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed."; |
|
| 1501 | + } else { |
|
| 1502 | + $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed."; |
|
| 1503 | + } |
|
| 1322 | 1504 | if ($error != '') { |
| 1323 | 1505 | return $error; |
| 1324 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1506 | + } elseif ($globalDebug) { |
|
| 1507 | + echo "Done\n"; |
|
| 1508 | + } |
|
| 1325 | 1509 | return ''; |
| 1326 | 1510 | } |
| 1327 | 1511 | public static function update_ModeS() { |
@@ -1338,275 +1522,483 @@ discard block |
||
| 1338 | 1522 | exit; |
| 1339 | 1523 | } elseif ($globalDebug) echo "Done\n"; |
| 1340 | 1524 | */ |
| 1341 | - if ($globalDebug) echo "Modes : Download..."; |
|
| 1525 | + if ($globalDebug) { |
|
| 1526 | + echo "Modes : Download..."; |
|
| 1527 | + } |
|
| 1342 | 1528 | update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
| 1343 | 1529 | if (file_exists($tmp_dir.'basestation_latest.zip')) { |
| 1344 | - if ($globalDebug) echo "Unzip..."; |
|
| 1530 | + if ($globalDebug) { |
|
| 1531 | + echo "Unzip..."; |
|
| 1532 | + } |
|
| 1345 | 1533 | update_db::unzip($tmp_dir.'basestation_latest.zip'); |
| 1346 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1534 | + if ($globalDebug) { |
|
| 1535 | + echo "Add to DB..."; |
|
| 1536 | + } |
|
| 1347 | 1537 | $error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb'); |
| 1348 | - } else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed."; |
|
| 1538 | + } else { |
|
| 1539 | + $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed."; |
|
| 1540 | + } |
|
| 1349 | 1541 | if ($error != '') { |
| 1350 | 1542 | return $error; |
| 1351 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1543 | + } elseif ($globalDebug) { |
|
| 1544 | + echo "Done\n"; |
|
| 1545 | + } |
|
| 1352 | 1546 | return ''; |
| 1353 | 1547 | } |
| 1354 | 1548 | |
| 1355 | 1549 | public static function update_ModeS_flarm() { |
| 1356 | 1550 | global $tmp_dir, $globalDebug; |
| 1357 | - if ($globalDebug) echo "Modes Flarmnet: Download..."; |
|
| 1551 | + if ($globalDebug) { |
|
| 1552 | + echo "Modes Flarmnet: Download..."; |
|
| 1553 | + } |
|
| 1358 | 1554 | update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln'); |
| 1359 | 1555 | if (file_exists($tmp_dir.'data.fln')) { |
| 1360 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1556 | + if ($globalDebug) { |
|
| 1557 | + echo "Add to DB..."; |
|
| 1558 | + } |
|
| 1361 | 1559 | $error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln'); |
| 1362 | - } else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed."; |
|
| 1560 | + } else { |
|
| 1561 | + $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed."; |
|
| 1562 | + } |
|
| 1363 | 1563 | if ($error != '') { |
| 1364 | 1564 | return $error; |
| 1365 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1565 | + } elseif ($globalDebug) { |
|
| 1566 | + echo "Done\n"; |
|
| 1567 | + } |
|
| 1366 | 1568 | return ''; |
| 1367 | 1569 | } |
| 1368 | 1570 | |
| 1369 | 1571 | public static function update_ModeS_ogn() { |
| 1370 | 1572 | global $tmp_dir, $globalDebug; |
| 1371 | - if ($globalDebug) echo "Modes OGN: Download..."; |
|
| 1573 | + if ($globalDebug) { |
|
| 1574 | + echo "Modes OGN: Download..."; |
|
| 1575 | + } |
|
| 1372 | 1576 | update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv'); |
| 1373 | 1577 | if (file_exists($tmp_dir.'ogn.csv')) { |
| 1374 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1578 | + if ($globalDebug) { |
|
| 1579 | + echo "Add to DB..."; |
|
| 1580 | + } |
|
| 1375 | 1581 | $error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv'); |
| 1376 | - } else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed."; |
|
| 1582 | + } else { |
|
| 1583 | + $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed."; |
|
| 1584 | + } |
|
| 1377 | 1585 | if ($error != '') { |
| 1378 | 1586 | return $error; |
| 1379 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1587 | + } elseif ($globalDebug) { |
|
| 1588 | + echo "Done\n"; |
|
| 1589 | + } |
|
| 1380 | 1590 | return ''; |
| 1381 | 1591 | } |
| 1382 | 1592 | |
| 1383 | 1593 | public static function update_owner() { |
| 1384 | 1594 | global $tmp_dir, $globalDebug; |
| 1385 | 1595 | |
| 1386 | - if ($globalDebug) echo "Owner France: Download..."; |
|
| 1596 | + if ($globalDebug) { |
|
| 1597 | + echo "Owner France: Download..."; |
|
| 1598 | + } |
|
| 1387 | 1599 | update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv'); |
| 1388 | 1600 | if (file_exists($tmp_dir.'owner_f.csv')) { |
| 1389 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1601 | + if ($globalDebug) { |
|
| 1602 | + echo "Add to DB..."; |
|
| 1603 | + } |
|
| 1390 | 1604 | $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F'); |
| 1391 | - } else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
|
| 1605 | + } else { |
|
| 1606 | + $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
|
| 1607 | + } |
|
| 1392 | 1608 | if ($error != '') { |
| 1393 | 1609 | return $error; |
| 1394 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1610 | + } elseif ($globalDebug) { |
|
| 1611 | + echo "Done\n"; |
|
| 1612 | + } |
|
| 1395 | 1613 | |
| 1396 | - if ($globalDebug) echo "Owner Ireland: Download..."; |
|
| 1614 | + if ($globalDebug) { |
|
| 1615 | + echo "Owner Ireland: Download..."; |
|
| 1616 | + } |
|
| 1397 | 1617 | update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv'); |
| 1398 | 1618 | if (file_exists($tmp_dir.'owner_ei.csv')) { |
| 1399 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1619 | + if ($globalDebug) { |
|
| 1620 | + echo "Add to DB..."; |
|
| 1621 | + } |
|
| 1400 | 1622 | $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI'); |
| 1401 | - } else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
|
| 1623 | + } else { |
|
| 1624 | + $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
|
| 1625 | + } |
|
| 1402 | 1626 | if ($error != '') { |
| 1403 | 1627 | return $error; |
| 1404 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1405 | - if ($globalDebug) echo "Owner Switzerland: Download..."; |
|
| 1628 | + } elseif ($globalDebug) { |
|
| 1629 | + echo "Done\n"; |
|
| 1630 | + } |
|
| 1631 | + if ($globalDebug) { |
|
| 1632 | + echo "Owner Switzerland: Download..."; |
|
| 1633 | + } |
|
| 1406 | 1634 | update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv'); |
| 1407 | 1635 | if (file_exists($tmp_dir.'owner_hb.csv')) { |
| 1408 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1636 | + if ($globalDebug) { |
|
| 1637 | + echo "Add to DB..."; |
|
| 1638 | + } |
|
| 1409 | 1639 | $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB'); |
| 1410 | - } else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
|
| 1640 | + } else { |
|
| 1641 | + $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
|
| 1642 | + } |
|
| 1411 | 1643 | if ($error != '') { |
| 1412 | 1644 | return $error; |
| 1413 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1414 | - if ($globalDebug) echo "Owner Czech Republic: Download..."; |
|
| 1645 | + } elseif ($globalDebug) { |
|
| 1646 | + echo "Done\n"; |
|
| 1647 | + } |
|
| 1648 | + if ($globalDebug) { |
|
| 1649 | + echo "Owner Czech Republic: Download..."; |
|
| 1650 | + } |
|
| 1415 | 1651 | update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv'); |
| 1416 | 1652 | if (file_exists($tmp_dir.'owner_ok.csv')) { |
| 1417 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1653 | + if ($globalDebug) { |
|
| 1654 | + echo "Add to DB..."; |
|
| 1655 | + } |
|
| 1418 | 1656 | $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK'); |
| 1419 | - } else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
|
| 1657 | + } else { |
|
| 1658 | + $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
|
| 1659 | + } |
|
| 1420 | 1660 | if ($error != '') { |
| 1421 | 1661 | return $error; |
| 1422 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1423 | - if ($globalDebug) echo "Owner Australia: Download..."; |
|
| 1662 | + } elseif ($globalDebug) { |
|
| 1663 | + echo "Done\n"; |
|
| 1664 | + } |
|
| 1665 | + if ($globalDebug) { |
|
| 1666 | + echo "Owner Australia: Download..."; |
|
| 1667 | + } |
|
| 1424 | 1668 | update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv'); |
| 1425 | 1669 | if (file_exists($tmp_dir.'owner_vh.csv')) { |
| 1426 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1670 | + if ($globalDebug) { |
|
| 1671 | + echo "Add to DB..."; |
|
| 1672 | + } |
|
| 1427 | 1673 | $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH'); |
| 1428 | - } else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
|
| 1674 | + } else { |
|
| 1675 | + $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
|
| 1676 | + } |
|
| 1429 | 1677 | if ($error != '') { |
| 1430 | 1678 | return $error; |
| 1431 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1432 | - if ($globalDebug) echo "Owner Austria: Download..."; |
|
| 1679 | + } elseif ($globalDebug) { |
|
| 1680 | + echo "Done\n"; |
|
| 1681 | + } |
|
| 1682 | + if ($globalDebug) { |
|
| 1683 | + echo "Owner Austria: Download..."; |
|
| 1684 | + } |
|
| 1433 | 1685 | update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv'); |
| 1434 | 1686 | if (file_exists($tmp_dir.'owner_oe.csv')) { |
| 1435 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1687 | + if ($globalDebug) { |
|
| 1688 | + echo "Add to DB..."; |
|
| 1689 | + } |
|
| 1436 | 1690 | $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE'); |
| 1437 | - } else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
|
| 1691 | + } else { |
|
| 1692 | + $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
|
| 1693 | + } |
|
| 1438 | 1694 | if ($error != '') { |
| 1439 | 1695 | return $error; |
| 1440 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1441 | - if ($globalDebug) echo "Owner Chile: Download..."; |
|
| 1696 | + } elseif ($globalDebug) { |
|
| 1697 | + echo "Done\n"; |
|
| 1698 | + } |
|
| 1699 | + if ($globalDebug) { |
|
| 1700 | + echo "Owner Chile: Download..."; |
|
| 1701 | + } |
|
| 1442 | 1702 | update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv'); |
| 1443 | 1703 | if (file_exists($tmp_dir.'owner_cc.csv')) { |
| 1444 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1704 | + if ($globalDebug) { |
|
| 1705 | + echo "Add to DB..."; |
|
| 1706 | + } |
|
| 1445 | 1707 | $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC'); |
| 1446 | - } else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
|
| 1708 | + } else { |
|
| 1709 | + $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
|
| 1710 | + } |
|
| 1447 | 1711 | if ($error != '') { |
| 1448 | 1712 | return $error; |
| 1449 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1450 | - if ($globalDebug) echo "Owner Colombia: Download..."; |
|
| 1713 | + } elseif ($globalDebug) { |
|
| 1714 | + echo "Done\n"; |
|
| 1715 | + } |
|
| 1716 | + if ($globalDebug) { |
|
| 1717 | + echo "Owner Colombia: Download..."; |
|
| 1718 | + } |
|
| 1451 | 1719 | update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv'); |
| 1452 | 1720 | if (file_exists($tmp_dir.'owner_hj.csv')) { |
| 1453 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1721 | + if ($globalDebug) { |
|
| 1722 | + echo "Add to DB..."; |
|
| 1723 | + } |
|
| 1454 | 1724 | $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ'); |
| 1455 | - } else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
|
| 1725 | + } else { |
|
| 1726 | + $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
|
| 1727 | + } |
|
| 1456 | 1728 | if ($error != '') { |
| 1457 | 1729 | return $error; |
| 1458 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1459 | - if ($globalDebug) echo "Owner Bosnia Herzegobina: Download..."; |
|
| 1730 | + } elseif ($globalDebug) { |
|
| 1731 | + echo "Done\n"; |
|
| 1732 | + } |
|
| 1733 | + if ($globalDebug) { |
|
| 1734 | + echo "Owner Bosnia Herzegobina: Download..."; |
|
| 1735 | + } |
|
| 1460 | 1736 | update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv'); |
| 1461 | 1737 | if (file_exists($tmp_dir.'owner_e7.csv')) { |
| 1462 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1738 | + if ($globalDebug) { |
|
| 1739 | + echo "Add to DB..."; |
|
| 1740 | + } |
|
| 1463 | 1741 | $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7'); |
| 1464 | - } else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
|
| 1742 | + } else { |
|
| 1743 | + $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
|
| 1744 | + } |
|
| 1465 | 1745 | if ($error != '') { |
| 1466 | 1746 | return $error; |
| 1467 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1468 | - if ($globalDebug) echo "Owner Brazil: Download..."; |
|
| 1747 | + } elseif ($globalDebug) { |
|
| 1748 | + echo "Done\n"; |
|
| 1749 | + } |
|
| 1750 | + if ($globalDebug) { |
|
| 1751 | + echo "Owner Brazil: Download..."; |
|
| 1752 | + } |
|
| 1469 | 1753 | update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv'); |
| 1470 | 1754 | if (file_exists($tmp_dir.'owner_pp.csv')) { |
| 1471 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1755 | + if ($globalDebug) { |
|
| 1756 | + echo "Add to DB..."; |
|
| 1757 | + } |
|
| 1472 | 1758 | $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP'); |
| 1473 | - } else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
|
| 1759 | + } else { |
|
| 1760 | + $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
|
| 1761 | + } |
|
| 1474 | 1762 | if ($error != '') { |
| 1475 | 1763 | return $error; |
| 1476 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1477 | - if ($globalDebug) echo "Owner Cayman Islands: Download..."; |
|
| 1764 | + } elseif ($globalDebug) { |
|
| 1765 | + echo "Done\n"; |
|
| 1766 | + } |
|
| 1767 | + if ($globalDebug) { |
|
| 1768 | + echo "Owner Cayman Islands: Download..."; |
|
| 1769 | + } |
|
| 1478 | 1770 | update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv'); |
| 1479 | 1771 | if (file_exists($tmp_dir.'owner_vp.csv')) { |
| 1480 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1772 | + if ($globalDebug) { |
|
| 1773 | + echo "Add to DB..."; |
|
| 1774 | + } |
|
| 1481 | 1775 | $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP'); |
| 1482 | - } else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
|
| 1776 | + } else { |
|
| 1777 | + $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
|
| 1778 | + } |
|
| 1483 | 1779 | if ($error != '') { |
| 1484 | 1780 | return $error; |
| 1485 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1486 | - if ($globalDebug) echo "Owner Croatia: Download..."; |
|
| 1781 | + } elseif ($globalDebug) { |
|
| 1782 | + echo "Done\n"; |
|
| 1783 | + } |
|
| 1784 | + if ($globalDebug) { |
|
| 1785 | + echo "Owner Croatia: Download..."; |
|
| 1786 | + } |
|
| 1487 | 1787 | update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv'); |
| 1488 | 1788 | if (file_exists($tmp_dir.'owner_9a.csv')) { |
| 1489 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1789 | + if ($globalDebug) { |
|
| 1790 | + echo "Add to DB..."; |
|
| 1791 | + } |
|
| 1490 | 1792 | $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A'); |
| 1491 | - } else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
|
| 1793 | + } else { |
|
| 1794 | + $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
|
| 1795 | + } |
|
| 1492 | 1796 | if ($error != '') { |
| 1493 | 1797 | return $error; |
| 1494 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1495 | - if ($globalDebug) echo "Owner Luxembourg: Download..."; |
|
| 1798 | + } elseif ($globalDebug) { |
|
| 1799 | + echo "Done\n"; |
|
| 1800 | + } |
|
| 1801 | + if ($globalDebug) { |
|
| 1802 | + echo "Owner Luxembourg: Download..."; |
|
| 1803 | + } |
|
| 1496 | 1804 | update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv'); |
| 1497 | 1805 | if (file_exists($tmp_dir.'owner_lx.csv')) { |
| 1498 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1806 | + if ($globalDebug) { |
|
| 1807 | + echo "Add to DB..."; |
|
| 1808 | + } |
|
| 1499 | 1809 | $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX'); |
| 1500 | - } else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
|
| 1810 | + } else { |
|
| 1811 | + $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
|
| 1812 | + } |
|
| 1501 | 1813 | if ($error != '') { |
| 1502 | 1814 | return $error; |
| 1503 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1504 | - if ($globalDebug) echo "Owner Maldives: Download..."; |
|
| 1815 | + } elseif ($globalDebug) { |
|
| 1816 | + echo "Done\n"; |
|
| 1817 | + } |
|
| 1818 | + if ($globalDebug) { |
|
| 1819 | + echo "Owner Maldives: Download..."; |
|
| 1820 | + } |
|
| 1505 | 1821 | update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv'); |
| 1506 | 1822 | if (file_exists($tmp_dir.'owner_8q.csv')) { |
| 1507 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1823 | + if ($globalDebug) { |
|
| 1824 | + echo "Add to DB..."; |
|
| 1825 | + } |
|
| 1508 | 1826 | $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q'); |
| 1509 | - } else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
|
| 1827 | + } else { |
|
| 1828 | + $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
|
| 1829 | + } |
|
| 1510 | 1830 | if ($error != '') { |
| 1511 | 1831 | return $error; |
| 1512 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1513 | - if ($globalDebug) echo "Owner New Zealand: Download..."; |
|
| 1832 | + } elseif ($globalDebug) { |
|
| 1833 | + echo "Done\n"; |
|
| 1834 | + } |
|
| 1835 | + if ($globalDebug) { |
|
| 1836 | + echo "Owner New Zealand: Download..."; |
|
| 1837 | + } |
|
| 1514 | 1838 | update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv'); |
| 1515 | 1839 | if (file_exists($tmp_dir.'owner_zk.csv')) { |
| 1516 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1840 | + if ($globalDebug) { |
|
| 1841 | + echo "Add to DB..."; |
|
| 1842 | + } |
|
| 1517 | 1843 | $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK'); |
| 1518 | - } else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
|
| 1844 | + } else { |
|
| 1845 | + $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
|
| 1846 | + } |
|
| 1519 | 1847 | if ($error != '') { |
| 1520 | 1848 | return $error; |
| 1521 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1522 | - if ($globalDebug) echo "Owner Papua New Guinea: Download..."; |
|
| 1849 | + } elseif ($globalDebug) { |
|
| 1850 | + echo "Done\n"; |
|
| 1851 | + } |
|
| 1852 | + if ($globalDebug) { |
|
| 1853 | + echo "Owner Papua New Guinea: Download..."; |
|
| 1854 | + } |
|
| 1523 | 1855 | update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv'); |
| 1524 | 1856 | if (file_exists($tmp_dir.'owner_p2.csv')) { |
| 1525 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1857 | + if ($globalDebug) { |
|
| 1858 | + echo "Add to DB..."; |
|
| 1859 | + } |
|
| 1526 | 1860 | $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2'); |
| 1527 | - } else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
|
| 1861 | + } else { |
|
| 1862 | + $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
|
| 1863 | + } |
|
| 1528 | 1864 | if ($error != '') { |
| 1529 | 1865 | return $error; |
| 1530 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1531 | - if ($globalDebug) echo "Owner Slovakia: Download..."; |
|
| 1866 | + } elseif ($globalDebug) { |
|
| 1867 | + echo "Done\n"; |
|
| 1868 | + } |
|
| 1869 | + if ($globalDebug) { |
|
| 1870 | + echo "Owner Slovakia: Download..."; |
|
| 1871 | + } |
|
| 1532 | 1872 | update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv'); |
| 1533 | 1873 | if (file_exists($tmp_dir.'owner_om.csv')) { |
| 1534 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1874 | + if ($globalDebug) { |
|
| 1875 | + echo "Add to DB..."; |
|
| 1876 | + } |
|
| 1535 | 1877 | $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM'); |
| 1536 | - } else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
|
| 1878 | + } else { |
|
| 1879 | + $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
|
| 1880 | + } |
|
| 1537 | 1881 | if ($error != '') { |
| 1538 | 1882 | return $error; |
| 1539 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1540 | - if ($globalDebug) echo "Owner Ecuador: Download..."; |
|
| 1883 | + } elseif ($globalDebug) { |
|
| 1884 | + echo "Done\n"; |
|
| 1885 | + } |
|
| 1886 | + if ($globalDebug) { |
|
| 1887 | + echo "Owner Ecuador: Download..."; |
|
| 1888 | + } |
|
| 1541 | 1889 | update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv'); |
| 1542 | 1890 | if (file_exists($tmp_dir.'owner_hc.csv')) { |
| 1543 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1891 | + if ($globalDebug) { |
|
| 1892 | + echo "Add to DB..."; |
|
| 1893 | + } |
|
| 1544 | 1894 | $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC'); |
| 1545 | - } else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
|
| 1895 | + } else { |
|
| 1896 | + $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
|
| 1897 | + } |
|
| 1546 | 1898 | if ($error != '') { |
| 1547 | 1899 | return $error; |
| 1548 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1549 | - if ($globalDebug) echo "Owner Iceland: Download..."; |
|
| 1900 | + } elseif ($globalDebug) { |
|
| 1901 | + echo "Done\n"; |
|
| 1902 | + } |
|
| 1903 | + if ($globalDebug) { |
|
| 1904 | + echo "Owner Iceland: Download..."; |
|
| 1905 | + } |
|
| 1550 | 1906 | update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv'); |
| 1551 | 1907 | if (file_exists($tmp_dir.'owner_tf.csv')) { |
| 1552 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1908 | + if ($globalDebug) { |
|
| 1909 | + echo "Add to DB..."; |
|
| 1910 | + } |
|
| 1553 | 1911 | $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF'); |
| 1554 | - } else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
|
| 1912 | + } else { |
|
| 1913 | + $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
|
| 1914 | + } |
|
| 1555 | 1915 | if ($error != '') { |
| 1556 | 1916 | return $error; |
| 1557 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1917 | + } elseif ($globalDebug) { |
|
| 1918 | + echo "Done\n"; |
|
| 1919 | + } |
|
| 1558 | 1920 | return ''; |
| 1559 | 1921 | } |
| 1560 | 1922 | |
| 1561 | 1923 | public static function update_translation() { |
| 1562 | 1924 | global $tmp_dir, $globalDebug; |
| 1563 | 1925 | $error = ''; |
| 1564 | - if ($globalDebug) echo "Translation : Download..."; |
|
| 1926 | + if ($globalDebug) { |
|
| 1927 | + echo "Translation : Download..."; |
|
| 1928 | + } |
|
| 1565 | 1929 | update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip'); |
| 1566 | 1930 | if (file_exists($tmp_dir.'translation.zip')) { |
| 1567 | - if ($globalDebug) echo "Unzip..."; |
|
| 1931 | + if ($globalDebug) { |
|
| 1932 | + echo "Unzip..."; |
|
| 1933 | + } |
|
| 1568 | 1934 | update_db::unzip($tmp_dir.'translation.zip'); |
| 1569 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1935 | + if ($globalDebug) { |
|
| 1936 | + echo "Add to DB..."; |
|
| 1937 | + } |
|
| 1570 | 1938 | $error = update_db::translation(); |
| 1571 | - } else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed."; |
|
| 1939 | + } else { |
|
| 1940 | + $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed."; |
|
| 1941 | + } |
|
| 1572 | 1942 | if ($error != '') { |
| 1573 | 1943 | return $error; |
| 1574 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1944 | + } elseif ($globalDebug) { |
|
| 1945 | + echo "Done\n"; |
|
| 1946 | + } |
|
| 1575 | 1947 | return ''; |
| 1576 | 1948 | } |
| 1577 | 1949 | |
| 1578 | 1950 | public static function update_translation_fam() { |
| 1579 | 1951 | global $tmp_dir, $globalDebug; |
| 1580 | - if ($globalDebug) echo "Translation from FlightAirMap website : Download..."; |
|
| 1952 | + if ($globalDebug) { |
|
| 1953 | + echo "Translation from FlightAirMap website : Download..."; |
|
| 1954 | + } |
|
| 1581 | 1955 | update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz'); |
| 1582 | 1956 | if (file_exists($tmp_dir.'translation.tsv.gz')) { |
| 1583 | - if ($globalDebug) echo "Gunzip..."; |
|
| 1957 | + if ($globalDebug) { |
|
| 1958 | + echo "Gunzip..."; |
|
| 1959 | + } |
|
| 1584 | 1960 | update_db::gunzip($tmp_dir.'translation.tsv.gz'); |
| 1585 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1961 | + if ($globalDebug) { |
|
| 1962 | + echo "Add to DB..."; |
|
| 1963 | + } |
|
| 1586 | 1964 | $error = update_db::translation_fam(); |
| 1587 | - } else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed."; |
|
| 1965 | + } else { |
|
| 1966 | + $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed."; |
|
| 1967 | + } |
|
| 1588 | 1968 | if ($error != '') { |
| 1589 | 1969 | return $error; |
| 1590 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1970 | + } elseif ($globalDebug) { |
|
| 1971 | + echo "Done\n"; |
|
| 1972 | + } |
|
| 1591 | 1973 | return ''; |
| 1592 | 1974 | } |
| 1593 | 1975 | |
| 1594 | 1976 | public static function update_tle() { |
| 1595 | 1977 | global $tmp_dir, $globalDebug; |
| 1596 | - if ($globalDebug) echo "Download TLE : Download..."; |
|
| 1978 | + if ($globalDebug) { |
|
| 1979 | + echo "Download TLE : Download..."; |
|
| 1980 | + } |
|
| 1597 | 1981 | $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', |
| 1598 | 1982 | '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', |
| 1599 | 1983 | 'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt'); |
| 1600 | 1984 | foreach ($alltle as $filename) { |
| 1601 | - if ($globalDebug) echo "downloading ".$filename.'...'; |
|
| 1985 | + if ($globalDebug) { |
|
| 1986 | + echo "downloading ".$filename.'...'; |
|
| 1987 | + } |
|
| 1602 | 1988 | update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename); |
| 1603 | 1989 | if (file_exists($tmp_dir.$filename)) { |
| 1604 | - if ($globalDebug) echo "Add to DB ".$filename."..."; |
|
| 1990 | + if ($globalDebug) { |
|
| 1991 | + echo "Add to DB ".$filename."..."; |
|
| 1992 | + } |
|
| 1605 | 1993 | $error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename)); |
| 1606 | - } else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
|
| 1994 | + } else { |
|
| 1995 | + $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
|
| 1996 | + } |
|
| 1607 | 1997 | if ($error != '') { |
| 1608 | 1998 | echo $error."\n"; |
| 1609 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1999 | + } elseif ($globalDebug) { |
|
| 2000 | + echo "Done\n"; |
|
| 2001 | + } |
|
| 1610 | 2002 | } |
| 1611 | 2003 | return ''; |
| 1612 | 2004 | } |
@@ -1614,10 +2006,14 @@ discard block |
||
| 1614 | 2006 | public static function update_models() { |
| 1615 | 2007 | global $tmp_dir, $globalDebug; |
| 1616 | 2008 | $error = ''; |
| 1617 | - if ($globalDebug) echo "Models from FlightAirMap website : Download..."; |
|
| 2009 | + if ($globalDebug) { |
|
| 2010 | + echo "Models from FlightAirMap website : Download..."; |
|
| 2011 | + } |
|
| 1618 | 2012 | update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum'); |
| 1619 | 2013 | if (file_exists($tmp_dir.'models.md5sum')) { |
| 1620 | - if ($globalDebug) echo "Check files...\n"; |
|
| 2014 | + if ($globalDebug) { |
|
| 2015 | + echo "Check files...\n"; |
|
| 2016 | + } |
|
| 1621 | 2017 | $newmodelsdb = array(); |
| 1622 | 2018 | if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) { |
| 1623 | 2019 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -1636,25 +2032,35 @@ discard block |
||
| 1636 | 2032 | } |
| 1637 | 2033 | $diff = array_diff($newmodelsdb,$modelsdb); |
| 1638 | 2034 | foreach ($diff as $key => $value) { |
| 1639 | - if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n"; |
|
| 2035 | + if ($globalDebug) { |
|
| 2036 | + echo 'Downloading model '.$key.' ...'."\n"; |
|
| 2037 | + } |
|
| 1640 | 2038 | update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key); |
| 1641 | 2039 | |
| 1642 | 2040 | } |
| 1643 | 2041 | update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum'); |
| 1644 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 2042 | + } else { |
|
| 2043 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 2044 | + } |
|
| 1645 | 2045 | if ($error != '') { |
| 1646 | 2046 | return $error; |
| 1647 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2047 | + } elseif ($globalDebug) { |
|
| 2048 | + echo "Done\n"; |
|
| 2049 | + } |
|
| 1648 | 2050 | return ''; |
| 1649 | 2051 | } |
| 1650 | 2052 | |
| 1651 | 2053 | public static function update_space_models() { |
| 1652 | 2054 | global $tmp_dir, $globalDebug; |
| 1653 | 2055 | $error = ''; |
| 1654 | - if ($globalDebug) echo "Space models from FlightAirMap website : Download..."; |
|
| 2056 | + if ($globalDebug) { |
|
| 2057 | + echo "Space models from FlightAirMap website : Download..."; |
|
| 2058 | + } |
|
| 1655 | 2059 | update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum'); |
| 1656 | 2060 | if (file_exists($tmp_dir.'space_models.md5sum')) { |
| 1657 | - if ($globalDebug) echo "Check files...\n"; |
|
| 2061 | + if ($globalDebug) { |
|
| 2062 | + echo "Check files...\n"; |
|
| 2063 | + } |
|
| 1658 | 2064 | $newmodelsdb = array(); |
| 1659 | 2065 | if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) { |
| 1660 | 2066 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -1673,15 +2079,21 @@ discard block |
||
| 1673 | 2079 | } |
| 1674 | 2080 | $diff = array_diff($newmodelsdb,$modelsdb); |
| 1675 | 2081 | foreach ($diff as $key => $value) { |
| 1676 | - if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n"; |
|
| 2082 | + if ($globalDebug) { |
|
| 2083 | + echo 'Downloading space model '.$key.' ...'."\n"; |
|
| 2084 | + } |
|
| 1677 | 2085 | update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key); |
| 1678 | 2086 | |
| 1679 | 2087 | } |
| 1680 | 2088 | update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum'); |
| 1681 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 2089 | + } else { |
|
| 2090 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 2091 | + } |
|
| 1682 | 2092 | if ($error != '') { |
| 1683 | 2093 | return $error; |
| 1684 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2094 | + } elseif ($globalDebug) { |
|
| 2095 | + echo "Done\n"; |
|
| 2096 | + } |
|
| 1685 | 2097 | return ''; |
| 1686 | 2098 | } |
| 1687 | 2099 | |
@@ -1724,7 +2136,9 @@ discard block |
||
| 1724 | 2136 | } |
| 1725 | 2137 | |
| 1726 | 2138 | $error = ''; |
| 1727 | - if ($globalDebug) echo "Notam : Download..."; |
|
| 2139 | + if ($globalDebug) { |
|
| 2140 | + echo "Notam : Download..."; |
|
| 2141 | + } |
|
| 1728 | 2142 | update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss'); |
| 1729 | 2143 | if (file_exists($tmp_dir.'notam.rss')) { |
| 1730 | 2144 | $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true); |
@@ -1739,14 +2153,30 @@ discard block |
||
| 1739 | 2153 | $data['fir'] = $q[0]; |
| 1740 | 2154 | $data['code'] = $q[1]; |
| 1741 | 2155 | $ifrvfr = $q[2]; |
| 1742 | - if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR'; |
|
| 1743 | - if ($ifrvfr == 'I') $data['rules'] = 'IFR'; |
|
| 1744 | - if ($ifrvfr == 'V') $data['rules'] = 'VFR'; |
|
| 1745 | - if ($q[4] == 'A') $data['scope'] = 'Airport warning'; |
|
| 1746 | - if ($q[4] == 'E') $data['scope'] = 'Enroute warning'; |
|
| 1747 | - if ($q[4] == 'W') $data['scope'] = 'Navigation warning'; |
|
| 1748 | - if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning'; |
|
| 1749 | - if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning'; |
|
| 2156 | + if ($ifrvfr == 'IV') { |
|
| 2157 | + $data['rules'] = 'IFR/VFR'; |
|
| 2158 | + } |
|
| 2159 | + if ($ifrvfr == 'I') { |
|
| 2160 | + $data['rules'] = 'IFR'; |
|
| 2161 | + } |
|
| 2162 | + if ($ifrvfr == 'V') { |
|
| 2163 | + $data['rules'] = 'VFR'; |
|
| 2164 | + } |
|
| 2165 | + if ($q[4] == 'A') { |
|
| 2166 | + $data['scope'] = 'Airport warning'; |
|
| 2167 | + } |
|
| 2168 | + if ($q[4] == 'E') { |
|
| 2169 | + $data['scope'] = 'Enroute warning'; |
|
| 2170 | + } |
|
| 2171 | + if ($q[4] == 'W') { |
|
| 2172 | + $data['scope'] = 'Navigation warning'; |
|
| 2173 | + } |
|
| 2174 | + if ($q[4] == 'AE') { |
|
| 2175 | + $data['scope'] = 'Airport/Enroute warning'; |
|
| 2176 | + } |
|
| 2177 | + if ($q[4] == 'AW') { |
|
| 2178 | + $data['scope'] = 'Airport/Navigation warning'; |
|
| 2179 | + } |
|
| 1750 | 2180 | //$data['scope'] = $q[4]; |
| 1751 | 2181 | $data['lower_limit'] = $q[5]; |
| 1752 | 2182 | $data['upper_limit'] = $q[6]; |
@@ -1754,8 +2184,12 @@ discard block |
||
| 1754 | 2184 | sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius); |
| 1755 | 2185 | $latitude = $Common->convertDec($las,'latitude'); |
| 1756 | 2186 | $longitude = $Common->convertDec($lns,'longitude'); |
| 1757 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
| 1758 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
| 2187 | + if ($lac == 'S') { |
|
| 2188 | + $latitude = '-'.$latitude; |
|
| 2189 | + } |
|
| 2190 | + if ($lnc == 'W') { |
|
| 2191 | + $longitude = '-'.$longitude; |
|
| 2192 | + } |
|
| 1759 | 2193 | $data['center_latitude'] = $latitude; |
| 1760 | 2194 | $data['center_longitude'] = $longitude; |
| 1761 | 2195 | $data['radius'] = intval($radius); |
@@ -1785,10 +2219,14 @@ discard block |
||
| 1785 | 2219 | $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']); |
| 1786 | 2220 | unset($data); |
| 1787 | 2221 | } |
| 1788 | - } else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
|
| 2222 | + } else { |
|
| 2223 | + $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
|
| 2224 | + } |
|
| 1789 | 2225 | if ($error != '') { |
| 1790 | 2226 | return $error; |
| 1791 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2227 | + } elseif ($globalDebug) { |
|
| 2228 | + echo "Done\n"; |
|
| 2229 | + } |
|
| 1792 | 2230 | return ''; |
| 1793 | 2231 | } |
| 1794 | 2232 | |
@@ -1807,8 +2245,11 @@ discard block |
||
| 1807 | 2245 | return "error : ".$e->getMessage(); |
| 1808 | 2246 | } |
| 1809 | 2247 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 1810 | - if ($row['nb'] > 0) return false; |
|
| 1811 | - else return true; |
|
| 2248 | + if ($row['nb'] > 0) { |
|
| 2249 | + return false; |
|
| 2250 | + } else { |
|
| 2251 | + return true; |
|
| 2252 | + } |
|
| 1812 | 2253 | } |
| 1813 | 2254 | |
| 1814 | 2255 | public static function insert_last_update() { |
@@ -1838,8 +2279,11 @@ discard block |
||
| 1838 | 2279 | return "error : ".$e->getMessage(); |
| 1839 | 2280 | } |
| 1840 | 2281 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 1841 | - if ($row['nb'] > 0) return false; |
|
| 1842 | - else return true; |
|
| 2282 | + if ($row['nb'] > 0) { |
|
| 2283 | + return false; |
|
| 2284 | + } else { |
|
| 2285 | + return true; |
|
| 2286 | + } |
|
| 1843 | 2287 | } |
| 1844 | 2288 | |
| 1845 | 2289 | public static function insert_last_notam_update() { |
@@ -1869,8 +2313,11 @@ discard block |
||
| 1869 | 2313 | return "error : ".$e->getMessage(); |
| 1870 | 2314 | } |
| 1871 | 2315 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 1872 | - if ($row['nb'] > 0) return false; |
|
| 1873 | - else return true; |
|
| 2316 | + if ($row['nb'] > 0) { |
|
| 2317 | + return false; |
|
| 2318 | + } else { |
|
| 2319 | + return true; |
|
| 2320 | + } |
|
| 1874 | 2321 | } |
| 1875 | 2322 | |
| 1876 | 2323 | public static function insert_last_owner_update() { |
@@ -1899,8 +2346,11 @@ discard block |
||
| 1899 | 2346 | return "error : ".$e->getMessage(); |
| 1900 | 2347 | } |
| 1901 | 2348 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 1902 | - if ($row['nb'] > 0) return false; |
|
| 1903 | - else return true; |
|
| 2349 | + if ($row['nb'] > 0) { |
|
| 2350 | + return false; |
|
| 2351 | + } else { |
|
| 2352 | + return true; |
|
| 2353 | + } |
|
| 1904 | 2354 | } |
| 1905 | 2355 | |
| 1906 | 2356 | public static function insert_last_schedules_update() { |
@@ -1929,8 +2379,11 @@ discard block |
||
| 1929 | 2379 | return "error : ".$e->getMessage(); |
| 1930 | 2380 | } |
| 1931 | 2381 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 1932 | - if ($row['nb'] > 0) return false; |
|
| 1933 | - else return true; |
|
| 2382 | + if ($row['nb'] > 0) { |
|
| 2383 | + return false; |
|
| 2384 | + } else { |
|
| 2385 | + return true; |
|
| 2386 | + } |
|
| 1934 | 2387 | } |
| 1935 | 2388 | |
| 1936 | 2389 | public static function insert_last_tle_update() { |