@@ -85,38 +85,38 @@ discard block |
||
| 85 | 85 | try { |
| 86 | 86 | //$Connection = new Connection(); |
| 87 | 87 | $sth = $Connection->db->prepare($query); |
| 88 | - $sth->execute(array(':source' => $database_file)); |
|
| 89 | - } catch(PDOException $e) { |
|
| 90 | - return "error : ".$e->getMessage(); |
|
| 91 | - } |
|
| 88 | + $sth->execute(array(':source' => $database_file)); |
|
| 89 | + } catch(PDOException $e) { |
|
| 90 | + return "error : ".$e->getMessage(); |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
| 94 | - update_db::connect_sqlite($database_file); |
|
| 93 | + if ($globalDebug) echo " - Add routes to DB -"; |
|
| 94 | + update_db::connect_sqlite($database_file); |
|
| 95 | 95 | //$query = 'select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID'; |
| 96 | 96 | $query = "select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao, rstp.allstop AS AllStop from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID LEFT JOIN (select RouteId,GROUP_CONCAT(icao,' ') as allstop from routestop left join Airport as air ON routestop.AirportId = air.AirportID group by RouteID) AS rstp ON Route.RouteID = rstp.RouteID"; |
| 97 | 97 | try { |
| 98 | - $sth = update_db::$db_sqlite->prepare($query); |
|
| 99 | - $sth->execute(); |
|
| 100 | - } catch(PDOException $e) { |
|
| 101 | - return "error : ".$e->getMessage(); |
|
| 102 | - } |
|
| 98 | + $sth = update_db::$db_sqlite->prepare($query); |
|
| 99 | + $sth->execute(); |
|
| 100 | + } catch(PDOException $e) { |
|
| 101 | + return "error : ".$e->getMessage(); |
|
| 102 | + } |
|
| 103 | 103 | //$query_dest = 'INSERT INTO routes (`RouteID`,`CallSign`,`Operator_ICAO`,`FromAirport_ICAO`,`ToAirport_ICAO`,`RouteStop`,`Source`) VALUES (:RouteID, :CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)'; |
| 104 | 104 | $query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,ToAirport_ICAO,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)'; |
| 105 | 105 | $Connection = new Connection(); |
| 106 | 106 | $sth_dest = $Connection->db->prepare($query_dest); |
| 107 | 107 | try { |
| 108 | 108 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 109 | - while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
| 109 | + while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
| 110 | 110 | //$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
| 111 | 111 | $query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
| 112 | 112 | $sth_dest->execute($query_dest_values); |
| 113 | - } |
|
| 113 | + } |
|
| 114 | 114 | if ($globalTransaction) $Connection->db->commit(); |
| 115 | 115 | } catch(PDOException $e) { |
| 116 | 116 | if ($globalTransaction) $Connection->db->rollBack(); |
| 117 | 117 | return "error : ".$e->getMessage(); |
| 118 | 118 | } |
| 119 | - return ''; |
|
| 119 | + return ''; |
|
| 120 | 120 | } |
| 121 | 121 | public static function retrieve_route_oneworld($database_file) { |
| 122 | 122 | global $globalDebug, $globalTransaction; |
@@ -127,12 +127,12 @@ discard block |
||
| 127 | 127 | try { |
| 128 | 128 | //$Connection = new Connection(); |
| 129 | 129 | $sth = $Connection->db->prepare($query); |
| 130 | - $sth->execute(array(':source' => 'oneworld')); |
|
| 131 | - } catch(PDOException $e) { |
|
| 132 | - return "error : ".$e->getMessage(); |
|
| 133 | - } |
|
| 130 | + $sth->execute(array(':source' => 'oneworld')); |
|
| 131 | + } catch(PDOException $e) { |
|
| 132 | + return "error : ".$e->getMessage(); |
|
| 133 | + } |
|
| 134 | 134 | |
| 135 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
| 135 | + if ($globalDebug) echo " - Add routes to DB -"; |
|
| 136 | 136 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 137 | 137 | $Spotter = new Spotter(); |
| 138 | 138 | if ($fh = fopen($database_file,"r")) { |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | } |
| 157 | 157 | if ($globalTransaction) $Connection->db->commit(); |
| 158 | 158 | } |
| 159 | - return ''; |
|
| 159 | + return ''; |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | public static function retrieve_route_skyteam($database_file) { |
@@ -168,12 +168,12 @@ discard block |
||
| 168 | 168 | try { |
| 169 | 169 | //$Connection = new Connection(); |
| 170 | 170 | $sth = $Connection->db->prepare($query); |
| 171 | - $sth->execute(array(':source' => 'skyteam')); |
|
| 172 | - } catch(PDOException $e) { |
|
| 173 | - return "error : ".$e->getMessage(); |
|
| 174 | - } |
|
| 171 | + $sth->execute(array(':source' => 'skyteam')); |
|
| 172 | + } catch(PDOException $e) { |
|
| 173 | + return "error : ".$e->getMessage(); |
|
| 174 | + } |
|
| 175 | 175 | |
| 176 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
| 176 | + if ($globalDebug) echo " - Add routes to DB -"; |
|
| 177 | 177 | |
| 178 | 178 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 179 | 179 | $Spotter = new Spotter(); |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | return "error : ".$e->getMessage(); |
| 200 | 200 | } |
| 201 | 201 | } |
| 202 | - return ''; |
|
| 202 | + return ''; |
|
| 203 | 203 | } |
| 204 | 204 | public static function retrieve_modes_sqlite_to_dest($database_file) { |
| 205 | 205 | global $globalTransaction; |
@@ -208,27 +208,27 @@ discard block |
||
| 208 | 208 | try { |
| 209 | 209 | $Connection = new Connection(); |
| 210 | 210 | $sth = $Connection->db->prepare($query); |
| 211 | - $sth->execute(array(':source' => $database_file)); |
|
| 212 | - } catch(PDOException $e) { |
|
| 213 | - return "error : ".$e->getMessage(); |
|
| 214 | - } |
|
| 211 | + $sth->execute(array(':source' => $database_file)); |
|
| 212 | + } catch(PDOException $e) { |
|
| 213 | + return "error : ".$e->getMessage(); |
|
| 214 | + } |
|
| 215 | 215 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source"; |
| 216 | 216 | try { |
| 217 | 217 | $Connection = new Connection(); |
| 218 | 218 | $sth = $Connection->db->prepare($query); |
| 219 | - $sth->execute(array(':source' => $database_file)); |
|
| 220 | - } catch(PDOException $e) { |
|
| 221 | - return "error : ".$e->getMessage(); |
|
| 222 | - } |
|
| 219 | + $sth->execute(array(':source' => $database_file)); |
|
| 220 | + } catch(PDOException $e) { |
|
| 221 | + return "error : ".$e->getMessage(); |
|
| 222 | + } |
|
| 223 | 223 | |
| 224 | - update_db::connect_sqlite($database_file); |
|
| 224 | + update_db::connect_sqlite($database_file); |
|
| 225 | 225 | $query = 'select * from Aircraft'; |
| 226 | 226 | try { |
| 227 | - $sth = update_db::$db_sqlite->prepare($query); |
|
| 228 | - $sth->execute(); |
|
| 229 | - } catch(PDOException $e) { |
|
| 230 | - return "error : ".$e->getMessage(); |
|
| 231 | - } |
|
| 227 | + $sth = update_db::$db_sqlite->prepare($query); |
|
| 228 | + $sth->execute(); |
|
| 229 | + } catch(PDOException $e) { |
|
| 230 | + return "error : ".$e->getMessage(); |
|
| 231 | + } |
|
| 232 | 232 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
| 233 | 233 | $query_dest = 'INSERT INTO aircraft_modes (LastModified, ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type,:source)'; |
| 234 | 234 | |
@@ -239,17 +239,17 @@ discard block |
||
| 239 | 239 | $sth_dest_owner = $Connection->db->prepare($query_dest_owner); |
| 240 | 240 | try { |
| 241 | 241 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 242 | - while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
| 242 | + while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
| 243 | 243 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
| 244 | 244 | if ($values['UserString4'] == 'M') $type = 'military'; |
| 245 | 245 | else $type = null; |
| 246 | 246 | $query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type); |
| 247 | 247 | $sth_dest->execute($query_dest_values); |
| 248 | 248 | if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') { |
| 249 | - $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']); |
|
| 250 | - $sth_dest_owner->execute($query_dest_owner_values); |
|
| 249 | + $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']); |
|
| 250 | + $sth_dest_owner->execute($query_dest_owner_values); |
|
| 251 | 251 | } |
| 252 | - } |
|
| 252 | + } |
|
| 253 | 253 | if ($globalTransaction) $Connection->db->commit(); |
| 254 | 254 | } catch(PDOException $e) { |
| 255 | 255 | return "error : ".$e->getMessage(); |
@@ -260,10 +260,10 @@ discard block |
||
| 260 | 260 | try { |
| 261 | 261 | $Connection = new Connection(); |
| 262 | 262 | $sth = $Connection->db->prepare($query); |
| 263 | - $sth->execute(array(':source' => $database_file)); |
|
| 264 | - } catch(PDOException $e) { |
|
| 265 | - return "error : ".$e->getMessage(); |
|
| 266 | - } |
|
| 263 | + $sth->execute(array(':source' => $database_file)); |
|
| 264 | + } catch(PDOException $e) { |
|
| 265 | + return "error : ".$e->getMessage(); |
|
| 266 | + } |
|
| 267 | 267 | return ''; |
| 268 | 268 | } |
| 269 | 269 | |
@@ -275,10 +275,10 @@ discard block |
||
| 275 | 275 | try { |
| 276 | 276 | $Connection = new Connection(); |
| 277 | 277 | $sth = $Connection->db->prepare($query); |
| 278 | - $sth->execute(array(':source' => $database_file)); |
|
| 279 | - } catch(PDOException $e) { |
|
| 280 | - return "error : ".$e->getMessage(); |
|
| 281 | - } |
|
| 278 | + $sth->execute(array(':source' => $database_file)); |
|
| 279 | + } catch(PDOException $e) { |
|
| 280 | + return "error : ".$e->getMessage(); |
|
| 281 | + } |
|
| 282 | 282 | |
| 283 | 283 | if ($fh = fopen($database_file,"r")) { |
| 284 | 284 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
@@ -288,26 +288,26 @@ discard block |
||
| 288 | 288 | $sth_dest = $Connection->db->prepare($query_dest); |
| 289 | 289 | try { |
| 290 | 290 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 291 | - while (!feof($fh)) { |
|
| 292 | - $values = array(); |
|
| 293 | - $line = $Common->hex2str(fgets($fh,9999)); |
|
| 291 | + while (!feof($fh)) { |
|
| 292 | + $values = array(); |
|
| 293 | + $line = $Common->hex2str(fgets($fh,9999)); |
|
| 294 | 294 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
| 295 | - $values['ModeS'] = substr($line,0,6); |
|
| 296 | - $values['Registration'] = trim(substr($line,69,6)); |
|
| 297 | - $aircraft_name = trim(substr($line,48,6)); |
|
| 298 | - // Check if we can find ICAO, else set it to GLID |
|
| 299 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
| 300 | - $search_more = ''; |
|
| 301 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 302 | - $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
| 303 | - $sth_search = $Connection->db->prepare($query_search); |
|
| 295 | + $values['ModeS'] = substr($line,0,6); |
|
| 296 | + $values['Registration'] = trim(substr($line,69,6)); |
|
| 297 | + $aircraft_name = trim(substr($line,48,6)); |
|
| 298 | + // Check if we can find ICAO, else set it to GLID |
|
| 299 | + $aircraft_name_split = explode(' ',$aircraft_name); |
|
| 300 | + $search_more = ''; |
|
| 301 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 302 | + $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
| 303 | + $sth_search = $Connection->db->prepare($query_search); |
|
| 304 | 304 | try { |
| 305 | - $sth_search->execute(); |
|
| 306 | - $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
| 307 | - //if (count($result) > 0) { |
|
| 308 | - if (isset($result['icao']) && $result['icao'] != '') { |
|
| 309 | - $values['ICAOTypeCode'] = $result['icao']; |
|
| 310 | - } |
|
| 305 | + $sth_search->execute(); |
|
| 306 | + $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
| 307 | + //if (count($result) > 0) { |
|
| 308 | + if (isset($result['icao']) && $result['icao'] != '') { |
|
| 309 | + $values['ICAOTypeCode'] = $result['icao']; |
|
| 310 | + } |
|
| 311 | 311 | } catch(PDOException $e) { |
| 312 | 312 | return "error : ".$e->getMessage(); |
| 313 | 313 | } |
@@ -330,10 +330,10 @@ discard block |
||
| 330 | 330 | try { |
| 331 | 331 | $Connection = new Connection(); |
| 332 | 332 | $sth = $Connection->db->prepare($query); |
| 333 | - $sth->execute(array(':source' => $database_file)); |
|
| 334 | - } catch(PDOException $e) { |
|
| 335 | - return "error : ".$e->getMessage(); |
|
| 336 | - } |
|
| 333 | + $sth->execute(array(':source' => $database_file)); |
|
| 334 | + } catch(PDOException $e) { |
|
| 335 | + return "error : ".$e->getMessage(); |
|
| 336 | + } |
|
| 337 | 337 | return ''; |
| 338 | 338 | } |
| 339 | 339 | |
@@ -344,10 +344,10 @@ discard block |
||
| 344 | 344 | try { |
| 345 | 345 | $Connection = new Connection(); |
| 346 | 346 | $sth = $Connection->db->prepare($query); |
| 347 | - $sth->execute(array(':source' => $database_file)); |
|
| 348 | - } catch(PDOException $e) { |
|
| 349 | - return "error : ".$e->getMessage(); |
|
| 350 | - } |
|
| 347 | + $sth->execute(array(':source' => $database_file)); |
|
| 348 | + } catch(PDOException $e) { |
|
| 349 | + return "error : ".$e->getMessage(); |
|
| 350 | + } |
|
| 351 | 351 | |
| 352 | 352 | if ($fh = fopen($database_file,"r")) { |
| 353 | 353 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
@@ -358,25 +358,25 @@ discard block |
||
| 358 | 358 | try { |
| 359 | 359 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 360 | 360 | $tmp = fgetcsv($fh,9999,',',"'"); |
| 361 | - while (!feof($fh)) { |
|
| 362 | - $line = fgetcsv($fh,9999,',',"'"); |
|
| 361 | + while (!feof($fh)) { |
|
| 362 | + $line = fgetcsv($fh,9999,',',"'"); |
|
| 363 | 363 | |
| 364 | 364 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
| 365 | 365 | //print_r($line); |
| 366 | - $values['ModeS'] = $line[1]; |
|
| 367 | - $values['Registration'] = $line[3]; |
|
| 368 | - $values['ICAOTypeCode'] = ''; |
|
| 369 | - $aircraft_name = $line[2]; |
|
| 370 | - // Check if we can find ICAO, else set it to GLID |
|
| 371 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
| 372 | - $search_more = ''; |
|
| 373 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 374 | - $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
| 375 | - $sth_search = $Connection->db->prepare($query_search); |
|
| 366 | + $values['ModeS'] = $line[1]; |
|
| 367 | + $values['Registration'] = $line[3]; |
|
| 368 | + $values['ICAOTypeCode'] = ''; |
|
| 369 | + $aircraft_name = $line[2]; |
|
| 370 | + // Check if we can find ICAO, else set it to GLID |
|
| 371 | + $aircraft_name_split = explode(' ',$aircraft_name); |
|
| 372 | + $search_more = ''; |
|
| 373 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 374 | + $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
| 375 | + $sth_search = $Connection->db->prepare($query_search); |
|
| 376 | 376 | try { |
| 377 | - $sth_search->execute(); |
|
| 378 | - $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
| 379 | - if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
|
| 377 | + $sth_search->execute(); |
|
| 378 | + $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
| 379 | + if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
|
| 380 | 380 | } catch(PDOException $e) { |
| 381 | 381 | return "error : ".$e->getMessage(); |
| 382 | 382 | } |
@@ -399,10 +399,10 @@ discard block |
||
| 399 | 399 | try { |
| 400 | 400 | $Connection = new Connection(); |
| 401 | 401 | $sth = $Connection->db->prepare($query); |
| 402 | - $sth->execute(array(':source' => $database_file)); |
|
| 403 | - } catch(PDOException $e) { |
|
| 404 | - return "error : ".$e->getMessage(); |
|
| 405 | - } |
|
| 402 | + $sth->execute(array(':source' => $database_file)); |
|
| 403 | + } catch(PDOException $e) { |
|
| 404 | + return "error : ".$e->getMessage(); |
|
| 405 | + } |
|
| 406 | 406 | return ''; |
| 407 | 407 | } |
| 408 | 408 | |
@@ -413,16 +413,16 @@ discard block |
||
| 413 | 413 | try { |
| 414 | 414 | $Connection = new Connection(); |
| 415 | 415 | $sth = $Connection->db->prepare($query); |
| 416 | - $sth->execute(array(':source' => $database_file)); |
|
| 417 | - } catch(PDOException $e) { |
|
| 418 | - return "error : ".$e->getMessage(); |
|
| 419 | - } |
|
| 416 | + $sth->execute(array(':source' => $database_file)); |
|
| 417 | + } catch(PDOException $e) { |
|
| 418 | + return "error : ".$e->getMessage(); |
|
| 419 | + } |
|
| 420 | 420 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 421 | 421 | $Spotter = new Spotter(); |
| 422 | 422 | if ($fh = fopen($database_file,"r")) { |
| 423 | 423 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
| 424 | 424 | $query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)'; |
| 425 | - $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)'; |
|
| 425 | + $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)'; |
|
| 426 | 426 | |
| 427 | 427 | $Connection = new Connection(); |
| 428 | 428 | $sth_dest = $Connection->db->prepare($query_dest); |
@@ -430,126 +430,126 @@ discard block |
||
| 430 | 430 | try { |
| 431 | 431 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 432 | 432 | $tmp = fgetcsv($fh,9999,',','"'); |
| 433 | - while (!feof($fh)) { |
|
| 434 | - $line = fgetcsv($fh,9999,',','"'); |
|
| 435 | - $values = array(); |
|
| 436 | - //print_r($line); |
|
| 437 | - if ($country == 'F') { |
|
| 438 | - $values['registration'] = $line[0]; |
|
| 439 | - $values['base'] = $line[4]; |
|
| 440 | - $values['owner'] = $line[5]; |
|
| 441 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
| 442 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 443 | - $values['cancel'] = $line[7]; |
|
| 433 | + while (!feof($fh)) { |
|
| 434 | + $line = fgetcsv($fh,9999,',','"'); |
|
| 435 | + $values = array(); |
|
| 436 | + //print_r($line); |
|
| 437 | + if ($country == 'F') { |
|
| 438 | + $values['registration'] = $line[0]; |
|
| 439 | + $values['base'] = $line[4]; |
|
| 440 | + $values['owner'] = $line[5]; |
|
| 441 | + if ($line[6] == '') $values['date_first_reg'] = null; |
|
| 442 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 443 | + $values['cancel'] = $line[7]; |
|
| 444 | 444 | } elseif ($country == 'EI') { |
| 445 | - // TODO : add modeS & reg to aircraft_modes |
|
| 446 | - $values['registration'] = $line[0]; |
|
| 447 | - $values['base'] = $line[3]; |
|
| 448 | - $values['owner'] = $line[2]; |
|
| 449 | - if ($line[1] == '') $values['date_first_reg'] = null; |
|
| 450 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
| 451 | - $values['cancel'] = ''; |
|
| 452 | - $values['modes'] = $line[7]; |
|
| 453 | - $values['icao'] = $line[8]; |
|
| 445 | + // TODO : add modeS & reg to aircraft_modes |
|
| 446 | + $values['registration'] = $line[0]; |
|
| 447 | + $values['base'] = $line[3]; |
|
| 448 | + $values['owner'] = $line[2]; |
|
| 449 | + if ($line[1] == '') $values['date_first_reg'] = null; |
|
| 450 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
| 451 | + $values['cancel'] = ''; |
|
| 452 | + $values['modes'] = $line[7]; |
|
| 453 | + $values['icao'] = $line[8]; |
|
| 454 | 454 | |
| 455 | 455 | } elseif ($country == 'HB') { |
| 456 | - // TODO : add modeS & reg to aircraft_modes |
|
| 457 | - $values['registration'] = $line[0]; |
|
| 458 | - $values['base'] = null; |
|
| 459 | - $values['owner'] = $line[5]; |
|
| 460 | - $values['date_first_reg'] = null; |
|
| 461 | - $values['cancel'] = ''; |
|
| 462 | - $values['modes'] = $line[4]; |
|
| 463 | - $values['icao'] = $line[7]; |
|
| 456 | + // TODO : add modeS & reg to aircraft_modes |
|
| 457 | + $values['registration'] = $line[0]; |
|
| 458 | + $values['base'] = null; |
|
| 459 | + $values['owner'] = $line[5]; |
|
| 460 | + $values['date_first_reg'] = null; |
|
| 461 | + $values['cancel'] = ''; |
|
| 462 | + $values['modes'] = $line[4]; |
|
| 463 | + $values['icao'] = $line[7]; |
|
| 464 | 464 | } elseif ($country == 'OK') { |
| 465 | - // TODO : add modeS & reg to aircraft_modes |
|
| 466 | - $values['registration'] = $line[3]; |
|
| 467 | - $values['base'] = null; |
|
| 468 | - $values['owner'] = $line[5]; |
|
| 469 | - if ($line[18] == '') $values['date_first_reg'] = null; |
|
| 470 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
| 471 | - $values['cancel'] = ''; |
|
| 465 | + // TODO : add modeS & reg to aircraft_modes |
|
| 466 | + $values['registration'] = $line[3]; |
|
| 467 | + $values['base'] = null; |
|
| 468 | + $values['owner'] = $line[5]; |
|
| 469 | + if ($line[18] == '') $values['date_first_reg'] = null; |
|
| 470 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
| 471 | + $values['cancel'] = ''; |
|
| 472 | 472 | } elseif ($country == 'VH') { |
| 473 | - // TODO : add modeS & reg to aircraft_modes |
|
| 474 | - $values['registration'] = $line[0]; |
|
| 475 | - $values['base'] = null; |
|
| 476 | - $values['owner'] = $line[12]; |
|
| 477 | - if ($line[28] == '') $values['date_first_reg'] = null; |
|
| 478 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
| 479 | - |
|
| 480 | - $values['cancel'] = $line[39]; |
|
| 473 | + // TODO : add modeS & reg to aircraft_modes |
|
| 474 | + $values['registration'] = $line[0]; |
|
| 475 | + $values['base'] = null; |
|
| 476 | + $values['owner'] = $line[12]; |
|
| 477 | + if ($line[28] == '') $values['date_first_reg'] = null; |
|
| 478 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
| 479 | + |
|
| 480 | + $values['cancel'] = $line[39]; |
|
| 481 | 481 | } elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { |
| 482 | - $values['registration'] = $line[0]; |
|
| 483 | - $values['base'] = null; |
|
| 484 | - $values['owner'] = $line[4]; |
|
| 485 | - $values['date_first_reg'] = null; |
|
| 486 | - $values['cancel'] = ''; |
|
| 482 | + $values['registration'] = $line[0]; |
|
| 483 | + $values['base'] = null; |
|
| 484 | + $values['owner'] = $line[4]; |
|
| 485 | + $values['date_first_reg'] = null; |
|
| 486 | + $values['cancel'] = ''; |
|
| 487 | 487 | } elseif ($country == 'CC') { |
| 488 | - $values['registration'] = $line[0]; |
|
| 489 | - $values['base'] = null; |
|
| 490 | - $values['owner'] = $line[6]; |
|
| 491 | - $values['date_first_reg'] = null; |
|
| 492 | - $values['cancel'] = ''; |
|
| 488 | + $values['registration'] = $line[0]; |
|
| 489 | + $values['base'] = null; |
|
| 490 | + $values['owner'] = $line[6]; |
|
| 491 | + $values['date_first_reg'] = null; |
|
| 492 | + $values['cancel'] = ''; |
|
| 493 | 493 | } elseif ($country == 'HJ') { |
| 494 | - $values['registration'] = $line[0]; |
|
| 495 | - $values['base'] = null; |
|
| 496 | - $values['owner'] = $line[8]; |
|
| 497 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
| 498 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 499 | - $values['cancel'] = ''; |
|
| 494 | + $values['registration'] = $line[0]; |
|
| 495 | + $values['base'] = null; |
|
| 496 | + $values['owner'] = $line[8]; |
|
| 497 | + if ($line[7] == '') $values['date_first_reg'] = null; |
|
| 498 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 499 | + $values['cancel'] = ''; |
|
| 500 | 500 | } elseif ($country == 'PP') { |
| 501 | - $values['registration'] = $line[0]; |
|
| 502 | - $values['base'] = null; |
|
| 503 | - $values['owner'] = $line[4]; |
|
| 504 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
| 505 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 506 | - $values['cancel'] = $line[7]; |
|
| 501 | + $values['registration'] = $line[0]; |
|
| 502 | + $values['base'] = null; |
|
| 503 | + $values['owner'] = $line[4]; |
|
| 504 | + if ($line[6] == '') $values['date_first_reg'] = null; |
|
| 505 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 506 | + $values['cancel'] = $line[7]; |
|
| 507 | 507 | } elseif ($country == 'E7') { |
| 508 | - $values['registration'] = $line[0]; |
|
| 509 | - $values['base'] = null; |
|
| 510 | - $values['owner'] = $line[4]; |
|
| 511 | - if ($line[5] == '') $values['date_first_reg'] = null; |
|
| 512 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
| 513 | - $values['cancel'] = ''; |
|
| 508 | + $values['registration'] = $line[0]; |
|
| 509 | + $values['base'] = null; |
|
| 510 | + $values['owner'] = $line[4]; |
|
| 511 | + if ($line[5] == '') $values['date_first_reg'] = null; |
|
| 512 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
| 513 | + $values['cancel'] = ''; |
|
| 514 | 514 | } elseif ($country == '8Q') { |
| 515 | - $values['registration'] = $line[0]; |
|
| 516 | - $values['base'] = null; |
|
| 517 | - $values['owner'] = $line[3]; |
|
| 518 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
| 519 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 520 | - $values['cancel'] = ''; |
|
| 515 | + $values['registration'] = $line[0]; |
|
| 516 | + $values['base'] = null; |
|
| 517 | + $values['owner'] = $line[3]; |
|
| 518 | + if ($line[7] == '') $values['date_first_reg'] = null; |
|
| 519 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 520 | + $values['cancel'] = ''; |
|
| 521 | 521 | } elseif ($country == 'ZK') { |
| 522 | - $values['registration'] = $line[0]; |
|
| 523 | - $values['base'] = null; |
|
| 524 | - $values['owner'] = $line[3]; |
|
| 525 | - $values['date_first_reg'] = null; |
|
| 526 | - $values['cancel'] = ''; |
|
| 527 | - $values['modes'] = $line[5]; |
|
| 528 | - $values['icao'] = $line[9]; |
|
| 522 | + $values['registration'] = $line[0]; |
|
| 523 | + $values['base'] = null; |
|
| 524 | + $values['owner'] = $line[3]; |
|
| 525 | + $values['date_first_reg'] = null; |
|
| 526 | + $values['cancel'] = ''; |
|
| 527 | + $values['modes'] = $line[5]; |
|
| 528 | + $values['icao'] = $line[9]; |
|
| 529 | 529 | } elseif ($country == 'M') { |
| 530 | - $values['registration'] = $line[0]; |
|
| 531 | - $values['base'] = null; |
|
| 532 | - $values['owner'] = $line[6]; |
|
| 533 | - $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
| 534 | - $values['cancel'] = date("Y-m-d",strtotime($line[8])); |
|
| 535 | - $values['modes'] = $line[4]; |
|
| 536 | - $values['icao'] = $line[10]; |
|
| 530 | + $values['registration'] = $line[0]; |
|
| 531 | + $values['base'] = null; |
|
| 532 | + $values['owner'] = $line[6]; |
|
| 533 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
| 534 | + $values['cancel'] = date("Y-m-d",strtotime($line[8])); |
|
| 535 | + $values['modes'] = $line[4]; |
|
| 536 | + $values['icao'] = $line[10]; |
|
| 537 | 537 | } elseif ($country == 'OY') { |
| 538 | - $values['registration'] = $line[0]; |
|
| 539 | - $values['date_first_reg'] = date("Y-m-d",strtotime($line[4])); |
|
| 540 | - $values['modes'] = $line[5]; |
|
| 541 | - $values['icao'] = $line[6]; |
|
| 538 | + $values['registration'] = $line[0]; |
|
| 539 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[4])); |
|
| 540 | + $values['modes'] = $line[5]; |
|
| 541 | + $values['icao'] = $line[6]; |
|
| 542 | 542 | } elseif ($country == 'PH') { |
| 543 | - $values['registration'] = $line[0]; |
|
| 544 | - $values['date_first_reg'] = date("Y-m-d",strtotime($line[3])); |
|
| 545 | - $values['modes'] = $line[4]; |
|
| 546 | - $values['icao'] = $line[5]; |
|
| 543 | + $values['registration'] = $line[0]; |
|
| 544 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[3])); |
|
| 545 | + $values['modes'] = $line[4]; |
|
| 546 | + $values['icao'] = $line[5]; |
|
| 547 | 547 | } elseif ($country == 'OM' || $country == 'TF') { |
| 548 | - $values['registration'] = $line[0]; |
|
| 549 | - $values['base'] = null; |
|
| 550 | - $values['owner'] = $line[3]; |
|
| 551 | - $values['date_first_reg'] = null; |
|
| 552 | - $values['cancel'] = ''; |
|
| 548 | + $values['registration'] = $line[0]; |
|
| 549 | + $values['base'] = null; |
|
| 550 | + $values['owner'] = $line[3]; |
|
| 551 | + $values['date_first_reg'] = null; |
|
| 552 | + $values['cancel'] = ''; |
|
| 553 | 553 | } |
| 554 | 554 | if (isset($values['cancel']) && $values['cancel'] == '' && $values['registration'] != null && isset($values['owner'])) { |
| 555 | 555 | $query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file); |
@@ -682,7 +682,7 @@ discard block |
||
| 682 | 682 | return "error : ".$e->getMessage(); |
| 683 | 683 | } |
| 684 | 684 | */ |
| 685 | - /* |
|
| 685 | + /* |
|
| 686 | 686 | $query = 'ALTER TABLE airport DROP INDEX icaoidx'; |
| 687 | 687 | try { |
| 688 | 688 | $Connection = new Connection(); |
@@ -927,10 +927,10 @@ discard block |
||
| 927 | 927 | try { |
| 928 | 928 | $Connection = new Connection(); |
| 929 | 929 | $sth = $Connection->db->prepare($query); |
| 930 | - $sth->execute(array(':source' => 'translation.csv')); |
|
| 931 | - } catch(PDOException $e) { |
|
| 932 | - return "error : ".$e->getMessage(); |
|
| 933 | - } |
|
| 930 | + $sth->execute(array(':source' => 'translation.csv')); |
|
| 931 | + } catch(PDOException $e) { |
|
| 932 | + return "error : ".$e->getMessage(); |
|
| 933 | + } |
|
| 934 | 934 | |
| 935 | 935 | |
| 936 | 936 | //update_db::unzip($out_file); |
@@ -949,21 +949,21 @@ discard block |
||
| 949 | 949 | $data = $row; |
| 950 | 950 | $operator = $data[2]; |
| 951 | 951 | if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) { |
| 952 | - $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2)); |
|
| 953 | - //echo substr($operator, 0, 2)."\n";; |
|
| 954 | - if (count($airline_array) > 0) { |
|
| 952 | + $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2)); |
|
| 953 | + //echo substr($operator, 0, 2)."\n";; |
|
| 954 | + if (count($airline_array) > 0) { |
|
| 955 | 955 | //print_r($airline_array); |
| 956 | 956 | $operator = $airline_array[0]['icao'].substr($operator,2); |
| 957 | - } |
|
| 958 | - } |
|
| 957 | + } |
|
| 958 | + } |
|
| 959 | 959 | |
| 960 | 960 | $operator_correct = $data[3]; |
| 961 | 961 | if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) { |
| 962 | - $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2)); |
|
| 963 | - if (count($airline_array) > 0) { |
|
| 964 | - $operator_correct = $airline_array[0]['icao'].substr($operator_correct,2); |
|
| 965 | - } |
|
| 966 | - } |
|
| 962 | + $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2)); |
|
| 963 | + if (count($airline_array) > 0) { |
|
| 964 | + $operator_correct = $airline_array[0]['icao'].substr($operator_correct,2); |
|
| 965 | + } |
|
| 966 | + } |
|
| 967 | 967 | $query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)'; |
| 968 | 968 | try { |
| 969 | 969 | $sth = $Connection->db->prepare($query); |
@@ -977,7 +977,7 @@ discard block |
||
| 977 | 977 | //$Connection->db->commit(); |
| 978 | 978 | } |
| 979 | 979 | return ''; |
| 980 | - } |
|
| 980 | + } |
|
| 981 | 981 | |
| 982 | 982 | public static function translation_fam() { |
| 983 | 983 | global $tmp_dir, $globalTransaction; |
@@ -1015,7 +1015,7 @@ discard block |
||
| 1015 | 1015 | //$Connection->db->commit(); |
| 1016 | 1016 | } |
| 1017 | 1017 | return ''; |
| 1018 | - } |
|
| 1018 | + } |
|
| 1019 | 1019 | |
| 1020 | 1020 | /* |
| 1021 | 1021 | * This function use FAA public data. |
@@ -1027,19 +1027,19 @@ discard block |
||
| 1027 | 1027 | try { |
| 1028 | 1028 | $Connection = new Connection(); |
| 1029 | 1029 | $sth = $Connection->db->prepare($query); |
| 1030 | - $sth->execute(array(':source' => 'website_faa')); |
|
| 1031 | - } catch(PDOException $e) { |
|
| 1032 | - return "error : ".$e->getMessage(); |
|
| 1033 | - } |
|
| 1030 | + $sth->execute(array(':source' => 'website_faa')); |
|
| 1031 | + } catch(PDOException $e) { |
|
| 1032 | + return "error : ".$e->getMessage(); |
|
| 1033 | + } |
|
| 1034 | 1034 | |
| 1035 | 1035 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source = :source"; |
| 1036 | 1036 | try { |
| 1037 | 1037 | $Connection = new Connection(); |
| 1038 | 1038 | $sth = $Connection->db->prepare($query); |
| 1039 | - $sth->execute(array(':source' => 'website_faa')); |
|
| 1040 | - } catch(PDOException $e) { |
|
| 1041 | - return "error : ".$e->getMessage(); |
|
| 1042 | - } |
|
| 1039 | + $sth->execute(array(':source' => 'website_faa')); |
|
| 1040 | + } catch(PDOException $e) { |
|
| 1041 | + return "error : ".$e->getMessage(); |
|
| 1042 | + } |
|
| 1043 | 1043 | |
| 1044 | 1044 | $delimiter = ","; |
| 1045 | 1045 | $mfr = array(); |
@@ -1199,7 +1199,7 @@ discard block |
||
| 1199 | 1199 | return "error : ".$e->getMessage(); |
| 1200 | 1200 | } |
| 1201 | 1201 | return ''; |
| 1202 | - } |
|
| 1202 | + } |
|
| 1203 | 1203 | |
| 1204 | 1204 | public static function owner_fam() { |
| 1205 | 1205 | global $tmp_dir, $globalTransaction; |
@@ -1207,10 +1207,10 @@ discard block |
||
| 1207 | 1207 | try { |
| 1208 | 1208 | $Connection = new Connection(); |
| 1209 | 1209 | $sth = $Connection->db->prepare($query); |
| 1210 | - $sth->execute(array(':source' => 'website_fam')); |
|
| 1211 | - } catch(PDOException $e) { |
|
| 1212 | - return "error : ".$e->getMessage(); |
|
| 1213 | - } |
|
| 1210 | + $sth->execute(array(':source' => 'website_fam')); |
|
| 1211 | + } catch(PDOException $e) { |
|
| 1212 | + return "error : ".$e->getMessage(); |
|
| 1213 | + } |
|
| 1214 | 1214 | |
| 1215 | 1215 | $delimiter = "\t"; |
| 1216 | 1216 | $Connection = new Connection(); |
@@ -1236,7 +1236,7 @@ discard block |
||
| 1236 | 1236 | if ($globalTransaction) $Connection->db->commit(); |
| 1237 | 1237 | } |
| 1238 | 1238 | return ''; |
| 1239 | - } |
|
| 1239 | + } |
|
| 1240 | 1240 | |
| 1241 | 1241 | public static function routes_fam() { |
| 1242 | 1242 | global $tmp_dir, $globalTransaction, $globalDebug; |
@@ -1271,7 +1271,7 @@ discard block |
||
| 1271 | 1271 | if ($globalTransaction) $Connection->db->commit(); |
| 1272 | 1272 | } |
| 1273 | 1273 | return ''; |
| 1274 | - } |
|
| 1274 | + } |
|
| 1275 | 1275 | |
| 1276 | 1276 | public static function marine_identity_fam() { |
| 1277 | 1277 | global $tmp_dir, $globalTransaction; |
@@ -1279,10 +1279,10 @@ discard block |
||
| 1279 | 1279 | try { |
| 1280 | 1280 | $Connection = new Connection(); |
| 1281 | 1281 | $sth = $Connection->db->prepare($query); |
| 1282 | - $sth->execute(); |
|
| 1283 | - } catch(PDOException $e) { |
|
| 1284 | - return "error : ".$e->getMessage(); |
|
| 1285 | - } |
|
| 1282 | + $sth->execute(); |
|
| 1283 | + } catch(PDOException $e) { |
|
| 1284 | + return "error : ".$e->getMessage(); |
|
| 1285 | + } |
|
| 1286 | 1286 | |
| 1287 | 1287 | |
| 1288 | 1288 | //update_db::unzip($out_file); |
@@ -1312,7 +1312,7 @@ discard block |
||
| 1312 | 1312 | if ($globalTransaction) $Connection->db->commit(); |
| 1313 | 1313 | } |
| 1314 | 1314 | return ''; |
| 1315 | - } |
|
| 1315 | + } |
|
| 1316 | 1316 | |
| 1317 | 1317 | public static function satellite_fam() { |
| 1318 | 1318 | global $tmp_dir, $globalTransaction; |
@@ -1383,7 +1383,7 @@ discard block |
||
| 1383 | 1383 | if ($globalTransaction) $Connection->db->commit(); |
| 1384 | 1384 | } |
| 1385 | 1385 | return ''; |
| 1386 | - } |
|
| 1386 | + } |
|
| 1387 | 1387 | |
| 1388 | 1388 | public static function tle($filename,$tletype) { |
| 1389 | 1389 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
@@ -1394,10 +1394,10 @@ discard block |
||
| 1394 | 1394 | try { |
| 1395 | 1395 | $Connection = new Connection(); |
| 1396 | 1396 | $sth = $Connection->db->prepare($query); |
| 1397 | - $sth->execute(array(':source' => $filename)); |
|
| 1398 | - } catch(PDOException $e) { |
|
| 1399 | - return "error : ".$e->getMessage(); |
|
| 1400 | - } |
|
| 1397 | + $sth->execute(array(':source' => $filename)); |
|
| 1398 | + } catch(PDOException $e) { |
|
| 1399 | + return "error : ".$e->getMessage(); |
|
| 1400 | + } |
|
| 1401 | 1401 | |
| 1402 | 1402 | $Connection = new Connection(); |
| 1403 | 1403 | if (($handle = fopen($filename, 'r')) !== FALSE) |
@@ -1432,7 +1432,7 @@ discard block |
||
| 1432 | 1432 | //$Connection->db->commit(); |
| 1433 | 1433 | } |
| 1434 | 1434 | return ''; |
| 1435 | - } |
|
| 1435 | + } |
|
| 1436 | 1436 | |
| 1437 | 1437 | public static function satellite_ucsdb($filename) { |
| 1438 | 1438 | global $tmp_dir, $globalTransaction; |
@@ -1681,11 +1681,11 @@ discard block |
||
| 1681 | 1681 | try { |
| 1682 | 1682 | $sth = $Connection->db->prepare($query); |
| 1683 | 1683 | $sth->execute(array( |
| 1684 | - ':name' => $result['name'], ':name_alternate' => '', ':country_un' => '', ':country_owner' => $result['country_owner'], ':owner' => $result['owner'], ':users' => '', ':purpose' => '', ':purpose_detailed' => '', ':orbit' => $result['status'], |
|
| 1685 | - ':type' => '', ':longitude_geo' => NULL, ':perigee' => !empty($result['perigee']) ? $result['perigee'] : NULL, ':apogee' => !empty($result['apogee']) ? $result['apogee'] : NULL, ':eccentricity' => NULL, ':inclination' => $result['inclination'], |
|
| 1686 | - ':period' => !empty($result['period']) ? $result['period'] : NULL, ':launch_mass' => NULL, ':dry_mass' => NULL, ':power' => NULL, ':launch_date' => $result['launch_date'], ':lifetime' => $result['lifetime'], |
|
| 1687 | - ':contractor' => '',':country_contractor' => '', ':launch_site' => $result['launch_site'], ':launch_vehicule' => '', ':cospar' => $result['cospar'], ':norad' => $result['norad'], ':comments' => '', ':source_orbital' => '', ':sources' => '' |
|
| 1688 | - ) |
|
| 1684 | + ':name' => $result['name'], ':name_alternate' => '', ':country_un' => '', ':country_owner' => $result['country_owner'], ':owner' => $result['owner'], ':users' => '', ':purpose' => '', ':purpose_detailed' => '', ':orbit' => $result['status'], |
|
| 1685 | + ':type' => '', ':longitude_geo' => NULL, ':perigee' => !empty($result['perigee']) ? $result['perigee'] : NULL, ':apogee' => !empty($result['apogee']) ? $result['apogee'] : NULL, ':eccentricity' => NULL, ':inclination' => $result['inclination'], |
|
| 1686 | + ':period' => !empty($result['period']) ? $result['period'] : NULL, ':launch_mass' => NULL, ':dry_mass' => NULL, ':power' => NULL, ':launch_date' => $result['launch_date'], ':lifetime' => $result['lifetime'], |
|
| 1687 | + ':contractor' => '',':country_contractor' => '', ':launch_site' => $result['launch_site'], ':launch_vehicule' => '', ':cospar' => $result['cospar'], ':norad' => $result['norad'], ':comments' => '', ':source_orbital' => '', ':sources' => '' |
|
| 1688 | + ) |
|
| 1689 | 1689 | ); |
| 1690 | 1690 | } catch(PDOException $e) { |
| 1691 | 1691 | return "error : ".$e->getMessage(); |
@@ -1709,13 +1709,13 @@ discard block |
||
| 1709 | 1709 | //$Connection->db->commit(); |
| 1710 | 1710 | } |
| 1711 | 1711 | return ''; |
| 1712 | - } |
|
| 1712 | + } |
|
| 1713 | 1713 | |
| 1714 | 1714 | /** |
| 1715 | - * Convert a HTML table to an array |
|
| 1716 | - * @param String $data HTML page |
|
| 1717 | - * @return Array array of the tables in HTML page |
|
| 1718 | - */ |
|
| 1715 | + * Convert a HTML table to an array |
|
| 1716 | + * @param String $data HTML page |
|
| 1717 | + * @return Array array of the tables in HTML page |
|
| 1718 | + */ |
|
| 1719 | 1719 | /* |
| 1720 | 1720 | private static function table2array($data) { |
| 1721 | 1721 | $html = str_get_html($data); |
@@ -1745,11 +1745,11 @@ discard block |
||
| 1745 | 1745 | return(array_filter($tabledata)); |
| 1746 | 1746 | } |
| 1747 | 1747 | */ |
| 1748 | - /** |
|
| 1749 | - * Get data from form result |
|
| 1750 | - * @param String $url form URL |
|
| 1751 | - * @return String the result |
|
| 1752 | - */ |
|
| 1748 | + /** |
|
| 1749 | + * Get data from form result |
|
| 1750 | + * @param String $url form URL |
|
| 1751 | + * @return String the result |
|
| 1752 | + */ |
|
| 1753 | 1753 | /* |
| 1754 | 1754 | private static function getData($url) { |
| 1755 | 1755 | $ch = curl_init(); |
@@ -1842,7 +1842,7 @@ discard block |
||
| 1842 | 1842 | if ($globalTransaction) $Connection->db->commit(); |
| 1843 | 1843 | } |
| 1844 | 1844 | return ''; |
| 1845 | - } |
|
| 1845 | + } |
|
| 1846 | 1846 | |
| 1847 | 1847 | public static function ivao_airlines($filename) { |
| 1848 | 1848 | //require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
@@ -1852,10 +1852,10 @@ discard block |
||
| 1852 | 1852 | try { |
| 1853 | 1853 | $Connection = new Connection(); |
| 1854 | 1854 | $sth = $Connection->db->prepare($query); |
| 1855 | - $sth->execute(); |
|
| 1856 | - } catch(PDOException $e) { |
|
| 1857 | - return "error : ".$e->getMessage(); |
|
| 1858 | - } |
|
| 1855 | + $sth->execute(); |
|
| 1856 | + } catch(PDOException $e) { |
|
| 1857 | + return "error : ".$e->getMessage(); |
|
| 1858 | + } |
|
| 1859 | 1859 | |
| 1860 | 1860 | $header = NULL; |
| 1861 | 1861 | $delimiter = ':'; |
@@ -1879,7 +1879,7 @@ discard block |
||
| 1879 | 1879 | if ($globalTransaction) $Connection->db->commit(); |
| 1880 | 1880 | } |
| 1881 | 1881 | return ''; |
| 1882 | - } |
|
| 1882 | + } |
|
| 1883 | 1883 | |
| 1884 | 1884 | public static function update_airspace() { |
| 1885 | 1885 | global $tmp_dir, $globalDBdriver; |
@@ -1889,11 +1889,11 @@ discard block |
||
| 1889 | 1889 | $query = 'DROP TABLE airspace'; |
| 1890 | 1890 | try { |
| 1891 | 1891 | $sth = $Connection->db->prepare($query); |
| 1892 | - $sth->execute(); |
|
| 1893 | - } catch(PDOException $e) { |
|
| 1892 | + $sth->execute(); |
|
| 1893 | + } catch(PDOException $e) { |
|
| 1894 | 1894 | return "error : ".$e->getMessage(); |
| 1895 | - } |
|
| 1896 | - } |
|
| 1895 | + } |
|
| 1896 | + } |
|
| 1897 | 1897 | |
| 1898 | 1898 | |
| 1899 | 1899 | if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
@@ -1958,10 +1958,10 @@ discard block |
||
| 1958 | 1958 | $query = 'DROP TABLE countries'; |
| 1959 | 1959 | try { |
| 1960 | 1960 | $sth = $Connection->db->prepare($query); |
| 1961 | - $sth->execute(); |
|
| 1962 | - } catch(PDOException $e) { |
|
| 1963 | - echo "error : ".$e->getMessage(); |
|
| 1964 | - } |
|
| 1961 | + $sth->execute(); |
|
| 1962 | + } catch(PDOException $e) { |
|
| 1963 | + echo "error : ".$e->getMessage(); |
|
| 1964 | + } |
|
| 1965 | 1965 | } |
| 1966 | 1966 | if ($globalDBdriver == 'mysql') { |
| 1967 | 1967 | update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql'); |
@@ -2417,7 +2417,7 @@ discard block |
||
| 2417 | 2417 | $error = update_db::airlines_fam(); |
| 2418 | 2418 | update_db::insert_airlines_version($airlines_md5); |
| 2419 | 2419 | } else $error = "File ".$tmp_dir.'airlines.tsv.gz'." md5 failed. Download failed."; |
| 2420 | - } else $error = "File ".$tmp_dir.'airlines.tsv.gz'." doesn't exist. Download failed."; |
|
| 2420 | + } else $error = "File ".$tmp_dir.'airlines.tsv.gz'." doesn't exist. Download failed."; |
|
| 2421 | 2421 | } elseif ($globalDebug) echo "No update"; |
| 2422 | 2422 | } else $error = "File ".$tmp_dir.'airlines.tsv.gz.md5'." doesn't exist. Download failed."; |
| 2423 | 2423 | if ($error != '') { |
@@ -2790,12 +2790,12 @@ discard block |
||
| 2790 | 2790 | echo $data; |
| 2791 | 2791 | */ |
| 2792 | 2792 | if (file_exists($tmp_dir.'aircrafts.html')) { |
| 2793 | - //var_dump(file_get_html($tmp_dir.'aircrafts.html')); |
|
| 2794 | - $fh = fopen($tmp_dir.'aircrafts.html',"r"); |
|
| 2795 | - $result = fread($fh,100000000); |
|
| 2796 | - //echo $result; |
|
| 2797 | - //var_dump(str_get_html($result)); |
|
| 2798 | - //print_r(self::table2array($result)); |
|
| 2793 | + //var_dump(file_get_html($tmp_dir.'aircrafts.html')); |
|
| 2794 | + $fh = fopen($tmp_dir.'aircrafts.html',"r"); |
|
| 2795 | + $result = fread($fh,100000000); |
|
| 2796 | + //echo $result; |
|
| 2797 | + //var_dump(str_get_html($result)); |
|
| 2798 | + //print_r(self::table2array($result)); |
|
| 2799 | 2799 | } |
| 2800 | 2800 | |
| 2801 | 2801 | } |
@@ -2809,10 +2809,10 @@ discard block |
||
| 2809 | 2809 | try { |
| 2810 | 2810 | $Connection = new Connection(); |
| 2811 | 2811 | $sth = $Connection->db->prepare($query); |
| 2812 | - $sth->execute(); |
|
| 2813 | - } catch(PDOException $e) { |
|
| 2814 | - return "error : ".$e->getMessage(); |
|
| 2815 | - } |
|
| 2812 | + $sth->execute(); |
|
| 2813 | + } catch(PDOException $e) { |
|
| 2814 | + return "error : ".$e->getMessage(); |
|
| 2815 | + } |
|
| 2816 | 2816 | |
| 2817 | 2817 | $error = ''; |
| 2818 | 2818 | if ($globalDebug) echo "Notam : Download..."; |
@@ -2868,8 +2868,8 @@ discard block |
||
| 2868 | 2868 | $data['date_end'] = date("Y-m-d H:i:s",strtotime($to)); |
| 2869 | 2869 | $data['permanent'] = 0; |
| 2870 | 2870 | } else { |
| 2871 | - $data['date_end'] = NULL; |
|
| 2872 | - $data['permanent'] = 1; |
|
| 2871 | + $data['date_end'] = NULL; |
|
| 2872 | + $data['permanent'] = 1; |
|
| 2873 | 2873 | } |
| 2874 | 2874 | $data['full_notam'] = $notam['title'].'<br>'.$notam['description']; |
| 2875 | 2875 | $NOTAM = new NOTAM(); |
@@ -2943,13 +2943,13 @@ discard block |
||
| 2943 | 2943 | try { |
| 2944 | 2944 | $Connection = new Connection(); |
| 2945 | 2945 | $sth = $Connection->db->prepare($query); |
| 2946 | - $sth->execute(); |
|
| 2947 | - } catch(PDOException $e) { |
|
| 2948 | - return "error : ".$e->getMessage(); |
|
| 2949 | - } |
|
| 2950 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2951 | - if ($row['nb'] > 0) return false; |
|
| 2952 | - else return true; |
|
| 2946 | + $sth->execute(); |
|
| 2947 | + } catch(PDOException $e) { |
|
| 2948 | + return "error : ".$e->getMessage(); |
|
| 2949 | + } |
|
| 2950 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2951 | + if ($row['nb'] > 0) return false; |
|
| 2952 | + else return true; |
|
| 2953 | 2953 | } |
| 2954 | 2954 | |
| 2955 | 2955 | public static function insert_last_update() { |
@@ -2958,10 +2958,10 @@ discard block |
||
| 2958 | 2958 | try { |
| 2959 | 2959 | $Connection = new Connection(); |
| 2960 | 2960 | $sth = $Connection->db->prepare($query); |
| 2961 | - $sth->execute(); |
|
| 2962 | - } catch(PDOException $e) { |
|
| 2963 | - return "error : ".$e->getMessage(); |
|
| 2964 | - } |
|
| 2961 | + $sth->execute(); |
|
| 2962 | + } catch(PDOException $e) { |
|
| 2963 | + return "error : ".$e->getMessage(); |
|
| 2964 | + } |
|
| 2965 | 2965 | } |
| 2966 | 2966 | |
| 2967 | 2967 | public static function check_airspace_version($version) { |
@@ -2969,13 +2969,13 @@ discard block |
||
| 2969 | 2969 | try { |
| 2970 | 2970 | $Connection = new Connection(); |
| 2971 | 2971 | $sth = $Connection->db->prepare($query); |
| 2972 | - $sth->execute(array(':version' => $version)); |
|
| 2973 | - } catch(PDOException $e) { |
|
| 2974 | - return "error : ".$e->getMessage(); |
|
| 2975 | - } |
|
| 2976 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2977 | - if ($row['nb'] > 0) return true; |
|
| 2978 | - else return false; |
|
| 2972 | + $sth->execute(array(':version' => $version)); |
|
| 2973 | + } catch(PDOException $e) { |
|
| 2974 | + return "error : ".$e->getMessage(); |
|
| 2975 | + } |
|
| 2976 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2977 | + if ($row['nb'] > 0) return true; |
|
| 2978 | + else return false; |
|
| 2979 | 2979 | } |
| 2980 | 2980 | |
| 2981 | 2981 | public static function check_geoid_version($version) { |
@@ -2983,13 +2983,13 @@ discard block |
||
| 2983 | 2983 | try { |
| 2984 | 2984 | $Connection = new Connection(); |
| 2985 | 2985 | $sth = $Connection->db->prepare($query); |
| 2986 | - $sth->execute(array(':version' => $version)); |
|
| 2987 | - } catch(PDOException $e) { |
|
| 2988 | - return "error : ".$e->getMessage(); |
|
| 2989 | - } |
|
| 2990 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2991 | - if ($row['nb'] > 0) return true; |
|
| 2992 | - else return false; |
|
| 2986 | + $sth->execute(array(':version' => $version)); |
|
| 2987 | + } catch(PDOException $e) { |
|
| 2988 | + return "error : ".$e->getMessage(); |
|
| 2989 | + } |
|
| 2990 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2991 | + if ($row['nb'] > 0) return true; |
|
| 2992 | + else return false; |
|
| 2993 | 2993 | } |
| 2994 | 2994 | |
| 2995 | 2995 | public static function check_marine_identity_version($version) { |
@@ -3090,10 +3090,10 @@ discard block |
||
| 3090 | 3090 | try { |
| 3091 | 3091 | $Connection = new Connection(); |
| 3092 | 3092 | $sth = $Connection->db->prepare($query); |
| 3093 | - $sth->execute(array(':version' => $version)); |
|
| 3094 | - } catch(PDOException $e) { |
|
| 3095 | - return "error : ".$e->getMessage(); |
|
| 3096 | - } |
|
| 3093 | + $sth->execute(array(':version' => $version)); |
|
| 3094 | + } catch(PDOException $e) { |
|
| 3095 | + return "error : ".$e->getMessage(); |
|
| 3096 | + } |
|
| 3097 | 3097 | } |
| 3098 | 3098 | |
| 3099 | 3099 | public static function insert_marine_identity_version($version) { |
@@ -3130,13 +3130,13 @@ discard block |
||
| 3130 | 3130 | try { |
| 3131 | 3131 | $Connection = new Connection(); |
| 3132 | 3132 | $sth = $Connection->db->prepare($query); |
| 3133 | - $sth->execute(); |
|
| 3134 | - } catch(PDOException $e) { |
|
| 3135 | - return "error : ".$e->getMessage(); |
|
| 3136 | - } |
|
| 3137 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 3138 | - if ($row['nb'] > 0) return false; |
|
| 3139 | - else return true; |
|
| 3133 | + $sth->execute(); |
|
| 3134 | + } catch(PDOException $e) { |
|
| 3135 | + return "error : ".$e->getMessage(); |
|
| 3136 | + } |
|
| 3137 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 3138 | + if ($row['nb'] > 0) return false; |
|
| 3139 | + else return true; |
|
| 3140 | 3140 | } |
| 3141 | 3141 | |
| 3142 | 3142 | public static function insert_last_notam_update() { |
@@ -3145,10 +3145,10 @@ discard block |
||
| 3145 | 3145 | try { |
| 3146 | 3146 | $Connection = new Connection(); |
| 3147 | 3147 | $sth = $Connection->db->prepare($query); |
| 3148 | - $sth->execute(); |
|
| 3149 | - } catch(PDOException $e) { |
|
| 3150 | - return "error : ".$e->getMessage(); |
|
| 3151 | - } |
|
| 3148 | + $sth->execute(); |
|
| 3149 | + } catch(PDOException $e) { |
|
| 3150 | + return "error : ".$e->getMessage(); |
|
| 3151 | + } |
|
| 3152 | 3152 | } |
| 3153 | 3153 | |
| 3154 | 3154 | public static function check_last_airspace_update() { |
@@ -3161,13 +3161,13 @@ discard block |
||
| 3161 | 3161 | try { |
| 3162 | 3162 | $Connection = new Connection(); |
| 3163 | 3163 | $sth = $Connection->db->prepare($query); |
| 3164 | - $sth->execute(); |
|
| 3165 | - } catch(PDOException $e) { |
|
| 3166 | - return "error : ".$e->getMessage(); |
|
| 3167 | - } |
|
| 3168 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 3169 | - if ($row['nb'] > 0) return false; |
|
| 3170 | - else return true; |
|
| 3164 | + $sth->execute(); |
|
| 3165 | + } catch(PDOException $e) { |
|
| 3166 | + return "error : ".$e->getMessage(); |
|
| 3167 | + } |
|
| 3168 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 3169 | + if ($row['nb'] > 0) return false; |
|
| 3170 | + else return true; |
|
| 3171 | 3171 | } |
| 3172 | 3172 | |
| 3173 | 3173 | public static function insert_last_airspace_update() { |
@@ -3176,10 +3176,10 @@ discard block |
||
| 3176 | 3176 | try { |
| 3177 | 3177 | $Connection = new Connection(); |
| 3178 | 3178 | $sth = $Connection->db->prepare($query); |
| 3179 | - $sth->execute(); |
|
| 3180 | - } catch(PDOException $e) { |
|
| 3181 | - return "error : ".$e->getMessage(); |
|
| 3182 | - } |
|
| 3179 | + $sth->execute(); |
|
| 3180 | + } catch(PDOException $e) { |
|
| 3181 | + return "error : ".$e->getMessage(); |
|
| 3182 | + } |
|
| 3183 | 3183 | } |
| 3184 | 3184 | |
| 3185 | 3185 | public static function check_last_geoid_update() { |
@@ -3192,13 +3192,13 @@ discard block |
||
| 3192 | 3192 | try { |
| 3193 | 3193 | $Connection = new Connection(); |
| 3194 | 3194 | $sth = $Connection->db->prepare($query); |
| 3195 | - $sth->execute(); |
|
| 3196 | - } catch(PDOException $e) { |
|
| 3197 | - return "error : ".$e->getMessage(); |
|
| 3198 | - } |
|
| 3199 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 3200 | - if ($row['nb'] > 0) return false; |
|
| 3201 | - else return true; |
|
| 3195 | + $sth->execute(); |
|
| 3196 | + } catch(PDOException $e) { |
|
| 3197 | + return "error : ".$e->getMessage(); |
|
| 3198 | + } |
|
| 3199 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 3200 | + if ($row['nb'] > 0) return false; |
|
| 3201 | + else return true; |
|
| 3202 | 3202 | } |
| 3203 | 3203 | |
| 3204 | 3204 | public static function insert_last_geoid_update() { |
@@ -3207,10 +3207,10 @@ discard block |
||
| 3207 | 3207 | try { |
| 3208 | 3208 | $Connection = new Connection(); |
| 3209 | 3209 | $sth = $Connection->db->prepare($query); |
| 3210 | - $sth->execute(); |
|
| 3211 | - } catch(PDOException $e) { |
|
| 3212 | - return "error : ".$e->getMessage(); |
|
| 3213 | - } |
|
| 3210 | + $sth->execute(); |
|
| 3211 | + } catch(PDOException $e) { |
|
| 3212 | + return "error : ".$e->getMessage(); |
|
| 3213 | + } |
|
| 3214 | 3214 | } |
| 3215 | 3215 | |
| 3216 | 3216 | public static function check_last_owner_update() { |
@@ -3223,13 +3223,13 @@ discard block |
||
| 3223 | 3223 | try { |
| 3224 | 3224 | $Connection = new Connection(); |
| 3225 | 3225 | $sth = $Connection->db->prepare($query); |
| 3226 | - $sth->execute(); |
|
| 3227 | - } catch(PDOException $e) { |
|
| 3228 | - return "error : ".$e->getMessage(); |
|
| 3229 | - } |
|
| 3230 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 3231 | - if ($row['nb'] > 0) return false; |
|
| 3232 | - else return true; |
|
| 3226 | + $sth->execute(); |
|
| 3227 | + } catch(PDOException $e) { |
|
| 3228 | + return "error : ".$e->getMessage(); |
|
| 3229 | + } |
|
| 3230 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 3231 | + if ($row['nb'] > 0) return false; |
|
| 3232 | + else return true; |
|
| 3233 | 3233 | } |
| 3234 | 3234 | |
| 3235 | 3235 | public static function insert_last_owner_update() { |
@@ -3238,10 +3238,10 @@ discard block |
||
| 3238 | 3238 | try { |
| 3239 | 3239 | $Connection = new Connection(); |
| 3240 | 3240 | $sth = $Connection->db->prepare($query); |
| 3241 | - $sth->execute(); |
|
| 3242 | - } catch(PDOException $e) { |
|
| 3243 | - return "error : ".$e->getMessage(); |
|
| 3244 | - } |
|
| 3241 | + $sth->execute(); |
|
| 3242 | + } catch(PDOException $e) { |
|
| 3243 | + return "error : ".$e->getMessage(); |
|
| 3244 | + } |
|
| 3245 | 3245 | } |
| 3246 | 3246 | public static function check_last_schedules_update() { |
| 3247 | 3247 | global $globalDBdriver; |
@@ -3253,13 +3253,13 @@ discard block |
||
| 3253 | 3253 | try { |
| 3254 | 3254 | $Connection = new Connection(); |
| 3255 | 3255 | $sth = $Connection->db->prepare($query); |
| 3256 | - $sth->execute(); |
|
| 3257 | - } catch(PDOException $e) { |
|
| 3258 | - return "error : ".$e->getMessage(); |
|
| 3259 | - } |
|
| 3260 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 3261 | - if ($row['nb'] > 0) return false; |
|
| 3262 | - else return true; |
|
| 3256 | + $sth->execute(); |
|
| 3257 | + } catch(PDOException $e) { |
|
| 3258 | + return "error : ".$e->getMessage(); |
|
| 3259 | + } |
|
| 3260 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 3261 | + if ($row['nb'] > 0) return false; |
|
| 3262 | + else return true; |
|
| 3263 | 3263 | } |
| 3264 | 3264 | |
| 3265 | 3265 | public static function insert_last_schedules_update() { |
@@ -3439,10 +3439,10 @@ discard block |
||
| 3439 | 3439 | try { |
| 3440 | 3440 | $Connection = new Connection(); |
| 3441 | 3441 | $sth = $Connection->db->prepare($query); |
| 3442 | - $sth->execute(); |
|
| 3443 | - } catch(PDOException $e) { |
|
| 3444 | - return "error : ".$e->getMessage(); |
|
| 3445 | - } |
|
| 3442 | + $sth->execute(); |
|
| 3443 | + } catch(PDOException $e) { |
|
| 3444 | + return "error : ".$e->getMessage(); |
|
| 3445 | + } |
|
| 3446 | 3446 | } |
| 3447 | 3447 | public static function delete_duplicateowner() { |
| 3448 | 3448 | global $globalDBdriver; |
@@ -3454,10 +3454,10 @@ discard block |
||
| 3454 | 3454 | try { |
| 3455 | 3455 | $Connection = new Connection(); |
| 3456 | 3456 | $sth = $Connection->db->prepare($query); |
| 3457 | - $sth->execute(); |
|
| 3458 | - } catch(PDOException $e) { |
|
| 3459 | - return "error : ".$e->getMessage(); |
|
| 3460 | - } |
|
| 3457 | + $sth->execute(); |
|
| 3458 | + } catch(PDOException $e) { |
|
| 3459 | + return "error : ".$e->getMessage(); |
|
| 3460 | + } |
|
| 3461 | 3461 | } |
| 3462 | 3462 | |
| 3463 | 3463 | public static function update_all() { |
@@ -26,7 +26,9 @@ discard block |
||
| 26 | 26 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
| 27 | 27 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
| 28 | 28 | curl_setopt($ch, CURLOPT_TIMEOUT, 20); |
| 29 | - if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
| 29 | + if ($referer != '') { |
|
| 30 | + curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
| 31 | + } |
|
| 30 | 32 | curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5'); |
| 31 | 33 | curl_setopt($ch, CURLOPT_FILE, $fp); |
| 32 | 34 | curl_exec($ch); |
@@ -37,12 +39,16 @@ discard block |
||
| 37 | 39 | public static function gunzip($in_file,$out_file_name = '') { |
| 38 | 40 | //echo $in_file.' -> '.$out_file_name."\n"; |
| 39 | 41 | $buffer_size = 4096; // read 4kb at a time |
| 40 | - if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); |
|
| 42 | + if ($out_file_name == '') { |
|
| 43 | + $out_file_name = str_replace('.gz', '', $in_file); |
|
| 44 | + } |
|
| 41 | 45 | if ($in_file != '' && file_exists($in_file)) { |
| 42 | 46 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
| 43 | - if (function_exists('gzopen')) $file = gzopen($in_file,'rb'); |
|
| 44 | - elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb'); |
|
| 45 | - else { |
|
| 47 | + if (function_exists('gzopen')) { |
|
| 48 | + $file = gzopen($in_file,'rb'); |
|
| 49 | + } elseif (function_exists('gzopen64')) { |
|
| 50 | + $file = gzopen64($in_file,'rb'); |
|
| 51 | + } else { |
|
| 46 | 52 | echo 'gzopen not available'; |
| 47 | 53 | die; |
| 48 | 54 | } |
@@ -63,8 +69,12 @@ discard block |
||
| 63 | 69 | if ($res === TRUE) { |
| 64 | 70 | $zip->extractTo($path); |
| 65 | 71 | $zip->close(); |
| 66 | - } else return false; |
|
| 67 | - } else return false; |
|
| 72 | + } else { |
|
| 73 | + return false; |
|
| 74 | + } |
|
| 75 | + } else { |
|
| 76 | + return false; |
|
| 77 | + } |
|
| 68 | 78 | } |
| 69 | 79 | |
| 70 | 80 | public static function connect_sqlite($database) { |
@@ -79,7 +89,9 @@ discard block |
||
| 79 | 89 | public static function retrieve_route_sqlite_to_dest($database_file) { |
| 80 | 90 | global $globalDebug, $globalTransaction; |
| 81 | 91 | //$query = 'TRUNCATE TABLE routes'; |
| 82 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
| 92 | + if ($globalDebug) { |
|
| 93 | + echo " - Delete previous routes from DB -"; |
|
| 94 | + } |
|
| 83 | 95 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
| 84 | 96 | $Connection = new Connection(); |
| 85 | 97 | try { |
@@ -90,7 +102,9 @@ discard block |
||
| 90 | 102 | return "error : ".$e->getMessage(); |
| 91 | 103 | } |
| 92 | 104 | |
| 93 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
| 105 | + if ($globalDebug) { |
|
| 106 | + echo " - Add routes to DB -"; |
|
| 107 | + } |
|
| 94 | 108 | update_db::connect_sqlite($database_file); |
| 95 | 109 | //$query = 'select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID'; |
| 96 | 110 | $query = "select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao, rstp.allstop AS AllStop from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID LEFT JOIN (select RouteId,GROUP_CONCAT(icao,' ') as allstop from routestop left join Airport as air ON routestop.AirportId = air.AirportID group by RouteID) AS rstp ON Route.RouteID = rstp.RouteID"; |
@@ -105,15 +119,21 @@ discard block |
||
| 105 | 119 | $Connection = new Connection(); |
| 106 | 120 | $sth_dest = $Connection->db->prepare($query_dest); |
| 107 | 121 | try { |
| 108 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 122 | + if ($globalTransaction) { |
|
| 123 | + $Connection->db->beginTransaction(); |
|
| 124 | + } |
|
| 109 | 125 | while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
| 110 | 126 | //$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
| 111 | 127 | $query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
| 112 | 128 | $sth_dest->execute($query_dest_values); |
| 113 | 129 | } |
| 114 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 130 | + if ($globalTransaction) { |
|
| 131 | + $Connection->db->commit(); |
|
| 132 | + } |
|
| 115 | 133 | } catch(PDOException $e) { |
| 116 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
| 134 | + if ($globalTransaction) { |
|
| 135 | + $Connection->db->rollBack(); |
|
| 136 | + } |
|
| 117 | 137 | return "error : ".$e->getMessage(); |
| 118 | 138 | } |
| 119 | 139 | return ''; |
@@ -121,7 +141,9 @@ discard block |
||
| 121 | 141 | public static function retrieve_route_oneworld($database_file) { |
| 122 | 142 | global $globalDebug, $globalTransaction; |
| 123 | 143 | //$query = 'TRUNCATE TABLE routes'; |
| 124 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
| 144 | + if ($globalDebug) { |
|
| 145 | + echo " - Delete previous routes from DB -"; |
|
| 146 | + } |
|
| 125 | 147 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
| 126 | 148 | $Connection = new Connection(); |
| 127 | 149 | try { |
@@ -132,14 +154,18 @@ discard block |
||
| 132 | 154 | return "error : ".$e->getMessage(); |
| 133 | 155 | } |
| 134 | 156 | |
| 135 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
| 157 | + if ($globalDebug) { |
|
| 158 | + echo " - Add routes to DB -"; |
|
| 159 | + } |
|
| 136 | 160 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 137 | 161 | $Spotter = new Spotter(); |
| 138 | 162 | if ($fh = fopen($database_file,"r")) { |
| 139 | 163 | $query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)'; |
| 140 | 164 | $Connection = new Connection(); |
| 141 | 165 | $sth_dest = $Connection->db->prepare($query_dest); |
| 142 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 166 | + if ($globalTransaction) { |
|
| 167 | + $Connection->db->beginTransaction(); |
|
| 168 | + } |
|
| 143 | 169 | while (!feof($fh)) { |
| 144 | 170 | $line = fgetcsv($fh,9999,','); |
| 145 | 171 | if ($line[0] != '') { |
@@ -148,13 +174,17 @@ discard block |
||
| 148 | 174 | $query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld'); |
| 149 | 175 | $sth_dest->execute($query_dest_values); |
| 150 | 176 | } catch(PDOException $e) { |
| 151 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
| 177 | + if ($globalTransaction) { |
|
| 178 | + $Connection->db->rollBack(); |
|
| 179 | + } |
|
| 152 | 180 | return "error : ".$e->getMessage(); |
| 153 | 181 | } |
| 154 | 182 | } |
| 155 | 183 | } |
| 156 | 184 | } |
| 157 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 185 | + if ($globalTransaction) { |
|
| 186 | + $Connection->db->commit(); |
|
| 187 | + } |
|
| 158 | 188 | } |
| 159 | 189 | return ''; |
| 160 | 190 | } |
@@ -162,7 +192,9 @@ discard block |
||
| 162 | 192 | public static function retrieve_route_skyteam($database_file) { |
| 163 | 193 | global $globalDebug, $globalTransaction; |
| 164 | 194 | //$query = 'TRUNCATE TABLE routes'; |
| 165 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
| 195 | + if ($globalDebug) { |
|
| 196 | + echo " - Delete previous routes from DB -"; |
|
| 197 | + } |
|
| 166 | 198 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
| 167 | 199 | $Connection = new Connection(); |
| 168 | 200 | try { |
@@ -173,7 +205,9 @@ discard block |
||
| 173 | 205 | return "error : ".$e->getMessage(); |
| 174 | 206 | } |
| 175 | 207 | |
| 176 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
| 208 | + if ($globalDebug) { |
|
| 209 | + echo " - Add routes to DB -"; |
|
| 210 | + } |
|
| 177 | 211 | |
| 178 | 212 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 179 | 213 | $Spotter = new Spotter(); |
@@ -182,7 +216,9 @@ discard block |
||
| 182 | 216 | $Connection = new Connection(); |
| 183 | 217 | $sth_dest = $Connection->db->prepare($query_dest); |
| 184 | 218 | try { |
| 185 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 219 | + if ($globalTransaction) { |
|
| 220 | + $Connection->db->beginTransaction(); |
|
| 221 | + } |
|
| 186 | 222 | while (!feof($fh)) { |
| 187 | 223 | $line = fgetcsv($fh,9999,','); |
| 188 | 224 | if ($line[0] != '') { |
@@ -193,9 +229,13 @@ discard block |
||
| 193 | 229 | } |
| 194 | 230 | } |
| 195 | 231 | } |
| 196 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 232 | + if ($globalTransaction) { |
|
| 233 | + $Connection->db->commit(); |
|
| 234 | + } |
|
| 197 | 235 | } catch(PDOException $e) { |
| 198 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
| 236 | + if ($globalTransaction) { |
|
| 237 | + $Connection->db->rollBack(); |
|
| 238 | + } |
|
| 199 | 239 | return "error : ".$e->getMessage(); |
| 200 | 240 | } |
| 201 | 241 | } |
@@ -238,11 +278,16 @@ discard block |
||
| 238 | 278 | $sth_dest = $Connection->db->prepare($query_dest); |
| 239 | 279 | $sth_dest_owner = $Connection->db->prepare($query_dest_owner); |
| 240 | 280 | try { |
| 241 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 281 | + if ($globalTransaction) { |
|
| 282 | + $Connection->db->beginTransaction(); |
|
| 283 | + } |
|
| 242 | 284 | while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
| 243 | 285 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
| 244 | - if ($values['UserString4'] == 'M') $type = 'military'; |
|
| 245 | - else $type = null; |
|
| 286 | + if ($values['UserString4'] == 'M') { |
|
| 287 | + $type = 'military'; |
|
| 288 | + } else { |
|
| 289 | + $type = null; |
|
| 290 | + } |
|
| 246 | 291 | $query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type); |
| 247 | 292 | $sth_dest->execute($query_dest_values); |
| 248 | 293 | if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') { |
@@ -250,7 +295,9 @@ discard block |
||
| 250 | 295 | $sth_dest_owner->execute($query_dest_owner_values); |
| 251 | 296 | } |
| 252 | 297 | } |
| 253 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 298 | + if ($globalTransaction) { |
|
| 299 | + $Connection->db->commit(); |
|
| 300 | + } |
|
| 254 | 301 | } catch(PDOException $e) { |
| 255 | 302 | return "error : ".$e->getMessage(); |
| 256 | 303 | } |
@@ -287,7 +334,9 @@ discard block |
||
| 287 | 334 | $Connection = new Connection(); |
| 288 | 335 | $sth_dest = $Connection->db->prepare($query_dest); |
| 289 | 336 | try { |
| 290 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 337 | + if ($globalTransaction) { |
|
| 338 | + $Connection->db->beginTransaction(); |
|
| 339 | + } |
|
| 291 | 340 | while (!feof($fh)) { |
| 292 | 341 | $values = array(); |
| 293 | 342 | $line = $Common->hex2str(fgets($fh,9999)); |
@@ -298,7 +347,9 @@ discard block |
||
| 298 | 347 | // Check if we can find ICAO, else set it to GLID |
| 299 | 348 | $aircraft_name_split = explode(' ',$aircraft_name); |
| 300 | 349 | $search_more = ''; |
| 301 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 350 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) { |
|
| 351 | + $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 352 | + } |
|
| 302 | 353 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
| 303 | 354 | $sth_search = $Connection->db->prepare($query_search); |
| 304 | 355 | try { |
@@ -311,7 +362,9 @@ discard block |
||
| 311 | 362 | } catch(PDOException $e) { |
| 312 | 363 | return "error : ".$e->getMessage(); |
| 313 | 364 | } |
| 314 | - if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID'; |
|
| 365 | + if (!isset($values['ICAOTypeCode'])) { |
|
| 366 | + $values['ICAOTypeCode'] = 'GLID'; |
|
| 367 | + } |
|
| 315 | 368 | // Add data to db |
| 316 | 369 | if ($values['Registration'] != '' && $values['Registration'] != '0000') { |
| 317 | 370 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
@@ -320,7 +373,9 @@ discard block |
||
| 320 | 373 | $sth_dest->execute($query_dest_values); |
| 321 | 374 | } |
| 322 | 375 | } |
| 323 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 376 | + if ($globalTransaction) { |
|
| 377 | + $Connection->db->commit(); |
|
| 378 | + } |
|
| 324 | 379 | } catch(PDOException $e) { |
| 325 | 380 | return "error : ".$e->getMessage(); |
| 326 | 381 | } |
@@ -356,7 +411,9 @@ discard block |
||
| 356 | 411 | $Connection = new Connection(); |
| 357 | 412 | $sth_dest = $Connection->db->prepare($query_dest); |
| 358 | 413 | try { |
| 359 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 414 | + if ($globalTransaction) { |
|
| 415 | + $Connection->db->beginTransaction(); |
|
| 416 | + } |
|
| 360 | 417 | $tmp = fgetcsv($fh,9999,',',"'"); |
| 361 | 418 | while (!feof($fh)) { |
| 362 | 419 | $line = fgetcsv($fh,9999,',',"'"); |
@@ -370,13 +427,17 @@ discard block |
||
| 370 | 427 | // Check if we can find ICAO, else set it to GLID |
| 371 | 428 | $aircraft_name_split = explode(' ',$aircraft_name); |
| 372 | 429 | $search_more = ''; |
| 373 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 430 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) { |
|
| 431 | + $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 432 | + } |
|
| 374 | 433 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
| 375 | 434 | $sth_search = $Connection->db->prepare($query_search); |
| 376 | 435 | try { |
| 377 | 436 | $sth_search->execute(); |
| 378 | 437 | $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
| 379 | - if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
|
| 438 | + if (isset($result['icao']) && $result['icao'] != '') { |
|
| 439 | + $values['ICAOTypeCode'] = $result['icao']; |
|
| 440 | + } |
|
| 380 | 441 | } catch(PDOException $e) { |
| 381 | 442 | return "error : ".$e->getMessage(); |
| 382 | 443 | } |
@@ -389,7 +450,9 @@ discard block |
||
| 389 | 450 | $sth_dest->execute($query_dest_values); |
| 390 | 451 | } |
| 391 | 452 | } |
| 392 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 453 | + if ($globalTransaction) { |
|
| 454 | + $Connection->db->commit(); |
|
| 455 | + } |
|
| 393 | 456 | } catch(PDOException $e) { |
| 394 | 457 | return "error : ".$e->getMessage(); |
| 395 | 458 | } |
@@ -428,7 +491,9 @@ discard block |
||
| 428 | 491 | $sth_dest = $Connection->db->prepare($query_dest); |
| 429 | 492 | $sth_modes = $Connection->db->prepare($query_modes); |
| 430 | 493 | try { |
| 431 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 494 | + if ($globalTransaction) { |
|
| 495 | + $Connection->db->beginTransaction(); |
|
| 496 | + } |
|
| 432 | 497 | $tmp = fgetcsv($fh,9999,',','"'); |
| 433 | 498 | while (!feof($fh)) { |
| 434 | 499 | $line = fgetcsv($fh,9999,',','"'); |
@@ -438,16 +503,22 @@ discard block |
||
| 438 | 503 | $values['registration'] = $line[0]; |
| 439 | 504 | $values['base'] = $line[4]; |
| 440 | 505 | $values['owner'] = $line[5]; |
| 441 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
| 442 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 506 | + if ($line[6] == '') { |
|
| 507 | + $values['date_first_reg'] = null; |
|
| 508 | + } else { |
|
| 509 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 510 | + } |
|
| 443 | 511 | $values['cancel'] = $line[7]; |
| 444 | 512 | } elseif ($country == 'EI') { |
| 445 | 513 | // TODO : add modeS & reg to aircraft_modes |
| 446 | 514 | $values['registration'] = $line[0]; |
| 447 | 515 | $values['base'] = $line[3]; |
| 448 | 516 | $values['owner'] = $line[2]; |
| 449 | - if ($line[1] == '') $values['date_first_reg'] = null; |
|
| 450 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
| 517 | + if ($line[1] == '') { |
|
| 518 | + $values['date_first_reg'] = null; |
|
| 519 | + } else { |
|
| 520 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
| 521 | + } |
|
| 451 | 522 | $values['cancel'] = ''; |
| 452 | 523 | $values['modes'] = $line[7]; |
| 453 | 524 | $values['icao'] = $line[8]; |
@@ -466,16 +537,22 @@ discard block |
||
| 466 | 537 | $values['registration'] = $line[3]; |
| 467 | 538 | $values['base'] = null; |
| 468 | 539 | $values['owner'] = $line[5]; |
| 469 | - if ($line[18] == '') $values['date_first_reg'] = null; |
|
| 470 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
| 540 | + if ($line[18] == '') { |
|
| 541 | + $values['date_first_reg'] = null; |
|
| 542 | + } else { |
|
| 543 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
| 544 | + } |
|
| 471 | 545 | $values['cancel'] = ''; |
| 472 | 546 | } elseif ($country == 'VH') { |
| 473 | 547 | // TODO : add modeS & reg to aircraft_modes |
| 474 | 548 | $values['registration'] = $line[0]; |
| 475 | 549 | $values['base'] = null; |
| 476 | 550 | $values['owner'] = $line[12]; |
| 477 | - if ($line[28] == '') $values['date_first_reg'] = null; |
|
| 478 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
| 551 | + if ($line[28] == '') { |
|
| 552 | + $values['date_first_reg'] = null; |
|
| 553 | + } else { |
|
| 554 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
| 555 | + } |
|
| 479 | 556 | |
| 480 | 557 | $values['cancel'] = $line[39]; |
| 481 | 558 | } elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { |
@@ -494,29 +571,41 @@ discard block |
||
| 494 | 571 | $values['registration'] = $line[0]; |
| 495 | 572 | $values['base'] = null; |
| 496 | 573 | $values['owner'] = $line[8]; |
| 497 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
| 498 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 574 | + if ($line[7] == '') { |
|
| 575 | + $values['date_first_reg'] = null; |
|
| 576 | + } else { |
|
| 577 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 578 | + } |
|
| 499 | 579 | $values['cancel'] = ''; |
| 500 | 580 | } elseif ($country == 'PP') { |
| 501 | 581 | $values['registration'] = $line[0]; |
| 502 | 582 | $values['base'] = null; |
| 503 | 583 | $values['owner'] = $line[4]; |
| 504 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
| 505 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 584 | + if ($line[6] == '') { |
|
| 585 | + $values['date_first_reg'] = null; |
|
| 586 | + } else { |
|
| 587 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 588 | + } |
|
| 506 | 589 | $values['cancel'] = $line[7]; |
| 507 | 590 | } elseif ($country == 'E7') { |
| 508 | 591 | $values['registration'] = $line[0]; |
| 509 | 592 | $values['base'] = null; |
| 510 | 593 | $values['owner'] = $line[4]; |
| 511 | - if ($line[5] == '') $values['date_first_reg'] = null; |
|
| 512 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
| 594 | + if ($line[5] == '') { |
|
| 595 | + $values['date_first_reg'] = null; |
|
| 596 | + } else { |
|
| 597 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
| 598 | + } |
|
| 513 | 599 | $values['cancel'] = ''; |
| 514 | 600 | } elseif ($country == '8Q') { |
| 515 | 601 | $values['registration'] = $line[0]; |
| 516 | 602 | $values['base'] = null; |
| 517 | 603 | $values['owner'] = $line[3]; |
| 518 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
| 519 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 604 | + if ($line[7] == '') { |
|
| 605 | + $values['date_first_reg'] = null; |
|
| 606 | + } else { |
|
| 607 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 608 | + } |
|
| 520 | 609 | $values['cancel'] = ''; |
| 521 | 610 | } elseif ($country == 'ZK') { |
| 522 | 611 | $values['registration'] = $line[0]; |
@@ -561,7 +650,9 @@ discard block |
||
| 561 | 650 | $sth_modes->execute($query_modes_values); |
| 562 | 651 | } |
| 563 | 652 | } |
| 564 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 653 | + if ($globalTransaction) { |
|
| 654 | + $Connection->db->commit(); |
|
| 655 | + } |
|
| 565 | 656 | } catch(PDOException $e) { |
| 566 | 657 | return "error : ".$e->getMessage(); |
| 567 | 658 | } |
@@ -697,25 +788,45 @@ discard block |
||
| 697 | 788 | VALUES (:name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)"; |
| 698 | 789 | $Connection = new Connection(); |
| 699 | 790 | $sth_dest = $Connection->db->prepare($query_dest); |
| 700 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 791 | + if ($globalTransaction) { |
|
| 792 | + $Connection->db->beginTransaction(); |
|
| 793 | + } |
|
| 701 | 794 | |
| 702 | 795 | $i = 0; |
| 703 | 796 | while($row = sparql_fetch_array($result)) |
| 704 | 797 | { |
| 705 | 798 | if ($i >= 1) { |
| 706 | 799 | //print_r($row); |
| 707 | - if (!isset($row['iata'])) $row['iata'] = ''; |
|
| 708 | - if (!isset($row['icao'])) $row['icao'] = ''; |
|
| 709 | - if (!isset($row['type'])) $row['type'] = ''; |
|
| 710 | - if (!isset($row['altitude'])) $row['altitude'] = ''; |
|
| 800 | + if (!isset($row['iata'])) { |
|
| 801 | + $row['iata'] = ''; |
|
| 802 | + } |
|
| 803 | + if (!isset($row['icao'])) { |
|
| 804 | + $row['icao'] = ''; |
|
| 805 | + } |
|
| 806 | + if (!isset($row['type'])) { |
|
| 807 | + $row['type'] = ''; |
|
| 808 | + } |
|
| 809 | + if (!isset($row['altitude'])) { |
|
| 810 | + $row['altitude'] = ''; |
|
| 811 | + } |
|
| 711 | 812 | if (isset($row['city_bis'])) { |
| 712 | 813 | $row['city'] = $row['city_bis']; |
| 713 | 814 | } |
| 714 | - if (!isset($row['city'])) $row['city'] = ''; |
|
| 715 | - if (!isset($row['country'])) $row['country'] = ''; |
|
| 716 | - if (!isset($row['homepage'])) $row['homepage'] = ''; |
|
| 717 | - if (!isset($row['wikipedia_page'])) $row['wikipedia_page'] = ''; |
|
| 718 | - if (!isset($row['name'])) continue; |
|
| 815 | + if (!isset($row['city'])) { |
|
| 816 | + $row['city'] = ''; |
|
| 817 | + } |
|
| 818 | + if (!isset($row['country'])) { |
|
| 819 | + $row['country'] = ''; |
|
| 820 | + } |
|
| 821 | + if (!isset($row['homepage'])) { |
|
| 822 | + $row['homepage'] = ''; |
|
| 823 | + } |
|
| 824 | + if (!isset($row['wikipedia_page'])) { |
|
| 825 | + $row['wikipedia_page'] = ''; |
|
| 826 | + } |
|
| 827 | + if (!isset($row['name'])) { |
|
| 828 | + continue; |
|
| 829 | + } |
|
| 719 | 830 | if (!isset($row['image'])) { |
| 720 | 831 | $row['image'] = ''; |
| 721 | 832 | $row['image_thumb'] = ''; |
@@ -771,7 +882,9 @@ discard block |
||
| 771 | 882 | |
| 772 | 883 | $i++; |
| 773 | 884 | } |
| 774 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 885 | + if ($globalTransaction) { |
|
| 886 | + $Connection->db->commit(); |
|
| 887 | + } |
|
| 775 | 888 | /* |
| 776 | 889 | echo "Delete duplicate rows...\n"; |
| 777 | 890 | $query = 'ALTER IGNORE TABLE airport ADD UNIQUE INDEX icaoidx (icao)'; |
@@ -814,7 +927,9 @@ discard block |
||
| 814 | 927 | $delimiter = ','; |
| 815 | 928 | $out_file = $tmp_dir.'airports.csv'; |
| 816 | 929 | update_db::download('http://ourairports.com/data/airports.csv',$out_file); |
| 817 | - if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
|
| 930 | + if (!file_exists($out_file) || !is_readable($out_file)) { |
|
| 931 | + return FALSE; |
|
| 932 | + } |
|
| 818 | 933 | echo "Add data from ourairports.com...\n"; |
| 819 | 934 | |
| 820 | 935 | $header = NULL; |
@@ -824,8 +939,9 @@ discard block |
||
| 824 | 939 | //$Connection->db->beginTransaction(); |
| 825 | 940 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 826 | 941 | { |
| 827 | - if(!$header) $header = $row; |
|
| 828 | - else { |
|
| 942 | + if(!$header) { |
|
| 943 | + $header = $row; |
|
| 944 | + } else { |
|
| 829 | 945 | $data = array(); |
| 830 | 946 | $data = array_combine($header, $row); |
| 831 | 947 | try { |
@@ -866,7 +982,9 @@ discard block |
||
| 866 | 982 | echo "Download data from another free database...\n"; |
| 867 | 983 | $out_file = $tmp_dir.'GlobalAirportDatabase.zip'; |
| 868 | 984 | update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file); |
| 869 | - if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
|
| 985 | + if (!file_exists($out_file) || !is_readable($out_file)) { |
|
| 986 | + return FALSE; |
|
| 987 | + } |
|
| 870 | 988 | update_db::unzip($out_file); |
| 871 | 989 | $header = NULL; |
| 872 | 990 | echo "Add data from another free database...\n"; |
@@ -877,8 +995,9 @@ discard block |
||
| 877 | 995 | //$Connection->db->beginTransaction(); |
| 878 | 996 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 879 | 997 | { |
| 880 | - if(!$header) $header = $row; |
|
| 881 | - else { |
|
| 998 | + if(!$header) { |
|
| 999 | + $header = $row; |
|
| 1000 | + } else { |
|
| 882 | 1001 | $data = $row; |
| 883 | 1002 | |
| 884 | 1003 | $query = 'UPDATE airport SET city = :city, country = :country WHERE icao = :icao'; |
@@ -1047,7 +1166,9 @@ discard block |
||
| 1047 | 1166 | if (($handle = fopen($tmp_dir.'MASTER.txt', 'r')) !== FALSE) |
| 1048 | 1167 | { |
| 1049 | 1168 | $i = 0; |
| 1050 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1169 | + if ($globalTransaction) { |
|
| 1170 | + $Connection->db->beginTransaction(); |
|
| 1171 | + } |
|
| 1051 | 1172 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1052 | 1173 | { |
| 1053 | 1174 | if ($i > 0) { |
@@ -1060,7 +1181,9 @@ discard block |
||
| 1060 | 1181 | } |
| 1061 | 1182 | $result_search = $sths->fetchAll(PDO::FETCH_ASSOC); |
| 1062 | 1183 | if (!empty($result_search)) { |
| 1063 | - if ($globalDebug) echo '.'; |
|
| 1184 | + if ($globalDebug) { |
|
| 1185 | + echo '.'; |
|
| 1186 | + } |
|
| 1064 | 1187 | //if ($globalDBdriver == 'mysql') { |
| 1065 | 1188 | // $queryi = 'INSERT INTO faamfr (mfr,icao) VALUES (:mfr,:icao) ON DUPLICATE KEY UPDATE icao = :icao'; |
| 1066 | 1189 | //} else { |
@@ -1082,8 +1205,12 @@ discard block |
||
| 1082 | 1205 | } |
| 1083 | 1206 | $result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC); |
| 1084 | 1207 | if (!empty($result_search_mfr)) { |
| 1085 | - if (trim($data[16]) == '' && trim($data[23]) != '') $data[16] = $data[23]; |
|
| 1086 | - if (trim($data[16]) == '' && trim($data[15]) != '') $data[16] = $data[15]; |
|
| 1208 | + if (trim($data[16]) == '' && trim($data[23]) != '') { |
|
| 1209 | + $data[16] = $data[23]; |
|
| 1210 | + } |
|
| 1211 | + if (trim($data[16]) == '' && trim($data[15]) != '') { |
|
| 1212 | + $data[16] = $data[15]; |
|
| 1213 | + } |
|
| 1087 | 1214 | $queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)'; |
| 1088 | 1215 | try { |
| 1089 | 1216 | $sthf = $Connection->db->prepare($queryf); |
@@ -1094,7 +1221,9 @@ discard block |
||
| 1094 | 1221 | } |
| 1095 | 1222 | } |
| 1096 | 1223 | if (strtotime($data[29]) > time()) { |
| 1097 | - if ($globalDebug) echo 'i'; |
|
| 1224 | + if ($globalDebug) { |
|
| 1225 | + echo 'i'; |
|
| 1226 | + } |
|
| 1098 | 1227 | $query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)'; |
| 1099 | 1228 | try { |
| 1100 | 1229 | $sth = $Connection->db->prepare($query); |
@@ -1105,13 +1234,19 @@ discard block |
||
| 1105 | 1234 | } |
| 1106 | 1235 | } |
| 1107 | 1236 | if ($i % 90 == 0) { |
| 1108 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1109 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1237 | + if ($globalTransaction) { |
|
| 1238 | + $Connection->db->commit(); |
|
| 1239 | + } |
|
| 1240 | + if ($globalTransaction) { |
|
| 1241 | + $Connection->db->beginTransaction(); |
|
| 1242 | + } |
|
| 1110 | 1243 | } |
| 1111 | 1244 | $i++; |
| 1112 | 1245 | } |
| 1113 | 1246 | fclose($handle); |
| 1114 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1247 | + if ($globalTransaction) { |
|
| 1248 | + $Connection->db->commit(); |
|
| 1249 | + } |
|
| 1115 | 1250 | } |
| 1116 | 1251 | return ''; |
| 1117 | 1252 | } |
@@ -1131,11 +1266,15 @@ discard block |
||
| 1131 | 1266 | if (($handle = fopen($tmp_dir.'modes.tsv', 'r')) !== FALSE) |
| 1132 | 1267 | { |
| 1133 | 1268 | $i = 0; |
| 1134 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1269 | + if ($globalTransaction) { |
|
| 1270 | + $Connection->db->beginTransaction(); |
|
| 1271 | + } |
|
| 1135 | 1272 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1136 | 1273 | { |
| 1137 | 1274 | if ($i > 0) { |
| 1138 | - if ($data[1] == 'NULL') $data[1] = $data[0]; |
|
| 1275 | + if ($data[1] == 'NULL') { |
|
| 1276 | + $data[1] = $data[0]; |
|
| 1277 | + } |
|
| 1139 | 1278 | $query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)'; |
| 1140 | 1279 | try { |
| 1141 | 1280 | $sth = $Connection->db->prepare($query); |
@@ -1147,7 +1286,9 @@ discard block |
||
| 1147 | 1286 | $i++; |
| 1148 | 1287 | } |
| 1149 | 1288 | fclose($handle); |
| 1150 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1289 | + if ($globalTransaction) { |
|
| 1290 | + $Connection->db->commit(); |
|
| 1291 | + } |
|
| 1151 | 1292 | } |
| 1152 | 1293 | return ''; |
| 1153 | 1294 | } |
@@ -1173,11 +1314,15 @@ discard block |
||
| 1173 | 1314 | if (($handle = fopen($tmp_dir.'airlines.tsv', 'r')) !== FALSE) |
| 1174 | 1315 | { |
| 1175 | 1316 | $i = 0; |
| 1176 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1317 | + if ($globalTransaction) { |
|
| 1318 | + $Connection->db->beginTransaction(); |
|
| 1319 | + } |
|
| 1177 | 1320 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1178 | 1321 | { |
| 1179 | 1322 | if ($i > 0) { |
| 1180 | - if ($data[1] == 'NULL') $data[1] = $data[0]; |
|
| 1323 | + if ($data[1] == 'NULL') { |
|
| 1324 | + $data[1] = $data[0]; |
|
| 1325 | + } |
|
| 1181 | 1326 | $query = 'INSERT INTO airlines (name,alias,iata,icao,callsign,country,active,type,home,wikipedia_link,alliance,ban_eu) VALUES (:name,:alias,:iata,:icao,:callsign,:country,:active,:type,:home,:wikipedia_link,:alliance,:ban_eu)'; |
| 1182 | 1327 | try { |
| 1183 | 1328 | $sth = $Connection->db->prepare($query); |
@@ -1189,7 +1334,9 @@ discard block |
||
| 1189 | 1334 | $i++; |
| 1190 | 1335 | } |
| 1191 | 1336 | fclose($handle); |
| 1192 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1337 | + if ($globalTransaction) { |
|
| 1338 | + $Connection->db->commit(); |
|
| 1339 | + } |
|
| 1193 | 1340 | } |
| 1194 | 1341 | $query = "UNLOCK TABLES"; |
| 1195 | 1342 | try { |
@@ -1217,7 +1364,9 @@ discard block |
||
| 1217 | 1364 | if (($handle = fopen($tmp_dir.'owners.tsv', 'r')) !== FALSE) |
| 1218 | 1365 | { |
| 1219 | 1366 | $i = 0; |
| 1220 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1367 | + if ($globalTransaction) { |
|
| 1368 | + $Connection->db->beginTransaction(); |
|
| 1369 | + } |
|
| 1221 | 1370 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1222 | 1371 | { |
| 1223 | 1372 | if ($i > 0) { |
@@ -1233,7 +1382,9 @@ discard block |
||
| 1233 | 1382 | $i++; |
| 1234 | 1383 | } |
| 1235 | 1384 | fclose($handle); |
| 1236 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1385 | + if ($globalTransaction) { |
|
| 1386 | + $Connection->db->commit(); |
|
| 1387 | + } |
|
| 1237 | 1388 | } |
| 1238 | 1389 | return ''; |
| 1239 | 1390 | } |
@@ -1253,7 +1404,9 @@ discard block |
||
| 1253 | 1404 | if (($handle = fopen($tmp_dir.'routes.tsv', 'r')) !== FALSE) |
| 1254 | 1405 | { |
| 1255 | 1406 | $i = 0; |
| 1256 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1407 | + if ($globalTransaction) { |
|
| 1408 | + $Connection->db->beginTransaction(); |
|
| 1409 | + } |
|
| 1257 | 1410 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1258 | 1411 | { |
| 1259 | 1412 | if ($i > 0) { |
@@ -1262,13 +1415,17 @@ discard block |
||
| 1262 | 1415 | $sth = $Connection->db->prepare($query); |
| 1263 | 1416 | $sth->execute(array(':CallSign' => $data[0],':Operator_ICAO' => $data[1],':FromAirport_ICAO' => $data[2],':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4],':ToAirport_Time' => $data[5],':RouteStop' => $data[6],':source' => 'website_fam')); |
| 1264 | 1417 | } catch(PDOException $e) { |
| 1265 | - if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".implode(',',$data); |
|
| 1418 | + if ($globalDebug) { |
|
| 1419 | + echo "error: ".$e->getMessage()." - data: ".implode(',',$data); |
|
| 1420 | + } |
|
| 1266 | 1421 | } |
| 1267 | 1422 | } |
| 1268 | 1423 | $i++; |
| 1269 | 1424 | } |
| 1270 | 1425 | fclose($handle); |
| 1271 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1426 | + if ($globalTransaction) { |
|
| 1427 | + $Connection->db->commit(); |
|
| 1428 | + } |
|
| 1272 | 1429 | } |
| 1273 | 1430 | return ''; |
| 1274 | 1431 | } |
@@ -1293,7 +1450,9 @@ discard block |
||
| 1293 | 1450 | $i = 0; |
| 1294 | 1451 | //$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE); |
| 1295 | 1452 | //$Connection->db->beginTransaction(); |
| 1296 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1453 | + if ($globalTransaction) { |
|
| 1454 | + $Connection->db->beginTransaction(); |
|
| 1455 | + } |
|
| 1297 | 1456 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1298 | 1457 | { |
| 1299 | 1458 | if ($i > 0) { |
@@ -1309,7 +1468,9 @@ discard block |
||
| 1309 | 1468 | $i++; |
| 1310 | 1469 | } |
| 1311 | 1470 | fclose($handle); |
| 1312 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1471 | + if ($globalTransaction) { |
|
| 1472 | + $Connection->db->commit(); |
|
| 1473 | + } |
|
| 1313 | 1474 | } |
| 1314 | 1475 | return ''; |
| 1315 | 1476 | } |
@@ -1329,7 +1490,9 @@ discard block |
||
| 1329 | 1490 | if (($handle = fopen($tmp_dir.'satellite.tsv', 'r')) !== FALSE) |
| 1330 | 1491 | { |
| 1331 | 1492 | $i = 0; |
| 1332 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1493 | + if ($globalTransaction) { |
|
| 1494 | + $Connection->db->beginTransaction(); |
|
| 1495 | + } |
|
| 1333 | 1496 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1334 | 1497 | { |
| 1335 | 1498 | if ($i > 0) { |
@@ -1346,7 +1509,9 @@ discard block |
||
| 1346 | 1509 | $i++; |
| 1347 | 1510 | } |
| 1348 | 1511 | fclose($handle); |
| 1349 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1512 | + if ($globalTransaction) { |
|
| 1513 | + $Connection->db->commit(); |
|
| 1514 | + } |
|
| 1350 | 1515 | } |
| 1351 | 1516 | return ''; |
| 1352 | 1517 | } |
@@ -1365,7 +1530,9 @@ discard block |
||
| 1365 | 1530 | $Connection = new Connection(); |
| 1366 | 1531 | if (($handle = fopen($tmp_dir.'ban_eu.csv', 'r')) !== FALSE) |
| 1367 | 1532 | { |
| 1368 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1533 | + if ($globalTransaction) { |
|
| 1534 | + $Connection->db->beginTransaction(); |
|
| 1535 | + } |
|
| 1369 | 1536 | while (($data = fgetcsv($handle, 1000)) !== FALSE) |
| 1370 | 1537 | { |
| 1371 | 1538 | $query = 'UPDATE airlines SET ban_eu = 1 WHERE icao = :icao AND forsource IS NULL'; |
@@ -1380,7 +1547,9 @@ discard block |
||
| 1380 | 1547 | } |
| 1381 | 1548 | } |
| 1382 | 1549 | fclose($handle); |
| 1383 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1550 | + if ($globalTransaction) { |
|
| 1551 | + $Connection->db->commit(); |
|
| 1552 | + } |
|
| 1384 | 1553 | } |
| 1385 | 1554 | return ''; |
| 1386 | 1555 | } |
@@ -1456,9 +1625,14 @@ discard block |
||
| 1456 | 1625 | if ($i > 0 && $data[0] != '') { |
| 1457 | 1626 | $sources = trim($data[28].' '.$data[29].' '.$data[30].' '.$data[31].' '.$data[32].' '.$data[33]); |
| 1458 | 1627 | $period = str_replace(',','',$data[14]); |
| 1459 | - if (!empty($period) && strpos($period,'days')) $period = str_replace(' days','',$period)*24*60; |
|
| 1460 | - if ($data[18] != '') $launch_date = date('Y-m-d',strtotime($data[18])); |
|
| 1461 | - else $launch_date = NULL; |
|
| 1628 | + if (!empty($period) && strpos($period,'days')) { |
|
| 1629 | + $period = str_replace(' days','',$period)*24*60; |
|
| 1630 | + } |
|
| 1631 | + if ($data[18] != '') { |
|
| 1632 | + $launch_date = date('Y-m-d',strtotime($data[18])); |
|
| 1633 | + } else { |
|
| 1634 | + $launch_date = NULL; |
|
| 1635 | + } |
|
| 1462 | 1636 | $data = array_map(function($value) { |
| 1463 | 1637 | return trim($value) === '' ? null : $value; |
| 1464 | 1638 | }, $data); |
@@ -1811,7 +1985,9 @@ discard block |
||
| 1811 | 1985 | if (($handle = fopen($filename, 'r')) !== FALSE) |
| 1812 | 1986 | { |
| 1813 | 1987 | $i = 0; |
| 1814 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1988 | + if ($globalTransaction) { |
|
| 1989 | + $Connection->db->beginTransaction(); |
|
| 1990 | + } |
|
| 1815 | 1991 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1816 | 1992 | { |
| 1817 | 1993 | $i++; |
@@ -1839,7 +2015,9 @@ discard block |
||
| 1839 | 2015 | } |
| 1840 | 2016 | } |
| 1841 | 2017 | fclose($handle); |
| 1842 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 2018 | + if ($globalTransaction) { |
|
| 2019 | + $Connection->db->commit(); |
|
| 2020 | + } |
|
| 1843 | 2021 | } |
| 1844 | 2022 | return ''; |
| 1845 | 2023 | } |
@@ -1862,7 +2040,9 @@ discard block |
||
| 1862 | 2040 | $Connection = new Connection(); |
| 1863 | 2041 | if (($handle = fopen($filename, 'r')) !== FALSE) |
| 1864 | 2042 | { |
| 1865 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 2043 | + if ($globalTransaction) { |
|
| 2044 | + $Connection->db->beginTransaction(); |
|
| 2045 | + } |
|
| 1866 | 2046 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1867 | 2047 | { |
| 1868 | 2048 | if(count($row) > 1) { |
@@ -1876,7 +2056,9 @@ discard block |
||
| 1876 | 2056 | } |
| 1877 | 2057 | } |
| 1878 | 2058 | fclose($handle); |
| 1879 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 2059 | + if ($globalTransaction) { |
|
| 2060 | + $Connection->db->commit(); |
|
| 2061 | + } |
|
| 1880 | 2062 | } |
| 1881 | 2063 | return ''; |
| 1882 | 2064 | } |
@@ -1896,8 +2078,9 @@ discard block |
||
| 1896 | 2078 | } |
| 1897 | 2079 | |
| 1898 | 2080 | |
| 1899 | - if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
| 1900 | - else { |
|
| 2081 | + if ($globalDBdriver == 'mysql') { |
|
| 2082 | + update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
| 2083 | + } else { |
|
| 1901 | 2084 | update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
| 1902 | 2085 | $query = "CREATE EXTENSION postgis"; |
| 1903 | 2086 | $Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']); |
@@ -1916,7 +2099,9 @@ discard block |
||
| 1916 | 2099 | global $tmp_dir, $globalDebug; |
| 1917 | 2100 | include_once('class.create_db.php'); |
| 1918 | 2101 | require_once(dirname(__FILE__).'/../require/class.NOTAM.php'); |
| 1919 | - if ($globalDebug) echo "NOTAM from FlightAirMap website : Download..."; |
|
| 2102 | + if ($globalDebug) { |
|
| 2103 | + echo "NOTAM from FlightAirMap website : Download..."; |
|
| 2104 | + } |
|
| 1920 | 2105 | update_db::download('http://data.flightairmap.com/data/notam.txt.gz.md5',$tmp_dir.'notam.txt.gz.md5'); |
| 1921 | 2106 | $error = ''; |
| 1922 | 2107 | if (file_exists($tmp_dir.'notam.txt.gz.md5')) { |
@@ -1926,20 +2111,34 @@ discard block |
||
| 1926 | 2111 | update_db::download('http://data.flightairmap.com/data/notam.txt.gz',$tmp_dir.'notam.txt.gz'); |
| 1927 | 2112 | if (file_exists($tmp_dir.'notam.txt.gz')) { |
| 1928 | 2113 | if (md5_file($tmp_dir.'notam.txt.gz') == $notam_md5) { |
| 1929 | - if ($globalDebug) echo "Gunzip..."; |
|
| 2114 | + if ($globalDebug) { |
|
| 2115 | + echo "Gunzip..."; |
|
| 2116 | + } |
|
| 1930 | 2117 | update_db::gunzip($tmp_dir.'notam.txt.gz'); |
| 1931 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2118 | + if ($globalDebug) { |
|
| 2119 | + echo "Add to DB..."; |
|
| 2120 | + } |
|
| 1932 | 2121 | //$error = create_db::import_file($tmp_dir.'notam.sql'); |
| 1933 | 2122 | $NOTAM = new NOTAM(); |
| 1934 | 2123 | $NOTAM->updateNOTAMfromTextFile($tmp_dir.'notam.txt'); |
| 1935 | 2124 | update_db::insert_notam_version($notam_md5); |
| 1936 | - } else $error = "File ".$tmp_dir.'notam.txt.gz'." md5 failed. Download failed."; |
|
| 1937 | - } else $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed."; |
|
| 1938 | - } elseif ($globalDebug) echo "No new version."; |
|
| 1939 | - } else $error = "File ".$tmp_dir.'notam.txt.gz.md5'." doesn't exist. Download failed."; |
|
| 2125 | + } else { |
|
| 2126 | + $error = "File ".$tmp_dir.'notam.txt.gz'." md5 failed. Download failed."; |
|
| 2127 | + } |
|
| 2128 | + } else { |
|
| 2129 | + $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed."; |
|
| 2130 | + } |
|
| 2131 | + } elseif ($globalDebug) { |
|
| 2132 | + echo "No new version."; |
|
| 2133 | + } |
|
| 2134 | + } else { |
|
| 2135 | + $error = "File ".$tmp_dir.'notam.txt.gz.md5'." doesn't exist. Download failed."; |
|
| 2136 | + } |
|
| 1940 | 2137 | if ($error != '') { |
| 1941 | 2138 | return $error; |
| 1942 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2139 | + } elseif ($globalDebug) { |
|
| 2140 | + echo "Done\n"; |
|
| 2141 | + } |
|
| 1943 | 2142 | return ''; |
| 1944 | 2143 | } |
| 1945 | 2144 | |
@@ -1994,68 +2193,114 @@ discard block |
||
| 1994 | 2193 | //update_db::download('http://fr.mirror.ivao.aero/software/ivae_feb2013.zip',$tmp_dir.'ivae_feb2013.zip'); |
| 1995 | 2194 | if (extension_loaded('zip')) { |
| 1996 | 2195 | if (file_exists($tmp_dir.'ivae_feb2013.zip')) { |
| 1997 | - if ($globalDebug) echo "Unzip..."; |
|
| 2196 | + if ($globalDebug) { |
|
| 2197 | + echo "Unzip..."; |
|
| 2198 | + } |
|
| 1998 | 2199 | update_db::unzip($tmp_dir.'ivae_feb2013.zip'); |
| 1999 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2200 | + if ($globalDebug) { |
|
| 2201 | + echo "Add to DB..."; |
|
| 2202 | + } |
|
| 2000 | 2203 | update_db::ivao_airlines($tmp_dir.'data/airlines.dat'); |
| 2001 | - if ($globalDebug) echo "Copy airlines logos to airlines images directory..."; |
|
| 2204 | + if ($globalDebug) { |
|
| 2205 | + echo "Copy airlines logos to airlines images directory..."; |
|
| 2206 | + } |
|
| 2002 | 2207 | if (is_writable(dirname(__FILE__).'/../images/airlines')) { |
| 2003 | - if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
| 2004 | - } else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
|
| 2005 | - } else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
|
| 2006 | - } else $error = "ZIP module not loaded but required for IVAO."; |
|
| 2208 | + if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) { |
|
| 2209 | + $error = "Failed to copy airlines logo."; |
|
| 2210 | + } |
|
| 2211 | + } else { |
|
| 2212 | + $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
|
| 2213 | + } |
|
| 2214 | + } else { |
|
| 2215 | + $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
|
| 2216 | + } |
|
| 2217 | + } else { |
|
| 2218 | + $error = "ZIP module not loaded but required for IVAO."; |
|
| 2219 | + } |
|
| 2007 | 2220 | if ($error != '') { |
| 2008 | 2221 | return $error; |
| 2009 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2222 | + } elseif ($globalDebug) { |
|
| 2223 | + echo "Done\n"; |
|
| 2224 | + } |
|
| 2010 | 2225 | return ''; |
| 2011 | 2226 | } |
| 2012 | 2227 | |
| 2013 | 2228 | public static function update_routes() { |
| 2014 | 2229 | global $tmp_dir, $globalDebug; |
| 2015 | 2230 | $error = ''; |
| 2016 | - if ($globalDebug) echo "Routes : Download..."; |
|
| 2231 | + if ($globalDebug) { |
|
| 2232 | + echo "Routes : Download..."; |
|
| 2233 | + } |
|
| 2017 | 2234 | update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz'); |
| 2018 | 2235 | if (file_exists($tmp_dir.'StandingData.sqb.gz')) { |
| 2019 | - if ($globalDebug) echo "Gunzip..."; |
|
| 2236 | + if ($globalDebug) { |
|
| 2237 | + echo "Gunzip..."; |
|
| 2238 | + } |
|
| 2020 | 2239 | update_db::gunzip($tmp_dir.'StandingData.sqb.gz'); |
| 2021 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2240 | + if ($globalDebug) { |
|
| 2241 | + echo "Add to DB..."; |
|
| 2242 | + } |
|
| 2022 | 2243 | $error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb'); |
| 2023 | - } else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed."; |
|
| 2244 | + } else { |
|
| 2245 | + $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed."; |
|
| 2246 | + } |
|
| 2024 | 2247 | if ($error != '') { |
| 2025 | 2248 | return $error; |
| 2026 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2249 | + } elseif ($globalDebug) { |
|
| 2250 | + echo "Done\n"; |
|
| 2251 | + } |
|
| 2027 | 2252 | return ''; |
| 2028 | 2253 | } |
| 2029 | 2254 | public static function update_oneworld() { |
| 2030 | 2255 | global $tmp_dir, $globalDebug; |
| 2031 | 2256 | $error = ''; |
| 2032 | - if ($globalDebug) echo "Schedules Oneworld : Download..."; |
|
| 2257 | + if ($globalDebug) { |
|
| 2258 | + echo "Schedules Oneworld : Download..."; |
|
| 2259 | + } |
|
| 2033 | 2260 | update_db::download('http://data.flightairmap.com/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz'); |
| 2034 | 2261 | if (file_exists($tmp_dir.'oneworld.csv.gz')) { |
| 2035 | - if ($globalDebug) echo "Gunzip..."; |
|
| 2262 | + if ($globalDebug) { |
|
| 2263 | + echo "Gunzip..."; |
|
| 2264 | + } |
|
| 2036 | 2265 | update_db::gunzip($tmp_dir.'oneworld.csv.gz'); |
| 2037 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2266 | + if ($globalDebug) { |
|
| 2267 | + echo "Add to DB..."; |
|
| 2268 | + } |
|
| 2038 | 2269 | $error = update_db::retrieve_route_oneworld($tmp_dir.'oneworld.csv'); |
| 2039 | - } else $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed."; |
|
| 2270 | + } else { |
|
| 2271 | + $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed."; |
|
| 2272 | + } |
|
| 2040 | 2273 | if ($error != '') { |
| 2041 | 2274 | return $error; |
| 2042 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2275 | + } elseif ($globalDebug) { |
|
| 2276 | + echo "Done\n"; |
|
| 2277 | + } |
|
| 2043 | 2278 | return ''; |
| 2044 | 2279 | } |
| 2045 | 2280 | public static function update_skyteam() { |
| 2046 | 2281 | global $tmp_dir, $globalDebug; |
| 2047 | 2282 | $error = ''; |
| 2048 | - if ($globalDebug) echo "Schedules Skyteam : Download..."; |
|
| 2283 | + if ($globalDebug) { |
|
| 2284 | + echo "Schedules Skyteam : Download..."; |
|
| 2285 | + } |
|
| 2049 | 2286 | update_db::download('http://data.flightairmap.com/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz'); |
| 2050 | 2287 | if (file_exists($tmp_dir.'skyteam.csv.gz')) { |
| 2051 | - if ($globalDebug) echo "Gunzip..."; |
|
| 2288 | + if ($globalDebug) { |
|
| 2289 | + echo "Gunzip..."; |
|
| 2290 | + } |
|
| 2052 | 2291 | update_db::gunzip($tmp_dir.'skyteam.csv.gz'); |
| 2053 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2292 | + if ($globalDebug) { |
|
| 2293 | + echo "Add to DB..."; |
|
| 2294 | + } |
|
| 2054 | 2295 | $error = update_db::retrieve_route_skyteam($tmp_dir.'skyteam.csv'); |
| 2055 | - } else $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed."; |
|
| 2296 | + } else { |
|
| 2297 | + $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed."; |
|
| 2298 | + } |
|
| 2056 | 2299 | if ($error != '') { |
| 2057 | 2300 | return $error; |
| 2058 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2301 | + } elseif ($globalDebug) { |
|
| 2302 | + echo "Done\n"; |
|
| 2303 | + } |
|
| 2059 | 2304 | return ''; |
| 2060 | 2305 | } |
| 2061 | 2306 | public static function update_ModeS() { |
@@ -2072,337 +2317,587 @@ discard block |
||
| 2072 | 2317 | exit; |
| 2073 | 2318 | } elseif ($globalDebug) echo "Done\n"; |
| 2074 | 2319 | */ |
| 2075 | - if ($globalDebug) echo "Modes : Download..."; |
|
| 2076 | -// update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
|
| 2320 | + if ($globalDebug) { |
|
| 2321 | + echo "Modes : Download..."; |
|
| 2322 | + } |
|
| 2323 | + // update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
|
| 2077 | 2324 | update_db::download('http://data.flightairmap.com/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz'); |
| 2078 | 2325 | |
| 2079 | 2326 | // if (file_exists($tmp_dir.'basestation_latest.zip')) { |
| 2080 | 2327 | if (file_exists($tmp_dir.'BaseStation.sqb.gz')) { |
| 2081 | - if ($globalDebug) echo "Unzip..."; |
|
| 2082 | -// update_db::unzip($tmp_dir.'basestation_latest.zip'); |
|
| 2328 | + if ($globalDebug) { |
|
| 2329 | + echo "Unzip..."; |
|
| 2330 | + } |
|
| 2331 | + // update_db::unzip($tmp_dir.'basestation_latest.zip'); |
|
| 2083 | 2332 | update_db::gunzip($tmp_dir.'BaseStation.sqb.gz'); |
| 2084 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2333 | + if ($globalDebug) { |
|
| 2334 | + echo "Add to DB..."; |
|
| 2335 | + } |
|
| 2085 | 2336 | $error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb'); |
| 2086 | 2337 | // $error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'basestation.sqb'); |
| 2087 | - } else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed."; |
|
| 2338 | + } else { |
|
| 2339 | + $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed."; |
|
| 2340 | + } |
|
| 2088 | 2341 | if ($error != '') { |
| 2089 | 2342 | return $error; |
| 2090 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2343 | + } elseif ($globalDebug) { |
|
| 2344 | + echo "Done\n"; |
|
| 2345 | + } |
|
| 2091 | 2346 | return ''; |
| 2092 | 2347 | } |
| 2093 | 2348 | |
| 2094 | 2349 | public static function update_ModeS_faa() { |
| 2095 | 2350 | global $tmp_dir, $globalDebug; |
| 2096 | - if ($globalDebug) echo "Modes FAA: Download..."; |
|
| 2351 | + if ($globalDebug) { |
|
| 2352 | + echo "Modes FAA: Download..."; |
|
| 2353 | + } |
|
| 2097 | 2354 | update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip'); |
| 2098 | 2355 | if (file_exists($tmp_dir.'ReleasableAircraft.zip')) { |
| 2099 | - if ($globalDebug) echo "Unzip..."; |
|
| 2356 | + if ($globalDebug) { |
|
| 2357 | + echo "Unzip..."; |
|
| 2358 | + } |
|
| 2100 | 2359 | update_db::unzip($tmp_dir.'ReleasableAircraft.zip'); |
| 2101 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2360 | + if ($globalDebug) { |
|
| 2361 | + echo "Add to DB..."; |
|
| 2362 | + } |
|
| 2102 | 2363 | $error = update_db::modes_faa(); |
| 2103 | - } else $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed."; |
|
| 2364 | + } else { |
|
| 2365 | + $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed."; |
|
| 2366 | + } |
|
| 2104 | 2367 | if ($error != '') { |
| 2105 | 2368 | return $error; |
| 2106 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2369 | + } elseif ($globalDebug) { |
|
| 2370 | + echo "Done\n"; |
|
| 2371 | + } |
|
| 2107 | 2372 | return ''; |
| 2108 | 2373 | } |
| 2109 | 2374 | |
| 2110 | 2375 | public static function update_ModeS_flarm() { |
| 2111 | 2376 | global $tmp_dir, $globalDebug; |
| 2112 | - if ($globalDebug) echo "Modes Flarmnet: Download..."; |
|
| 2377 | + if ($globalDebug) { |
|
| 2378 | + echo "Modes Flarmnet: Download..."; |
|
| 2379 | + } |
|
| 2113 | 2380 | update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln'); |
| 2114 | 2381 | if (file_exists($tmp_dir.'data.fln')) { |
| 2115 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2382 | + if ($globalDebug) { |
|
| 2383 | + echo "Add to DB..."; |
|
| 2384 | + } |
|
| 2116 | 2385 | $error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln'); |
| 2117 | - } else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed."; |
|
| 2386 | + } else { |
|
| 2387 | + $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed."; |
|
| 2388 | + } |
|
| 2118 | 2389 | if ($error != '') { |
| 2119 | 2390 | return $error; |
| 2120 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2391 | + } elseif ($globalDebug) { |
|
| 2392 | + echo "Done\n"; |
|
| 2393 | + } |
|
| 2121 | 2394 | return ''; |
| 2122 | 2395 | } |
| 2123 | 2396 | |
| 2124 | 2397 | public static function update_ModeS_ogn() { |
| 2125 | 2398 | global $tmp_dir, $globalDebug; |
| 2126 | - if ($globalDebug) echo "Modes OGN: Download..."; |
|
| 2399 | + if ($globalDebug) { |
|
| 2400 | + echo "Modes OGN: Download..."; |
|
| 2401 | + } |
|
| 2127 | 2402 | update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv'); |
| 2128 | 2403 | if (file_exists($tmp_dir.'ogn.csv')) { |
| 2129 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2404 | + if ($globalDebug) { |
|
| 2405 | + echo "Add to DB..."; |
|
| 2406 | + } |
|
| 2130 | 2407 | $error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv'); |
| 2131 | - } else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed."; |
|
| 2408 | + } else { |
|
| 2409 | + $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed."; |
|
| 2410 | + } |
|
| 2132 | 2411 | if ($error != '') { |
| 2133 | 2412 | return $error; |
| 2134 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2413 | + } elseif ($globalDebug) { |
|
| 2414 | + echo "Done\n"; |
|
| 2415 | + } |
|
| 2135 | 2416 | return ''; |
| 2136 | 2417 | } |
| 2137 | 2418 | |
| 2138 | 2419 | public static function update_owner() { |
| 2139 | 2420 | global $tmp_dir, $globalDebug, $globalMasterSource; |
| 2140 | 2421 | |
| 2141 | - if ($globalDebug) echo "Owner France: Download..."; |
|
| 2422 | + if ($globalDebug) { |
|
| 2423 | + echo "Owner France: Download..."; |
|
| 2424 | + } |
|
| 2142 | 2425 | update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv'); |
| 2143 | 2426 | if (file_exists($tmp_dir.'owner_f.csv')) { |
| 2144 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2427 | + if ($globalDebug) { |
|
| 2428 | + echo "Add to DB..."; |
|
| 2429 | + } |
|
| 2145 | 2430 | $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F'); |
| 2146 | - } else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
|
| 2431 | + } else { |
|
| 2432 | + $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
|
| 2433 | + } |
|
| 2147 | 2434 | if ($error != '') { |
| 2148 | 2435 | return $error; |
| 2149 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2436 | + } elseif ($globalDebug) { |
|
| 2437 | + echo "Done\n"; |
|
| 2438 | + } |
|
| 2150 | 2439 | |
| 2151 | - if ($globalDebug) echo "Owner Ireland: Download..."; |
|
| 2440 | + if ($globalDebug) { |
|
| 2441 | + echo "Owner Ireland: Download..."; |
|
| 2442 | + } |
|
| 2152 | 2443 | update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv'); |
| 2153 | 2444 | if (file_exists($tmp_dir.'owner_ei.csv')) { |
| 2154 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2445 | + if ($globalDebug) { |
|
| 2446 | + echo "Add to DB..."; |
|
| 2447 | + } |
|
| 2155 | 2448 | $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI'); |
| 2156 | - } else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
|
| 2449 | + } else { |
|
| 2450 | + $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
|
| 2451 | + } |
|
| 2157 | 2452 | if ($error != '') { |
| 2158 | 2453 | return $error; |
| 2159 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2160 | - if ($globalDebug) echo "Owner Switzerland: Download..."; |
|
| 2454 | + } elseif ($globalDebug) { |
|
| 2455 | + echo "Done\n"; |
|
| 2456 | + } |
|
| 2457 | + if ($globalDebug) { |
|
| 2458 | + echo "Owner Switzerland: Download..."; |
|
| 2459 | + } |
|
| 2161 | 2460 | update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv'); |
| 2162 | 2461 | if (file_exists($tmp_dir.'owner_hb.csv')) { |
| 2163 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2462 | + if ($globalDebug) { |
|
| 2463 | + echo "Add to DB..."; |
|
| 2464 | + } |
|
| 2164 | 2465 | $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB'); |
| 2165 | - } else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
|
| 2466 | + } else { |
|
| 2467 | + $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
|
| 2468 | + } |
|
| 2166 | 2469 | if ($error != '') { |
| 2167 | 2470 | return $error; |
| 2168 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2169 | - if ($globalDebug) echo "Owner Czech Republic: Download..."; |
|
| 2471 | + } elseif ($globalDebug) { |
|
| 2472 | + echo "Done\n"; |
|
| 2473 | + } |
|
| 2474 | + if ($globalDebug) { |
|
| 2475 | + echo "Owner Czech Republic: Download..."; |
|
| 2476 | + } |
|
| 2170 | 2477 | update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv'); |
| 2171 | 2478 | if (file_exists($tmp_dir.'owner_ok.csv')) { |
| 2172 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2479 | + if ($globalDebug) { |
|
| 2480 | + echo "Add to DB..."; |
|
| 2481 | + } |
|
| 2173 | 2482 | $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK'); |
| 2174 | - } else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
|
| 2483 | + } else { |
|
| 2484 | + $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
|
| 2485 | + } |
|
| 2175 | 2486 | if ($error != '') { |
| 2176 | 2487 | return $error; |
| 2177 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2178 | - if ($globalDebug) echo "Owner Australia: Download..."; |
|
| 2488 | + } elseif ($globalDebug) { |
|
| 2489 | + echo "Done\n"; |
|
| 2490 | + } |
|
| 2491 | + if ($globalDebug) { |
|
| 2492 | + echo "Owner Australia: Download..."; |
|
| 2493 | + } |
|
| 2179 | 2494 | update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv'); |
| 2180 | 2495 | if (file_exists($tmp_dir.'owner_vh.csv')) { |
| 2181 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2496 | + if ($globalDebug) { |
|
| 2497 | + echo "Add to DB..."; |
|
| 2498 | + } |
|
| 2182 | 2499 | $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH'); |
| 2183 | - } else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
|
| 2500 | + } else { |
|
| 2501 | + $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
|
| 2502 | + } |
|
| 2184 | 2503 | if ($error != '') { |
| 2185 | 2504 | return $error; |
| 2186 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2187 | - if ($globalDebug) echo "Owner Austria: Download..."; |
|
| 2505 | + } elseif ($globalDebug) { |
|
| 2506 | + echo "Done\n"; |
|
| 2507 | + } |
|
| 2508 | + if ($globalDebug) { |
|
| 2509 | + echo "Owner Austria: Download..."; |
|
| 2510 | + } |
|
| 2188 | 2511 | update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv'); |
| 2189 | 2512 | if (file_exists($tmp_dir.'owner_oe.csv')) { |
| 2190 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2513 | + if ($globalDebug) { |
|
| 2514 | + echo "Add to DB..."; |
|
| 2515 | + } |
|
| 2191 | 2516 | $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE'); |
| 2192 | - } else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
|
| 2517 | + } else { |
|
| 2518 | + $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
|
| 2519 | + } |
|
| 2193 | 2520 | if ($error != '') { |
| 2194 | 2521 | return $error; |
| 2195 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2196 | - if ($globalDebug) echo "Owner Chile: Download..."; |
|
| 2522 | + } elseif ($globalDebug) { |
|
| 2523 | + echo "Done\n"; |
|
| 2524 | + } |
|
| 2525 | + if ($globalDebug) { |
|
| 2526 | + echo "Owner Chile: Download..."; |
|
| 2527 | + } |
|
| 2197 | 2528 | update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv'); |
| 2198 | 2529 | if (file_exists($tmp_dir.'owner_cc.csv')) { |
| 2199 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2530 | + if ($globalDebug) { |
|
| 2531 | + echo "Add to DB..."; |
|
| 2532 | + } |
|
| 2200 | 2533 | $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC'); |
| 2201 | - } else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
|
| 2534 | + } else { |
|
| 2535 | + $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
|
| 2536 | + } |
|
| 2202 | 2537 | if ($error != '') { |
| 2203 | 2538 | return $error; |
| 2204 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2205 | - if ($globalDebug) echo "Owner Colombia: Download..."; |
|
| 2539 | + } elseif ($globalDebug) { |
|
| 2540 | + echo "Done\n"; |
|
| 2541 | + } |
|
| 2542 | + if ($globalDebug) { |
|
| 2543 | + echo "Owner Colombia: Download..."; |
|
| 2544 | + } |
|
| 2206 | 2545 | update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv'); |
| 2207 | 2546 | if (file_exists($tmp_dir.'owner_hj.csv')) { |
| 2208 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2547 | + if ($globalDebug) { |
|
| 2548 | + echo "Add to DB..."; |
|
| 2549 | + } |
|
| 2209 | 2550 | $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ'); |
| 2210 | - } else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
|
| 2551 | + } else { |
|
| 2552 | + $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
|
| 2553 | + } |
|
| 2211 | 2554 | if ($error != '') { |
| 2212 | 2555 | return $error; |
| 2213 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2214 | - if ($globalDebug) echo "Owner Bosnia Herzegobina: Download..."; |
|
| 2556 | + } elseif ($globalDebug) { |
|
| 2557 | + echo "Done\n"; |
|
| 2558 | + } |
|
| 2559 | + if ($globalDebug) { |
|
| 2560 | + echo "Owner Bosnia Herzegobina: Download..."; |
|
| 2561 | + } |
|
| 2215 | 2562 | update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv'); |
| 2216 | 2563 | if (file_exists($tmp_dir.'owner_e7.csv')) { |
| 2217 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2564 | + if ($globalDebug) { |
|
| 2565 | + echo "Add to DB..."; |
|
| 2566 | + } |
|
| 2218 | 2567 | $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7'); |
| 2219 | - } else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
|
| 2568 | + } else { |
|
| 2569 | + $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
|
| 2570 | + } |
|
| 2220 | 2571 | if ($error != '') { |
| 2221 | 2572 | return $error; |
| 2222 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2223 | - if ($globalDebug) echo "Owner Brazil: Download..."; |
|
| 2573 | + } elseif ($globalDebug) { |
|
| 2574 | + echo "Done\n"; |
|
| 2575 | + } |
|
| 2576 | + if ($globalDebug) { |
|
| 2577 | + echo "Owner Brazil: Download..."; |
|
| 2578 | + } |
|
| 2224 | 2579 | update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv'); |
| 2225 | 2580 | if (file_exists($tmp_dir.'owner_pp.csv')) { |
| 2226 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2581 | + if ($globalDebug) { |
|
| 2582 | + echo "Add to DB..."; |
|
| 2583 | + } |
|
| 2227 | 2584 | $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP'); |
| 2228 | - } else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
|
| 2585 | + } else { |
|
| 2586 | + $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
|
| 2587 | + } |
|
| 2229 | 2588 | if ($error != '') { |
| 2230 | 2589 | return $error; |
| 2231 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2232 | - if ($globalDebug) echo "Owner Cayman Islands: Download..."; |
|
| 2590 | + } elseif ($globalDebug) { |
|
| 2591 | + echo "Done\n"; |
|
| 2592 | + } |
|
| 2593 | + if ($globalDebug) { |
|
| 2594 | + echo "Owner Cayman Islands: Download..."; |
|
| 2595 | + } |
|
| 2233 | 2596 | update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv'); |
| 2234 | 2597 | if (file_exists($tmp_dir.'owner_vp.csv')) { |
| 2235 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2598 | + if ($globalDebug) { |
|
| 2599 | + echo "Add to DB..."; |
|
| 2600 | + } |
|
| 2236 | 2601 | $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP'); |
| 2237 | - } else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
|
| 2602 | + } else { |
|
| 2603 | + $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
|
| 2604 | + } |
|
| 2238 | 2605 | if ($error != '') { |
| 2239 | 2606 | return $error; |
| 2240 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2241 | - if ($globalDebug) echo "Owner Croatia: Download..."; |
|
| 2607 | + } elseif ($globalDebug) { |
|
| 2608 | + echo "Done\n"; |
|
| 2609 | + } |
|
| 2610 | + if ($globalDebug) { |
|
| 2611 | + echo "Owner Croatia: Download..."; |
|
| 2612 | + } |
|
| 2242 | 2613 | update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv'); |
| 2243 | 2614 | if (file_exists($tmp_dir.'owner_9a.csv')) { |
| 2244 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2615 | + if ($globalDebug) { |
|
| 2616 | + echo "Add to DB..."; |
|
| 2617 | + } |
|
| 2245 | 2618 | $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A'); |
| 2246 | - } else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
|
| 2619 | + } else { |
|
| 2620 | + $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
|
| 2621 | + } |
|
| 2247 | 2622 | if ($error != '') { |
| 2248 | 2623 | return $error; |
| 2249 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2250 | - if ($globalDebug) echo "Owner Luxembourg: Download..."; |
|
| 2624 | + } elseif ($globalDebug) { |
|
| 2625 | + echo "Done\n"; |
|
| 2626 | + } |
|
| 2627 | + if ($globalDebug) { |
|
| 2628 | + echo "Owner Luxembourg: Download..."; |
|
| 2629 | + } |
|
| 2251 | 2630 | update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv'); |
| 2252 | 2631 | if (file_exists($tmp_dir.'owner_lx.csv')) { |
| 2253 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2632 | + if ($globalDebug) { |
|
| 2633 | + echo "Add to DB..."; |
|
| 2634 | + } |
|
| 2254 | 2635 | $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX'); |
| 2255 | - } else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
|
| 2636 | + } else { |
|
| 2637 | + $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
|
| 2638 | + } |
|
| 2256 | 2639 | if ($error != '') { |
| 2257 | 2640 | return $error; |
| 2258 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2259 | - if ($globalDebug) echo "Owner Maldives: Download..."; |
|
| 2641 | + } elseif ($globalDebug) { |
|
| 2642 | + echo "Done\n"; |
|
| 2643 | + } |
|
| 2644 | + if ($globalDebug) { |
|
| 2645 | + echo "Owner Maldives: Download..."; |
|
| 2646 | + } |
|
| 2260 | 2647 | update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv'); |
| 2261 | 2648 | if (file_exists($tmp_dir.'owner_8q.csv')) { |
| 2262 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2649 | + if ($globalDebug) { |
|
| 2650 | + echo "Add to DB..."; |
|
| 2651 | + } |
|
| 2263 | 2652 | $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q'); |
| 2264 | - } else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
|
| 2653 | + } else { |
|
| 2654 | + $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
|
| 2655 | + } |
|
| 2265 | 2656 | if ($error != '') { |
| 2266 | 2657 | return $error; |
| 2267 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2268 | - if ($globalDebug) echo "Owner New Zealand: Download..."; |
|
| 2658 | + } elseif ($globalDebug) { |
|
| 2659 | + echo "Done\n"; |
|
| 2660 | + } |
|
| 2661 | + if ($globalDebug) { |
|
| 2662 | + echo "Owner New Zealand: Download..."; |
|
| 2663 | + } |
|
| 2269 | 2664 | update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv'); |
| 2270 | 2665 | if (file_exists($tmp_dir.'owner_zk.csv')) { |
| 2271 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2666 | + if ($globalDebug) { |
|
| 2667 | + echo "Add to DB..."; |
|
| 2668 | + } |
|
| 2272 | 2669 | $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK'); |
| 2273 | - } else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
|
| 2670 | + } else { |
|
| 2671 | + $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
|
| 2672 | + } |
|
| 2274 | 2673 | if ($error != '') { |
| 2275 | 2674 | return $error; |
| 2276 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2277 | - if ($globalDebug) echo "Owner Papua New Guinea: Download..."; |
|
| 2675 | + } elseif ($globalDebug) { |
|
| 2676 | + echo "Done\n"; |
|
| 2677 | + } |
|
| 2678 | + if ($globalDebug) { |
|
| 2679 | + echo "Owner Papua New Guinea: Download..."; |
|
| 2680 | + } |
|
| 2278 | 2681 | update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv'); |
| 2279 | 2682 | if (file_exists($tmp_dir.'owner_p2.csv')) { |
| 2280 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2683 | + if ($globalDebug) { |
|
| 2684 | + echo "Add to DB..."; |
|
| 2685 | + } |
|
| 2281 | 2686 | $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2'); |
| 2282 | - } else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
|
| 2687 | + } else { |
|
| 2688 | + $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
|
| 2689 | + } |
|
| 2283 | 2690 | if ($error != '') { |
| 2284 | 2691 | return $error; |
| 2285 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2286 | - if ($globalDebug) echo "Owner Slovakia: Download..."; |
|
| 2692 | + } elseif ($globalDebug) { |
|
| 2693 | + echo "Done\n"; |
|
| 2694 | + } |
|
| 2695 | + if ($globalDebug) { |
|
| 2696 | + echo "Owner Slovakia: Download..."; |
|
| 2697 | + } |
|
| 2287 | 2698 | update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv'); |
| 2288 | 2699 | if (file_exists($tmp_dir.'owner_om.csv')) { |
| 2289 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2700 | + if ($globalDebug) { |
|
| 2701 | + echo "Add to DB..."; |
|
| 2702 | + } |
|
| 2290 | 2703 | $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM'); |
| 2291 | - } else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
|
| 2704 | + } else { |
|
| 2705 | + $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
|
| 2706 | + } |
|
| 2292 | 2707 | if ($error != '') { |
| 2293 | 2708 | return $error; |
| 2294 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2295 | - if ($globalDebug) echo "Owner Ecuador: Download..."; |
|
| 2709 | + } elseif ($globalDebug) { |
|
| 2710 | + echo "Done\n"; |
|
| 2711 | + } |
|
| 2712 | + if ($globalDebug) { |
|
| 2713 | + echo "Owner Ecuador: Download..."; |
|
| 2714 | + } |
|
| 2296 | 2715 | update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv'); |
| 2297 | 2716 | if (file_exists($tmp_dir.'owner_hc.csv')) { |
| 2298 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2717 | + if ($globalDebug) { |
|
| 2718 | + echo "Add to DB..."; |
|
| 2719 | + } |
|
| 2299 | 2720 | $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC'); |
| 2300 | - } else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
|
| 2721 | + } else { |
|
| 2722 | + $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
|
| 2723 | + } |
|
| 2301 | 2724 | if ($error != '') { |
| 2302 | 2725 | return $error; |
| 2303 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2304 | - if ($globalDebug) echo "Owner Iceland: Download..."; |
|
| 2726 | + } elseif ($globalDebug) { |
|
| 2727 | + echo "Done\n"; |
|
| 2728 | + } |
|
| 2729 | + if ($globalDebug) { |
|
| 2730 | + echo "Owner Iceland: Download..."; |
|
| 2731 | + } |
|
| 2305 | 2732 | update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv'); |
| 2306 | 2733 | if (file_exists($tmp_dir.'owner_tf.csv')) { |
| 2307 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2734 | + if ($globalDebug) { |
|
| 2735 | + echo "Add to DB..."; |
|
| 2736 | + } |
|
| 2308 | 2737 | $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF'); |
| 2309 | - } else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
|
| 2738 | + } else { |
|
| 2739 | + $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
|
| 2740 | + } |
|
| 2310 | 2741 | if ($error != '') { |
| 2311 | 2742 | return $error; |
| 2312 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2313 | - if ($globalDebug) echo "Owner Isle of Man: Download..."; |
|
| 2743 | + } elseif ($globalDebug) { |
|
| 2744 | + echo "Done\n"; |
|
| 2745 | + } |
|
| 2746 | + if ($globalDebug) { |
|
| 2747 | + echo "Owner Isle of Man: Download..."; |
|
| 2748 | + } |
|
| 2314 | 2749 | update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv'); |
| 2315 | 2750 | if (file_exists($tmp_dir.'owner_m.csv')) { |
| 2316 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2751 | + if ($globalDebug) { |
|
| 2752 | + echo "Add to DB..."; |
|
| 2753 | + } |
|
| 2317 | 2754 | $error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M'); |
| 2318 | - } else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed."; |
|
| 2755 | + } else { |
|
| 2756 | + $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed."; |
|
| 2757 | + } |
|
| 2319 | 2758 | if ($error != '') { |
| 2320 | 2759 | return $error; |
| 2321 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2760 | + } elseif ($globalDebug) { |
|
| 2761 | + echo "Done\n"; |
|
| 2762 | + } |
|
| 2322 | 2763 | if ($globalMasterSource) { |
| 2323 | - if ($globalDebug) echo "ModeS Netherlands: Download..."; |
|
| 2764 | + if ($globalDebug) { |
|
| 2765 | + echo "ModeS Netherlands: Download..."; |
|
| 2766 | + } |
|
| 2324 | 2767 | update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv'); |
| 2325 | 2768 | if (file_exists($tmp_dir.'owner_ph.csv')) { |
| 2326 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2769 | + if ($globalDebug) { |
|
| 2770 | + echo "Add to DB..."; |
|
| 2771 | + } |
|
| 2327 | 2772 | $error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH'); |
| 2328 | - } else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed."; |
|
| 2773 | + } else { |
|
| 2774 | + $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed."; |
|
| 2775 | + } |
|
| 2329 | 2776 | if ($error != '') { |
| 2330 | 2777 | return $error; |
| 2331 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2332 | - if ($globalDebug) echo "ModeS Denmark: Download..."; |
|
| 2778 | + } elseif ($globalDebug) { |
|
| 2779 | + echo "Done\n"; |
|
| 2780 | + } |
|
| 2781 | + if ($globalDebug) { |
|
| 2782 | + echo "ModeS Denmark: Download..."; |
|
| 2783 | + } |
|
| 2333 | 2784 | update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv'); |
| 2334 | 2785 | if (file_exists($tmp_dir.'owner_oy.csv')) { |
| 2335 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2786 | + if ($globalDebug) { |
|
| 2787 | + echo "Add to DB..."; |
|
| 2788 | + } |
|
| 2336 | 2789 | $error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY'); |
| 2337 | - } else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed."; |
|
| 2790 | + } else { |
|
| 2791 | + $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed."; |
|
| 2792 | + } |
|
| 2338 | 2793 | if ($error != '') { |
| 2339 | 2794 | return $error; |
| 2340 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2341 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2795 | + } elseif ($globalDebug) { |
|
| 2796 | + echo "Done\n"; |
|
| 2797 | + } |
|
| 2798 | + } elseif ($globalDebug) { |
|
| 2799 | + echo "Done\n"; |
|
| 2800 | + } |
|
| 2342 | 2801 | return ''; |
| 2343 | 2802 | } |
| 2344 | 2803 | |
| 2345 | 2804 | public static function update_translation() { |
| 2346 | 2805 | global $tmp_dir, $globalDebug; |
| 2347 | 2806 | $error = ''; |
| 2348 | - if ($globalDebug) echo "Translation : Download..."; |
|
| 2807 | + if ($globalDebug) { |
|
| 2808 | + echo "Translation : Download..."; |
|
| 2809 | + } |
|
| 2349 | 2810 | update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip'); |
| 2350 | 2811 | if (file_exists($tmp_dir.'translation.zip')) { |
| 2351 | - if ($globalDebug) echo "Unzip..."; |
|
| 2812 | + if ($globalDebug) { |
|
| 2813 | + echo "Unzip..."; |
|
| 2814 | + } |
|
| 2352 | 2815 | update_db::unzip($tmp_dir.'translation.zip'); |
| 2353 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2816 | + if ($globalDebug) { |
|
| 2817 | + echo "Add to DB..."; |
|
| 2818 | + } |
|
| 2354 | 2819 | $error = update_db::translation(); |
| 2355 | - } else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed."; |
|
| 2820 | + } else { |
|
| 2821 | + $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed."; |
|
| 2822 | + } |
|
| 2356 | 2823 | if ($error != '') { |
| 2357 | 2824 | return $error; |
| 2358 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2825 | + } elseif ($globalDebug) { |
|
| 2826 | + echo "Done\n"; |
|
| 2827 | + } |
|
| 2359 | 2828 | return ''; |
| 2360 | 2829 | } |
| 2361 | 2830 | |
| 2362 | 2831 | public static function update_translation_fam() { |
| 2363 | 2832 | global $tmp_dir, $globalDebug; |
| 2364 | - if ($globalDebug) echo "Translation from FlightAirMap website : Download..."; |
|
| 2833 | + if ($globalDebug) { |
|
| 2834 | + echo "Translation from FlightAirMap website : Download..."; |
|
| 2835 | + } |
|
| 2365 | 2836 | update_db::download('http://data.flightairmap.com/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz'); |
| 2366 | 2837 | update_db::download('http://data.flightairmap.com/data/translation.tsv.gz.md5',$tmp_dir.'translation.tsv.gz.md5'); |
| 2367 | 2838 | if (file_exists($tmp_dir.'translation.tsv.gz') && file_exists($tmp_dir.'translation.tsv.gz')) { |
| 2368 | 2839 | $translation_md5_file = explode(' ',file_get_contents($tmp_dir.'translation.tsv.gz.md5')); |
| 2369 | 2840 | $translation_md5 = $translation_md5_file[0]; |
| 2370 | 2841 | if (md5_file($tmp_dir.'translation.tsv.gz') == $translation_md5) { |
| 2371 | - if ($globalDebug) echo "Gunzip..."; |
|
| 2842 | + if ($globalDebug) { |
|
| 2843 | + echo "Gunzip..."; |
|
| 2844 | + } |
|
| 2372 | 2845 | update_db::gunzip($tmp_dir.'translation.tsv.gz'); |
| 2373 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2846 | + if ($globalDebug) { |
|
| 2847 | + echo "Add to DB..."; |
|
| 2848 | + } |
|
| 2374 | 2849 | $error = update_db::translation_fam(); |
| 2375 | - } else $error = "File ".$tmp_dir.'translation.tsv.gz'." md5 failed. Download failed."; |
|
| 2376 | - } else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed."; |
|
| 2850 | + } else { |
|
| 2851 | + $error = "File ".$tmp_dir.'translation.tsv.gz'." md5 failed. Download failed."; |
|
| 2852 | + } |
|
| 2853 | + } else { |
|
| 2854 | + $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed."; |
|
| 2855 | + } |
|
| 2377 | 2856 | if ($error != '') { |
| 2378 | 2857 | return $error; |
| 2379 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2858 | + } elseif ($globalDebug) { |
|
| 2859 | + echo "Done\n"; |
|
| 2860 | + } |
|
| 2380 | 2861 | return ''; |
| 2381 | 2862 | } |
| 2382 | 2863 | public static function update_ModeS_fam() { |
| 2383 | 2864 | global $tmp_dir, $globalDebug; |
| 2384 | - if ($globalDebug) echo "ModeS from FlightAirMap website : Download..."; |
|
| 2865 | + if ($globalDebug) { |
|
| 2866 | + echo "ModeS from FlightAirMap website : Download..."; |
|
| 2867 | + } |
|
| 2385 | 2868 | update_db::download('http://data.flightairmap.com/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz'); |
| 2386 | 2869 | update_db::download('http://data.flightairmap.com/data/modes.tsv.gz.md5',$tmp_dir.'modes.tsv.gz.md5'); |
| 2387 | 2870 | if (file_exists($tmp_dir.'modes.tsv.gz') && file_exists($tmp_dir.'modes.tsv.gz.md5')) { |
| 2388 | 2871 | $modes_md5_file = explode(' ',file_get_contents($tmp_dir.'modes.tsv.gz.md5')); |
| 2389 | 2872 | $modes_md5 = $modes_md5_file[0]; |
| 2390 | 2873 | if (md5_file($tmp_dir.'modes.tsv.gz') == $modes_md5) { |
| 2391 | - if ($globalDebug) echo "Gunzip..."; |
|
| 2874 | + if ($globalDebug) { |
|
| 2875 | + echo "Gunzip..."; |
|
| 2876 | + } |
|
| 2392 | 2877 | update_db::gunzip($tmp_dir.'modes.tsv.gz'); |
| 2393 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2878 | + if ($globalDebug) { |
|
| 2879 | + echo "Add to DB..."; |
|
| 2880 | + } |
|
| 2394 | 2881 | $error = update_db::modes_fam(); |
| 2395 | - } else $error = "File ".$tmp_dir.'modes.tsv.gz'." md5 failed. Download failed."; |
|
| 2396 | - } else $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed."; |
|
| 2882 | + } else { |
|
| 2883 | + $error = "File ".$tmp_dir.'modes.tsv.gz'." md5 failed. Download failed."; |
|
| 2884 | + } |
|
| 2885 | + } else { |
|
| 2886 | + $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed."; |
|
| 2887 | + } |
|
| 2397 | 2888 | if ($error != '') { |
| 2398 | 2889 | return $error; |
| 2399 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2890 | + } elseif ($globalDebug) { |
|
| 2891 | + echo "Done\n"; |
|
| 2892 | + } |
|
| 2400 | 2893 | return ''; |
| 2401 | 2894 | } |
| 2402 | 2895 | |
| 2403 | 2896 | public static function update_airlines_fam() { |
| 2404 | 2897 | global $tmp_dir, $globalDebug; |
| 2405 | - if ($globalDebug) echo "Airlines from FlightAirMap website : Download..."; |
|
| 2898 | + if ($globalDebug) { |
|
| 2899 | + echo "Airlines from FlightAirMap website : Download..."; |
|
| 2900 | + } |
|
| 2406 | 2901 | update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz',$tmp_dir.'airlines.tsv.gz'); |
| 2407 | 2902 | if (file_exists($tmp_dir.'airlines.tsv.gz.md5')) { |
| 2408 | 2903 | $airlines_md5_file = explode(' ',file_get_contents($tmp_dir.'airlines.tsv.gz.md5')); |
@@ -2411,26 +2906,42 @@ discard block |
||
| 2411 | 2906 | update_db::download('http://data.flightairmap.com/data/airliness.tsv.gz.md5',$tmp_dir.'airlines.tsv.gz.md5'); |
| 2412 | 2907 | if (file_exists($tmp_dir.'airlines.tsv.gz')) { |
| 2413 | 2908 | if (md5_file($tmp_dir.'airlines.tsv.gz') == $airlines_md5) { |
| 2414 | - if ($globalDebug) echo "Gunzip..."; |
|
| 2909 | + if ($globalDebug) { |
|
| 2910 | + echo "Gunzip..."; |
|
| 2911 | + } |
|
| 2415 | 2912 | update_db::gunzip($tmp_dir.'airlines.tsv.gz'); |
| 2416 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2913 | + if ($globalDebug) { |
|
| 2914 | + echo "Add to DB..."; |
|
| 2915 | + } |
|
| 2417 | 2916 | $error = update_db::airlines_fam(); |
| 2418 | 2917 | update_db::insert_airlines_version($airlines_md5); |
| 2419 | - } else $error = "File ".$tmp_dir.'airlines.tsv.gz'." md5 failed. Download failed."; |
|
| 2420 | - } else $error = "File ".$tmp_dir.'airlines.tsv.gz'." doesn't exist. Download failed."; |
|
| 2421 | - } elseif ($globalDebug) echo "No update"; |
|
| 2422 | - } else $error = "File ".$tmp_dir.'airlines.tsv.gz.md5'." doesn't exist. Download failed."; |
|
| 2918 | + } else { |
|
| 2919 | + $error = "File ".$tmp_dir.'airlines.tsv.gz'." md5 failed. Download failed."; |
|
| 2920 | + } |
|
| 2921 | + } else { |
|
| 2922 | + $error = "File ".$tmp_dir.'airlines.tsv.gz'." doesn't exist. Download failed."; |
|
| 2923 | + } |
|
| 2924 | + } elseif ($globalDebug) { |
|
| 2925 | + echo "No update"; |
|
| 2926 | + } |
|
| 2927 | + } else { |
|
| 2928 | + $error = "File ".$tmp_dir.'airlines.tsv.gz.md5'." doesn't exist. Download failed."; |
|
| 2929 | + } |
|
| 2423 | 2930 | if ($error != '') { |
| 2424 | 2931 | return $error; |
| 2425 | 2932 | } else { |
| 2426 | - if ($globalDebug) echo "Done\n"; |
|
| 2933 | + if ($globalDebug) { |
|
| 2934 | + echo "Done\n"; |
|
| 2935 | + } |
|
| 2427 | 2936 | } |
| 2428 | 2937 | return ''; |
| 2429 | 2938 | } |
| 2430 | 2939 | |
| 2431 | 2940 | public static function update_owner_fam() { |
| 2432 | 2941 | global $tmp_dir, $globalDebug, $globalOwner; |
| 2433 | - if ($globalDebug) echo "owner from FlightAirMap website : Download..."; |
|
| 2942 | + if ($globalDebug) { |
|
| 2943 | + echo "owner from FlightAirMap website : Download..."; |
|
| 2944 | + } |
|
| 2434 | 2945 | if ($globalOwner === TRUE) { |
| 2435 | 2946 | update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz'); |
| 2436 | 2947 | update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz.md5',$tmp_dir.'owners.tsv.gz.md5'); |
@@ -2442,35 +2953,57 @@ discard block |
||
| 2442 | 2953 | $owners_md5_file = explode(' ',file_get_contents($tmp_dir.'owners.tsv.gz.md5')); |
| 2443 | 2954 | $owners_md5 = $owners_md5_file[0]; |
| 2444 | 2955 | if (md5_file($tmp_dir.'owners.tsv.gz') == $owners_md5) { |
| 2445 | - if ($globalDebug) echo "Gunzip..."; |
|
| 2956 | + if ($globalDebug) { |
|
| 2957 | + echo "Gunzip..."; |
|
| 2958 | + } |
|
| 2446 | 2959 | update_db::gunzip($tmp_dir.'owners.tsv.gz'); |
| 2447 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2960 | + if ($globalDebug) { |
|
| 2961 | + echo "Add to DB..."; |
|
| 2962 | + } |
|
| 2448 | 2963 | $error = update_db::owner_fam(); |
| 2449 | - } else $error = "File ".$tmp_dir.'owners.tsv.gz'." md5 failed. Download failed."; |
|
| 2450 | - } else $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed."; |
|
| 2964 | + } else { |
|
| 2965 | + $error = "File ".$tmp_dir.'owners.tsv.gz'." md5 failed. Download failed."; |
|
| 2966 | + } |
|
| 2967 | + } else { |
|
| 2968 | + $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed."; |
|
| 2969 | + } |
|
| 2451 | 2970 | if ($error != '') { |
| 2452 | 2971 | return $error; |
| 2453 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2972 | + } elseif ($globalDebug) { |
|
| 2973 | + echo "Done\n"; |
|
| 2974 | + } |
|
| 2454 | 2975 | return ''; |
| 2455 | 2976 | } |
| 2456 | 2977 | public static function update_routes_fam() { |
| 2457 | 2978 | global $tmp_dir, $globalDebug; |
| 2458 | - if ($globalDebug) echo "Routes from FlightAirMap website : Download..."; |
|
| 2979 | + if ($globalDebug) { |
|
| 2980 | + echo "Routes from FlightAirMap website : Download..."; |
|
| 2981 | + } |
|
| 2459 | 2982 | update_db::download('http://data.flightairmap.com/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz'); |
| 2460 | 2983 | update_db::download('http://data.flightairmap.com/data/routes.tsv.gz.md5',$tmp_dir.'routes.tsv.gz.md5'); |
| 2461 | 2984 | if (file_exists($tmp_dir.'routes.tsv.gz') && file_exists($tmp_dir.'routes.tsv.gz.md5')) { |
| 2462 | 2985 | $routes_md5_file = explode(' ',file_get_contents($tmp_dir.'routes.tsv.gz.md5')); |
| 2463 | 2986 | $routes_md5 = $routes_md5_file[0]; |
| 2464 | 2987 | if (md5_file($tmp_dir.'routes.tsv.gz') == $routes_md5) { |
| 2465 | - if ($globalDebug) echo "Gunzip..."; |
|
| 2988 | + if ($globalDebug) { |
|
| 2989 | + echo "Gunzip..."; |
|
| 2990 | + } |
|
| 2466 | 2991 | update_db::gunzip($tmp_dir.'routes.tsv.gz'); |
| 2467 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2992 | + if ($globalDebug) { |
|
| 2993 | + echo "Add to DB..."; |
|
| 2994 | + } |
|
| 2468 | 2995 | $error = update_db::routes_fam(); |
| 2469 | - } else $error = "File ".$tmp_dir.'routes.tsv.gz'." md5 failed. Download failed."; |
|
| 2470 | - } else $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed."; |
|
| 2996 | + } else { |
|
| 2997 | + $error = "File ".$tmp_dir.'routes.tsv.gz'." md5 failed. Download failed."; |
|
| 2998 | + } |
|
| 2999 | + } else { |
|
| 3000 | + $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed."; |
|
| 3001 | + } |
|
| 2471 | 3002 | if ($error != '') { |
| 2472 | 3003 | return $error; |
| 2473 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 3004 | + } elseif ($globalDebug) { |
|
| 3005 | + echo "Done\n"; |
|
| 3006 | + } |
|
| 2474 | 3007 | return ''; |
| 2475 | 3008 | } |
| 2476 | 3009 | public static function update_marine_identity_fam() { |
@@ -2480,21 +3013,33 @@ discard block |
||
| 2480 | 3013 | $marine_identity_md5_file = explode(' ',file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5')); |
| 2481 | 3014 | $marine_identity_md5 = $marine_identity_md5_file[0]; |
| 2482 | 3015 | if (!update_db::check_marine_identity_version($marine_identity_md5)) { |
| 2483 | - if ($globalDebug) echo "Marine identity from FlightAirMap website : Download..."; |
|
| 3016 | + if ($globalDebug) { |
|
| 3017 | + echo "Marine identity from FlightAirMap website : Download..."; |
|
| 3018 | + } |
|
| 2484 | 3019 | update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz',$tmp_dir.'marine_identity.tsv.gz'); |
| 2485 | 3020 | if (file_exists($tmp_dir.'marine_identity.tsv.gz')) { |
| 2486 | 3021 | if (md5_file($tmp_dir.'marine_identity.tsv.gz') == $marine_identity_md5) { |
| 2487 | - if ($globalDebug) echo "Gunzip..."; |
|
| 3022 | + if ($globalDebug) { |
|
| 3023 | + echo "Gunzip..."; |
|
| 3024 | + } |
|
| 2488 | 3025 | update_db::gunzip($tmp_dir.'marine_identity.tsv.gz'); |
| 2489 | - if ($globalDebug) echo "Add to DB..."; |
|
| 3026 | + if ($globalDebug) { |
|
| 3027 | + echo "Add to DB..."; |
|
| 3028 | + } |
|
| 2490 | 3029 | $error = update_db::marine_identity_fam(); |
| 2491 | - } else $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." md5 failed. Download failed."; |
|
| 2492 | - } else $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed."; |
|
| 3030 | + } else { |
|
| 3031 | + $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." md5 failed. Download failed."; |
|
| 3032 | + } |
|
| 3033 | + } else { |
|
| 3034 | + $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed."; |
|
| 3035 | + } |
|
| 2493 | 3036 | if ($error != '') { |
| 2494 | 3037 | return $error; |
| 2495 | 3038 | } else { |
| 2496 | 3039 | update_db::insert_marine_identity_version($marine_identity_md5); |
| 2497 | - if ($globalDebug) echo "Done\n"; |
|
| 3040 | + if ($globalDebug) { |
|
| 3041 | + echo "Done\n"; |
|
| 3042 | + } |
|
| 2498 | 3043 | } |
| 2499 | 3044 | } |
| 2500 | 3045 | } |
@@ -2508,21 +3053,33 @@ discard block |
||
| 2508 | 3053 | $satellite_md5_file = explode(' ',file_get_contents($tmp_dir.'satellite.tsv.gz.md5')); |
| 2509 | 3054 | $satellite_md5 = $satellite_md5_file[0]; |
| 2510 | 3055 | if (!update_db::check_satellite_version($satellite_md5)) { |
| 2511 | - if ($globalDebug) echo "Satellite from FlightAirMap website : Download..."; |
|
| 3056 | + if ($globalDebug) { |
|
| 3057 | + echo "Satellite from FlightAirMap website : Download..."; |
|
| 3058 | + } |
|
| 2512 | 3059 | update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz',$tmp_dir.'satellite.tsv.gz'); |
| 2513 | 3060 | if (file_exists($tmp_dir.'satellite.tsv.gz')) { |
| 2514 | 3061 | if (md5_file($tmp_dir.'satellite.tsv.gz') == $satellite_md5) { |
| 2515 | - if ($globalDebug) echo "Gunzip..."; |
|
| 3062 | + if ($globalDebug) { |
|
| 3063 | + echo "Gunzip..."; |
|
| 3064 | + } |
|
| 2516 | 3065 | update_db::gunzip($tmp_dir.'satellite.tsv.gz'); |
| 2517 | - if ($globalDebug) echo "Add to DB..."; |
|
| 3066 | + if ($globalDebug) { |
|
| 3067 | + echo "Add to DB..."; |
|
| 3068 | + } |
|
| 2518 | 3069 | $error = update_db::satellite_fam(); |
| 2519 | - } else $error = "File ".$tmp_dir.'satellite.tsv.gz'." md5 failed. Download failed."; |
|
| 2520 | - } else $error = "File ".$tmp_dir.'satellite.tsv.gz'." doesn't exist. Download failed."; |
|
| 3070 | + } else { |
|
| 3071 | + $error = "File ".$tmp_dir.'satellite.tsv.gz'." md5 failed. Download failed."; |
|
| 3072 | + } |
|
| 3073 | + } else { |
|
| 3074 | + $error = "File ".$tmp_dir.'satellite.tsv.gz'." doesn't exist. Download failed."; |
|
| 3075 | + } |
|
| 2521 | 3076 | if ($error != '') { |
| 2522 | 3077 | return $error; |
| 2523 | 3078 | } else { |
| 2524 | 3079 | update_db::insert_satellite_version($satellite_md5); |
| 2525 | - if ($globalDebug) echo "Done\n"; |
|
| 3080 | + if ($globalDebug) { |
|
| 3081 | + echo "Done\n"; |
|
| 3082 | + } |
|
| 2526 | 3083 | } |
| 2527 | 3084 | } |
| 2528 | 3085 | } |
@@ -2530,17 +3087,25 @@ discard block |
||
| 2530 | 3087 | } |
| 2531 | 3088 | public static function update_banned_fam() { |
| 2532 | 3089 | global $tmp_dir, $globalDebug; |
| 2533 | - if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download..."; |
|
| 3090 | + if ($globalDebug) { |
|
| 3091 | + echo "Banned airlines in Europe from FlightAirMap website : Download..."; |
|
| 3092 | + } |
|
| 2534 | 3093 | update_db::download('http://data.flightairmap.com/data/ban-eu.csv',$tmp_dir.'ban_eu.csv'); |
| 2535 | 3094 | if (file_exists($tmp_dir.'ban_eu.csv')) { |
| 2536 | 3095 | //if ($globalDebug) echo "Gunzip..."; |
| 2537 | 3096 | //update_db::gunzip($tmp_dir.'ban_ue.csv'); |
| 2538 | - if ($globalDebug) echo "Add to DB..."; |
|
| 3097 | + if ($globalDebug) { |
|
| 3098 | + echo "Add to DB..."; |
|
| 3099 | + } |
|
| 2539 | 3100 | $error = update_db::banned_fam(); |
| 2540 | - } else $error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed."; |
|
| 3101 | + } else { |
|
| 3102 | + $error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed."; |
|
| 3103 | + } |
|
| 2541 | 3104 | if ($error != '') { |
| 2542 | 3105 | return $error; |
| 2543 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 3106 | + } elseif ($globalDebug) { |
|
| 3107 | + echo "Done\n"; |
|
| 3108 | + } |
|
| 2544 | 3109 | return ''; |
| 2545 | 3110 | } |
| 2546 | 3111 | |
@@ -2548,7 +3113,9 @@ discard block |
||
| 2548 | 3113 | global $tmp_dir, $globalDebug, $globalDBdriver; |
| 2549 | 3114 | include_once('class.create_db.php'); |
| 2550 | 3115 | $error = ''; |
| 2551 | - if ($globalDebug) echo "Airspace from FlightAirMap website : Download..."; |
|
| 3116 | + if ($globalDebug) { |
|
| 3117 | + echo "Airspace from FlightAirMap website : Download..."; |
|
| 3118 | + } |
|
| 2552 | 3119 | if ($globalDBdriver == 'mysql') { |
| 2553 | 3120 | update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); |
| 2554 | 3121 | } else { |
@@ -2565,9 +3132,13 @@ discard block |
||
| 2565 | 3132 | } |
| 2566 | 3133 | if (file_exists($tmp_dir.'airspace.sql.gz')) { |
| 2567 | 3134 | if (md5_file($tmp_dir.'airspace.sql.gz') == $airspace_md5) { |
| 2568 | - if ($globalDebug) echo "Gunzip..."; |
|
| 3135 | + if ($globalDebug) { |
|
| 3136 | + echo "Gunzip..."; |
|
| 3137 | + } |
|
| 2569 | 3138 | update_db::gunzip($tmp_dir.'airspace.sql.gz'); |
| 2570 | - if ($globalDebug) echo "Add to DB..."; |
|
| 3139 | + if ($globalDebug) { |
|
| 3140 | + echo "Add to DB..."; |
|
| 3141 | + } |
|
| 2571 | 3142 | $Connection = new Connection(); |
| 2572 | 3143 | if ($Connection->tableExists('airspace')) { |
| 2573 | 3144 | $query = 'DROP TABLE airspace'; |
@@ -2580,20 +3151,30 @@ discard block |
||
| 2580 | 3151 | } |
| 2581 | 3152 | $error = create_db::import_file($tmp_dir.'airspace.sql'); |
| 2582 | 3153 | update_db::insert_airspace_version($airspace_md5); |
| 2583 | - } else $error = "File ".$tmp_dir.'airspace.sql.gz'." md5 failed. Download failed."; |
|
| 2584 | - } else $error = "File ".$tmp_dir.'airspace.sql.gz'." doesn't exist. Download failed."; |
|
| 3154 | + } else { |
|
| 3155 | + $error = "File ".$tmp_dir.'airspace.sql.gz'." md5 failed. Download failed."; |
|
| 3156 | + } |
|
| 3157 | + } else { |
|
| 3158 | + $error = "File ".$tmp_dir.'airspace.sql.gz'." doesn't exist. Download failed."; |
|
| 3159 | + } |
|
| 2585 | 3160 | } |
| 2586 | - } else $error = "File ".$tmp_dir.'airspace.sql.gz.md5'." doesn't exist. Download failed."; |
|
| 3161 | + } else { |
|
| 3162 | + $error = "File ".$tmp_dir.'airspace.sql.gz.md5'." doesn't exist. Download failed."; |
|
| 3163 | + } |
|
| 2587 | 3164 | if ($error != '') { |
| 2588 | 3165 | return $error; |
| 2589 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 3166 | + } elseif ($globalDebug) { |
|
| 3167 | + echo "Done\n"; |
|
| 3168 | + } |
|
| 2590 | 3169 | return ''; |
| 2591 | 3170 | } |
| 2592 | 3171 | |
| 2593 | 3172 | public static function update_geoid_fam() { |
| 2594 | 3173 | global $tmp_dir, $globalDebug, $globalGeoidSource; |
| 2595 | 3174 | $error = ''; |
| 2596 | - if ($globalDebug) echo "Geoid from FlightAirMap website : Download..."; |
|
| 3175 | + if ($globalDebug) { |
|
| 3176 | + echo "Geoid from FlightAirMap website : Download..."; |
|
| 3177 | + } |
|
| 2597 | 3178 | update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5',$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'); |
| 2598 | 3179 | if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')) { |
| 2599 | 3180 | $geoid_md5_file = explode(' ',file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')); |
@@ -2602,76 +3183,116 @@ discard block |
||
| 2602 | 3183 | update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz',$tmp_dir.$globalGeoidSource.'.pgm.gz'); |
| 2603 | 3184 | if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz')) { |
| 2604 | 3185 | if (md5_file($tmp_dir.$globalGeoidSource.'.pgm.gz') == $geoid_md5) { |
| 2605 | - if ($globalDebug) echo "Gunzip..."; |
|
| 3186 | + if ($globalDebug) { |
|
| 3187 | + echo "Gunzip..."; |
|
| 3188 | + } |
|
| 2606 | 3189 | update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz',dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm'); |
| 2607 | 3190 | if (file_exists(dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm')) { |
| 2608 | 3191 | update_db::insert_geoid_version($geoid_md5); |
| 2609 | 3192 | } |
| 2610 | - } else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." md5 failed. Download failed."; |
|
| 2611 | - } else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed."; |
|
| 3193 | + } else { |
|
| 3194 | + $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." md5 failed. Download failed."; |
|
| 3195 | + } |
|
| 3196 | + } else { |
|
| 3197 | + $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed."; |
|
| 3198 | + } |
|
| 2612 | 3199 | } |
| 2613 | - } else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed."; |
|
| 3200 | + } else { |
|
| 3201 | + $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed."; |
|
| 3202 | + } |
|
| 2614 | 3203 | if ($error != '') { |
| 2615 | 3204 | return $error; |
| 2616 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 3205 | + } elseif ($globalDebug) { |
|
| 3206 | + echo "Done\n"; |
|
| 3207 | + } |
|
| 2617 | 3208 | return ''; |
| 2618 | 3209 | } |
| 2619 | 3210 | |
| 2620 | 3211 | public static function update_tle() { |
| 2621 | 3212 | global $tmp_dir, $globalDebug; |
| 2622 | - if ($globalDebug) echo "Download TLE : Download..."; |
|
| 3213 | + if ($globalDebug) { |
|
| 3214 | + echo "Download TLE : Download..."; |
|
| 3215 | + } |
|
| 2623 | 3216 | $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', |
| 2624 | 3217 | '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', |
| 2625 | 3218 | 'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt','visual.txt','sarsat.txt','argos.txt','ses.txt','iridium-NEXT.txt','beidou.txt'); |
| 2626 | 3219 | foreach ($alltle as $filename) { |
| 2627 | - if ($globalDebug) echo "downloading ".$filename.'...'; |
|
| 3220 | + if ($globalDebug) { |
|
| 3221 | + echo "downloading ".$filename.'...'; |
|
| 3222 | + } |
|
| 2628 | 3223 | update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename); |
| 2629 | 3224 | if (file_exists($tmp_dir.$filename)) { |
| 2630 | - if ($globalDebug) echo "Add to DB ".$filename."..."; |
|
| 3225 | + if ($globalDebug) { |
|
| 3226 | + echo "Add to DB ".$filename."..."; |
|
| 3227 | + } |
|
| 2631 | 3228 | $error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename)); |
| 2632 | - } else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
|
| 3229 | + } else { |
|
| 3230 | + $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
|
| 3231 | + } |
|
| 2633 | 3232 | if ($error != '') { |
| 2634 | 3233 | echo $error."\n"; |
| 2635 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 3234 | + } elseif ($globalDebug) { |
|
| 3235 | + echo "Done\n"; |
|
| 3236 | + } |
|
| 2636 | 3237 | } |
| 2637 | 3238 | return ''; |
| 2638 | 3239 | } |
| 2639 | 3240 | |
| 2640 | 3241 | public static function update_ucsdb() { |
| 2641 | 3242 | global $tmp_dir, $globalDebug; |
| 2642 | - if ($globalDebug) echo "Download UCS DB : Download..."; |
|
| 3243 | + if ($globalDebug) { |
|
| 3244 | + echo "Download UCS DB : Download..."; |
|
| 3245 | + } |
|
| 2643 | 3246 | update_db::download('https://s3.amazonaws.com/ucs-documents/nuclear-weapons/sat-database/4-11-17-update/UCS_Satellite_Database_officialname_1-1-17.txt',$tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt'); |
| 2644 | 3247 | if (file_exists($tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt')) { |
| 2645 | - if ($globalDebug) echo "Add to DB..."; |
|
| 3248 | + if ($globalDebug) { |
|
| 3249 | + echo "Add to DB..."; |
|
| 3250 | + } |
|
| 2646 | 3251 | $error = update_db::satellite_ucsdb($tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt'); |
| 2647 | - } else $error = "File ".$tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt'." doesn't exist. Download failed."; |
|
| 3252 | + } else { |
|
| 3253 | + $error = "File ".$tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt'." doesn't exist. Download failed."; |
|
| 3254 | + } |
|
| 2648 | 3255 | if ($error != '') { |
| 2649 | 3256 | echo $error."\n"; |
| 2650 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 3257 | + } elseif ($globalDebug) { |
|
| 3258 | + echo "Done\n"; |
|
| 3259 | + } |
|
| 2651 | 3260 | return ''; |
| 2652 | 3261 | } |
| 2653 | 3262 | |
| 2654 | 3263 | public static function update_celestrak() { |
| 2655 | 3264 | global $tmp_dir, $globalDebug; |
| 2656 | - if ($globalDebug) echo "Download Celestrak DB : Download..."; |
|
| 3265 | + if ($globalDebug) { |
|
| 3266 | + echo "Download Celestrak DB : Download..."; |
|
| 3267 | + } |
|
| 2657 | 3268 | update_db::download('http://celestrak.com/pub/satcat.txt',$tmp_dir.'satcat.txt'); |
| 2658 | 3269 | if (file_exists($tmp_dir.'satcat.txt')) { |
| 2659 | - if ($globalDebug) echo "Add to DB..."; |
|
| 3270 | + if ($globalDebug) { |
|
| 3271 | + echo "Add to DB..."; |
|
| 3272 | + } |
|
| 2660 | 3273 | $error = update_db::satellite_celestrak($tmp_dir.'satcat.txt'); |
| 2661 | - } else $error = "File ".$tmp_dir.'satcat.txt'." doesn't exist. Download failed."; |
|
| 3274 | + } else { |
|
| 3275 | + $error = "File ".$tmp_dir.'satcat.txt'." doesn't exist. Download failed."; |
|
| 3276 | + } |
|
| 2662 | 3277 | if ($error != '') { |
| 2663 | 3278 | echo $error."\n"; |
| 2664 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 3279 | + } elseif ($globalDebug) { |
|
| 3280 | + echo "Done\n"; |
|
| 3281 | + } |
|
| 2665 | 3282 | return ''; |
| 2666 | 3283 | } |
| 2667 | 3284 | |
| 2668 | 3285 | public static function update_models() { |
| 2669 | 3286 | global $tmp_dir, $globalDebug; |
| 2670 | 3287 | $error = ''; |
| 2671 | - if ($globalDebug) echo "Models from FlightAirMap website : Download..."; |
|
| 3288 | + if ($globalDebug) { |
|
| 3289 | + echo "Models from FlightAirMap website : Download..."; |
|
| 3290 | + } |
|
| 2672 | 3291 | update_db::download('http://data.flightairmap.com/data/models/models.md5sum',$tmp_dir.'models.md5sum'); |
| 2673 | 3292 | if (file_exists($tmp_dir.'models.md5sum')) { |
| 2674 | - if ($globalDebug) echo "Check files...\n"; |
|
| 3293 | + if ($globalDebug) { |
|
| 3294 | + echo "Check files...\n"; |
|
| 3295 | + } |
|
| 2675 | 3296 | $newmodelsdb = array(); |
| 2676 | 3297 | if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) { |
| 2677 | 3298 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2690,25 +3311,35 @@ discard block |
||
| 2690 | 3311 | } |
| 2691 | 3312 | $diff = array_diff($newmodelsdb,$modelsdb); |
| 2692 | 3313 | foreach ($diff as $key => $value) { |
| 2693 | - if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n"; |
|
| 3314 | + if ($globalDebug) { |
|
| 3315 | + echo 'Downloading model '.$key.' ...'."\n"; |
|
| 3316 | + } |
|
| 2694 | 3317 | update_db::download('http://data.flightairmap.com/data/models/'.$key,dirname(__FILE__).'/../models/'.$key); |
| 2695 | 3318 | |
| 2696 | 3319 | } |
| 2697 | 3320 | update_db::download('http://data.flightairmap.com/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum'); |
| 2698 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 3321 | + } else { |
|
| 3322 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 3323 | + } |
|
| 2699 | 3324 | if ($error != '') { |
| 2700 | 3325 | return $error; |
| 2701 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 3326 | + } elseif ($globalDebug) { |
|
| 3327 | + echo "Done\n"; |
|
| 3328 | + } |
|
| 2702 | 3329 | return ''; |
| 2703 | 3330 | } |
| 2704 | 3331 | |
| 2705 | 3332 | public static function update_space_models() { |
| 2706 | 3333 | global $tmp_dir, $globalDebug; |
| 2707 | 3334 | $error = ''; |
| 2708 | - if ($globalDebug) echo "Space models from FlightAirMap website : Download..."; |
|
| 3335 | + if ($globalDebug) { |
|
| 3336 | + echo "Space models from FlightAirMap website : Download..."; |
|
| 3337 | + } |
|
| 2709 | 3338 | update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum'); |
| 2710 | 3339 | if (file_exists($tmp_dir.'space_models.md5sum')) { |
| 2711 | - if ($globalDebug) echo "Check files...\n"; |
|
| 3340 | + if ($globalDebug) { |
|
| 3341 | + echo "Check files...\n"; |
|
| 3342 | + } |
|
| 2712 | 3343 | $newmodelsdb = array(); |
| 2713 | 3344 | if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) { |
| 2714 | 3345 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2727,25 +3358,35 @@ discard block |
||
| 2727 | 3358 | } |
| 2728 | 3359 | $diff = array_diff($newmodelsdb,$modelsdb); |
| 2729 | 3360 | foreach ($diff as $key => $value) { |
| 2730 | - if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n"; |
|
| 3361 | + if ($globalDebug) { |
|
| 3362 | + echo 'Downloading space model '.$key.' ...'."\n"; |
|
| 3363 | + } |
|
| 2731 | 3364 | update_db::download('http://data.flightairmap.com/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key); |
| 2732 | 3365 | |
| 2733 | 3366 | } |
| 2734 | 3367 | update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum'); |
| 2735 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 3368 | + } else { |
|
| 3369 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 3370 | + } |
|
| 2736 | 3371 | if ($error != '') { |
| 2737 | 3372 | return $error; |
| 2738 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 3373 | + } elseif ($globalDebug) { |
|
| 3374 | + echo "Done\n"; |
|
| 3375 | + } |
|
| 2739 | 3376 | return ''; |
| 2740 | 3377 | } |
| 2741 | 3378 | |
| 2742 | 3379 | public static function update_vehicules_models() { |
| 2743 | 3380 | global $tmp_dir, $globalDebug; |
| 2744 | 3381 | $error = ''; |
| 2745 | - if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download..."; |
|
| 3382 | + if ($globalDebug) { |
|
| 3383 | + echo "Vehicules models from FlightAirMap website : Download..."; |
|
| 3384 | + } |
|
| 2746 | 3385 | update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum'); |
| 2747 | 3386 | if (file_exists($tmp_dir.'vehicules_models.md5sum')) { |
| 2748 | - if ($globalDebug) echo "Check files...\n"; |
|
| 3387 | + if ($globalDebug) { |
|
| 3388 | + echo "Check files...\n"; |
|
| 3389 | + } |
|
| 2749 | 3390 | $newmodelsdb = array(); |
| 2750 | 3391 | if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) { |
| 2751 | 3392 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2764,15 +3405,21 @@ discard block |
||
| 2764 | 3405 | } |
| 2765 | 3406 | $diff = array_diff($newmodelsdb,$modelsdb); |
| 2766 | 3407 | foreach ($diff as $key => $value) { |
| 2767 | - if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n"; |
|
| 3408 | + if ($globalDebug) { |
|
| 3409 | + echo 'Downloading vehicules model '.$key.' ...'."\n"; |
|
| 3410 | + } |
|
| 2768 | 3411 | update_db::download('http://data.flightairmap.com/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key); |
| 2769 | 3412 | |
| 2770 | 3413 | } |
| 2771 | 3414 | update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum'); |
| 2772 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 3415 | + } else { |
|
| 3416 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 3417 | + } |
|
| 2773 | 3418 | if ($error != '') { |
| 2774 | 3419 | return $error; |
| 2775 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 3420 | + } elseif ($globalDebug) { |
|
| 3421 | + echo "Done\n"; |
|
| 3422 | + } |
|
| 2776 | 3423 | return ''; |
| 2777 | 3424 | } |
| 2778 | 3425 | |
@@ -2815,7 +3462,9 @@ discard block |
||
| 2815 | 3462 | } |
| 2816 | 3463 | |
| 2817 | 3464 | $error = ''; |
| 2818 | - if ($globalDebug) echo "Notam : Download..."; |
|
| 3465 | + if ($globalDebug) { |
|
| 3466 | + echo "Notam : Download..."; |
|
| 3467 | + } |
|
| 2819 | 3468 | update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss'); |
| 2820 | 3469 | if (file_exists($tmp_dir.'notam.rss')) { |
| 2821 | 3470 | $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true); |
@@ -2830,14 +3479,30 @@ discard block |
||
| 2830 | 3479 | $data['fir'] = $q[0]; |
| 2831 | 3480 | $data['code'] = $q[1]; |
| 2832 | 3481 | $ifrvfr = $q[2]; |
| 2833 | - if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR'; |
|
| 2834 | - if ($ifrvfr == 'I') $data['rules'] = 'IFR'; |
|
| 2835 | - if ($ifrvfr == 'V') $data['rules'] = 'VFR'; |
|
| 2836 | - if ($q[4] == 'A') $data['scope'] = 'Airport warning'; |
|
| 2837 | - if ($q[4] == 'E') $data['scope'] = 'Enroute warning'; |
|
| 2838 | - if ($q[4] == 'W') $data['scope'] = 'Navigation warning'; |
|
| 2839 | - if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning'; |
|
| 2840 | - if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning'; |
|
| 3482 | + if ($ifrvfr == 'IV') { |
|
| 3483 | + $data['rules'] = 'IFR/VFR'; |
|
| 3484 | + } |
|
| 3485 | + if ($ifrvfr == 'I') { |
|
| 3486 | + $data['rules'] = 'IFR'; |
|
| 3487 | + } |
|
| 3488 | + if ($ifrvfr == 'V') { |
|
| 3489 | + $data['rules'] = 'VFR'; |
|
| 3490 | + } |
|
| 3491 | + if ($q[4] == 'A') { |
|
| 3492 | + $data['scope'] = 'Airport warning'; |
|
| 3493 | + } |
|
| 3494 | + if ($q[4] == 'E') { |
|
| 3495 | + $data['scope'] = 'Enroute warning'; |
|
| 3496 | + } |
|
| 3497 | + if ($q[4] == 'W') { |
|
| 3498 | + $data['scope'] = 'Navigation warning'; |
|
| 3499 | + } |
|
| 3500 | + if ($q[4] == 'AE') { |
|
| 3501 | + $data['scope'] = 'Airport/Enroute warning'; |
|
| 3502 | + } |
|
| 3503 | + if ($q[4] == 'AW') { |
|
| 3504 | + $data['scope'] = 'Airport/Navigation warning'; |
|
| 3505 | + } |
|
| 2841 | 3506 | //$data['scope'] = $q[4]; |
| 2842 | 3507 | $data['lower_limit'] = $q[5]; |
| 2843 | 3508 | $data['upper_limit'] = $q[6]; |
@@ -2845,8 +3510,12 @@ discard block |
||
| 2845 | 3510 | sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius); |
| 2846 | 3511 | $latitude = $Common->convertDec($las,'latitude'); |
| 2847 | 3512 | $longitude = $Common->convertDec($lns,'longitude'); |
| 2848 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
| 2849 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
| 3513 | + if ($lac == 'S') { |
|
| 3514 | + $latitude = '-'.$latitude; |
|
| 3515 | + } |
|
| 3516 | + if ($lnc == 'W') { |
|
| 3517 | + $longitude = '-'.$longitude; |
|
| 3518 | + } |
|
| 2850 | 3519 | $data['center_latitude'] = $latitude; |
| 2851 | 3520 | $data['center_longitude'] = $longitude; |
| 2852 | 3521 | $data['radius'] = intval($radius); |
@@ -2876,10 +3545,14 @@ discard block |
||
| 2876 | 3545 | $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']); |
| 2877 | 3546 | unset($data); |
| 2878 | 3547 | } |
| 2879 | - } else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
|
| 3548 | + } else { |
|
| 3549 | + $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
|
| 3550 | + } |
|
| 2880 | 3551 | if ($error != '') { |
| 2881 | 3552 | return $error; |
| 2882 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 3553 | + } elseif ($globalDebug) { |
|
| 3554 | + echo "Done\n"; |
|
| 3555 | + } |
|
| 2883 | 3556 | return ''; |
| 2884 | 3557 | } |
| 2885 | 3558 | |
@@ -2904,7 +3577,9 @@ discard block |
||
| 2904 | 3577 | $airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json'); |
| 2905 | 3578 | $airspace_json = json_decode($airspace_lst,true); |
| 2906 | 3579 | foreach ($airspace_json['records'] as $airspace) { |
| 2907 | - if ($globalDebug) echo $airspace['name']."...\n"; |
|
| 3580 | + if ($globalDebug) { |
|
| 3581 | + echo $airspace['name']."...\n"; |
|
| 3582 | + } |
|
| 2908 | 3583 | update_db::download($airspace['uri'],$tmp_dir.$airspace['name']); |
| 2909 | 3584 | if (file_exists($tmp_dir.$airspace['name'])) { |
| 2910 | 3585 | file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name']))); |
@@ -2948,8 +3623,11 @@ discard block |
||
| 2948 | 3623 | return "error : ".$e->getMessage(); |
| 2949 | 3624 | } |
| 2950 | 3625 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 2951 | - if ($row['nb'] > 0) return false; |
|
| 2952 | - else return true; |
|
| 3626 | + if ($row['nb'] > 0) { |
|
| 3627 | + return false; |
|
| 3628 | + } else { |
|
| 3629 | + return true; |
|
| 3630 | + } |
|
| 2953 | 3631 | } |
| 2954 | 3632 | |
| 2955 | 3633 | public static function insert_last_update() { |
@@ -2974,8 +3652,11 @@ discard block |
||
| 2974 | 3652 | return "error : ".$e->getMessage(); |
| 2975 | 3653 | } |
| 2976 | 3654 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 2977 | - if ($row['nb'] > 0) return true; |
|
| 2978 | - else return false; |
|
| 3655 | + if ($row['nb'] > 0) { |
|
| 3656 | + return true; |
|
| 3657 | + } else { |
|
| 3658 | + return false; |
|
| 3659 | + } |
|
| 2979 | 3660 | } |
| 2980 | 3661 | |
| 2981 | 3662 | public static function check_geoid_version($version) { |
@@ -2988,8 +3669,11 @@ discard block |
||
| 2988 | 3669 | return "error : ".$e->getMessage(); |
| 2989 | 3670 | } |
| 2990 | 3671 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 2991 | - if ($row['nb'] > 0) return true; |
|
| 2992 | - else return false; |
|
| 3672 | + if ($row['nb'] > 0) { |
|
| 3673 | + return true; |
|
| 3674 | + } else { |
|
| 3675 | + return false; |
|
| 3676 | + } |
|
| 2993 | 3677 | } |
| 2994 | 3678 | |
| 2995 | 3679 | public static function check_marine_identity_version($version) { |
@@ -3002,8 +3686,11 @@ discard block |
||
| 3002 | 3686 | return "error : ".$e->getMessage(); |
| 3003 | 3687 | } |
| 3004 | 3688 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3005 | - if ($row['nb'] > 0) return true; |
|
| 3006 | - else return false; |
|
| 3689 | + if ($row['nb'] > 0) { |
|
| 3690 | + return true; |
|
| 3691 | + } else { |
|
| 3692 | + return false; |
|
| 3693 | + } |
|
| 3007 | 3694 | } |
| 3008 | 3695 | |
| 3009 | 3696 | public static function check_satellite_version($version) { |
@@ -3016,8 +3703,11 @@ discard block |
||
| 3016 | 3703 | return "error : ".$e->getMessage(); |
| 3017 | 3704 | } |
| 3018 | 3705 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3019 | - if ($row['nb'] > 0) return true; |
|
| 3020 | - else return false; |
|
| 3706 | + if ($row['nb'] > 0) { |
|
| 3707 | + return true; |
|
| 3708 | + } else { |
|
| 3709 | + return false; |
|
| 3710 | + } |
|
| 3021 | 3711 | } |
| 3022 | 3712 | |
| 3023 | 3713 | public static function check_airlines_version($version) { |
@@ -3030,8 +3720,11 @@ discard block |
||
| 3030 | 3720 | return "error : ".$e->getMessage(); |
| 3031 | 3721 | } |
| 3032 | 3722 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3033 | - if ($row['nb'] > 0) return true; |
|
| 3034 | - else return false; |
|
| 3723 | + if ($row['nb'] > 0) { |
|
| 3724 | + return true; |
|
| 3725 | + } else { |
|
| 3726 | + return false; |
|
| 3727 | + } |
|
| 3035 | 3728 | } |
| 3036 | 3729 | |
| 3037 | 3730 | public static function check_notam_version($version) { |
@@ -3044,8 +3737,11 @@ discard block |
||
| 3044 | 3737 | return "error : ".$e->getMessage(); |
| 3045 | 3738 | } |
| 3046 | 3739 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3047 | - if ($row['nb'] > 0) return true; |
|
| 3048 | - else return false; |
|
| 3740 | + if ($row['nb'] > 0) { |
|
| 3741 | + return true; |
|
| 3742 | + } else { |
|
| 3743 | + return false; |
|
| 3744 | + } |
|
| 3049 | 3745 | } |
| 3050 | 3746 | |
| 3051 | 3747 | public static function insert_airlines_version($version) { |
@@ -3135,8 +3831,11 @@ discard block |
||
| 3135 | 3831 | return "error : ".$e->getMessage(); |
| 3136 | 3832 | } |
| 3137 | 3833 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3138 | - if ($row['nb'] > 0) return false; |
|
| 3139 | - else return true; |
|
| 3834 | + if ($row['nb'] > 0) { |
|
| 3835 | + return false; |
|
| 3836 | + } else { |
|
| 3837 | + return true; |
|
| 3838 | + } |
|
| 3140 | 3839 | } |
| 3141 | 3840 | |
| 3142 | 3841 | public static function insert_last_notam_update() { |
@@ -3166,8 +3865,11 @@ discard block |
||
| 3166 | 3865 | return "error : ".$e->getMessage(); |
| 3167 | 3866 | } |
| 3168 | 3867 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3169 | - if ($row['nb'] > 0) return false; |
|
| 3170 | - else return true; |
|
| 3868 | + if ($row['nb'] > 0) { |
|
| 3869 | + return false; |
|
| 3870 | + } else { |
|
| 3871 | + return true; |
|
| 3872 | + } |
|
| 3171 | 3873 | } |
| 3172 | 3874 | |
| 3173 | 3875 | public static function insert_last_airspace_update() { |
@@ -3197,8 +3899,11 @@ discard block |
||
| 3197 | 3899 | return "error : ".$e->getMessage(); |
| 3198 | 3900 | } |
| 3199 | 3901 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3200 | - if ($row['nb'] > 0) return false; |
|
| 3201 | - else return true; |
|
| 3902 | + if ($row['nb'] > 0) { |
|
| 3903 | + return false; |
|
| 3904 | + } else { |
|
| 3905 | + return true; |
|
| 3906 | + } |
|
| 3202 | 3907 | } |
| 3203 | 3908 | |
| 3204 | 3909 | public static function insert_last_geoid_update() { |
@@ -3228,8 +3933,11 @@ discard block |
||
| 3228 | 3933 | return "error : ".$e->getMessage(); |
| 3229 | 3934 | } |
| 3230 | 3935 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3231 | - if ($row['nb'] > 0) return false; |
|
| 3232 | - else return true; |
|
| 3936 | + if ($row['nb'] > 0) { |
|
| 3937 | + return false; |
|
| 3938 | + } else { |
|
| 3939 | + return true; |
|
| 3940 | + } |
|
| 3233 | 3941 | } |
| 3234 | 3942 | |
| 3235 | 3943 | public static function insert_last_owner_update() { |
@@ -3258,8 +3966,11 @@ discard block |
||
| 3258 | 3966 | return "error : ".$e->getMessage(); |
| 3259 | 3967 | } |
| 3260 | 3968 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3261 | - if ($row['nb'] > 0) return false; |
|
| 3262 | - else return true; |
|
| 3969 | + if ($row['nb'] > 0) { |
|
| 3970 | + return false; |
|
| 3971 | + } else { |
|
| 3972 | + return true; |
|
| 3973 | + } |
|
| 3263 | 3974 | } |
| 3264 | 3975 | |
| 3265 | 3976 | public static function insert_last_schedules_update() { |
@@ -3289,8 +4000,11 @@ discard block |
||
| 3289 | 4000 | return "error : ".$e->getMessage(); |
| 3290 | 4001 | } |
| 3291 | 4002 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3292 | - if ($row['nb'] > 0) return false; |
|
| 3293 | - else return true; |
|
| 4003 | + if ($row['nb'] > 0) { |
|
| 4004 | + return false; |
|
| 4005 | + } else { |
|
| 4006 | + return true; |
|
| 4007 | + } |
|
| 3294 | 4008 | } |
| 3295 | 4009 | |
| 3296 | 4010 | public static function insert_last_tle_update() { |
@@ -3320,8 +4034,11 @@ discard block |
||
| 3320 | 4034 | return "error : ".$e->getMessage(); |
| 3321 | 4035 | } |
| 3322 | 4036 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3323 | - if ($row['nb'] > 0) return false; |
|
| 3324 | - else return true; |
|
| 4037 | + if ($row['nb'] > 0) { |
|
| 4038 | + return false; |
|
| 4039 | + } else { |
|
| 4040 | + return true; |
|
| 4041 | + } |
|
| 3325 | 4042 | } |
| 3326 | 4043 | |
| 3327 | 4044 | public static function insert_last_ucsdb_update() { |
@@ -3351,8 +4068,11 @@ discard block |
||
| 3351 | 4068 | return "error : ".$e->getMessage(); |
| 3352 | 4069 | } |
| 3353 | 4070 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3354 | - if ($row['nb'] > 0) return false; |
|
| 3355 | - else return true; |
|
| 4071 | + if ($row['nb'] > 0) { |
|
| 4072 | + return false; |
|
| 4073 | + } else { |
|
| 4074 | + return true; |
|
| 4075 | + } |
|
| 3356 | 4076 | } |
| 3357 | 4077 | |
| 3358 | 4078 | public static function insert_last_celestrak_update() { |
@@ -3382,8 +4102,11 @@ discard block |
||
| 3382 | 4102 | return "error : ".$e->getMessage(); |
| 3383 | 4103 | } |
| 3384 | 4104 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3385 | - if ($row['nb'] > 0) return false; |
|
| 3386 | - else return true; |
|
| 4105 | + if ($row['nb'] > 0) { |
|
| 4106 | + return false; |
|
| 4107 | + } else { |
|
| 4108 | + return true; |
|
| 4109 | + } |
|
| 3387 | 4110 | } |
| 3388 | 4111 | |
| 3389 | 4112 | public static function check_last_satellite_update() { |
@@ -3401,8 +4124,11 @@ discard block |
||
| 3401 | 4124 | return "error : ".$e->getMessage(); |
| 3402 | 4125 | } |
| 3403 | 4126 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 3404 | - if ($row['nb'] > 0) return false; |
|
| 3405 | - else return true; |
|
| 4127 | + if ($row['nb'] > 0) { |
|
| 4128 | + return false; |
|
| 4129 | + } else { |
|
| 4130 | + return true; |
|
| 4131 | + } |
|
| 3406 | 4132 | } |
| 3407 | 4133 | |
| 3408 | 4134 | public static function insert_last_marine_identity_update() { |