@@ -70,38 +70,38 @@ discard block |
||
| 70 | 70 | try { |
| 71 | 71 | //$Connection = new Connection(); |
| 72 | 72 | $sth = $Connection->db->prepare($query); |
| 73 | - $sth->execute(array(':source' => $database_file)); |
|
| 74 | - } catch(PDOException $e) { |
|
| 75 | - return "error : ".$e->getMessage(); |
|
| 76 | - } |
|
| 73 | + $sth->execute(array(':source' => $database_file)); |
|
| 74 | + } catch(PDOException $e) { |
|
| 75 | + return "error : ".$e->getMessage(); |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
| 79 | - update_db::connect_sqlite($database_file); |
|
| 78 | + if ($globalDebug) echo " - Add routes to DB -"; |
|
| 79 | + update_db::connect_sqlite($database_file); |
|
| 80 | 80 | //$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'; |
| 81 | 81 | $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"; |
| 82 | 82 | try { |
| 83 | - $sth = update_db::$db_sqlite->prepare($query); |
|
| 84 | - $sth->execute(); |
|
| 85 | - } catch(PDOException $e) { |
|
| 86 | - return "error : ".$e->getMessage(); |
|
| 87 | - } |
|
| 83 | + $sth = update_db::$db_sqlite->prepare($query); |
|
| 84 | + $sth->execute(); |
|
| 85 | + } catch(PDOException $e) { |
|
| 86 | + return "error : ".$e->getMessage(); |
|
| 87 | + } |
|
| 88 | 88 | //$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)'; |
| 89 | 89 | $query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,ToAirport_ICAO,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)'; |
| 90 | 90 | $Connection = new Connection(); |
| 91 | 91 | $sth_dest = $Connection->db->prepare($query_dest); |
| 92 | 92 | try { |
| 93 | 93 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 94 | - while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
| 94 | + while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
| 95 | 95 | //$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); |
| 96 | 96 | $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); |
| 97 | 97 | $sth_dest->execute($query_dest_values); |
| 98 | - } |
|
| 98 | + } |
|
| 99 | 99 | if ($globalTransaction) $Connection->db->commit(); |
| 100 | 100 | } catch(PDOException $e) { |
| 101 | 101 | if ($globalTransaction) $Connection->db->rollBack(); |
| 102 | 102 | return "error : ".$e->getMessage(); |
| 103 | 103 | } |
| 104 | - return ''; |
|
| 104 | + return ''; |
|
| 105 | 105 | } |
| 106 | 106 | public static function retrieve_modes_sqlite_to_dest($database_file) { |
| 107 | 107 | global $globalTransaction; |
@@ -110,27 +110,27 @@ discard block |
||
| 110 | 110 | try { |
| 111 | 111 | $Connection = new Connection(); |
| 112 | 112 | $sth = $Connection->db->prepare($query); |
| 113 | - $sth->execute(array(':source' => $database_file)); |
|
| 114 | - } catch(PDOException $e) { |
|
| 115 | - return "error : ".$e->getMessage(); |
|
| 116 | - } |
|
| 113 | + $sth->execute(array(':source' => $database_file)); |
|
| 114 | + } catch(PDOException $e) { |
|
| 115 | + return "error : ".$e->getMessage(); |
|
| 116 | + } |
|
| 117 | 117 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source"; |
| 118 | 118 | try { |
| 119 | 119 | $Connection = new Connection(); |
| 120 | 120 | $sth = $Connection->db->prepare($query); |
| 121 | - $sth->execute(array(':source' => $database_file)); |
|
| 122 | - } catch(PDOException $e) { |
|
| 123 | - return "error : ".$e->getMessage(); |
|
| 124 | - } |
|
| 121 | + $sth->execute(array(':source' => $database_file)); |
|
| 122 | + } catch(PDOException $e) { |
|
| 123 | + return "error : ".$e->getMessage(); |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | - update_db::connect_sqlite($database_file); |
|
| 126 | + update_db::connect_sqlite($database_file); |
|
| 127 | 127 | $query = 'select * from Aircraft'; |
| 128 | 128 | try { |
| 129 | - $sth = update_db::$db_sqlite->prepare($query); |
|
| 130 | - $sth->execute(); |
|
| 131 | - } catch(PDOException $e) { |
|
| 132 | - return "error : ".$e->getMessage(); |
|
| 133 | - } |
|
| 129 | + $sth = update_db::$db_sqlite->prepare($query); |
|
| 130 | + $sth->execute(); |
|
| 131 | + } catch(PDOException $e) { |
|
| 132 | + return "error : ".$e->getMessage(); |
|
| 133 | + } |
|
| 134 | 134 | //$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)'; |
| 135 | 135 | $query_dest = 'INSERT INTO aircraft_modes (LastModified, ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type,:source)'; |
| 136 | 136 | |
@@ -141,17 +141,17 @@ discard block |
||
| 141 | 141 | $sth_dest_owner = $Connection->db->prepare($query_dest_owner); |
| 142 | 142 | try { |
| 143 | 143 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 144 | - while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
| 144 | + while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
| 145 | 145 | //$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']); |
| 146 | 146 | if ($values['UserString4'] == 'M') $type = 'military'; |
| 147 | 147 | else $type = null; |
| 148 | 148 | $query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type); |
| 149 | 149 | $sth_dest->execute($query_dest_values); |
| 150 | 150 | if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') { |
| 151 | - $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']); |
|
| 152 | - $sth_dest_owner->execute($query_dest_owner_values); |
|
| 151 | + $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']); |
|
| 152 | + $sth_dest_owner->execute($query_dest_owner_values); |
|
| 153 | 153 | } |
| 154 | - } |
|
| 154 | + } |
|
| 155 | 155 | if ($globalTransaction) $Connection->db->commit(); |
| 156 | 156 | } catch(PDOException $e) { |
| 157 | 157 | return "error : ".$e->getMessage(); |
@@ -161,10 +161,10 @@ discard block |
||
| 161 | 161 | try { |
| 162 | 162 | $Connection = new Connection(); |
| 163 | 163 | $sth = $Connection->db->prepare($query); |
| 164 | - $sth->execute(array(':source' => $database_file)); |
|
| 165 | - } catch(PDOException $e) { |
|
| 166 | - return "error : ".$e->getMessage(); |
|
| 167 | - } |
|
| 164 | + $sth->execute(array(':source' => $database_file)); |
|
| 165 | + } catch(PDOException $e) { |
|
| 166 | + return "error : ".$e->getMessage(); |
|
| 167 | + } |
|
| 168 | 168 | return ''; |
| 169 | 169 | } |
| 170 | 170 | |
@@ -176,10 +176,10 @@ discard block |
||
| 176 | 176 | try { |
| 177 | 177 | $Connection = new Connection(); |
| 178 | 178 | $sth = $Connection->db->prepare($query); |
| 179 | - $sth->execute(array(':source' => $database_file)); |
|
| 180 | - } catch(PDOException $e) { |
|
| 181 | - return "error : ".$e->getMessage(); |
|
| 182 | - } |
|
| 179 | + $sth->execute(array(':source' => $database_file)); |
|
| 180 | + } catch(PDOException $e) { |
|
| 181 | + return "error : ".$e->getMessage(); |
|
| 182 | + } |
|
| 183 | 183 | |
| 184 | 184 | if ($fh = fopen($database_file,"r")) { |
| 185 | 185 | //$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)'; |
@@ -189,25 +189,25 @@ discard block |
||
| 189 | 189 | $sth_dest = $Connection->db->prepare($query_dest); |
| 190 | 190 | try { |
| 191 | 191 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 192 | - while (!feof($fh)) { |
|
| 193 | - $line = $Common->hex2str(fgets($fh,9999)); |
|
| 192 | + while (!feof($fh)) { |
|
| 193 | + $line = $Common->hex2str(fgets($fh,9999)); |
|
| 194 | 194 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
| 195 | - $values['ModeS'] = substr($line,0,6); |
|
| 196 | - $values['Registration'] = trim(substr($line,69,6)); |
|
| 197 | - $aircraft_name = trim(substr($line,48,6)); |
|
| 198 | - // Check if we can find ICAO, else set it to GLID |
|
| 199 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
| 200 | - $search_more = ''; |
|
| 201 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 202 | - $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
| 203 | - $sth_search = $Connection->db->prepare($query_search); |
|
| 195 | + $values['ModeS'] = substr($line,0,6); |
|
| 196 | + $values['Registration'] = trim(substr($line,69,6)); |
|
| 197 | + $aircraft_name = trim(substr($line,48,6)); |
|
| 198 | + // Check if we can find ICAO, else set it to GLID |
|
| 199 | + $aircraft_name_split = explode(' ',$aircraft_name); |
|
| 200 | + $search_more = ''; |
|
| 201 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 202 | + $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
| 203 | + $sth_search = $Connection->db->prepare($query_search); |
|
| 204 | 204 | try { |
| 205 | - $sth_search->execute(); |
|
| 206 | - $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
| 207 | - //if (count($result) > 0) { |
|
| 208 | - if (isset($result['icao']) && $result['icao'] != '') { |
|
| 209 | - $values['ICAOTypeCode'] = $result['icao']; |
|
| 210 | - } |
|
| 205 | + $sth_search->execute(); |
|
| 206 | + $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
| 207 | + //if (count($result) > 0) { |
|
| 208 | + if (isset($result['icao']) && $result['icao'] != '') { |
|
| 209 | + $values['ICAOTypeCode'] = $result['icao']; |
|
| 210 | + } |
|
| 211 | 211 | } catch(PDOException $e) { |
| 212 | 212 | return "error : ".$e->getMessage(); |
| 213 | 213 | } |
@@ -230,10 +230,10 @@ discard block |
||
| 230 | 230 | try { |
| 231 | 231 | $Connection = new Connection(); |
| 232 | 232 | $sth = $Connection->db->prepare($query); |
| 233 | - $sth->execute(array(':source' => $database_file)); |
|
| 234 | - } catch(PDOException $e) { |
|
| 235 | - return "error : ".$e->getMessage(); |
|
| 236 | - } |
|
| 233 | + $sth->execute(array(':source' => $database_file)); |
|
| 234 | + } catch(PDOException $e) { |
|
| 235 | + return "error : ".$e->getMessage(); |
|
| 236 | + } |
|
| 237 | 237 | return ''; |
| 238 | 238 | } |
| 239 | 239 | |
@@ -244,10 +244,10 @@ discard block |
||
| 244 | 244 | try { |
| 245 | 245 | $Connection = new Connection(); |
| 246 | 246 | $sth = $Connection->db->prepare($query); |
| 247 | - $sth->execute(array(':source' => $database_file)); |
|
| 248 | - } catch(PDOException $e) { |
|
| 249 | - return "error : ".$e->getMessage(); |
|
| 250 | - } |
|
| 247 | + $sth->execute(array(':source' => $database_file)); |
|
| 248 | + } catch(PDOException $e) { |
|
| 249 | + return "error : ".$e->getMessage(); |
|
| 250 | + } |
|
| 251 | 251 | |
| 252 | 252 | if ($fh = fopen($database_file,"r")) { |
| 253 | 253 | //$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)'; |
@@ -258,24 +258,24 @@ discard block |
||
| 258 | 258 | try { |
| 259 | 259 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 260 | 260 | $tmp = fgetcsv($fh,9999,',',"'"); |
| 261 | - while (!feof($fh)) { |
|
| 262 | - $line = fgetcsv($fh,9999,',',"'"); |
|
| 261 | + while (!feof($fh)) { |
|
| 262 | + $line = fgetcsv($fh,9999,',',"'"); |
|
| 263 | 263 | |
| 264 | 264 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
| 265 | 265 | //print_r($line); |
| 266 | - $values['ModeS'] = $line[1]; |
|
| 267 | - $values['Registration'] = $line[3]; |
|
| 268 | - $aircraft_name = $line[2]; |
|
| 269 | - // Check if we can find ICAO, else set it to GLID |
|
| 270 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
| 271 | - $search_more = ''; |
|
| 272 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 273 | - $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
| 274 | - $sth_search = $Connection->db->prepare($query_search); |
|
| 266 | + $values['ModeS'] = $line[1]; |
|
| 267 | + $values['Registration'] = $line[3]; |
|
| 268 | + $aircraft_name = $line[2]; |
|
| 269 | + // Check if we can find ICAO, else set it to GLID |
|
| 270 | + $aircraft_name_split = explode(' ',$aircraft_name); |
|
| 271 | + $search_more = ''; |
|
| 272 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 273 | + $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
| 274 | + $sth_search = $Connection->db->prepare($query_search); |
|
| 275 | 275 | try { |
| 276 | - $sth_search->execute(); |
|
| 277 | - $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
| 278 | - if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
|
| 276 | + $sth_search->execute(); |
|
| 277 | + $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
| 278 | + if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
|
| 279 | 279 | } catch(PDOException $e) { |
| 280 | 280 | return "error : ".$e->getMessage(); |
| 281 | 281 | } |
@@ -298,10 +298,10 @@ discard block |
||
| 298 | 298 | try { |
| 299 | 299 | $Connection = new Connection(); |
| 300 | 300 | $sth = $Connection->db->prepare($query); |
| 301 | - $sth->execute(array(':source' => $database_file)); |
|
| 302 | - } catch(PDOException $e) { |
|
| 303 | - return "error : ".$e->getMessage(); |
|
| 304 | - } |
|
| 301 | + $sth->execute(array(':source' => $database_file)); |
|
| 302 | + } catch(PDOException $e) { |
|
| 303 | + return "error : ".$e->getMessage(); |
|
| 304 | + } |
|
| 305 | 305 | return ''; |
| 306 | 306 | } |
| 307 | 307 | |
@@ -312,10 +312,10 @@ discard block |
||
| 312 | 312 | try { |
| 313 | 313 | $Connection = new Connection(); |
| 314 | 314 | $sth = $Connection->db->prepare($query); |
| 315 | - $sth->execute(array(':source' => $database_file)); |
|
| 316 | - } catch(PDOException $e) { |
|
| 317 | - return "error : ".$e->getMessage(); |
|
| 318 | - } |
|
| 315 | + $sth->execute(array(':source' => $database_file)); |
|
| 316 | + } catch(PDOException $e) { |
|
| 317 | + return "error : ".$e->getMessage(); |
|
| 318 | + } |
|
| 319 | 319 | |
| 320 | 320 | if ($fh = fopen($database_file,"r")) { |
| 321 | 321 | //$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)'; |
@@ -326,94 +326,94 @@ discard block |
||
| 326 | 326 | try { |
| 327 | 327 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 328 | 328 | $tmp = fgetcsv($fh,9999,',','"'); |
| 329 | - while (!feof($fh)) { |
|
| 330 | - $line = fgetcsv($fh,9999,',','"'); |
|
| 331 | - //print_r($line); |
|
| 332 | - if ($country == 'F') { |
|
| 333 | - $values['registration'] = $line[0]; |
|
| 334 | - $values['base'] = $line[4]; |
|
| 335 | - $values['owner'] = $line[5]; |
|
| 336 | - if ($line[6] == '') $values['date_first_reg'] = ''; |
|
| 337 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 338 | - $values['cancel'] = $line[7]; |
|
| 329 | + while (!feof($fh)) { |
|
| 330 | + $line = fgetcsv($fh,9999,',','"'); |
|
| 331 | + //print_r($line); |
|
| 332 | + if ($country == 'F') { |
|
| 333 | + $values['registration'] = $line[0]; |
|
| 334 | + $values['base'] = $line[4]; |
|
| 335 | + $values['owner'] = $line[5]; |
|
| 336 | + if ($line[6] == '') $values['date_first_reg'] = ''; |
|
| 337 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 338 | + $values['cancel'] = $line[7]; |
|
| 339 | 339 | } elseif ($country == 'EI') { |
| 340 | - // TODO : add modeS & reg to aircraft_modes |
|
| 341 | - $values['registration'] = $line[0]; |
|
| 342 | - $values['base'] = $line[3]; |
|
| 343 | - $values['owner'] = $line[2]; |
|
| 344 | - if ($line[1] == '') $values['date_first_reg'] = ''; |
|
| 345 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
| 346 | - $values['cancel'] = ''; |
|
| 340 | + // TODO : add modeS & reg to aircraft_modes |
|
| 341 | + $values['registration'] = $line[0]; |
|
| 342 | + $values['base'] = $line[3]; |
|
| 343 | + $values['owner'] = $line[2]; |
|
| 344 | + if ($line[1] == '') $values['date_first_reg'] = ''; |
|
| 345 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
| 346 | + $values['cancel'] = ''; |
|
| 347 | 347 | } elseif ($country == 'HB') { |
| 348 | - // TODO : add modeS & reg to aircraft_modes |
|
| 349 | - $values['registration'] = $line[0]; |
|
| 350 | - $values['base'] = null; |
|
| 351 | - $values['owner'] = $line[5]; |
|
| 352 | - $values['date_first_reg'] = ''; |
|
| 353 | - $values['cancel'] = ''; |
|
| 348 | + // TODO : add modeS & reg to aircraft_modes |
|
| 349 | + $values['registration'] = $line[0]; |
|
| 350 | + $values['base'] = null; |
|
| 351 | + $values['owner'] = $line[5]; |
|
| 352 | + $values['date_first_reg'] = ''; |
|
| 353 | + $values['cancel'] = ''; |
|
| 354 | 354 | } elseif ($country == 'OK') { |
| 355 | - // TODO : add modeS & reg to aircraft_modes |
|
| 356 | - $values['registration'] = $line[3]; |
|
| 357 | - $values['base'] = null; |
|
| 358 | - $values['owner'] = $line[5]; |
|
| 359 | - if ($line[18] == '') $values['date_first_reg'] = ''; |
|
| 360 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
| 361 | - $values['cancel'] = ''; |
|
| 355 | + // TODO : add modeS & reg to aircraft_modes |
|
| 356 | + $values['registration'] = $line[3]; |
|
| 357 | + $values['base'] = null; |
|
| 358 | + $values['owner'] = $line[5]; |
|
| 359 | + if ($line[18] == '') $values['date_first_reg'] = ''; |
|
| 360 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
| 361 | + $values['cancel'] = ''; |
|
| 362 | 362 | } elseif ($country == 'VH') { |
| 363 | - // TODO : add modeS & reg to aircraft_modes |
|
| 364 | - $values['registration'] = $line[0]; |
|
| 365 | - $values['base'] = null; |
|
| 366 | - $values['owner'] = $line[12]; |
|
| 367 | - if ($line[28] == '') $values['date_first_reg'] = ''; |
|
| 368 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
| 369 | - |
|
| 370 | - $values['cancel'] = $line[39]; |
|
| 363 | + // TODO : add modeS & reg to aircraft_modes |
|
| 364 | + $values['registration'] = $line[0]; |
|
| 365 | + $values['base'] = null; |
|
| 366 | + $values['owner'] = $line[12]; |
|
| 367 | + if ($line[28] == '') $values['date_first_reg'] = ''; |
|
| 368 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
| 369 | + |
|
| 370 | + $values['cancel'] = $line[39]; |
|
| 371 | 371 | } elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { |
| 372 | - $values['registration'] = $line[0]; |
|
| 373 | - $values['base'] = null; |
|
| 374 | - $values['owner'] = $line[4]; |
|
| 375 | - $values['date_first_reg'] = null; |
|
| 376 | - $values['cancel'] = ''; |
|
| 372 | + $values['registration'] = $line[0]; |
|
| 373 | + $values['base'] = null; |
|
| 374 | + $values['owner'] = $line[4]; |
|
| 375 | + $values['date_first_reg'] = null; |
|
| 376 | + $values['cancel'] = ''; |
|
| 377 | 377 | } elseif ($country == 'CC') { |
| 378 | - $values['registration'] = $line[0]; |
|
| 379 | - $values['base'] = null; |
|
| 380 | - $values['owner'] = $line[6]; |
|
| 381 | - $values['date_first_reg'] = null; |
|
| 382 | - $values['cancel'] = ''; |
|
| 378 | + $values['registration'] = $line[0]; |
|
| 379 | + $values['base'] = null; |
|
| 380 | + $values['owner'] = $line[6]; |
|
| 381 | + $values['date_first_reg'] = null; |
|
| 382 | + $values['cancel'] = ''; |
|
| 383 | 383 | } elseif ($country == 'HJ') { |
| 384 | - $values['registration'] = $line[0]; |
|
| 385 | - $values['base'] = null; |
|
| 386 | - $values['owner'] = $line[8]; |
|
| 387 | - if ($line[7] == '') $values['date_first_reg'] = ''; |
|
| 388 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 389 | - $values['cancel'] = ''; |
|
| 384 | + $values['registration'] = $line[0]; |
|
| 385 | + $values['base'] = null; |
|
| 386 | + $values['owner'] = $line[8]; |
|
| 387 | + if ($line[7] == '') $values['date_first_reg'] = ''; |
|
| 388 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 389 | + $values['cancel'] = ''; |
|
| 390 | 390 | } elseif ($country == 'PP') { |
| 391 | - $values['registration'] = $line[0]; |
|
| 392 | - $values['base'] = null; |
|
| 393 | - $values['owner'] = $line[4]; |
|
| 394 | - if ($line[6] == '') $values['date_first_reg'] = ''; |
|
| 395 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 396 | - $values['cancel'] = $line[7]; |
|
| 391 | + $values['registration'] = $line[0]; |
|
| 392 | + $values['base'] = null; |
|
| 393 | + $values['owner'] = $line[4]; |
|
| 394 | + if ($line[6] == '') $values['date_first_reg'] = ''; |
|
| 395 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 396 | + $values['cancel'] = $line[7]; |
|
| 397 | 397 | } elseif ($country == 'E7') { |
| 398 | - $values['registration'] = $line[0]; |
|
| 399 | - $values['base'] = null; |
|
| 400 | - $values['owner'] = $line[4]; |
|
| 401 | - if ($line[5] == '') $values['date_first_reg'] = ''; |
|
| 402 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
| 403 | - $values['cancel'] = ''; |
|
| 398 | + $values['registration'] = $line[0]; |
|
| 399 | + $values['base'] = null; |
|
| 400 | + $values['owner'] = $line[4]; |
|
| 401 | + if ($line[5] == '') $values['date_first_reg'] = ''; |
|
| 402 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
| 403 | + $values['cancel'] = ''; |
|
| 404 | 404 | } elseif ($country == '8Q') { |
| 405 | - $values['registration'] = $line[0]; |
|
| 406 | - $values['base'] = null; |
|
| 407 | - $values['owner'] = $line[3]; |
|
| 408 | - if ($line[7] == '') $values['date_first_reg'] = ''; |
|
| 409 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 410 | - $values['cancel'] = ''; |
|
| 405 | + $values['registration'] = $line[0]; |
|
| 406 | + $values['base'] = null; |
|
| 407 | + $values['owner'] = $line[3]; |
|
| 408 | + if ($line[7] == '') $values['date_first_reg'] = ''; |
|
| 409 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 410 | + $values['cancel'] = ''; |
|
| 411 | 411 | } elseif ($country == 'ZK' || $country == 'OM' || $country == 'TF') { |
| 412 | - $values['registration'] = $line[0]; |
|
| 413 | - $values['base'] = null; |
|
| 414 | - $values['owner'] = $line[3]; |
|
| 415 | - $values['date_first_reg'] = ''; |
|
| 416 | - $values['cancel'] = ''; |
|
| 412 | + $values['registration'] = $line[0]; |
|
| 413 | + $values['base'] = null; |
|
| 414 | + $values['owner'] = $line[3]; |
|
| 415 | + $values['date_first_reg'] = ''; |
|
| 416 | + $values['cancel'] = ''; |
|
| 417 | 417 | } |
| 418 | 418 | if ($values['cancel'] == '' && $values['registration'] != null) { |
| 419 | 419 | $query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file); |
@@ -535,20 +535,20 @@ discard block |
||
| 535 | 535 | try { |
| 536 | 536 | $Connection = new Connection(); |
| 537 | 537 | $sth = $Connection->db->prepare($query); |
| 538 | - $sth->execute(); |
|
| 539 | - } catch(PDOException $e) { |
|
| 540 | - return "error : ".$e->getMessage(); |
|
| 541 | - } |
|
| 538 | + $sth->execute(); |
|
| 539 | + } catch(PDOException $e) { |
|
| 540 | + return "error : ".$e->getMessage(); |
|
| 541 | + } |
|
| 542 | 542 | |
| 543 | 543 | |
| 544 | 544 | $query = 'ALTER TABLE airport DROP INDEX icaoidx'; |
| 545 | 545 | try { |
| 546 | 546 | $Connection = new Connection(); |
| 547 | 547 | $sth = $Connection->db->prepare($query); |
| 548 | - $sth->execute(); |
|
| 549 | - } catch(PDOException $e) { |
|
| 550 | - return "error : ".$e->getMessage(); |
|
| 551 | - } |
|
| 548 | + $sth->execute(); |
|
| 549 | + } catch(PDOException $e) { |
|
| 550 | + return "error : ".$e->getMessage(); |
|
| 551 | + } |
|
| 552 | 552 | |
| 553 | 553 | $query_dest = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image_thumb`,`image`) |
| 554 | 554 | VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)"; |
@@ -614,10 +614,10 @@ discard block |
||
| 614 | 614 | try { |
| 615 | 615 | $Connection = new Connection(); |
| 616 | 616 | $sth = $Connection->db->prepare($query); |
| 617 | - $sth->execute(); |
|
| 618 | - } catch(PDOException $e) { |
|
| 619 | - return "error : ".$e->getMessage(); |
|
| 620 | - } |
|
| 617 | + $sth->execute(); |
|
| 618 | + } catch(PDOException $e) { |
|
| 619 | + return "error : ".$e->getMessage(); |
|
| 620 | + } |
|
| 621 | 621 | |
| 622 | 622 | |
| 623 | 623 | if ($globalDebug) echo "Insert Not available Airport...\n"; |
@@ -627,10 +627,10 @@ discard block |
||
| 627 | 627 | try { |
| 628 | 628 | $Connection = new Connection(); |
| 629 | 629 | $sth = $Connection->db->prepare($query); |
| 630 | - $sth->execute($query_values); |
|
| 631 | - } catch(PDOException $e) { |
|
| 632 | - return "error : ".$e->getMessage(); |
|
| 633 | - } |
|
| 630 | + $sth->execute($query_values); |
|
| 631 | + } catch(PDOException $e) { |
|
| 632 | + return "error : ".$e->getMessage(); |
|
| 633 | + } |
|
| 634 | 634 | $i++; |
| 635 | 635 | /* |
| 636 | 636 | $query = 'DELETE FROM airport WHERE airport_id IN (SELECT * FROM (SELECT min(a.airport_id) FROM airport a GROUP BY a.icao) x)'; |
@@ -744,7 +744,7 @@ discard block |
||
| 744 | 744 | |
| 745 | 745 | |
| 746 | 746 | |
| 747 | - return "success"; |
|
| 747 | + return "success"; |
|
| 748 | 748 | } |
| 749 | 749 | |
| 750 | 750 | public static function translation() { |
@@ -760,10 +760,10 @@ discard block |
||
| 760 | 760 | try { |
| 761 | 761 | $Connection = new Connection(); |
| 762 | 762 | $sth = $Connection->db->prepare($query); |
| 763 | - $sth->execute(array(':source' => 'translation.csv')); |
|
| 764 | - } catch(PDOException $e) { |
|
| 765 | - return "error : ".$e->getMessage(); |
|
| 766 | - } |
|
| 763 | + $sth->execute(array(':source' => 'translation.csv')); |
|
| 764 | + } catch(PDOException $e) { |
|
| 765 | + return "error : ".$e->getMessage(); |
|
| 766 | + } |
|
| 767 | 767 | |
| 768 | 768 | |
| 769 | 769 | //update_db::unzip($out_file); |
@@ -782,21 +782,21 @@ discard block |
||
| 782 | 782 | $data = $row; |
| 783 | 783 | $operator = $data[2]; |
| 784 | 784 | if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) { |
| 785 | - $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2)); |
|
| 786 | - //echo substr($operator, 0, 2)."\n";; |
|
| 787 | - if (count($airline_array) > 0) { |
|
| 785 | + $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2)); |
|
| 786 | + //echo substr($operator, 0, 2)."\n";; |
|
| 787 | + if (count($airline_array) > 0) { |
|
| 788 | 788 | //print_r($airline_array); |
| 789 | 789 | $operator = $airline_array[0]['icao'].substr($operator,2); |
| 790 | - } |
|
| 791 | - } |
|
| 790 | + } |
|
| 791 | + } |
|
| 792 | 792 | |
| 793 | 793 | $operator_correct = $data[3]; |
| 794 | 794 | if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) { |
| 795 | - $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2)); |
|
| 796 | - if (count($airline_array) > 0) { |
|
| 797 | - $operator_correct = $airline_array[0]['icao'].substr($operator_correct,2); |
|
| 798 | - } |
|
| 799 | - } |
|
| 795 | + $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2)); |
|
| 796 | + if (count($airline_array) > 0) { |
|
| 797 | + $operator_correct = $airline_array[0]['icao'].substr($operator_correct,2); |
|
| 798 | + } |
|
| 799 | + } |
|
| 800 | 800 | $query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)'; |
| 801 | 801 | try { |
| 802 | 802 | $sth = $Connection->db->prepare($query); |
@@ -810,7 +810,7 @@ discard block |
||
| 810 | 810 | //$Connection->db->commit(); |
| 811 | 811 | } |
| 812 | 812 | return ''; |
| 813 | - } |
|
| 813 | + } |
|
| 814 | 814 | |
| 815 | 815 | public static function translation_fam() { |
| 816 | 816 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
@@ -820,10 +820,10 @@ discard block |
||
| 820 | 820 | try { |
| 821 | 821 | $Connection = new Connection(); |
| 822 | 822 | $sth = $Connection->db->prepare($query); |
| 823 | - $sth->execute(array(':source' => 'website_fam')); |
|
| 824 | - } catch(PDOException $e) { |
|
| 825 | - return "error : ".$e->getMessage(); |
|
| 826 | - } |
|
| 823 | + $sth->execute(array(':source' => 'website_fam')); |
|
| 824 | + } catch(PDOException $e) { |
|
| 825 | + return "error : ".$e->getMessage(); |
|
| 826 | + } |
|
| 827 | 827 | |
| 828 | 828 | |
| 829 | 829 | //update_db::unzip($out_file); |
@@ -852,54 +852,54 @@ discard block |
||
| 852 | 852 | //$Connection->db->commit(); |
| 853 | 853 | } |
| 854 | 854 | return ''; |
| 855 | - } |
|
| 855 | + } |
|
| 856 | 856 | |
| 857 | 857 | /** |
| 858 | - * Convert a HTML table to an array |
|
| 859 | - * @param String $data HTML page |
|
| 860 | - * @return Array array of the tables in HTML page |
|
| 861 | - */ |
|
| 862 | - private static function table2array($data) { |
|
| 863 | - $html = str_get_html($data); |
|
| 864 | - $tabledata=array(); |
|
| 865 | - foreach($html->find('tr') as $element) |
|
| 866 | - { |
|
| 867 | - $td = array(); |
|
| 868 | - foreach( $element->find('th') as $row) |
|
| 869 | - { |
|
| 870 | - $td [] = trim($row->plaintext); |
|
| 871 | - } |
|
| 872 | - $td=array_filter($td); |
|
| 873 | - $tabledata[] = $td; |
|
| 874 | - |
|
| 875 | - $td = array(); |
|
| 876 | - $tdi = array(); |
|
| 877 | - foreach( $element->find('td') as $row) |
|
| 878 | - { |
|
| 879 | - $td [] = trim($row->plaintext); |
|
| 880 | - $tdi [] = trim($row->innertext); |
|
| 881 | - } |
|
| 882 | - $td=array_filter($td); |
|
| 883 | - $tdi=array_filter($tdi); |
|
| 884 | - // $tabledata[]=array_merge($td,$tdi); |
|
| 885 | - $tabledata[]=$td; |
|
| 886 | - } |
|
| 887 | - return(array_filter($tabledata)); |
|
| 888 | - } |
|
| 889 | - |
|
| 890 | - /** |
|
| 891 | - * Get data from form result |
|
| 892 | - * @param String $url form URL |
|
| 893 | - * @return String the result |
|
| 894 | - */ |
|
| 895 | - private static function getData($url) { |
|
| 896 | - $ch = curl_init(); |
|
| 897 | - curl_setopt($ch, CURLOPT_URL, $url); |
|
| 898 | - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
| 899 | - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
|
| 900 | - 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'); |
|
| 901 | - return curl_exec($ch); |
|
| 902 | - } |
|
| 858 | + * Convert a HTML table to an array |
|
| 859 | + * @param String $data HTML page |
|
| 860 | + * @return Array array of the tables in HTML page |
|
| 861 | + */ |
|
| 862 | + private static function table2array($data) { |
|
| 863 | + $html = str_get_html($data); |
|
| 864 | + $tabledata=array(); |
|
| 865 | + foreach($html->find('tr') as $element) |
|
| 866 | + { |
|
| 867 | + $td = array(); |
|
| 868 | + foreach( $element->find('th') as $row) |
|
| 869 | + { |
|
| 870 | + $td [] = trim($row->plaintext); |
|
| 871 | + } |
|
| 872 | + $td=array_filter($td); |
|
| 873 | + $tabledata[] = $td; |
|
| 874 | + |
|
| 875 | + $td = array(); |
|
| 876 | + $tdi = array(); |
|
| 877 | + foreach( $element->find('td') as $row) |
|
| 878 | + { |
|
| 879 | + $td [] = trim($row->plaintext); |
|
| 880 | + $tdi [] = trim($row->innertext); |
|
| 881 | + } |
|
| 882 | + $td=array_filter($td); |
|
| 883 | + $tdi=array_filter($tdi); |
|
| 884 | + // $tabledata[]=array_merge($td,$tdi); |
|
| 885 | + $tabledata[]=$td; |
|
| 886 | + } |
|
| 887 | + return(array_filter($tabledata)); |
|
| 888 | + } |
|
| 889 | + |
|
| 890 | + /** |
|
| 891 | + * Get data from form result |
|
| 892 | + * @param String $url form URL |
|
| 893 | + * @return String the result |
|
| 894 | + */ |
|
| 895 | + private static function getData($url) { |
|
| 896 | + $ch = curl_init(); |
|
| 897 | + curl_setopt($ch, CURLOPT_URL, $url); |
|
| 898 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
| 899 | + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
|
| 900 | + 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'); |
|
| 901 | + return curl_exec($ch); |
|
| 902 | + } |
|
| 903 | 903 | /* |
| 904 | 904 | public static function waypoints() { |
| 905 | 905 | $data = update_db::getData('http://www.fallingrain.com/world/FR/waypoints.html'); |
@@ -949,10 +949,10 @@ discard block |
||
| 949 | 949 | try { |
| 950 | 950 | $Connection = new Connection(); |
| 951 | 951 | $sth = $Connection->db->prepare($query); |
| 952 | - $sth->execute(); |
|
| 953 | - } catch(PDOException $e) { |
|
| 954 | - return "error : ".$e->getMessage(); |
|
| 955 | - } |
|
| 952 | + $sth->execute(); |
|
| 953 | + } catch(PDOException $e) { |
|
| 954 | + return "error : ".$e->getMessage(); |
|
| 955 | + } |
|
| 956 | 956 | |
| 957 | 957 | |
| 958 | 958 | //update_db::unzip($out_file); |
@@ -993,7 +993,7 @@ discard block |
||
| 993 | 993 | if ($globalTransaction) $Connection->db->commit(); |
| 994 | 994 | } |
| 995 | 995 | return ''; |
| 996 | - } |
|
| 996 | + } |
|
| 997 | 997 | |
| 998 | 998 | public static function ivao_airlines($filename) { |
| 999 | 999 | //require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
@@ -1002,10 +1002,10 @@ discard block |
||
| 1002 | 1002 | try { |
| 1003 | 1003 | $Connection = new Connection(); |
| 1004 | 1004 | $sth = $Connection->db->prepare($query); |
| 1005 | - $sth->execute(); |
|
| 1006 | - } catch(PDOException $e) { |
|
| 1007 | - return "error : ".$e->getMessage(); |
|
| 1008 | - } |
|
| 1005 | + $sth->execute(); |
|
| 1006 | + } catch(PDOException $e) { |
|
| 1007 | + return "error : ".$e->getMessage(); |
|
| 1008 | + } |
|
| 1009 | 1009 | |
| 1010 | 1010 | $header = NULL; |
| 1011 | 1011 | $delimiter = ':'; |
@@ -1029,7 +1029,7 @@ discard block |
||
| 1029 | 1029 | if ($globalTransaction) $Connection->db->commit(); |
| 1030 | 1030 | } |
| 1031 | 1031 | return ''; |
| 1032 | - } |
|
| 1032 | + } |
|
| 1033 | 1033 | |
| 1034 | 1034 | public static function update_airspace() { |
| 1035 | 1035 | global $tmp_dir, $globalDBdriver; |
@@ -1064,10 +1064,10 @@ discard block |
||
| 1064 | 1064 | $query = 'DROP TABLE countries'; |
| 1065 | 1065 | try { |
| 1066 | 1066 | $sth = $Connection->db->prepare($query); |
| 1067 | - $sth->execute(); |
|
| 1068 | - } catch(PDOException $e) { |
|
| 1069 | - echo "error : ".$e->getMessage(); |
|
| 1070 | - } |
|
| 1067 | + $sth->execute(); |
|
| 1068 | + } catch(PDOException $e) { |
|
| 1069 | + echo "error : ".$e->getMessage(); |
|
| 1070 | + } |
|
| 1071 | 1071 | } |
| 1072 | 1072 | if ($globalDBdriver == 'mysql') { |
| 1073 | 1073 | update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql'); |
@@ -1412,12 +1412,12 @@ discard block |
||
| 1412 | 1412 | echo $data; |
| 1413 | 1413 | */ |
| 1414 | 1414 | if (file_exists($tmp_dir.'aircrafts.html')) { |
| 1415 | - //var_dump(file_get_html($tmp_dir.'aircrafts.html')); |
|
| 1416 | - $fh = fopen($tmp_dir.'aircrafts.html',"r"); |
|
| 1417 | - $result = fread($fh,100000000); |
|
| 1418 | - //echo $result; |
|
| 1419 | - //var_dump(str_get_html($result)); |
|
| 1420 | - //print_r(self::table2array($result)); |
|
| 1415 | + //var_dump(file_get_html($tmp_dir.'aircrafts.html')); |
|
| 1416 | + $fh = fopen($tmp_dir.'aircrafts.html',"r"); |
|
| 1417 | + $result = fread($fh,100000000); |
|
| 1418 | + //echo $result; |
|
| 1419 | + //var_dump(str_get_html($result)); |
|
| 1420 | + //print_r(self::table2array($result)); |
|
| 1421 | 1421 | } |
| 1422 | 1422 | |
| 1423 | 1423 | } |
@@ -1431,10 +1431,10 @@ discard block |
||
| 1431 | 1431 | try { |
| 1432 | 1432 | $Connection = new Connection(); |
| 1433 | 1433 | $sth = $Connection->db->prepare($query); |
| 1434 | - $sth->execute(); |
|
| 1435 | - } catch(PDOException $e) { |
|
| 1436 | - return "error : ".$e->getMessage(); |
|
| 1437 | - } |
|
| 1434 | + $sth->execute(); |
|
| 1435 | + } catch(PDOException $e) { |
|
| 1436 | + return "error : ".$e->getMessage(); |
|
| 1437 | + } |
|
| 1438 | 1438 | |
| 1439 | 1439 | $error = ''; |
| 1440 | 1440 | if ($globalDebug) echo "Notam : Download..."; |
@@ -1490,8 +1490,8 @@ discard block |
||
| 1490 | 1490 | $data['date_end'] = date("Y-m-d H:i:s",strtotime($to)); |
| 1491 | 1491 | $data['permanent'] = 0; |
| 1492 | 1492 | } else { |
| 1493 | - $data['date_end'] = NULL; |
|
| 1494 | - $data['permanent'] = 1; |
|
| 1493 | + $data['date_end'] = NULL; |
|
| 1494 | + $data['permanent'] = 1; |
|
| 1495 | 1495 | } |
| 1496 | 1496 | $data['full_notam'] = $notam['title'].'<br>'.$notam['description']; |
| 1497 | 1497 | $NOTAM = new NOTAM(); |
@@ -1515,13 +1515,13 @@ discard block |
||
| 1515 | 1515 | try { |
| 1516 | 1516 | $Connection = new Connection(); |
| 1517 | 1517 | $sth = $Connection->db->prepare($query); |
| 1518 | - $sth->execute(); |
|
| 1519 | - } catch(PDOException $e) { |
|
| 1520 | - return "error : ".$e->getMessage(); |
|
| 1521 | - } |
|
| 1522 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 1523 | - if ($row['nb'] > 0) return false; |
|
| 1524 | - else return true; |
|
| 1518 | + $sth->execute(); |
|
| 1519 | + } catch(PDOException $e) { |
|
| 1520 | + return "error : ".$e->getMessage(); |
|
| 1521 | + } |
|
| 1522 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 1523 | + if ($row['nb'] > 0) return false; |
|
| 1524 | + else return true; |
|
| 1525 | 1525 | } |
| 1526 | 1526 | |
| 1527 | 1527 | public static function insert_last_update() { |
@@ -1530,10 +1530,10 @@ discard block |
||
| 1530 | 1530 | try { |
| 1531 | 1531 | $Connection = new Connection(); |
| 1532 | 1532 | $sth = $Connection->db->prepare($query); |
| 1533 | - $sth->execute(); |
|
| 1534 | - } catch(PDOException $e) { |
|
| 1535 | - return "error : ".$e->getMessage(); |
|
| 1536 | - } |
|
| 1533 | + $sth->execute(); |
|
| 1534 | + } catch(PDOException $e) { |
|
| 1535 | + return "error : ".$e->getMessage(); |
|
| 1536 | + } |
|
| 1537 | 1537 | } |
| 1538 | 1538 | |
| 1539 | 1539 | public static function check_last_notam_update() { |
@@ -1546,13 +1546,13 @@ discard block |
||
| 1546 | 1546 | try { |
| 1547 | 1547 | $Connection = new Connection(); |
| 1548 | 1548 | $sth = $Connection->db->prepare($query); |
| 1549 | - $sth->execute(); |
|
| 1550 | - } catch(PDOException $e) { |
|
| 1551 | - return "error : ".$e->getMessage(); |
|
| 1552 | - } |
|
| 1553 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 1554 | - if ($row['nb'] > 0) return false; |
|
| 1555 | - else return true; |
|
| 1549 | + $sth->execute(); |
|
| 1550 | + } catch(PDOException $e) { |
|
| 1551 | + return "error : ".$e->getMessage(); |
|
| 1552 | + } |
|
| 1553 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 1554 | + if ($row['nb'] > 0) return false; |
|
| 1555 | + else return true; |
|
| 1556 | 1556 | } |
| 1557 | 1557 | |
| 1558 | 1558 | public static function insert_last_notam_update() { |
@@ -1561,10 +1561,10 @@ discard block |
||
| 1561 | 1561 | try { |
| 1562 | 1562 | $Connection = new Connection(); |
| 1563 | 1563 | $sth = $Connection->db->prepare($query); |
| 1564 | - $sth->execute(); |
|
| 1565 | - } catch(PDOException $e) { |
|
| 1566 | - return "error : ".$e->getMessage(); |
|
| 1567 | - } |
|
| 1564 | + $sth->execute(); |
|
| 1565 | + } catch(PDOException $e) { |
|
| 1566 | + return "error : ".$e->getMessage(); |
|
| 1567 | + } |
|
| 1568 | 1568 | } |
| 1569 | 1569 | |
| 1570 | 1570 | public static function check_last_owner_update() { |
@@ -1577,13 +1577,13 @@ discard block |
||
| 1577 | 1577 | try { |
| 1578 | 1578 | $Connection = new Connection(); |
| 1579 | 1579 | $sth = $Connection->db->prepare($query); |
| 1580 | - $sth->execute(); |
|
| 1581 | - } catch(PDOException $e) { |
|
| 1582 | - return "error : ".$e->getMessage(); |
|
| 1583 | - } |
|
| 1584 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 1585 | - if ($row['nb'] > 0) return false; |
|
| 1586 | - else return true; |
|
| 1580 | + $sth->execute(); |
|
| 1581 | + } catch(PDOException $e) { |
|
| 1582 | + return "error : ".$e->getMessage(); |
|
| 1583 | + } |
|
| 1584 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 1585 | + if ($row['nb'] > 0) return false; |
|
| 1586 | + else return true; |
|
| 1587 | 1587 | } |
| 1588 | 1588 | |
| 1589 | 1589 | public static function insert_last_owner_update() { |
@@ -1592,10 +1592,10 @@ discard block |
||
| 1592 | 1592 | try { |
| 1593 | 1593 | $Connection = new Connection(); |
| 1594 | 1594 | $sth = $Connection->db->prepare($query); |
| 1595 | - $sth->execute(); |
|
| 1596 | - } catch(PDOException $e) { |
|
| 1597 | - return "error : ".$e->getMessage(); |
|
| 1598 | - } |
|
| 1595 | + $sth->execute(); |
|
| 1596 | + } catch(PDOException $e) { |
|
| 1597 | + return "error : ".$e->getMessage(); |
|
| 1598 | + } |
|
| 1599 | 1599 | } |
| 1600 | 1600 | |
| 1601 | 1601 | public static function update_all() { |
@@ -16,7 +16,9 @@ discard block |
||
| 16 | 16 | curl_setopt($ch, CURLOPT_URL, $url); |
| 17 | 17 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
| 18 | 18 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
| 19 | - if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
| 19 | + if ($referer != '') { |
|
| 20 | + curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
| 21 | + } |
|
| 20 | 22 | curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5'); |
| 21 | 23 | curl_setopt($ch, CURLOPT_FILE, $fp); |
| 22 | 24 | $data = curl_exec($ch); |
@@ -26,11 +28,16 @@ discard block |
||
| 26 | 28 | public static function gunzip($in_file,$out_file_name = '') { |
| 27 | 29 | //echo $in_file.' -> '.$out_file_name."\n"; |
| 28 | 30 | $buffer_size = 4096; // read 4kb at a time |
| 29 | - if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); |
|
| 31 | + if ($out_file_name == '') { |
|
| 32 | + $out_file_name = str_replace('.gz', '', $in_file); |
|
| 33 | + } |
|
| 30 | 34 | if ($in_file != '' && file_exists($in_file)) { |
| 31 | 35 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
| 32 | - if (function_exists('gzopen')) $file = gzopen($in_file,'rb'); |
|
| 33 | - elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb'); |
|
| 36 | + if (function_exists('gzopen')) { |
|
| 37 | + $file = gzopen($in_file,'rb'); |
|
| 38 | + } elseif (function_exists('gzopen64')) { |
|
| 39 | + $file = gzopen64($in_file,'rb'); |
|
| 40 | + } |
|
| 34 | 41 | $out_file = fopen($out_file_name, 'wb'); |
| 35 | 42 | while(!gzeof($file)) { |
| 36 | 43 | fwrite($out_file, gzread($file, $buffer_size)); |
@@ -48,8 +55,12 @@ discard block |
||
| 48 | 55 | if ($res === TRUE) { |
| 49 | 56 | $zip->extractTo($path); |
| 50 | 57 | $zip->close(); |
| 51 | - } else return false; |
|
| 52 | - } else return false; |
|
| 58 | + } else { |
|
| 59 | + return false; |
|
| 60 | + } |
|
| 61 | + } else { |
|
| 62 | + return false; |
|
| 63 | + } |
|
| 53 | 64 | } |
| 54 | 65 | |
| 55 | 66 | public static function connect_sqlite($database) { |
@@ -64,7 +75,9 @@ discard block |
||
| 64 | 75 | public static function retrieve_route_sqlite_to_dest($database_file) { |
| 65 | 76 | global $globalDebug, $globalTransaction; |
| 66 | 77 | //$query = 'TRUNCATE TABLE routes'; |
| 67 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
| 78 | + if ($globalDebug) { |
|
| 79 | + echo " - Delete previous routes from DB -"; |
|
| 80 | + } |
|
| 68 | 81 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
| 69 | 82 | $Connection = new Connection(); |
| 70 | 83 | try { |
@@ -75,7 +88,9 @@ discard block |
||
| 75 | 88 | return "error : ".$e->getMessage(); |
| 76 | 89 | } |
| 77 | 90 | |
| 78 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
| 91 | + if ($globalDebug) { |
|
| 92 | + echo " - Add routes to DB -"; |
|
| 93 | + } |
|
| 79 | 94 | update_db::connect_sqlite($database_file); |
| 80 | 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'; |
| 81 | 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"; |
@@ -90,15 +105,21 @@ discard block |
||
| 90 | 105 | $Connection = new Connection(); |
| 91 | 106 | $sth_dest = $Connection->db->prepare($query_dest); |
| 92 | 107 | try { |
| 93 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 108 | + if ($globalTransaction) { |
|
| 109 | + $Connection->db->beginTransaction(); |
|
| 110 | + } |
|
| 94 | 111 | while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
| 95 | 112 | //$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); |
| 96 | 113 | $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); |
| 97 | 114 | $sth_dest->execute($query_dest_values); |
| 98 | 115 | } |
| 99 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 116 | + if ($globalTransaction) { |
|
| 117 | + $Connection->db->commit(); |
|
| 118 | + } |
|
| 100 | 119 | } catch(PDOException $e) { |
| 101 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
| 120 | + if ($globalTransaction) { |
|
| 121 | + $Connection->db->rollBack(); |
|
| 122 | + } |
|
| 102 | 123 | return "error : ".$e->getMessage(); |
| 103 | 124 | } |
| 104 | 125 | return ''; |
@@ -140,11 +161,16 @@ discard block |
||
| 140 | 161 | $sth_dest = $Connection->db->prepare($query_dest); |
| 141 | 162 | $sth_dest_owner = $Connection->db->prepare($query_dest_owner); |
| 142 | 163 | try { |
| 143 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 164 | + if ($globalTransaction) { |
|
| 165 | + $Connection->db->beginTransaction(); |
|
| 166 | + } |
|
| 144 | 167 | while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
| 145 | 168 | //$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']); |
| 146 | - if ($values['UserString4'] == 'M') $type = 'military'; |
|
| 147 | - else $type = null; |
|
| 169 | + if ($values['UserString4'] == 'M') { |
|
| 170 | + $type = 'military'; |
|
| 171 | + } else { |
|
| 172 | + $type = null; |
|
| 173 | + } |
|
| 148 | 174 | $query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type); |
| 149 | 175 | $sth_dest->execute($query_dest_values); |
| 150 | 176 | if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') { |
@@ -152,7 +178,9 @@ discard block |
||
| 152 | 178 | $sth_dest_owner->execute($query_dest_owner_values); |
| 153 | 179 | } |
| 154 | 180 | } |
| 155 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 181 | + if ($globalTransaction) { |
|
| 182 | + $Connection->db->commit(); |
|
| 183 | + } |
|
| 156 | 184 | } catch(PDOException $e) { |
| 157 | 185 | return "error : ".$e->getMessage(); |
| 158 | 186 | } |
@@ -188,7 +216,9 @@ discard block |
||
| 188 | 216 | $Connection = new Connection(); |
| 189 | 217 | $sth_dest = $Connection->db->prepare($query_dest); |
| 190 | 218 | try { |
| 191 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 219 | + if ($globalTransaction) { |
|
| 220 | + $Connection->db->beginTransaction(); |
|
| 221 | + } |
|
| 192 | 222 | while (!feof($fh)) { |
| 193 | 223 | $line = $Common->hex2str(fgets($fh,9999)); |
| 194 | 224 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
@@ -198,7 +228,9 @@ discard block |
||
| 198 | 228 | // Check if we can find ICAO, else set it to GLID |
| 199 | 229 | $aircraft_name_split = explode(' ',$aircraft_name); |
| 200 | 230 | $search_more = ''; |
| 201 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 231 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) { |
|
| 232 | + $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 233 | + } |
|
| 202 | 234 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
| 203 | 235 | $sth_search = $Connection->db->prepare($query_search); |
| 204 | 236 | try { |
@@ -211,7 +243,9 @@ discard block |
||
| 211 | 243 | } catch(PDOException $e) { |
| 212 | 244 | return "error : ".$e->getMessage(); |
| 213 | 245 | } |
| 214 | - if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID'; |
|
| 246 | + if (!isset($values['ICAOTypeCode'])) { |
|
| 247 | + $values['ICAOTypeCode'] = 'GLID'; |
|
| 248 | + } |
|
| 215 | 249 | // Add data to db |
| 216 | 250 | if ($values['ModeS'] != '' && $values['Registration'] != '' && $values['Registration'] != '0000') { |
| 217 | 251 | //$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']); |
@@ -220,7 +254,9 @@ discard block |
||
| 220 | 254 | $sth_dest->execute($query_dest_values); |
| 221 | 255 | } |
| 222 | 256 | } |
| 223 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 257 | + if ($globalTransaction) { |
|
| 258 | + $Connection->db->commit(); |
|
| 259 | + } |
|
| 224 | 260 | } catch(PDOException $e) { |
| 225 | 261 | return "error : ".$e->getMessage(); |
| 226 | 262 | } |
@@ -256,7 +292,9 @@ discard block |
||
| 256 | 292 | $Connection = new Connection(); |
| 257 | 293 | $sth_dest = $Connection->db->prepare($query_dest); |
| 258 | 294 | try { |
| 259 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 295 | + if ($globalTransaction) { |
|
| 296 | + $Connection->db->beginTransaction(); |
|
| 297 | + } |
|
| 260 | 298 | $tmp = fgetcsv($fh,9999,',',"'"); |
| 261 | 299 | while (!feof($fh)) { |
| 262 | 300 | $line = fgetcsv($fh,9999,',',"'"); |
@@ -269,13 +307,17 @@ discard block |
||
| 269 | 307 | // Check if we can find ICAO, else set it to GLID |
| 270 | 308 | $aircraft_name_split = explode(' ',$aircraft_name); |
| 271 | 309 | $search_more = ''; |
| 272 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 310 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) { |
|
| 311 | + $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 312 | + } |
|
| 273 | 313 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
| 274 | 314 | $sth_search = $Connection->db->prepare($query_search); |
| 275 | 315 | try { |
| 276 | 316 | $sth_search->execute(); |
| 277 | 317 | $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
| 278 | - if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
|
| 318 | + if (isset($result['icao']) && $result['icao'] != '') { |
|
| 319 | + $values['ICAOTypeCode'] = $result['icao']; |
|
| 320 | + } |
|
| 279 | 321 | } catch(PDOException $e) { |
| 280 | 322 | return "error : ".$e->getMessage(); |
| 281 | 323 | } |
@@ -288,7 +330,9 @@ discard block |
||
| 288 | 330 | $sth_dest->execute($query_dest_values); |
| 289 | 331 | } |
| 290 | 332 | } |
| 291 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 333 | + if ($globalTransaction) { |
|
| 334 | + $Connection->db->commit(); |
|
| 335 | + } |
|
| 292 | 336 | } catch(PDOException $e) { |
| 293 | 337 | return "error : ".$e->getMessage(); |
| 294 | 338 | } |
@@ -324,7 +368,9 @@ discard block |
||
| 324 | 368 | $Connection = new Connection(); |
| 325 | 369 | $sth_dest = $Connection->db->prepare($query_dest); |
| 326 | 370 | try { |
| 327 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 371 | + if ($globalTransaction) { |
|
| 372 | + $Connection->db->beginTransaction(); |
|
| 373 | + } |
|
| 328 | 374 | $tmp = fgetcsv($fh,9999,',','"'); |
| 329 | 375 | while (!feof($fh)) { |
| 330 | 376 | $line = fgetcsv($fh,9999,',','"'); |
@@ -333,16 +379,22 @@ discard block |
||
| 333 | 379 | $values['registration'] = $line[0]; |
| 334 | 380 | $values['base'] = $line[4]; |
| 335 | 381 | $values['owner'] = $line[5]; |
| 336 | - if ($line[6] == '') $values['date_first_reg'] = ''; |
|
| 337 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 382 | + if ($line[6] == '') { |
|
| 383 | + $values['date_first_reg'] = ''; |
|
| 384 | + } else { |
|
| 385 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 386 | + } |
|
| 338 | 387 | $values['cancel'] = $line[7]; |
| 339 | 388 | } elseif ($country == 'EI') { |
| 340 | 389 | // TODO : add modeS & reg to aircraft_modes |
| 341 | 390 | $values['registration'] = $line[0]; |
| 342 | 391 | $values['base'] = $line[3]; |
| 343 | 392 | $values['owner'] = $line[2]; |
| 344 | - if ($line[1] == '') $values['date_first_reg'] = ''; |
|
| 345 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
| 393 | + if ($line[1] == '') { |
|
| 394 | + $values['date_first_reg'] = ''; |
|
| 395 | + } else { |
|
| 396 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
| 397 | + } |
|
| 346 | 398 | $values['cancel'] = ''; |
| 347 | 399 | } elseif ($country == 'HB') { |
| 348 | 400 | // TODO : add modeS & reg to aircraft_modes |
@@ -356,16 +408,22 @@ discard block |
||
| 356 | 408 | $values['registration'] = $line[3]; |
| 357 | 409 | $values['base'] = null; |
| 358 | 410 | $values['owner'] = $line[5]; |
| 359 | - if ($line[18] == '') $values['date_first_reg'] = ''; |
|
| 360 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
| 411 | + if ($line[18] == '') { |
|
| 412 | + $values['date_first_reg'] = ''; |
|
| 413 | + } else { |
|
| 414 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
| 415 | + } |
|
| 361 | 416 | $values['cancel'] = ''; |
| 362 | 417 | } elseif ($country == 'VH') { |
| 363 | 418 | // TODO : add modeS & reg to aircraft_modes |
| 364 | 419 | $values['registration'] = $line[0]; |
| 365 | 420 | $values['base'] = null; |
| 366 | 421 | $values['owner'] = $line[12]; |
| 367 | - if ($line[28] == '') $values['date_first_reg'] = ''; |
|
| 368 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
| 422 | + if ($line[28] == '') { |
|
| 423 | + $values['date_first_reg'] = ''; |
|
| 424 | + } else { |
|
| 425 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
| 426 | + } |
|
| 369 | 427 | |
| 370 | 428 | $values['cancel'] = $line[39]; |
| 371 | 429 | } elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { |
@@ -384,29 +442,41 @@ discard block |
||
| 384 | 442 | $values['registration'] = $line[0]; |
| 385 | 443 | $values['base'] = null; |
| 386 | 444 | $values['owner'] = $line[8]; |
| 387 | - if ($line[7] == '') $values['date_first_reg'] = ''; |
|
| 388 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 445 | + if ($line[7] == '') { |
|
| 446 | + $values['date_first_reg'] = ''; |
|
| 447 | + } else { |
|
| 448 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 449 | + } |
|
| 389 | 450 | $values['cancel'] = ''; |
| 390 | 451 | } elseif ($country == 'PP') { |
| 391 | 452 | $values['registration'] = $line[0]; |
| 392 | 453 | $values['base'] = null; |
| 393 | 454 | $values['owner'] = $line[4]; |
| 394 | - if ($line[6] == '') $values['date_first_reg'] = ''; |
|
| 395 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 455 | + if ($line[6] == '') { |
|
| 456 | + $values['date_first_reg'] = ''; |
|
| 457 | + } else { |
|
| 458 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 459 | + } |
|
| 396 | 460 | $values['cancel'] = $line[7]; |
| 397 | 461 | } elseif ($country == 'E7') { |
| 398 | 462 | $values['registration'] = $line[0]; |
| 399 | 463 | $values['base'] = null; |
| 400 | 464 | $values['owner'] = $line[4]; |
| 401 | - if ($line[5] == '') $values['date_first_reg'] = ''; |
|
| 402 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
| 465 | + if ($line[5] == '') { |
|
| 466 | + $values['date_first_reg'] = ''; |
|
| 467 | + } else { |
|
| 468 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
| 469 | + } |
|
| 403 | 470 | $values['cancel'] = ''; |
| 404 | 471 | } elseif ($country == '8Q') { |
| 405 | 472 | $values['registration'] = $line[0]; |
| 406 | 473 | $values['base'] = null; |
| 407 | 474 | $values['owner'] = $line[3]; |
| 408 | - if ($line[7] == '') $values['date_first_reg'] = ''; |
|
| 409 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 475 | + if ($line[7] == '') { |
|
| 476 | + $values['date_first_reg'] = ''; |
|
| 477 | + } else { |
|
| 478 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 479 | + } |
|
| 410 | 480 | $values['cancel'] = ''; |
| 411 | 481 | } elseif ($country == 'ZK' || $country == 'OM' || $country == 'TF') { |
| 412 | 482 | $values['registration'] = $line[0]; |
@@ -420,7 +490,9 @@ discard block |
||
| 420 | 490 | $sth_dest->execute($query_dest_values); |
| 421 | 491 | } |
| 422 | 492 | } |
| 423 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 493 | + if ($globalTransaction) { |
|
| 494 | + $Connection->db->commit(); |
|
| 495 | + } |
|
| 424 | 496 | } catch(PDOException $e) { |
| 425 | 497 | return "error : ".$e->getMessage(); |
| 426 | 498 | } |
@@ -554,25 +626,45 @@ discard block |
||
| 554 | 626 | VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)"; |
| 555 | 627 | $Connection = new Connection(); |
| 556 | 628 | $sth_dest = $Connection->db->prepare($query_dest); |
| 557 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 629 | + if ($globalTransaction) { |
|
| 630 | + $Connection->db->beginTransaction(); |
|
| 631 | + } |
|
| 558 | 632 | |
| 559 | 633 | $i = 0; |
| 560 | 634 | while($row = sparql_fetch_array($result)) |
| 561 | 635 | { |
| 562 | 636 | if ($i >= 1) { |
| 563 | 637 | //print_r($row); |
| 564 | - if (!isset($row['iata'])) $row['iata'] = ''; |
|
| 565 | - if (!isset($row['icao'])) $row['icao'] = ''; |
|
| 566 | - if (!isset($row['type'])) $row['type'] = ''; |
|
| 567 | - if (!isset($row['altitude'])) $row['altitude'] = ''; |
|
| 638 | + if (!isset($row['iata'])) { |
|
| 639 | + $row['iata'] = ''; |
|
| 640 | + } |
|
| 641 | + if (!isset($row['icao'])) { |
|
| 642 | + $row['icao'] = ''; |
|
| 643 | + } |
|
| 644 | + if (!isset($row['type'])) { |
|
| 645 | + $row['type'] = ''; |
|
| 646 | + } |
|
| 647 | + if (!isset($row['altitude'])) { |
|
| 648 | + $row['altitude'] = ''; |
|
| 649 | + } |
|
| 568 | 650 | if (isset($row['city_bis'])) { |
| 569 | 651 | $row['city'] = $row['city_bis']; |
| 570 | 652 | } |
| 571 | - if (!isset($row['city'])) $row['city'] = ''; |
|
| 572 | - if (!isset($row['country'])) $row['country'] = ''; |
|
| 573 | - if (!isset($row['homepage'])) $row['homepage'] = ''; |
|
| 574 | - if (!isset($row['wikipedia_page'])) $row['wikipedia_page'] = ''; |
|
| 575 | - if (!isset($row['name'])) continue; |
|
| 653 | + if (!isset($row['city'])) { |
|
| 654 | + $row['city'] = ''; |
|
| 655 | + } |
|
| 656 | + if (!isset($row['country'])) { |
|
| 657 | + $row['country'] = ''; |
|
| 658 | + } |
|
| 659 | + if (!isset($row['homepage'])) { |
|
| 660 | + $row['homepage'] = ''; |
|
| 661 | + } |
|
| 662 | + if (!isset($row['wikipedia_page'])) { |
|
| 663 | + $row['wikipedia_page'] = ''; |
|
| 664 | + } |
|
| 665 | + if (!isset($row['name'])) { |
|
| 666 | + continue; |
|
| 667 | + } |
|
| 576 | 668 | if (!isset($row['image'])) { |
| 577 | 669 | $row['image'] = ''; |
| 578 | 670 | $row['image_thumb'] = ''; |
@@ -608,7 +700,9 @@ discard block |
||
| 608 | 700 | |
| 609 | 701 | $i++; |
| 610 | 702 | } |
| 611 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 703 | + if ($globalTransaction) { |
|
| 704 | + $Connection->db->commit(); |
|
| 705 | + } |
|
| 612 | 706 | echo "Delete duplicate rows...\n"; |
| 613 | 707 | $query = 'ALTER IGNORE TABLE airport ADD UNIQUE INDEX icaoidx (icao)'; |
| 614 | 708 | try { |
@@ -620,7 +714,9 @@ discard block |
||
| 620 | 714 | } |
| 621 | 715 | |
| 622 | 716 | |
| 623 | - if ($globalDebug) echo "Insert Not available Airport...\n"; |
|
| 717 | + if ($globalDebug) { |
|
| 718 | + echo "Insert Not available Airport...\n"; |
|
| 719 | + } |
|
| 624 | 720 | $query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image`,`image_thumb`) |
| 625 | 721 | VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image, :image_thumb)"; |
| 626 | 722 | $query_values = array(':airport_id' => $i, ':name' => 'Not available',':iata' => 'NA',':icao' => 'NA',':latitude' => '0',':longitude' => '0',':altitude' => '0',':type' => 'NA',':city' => 'N/A',':country' => 'N/A',':home_link' => '',':wikipedia_link' => '',':image' => '',':image_thumb' => ''); |
@@ -647,7 +743,9 @@ discard block |
||
| 647 | 743 | $delimiter = ','; |
| 648 | 744 | $out_file = $tmp_dir.'airports.csv'; |
| 649 | 745 | update_db::download('http://ourairports.com/data/airports.csv',$out_file); |
| 650 | - if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
|
| 746 | + if (!file_exists($out_file) || !is_readable($out_file)) { |
|
| 747 | + return FALSE; |
|
| 748 | + } |
|
| 651 | 749 | echo "Add data from ourairports.com...\n"; |
| 652 | 750 | |
| 653 | 751 | $header = NULL; |
@@ -657,8 +755,9 @@ discard block |
||
| 657 | 755 | //$Connection->db->beginTransaction(); |
| 658 | 756 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 659 | 757 | { |
| 660 | - if(!$header) $header = $row; |
|
| 661 | - else { |
|
| 758 | + if(!$header) { |
|
| 759 | + $header = $row; |
|
| 760 | + } else { |
|
| 662 | 761 | $data = array(); |
| 663 | 762 | $data = array_combine($header, $row); |
| 664 | 763 | try { |
@@ -696,7 +795,9 @@ discard block |
||
| 696 | 795 | echo "Download data from another free database...\n"; |
| 697 | 796 | $out_file = $tmp_dir.'GlobalAirportDatabase.zip'; |
| 698 | 797 | update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file); |
| 699 | - if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
|
| 798 | + if (!file_exists($out_file) || !is_readable($out_file)) { |
|
| 799 | + return FALSE; |
|
| 800 | + } |
|
| 700 | 801 | update_db::unzip($out_file); |
| 701 | 802 | $header = NULL; |
| 702 | 803 | echo "Add data from another free database...\n"; |
@@ -707,8 +808,9 @@ discard block |
||
| 707 | 808 | //$Connection->db->beginTransaction(); |
| 708 | 809 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 709 | 810 | { |
| 710 | - if(!$header) $header = $row; |
|
| 711 | - else { |
|
| 811 | + if(!$header) { |
|
| 812 | + $header = $row; |
|
| 813 | + } else { |
|
| 712 | 814 | $data = $row; |
| 713 | 815 | |
| 714 | 816 | $query = 'UPDATE airport SET `city` = :city, `country` = :country WHERE icao = :icao'; |
@@ -962,7 +1064,9 @@ discard block |
||
| 962 | 1064 | if (($handle = fopen($filename, 'r')) !== FALSE) |
| 963 | 1065 | { |
| 964 | 1066 | $i = 0; |
| 965 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1067 | + if ($globalTransaction) { |
|
| 1068 | + $Connection->db->beginTransaction(); |
|
| 1069 | + } |
|
| 966 | 1070 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 967 | 1071 | { |
| 968 | 1072 | $i++; |
@@ -990,7 +1094,9 @@ discard block |
||
| 990 | 1094 | } |
| 991 | 1095 | } |
| 992 | 1096 | fclose($handle); |
| 993 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1097 | + if ($globalTransaction) { |
|
| 1098 | + $Connection->db->commit(); |
|
| 1099 | + } |
|
| 994 | 1100 | } |
| 995 | 1101 | return ''; |
| 996 | 1102 | } |
@@ -1012,7 +1118,9 @@ discard block |
||
| 1012 | 1118 | $Connection = new Connection(); |
| 1013 | 1119 | if (($handle = fopen($filename, 'r')) !== FALSE) |
| 1014 | 1120 | { |
| 1015 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1121 | + if ($globalTransaction) { |
|
| 1122 | + $Connection->db->beginTransaction(); |
|
| 1123 | + } |
|
| 1016 | 1124 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1017 | 1125 | { |
| 1018 | 1126 | if(count($row) > 1) { |
@@ -1026,7 +1134,9 @@ discard block |
||
| 1026 | 1134 | } |
| 1027 | 1135 | } |
| 1028 | 1136 | fclose($handle); |
| 1029 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1137 | + if ($globalTransaction) { |
|
| 1138 | + $Connection->db->commit(); |
|
| 1139 | + } |
|
| 1030 | 1140 | } |
| 1031 | 1141 | return ''; |
| 1032 | 1142 | } |
@@ -1034,8 +1144,9 @@ discard block |
||
| 1034 | 1144 | public static function update_airspace() { |
| 1035 | 1145 | global $tmp_dir, $globalDBdriver; |
| 1036 | 1146 | include_once('class.create_db.php'); |
| 1037 | - if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
| 1038 | - else { |
|
| 1147 | + if ($globalDBdriver == 'mysql') { |
|
| 1148 | + update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
| 1149 | + } else { |
|
| 1039 | 1150 | update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
| 1040 | 1151 | $query = "CREATE EXTENSION postgis"; |
| 1041 | 1152 | try { |
@@ -1099,35 +1210,59 @@ discard block |
||
| 1099 | 1210 | //if ($globalDebug) echo "IVAO : Download..."; |
| 1100 | 1211 | //update_db::download('http://fr.mirror.ivao.aero/software/ivae_feb2013.zip',$tmp_dir.'ivae_feb2013.zip'); |
| 1101 | 1212 | if (file_exists($tmp_dir.'ivae_feb2013.zip')) { |
| 1102 | - if ($globalDebug) echo "Unzip..."; |
|
| 1213 | + if ($globalDebug) { |
|
| 1214 | + echo "Unzip..."; |
|
| 1215 | + } |
|
| 1103 | 1216 | update_db::unzip($tmp_dir.'ivae_feb2013.zip'); |
| 1104 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1217 | + if ($globalDebug) { |
|
| 1218 | + echo "Add to DB..."; |
|
| 1219 | + } |
|
| 1105 | 1220 | update_db::ivao_airlines($tmp_dir.'data/airlines.dat'); |
| 1106 | - if ($globalDebug) echo "Copy airlines logos to airlines images directory..."; |
|
| 1221 | + if ($globalDebug) { |
|
| 1222 | + echo "Copy airlines logos to airlines images directory..."; |
|
| 1223 | + } |
|
| 1107 | 1224 | if (is_writable(dirname(__FILE__).'/../images/airlines')) { |
| 1108 | - if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
| 1109 | - } else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
|
| 1110 | - } else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
|
| 1225 | + if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) { |
|
| 1226 | + $error = "Failed to copy airlines logo."; |
|
| 1227 | + } |
|
| 1228 | + } else { |
|
| 1229 | + $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
|
| 1230 | + } |
|
| 1231 | + } else { |
|
| 1232 | + $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
|
| 1233 | + } |
|
| 1111 | 1234 | if ($error != '') { |
| 1112 | 1235 | return $error; |
| 1113 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1236 | + } elseif ($globalDebug) { |
|
| 1237 | + echo "Done\n"; |
|
| 1238 | + } |
|
| 1114 | 1239 | return ''; |
| 1115 | 1240 | } |
| 1116 | 1241 | |
| 1117 | 1242 | public static function update_routes() { |
| 1118 | 1243 | global $tmp_dir, $globalDebug; |
| 1119 | 1244 | $error = ''; |
| 1120 | - if ($globalDebug) echo "Routes : Download..."; |
|
| 1245 | + if ($globalDebug) { |
|
| 1246 | + echo "Routes : Download..."; |
|
| 1247 | + } |
|
| 1121 | 1248 | update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz'); |
| 1122 | 1249 | if (file_exists($tmp_dir.'StandingData.sqb.gz')) { |
| 1123 | - if ($globalDebug) echo "Gunzip..."; |
|
| 1250 | + if ($globalDebug) { |
|
| 1251 | + echo "Gunzip..."; |
|
| 1252 | + } |
|
| 1124 | 1253 | update_db::gunzip($tmp_dir.'StandingData.sqb.gz'); |
| 1125 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1254 | + if ($globalDebug) { |
|
| 1255 | + echo "Add to DB..."; |
|
| 1256 | + } |
|
| 1126 | 1257 | $error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb'); |
| 1127 | - } else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed."; |
|
| 1258 | + } else { |
|
| 1259 | + $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed."; |
|
| 1260 | + } |
|
| 1128 | 1261 | if ($error != '') { |
| 1129 | 1262 | return $error; |
| 1130 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1263 | + } elseif ($globalDebug) { |
|
| 1264 | + echo "Done\n"; |
|
| 1265 | + } |
|
| 1131 | 1266 | return ''; |
| 1132 | 1267 | } |
| 1133 | 1268 | public static function update_ModeS() { |
@@ -1144,257 +1279,455 @@ discard block |
||
| 1144 | 1279 | exit; |
| 1145 | 1280 | } elseif ($globalDebug) echo "Done\n"; |
| 1146 | 1281 | */ |
| 1147 | - if ($globalDebug) echo "Modes : Download..."; |
|
| 1282 | + if ($globalDebug) { |
|
| 1283 | + echo "Modes : Download..."; |
|
| 1284 | + } |
|
| 1148 | 1285 | update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
| 1149 | 1286 | if (file_exists($tmp_dir.'basestation_latest.zip')) { |
| 1150 | - if ($globalDebug) echo "Unzip..."; |
|
| 1287 | + if ($globalDebug) { |
|
| 1288 | + echo "Unzip..."; |
|
| 1289 | + } |
|
| 1151 | 1290 | update_db::unzip($tmp_dir.'basestation_latest.zip'); |
| 1152 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1291 | + if ($globalDebug) { |
|
| 1292 | + echo "Add to DB..."; |
|
| 1293 | + } |
|
| 1153 | 1294 | $error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb'); |
| 1154 | - } else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed."; |
|
| 1295 | + } else { |
|
| 1296 | + $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed."; |
|
| 1297 | + } |
|
| 1155 | 1298 | if ($error != '') { |
| 1156 | 1299 | return $error; |
| 1157 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1300 | + } elseif ($globalDebug) { |
|
| 1301 | + echo "Done\n"; |
|
| 1302 | + } |
|
| 1158 | 1303 | return ''; |
| 1159 | 1304 | } |
| 1160 | 1305 | |
| 1161 | 1306 | public static function update_ModeS_flarm() { |
| 1162 | 1307 | global $tmp_dir, $globalDebug; |
| 1163 | - if ($globalDebug) echo "Modes Flarmnet: Download..."; |
|
| 1308 | + if ($globalDebug) { |
|
| 1309 | + echo "Modes Flarmnet: Download..."; |
|
| 1310 | + } |
|
| 1164 | 1311 | update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln'); |
| 1165 | 1312 | if (file_exists($tmp_dir.'data.fln')) { |
| 1166 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1313 | + if ($globalDebug) { |
|
| 1314 | + echo "Add to DB..."; |
|
| 1315 | + } |
|
| 1167 | 1316 | $error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln'); |
| 1168 | - } else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed."; |
|
| 1317 | + } else { |
|
| 1318 | + $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed."; |
|
| 1319 | + } |
|
| 1169 | 1320 | if ($error != '') { |
| 1170 | 1321 | return $error; |
| 1171 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1322 | + } elseif ($globalDebug) { |
|
| 1323 | + echo "Done\n"; |
|
| 1324 | + } |
|
| 1172 | 1325 | return ''; |
| 1173 | 1326 | } |
| 1174 | 1327 | |
| 1175 | 1328 | public static function update_ModeS_ogn() { |
| 1176 | 1329 | global $tmp_dir, $globalDebug; |
| 1177 | - if ($globalDebug) echo "Modes OGN: Download..."; |
|
| 1330 | + if ($globalDebug) { |
|
| 1331 | + echo "Modes OGN: Download..."; |
|
| 1332 | + } |
|
| 1178 | 1333 | update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv'); |
| 1179 | 1334 | if (file_exists($tmp_dir.'ogn.csv')) { |
| 1180 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1335 | + if ($globalDebug) { |
|
| 1336 | + echo "Add to DB..."; |
|
| 1337 | + } |
|
| 1181 | 1338 | $error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv'); |
| 1182 | - } else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed."; |
|
| 1339 | + } else { |
|
| 1340 | + $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed."; |
|
| 1341 | + } |
|
| 1183 | 1342 | if ($error != '') { |
| 1184 | 1343 | return $error; |
| 1185 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1344 | + } elseif ($globalDebug) { |
|
| 1345 | + echo "Done\n"; |
|
| 1346 | + } |
|
| 1186 | 1347 | return ''; |
| 1187 | 1348 | } |
| 1188 | 1349 | |
| 1189 | 1350 | public static function update_owner() { |
| 1190 | 1351 | global $tmp_dir, $globalDebug; |
| 1191 | 1352 | |
| 1192 | - if ($globalDebug) echo "Owner France: Download..."; |
|
| 1353 | + if ($globalDebug) { |
|
| 1354 | + echo "Owner France: Download..."; |
|
| 1355 | + } |
|
| 1193 | 1356 | update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv'); |
| 1194 | 1357 | if (file_exists($tmp_dir.'owner_f.csv')) { |
| 1195 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1358 | + if ($globalDebug) { |
|
| 1359 | + echo "Add to DB..."; |
|
| 1360 | + } |
|
| 1196 | 1361 | $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F'); |
| 1197 | - } else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
|
| 1362 | + } else { |
|
| 1363 | + $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
|
| 1364 | + } |
|
| 1198 | 1365 | if ($error != '') { |
| 1199 | 1366 | return $error; |
| 1200 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1367 | + } elseif ($globalDebug) { |
|
| 1368 | + echo "Done\n"; |
|
| 1369 | + } |
|
| 1201 | 1370 | |
| 1202 | - if ($globalDebug) echo "Owner Ireland: Download..."; |
|
| 1371 | + if ($globalDebug) { |
|
| 1372 | + echo "Owner Ireland: Download..."; |
|
| 1373 | + } |
|
| 1203 | 1374 | update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv'); |
| 1204 | 1375 | if (file_exists($tmp_dir.'owner_ei.csv')) { |
| 1205 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1376 | + if ($globalDebug) { |
|
| 1377 | + echo "Add to DB..."; |
|
| 1378 | + } |
|
| 1206 | 1379 | $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI'); |
| 1207 | - } else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
|
| 1380 | + } else { |
|
| 1381 | + $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
|
| 1382 | + } |
|
| 1208 | 1383 | if ($error != '') { |
| 1209 | 1384 | return $error; |
| 1210 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1211 | - if ($globalDebug) echo "Owner Switzerland: Download..."; |
|
| 1385 | + } elseif ($globalDebug) { |
|
| 1386 | + echo "Done\n"; |
|
| 1387 | + } |
|
| 1388 | + if ($globalDebug) { |
|
| 1389 | + echo "Owner Switzerland: Download..."; |
|
| 1390 | + } |
|
| 1212 | 1391 | update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv'); |
| 1213 | 1392 | if (file_exists($tmp_dir.'owner_hb.csv')) { |
| 1214 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1393 | + if ($globalDebug) { |
|
| 1394 | + echo "Add to DB..."; |
|
| 1395 | + } |
|
| 1215 | 1396 | $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB'); |
| 1216 | - } else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
|
| 1397 | + } else { |
|
| 1398 | + $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
|
| 1399 | + } |
|
| 1217 | 1400 | if ($error != '') { |
| 1218 | 1401 | return $error; |
| 1219 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1220 | - if ($globalDebug) echo "Owner Czech Republic: Download..."; |
|
| 1402 | + } elseif ($globalDebug) { |
|
| 1403 | + echo "Done\n"; |
|
| 1404 | + } |
|
| 1405 | + if ($globalDebug) { |
|
| 1406 | + echo "Owner Czech Republic: Download..."; |
|
| 1407 | + } |
|
| 1221 | 1408 | update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv'); |
| 1222 | 1409 | if (file_exists($tmp_dir.'owner_ok.csv')) { |
| 1223 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1410 | + if ($globalDebug) { |
|
| 1411 | + echo "Add to DB..."; |
|
| 1412 | + } |
|
| 1224 | 1413 | $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK'); |
| 1225 | - } else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
|
| 1414 | + } else { |
|
| 1415 | + $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
|
| 1416 | + } |
|
| 1226 | 1417 | if ($error != '') { |
| 1227 | 1418 | return $error; |
| 1228 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1229 | - if ($globalDebug) echo "Owner Australia: Download..."; |
|
| 1419 | + } elseif ($globalDebug) { |
|
| 1420 | + echo "Done\n"; |
|
| 1421 | + } |
|
| 1422 | + if ($globalDebug) { |
|
| 1423 | + echo "Owner Australia: Download..."; |
|
| 1424 | + } |
|
| 1230 | 1425 | update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv'); |
| 1231 | 1426 | if (file_exists($tmp_dir.'owner_vh.csv')) { |
| 1232 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1427 | + if ($globalDebug) { |
|
| 1428 | + echo "Add to DB..."; |
|
| 1429 | + } |
|
| 1233 | 1430 | $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH'); |
| 1234 | - } else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
|
| 1431 | + } else { |
|
| 1432 | + $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
|
| 1433 | + } |
|
| 1235 | 1434 | if ($error != '') { |
| 1236 | 1435 | return $error; |
| 1237 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1238 | - if ($globalDebug) echo "Owner Austria: Download..."; |
|
| 1436 | + } elseif ($globalDebug) { |
|
| 1437 | + echo "Done\n"; |
|
| 1438 | + } |
|
| 1439 | + if ($globalDebug) { |
|
| 1440 | + echo "Owner Austria: Download..."; |
|
| 1441 | + } |
|
| 1239 | 1442 | update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv'); |
| 1240 | 1443 | if (file_exists($tmp_dir.'owner_oe.csv')) { |
| 1241 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1444 | + if ($globalDebug) { |
|
| 1445 | + echo "Add to DB..."; |
|
| 1446 | + } |
|
| 1242 | 1447 | $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE'); |
| 1243 | - } else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
|
| 1448 | + } else { |
|
| 1449 | + $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
|
| 1450 | + } |
|
| 1244 | 1451 | if ($error != '') { |
| 1245 | 1452 | return $error; |
| 1246 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1247 | - if ($globalDebug) echo "Owner Chile: Download..."; |
|
| 1453 | + } elseif ($globalDebug) { |
|
| 1454 | + echo "Done\n"; |
|
| 1455 | + } |
|
| 1456 | + if ($globalDebug) { |
|
| 1457 | + echo "Owner Chile: Download..."; |
|
| 1458 | + } |
|
| 1248 | 1459 | update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv'); |
| 1249 | 1460 | if (file_exists($tmp_dir.'owner_cc.csv')) { |
| 1250 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1461 | + if ($globalDebug) { |
|
| 1462 | + echo "Add to DB..."; |
|
| 1463 | + } |
|
| 1251 | 1464 | $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC'); |
| 1252 | - } else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
|
| 1465 | + } else { |
|
| 1466 | + $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
|
| 1467 | + } |
|
| 1253 | 1468 | if ($error != '') { |
| 1254 | 1469 | return $error; |
| 1255 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1256 | - if ($globalDebug) echo "Owner Colombia: Download..."; |
|
| 1470 | + } elseif ($globalDebug) { |
|
| 1471 | + echo "Done\n"; |
|
| 1472 | + } |
|
| 1473 | + if ($globalDebug) { |
|
| 1474 | + echo "Owner Colombia: Download..."; |
|
| 1475 | + } |
|
| 1257 | 1476 | update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv'); |
| 1258 | 1477 | if (file_exists($tmp_dir.'owner_hj.csv')) { |
| 1259 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1478 | + if ($globalDebug) { |
|
| 1479 | + echo "Add to DB..."; |
|
| 1480 | + } |
|
| 1260 | 1481 | $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ'); |
| 1261 | - } else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
|
| 1482 | + } else { |
|
| 1483 | + $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
|
| 1484 | + } |
|
| 1262 | 1485 | if ($error != '') { |
| 1263 | 1486 | return $error; |
| 1264 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1265 | - if ($globalDebug) echo "Owner Bosnia Herzegobina: Download..."; |
|
| 1487 | + } elseif ($globalDebug) { |
|
| 1488 | + echo "Done\n"; |
|
| 1489 | + } |
|
| 1490 | + if ($globalDebug) { |
|
| 1491 | + echo "Owner Bosnia Herzegobina: Download..."; |
|
| 1492 | + } |
|
| 1266 | 1493 | update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv'); |
| 1267 | 1494 | if (file_exists($tmp_dir.'owner_e7.csv')) { |
| 1268 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1495 | + if ($globalDebug) { |
|
| 1496 | + echo "Add to DB..."; |
|
| 1497 | + } |
|
| 1269 | 1498 | $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7'); |
| 1270 | - } else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
|
| 1499 | + } else { |
|
| 1500 | + $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
|
| 1501 | + } |
|
| 1271 | 1502 | if ($error != '') { |
| 1272 | 1503 | return $error; |
| 1273 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1274 | - if ($globalDebug) echo "Owner Brazil: Download..."; |
|
| 1504 | + } elseif ($globalDebug) { |
|
| 1505 | + echo "Done\n"; |
|
| 1506 | + } |
|
| 1507 | + if ($globalDebug) { |
|
| 1508 | + echo "Owner Brazil: Download..."; |
|
| 1509 | + } |
|
| 1275 | 1510 | update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv'); |
| 1276 | 1511 | if (file_exists($tmp_dir.'owner_pp.csv')) { |
| 1277 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1512 | + if ($globalDebug) { |
|
| 1513 | + echo "Add to DB..."; |
|
| 1514 | + } |
|
| 1278 | 1515 | $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP'); |
| 1279 | - } else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
|
| 1516 | + } else { |
|
| 1517 | + $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
|
| 1518 | + } |
|
| 1280 | 1519 | if ($error != '') { |
| 1281 | 1520 | return $error; |
| 1282 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1283 | - if ($globalDebug) echo "Owner Cayman Islands: Download..."; |
|
| 1521 | + } elseif ($globalDebug) { |
|
| 1522 | + echo "Done\n"; |
|
| 1523 | + } |
|
| 1524 | + if ($globalDebug) { |
|
| 1525 | + echo "Owner Cayman Islands: Download..."; |
|
| 1526 | + } |
|
| 1284 | 1527 | update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv'); |
| 1285 | 1528 | if (file_exists($tmp_dir.'owner_vp.csv')) { |
| 1286 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1529 | + if ($globalDebug) { |
|
| 1530 | + echo "Add to DB..."; |
|
| 1531 | + } |
|
| 1287 | 1532 | $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP'); |
| 1288 | - } else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
|
| 1533 | + } else { |
|
| 1534 | + $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
|
| 1535 | + } |
|
| 1289 | 1536 | if ($error != '') { |
| 1290 | 1537 | return $error; |
| 1291 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1292 | - if ($globalDebug) echo "Owner Croatia: Download..."; |
|
| 1538 | + } elseif ($globalDebug) { |
|
| 1539 | + echo "Done\n"; |
|
| 1540 | + } |
|
| 1541 | + if ($globalDebug) { |
|
| 1542 | + echo "Owner Croatia: Download..."; |
|
| 1543 | + } |
|
| 1293 | 1544 | update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv'); |
| 1294 | 1545 | if (file_exists($tmp_dir.'owner_9a.csv')) { |
| 1295 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1546 | + if ($globalDebug) { |
|
| 1547 | + echo "Add to DB..."; |
|
| 1548 | + } |
|
| 1296 | 1549 | $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A'); |
| 1297 | - } else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
|
| 1550 | + } else { |
|
| 1551 | + $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
|
| 1552 | + } |
|
| 1298 | 1553 | if ($error != '') { |
| 1299 | 1554 | return $error; |
| 1300 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1301 | - if ($globalDebug) echo "Owner Luxembourg: Download..."; |
|
| 1555 | + } elseif ($globalDebug) { |
|
| 1556 | + echo "Done\n"; |
|
| 1557 | + } |
|
| 1558 | + if ($globalDebug) { |
|
| 1559 | + echo "Owner Luxembourg: Download..."; |
|
| 1560 | + } |
|
| 1302 | 1561 | update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv'); |
| 1303 | 1562 | if (file_exists($tmp_dir.'owner_lx.csv')) { |
| 1304 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1563 | + if ($globalDebug) { |
|
| 1564 | + echo "Add to DB..."; |
|
| 1565 | + } |
|
| 1305 | 1566 | $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX'); |
| 1306 | - } else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
|
| 1567 | + } else { |
|
| 1568 | + $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
|
| 1569 | + } |
|
| 1307 | 1570 | if ($error != '') { |
| 1308 | 1571 | return $error; |
| 1309 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1310 | - if ($globalDebug) echo "Owner Maldives: Download..."; |
|
| 1572 | + } elseif ($globalDebug) { |
|
| 1573 | + echo "Done\n"; |
|
| 1574 | + } |
|
| 1575 | + if ($globalDebug) { |
|
| 1576 | + echo "Owner Maldives: Download..."; |
|
| 1577 | + } |
|
| 1311 | 1578 | update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv'); |
| 1312 | 1579 | if (file_exists($tmp_dir.'owner_8q.csv')) { |
| 1313 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1580 | + if ($globalDebug) { |
|
| 1581 | + echo "Add to DB..."; |
|
| 1582 | + } |
|
| 1314 | 1583 | $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q'); |
| 1315 | - } else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
|
| 1584 | + } else { |
|
| 1585 | + $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
|
| 1586 | + } |
|
| 1316 | 1587 | if ($error != '') { |
| 1317 | 1588 | return $error; |
| 1318 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1319 | - if ($globalDebug) echo "Owner New Zealand: Download..."; |
|
| 1589 | + } elseif ($globalDebug) { |
|
| 1590 | + echo "Done\n"; |
|
| 1591 | + } |
|
| 1592 | + if ($globalDebug) { |
|
| 1593 | + echo "Owner New Zealand: Download..."; |
|
| 1594 | + } |
|
| 1320 | 1595 | update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv'); |
| 1321 | 1596 | if (file_exists($tmp_dir.'owner_zk.csv')) { |
| 1322 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1597 | + if ($globalDebug) { |
|
| 1598 | + echo "Add to DB..."; |
|
| 1599 | + } |
|
| 1323 | 1600 | $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK'); |
| 1324 | - } else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
|
| 1601 | + } else { |
|
| 1602 | + $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
|
| 1603 | + } |
|
| 1325 | 1604 | if ($error != '') { |
| 1326 | 1605 | return $error; |
| 1327 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1328 | - if ($globalDebug) echo "Owner Papua New Guinea: Download..."; |
|
| 1606 | + } elseif ($globalDebug) { |
|
| 1607 | + echo "Done\n"; |
|
| 1608 | + } |
|
| 1609 | + if ($globalDebug) { |
|
| 1610 | + echo "Owner Papua New Guinea: Download..."; |
|
| 1611 | + } |
|
| 1329 | 1612 | update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv'); |
| 1330 | 1613 | if (file_exists($tmp_dir.'owner_p2.csv')) { |
| 1331 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1614 | + if ($globalDebug) { |
|
| 1615 | + echo "Add to DB..."; |
|
| 1616 | + } |
|
| 1332 | 1617 | $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2'); |
| 1333 | - } else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
|
| 1618 | + } else { |
|
| 1619 | + $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
|
| 1620 | + } |
|
| 1334 | 1621 | if ($error != '') { |
| 1335 | 1622 | return $error; |
| 1336 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1337 | - if ($globalDebug) echo "Owner Slovakia: Download..."; |
|
| 1623 | + } elseif ($globalDebug) { |
|
| 1624 | + echo "Done\n"; |
|
| 1625 | + } |
|
| 1626 | + if ($globalDebug) { |
|
| 1627 | + echo "Owner Slovakia: Download..."; |
|
| 1628 | + } |
|
| 1338 | 1629 | update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv'); |
| 1339 | 1630 | if (file_exists($tmp_dir.'owner_om.csv')) { |
| 1340 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1631 | + if ($globalDebug) { |
|
| 1632 | + echo "Add to DB..."; |
|
| 1633 | + } |
|
| 1341 | 1634 | $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM'); |
| 1342 | - } else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
|
| 1635 | + } else { |
|
| 1636 | + $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
|
| 1637 | + } |
|
| 1343 | 1638 | if ($error != '') { |
| 1344 | 1639 | return $error; |
| 1345 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1346 | - if ($globalDebug) echo "Owner Ecuador: Download..."; |
|
| 1640 | + } elseif ($globalDebug) { |
|
| 1641 | + echo "Done\n"; |
|
| 1642 | + } |
|
| 1643 | + if ($globalDebug) { |
|
| 1644 | + echo "Owner Ecuador: Download..."; |
|
| 1645 | + } |
|
| 1347 | 1646 | update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv'); |
| 1348 | 1647 | if (file_exists($tmp_dir.'owner_hc.csv')) { |
| 1349 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1648 | + if ($globalDebug) { |
|
| 1649 | + echo "Add to DB..."; |
|
| 1650 | + } |
|
| 1350 | 1651 | $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC'); |
| 1351 | - } else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
|
| 1652 | + } else { |
|
| 1653 | + $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
|
| 1654 | + } |
|
| 1352 | 1655 | if ($error != '') { |
| 1353 | 1656 | return $error; |
| 1354 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1355 | - if ($globalDebug) echo "Owner Iceland: Download..."; |
|
| 1657 | + } elseif ($globalDebug) { |
|
| 1658 | + echo "Done\n"; |
|
| 1659 | + } |
|
| 1660 | + if ($globalDebug) { |
|
| 1661 | + echo "Owner Iceland: Download..."; |
|
| 1662 | + } |
|
| 1356 | 1663 | update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv'); |
| 1357 | 1664 | if (file_exists($tmp_dir.'owner_tf.csv')) { |
| 1358 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1665 | + if ($globalDebug) { |
|
| 1666 | + echo "Add to DB..."; |
|
| 1667 | + } |
|
| 1359 | 1668 | $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF'); |
| 1360 | - } else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
|
| 1669 | + } else { |
|
| 1670 | + $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
|
| 1671 | + } |
|
| 1361 | 1672 | if ($error != '') { |
| 1362 | 1673 | return $error; |
| 1363 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1674 | + } elseif ($globalDebug) { |
|
| 1675 | + echo "Done\n"; |
|
| 1676 | + } |
|
| 1364 | 1677 | return ''; |
| 1365 | 1678 | } |
| 1366 | 1679 | |
| 1367 | 1680 | public static function update_translation() { |
| 1368 | 1681 | global $tmp_dir, $globalDebug; |
| 1369 | 1682 | $error = ''; |
| 1370 | - if ($globalDebug) echo "Translation : Download..."; |
|
| 1683 | + if ($globalDebug) { |
|
| 1684 | + echo "Translation : Download..."; |
|
| 1685 | + } |
|
| 1371 | 1686 | update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip'); |
| 1372 | 1687 | if (file_exists($tmp_dir.'translation.zip')) { |
| 1373 | - if ($globalDebug) echo "Unzip..."; |
|
| 1688 | + if ($globalDebug) { |
|
| 1689 | + echo "Unzip..."; |
|
| 1690 | + } |
|
| 1374 | 1691 | update_db::unzip($tmp_dir.'translation.zip'); |
| 1375 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1692 | + if ($globalDebug) { |
|
| 1693 | + echo "Add to DB..."; |
|
| 1694 | + } |
|
| 1376 | 1695 | $error = update_db::translation(); |
| 1377 | - } else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed."; |
|
| 1696 | + } else { |
|
| 1697 | + $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed."; |
|
| 1698 | + } |
|
| 1378 | 1699 | if ($error != '') { |
| 1379 | 1700 | return $error; |
| 1380 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1701 | + } elseif ($globalDebug) { |
|
| 1702 | + echo "Done\n"; |
|
| 1703 | + } |
|
| 1381 | 1704 | return ''; |
| 1382 | 1705 | } |
| 1383 | 1706 | |
| 1384 | 1707 | public static function update_translation_fam() { |
| 1385 | 1708 | global $tmp_dir, $globalDebug; |
| 1386 | 1709 | $error = ''; |
| 1387 | - if ($globalDebug) echo "Translation from FlightAirMap website : Download..."; |
|
| 1710 | + if ($globalDebug) { |
|
| 1711 | + echo "Translation from FlightAirMap website : Download..."; |
|
| 1712 | + } |
|
| 1388 | 1713 | update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz'); |
| 1389 | 1714 | if (file_exists($tmp_dir.'translation.tsv.gz')) { |
| 1390 | - if ($globalDebug) echo "Gunzip..."; |
|
| 1715 | + if ($globalDebug) { |
|
| 1716 | + echo "Gunzip..."; |
|
| 1717 | + } |
|
| 1391 | 1718 | update_db::gunzip($tmp_dir.'translation.tsv.gz'); |
| 1392 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1719 | + if ($globalDebug) { |
|
| 1720 | + echo "Add to DB..."; |
|
| 1721 | + } |
|
| 1393 | 1722 | $error = update_db::translation_fam(); |
| 1394 | - } else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed."; |
|
| 1723 | + } else { |
|
| 1724 | + $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed."; |
|
| 1725 | + } |
|
| 1395 | 1726 | if ($error != '') { |
| 1396 | 1727 | return $error; |
| 1397 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1728 | + } elseif ($globalDebug) { |
|
| 1729 | + echo "Done\n"; |
|
| 1730 | + } |
|
| 1398 | 1731 | return ''; |
| 1399 | 1732 | } |
| 1400 | 1733 | |
@@ -1437,7 +1770,9 @@ discard block |
||
| 1437 | 1770 | } |
| 1438 | 1771 | |
| 1439 | 1772 | $error = ''; |
| 1440 | - if ($globalDebug) echo "Notam : Download..."; |
|
| 1773 | + if ($globalDebug) { |
|
| 1774 | + echo "Notam : Download..."; |
|
| 1775 | + } |
|
| 1441 | 1776 | update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss'); |
| 1442 | 1777 | if (file_exists($tmp_dir.'notam.rss')) { |
| 1443 | 1778 | $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true); |
@@ -1452,14 +1787,30 @@ discard block |
||
| 1452 | 1787 | $data['fir'] = $q[0]; |
| 1453 | 1788 | $data['code'] = $q[1]; |
| 1454 | 1789 | $ifrvfr = $q[2]; |
| 1455 | - if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR'; |
|
| 1456 | - if ($ifrvfr == 'I') $data['rules'] = 'IFR'; |
|
| 1457 | - if ($ifrvfr == 'V') $data['rules'] = 'VFR'; |
|
| 1458 | - if ($q[4] == 'A') $data['scope'] = 'Airport warning'; |
|
| 1459 | - if ($q[4] == 'E') $data['scope'] = 'Enroute warning'; |
|
| 1460 | - if ($q[4] == 'W') $data['scope'] = 'Navigation warning'; |
|
| 1461 | - if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning'; |
|
| 1462 | - if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning'; |
|
| 1790 | + if ($ifrvfr == 'IV') { |
|
| 1791 | + $data['rules'] = 'IFR/VFR'; |
|
| 1792 | + } |
|
| 1793 | + if ($ifrvfr == 'I') { |
|
| 1794 | + $data['rules'] = 'IFR'; |
|
| 1795 | + } |
|
| 1796 | + if ($ifrvfr == 'V') { |
|
| 1797 | + $data['rules'] = 'VFR'; |
|
| 1798 | + } |
|
| 1799 | + if ($q[4] == 'A') { |
|
| 1800 | + $data['scope'] = 'Airport warning'; |
|
| 1801 | + } |
|
| 1802 | + if ($q[4] == 'E') { |
|
| 1803 | + $data['scope'] = 'Enroute warning'; |
|
| 1804 | + } |
|
| 1805 | + if ($q[4] == 'W') { |
|
| 1806 | + $data['scope'] = 'Navigation warning'; |
|
| 1807 | + } |
|
| 1808 | + if ($q[4] == 'AE') { |
|
| 1809 | + $data['scope'] = 'Airport/Enroute warning'; |
|
| 1810 | + } |
|
| 1811 | + if ($q[4] == 'AW') { |
|
| 1812 | + $data['scope'] = 'Airport/Navigation warning'; |
|
| 1813 | + } |
|
| 1463 | 1814 | //$data['scope'] = $q[4]; |
| 1464 | 1815 | $data['lower_limit'] = $q[5]; |
| 1465 | 1816 | $data['upper_limit'] = $q[6]; |
@@ -1467,8 +1818,12 @@ discard block |
||
| 1467 | 1818 | sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius); |
| 1468 | 1819 | $latitude = $Common->convertDec($las,'latitude'); |
| 1469 | 1820 | $longitude = $Common->convertDec($lns,'longitude'); |
| 1470 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
| 1471 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
| 1821 | + if ($lac == 'S') { |
|
| 1822 | + $latitude = '-'.$latitude; |
|
| 1823 | + } |
|
| 1824 | + if ($lnc == 'W') { |
|
| 1825 | + $longitude = '-'.$longitude; |
|
| 1826 | + } |
|
| 1472 | 1827 | $data['center_latitude'] = $latitude; |
| 1473 | 1828 | $data['center_longitude'] = $longitude; |
| 1474 | 1829 | $data['radius'] = intval($radius); |
@@ -1498,10 +1853,14 @@ discard block |
||
| 1498 | 1853 | $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']); |
| 1499 | 1854 | unset($data); |
| 1500 | 1855 | } |
| 1501 | - } else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
|
| 1856 | + } else { |
|
| 1857 | + $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
|
| 1858 | + } |
|
| 1502 | 1859 | if ($error != '') { |
| 1503 | 1860 | return $error; |
| 1504 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1861 | + } elseif ($globalDebug) { |
|
| 1862 | + echo "Done\n"; |
|
| 1863 | + } |
|
| 1505 | 1864 | return ''; |
| 1506 | 1865 | } |
| 1507 | 1866 | |
@@ -1520,8 +1879,11 @@ discard block |
||
| 1520 | 1879 | return "error : ".$e->getMessage(); |
| 1521 | 1880 | } |
| 1522 | 1881 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 1523 | - if ($row['nb'] > 0) return false; |
|
| 1524 | - else return true; |
|
| 1882 | + if ($row['nb'] > 0) { |
|
| 1883 | + return false; |
|
| 1884 | + } else { |
|
| 1885 | + return true; |
|
| 1886 | + } |
|
| 1525 | 1887 | } |
| 1526 | 1888 | |
| 1527 | 1889 | public static function insert_last_update() { |
@@ -1551,8 +1913,11 @@ discard block |
||
| 1551 | 1913 | return "error : ".$e->getMessage(); |
| 1552 | 1914 | } |
| 1553 | 1915 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 1554 | - if ($row['nb'] > 0) return false; |
|
| 1555 | - else return true; |
|
| 1916 | + if ($row['nb'] > 0) { |
|
| 1917 | + return false; |
|
| 1918 | + } else { |
|
| 1919 | + return true; |
|
| 1920 | + } |
|
| 1556 | 1921 | } |
| 1557 | 1922 | |
| 1558 | 1923 | public static function insert_last_notam_update() { |
@@ -1582,8 +1947,11 @@ discard block |
||
| 1582 | 1947 | return "error : ".$e->getMessage(); |
| 1583 | 1948 | } |
| 1584 | 1949 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 1585 | - if ($row['nb'] > 0) return false; |
|
| 1586 | - else return true; |
|
| 1950 | + if ($row['nb'] > 0) { |
|
| 1951 | + return false; |
|
| 1952 | + } else { |
|
| 1953 | + return true; |
|
| 1954 | + } |
|
| 1587 | 1955 | } |
| 1588 | 1956 | |
| 1589 | 1957 | public static function insert_last_owner_update() { |