@@ -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() { |
@@ -23,16 +23,16 @@ discard block |
||
23 | 23 | curl_close($ch); |
24 | 24 | } |
25 | 25 | |
26 | - public static function gunzip($in_file,$out_file_name = '') { |
|
26 | + public static function gunzip($in_file, $out_file_name = '') { |
|
27 | 27 | //echo $in_file.' -> '.$out_file_name."\n"; |
28 | 28 | $buffer_size = 4096; // read 4kb at a time |
29 | 29 | if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); |
30 | 30 | if ($in_file != '' && file_exists($in_file)) { |
31 | 31 | // 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'); |
|
32 | + if (function_exists('gzopen')) $file = gzopen($in_file, 'rb'); |
|
33 | + elseif (function_exists('gzopen64')) $file = gzopen64($in_file, 'rb'); |
|
34 | 34 | $out_file = fopen($out_file_name, 'wb'); |
35 | - while(!gzeof($file)) { |
|
35 | + while (!gzeof($file)) { |
|
36 | 36 | fwrite($out_file, gzread($file, $buffer_size)); |
37 | 37 | } |
38 | 38 | fclose($out_file); |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | try { |
57 | 57 | self::$db_sqlite = new PDO('sqlite:'.$database); |
58 | 58 | self::$db_sqlite->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
59 | - } catch(PDOException $e) { |
|
59 | + } catch (PDOException $e) { |
|
60 | 60 | return "error : ".$e->getMessage(); |
61 | 61 | } |
62 | 62 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | //$Connection = new Connection(); |
72 | 72 | $sth = $Connection->db->prepare($query); |
73 | 73 | $sth->execute(array(':source' => $database_file)); |
74 | - } catch(PDOException $e) { |
|
74 | + } catch (PDOException $e) { |
|
75 | 75 | return "error : ".$e->getMessage(); |
76 | 76 | } |
77 | 77 | |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | try { |
83 | 83 | $sth = update_db::$db_sqlite->prepare($query); |
84 | 84 | $sth->execute(); |
85 | - } catch(PDOException $e) { |
|
85 | + } catch (PDOException $e) { |
|
86 | 86 | return "error : ".$e->getMessage(); |
87 | 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)'; |
@@ -93,11 +93,11 @@ discard block |
||
93 | 93 | if ($globalTransaction) $Connection->db->beginTransaction(); |
94 | 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 | - $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); |
|
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 | - } catch(PDOException $e) { |
|
100 | + } catch (PDOException $e) { |
|
101 | 101 | if ($globalTransaction) $Connection->db->rollBack(); |
102 | 102 | return "error : ".$e->getMessage(); |
103 | 103 | } |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | $Connection = new Connection(); |
112 | 112 | $sth = $Connection->db->prepare($query); |
113 | 113 | $sth->execute(array(':source' => $database_file)); |
114 | - } catch(PDOException $e) { |
|
114 | + } catch (PDOException $e) { |
|
115 | 115 | return "error : ".$e->getMessage(); |
116 | 116 | } |
117 | 117 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source"; |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | $Connection = new Connection(); |
120 | 120 | $sth = $Connection->db->prepare($query); |
121 | 121 | $sth->execute(array(':source' => $database_file)); |
122 | - } catch(PDOException $e) { |
|
122 | + } catch (PDOException $e) { |
|
123 | 123 | return "error : ".$e->getMessage(); |
124 | 124 | } |
125 | 125 | |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | try { |
129 | 129 | $sth = update_db::$db_sqlite->prepare($query); |
130 | 130 | $sth->execute(); |
131 | - } catch(PDOException $e) { |
|
131 | + } catch (PDOException $e) { |
|
132 | 132 | return "error : ".$e->getMessage(); |
133 | 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)'; |
@@ -145,15 +145,15 @@ discard block |
||
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 | - $query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type); |
|
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']); |
|
151 | + $query_dest_owner_values = array(':registration' => $values['Registration'], ':source' => $database_file, ':owner' => $values['RegisteredOwners']); |
|
152 | 152 | $sth_dest_owner->execute($query_dest_owner_values); |
153 | 153 | } |
154 | 154 | } |
155 | 155 | if ($globalTransaction) $Connection->db->commit(); |
156 | - } catch(PDOException $e) { |
|
156 | + } catch (PDOException $e) { |
|
157 | 157 | return "error : ".$e->getMessage(); |
158 | 158 | } |
159 | 159 | |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | $Connection = new Connection(); |
163 | 163 | $sth = $Connection->db->prepare($query); |
164 | 164 | $sth->execute(array(':source' => $database_file)); |
165 | - } catch(PDOException $e) { |
|
165 | + } catch (PDOException $e) { |
|
166 | 166 | return "error : ".$e->getMessage(); |
167 | 167 | } |
168 | 168 | return ''; |
@@ -177,11 +177,11 @@ discard block |
||
177 | 177 | $Connection = new Connection(); |
178 | 178 | $sth = $Connection->db->prepare($query); |
179 | 179 | $sth->execute(array(':source' => $database_file)); |
180 | - } catch(PDOException $e) { |
|
180 | + } catch (PDOException $e) { |
|
181 | 181 | return "error : ".$e->getMessage(); |
182 | 182 | } |
183 | 183 | |
184 | - if ($fh = fopen($database_file,"r")) { |
|
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)'; |
186 | 186 | $query_dest = 'INSERT INTO aircraft_modes (ModeS,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:Registration,:ICAOTypeCode,:source)'; |
187 | 187 | |
@@ -190,13 +190,13 @@ discard block |
||
190 | 190 | try { |
191 | 191 | if ($globalTransaction) $Connection->db->beginTransaction(); |
192 | 192 | while (!feof($fh)) { |
193 | - $line = $Common->hex2str(fgets($fh,9999)); |
|
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)); |
|
195 | + $values['ModeS'] = substr($line, 0, 6); |
|
196 | + $values['Registration'] = trim(substr($line, 69, 6)); |
|
197 | + $aircraft_name = trim(substr($line, 48, 6)); |
|
198 | 198 | // Check if we can find ICAO, else set it to GLID |
199 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
199 | + $aircraft_name_split = explode(' ', $aircraft_name); |
|
200 | 200 | $search_more = ''; |
201 | 201 | if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
202 | 202 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
@@ -208,20 +208,20 @@ discard block |
||
208 | 208 | if (isset($result['icao']) && $result['icao'] != '') { |
209 | 209 | $values['ICAOTypeCode'] = $result['icao']; |
210 | 210 | } |
211 | - } catch(PDOException $e) { |
|
211 | + } catch (PDOException $e) { |
|
212 | 212 | return "error : ".$e->getMessage(); |
213 | 213 | } |
214 | 214 | if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID'; |
215 | 215 | // Add data to db |
216 | 216 | if ($values['ModeS'] != '' && $values['Registration'] != '' && $values['Registration'] != '0000') { |
217 | 217 | //$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']); |
218 | - $query_dest_values = array(':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file); |
|
218 | + $query_dest_values = array(':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file); |
|
219 | 219 | //print_r($query_dest_values); |
220 | 220 | $sth_dest->execute($query_dest_values); |
221 | 221 | } |
222 | 222 | } |
223 | 223 | if ($globalTransaction) $Connection->db->commit(); |
224 | - } catch(PDOException $e) { |
|
224 | + } catch (PDOException $e) { |
|
225 | 225 | return "error : ".$e->getMessage(); |
226 | 226 | } |
227 | 227 | } |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | $Connection = new Connection(); |
232 | 232 | $sth = $Connection->db->prepare($query); |
233 | 233 | $sth->execute(array(':source' => $database_file)); |
234 | - } catch(PDOException $e) { |
|
234 | + } catch (PDOException $e) { |
|
235 | 235 | return "error : ".$e->getMessage(); |
236 | 236 | } |
237 | 237 | return ''; |
@@ -245,11 +245,11 @@ discard block |
||
245 | 245 | $Connection = new Connection(); |
246 | 246 | $sth = $Connection->db->prepare($query); |
247 | 247 | $sth->execute(array(':source' => $database_file)); |
248 | - } catch(PDOException $e) { |
|
248 | + } catch (PDOException $e) { |
|
249 | 249 | return "error : ".$e->getMessage(); |
250 | 250 | } |
251 | 251 | |
252 | - if ($fh = fopen($database_file,"r")) { |
|
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)'; |
254 | 254 | $query_dest = 'INSERT INTO aircraft_modes (ModeS,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:Registration,:ICAOTypeCode,:source)'; |
255 | 255 | |
@@ -257,9 +257,9 @@ discard block |
||
257 | 257 | $sth_dest = $Connection->db->prepare($query_dest); |
258 | 258 | try { |
259 | 259 | if ($globalTransaction) $Connection->db->beginTransaction(); |
260 | - $tmp = fgetcsv($fh,9999,',',"'"); |
|
260 | + $tmp = fgetcsv($fh, 9999, ',', "'"); |
|
261 | 261 | while (!feof($fh)) { |
262 | - $line = fgetcsv($fh,9999,',',"'"); |
|
262 | + $line = fgetcsv($fh, 9999, ',', "'"); |
|
263 | 263 | |
264 | 264 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
265 | 265 | //print_r($line); |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | $values['Registration'] = $line[3]; |
268 | 268 | $aircraft_name = $line[2]; |
269 | 269 | // Check if we can find ICAO, else set it to GLID |
270 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
270 | + $aircraft_name_split = explode(' ', $aircraft_name); |
|
271 | 271 | $search_more = ''; |
272 | 272 | if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
273 | 273 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
@@ -276,20 +276,20 @@ discard block |
||
276 | 276 | $sth_search->execute(); |
277 | 277 | $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
278 | 278 | if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
279 | - } catch(PDOException $e) { |
|
279 | + } catch (PDOException $e) { |
|
280 | 280 | return "error : ".$e->getMessage(); |
281 | 281 | } |
282 | 282 | //if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID'; |
283 | 283 | // Add data to db |
284 | 284 | if ($values['ModeS'] != '' && $values['Registration'] != '' && $values['Registration'] != '0000' && $values['ICAOTypeCode'] != '') { |
285 | 285 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
286 | - $query_dest_values = array(':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file); |
|
286 | + $query_dest_values = array(':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file); |
|
287 | 287 | //print_r($query_dest_values); |
288 | 288 | $sth_dest->execute($query_dest_values); |
289 | 289 | } |
290 | 290 | } |
291 | 291 | if ($globalTransaction) $Connection->db->commit(); |
292 | - } catch(PDOException $e) { |
|
292 | + } catch (PDOException $e) { |
|
293 | 293 | return "error : ".$e->getMessage(); |
294 | 294 | } |
295 | 295 | } |
@@ -299,13 +299,13 @@ discard block |
||
299 | 299 | $Connection = new Connection(); |
300 | 300 | $sth = $Connection->db->prepare($query); |
301 | 301 | $sth->execute(array(':source' => $database_file)); |
302 | - } catch(PDOException $e) { |
|
302 | + } catch (PDOException $e) { |
|
303 | 303 | return "error : ".$e->getMessage(); |
304 | 304 | } |
305 | 305 | return ''; |
306 | 306 | } |
307 | 307 | |
308 | - public static function retrieve_owner($database_file,$country = 'F') { |
|
308 | + public static function retrieve_owner($database_file, $country = 'F') { |
|
309 | 309 | global $globalTransaction; |
310 | 310 | //$query = 'TRUNCATE TABLE aircraft_modes'; |
311 | 311 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source"; |
@@ -313,11 +313,11 @@ discard block |
||
313 | 313 | $Connection = new Connection(); |
314 | 314 | $sth = $Connection->db->prepare($query); |
315 | 315 | $sth->execute(array(':source' => $database_file)); |
316 | - } catch(PDOException $e) { |
|
316 | + } catch (PDOException $e) { |
|
317 | 317 | return "error : ".$e->getMessage(); |
318 | 318 | } |
319 | 319 | |
320 | - if ($fh = fopen($database_file,"r")) { |
|
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)'; |
322 | 322 | $query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)'; |
323 | 323 | |
@@ -325,16 +325,16 @@ discard block |
||
325 | 325 | $sth_dest = $Connection->db->prepare($query_dest); |
326 | 326 | try { |
327 | 327 | if ($globalTransaction) $Connection->db->beginTransaction(); |
328 | - $tmp = fgetcsv($fh,9999,',','"'); |
|
328 | + $tmp = fgetcsv($fh, 9999, ',', '"'); |
|
329 | 329 | while (!feof($fh)) { |
330 | - $line = fgetcsv($fh,9999,',','"'); |
|
330 | + $line = fgetcsv($fh, 9999, ',', '"'); |
|
331 | 331 | //print_r($line); |
332 | 332 | if ($country == 'F') { |
333 | 333 | $values['registration'] = $line[0]; |
334 | 334 | $values['base'] = $line[4]; |
335 | 335 | $values['owner'] = $line[5]; |
336 | 336 | if ($line[6] == '') $values['date_first_reg'] = ''; |
337 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
337 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6])); |
|
338 | 338 | $values['cancel'] = $line[7]; |
339 | 339 | } elseif ($country == 'EI') { |
340 | 340 | // TODO : add modeS & reg to aircraft_modes |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | $values['base'] = $line[3]; |
343 | 343 | $values['owner'] = $line[2]; |
344 | 344 | if ($line[1] == '') $values['date_first_reg'] = ''; |
345 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
345 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[1])); |
|
346 | 346 | $values['cancel'] = ''; |
347 | 347 | } elseif ($country == 'HB') { |
348 | 348 | // TODO : add modeS & reg to aircraft_modes |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | $values['base'] = null; |
358 | 358 | $values['owner'] = $line[5]; |
359 | 359 | if ($line[18] == '') $values['date_first_reg'] = ''; |
360 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
360 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[18])); |
|
361 | 361 | $values['cancel'] = ''; |
362 | 362 | } elseif ($country == 'VH') { |
363 | 363 | // TODO : add modeS & reg to aircraft_modes |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | $values['base'] = null; |
366 | 366 | $values['owner'] = $line[12]; |
367 | 367 | if ($line[28] == '') $values['date_first_reg'] = ''; |
368 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
368 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[28])); |
|
369 | 369 | |
370 | 370 | $values['cancel'] = $line[39]; |
371 | 371 | } elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { |
@@ -385,28 +385,28 @@ discard block |
||
385 | 385 | $values['base'] = null; |
386 | 386 | $values['owner'] = $line[8]; |
387 | 387 | if ($line[7] == '') $values['date_first_reg'] = ''; |
388 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
388 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7])); |
|
389 | 389 | $values['cancel'] = ''; |
390 | 390 | } elseif ($country == 'PP') { |
391 | 391 | $values['registration'] = $line[0]; |
392 | 392 | $values['base'] = null; |
393 | 393 | $values['owner'] = $line[4]; |
394 | 394 | if ($line[6] == '') $values['date_first_reg'] = ''; |
395 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
395 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6])); |
|
396 | 396 | $values['cancel'] = $line[7]; |
397 | 397 | } elseif ($country == 'E7') { |
398 | 398 | $values['registration'] = $line[0]; |
399 | 399 | $values['base'] = null; |
400 | 400 | $values['owner'] = $line[4]; |
401 | 401 | if ($line[5] == '') $values['date_first_reg'] = ''; |
402 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
402 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[5])); |
|
403 | 403 | $values['cancel'] = ''; |
404 | 404 | } elseif ($country == '8Q') { |
405 | 405 | $values['registration'] = $line[0]; |
406 | 406 | $values['base'] = null; |
407 | 407 | $values['owner'] = $line[3]; |
408 | 408 | if ($line[7] == '') $values['date_first_reg'] = ''; |
409 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
409 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7])); |
|
410 | 410 | $values['cancel'] = ''; |
411 | 411 | } elseif ($country == 'ZK' || $country == 'OM' || $country == 'TF') { |
412 | 412 | $values['registration'] = $line[0]; |
@@ -416,12 +416,12 @@ discard block |
||
416 | 416 | $values['cancel'] = ''; |
417 | 417 | } |
418 | 418 | if ($values['cancel'] == '' && $values['registration'] != null) { |
419 | - $query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file); |
|
419 | + $query_dest_values = array(':registration' => $values['registration'], ':base' => $values['base'], ':date_first_reg' => $values['date_first_reg'], ':owner' => $values['owner'], ':source' => $database_file); |
|
420 | 420 | $sth_dest->execute($query_dest_values); |
421 | 421 | } |
422 | 422 | } |
423 | 423 | if ($globalTransaction) $Connection->db->commit(); |
424 | - } catch(PDOException $e) { |
|
424 | + } catch (PDOException $e) { |
|
425 | 425 | return "error : ".$e->getMessage(); |
426 | 426 | } |
427 | 427 | } |
@@ -536,7 +536,7 @@ discard block |
||
536 | 536 | $Connection = new Connection(); |
537 | 537 | $sth = $Connection->db->prepare($query); |
538 | 538 | $sth->execute(); |
539 | - } catch(PDOException $e) { |
|
539 | + } catch (PDOException $e) { |
|
540 | 540 | return "error : ".$e->getMessage(); |
541 | 541 | } |
542 | 542 | |
@@ -546,7 +546,7 @@ discard block |
||
546 | 546 | $Connection = new Connection(); |
547 | 547 | $sth = $Connection->db->prepare($query); |
548 | 548 | $sth->execute(); |
549 | - } catch(PDOException $e) { |
|
549 | + } catch (PDOException $e) { |
|
550 | 550 | return "error : ".$e->getMessage(); |
551 | 551 | } |
552 | 552 | |
@@ -557,7 +557,7 @@ discard block |
||
557 | 557 | if ($globalTransaction) $Connection->db->beginTransaction(); |
558 | 558 | |
559 | 559 | $i = 0; |
560 | - while($row = sparql_fetch_array($result)) |
|
560 | + while ($row = sparql_fetch_array($result)) |
|
561 | 561 | { |
562 | 562 | if ($i >= 1) { |
563 | 563 | //print_r($row); |
@@ -577,31 +577,31 @@ discard block |
||
577 | 577 | $row['image'] = ''; |
578 | 578 | $row['image_thumb'] = ''; |
579 | 579 | } else { |
580 | - $image = str_replace(' ','_',$row['image']); |
|
580 | + $image = str_replace(' ', '_', $row['image']); |
|
581 | 581 | $digest = md5($image); |
582 | - $folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image . '/220px-' . $image; |
|
583 | - $row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/' . $folder; |
|
584 | - $folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image; |
|
585 | - $row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/' . $folder; |
|
582 | + $folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image.'/220px-'.$image; |
|
583 | + $row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/'.$folder; |
|
584 | + $folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image; |
|
585 | + $row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/'.$folder; |
|
586 | 586 | } |
587 | 587 | |
588 | - $country = explode('-',$row['country']); |
|
588 | + $country = explode('-', $row['country']); |
|
589 | 589 | $row['country'] = $country[0]; |
590 | 590 | |
591 | 591 | $row['type'] = trim($row['type']); |
592 | - if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i',$row['name'])) { |
|
592 | + if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i', $row['name'])) { |
|
593 | 593 | $row['type'] = 'Military'; |
594 | 594 | } elseif ($row['type'] == 'http://dbpedia.org/resource/Airport' || $row['type'] == 'Civil' || $row['type'] == 'Public use' || $row['type'] == 'Public' || $row['type'] == 'http://dbpedia.org/resource/Civilian' || $row['type'] == 'Public, Civilian' || $row['type'] == 'Public / Military' || $row['type'] == 'Private & Civilian' || $row['type'] == 'Civilian and Military' || $row['type'] == 'Public/military' || $row['type'] == 'Active With Few Facilities' || $row['type'] == '?ivilian' || $row['type'] == 'Civil/Military' || $row['type'] == 'NA' || $row['type'] == 'Public/Military') { |
595 | 595 | $row['type'] = 'small_airport'; |
596 | 596 | } |
597 | 597 | |
598 | - $row['city'] = urldecode(str_replace('_',' ',str_replace('http://dbpedia.org/resource/','',$row['city']))); |
|
599 | - $query_dest_values = array(':airport_id' => $i, ':name' => $row['name'],':iata' => $row['iata'],':icao' => $row['icao'],':latitude' => $row['latitude'],':longitude' => $row['longitude'],':altitude' => $row['altitude'],':type' => $row['type'],':city' => $row['city'],':country' => $row['country'],':home_link' => $row['homepage'],':wikipedia_link' => $row['wikipedia_page'],':image' => $row['image'],':image_thumb' => $row['image_thumb']); |
|
598 | + $row['city'] = urldecode(str_replace('_', ' ', str_replace('http://dbpedia.org/resource/', '', $row['city']))); |
|
599 | + $query_dest_values = array(':airport_id' => $i, ':name' => $row['name'], ':iata' => $row['iata'], ':icao' => $row['icao'], ':latitude' => $row['latitude'], ':longitude' => $row['longitude'], ':altitude' => $row['altitude'], ':type' => $row['type'], ':city' => $row['city'], ':country' => $row['country'], ':home_link' => $row['homepage'], ':wikipedia_link' => $row['wikipedia_page'], ':image' => $row['image'], ':image_thumb' => $row['image_thumb']); |
|
600 | 600 | //print_r($query_dest_values); |
601 | 601 | |
602 | 602 | try { |
603 | 603 | $sth_dest->execute($query_dest_values); |
604 | - } catch(PDOException $e) { |
|
604 | + } catch (PDOException $e) { |
|
605 | 605 | return "error : ".$e->getMessage(); |
606 | 606 | } |
607 | 607 | } |
@@ -615,7 +615,7 @@ discard block |
||
615 | 615 | $Connection = new Connection(); |
616 | 616 | $sth = $Connection->db->prepare($query); |
617 | 617 | $sth->execute(); |
618 | - } catch(PDOException $e) { |
|
618 | + } catch (PDOException $e) { |
|
619 | 619 | return "error : ".$e->getMessage(); |
620 | 620 | } |
621 | 621 | |
@@ -623,12 +623,12 @@ discard block |
||
623 | 623 | if ($globalDebug) echo "Insert Not available Airport...\n"; |
624 | 624 | $query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image`,`image_thumb`) |
625 | 625 | VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image, :image_thumb)"; |
626 | - $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' => ''); |
|
626 | + $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' => ''); |
|
627 | 627 | try { |
628 | 628 | $Connection = new Connection(); |
629 | 629 | $sth = $Connection->db->prepare($query); |
630 | 630 | $sth->execute($query_values); |
631 | - } catch(PDOException $e) { |
|
631 | + } catch (PDOException $e) { |
|
632 | 632 | return "error : ".$e->getMessage(); |
633 | 633 | } |
634 | 634 | $i++; |
@@ -646,7 +646,7 @@ discard block |
||
646 | 646 | echo "Download data from ourairports.com...\n"; |
647 | 647 | $delimiter = ','; |
648 | 648 | $out_file = $tmp_dir.'airports.csv'; |
649 | - update_db::download('http://ourairports.com/data/airports.csv',$out_file); |
|
649 | + update_db::download('http://ourairports.com/data/airports.csv', $out_file); |
|
650 | 650 | if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
651 | 651 | echo "Add data from ourairports.com...\n"; |
652 | 652 | |
@@ -657,32 +657,32 @@ discard block |
||
657 | 657 | //$Connection->db->beginTransaction(); |
658 | 658 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
659 | 659 | { |
660 | - if(!$header) $header = $row; |
|
660 | + if (!$header) $header = $row; |
|
661 | 661 | else { |
662 | 662 | $data = array(); |
663 | 663 | $data = array_combine($header, $row); |
664 | 664 | try { |
665 | 665 | $sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE `icao` = :icao'); |
666 | 666 | $sth->execute(array(':icao' => $data['gps_code'])); |
667 | - } catch(PDOException $e) { |
|
667 | + } catch (PDOException $e) { |
|
668 | 668 | return "error : ".$e->getMessage(); |
669 | 669 | } |
670 | 670 | if ($sth->fetchColumn() > 0) { |
671 | 671 | $query = 'UPDATE airport SET `type` = :type WHERE icao = :icao'; |
672 | 672 | try { |
673 | 673 | $sth = $Connection->db->prepare($query); |
674 | - $sth->execute(array(':icao' => $data['gps_code'],':type' => $data['type'])); |
|
675 | - } catch(PDOException $e) { |
|
674 | + $sth->execute(array(':icao' => $data['gps_code'], ':type' => $data['type'])); |
|
675 | + } catch (PDOException $e) { |
|
676 | 676 | return "error : ".$e->getMessage(); |
677 | 677 | } |
678 | 678 | } else { |
679 | 679 | $query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`) |
680 | 680 | VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link)"; |
681 | - $query_values = array(':airport_id' => $i, ':name' => $data['name'],':iata' => $data['iata_code'],':icao' => $data['gps_code'],':latitude' => $data['latitude_deg'],':longitude' => $data['longitude_deg'],':altitude' => $data['elevation_ft'],':type' => $data['type'],':city' => $data['municipality'],':country' => $data['iso_country'],':home_link' => $data['home_link'],':wikipedia_link' => $data['wikipedia_link']); |
|
681 | + $query_values = array(':airport_id' => $i, ':name' => $data['name'], ':iata' => $data['iata_code'], ':icao' => $data['gps_code'], ':latitude' => $data['latitude_deg'], ':longitude' => $data['longitude_deg'], ':altitude' => $data['elevation_ft'], ':type' => $data['type'], ':city' => $data['municipality'], ':country' => $data['iso_country'], ':home_link' => $data['home_link'], ':wikipedia_link' => $data['wikipedia_link']); |
|
682 | 682 | try { |
683 | 683 | $sth = $Connection->db->prepare($query); |
684 | 684 | $sth->execute($query_values); |
685 | - } catch(PDOException $e) { |
|
685 | + } catch (PDOException $e) { |
|
686 | 686 | return "error : ".$e->getMessage(); |
687 | 687 | } |
688 | 688 | $i++; |
@@ -695,7 +695,7 @@ discard block |
||
695 | 695 | |
696 | 696 | echo "Download data from another free database...\n"; |
697 | 697 | $out_file = $tmp_dir.'GlobalAirportDatabase.zip'; |
698 | - update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file); |
|
698 | + update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip', $out_file); |
|
699 | 699 | if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
700 | 700 | update_db::unzip($out_file); |
701 | 701 | $header = NULL; |
@@ -707,15 +707,15 @@ discard block |
||
707 | 707 | //$Connection->db->beginTransaction(); |
708 | 708 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
709 | 709 | { |
710 | - if(!$header) $header = $row; |
|
710 | + if (!$header) $header = $row; |
|
711 | 711 | else { |
712 | 712 | $data = $row; |
713 | 713 | |
714 | 714 | $query = 'UPDATE airport SET `city` = :city, `country` = :country WHERE icao = :icao'; |
715 | 715 | try { |
716 | 716 | $sth = $Connection->db->prepare($query); |
717 | - $sth->execute(array(':icao' => $data[0],':city' => ucwords(strtolower($data[3])),':country' => ucwords(strtolower($data[4])))); |
|
718 | - } catch(PDOException $e) { |
|
717 | + $sth->execute(array(':icao' => $data[0], ':city' => ucwords(strtolower($data[3])), ':country' => ucwords(strtolower($data[4])))); |
|
718 | + } catch (PDOException $e) { |
|
719 | 719 | return "error : ".$e->getMessage(); |
720 | 720 | } |
721 | 721 | } |
@@ -729,15 +729,15 @@ discard block |
||
729 | 729 | try { |
730 | 730 | $sth = $Connection->db->prepare("SELECT icao FROM airport WHERE `name` LIKE '%Air Base%'"); |
731 | 731 | $sth->execute(); |
732 | - } catch(PDOException $e) { |
|
732 | + } catch (PDOException $e) { |
|
733 | 733 | return "error : ".$e->getMessage(); |
734 | 734 | } |
735 | 735 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
736 | 736 | $query2 = 'UPDATE airport SET `type` = :type WHERE icao = :icao'; |
737 | 737 | try { |
738 | 738 | $sth2 = $Connection->db->prepare($query2); |
739 | - $sth2->execute(array(':icao' => $row['icao'],':type' => 'military')); |
|
740 | - } catch(PDOException $e) { |
|
739 | + $sth2->execute(array(':icao' => $row['icao'], ':type' => 'military')); |
|
740 | + } catch (PDOException $e) { |
|
741 | 741 | return "error : ".$e->getMessage(); |
742 | 742 | } |
743 | 743 | } |
@@ -761,7 +761,7 @@ discard block |
||
761 | 761 | $Connection = new Connection(); |
762 | 762 | $sth = $Connection->db->prepare($query); |
763 | 763 | $sth->execute(array(':source' => 'translation.csv')); |
764 | - } catch(PDOException $e) { |
|
764 | + } catch (PDOException $e) { |
|
765 | 765 | return "error : ".$e->getMessage(); |
766 | 766 | } |
767 | 767 | |
@@ -778,7 +778,7 @@ discard block |
||
778 | 778 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
779 | 779 | { |
780 | 780 | $i++; |
781 | - if($i > 12) { |
|
781 | + if ($i > 12) { |
|
782 | 782 | $data = $row; |
783 | 783 | $operator = $data[2]; |
784 | 784 | if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) { |
@@ -786,7 +786,7 @@ discard block |
||
786 | 786 | //echo substr($operator, 0, 2)."\n";; |
787 | 787 | if (count($airline_array) > 0) { |
788 | 788 | //print_r($airline_array); |
789 | - $operator = $airline_array[0]['icao'].substr($operator,2); |
|
789 | + $operator = $airline_array[0]['icao'].substr($operator, 2); |
|
790 | 790 | } |
791 | 791 | } |
792 | 792 | |
@@ -794,14 +794,14 @@ discard block |
||
794 | 794 | if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) { |
795 | 795 | $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2)); |
796 | 796 | if (count($airline_array) > 0) { |
797 | - $operator_correct = $airline_array[0]['icao'].substr($operator_correct,2); |
|
797 | + $operator_correct = $airline_array[0]['icao'].substr($operator_correct, 2); |
|
798 | 798 | } |
799 | 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); |
803 | - $sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $operator,':Operator_correct' => $operator_correct, ':source' => 'translation.csv')); |
|
804 | - } catch(PDOException $e) { |
|
803 | + $sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $operator, ':Operator_correct' => $operator_correct, ':source' => 'translation.csv')); |
|
804 | + } catch (PDOException $e) { |
|
805 | 805 | return "error : ".$e->getMessage(); |
806 | 806 | } |
807 | 807 | } |
@@ -821,7 +821,7 @@ discard block |
||
821 | 821 | $Connection = new Connection(); |
822 | 822 | $sth = $Connection->db->prepare($query); |
823 | 823 | $sth->execute(array(':source' => 'website_fam')); |
824 | - } catch(PDOException $e) { |
|
824 | + } catch (PDOException $e) { |
|
825 | 825 | return "error : ".$e->getMessage(); |
826 | 826 | } |
827 | 827 | |
@@ -841,8 +841,8 @@ discard block |
||
841 | 841 | $query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)'; |
842 | 842 | try { |
843 | 843 | $sth = $Connection->db->prepare($query); |
844 | - $sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $data[2],':Operator_correct' => $data[3], ':source' => 'website_fam')); |
|
845 | - } catch(PDOException $e) { |
|
844 | + $sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $data[2], ':Operator_correct' => $data[3], ':source' => 'website_fam')); |
|
845 | + } catch (PDOException $e) { |
|
846 | 846 | return "error : ".$e->getMessage(); |
847 | 847 | } |
848 | 848 | } |
@@ -861,28 +861,28 @@ discard block |
||
861 | 861 | */ |
862 | 862 | private static function table2array($data) { |
863 | 863 | $html = str_get_html($data); |
864 | - $tabledata=array(); |
|
865 | - foreach($html->find('tr') as $element) |
|
864 | + $tabledata = array(); |
|
865 | + foreach ($html->find('tr') as $element) |
|
866 | 866 | { |
867 | 867 | $td = array(); |
868 | - foreach( $element->find('th') as $row) |
|
868 | + foreach ($element->find('th') as $row) |
|
869 | 869 | { |
870 | 870 | $td [] = trim($row->plaintext); |
871 | 871 | } |
872 | - $td=array_filter($td); |
|
872 | + $td = array_filter($td); |
|
873 | 873 | $tabledata[] = $td; |
874 | 874 | |
875 | 875 | $td = array(); |
876 | 876 | $tdi = array(); |
877 | - foreach( $element->find('td') as $row) |
|
877 | + foreach ($element->find('td') as $row) |
|
878 | 878 | { |
879 | 879 | $td [] = trim($row->plaintext); |
880 | 880 | $tdi [] = trim($row->innertext); |
881 | 881 | } |
882 | - $td=array_filter($td); |
|
883 | - $tdi=array_filter($tdi); |
|
882 | + $td = array_filter($td); |
|
883 | + $tdi = array_filter($tdi); |
|
884 | 884 | // $tabledata[]=array_merge($td,$tdi); |
885 | - $tabledata[]=$td; |
|
885 | + $tabledata[] = $td; |
|
886 | 886 | } |
887 | 887 | return(array_filter($tabledata)); |
888 | 888 | } |
@@ -950,7 +950,7 @@ discard block |
||
950 | 950 | $Connection = new Connection(); |
951 | 951 | $sth = $Connection->db->prepare($query); |
952 | 952 | $sth->execute(); |
953 | - } catch(PDOException $e) { |
|
953 | + } catch (PDOException $e) { |
|
954 | 954 | return "error : ".$e->getMessage(); |
955 | 955 | } |
956 | 956 | |
@@ -966,13 +966,13 @@ discard block |
||
966 | 966 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
967 | 967 | { |
968 | 968 | $i++; |
969 | - if($i > 3 && count($row) > 2) { |
|
969 | + if ($i > 3 && count($row) > 2) { |
|
970 | 970 | $data = array_values(array_filter($row)); |
971 | 971 | $cntdata = count($data); |
972 | 972 | if ($cntdata > 10) { |
973 | 973 | $value = $data[9]; |
974 | 974 | |
975 | - for ($i =10;$i < $cntdata;$i++) { |
|
975 | + for ($i = 10; $i < $cntdata; $i++) { |
|
976 | 976 | $value .= ' '.$data[$i]; |
977 | 977 | } |
978 | 978 | $data[9] = $value; |
@@ -982,8 +982,8 @@ discard block |
||
982 | 982 | $query = 'INSERT INTO waypoints (name_begin,latitude_begin,longitude_begin,name_end,latitude_end,longitude_end,high,base,top,segment_name) VALUES (:name_begin, :latitude_begin, :longitude_begin, :name_end, :latitude_end, :longitude_end, :high, :base, :top, :segment_name)'; |
983 | 983 | try { |
984 | 984 | $sth = $Connection->db->prepare($query); |
985 | - $sth->execute(array(':name_begin' => $data[0],':latitude_begin' => $data[1],':longitude_begin' => $data[2],':name_end' => $data[3], ':latitude_end' => $data[4], ':longitude_end' => $data[5], ':high' => $data[6], ':base' => $data[7], ':top' => $data[8], ':segment_name' => $data[9])); |
|
986 | - } catch(PDOException $e) { |
|
985 | + $sth->execute(array(':name_begin' => $data[0], ':latitude_begin' => $data[1], ':longitude_begin' => $data[2], ':name_end' => $data[3], ':latitude_end' => $data[4], ':longitude_end' => $data[5], ':high' => $data[6], ':base' => $data[7], ':top' => $data[8], ':segment_name' => $data[9])); |
|
986 | + } catch (PDOException $e) { |
|
987 | 987 | return "error : ".$e->getMessage(); |
988 | 988 | } |
989 | 989 | } |
@@ -1003,7 +1003,7 @@ discard block |
||
1003 | 1003 | $Connection = new Connection(); |
1004 | 1004 | $sth = $Connection->db->prepare($query); |
1005 | 1005 | $sth->execute(); |
1006 | - } catch(PDOException $e) { |
|
1006 | + } catch (PDOException $e) { |
|
1007 | 1007 | return "error : ".$e->getMessage(); |
1008 | 1008 | } |
1009 | 1009 | |
@@ -1015,12 +1015,12 @@ discard block |
||
1015 | 1015 | if ($globalTransaction) $Connection->db->beginTransaction(); |
1016 | 1016 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1017 | 1017 | { |
1018 | - if(count($row) > 1) { |
|
1018 | + if (count($row) > 1) { |
|
1019 | 1019 | $query = "INSERT INTO airlines (name,icao,active) VALUES (:name, :icao, 'Y')"; |
1020 | 1020 | try { |
1021 | 1021 | $sth = $Connection->db->prepare($query); |
1022 | - $sth->execute(array(':name' => $row[1],':icao' => $row[0])); |
|
1023 | - } catch(PDOException $e) { |
|
1022 | + $sth->execute(array(':name' => $row[1], ':icao' => $row[0])); |
|
1023 | + } catch (PDOException $e) { |
|
1024 | 1024 | return "error : ".$e->getMessage(); |
1025 | 1025 | } |
1026 | 1026 | } |
@@ -1034,14 +1034,14 @@ discard block |
||
1034 | 1034 | public static function update_airspace() { |
1035 | 1035 | global $tmp_dir, $globalDBdriver; |
1036 | 1036 | include_once('class.create_db.php'); |
1037 | - if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
1037 | + if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz', $tmp_dir.'airspace.sql'); |
|
1038 | 1038 | else { |
1039 | - update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
1039 | + update_db::gunzip('../db/pgsql/airspace.sql.gz', $tmp_dir.'airspace.sql'); |
|
1040 | 1040 | $query = "CREATE EXTENSION postgis"; |
1041 | 1041 | try { |
1042 | 1042 | $sth = $Connection->db->prepare($query); |
1043 | 1043 | $sth->execute(); |
1044 | - } catch(PDOException $e) { |
|
1044 | + } catch (PDOException $e) { |
|
1045 | 1045 | return "error : ".$e->getMessage(); |
1046 | 1046 | } |
1047 | 1047 | } |
@@ -1065,14 +1065,14 @@ discard block |
||
1065 | 1065 | try { |
1066 | 1066 | $sth = $Connection->db->prepare($query); |
1067 | 1067 | $sth->execute(); |
1068 | - } catch(PDOException $e) { |
|
1068 | + } catch (PDOException $e) { |
|
1069 | 1069 | echo "error : ".$e->getMessage(); |
1070 | 1070 | } |
1071 | 1071 | } |
1072 | 1072 | if ($globalDBdriver == 'mysql') { |
1073 | - update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql'); |
|
1073 | + update_db::gunzip('../db/countries.sql.gz', $tmp_dir.'countries.sql'); |
|
1074 | 1074 | } else { |
1075 | - update_db::gunzip('../db/pgsql/countries.sql.gz',$tmp_dir.'countries.sql'); |
|
1075 | + update_db::gunzip('../db/pgsql/countries.sql.gz', $tmp_dir.'countries.sql'); |
|
1076 | 1076 | } |
1077 | 1077 | $error = create_db::import_file($tmp_dir.'countries.sql'); |
1078 | 1078 | return $error; |
@@ -1085,7 +1085,7 @@ discard block |
||
1085 | 1085 | // update_db::unzip($tmp_dir.'AptNav.zip'); |
1086 | 1086 | // update_db::download('https://gitorious.org/fg/fgdata/raw/e81f8a15424a175a7b715f8f7eb8f4147b802a27:Navaids/awy.dat.gz',$tmp_dir.'awy.dat.gz'); |
1087 | 1087 | // update_db::download('http://sourceforge.net/p/flightgear/fgdata/ci/next/tree/Navaids/awy.dat.gz?format=raw',$tmp_dir.'awy.dat.gz','http://sourceforge.net'); |
1088 | - update_db::download('http://pkgs.fedoraproject.org/repo/extras/FlightGear-Atlas/awy.dat.gz/f530c9d1c4b31a288ba88dcc8224268b/awy.dat.gz',$tmp_dir.'awy.dat.gz','http://sourceforge.net'); |
|
1088 | + update_db::download('http://pkgs.fedoraproject.org/repo/extras/FlightGear-Atlas/awy.dat.gz/f530c9d1c4b31a288ba88dcc8224268b/awy.dat.gz', $tmp_dir.'awy.dat.gz', 'http://sourceforge.net'); |
|
1089 | 1089 | update_db::gunzip($tmp_dir.'awy.dat.gz'); |
1090 | 1090 | $error = update_db::waypoints($tmp_dir.'awy.dat'); |
1091 | 1091 | return $error; |
@@ -1105,7 +1105,7 @@ discard block |
||
1105 | 1105 | update_db::ivao_airlines($tmp_dir.'data/airlines.dat'); |
1106 | 1106 | if ($globalDebug) echo "Copy airlines logos to airlines images directory..."; |
1107 | 1107 | if (is_writable(dirname(__FILE__).'/../images/airlines')) { |
1108 | - if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
1108 | + if (!$Common->xcopy($tmp_dir.'logos/', dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
1109 | 1109 | } else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
1110 | 1110 | } else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
1111 | 1111 | if ($error != '') { |
@@ -1118,7 +1118,7 @@ discard block |
||
1118 | 1118 | global $tmp_dir, $globalDebug; |
1119 | 1119 | $error = ''; |
1120 | 1120 | if ($globalDebug) echo "Routes : Download..."; |
1121 | - update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz'); |
|
1121 | + update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz', $tmp_dir.'StandingData.sqb.gz'); |
|
1122 | 1122 | if (file_exists($tmp_dir.'StandingData.sqb.gz')) { |
1123 | 1123 | if ($globalDebug) echo "Gunzip..."; |
1124 | 1124 | update_db::gunzip($tmp_dir.'StandingData.sqb.gz'); |
@@ -1145,7 +1145,7 @@ discard block |
||
1145 | 1145 | } elseif ($globalDebug) echo "Done\n"; |
1146 | 1146 | */ |
1147 | 1147 | if ($globalDebug) echo "Modes : Download..."; |
1148 | - update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
|
1148 | + update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip', $tmp_dir.'basestation_latest.zip', 'http://planebase.biz/bstnsqb'); |
|
1149 | 1149 | if (file_exists($tmp_dir.'basestation_latest.zip')) { |
1150 | 1150 | if ($globalDebug) echo "Unzip..."; |
1151 | 1151 | update_db::unzip($tmp_dir.'basestation_latest.zip'); |
@@ -1161,7 +1161,7 @@ discard block |
||
1161 | 1161 | public static function update_ModeS_flarm() { |
1162 | 1162 | global $tmp_dir, $globalDebug; |
1163 | 1163 | if ($globalDebug) echo "Modes Flarmnet: Download..."; |
1164 | - update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln'); |
|
1164 | + update_db::download('http://flarmnet.org/files/data.fln', $tmp_dir.'data.fln'); |
|
1165 | 1165 | if (file_exists($tmp_dir.'data.fln')) { |
1166 | 1166 | if ($globalDebug) echo "Add to DB..."; |
1167 | 1167 | $error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln'); |
@@ -1175,7 +1175,7 @@ discard block |
||
1175 | 1175 | public static function update_ModeS_ogn() { |
1176 | 1176 | global $tmp_dir, $globalDebug; |
1177 | 1177 | if ($globalDebug) echo "Modes OGN: Download..."; |
1178 | - update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv'); |
|
1178 | + update_db::download('http://ddb.glidernet.org/download/', $tmp_dir.'ogn.csv'); |
|
1179 | 1179 | if (file_exists($tmp_dir.'ogn.csv')) { |
1180 | 1180 | if ($globalDebug) echo "Add to DB..."; |
1181 | 1181 | $error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv'); |
@@ -1190,173 +1190,173 @@ discard block |
||
1190 | 1190 | global $tmp_dir, $globalDebug; |
1191 | 1191 | |
1192 | 1192 | if ($globalDebug) echo "Owner France: Download..."; |
1193 | - update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv'); |
|
1193 | + update_db::download('http://antonakis.co.uk/registers/France.txt', $tmp_dir.'owner_f.csv'); |
|
1194 | 1194 | if (file_exists($tmp_dir.'owner_f.csv')) { |
1195 | 1195 | if ($globalDebug) echo "Add to DB..."; |
1196 | - $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F'); |
|
1196 | + $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv', 'F'); |
|
1197 | 1197 | } else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
1198 | 1198 | if ($error != '') { |
1199 | 1199 | return $error; |
1200 | 1200 | } elseif ($globalDebug) echo "Done\n"; |
1201 | 1201 | |
1202 | 1202 | if ($globalDebug) echo "Owner Ireland: Download..."; |
1203 | - update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv'); |
|
1203 | + update_db::download('http://antonakis.co.uk/registers/Ireland.txt', $tmp_dir.'owner_ei.csv'); |
|
1204 | 1204 | if (file_exists($tmp_dir.'owner_ei.csv')) { |
1205 | 1205 | if ($globalDebug) echo "Add to DB..."; |
1206 | - $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI'); |
|
1206 | + $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv', 'EI'); |
|
1207 | 1207 | } else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
1208 | 1208 | if ($error != '') { |
1209 | 1209 | return $error; |
1210 | 1210 | } elseif ($globalDebug) echo "Done\n"; |
1211 | 1211 | if ($globalDebug) echo "Owner Switzerland: Download..."; |
1212 | - update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv'); |
|
1212 | + update_db::download('http://antonakis.co.uk/registers/Switzerland.txt', $tmp_dir.'owner_hb.csv'); |
|
1213 | 1213 | if (file_exists($tmp_dir.'owner_hb.csv')) { |
1214 | 1214 | if ($globalDebug) echo "Add to DB..."; |
1215 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB'); |
|
1215 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv', 'HB'); |
|
1216 | 1216 | } else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
1217 | 1217 | if ($error != '') { |
1218 | 1218 | return $error; |
1219 | 1219 | } elseif ($globalDebug) echo "Done\n"; |
1220 | 1220 | if ($globalDebug) echo "Owner Czech Republic: Download..."; |
1221 | - update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv'); |
|
1221 | + update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt', $tmp_dir.'owner_ok.csv'); |
|
1222 | 1222 | if (file_exists($tmp_dir.'owner_ok.csv')) { |
1223 | 1223 | if ($globalDebug) echo "Add to DB..."; |
1224 | - $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK'); |
|
1224 | + $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv', 'OK'); |
|
1225 | 1225 | } else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
1226 | 1226 | if ($error != '') { |
1227 | 1227 | return $error; |
1228 | 1228 | } elseif ($globalDebug) echo "Done\n"; |
1229 | 1229 | if ($globalDebug) echo "Owner Australia: Download..."; |
1230 | - update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv'); |
|
1230 | + update_db::download('http://antonakis.co.uk/registers/Australia.txt', $tmp_dir.'owner_vh.csv'); |
|
1231 | 1231 | if (file_exists($tmp_dir.'owner_vh.csv')) { |
1232 | 1232 | if ($globalDebug) echo "Add to DB..."; |
1233 | - $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH'); |
|
1233 | + $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv', 'VH'); |
|
1234 | 1234 | } else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
1235 | 1235 | if ($error != '') { |
1236 | 1236 | return $error; |
1237 | 1237 | } elseif ($globalDebug) echo "Done\n"; |
1238 | 1238 | if ($globalDebug) echo "Owner Austria: Download..."; |
1239 | - update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv'); |
|
1239 | + update_db::download('http://antonakis.co.uk/registers/Austria.txt', $tmp_dir.'owner_oe.csv'); |
|
1240 | 1240 | if (file_exists($tmp_dir.'owner_oe.csv')) { |
1241 | 1241 | if ($globalDebug) echo "Add to DB..."; |
1242 | - $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE'); |
|
1242 | + $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv', 'OE'); |
|
1243 | 1243 | } else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
1244 | 1244 | if ($error != '') { |
1245 | 1245 | return $error; |
1246 | 1246 | } elseif ($globalDebug) echo "Done\n"; |
1247 | 1247 | if ($globalDebug) echo "Owner Chile: Download..."; |
1248 | - update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv'); |
|
1248 | + update_db::download('http://antonakis.co.uk/registers/Chile.txt', $tmp_dir.'owner_cc.csv'); |
|
1249 | 1249 | if (file_exists($tmp_dir.'owner_cc.csv')) { |
1250 | 1250 | if ($globalDebug) echo "Add to DB..."; |
1251 | - $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC'); |
|
1251 | + $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv', 'CC'); |
|
1252 | 1252 | } else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
1253 | 1253 | if ($error != '') { |
1254 | 1254 | return $error; |
1255 | 1255 | } elseif ($globalDebug) echo "Done\n"; |
1256 | 1256 | if ($globalDebug) echo "Owner Colombia: Download..."; |
1257 | - update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv'); |
|
1257 | + update_db::download('http://antonakis.co.uk/registers/Colombia.txt', $tmp_dir.'owner_hj.csv'); |
|
1258 | 1258 | if (file_exists($tmp_dir.'owner_hj.csv')) { |
1259 | 1259 | if ($globalDebug) echo "Add to DB..."; |
1260 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ'); |
|
1260 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv', 'HJ'); |
|
1261 | 1261 | } else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
1262 | 1262 | if ($error != '') { |
1263 | 1263 | return $error; |
1264 | 1264 | } elseif ($globalDebug) echo "Done\n"; |
1265 | 1265 | if ($globalDebug) echo "Owner Bosnia Herzegobina: Download..."; |
1266 | - update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv'); |
|
1266 | + update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt', $tmp_dir.'owner_e7.csv'); |
|
1267 | 1267 | if (file_exists($tmp_dir.'owner_e7.csv')) { |
1268 | 1268 | if ($globalDebug) echo "Add to DB..."; |
1269 | - $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7'); |
|
1269 | + $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv', 'E7'); |
|
1270 | 1270 | } else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
1271 | 1271 | if ($error != '') { |
1272 | 1272 | return $error; |
1273 | 1273 | } elseif ($globalDebug) echo "Done\n"; |
1274 | 1274 | if ($globalDebug) echo "Owner Brazil: Download..."; |
1275 | - update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv'); |
|
1275 | + update_db::download('http://antonakis.co.uk/registers/Brazil.txt', $tmp_dir.'owner_pp.csv'); |
|
1276 | 1276 | if (file_exists($tmp_dir.'owner_pp.csv')) { |
1277 | 1277 | if ($globalDebug) echo "Add to DB..."; |
1278 | - $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP'); |
|
1278 | + $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv', 'PP'); |
|
1279 | 1279 | } else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
1280 | 1280 | if ($error != '') { |
1281 | 1281 | return $error; |
1282 | 1282 | } elseif ($globalDebug) echo "Done\n"; |
1283 | 1283 | if ($globalDebug) echo "Owner Cayman Islands: Download..."; |
1284 | - update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv'); |
|
1284 | + update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt', $tmp_dir.'owner_vp.csv'); |
|
1285 | 1285 | if (file_exists($tmp_dir.'owner_vp.csv')) { |
1286 | 1286 | if ($globalDebug) echo "Add to DB..."; |
1287 | - $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP'); |
|
1287 | + $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv', 'VP'); |
|
1288 | 1288 | } else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
1289 | 1289 | if ($error != '') { |
1290 | 1290 | return $error; |
1291 | 1291 | } elseif ($globalDebug) echo "Done\n"; |
1292 | 1292 | if ($globalDebug) echo "Owner Croatia: Download..."; |
1293 | - update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv'); |
|
1293 | + update_db::download('http://antonakis.co.uk/registers/Croatia.txt', $tmp_dir.'owner_9a.csv'); |
|
1294 | 1294 | if (file_exists($tmp_dir.'owner_9a.csv')) { |
1295 | 1295 | if ($globalDebug) echo "Add to DB..."; |
1296 | - $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A'); |
|
1296 | + $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv', '9A'); |
|
1297 | 1297 | } else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
1298 | 1298 | if ($error != '') { |
1299 | 1299 | return $error; |
1300 | 1300 | } elseif ($globalDebug) echo "Done\n"; |
1301 | 1301 | if ($globalDebug) echo "Owner Luxembourg: Download..."; |
1302 | - update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv'); |
|
1302 | + update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt', $tmp_dir.'owner_lx.csv'); |
|
1303 | 1303 | if (file_exists($tmp_dir.'owner_lx.csv')) { |
1304 | 1304 | if ($globalDebug) echo "Add to DB..."; |
1305 | - $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX'); |
|
1305 | + $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv', 'LX'); |
|
1306 | 1306 | } else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
1307 | 1307 | if ($error != '') { |
1308 | 1308 | return $error; |
1309 | 1309 | } elseif ($globalDebug) echo "Done\n"; |
1310 | 1310 | if ($globalDebug) echo "Owner Maldives: Download..."; |
1311 | - update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv'); |
|
1311 | + update_db::download('http://antonakis.co.uk/registers/Maldives.txt', $tmp_dir.'owner_8q.csv'); |
|
1312 | 1312 | if (file_exists($tmp_dir.'owner_8q.csv')) { |
1313 | 1313 | if ($globalDebug) echo "Add to DB..."; |
1314 | - $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q'); |
|
1314 | + $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv', '8Q'); |
|
1315 | 1315 | } else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
1316 | 1316 | if ($error != '') { |
1317 | 1317 | return $error; |
1318 | 1318 | } elseif ($globalDebug) echo "Done\n"; |
1319 | 1319 | if ($globalDebug) echo "Owner New Zealand: Download..."; |
1320 | - update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv'); |
|
1320 | + update_db::download('http://antonakis.co.uk/registers/NewZealand.txt', $tmp_dir.'owner_zk.csv'); |
|
1321 | 1321 | if (file_exists($tmp_dir.'owner_zk.csv')) { |
1322 | 1322 | if ($globalDebug) echo "Add to DB..."; |
1323 | - $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK'); |
|
1323 | + $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv', 'ZK'); |
|
1324 | 1324 | } else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
1325 | 1325 | if ($error != '') { |
1326 | 1326 | return $error; |
1327 | 1327 | } elseif ($globalDebug) echo "Done\n"; |
1328 | 1328 | if ($globalDebug) echo "Owner Papua New Guinea: Download..."; |
1329 | - update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv'); |
|
1329 | + update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt', $tmp_dir.'owner_p2.csv'); |
|
1330 | 1330 | if (file_exists($tmp_dir.'owner_p2.csv')) { |
1331 | 1331 | if ($globalDebug) echo "Add to DB..."; |
1332 | - $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2'); |
|
1332 | + $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv', 'P2'); |
|
1333 | 1333 | } else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
1334 | 1334 | if ($error != '') { |
1335 | 1335 | return $error; |
1336 | 1336 | } elseif ($globalDebug) echo "Done\n"; |
1337 | 1337 | if ($globalDebug) echo "Owner Slovakia: Download..."; |
1338 | - update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv'); |
|
1338 | + update_db::download('http://antonakis.co.uk/registers/Slovakia.txt', $tmp_dir.'owner_om.csv'); |
|
1339 | 1339 | if (file_exists($tmp_dir.'owner_om.csv')) { |
1340 | 1340 | if ($globalDebug) echo "Add to DB..."; |
1341 | - $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM'); |
|
1341 | + $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv', 'OM'); |
|
1342 | 1342 | } else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
1343 | 1343 | if ($error != '') { |
1344 | 1344 | return $error; |
1345 | 1345 | } elseif ($globalDebug) echo "Done\n"; |
1346 | 1346 | if ($globalDebug) echo "Owner Ecuador: Download..."; |
1347 | - update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv'); |
|
1347 | + update_db::download('http://antonakis.co.uk/registers/Ecuador.txt', $tmp_dir.'owner_hc.csv'); |
|
1348 | 1348 | if (file_exists($tmp_dir.'owner_hc.csv')) { |
1349 | 1349 | if ($globalDebug) echo "Add to DB..."; |
1350 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC'); |
|
1350 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv', 'HC'); |
|
1351 | 1351 | } else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
1352 | 1352 | if ($error != '') { |
1353 | 1353 | return $error; |
1354 | 1354 | } elseif ($globalDebug) echo "Done\n"; |
1355 | 1355 | if ($globalDebug) echo "Owner Iceland: Download..."; |
1356 | - update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv'); |
|
1356 | + update_db::download('http://antonakis.co.uk/registers/Iceland.txt', $tmp_dir.'owner_tf.csv'); |
|
1357 | 1357 | if (file_exists($tmp_dir.'owner_tf.csv')) { |
1358 | 1358 | if ($globalDebug) echo "Add to DB..."; |
1359 | - $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF'); |
|
1359 | + $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv', 'TF'); |
|
1360 | 1360 | } else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
1361 | 1361 | if ($error != '') { |
1362 | 1362 | return $error; |
@@ -1368,7 +1368,7 @@ discard block |
||
1368 | 1368 | global $tmp_dir, $globalDebug; |
1369 | 1369 | $error = ''; |
1370 | 1370 | if ($globalDebug) echo "Translation : Download..."; |
1371 | - update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip'); |
|
1371 | + update_db::download('http://www.acarsd.org/download/translation.php', $tmp_dir.'translation.zip'); |
|
1372 | 1372 | if (file_exists($tmp_dir.'translation.zip')) { |
1373 | 1373 | if ($globalDebug) echo "Unzip..."; |
1374 | 1374 | update_db::unzip($tmp_dir.'translation.zip'); |
@@ -1385,7 +1385,7 @@ discard block |
||
1385 | 1385 | global $tmp_dir, $globalDebug; |
1386 | 1386 | $error = ''; |
1387 | 1387 | if ($globalDebug) echo "Translation from FlightAirMap website : Download..."; |
1388 | - update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz'); |
|
1388 | + update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz', $tmp_dir.'translation.tsv.gz'); |
|
1389 | 1389 | if (file_exists($tmp_dir.'translation.tsv.gz')) { |
1390 | 1390 | if ($globalDebug) echo "Gunzip..."; |
1391 | 1391 | update_db::gunzip($tmp_dir.'translation.tsv.gz'); |
@@ -1413,8 +1413,8 @@ discard block |
||
1413 | 1413 | */ |
1414 | 1414 | if (file_exists($tmp_dir.'aircrafts.html')) { |
1415 | 1415 | //var_dump(file_get_html($tmp_dir.'aircrafts.html')); |
1416 | - $fh = fopen($tmp_dir.'aircrafts.html',"r"); |
|
1417 | - $result = fread($fh,100000000); |
|
1416 | + $fh = fopen($tmp_dir.'aircrafts.html', "r"); |
|
1417 | + $result = fread($fh, 100000000); |
|
1418 | 1418 | //echo $result; |
1419 | 1419 | //var_dump(str_get_html($result)); |
1420 | 1420 | //print_r(self::table2array($result)); |
@@ -1432,23 +1432,23 @@ discard block |
||
1432 | 1432 | $Connection = new Connection(); |
1433 | 1433 | $sth = $Connection->db->prepare($query); |
1434 | 1434 | $sth->execute(); |
1435 | - } catch(PDOException $e) { |
|
1435 | + } catch (PDOException $e) { |
|
1436 | 1436 | return "error : ".$e->getMessage(); |
1437 | 1437 | } |
1438 | 1438 | |
1439 | 1439 | $error = ''; |
1440 | 1440 | if ($globalDebug) echo "Notam : Download..."; |
1441 | - update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss'); |
|
1441 | + update_db::download($globalNOTAMSource, $tmp_dir.'notam.rss'); |
|
1442 | 1442 | if (file_exists($tmp_dir.'notam.rss')) { |
1443 | - $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true); |
|
1443 | + $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')), true); |
|
1444 | 1444 | foreach ($notams['channel']['item'] as $notam) { |
1445 | - $title = explode(':',$notam['title']); |
|
1445 | + $title = explode(':', $notam['title']); |
|
1446 | 1446 | $data['ref'] = trim($title[0]); |
1447 | 1447 | unset($title[0]); |
1448 | - $data['title'] = trim(implode(':',$title)); |
|
1449 | - $description = strip_tags($notam['description'],'<pre>'); |
|
1450 | - preg_match(':^(.*?)<pre>:',$description,$match); |
|
1451 | - $q = explode('/',$match[1]); |
|
1448 | + $data['title'] = trim(implode(':', $title)); |
|
1449 | + $description = strip_tags($notam['description'], '<pre>'); |
|
1450 | + preg_match(':^(.*?)<pre>:', $description, $match); |
|
1451 | + $q = explode('/', $match[1]); |
|
1452 | 1452 | $data['fir'] = $q[0]; |
1453 | 1453 | $data['code'] = $q[1]; |
1454 | 1454 | $ifrvfr = $q[2]; |
@@ -1464,30 +1464,30 @@ discard block |
||
1464 | 1464 | $data['lower_limit'] = $q[5]; |
1465 | 1465 | $data['upper_limit'] = $q[6]; |
1466 | 1466 | $latlonrad = $q[7]; |
1467 | - sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius); |
|
1468 | - $latitude = $Common->convertDec($las,'latitude'); |
|
1469 | - $longitude = $Common->convertDec($lns,'longitude'); |
|
1467 | + sscanf($latlonrad, '%4c%c%5c%c%3d', $las, $lac, $lns, $lnc, $radius); |
|
1468 | + $latitude = $Common->convertDec($las, 'latitude'); |
|
1469 | + $longitude = $Common->convertDec($lns, 'longitude'); |
|
1470 | 1470 | if ($lac == 'S') $latitude = '-'.$latitude; |
1471 | 1471 | if ($lnc == 'W') $longitude = '-'.$longitude; |
1472 | 1472 | $data['center_latitude'] = $latitude; |
1473 | 1473 | $data['center_longitude'] = $longitude; |
1474 | 1474 | $data['radius'] = intval($radius); |
1475 | 1475 | |
1476 | - preg_match(':<pre>(.*?)</pre>:',$description,$match); |
|
1476 | + preg_match(':<pre>(.*?)</pre>:', $description, $match); |
|
1477 | 1477 | $data['text'] = $match[1]; |
1478 | - preg_match(':</pre>(.*?)$:',$description,$match); |
|
1478 | + preg_match(':</pre>(.*?)$:', $description, $match); |
|
1479 | 1479 | $fromto = $match[1]; |
1480 | - preg_match('#FROM:(.*?)TO:#',$fromto,$match); |
|
1480 | + preg_match('#FROM:(.*?)TO:#', $fromto, $match); |
|
1481 | 1481 | $fromall = trim($match[1]); |
1482 | - preg_match('#^(.*?) \((.*?)\)$#',$fromall,$match); |
|
1482 | + preg_match('#^(.*?) \((.*?)\)$#', $fromall, $match); |
|
1483 | 1483 | $from = trim($match[1]); |
1484 | - $data['date_begin'] = date("Y-m-d H:i:s",strtotime($from)); |
|
1485 | - preg_match('#TO:(.*?)$#',$fromto,$match); |
|
1484 | + $data['date_begin'] = date("Y-m-d H:i:s", strtotime($from)); |
|
1485 | + preg_match('#TO:(.*?)$#', $fromto, $match); |
|
1486 | 1486 | $toall = trim($match[1]); |
1487 | - if (!preg_match(':Permanent:',$toall)) { |
|
1488 | - preg_match('#^(.*?) \((.*?)\)#',$toall,$match); |
|
1487 | + if (!preg_match(':Permanent:', $toall)) { |
|
1488 | + preg_match('#^(.*?) \((.*?)\)#', $toall, $match); |
|
1489 | 1489 | $to = trim($match[1]); |
1490 | - $data['date_end'] = date("Y-m-d H:i:s",strtotime($to)); |
|
1490 | + $data['date_end'] = date("Y-m-d H:i:s", strtotime($to)); |
|
1491 | 1491 | $data['permanent'] = 0; |
1492 | 1492 | } else { |
1493 | 1493 | $data['date_end'] = NULL; |
@@ -1495,7 +1495,7 @@ discard block |
||
1495 | 1495 | } |
1496 | 1496 | $data['full_notam'] = $notam['title'].'<br>'.$notam['description']; |
1497 | 1497 | $NOTAM = new NOTAM(); |
1498 | - $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']); |
|
1498 | + $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 | 1499 | unset($data); |
1500 | 1500 | } |
1501 | 1501 | } else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
@@ -1516,7 +1516,7 @@ discard block |
||
1516 | 1516 | $Connection = new Connection(); |
1517 | 1517 | $sth = $Connection->db->prepare($query); |
1518 | 1518 | $sth->execute(); |
1519 | - } catch(PDOException $e) { |
|
1519 | + } catch (PDOException $e) { |
|
1520 | 1520 | return "error : ".$e->getMessage(); |
1521 | 1521 | } |
1522 | 1522 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -1531,7 +1531,7 @@ discard block |
||
1531 | 1531 | $Connection = new Connection(); |
1532 | 1532 | $sth = $Connection->db->prepare($query); |
1533 | 1533 | $sth->execute(); |
1534 | - } catch(PDOException $e) { |
|
1534 | + } catch (PDOException $e) { |
|
1535 | 1535 | return "error : ".$e->getMessage(); |
1536 | 1536 | } |
1537 | 1537 | } |
@@ -1547,7 +1547,7 @@ discard block |
||
1547 | 1547 | $Connection = new Connection(); |
1548 | 1548 | $sth = $Connection->db->prepare($query); |
1549 | 1549 | $sth->execute(); |
1550 | - } catch(PDOException $e) { |
|
1550 | + } catch (PDOException $e) { |
|
1551 | 1551 | return "error : ".$e->getMessage(); |
1552 | 1552 | } |
1553 | 1553 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -1562,7 +1562,7 @@ discard block |
||
1562 | 1562 | $Connection = new Connection(); |
1563 | 1563 | $sth = $Connection->db->prepare($query); |
1564 | 1564 | $sth->execute(); |
1565 | - } catch(PDOException $e) { |
|
1565 | + } catch (PDOException $e) { |
|
1566 | 1566 | return "error : ".$e->getMessage(); |
1567 | 1567 | } |
1568 | 1568 | } |
@@ -1578,7 +1578,7 @@ discard block |
||
1578 | 1578 | $Connection = new Connection(); |
1579 | 1579 | $sth = $Connection->db->prepare($query); |
1580 | 1580 | $sth->execute(); |
1581 | - } catch(PDOException $e) { |
|
1581 | + } catch (PDOException $e) { |
|
1582 | 1582 | return "error : ".$e->getMessage(); |
1583 | 1583 | } |
1584 | 1584 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -1593,7 +1593,7 @@ discard block |
||
1593 | 1593 | $Connection = new Connection(); |
1594 | 1594 | $sth = $Connection->db->prepare($query); |
1595 | 1595 | $sth->execute(); |
1596 | - } catch(PDOException $e) { |
|
1596 | + } catch (PDOException $e) { |
|
1597 | 1597 | return "error : ".$e->getMessage(); |
1598 | 1598 | } |
1599 | 1599 | } |
@@ -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() { |