@@ -75,38 +75,38 @@ discard block |
||
75 | 75 | try { |
76 | 76 | //$Connection = new Connection(); |
77 | 77 | $sth = $Connection->db->prepare($query); |
78 | - $sth->execute(array(':source' => $database_file)); |
|
79 | - } catch(PDOException $e) { |
|
80 | - return "error : ".$e->getMessage(); |
|
81 | - } |
|
78 | + $sth->execute(array(':source' => $database_file)); |
|
79 | + } catch(PDOException $e) { |
|
80 | + return "error : ".$e->getMessage(); |
|
81 | + } |
|
82 | 82 | |
83 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
84 | - update_db::connect_sqlite($database_file); |
|
83 | + if ($globalDebug) echo " - Add routes to DB -"; |
|
84 | + update_db::connect_sqlite($database_file); |
|
85 | 85 | //$query = 'select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID'; |
86 | 86 | $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"; |
87 | 87 | try { |
88 | - $sth = update_db::$db_sqlite->prepare($query); |
|
89 | - $sth->execute(); |
|
90 | - } catch(PDOException $e) { |
|
91 | - return "error : ".$e->getMessage(); |
|
92 | - } |
|
88 | + $sth = update_db::$db_sqlite->prepare($query); |
|
89 | + $sth->execute(); |
|
90 | + } catch(PDOException $e) { |
|
91 | + return "error : ".$e->getMessage(); |
|
92 | + } |
|
93 | 93 | //$query_dest = 'INSERT INTO routes (`RouteID`,`CallSign`,`Operator_ICAO`,`FromAirport_ICAO`,`ToAirport_ICAO`,`RouteStop`,`Source`) VALUES (:RouteID, :CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)'; |
94 | 94 | $query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,ToAirport_ICAO,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)'; |
95 | 95 | $Connection = new Connection(); |
96 | 96 | $sth_dest = $Connection->db->prepare($query_dest); |
97 | 97 | try { |
98 | 98 | if ($globalTransaction) $Connection->db->beginTransaction(); |
99 | - while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
99 | + while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
100 | 100 | //$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
101 | 101 | $query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
102 | 102 | $sth_dest->execute($query_dest_values); |
103 | - } |
|
103 | + } |
|
104 | 104 | if ($globalTransaction) $Connection->db->commit(); |
105 | 105 | } catch(PDOException $e) { |
106 | 106 | if ($globalTransaction) $Connection->db->rollBack(); |
107 | 107 | return "error : ".$e->getMessage(); |
108 | 108 | } |
109 | - return ''; |
|
109 | + return ''; |
|
110 | 110 | } |
111 | 111 | public static function retrieve_route_oneworld($database_file) { |
112 | 112 | global $globalDebug, $globalTransaction; |
@@ -117,12 +117,12 @@ discard block |
||
117 | 117 | try { |
118 | 118 | //$Connection = new Connection(); |
119 | 119 | $sth = $Connection->db->prepare($query); |
120 | - $sth->execute(array(':source' => 'oneworld')); |
|
121 | - } catch(PDOException $e) { |
|
122 | - return "error : ".$e->getMessage(); |
|
123 | - } |
|
120 | + $sth->execute(array(':source' => 'oneworld')); |
|
121 | + } catch(PDOException $e) { |
|
122 | + return "error : ".$e->getMessage(); |
|
123 | + } |
|
124 | 124 | |
125 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
125 | + if ($globalDebug) echo " - Add routes to DB -"; |
|
126 | 126 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
127 | 127 | $Spotter = new Spotter(); |
128 | 128 | if ($fh = fopen($database_file,"r")) { |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | } |
147 | 147 | if ($globalTransaction) $Connection->db->commit(); |
148 | 148 | } |
149 | - return ''; |
|
149 | + return ''; |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | public static function retrieve_route_skyteam($database_file) { |
@@ -158,12 +158,12 @@ discard block |
||
158 | 158 | try { |
159 | 159 | //$Connection = new Connection(); |
160 | 160 | $sth = $Connection->db->prepare($query); |
161 | - $sth->execute(array(':source' => 'skyteam')); |
|
162 | - } catch(PDOException $e) { |
|
163 | - return "error : ".$e->getMessage(); |
|
164 | - } |
|
161 | + $sth->execute(array(':source' => 'skyteam')); |
|
162 | + } catch(PDOException $e) { |
|
163 | + return "error : ".$e->getMessage(); |
|
164 | + } |
|
165 | 165 | |
166 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
166 | + if ($globalDebug) echo " - Add routes to DB -"; |
|
167 | 167 | |
168 | 168 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
169 | 169 | $Spotter = new Spotter(); |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | return "error : ".$e->getMessage(); |
190 | 190 | } |
191 | 191 | } |
192 | - return ''; |
|
192 | + return ''; |
|
193 | 193 | } |
194 | 194 | public static function retrieve_modes_sqlite_to_dest($database_file) { |
195 | 195 | global $globalTransaction; |
@@ -198,27 +198,27 @@ discard block |
||
198 | 198 | try { |
199 | 199 | $Connection = new Connection(); |
200 | 200 | $sth = $Connection->db->prepare($query); |
201 | - $sth->execute(array(':source' => $database_file)); |
|
202 | - } catch(PDOException $e) { |
|
203 | - return "error : ".$e->getMessage(); |
|
204 | - } |
|
201 | + $sth->execute(array(':source' => $database_file)); |
|
202 | + } catch(PDOException $e) { |
|
203 | + return "error : ".$e->getMessage(); |
|
204 | + } |
|
205 | 205 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source"; |
206 | 206 | try { |
207 | 207 | $Connection = new Connection(); |
208 | 208 | $sth = $Connection->db->prepare($query); |
209 | - $sth->execute(array(':source' => $database_file)); |
|
210 | - } catch(PDOException $e) { |
|
211 | - return "error : ".$e->getMessage(); |
|
212 | - } |
|
209 | + $sth->execute(array(':source' => $database_file)); |
|
210 | + } catch(PDOException $e) { |
|
211 | + return "error : ".$e->getMessage(); |
|
212 | + } |
|
213 | 213 | |
214 | - update_db::connect_sqlite($database_file); |
|
214 | + update_db::connect_sqlite($database_file); |
|
215 | 215 | $query = 'select * from Aircraft'; |
216 | 216 | try { |
217 | - $sth = update_db::$db_sqlite->prepare($query); |
|
218 | - $sth->execute(); |
|
219 | - } catch(PDOException $e) { |
|
220 | - return "error : ".$e->getMessage(); |
|
221 | - } |
|
217 | + $sth = update_db::$db_sqlite->prepare($query); |
|
218 | + $sth->execute(); |
|
219 | + } catch(PDOException $e) { |
|
220 | + return "error : ".$e->getMessage(); |
|
221 | + } |
|
222 | 222 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
223 | 223 | $query_dest = 'INSERT INTO aircraft_modes (LastModified, ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type,:source)'; |
224 | 224 | |
@@ -229,17 +229,17 @@ discard block |
||
229 | 229 | $sth_dest_owner = $Connection->db->prepare($query_dest_owner); |
230 | 230 | try { |
231 | 231 | if ($globalTransaction) $Connection->db->beginTransaction(); |
232 | - while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
232 | + while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
233 | 233 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
234 | 234 | if ($values['UserString4'] == 'M') $type = 'military'; |
235 | 235 | else $type = null; |
236 | 236 | $query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type); |
237 | 237 | $sth_dest->execute($query_dest_values); |
238 | 238 | if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') { |
239 | - $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']); |
|
240 | - $sth_dest_owner->execute($query_dest_owner_values); |
|
239 | + $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']); |
|
240 | + $sth_dest_owner->execute($query_dest_owner_values); |
|
241 | 241 | } |
242 | - } |
|
242 | + } |
|
243 | 243 | if ($globalTransaction) $Connection->db->commit(); |
244 | 244 | } catch(PDOException $e) { |
245 | 245 | return "error : ".$e->getMessage(); |
@@ -249,10 +249,10 @@ discard block |
||
249 | 249 | try { |
250 | 250 | $Connection = new Connection(); |
251 | 251 | $sth = $Connection->db->prepare($query); |
252 | - $sth->execute(array(':source' => $database_file)); |
|
253 | - } catch(PDOException $e) { |
|
254 | - return "error : ".$e->getMessage(); |
|
255 | - } |
|
252 | + $sth->execute(array(':source' => $database_file)); |
|
253 | + } catch(PDOException $e) { |
|
254 | + return "error : ".$e->getMessage(); |
|
255 | + } |
|
256 | 256 | return ''; |
257 | 257 | } |
258 | 258 | |
@@ -264,10 +264,10 @@ discard block |
||
264 | 264 | try { |
265 | 265 | $Connection = new Connection(); |
266 | 266 | $sth = $Connection->db->prepare($query); |
267 | - $sth->execute(array(':source' => $database_file)); |
|
268 | - } catch(PDOException $e) { |
|
269 | - return "error : ".$e->getMessage(); |
|
270 | - } |
|
267 | + $sth->execute(array(':source' => $database_file)); |
|
268 | + } catch(PDOException $e) { |
|
269 | + return "error : ".$e->getMessage(); |
|
270 | + } |
|
271 | 271 | |
272 | 272 | if ($fh = fopen($database_file,"r")) { |
273 | 273 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
@@ -277,26 +277,26 @@ discard block |
||
277 | 277 | $sth_dest = $Connection->db->prepare($query_dest); |
278 | 278 | try { |
279 | 279 | if ($globalTransaction) $Connection->db->beginTransaction(); |
280 | - while (!feof($fh)) { |
|
281 | - $values = array(); |
|
282 | - $line = $Common->hex2str(fgets($fh,9999)); |
|
280 | + while (!feof($fh)) { |
|
281 | + $values = array(); |
|
282 | + $line = $Common->hex2str(fgets($fh,9999)); |
|
283 | 283 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
284 | - $values['ModeS'] = substr($line,0,6); |
|
285 | - $values['Registration'] = trim(substr($line,69,6)); |
|
286 | - $aircraft_name = trim(substr($line,48,6)); |
|
287 | - // Check if we can find ICAO, else set it to GLID |
|
288 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
289 | - $search_more = ''; |
|
290 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
291 | - $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
292 | - $sth_search = $Connection->db->prepare($query_search); |
|
284 | + $values['ModeS'] = substr($line,0,6); |
|
285 | + $values['Registration'] = trim(substr($line,69,6)); |
|
286 | + $aircraft_name = trim(substr($line,48,6)); |
|
287 | + // Check if we can find ICAO, else set it to GLID |
|
288 | + $aircraft_name_split = explode(' ',$aircraft_name); |
|
289 | + $search_more = ''; |
|
290 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
291 | + $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
292 | + $sth_search = $Connection->db->prepare($query_search); |
|
293 | 293 | try { |
294 | - $sth_search->execute(); |
|
295 | - $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
296 | - //if (count($result) > 0) { |
|
297 | - if (isset($result['icao']) && $result['icao'] != '') { |
|
298 | - $values['ICAOTypeCode'] = $result['icao']; |
|
299 | - } |
|
294 | + $sth_search->execute(); |
|
295 | + $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
296 | + //if (count($result) > 0) { |
|
297 | + if (isset($result['icao']) && $result['icao'] != '') { |
|
298 | + $values['ICAOTypeCode'] = $result['icao']; |
|
299 | + } |
|
300 | 300 | } catch(PDOException $e) { |
301 | 301 | return "error : ".$e->getMessage(); |
302 | 302 | } |
@@ -319,10 +319,10 @@ discard block |
||
319 | 319 | try { |
320 | 320 | $Connection = new Connection(); |
321 | 321 | $sth = $Connection->db->prepare($query); |
322 | - $sth->execute(array(':source' => $database_file)); |
|
323 | - } catch(PDOException $e) { |
|
324 | - return "error : ".$e->getMessage(); |
|
325 | - } |
|
322 | + $sth->execute(array(':source' => $database_file)); |
|
323 | + } catch(PDOException $e) { |
|
324 | + return "error : ".$e->getMessage(); |
|
325 | + } |
|
326 | 326 | return ''; |
327 | 327 | } |
328 | 328 | |
@@ -333,10 +333,10 @@ discard block |
||
333 | 333 | try { |
334 | 334 | $Connection = new Connection(); |
335 | 335 | $sth = $Connection->db->prepare($query); |
336 | - $sth->execute(array(':source' => $database_file)); |
|
337 | - } catch(PDOException $e) { |
|
338 | - return "error : ".$e->getMessage(); |
|
339 | - } |
|
336 | + $sth->execute(array(':source' => $database_file)); |
|
337 | + } catch(PDOException $e) { |
|
338 | + return "error : ".$e->getMessage(); |
|
339 | + } |
|
340 | 340 | |
341 | 341 | if ($fh = fopen($database_file,"r")) { |
342 | 342 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
@@ -347,24 +347,24 @@ discard block |
||
347 | 347 | try { |
348 | 348 | if ($globalTransaction) $Connection->db->beginTransaction(); |
349 | 349 | $tmp = fgetcsv($fh,9999,',',"'"); |
350 | - while (!feof($fh)) { |
|
351 | - $line = fgetcsv($fh,9999,',',"'"); |
|
350 | + while (!feof($fh)) { |
|
351 | + $line = fgetcsv($fh,9999,',',"'"); |
|
352 | 352 | |
353 | 353 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
354 | 354 | //print_r($line); |
355 | - $values['ModeS'] = $line[1]; |
|
356 | - $values['Registration'] = $line[3]; |
|
357 | - $aircraft_name = $line[2]; |
|
358 | - // Check if we can find ICAO, else set it to GLID |
|
359 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
360 | - $search_more = ''; |
|
361 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
362 | - $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
363 | - $sth_search = $Connection->db->prepare($query_search); |
|
355 | + $values['ModeS'] = $line[1]; |
|
356 | + $values['Registration'] = $line[3]; |
|
357 | + $aircraft_name = $line[2]; |
|
358 | + // Check if we can find ICAO, else set it to GLID |
|
359 | + $aircraft_name_split = explode(' ',$aircraft_name); |
|
360 | + $search_more = ''; |
|
361 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
362 | + $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
363 | + $sth_search = $Connection->db->prepare($query_search); |
|
364 | 364 | try { |
365 | - $sth_search->execute(); |
|
366 | - $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
367 | - if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
|
365 | + $sth_search->execute(); |
|
366 | + $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
367 | + if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
|
368 | 368 | } catch(PDOException $e) { |
369 | 369 | return "error : ".$e->getMessage(); |
370 | 370 | } |
@@ -387,10 +387,10 @@ discard block |
||
387 | 387 | try { |
388 | 388 | $Connection = new Connection(); |
389 | 389 | $sth = $Connection->db->prepare($query); |
390 | - $sth->execute(array(':source' => $database_file)); |
|
391 | - } catch(PDOException $e) { |
|
392 | - return "error : ".$e->getMessage(); |
|
393 | - } |
|
390 | + $sth->execute(array(':source' => $database_file)); |
|
391 | + } catch(PDOException $e) { |
|
392 | + return "error : ".$e->getMessage(); |
|
393 | + } |
|
394 | 394 | return ''; |
395 | 395 | } |
396 | 396 | |
@@ -401,10 +401,10 @@ discard block |
||
401 | 401 | try { |
402 | 402 | $Connection = new Connection(); |
403 | 403 | $sth = $Connection->db->prepare($query); |
404 | - $sth->execute(array(':source' => $database_file)); |
|
405 | - } catch(PDOException $e) { |
|
406 | - return "error : ".$e->getMessage(); |
|
407 | - } |
|
404 | + $sth->execute(array(':source' => $database_file)); |
|
405 | + } catch(PDOException $e) { |
|
406 | + return "error : ".$e->getMessage(); |
|
407 | + } |
|
408 | 408 | |
409 | 409 | if ($fh = fopen($database_file,"r")) { |
410 | 410 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
@@ -415,95 +415,95 @@ discard block |
||
415 | 415 | try { |
416 | 416 | if ($globalTransaction) $Connection->db->beginTransaction(); |
417 | 417 | $tmp = fgetcsv($fh,9999,',','"'); |
418 | - while (!feof($fh)) { |
|
419 | - $line = fgetcsv($fh,9999,',','"'); |
|
420 | - $values = array(); |
|
421 | - //print_r($line); |
|
422 | - if ($country == 'F') { |
|
423 | - $values['registration'] = $line[0]; |
|
424 | - $values['base'] = $line[4]; |
|
425 | - $values['owner'] = $line[5]; |
|
426 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
427 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
428 | - $values['cancel'] = $line[7]; |
|
418 | + while (!feof($fh)) { |
|
419 | + $line = fgetcsv($fh,9999,',','"'); |
|
420 | + $values = array(); |
|
421 | + //print_r($line); |
|
422 | + if ($country == 'F') { |
|
423 | + $values['registration'] = $line[0]; |
|
424 | + $values['base'] = $line[4]; |
|
425 | + $values['owner'] = $line[5]; |
|
426 | + if ($line[6] == '') $values['date_first_reg'] = null; |
|
427 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
428 | + $values['cancel'] = $line[7]; |
|
429 | 429 | } elseif ($country == 'EI') { |
430 | - // TODO : add modeS & reg to aircraft_modes |
|
431 | - $values['registration'] = $line[0]; |
|
432 | - $values['base'] = $line[3]; |
|
433 | - $values['owner'] = $line[2]; |
|
434 | - if ($line[1] == '') $values['date_first_reg'] = null; |
|
435 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
436 | - $values['cancel'] = ''; |
|
430 | + // TODO : add modeS & reg to aircraft_modes |
|
431 | + $values['registration'] = $line[0]; |
|
432 | + $values['base'] = $line[3]; |
|
433 | + $values['owner'] = $line[2]; |
|
434 | + if ($line[1] == '') $values['date_first_reg'] = null; |
|
435 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
436 | + $values['cancel'] = ''; |
|
437 | 437 | } elseif ($country == 'HB') { |
438 | - // TODO : add modeS & reg to aircraft_modes |
|
439 | - $values['registration'] = $line[0]; |
|
440 | - $values['base'] = null; |
|
441 | - $values['owner'] = $line[5]; |
|
442 | - $values['date_first_reg'] = null; |
|
443 | - $values['cancel'] = ''; |
|
438 | + // TODO : add modeS & reg to aircraft_modes |
|
439 | + $values['registration'] = $line[0]; |
|
440 | + $values['base'] = null; |
|
441 | + $values['owner'] = $line[5]; |
|
442 | + $values['date_first_reg'] = null; |
|
443 | + $values['cancel'] = ''; |
|
444 | 444 | } elseif ($country == 'OK') { |
445 | - // TODO : add modeS & reg to aircraft_modes |
|
446 | - $values['registration'] = $line[3]; |
|
447 | - $values['base'] = null; |
|
448 | - $values['owner'] = $line[5]; |
|
449 | - if ($line[18] == '') $values['date_first_reg'] = null; |
|
450 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
451 | - $values['cancel'] = ''; |
|
445 | + // TODO : add modeS & reg to aircraft_modes |
|
446 | + $values['registration'] = $line[3]; |
|
447 | + $values['base'] = null; |
|
448 | + $values['owner'] = $line[5]; |
|
449 | + if ($line[18] == '') $values['date_first_reg'] = null; |
|
450 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
451 | + $values['cancel'] = ''; |
|
452 | 452 | } elseif ($country == 'VH') { |
453 | - // TODO : add modeS & reg to aircraft_modes |
|
454 | - $values['registration'] = $line[0]; |
|
455 | - $values['base'] = null; |
|
456 | - $values['owner'] = $line[12]; |
|
457 | - if ($line[28] == '') $values['date_first_reg'] = null; |
|
458 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
459 | - |
|
460 | - $values['cancel'] = $line[39]; |
|
453 | + // TODO : add modeS & reg to aircraft_modes |
|
454 | + $values['registration'] = $line[0]; |
|
455 | + $values['base'] = null; |
|
456 | + $values['owner'] = $line[12]; |
|
457 | + if ($line[28] == '') $values['date_first_reg'] = null; |
|
458 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
459 | + |
|
460 | + $values['cancel'] = $line[39]; |
|
461 | 461 | } elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { |
462 | - $values['registration'] = $line[0]; |
|
463 | - $values['base'] = null; |
|
464 | - $values['owner'] = $line[4]; |
|
465 | - $values['date_first_reg'] = null; |
|
466 | - $values['cancel'] = ''; |
|
462 | + $values['registration'] = $line[0]; |
|
463 | + $values['base'] = null; |
|
464 | + $values['owner'] = $line[4]; |
|
465 | + $values['date_first_reg'] = null; |
|
466 | + $values['cancel'] = ''; |
|
467 | 467 | } elseif ($country == 'CC') { |
468 | - $values['registration'] = $line[0]; |
|
469 | - $values['base'] = null; |
|
470 | - $values['owner'] = $line[6]; |
|
471 | - $values['date_first_reg'] = null; |
|
472 | - $values['cancel'] = ''; |
|
468 | + $values['registration'] = $line[0]; |
|
469 | + $values['base'] = null; |
|
470 | + $values['owner'] = $line[6]; |
|
471 | + $values['date_first_reg'] = null; |
|
472 | + $values['cancel'] = ''; |
|
473 | 473 | } elseif ($country == 'HJ') { |
474 | - $values['registration'] = $line[0]; |
|
475 | - $values['base'] = null; |
|
476 | - $values['owner'] = $line[8]; |
|
477 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
478 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
479 | - $values['cancel'] = ''; |
|
474 | + $values['registration'] = $line[0]; |
|
475 | + $values['base'] = null; |
|
476 | + $values['owner'] = $line[8]; |
|
477 | + if ($line[7] == '') $values['date_first_reg'] = null; |
|
478 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
479 | + $values['cancel'] = ''; |
|
480 | 480 | } elseif ($country == 'PP') { |
481 | - $values['registration'] = $line[0]; |
|
482 | - $values['base'] = null; |
|
483 | - $values['owner'] = $line[4]; |
|
484 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
485 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
486 | - $values['cancel'] = $line[7]; |
|
481 | + $values['registration'] = $line[0]; |
|
482 | + $values['base'] = null; |
|
483 | + $values['owner'] = $line[4]; |
|
484 | + if ($line[6] == '') $values['date_first_reg'] = null; |
|
485 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
486 | + $values['cancel'] = $line[7]; |
|
487 | 487 | } elseif ($country == 'E7') { |
488 | - $values['registration'] = $line[0]; |
|
489 | - $values['base'] = null; |
|
490 | - $values['owner'] = $line[4]; |
|
491 | - if ($line[5] == '') $values['date_first_reg'] = null; |
|
492 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
493 | - $values['cancel'] = ''; |
|
488 | + $values['registration'] = $line[0]; |
|
489 | + $values['base'] = null; |
|
490 | + $values['owner'] = $line[4]; |
|
491 | + if ($line[5] == '') $values['date_first_reg'] = null; |
|
492 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
493 | + $values['cancel'] = ''; |
|
494 | 494 | } elseif ($country == '8Q') { |
495 | - $values['registration'] = $line[0]; |
|
496 | - $values['base'] = null; |
|
497 | - $values['owner'] = $line[3]; |
|
498 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
499 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
500 | - $values['cancel'] = ''; |
|
495 | + $values['registration'] = $line[0]; |
|
496 | + $values['base'] = null; |
|
497 | + $values['owner'] = $line[3]; |
|
498 | + if ($line[7] == '') $values['date_first_reg'] = null; |
|
499 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
500 | + $values['cancel'] = ''; |
|
501 | 501 | } elseif ($country == 'ZK' || $country == 'OM' || $country == 'TF') { |
502 | - $values['registration'] = $line[0]; |
|
503 | - $values['base'] = null; |
|
504 | - $values['owner'] = $line[3]; |
|
505 | - $values['date_first_reg'] = null; |
|
506 | - $values['cancel'] = ''; |
|
502 | + $values['registration'] = $line[0]; |
|
503 | + $values['base'] = null; |
|
504 | + $values['owner'] = $line[3]; |
|
505 | + $values['date_first_reg'] = null; |
|
506 | + $values['cancel'] = ''; |
|
507 | 507 | } |
508 | 508 | if ($values['cancel'] == '' && $values['registration'] != null) { |
509 | 509 | $query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file); |
@@ -625,20 +625,20 @@ discard block |
||
625 | 625 | try { |
626 | 626 | $Connection = new Connection(); |
627 | 627 | $sth = $Connection->db->prepare($query); |
628 | - $sth->execute(); |
|
629 | - } catch(PDOException $e) { |
|
630 | - return "error : ".$e->getMessage(); |
|
631 | - } |
|
628 | + $sth->execute(); |
|
629 | + } catch(PDOException $e) { |
|
630 | + return "error : ".$e->getMessage(); |
|
631 | + } |
|
632 | 632 | |
633 | 633 | |
634 | 634 | $query = 'ALTER TABLE airport DROP INDEX icaoidx'; |
635 | 635 | try { |
636 | 636 | $Connection = new Connection(); |
637 | 637 | $sth = $Connection->db->prepare($query); |
638 | - $sth->execute(); |
|
639 | - } catch(PDOException $e) { |
|
640 | - return "error : ".$e->getMessage(); |
|
641 | - } |
|
638 | + $sth->execute(); |
|
639 | + } catch(PDOException $e) { |
|
640 | + return "error : ".$e->getMessage(); |
|
641 | + } |
|
642 | 642 | |
643 | 643 | $query_dest = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image_thumb`,`image`) |
644 | 644 | VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)"; |
@@ -704,10 +704,10 @@ discard block |
||
704 | 704 | try { |
705 | 705 | $Connection = new Connection(); |
706 | 706 | $sth = $Connection->db->prepare($query); |
707 | - $sth->execute(); |
|
708 | - } catch(PDOException $e) { |
|
709 | - return "error : ".$e->getMessage(); |
|
710 | - } |
|
707 | + $sth->execute(); |
|
708 | + } catch(PDOException $e) { |
|
709 | + return "error : ".$e->getMessage(); |
|
710 | + } |
|
711 | 711 | |
712 | 712 | |
713 | 713 | if ($globalDebug) echo "Insert Not available Airport...\n"; |
@@ -717,10 +717,10 @@ discard block |
||
717 | 717 | try { |
718 | 718 | $Connection = new Connection(); |
719 | 719 | $sth = $Connection->db->prepare($query); |
720 | - $sth->execute($query_values); |
|
721 | - } catch(PDOException $e) { |
|
722 | - return "error : ".$e->getMessage(); |
|
723 | - } |
|
720 | + $sth->execute($query_values); |
|
721 | + } catch(PDOException $e) { |
|
722 | + return "error : ".$e->getMessage(); |
|
723 | + } |
|
724 | 724 | $i++; |
725 | 725 | /* |
726 | 726 | $query = 'DELETE FROM airport WHERE airport_id IN (SELECT * FROM (SELECT min(a.airport_id) FROM airport a GROUP BY a.icao) x)'; |
@@ -834,7 +834,7 @@ discard block |
||
834 | 834 | |
835 | 835 | |
836 | 836 | |
837 | - return "success"; |
|
837 | + return "success"; |
|
838 | 838 | } |
839 | 839 | |
840 | 840 | public static function translation() { |
@@ -850,10 +850,10 @@ discard block |
||
850 | 850 | try { |
851 | 851 | $Connection = new Connection(); |
852 | 852 | $sth = $Connection->db->prepare($query); |
853 | - $sth->execute(array(':source' => 'translation.csv')); |
|
854 | - } catch(PDOException $e) { |
|
855 | - return "error : ".$e->getMessage(); |
|
856 | - } |
|
853 | + $sth->execute(array(':source' => 'translation.csv')); |
|
854 | + } catch(PDOException $e) { |
|
855 | + return "error : ".$e->getMessage(); |
|
856 | + } |
|
857 | 857 | |
858 | 858 | |
859 | 859 | //update_db::unzip($out_file); |
@@ -872,21 +872,21 @@ discard block |
||
872 | 872 | $data = $row; |
873 | 873 | $operator = $data[2]; |
874 | 874 | if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) { |
875 | - $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2)); |
|
876 | - //echo substr($operator, 0, 2)."\n";; |
|
877 | - if (count($airline_array) > 0) { |
|
875 | + $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2)); |
|
876 | + //echo substr($operator, 0, 2)."\n";; |
|
877 | + if (count($airline_array) > 0) { |
|
878 | 878 | //print_r($airline_array); |
879 | 879 | $operator = $airline_array[0]['icao'].substr($operator,2); |
880 | - } |
|
881 | - } |
|
880 | + } |
|
881 | + } |
|
882 | 882 | |
883 | 883 | $operator_correct = $data[3]; |
884 | 884 | if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) { |
885 | - $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2)); |
|
886 | - if (count($airline_array) > 0) { |
|
887 | - $operator_correct = $airline_array[0]['icao'].substr($operator_correct,2); |
|
888 | - } |
|
889 | - } |
|
885 | + $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2)); |
|
886 | + if (count($airline_array) > 0) { |
|
887 | + $operator_correct = $airline_array[0]['icao'].substr($operator_correct,2); |
|
888 | + } |
|
889 | + } |
|
890 | 890 | $query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)'; |
891 | 891 | try { |
892 | 892 | $sth = $Connection->db->prepare($query); |
@@ -900,7 +900,7 @@ discard block |
||
900 | 900 | //$Connection->db->commit(); |
901 | 901 | } |
902 | 902 | return ''; |
903 | - } |
|
903 | + } |
|
904 | 904 | |
905 | 905 | public static function translation_fam() { |
906 | 906 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
@@ -910,10 +910,10 @@ discard block |
||
910 | 910 | try { |
911 | 911 | $Connection = new Connection(); |
912 | 912 | $sth = $Connection->db->prepare($query); |
913 | - $sth->execute(array(':source' => 'website_fam')); |
|
914 | - } catch(PDOException $e) { |
|
915 | - return "error : ".$e->getMessage(); |
|
916 | - } |
|
913 | + $sth->execute(array(':source' => 'website_fam')); |
|
914 | + } catch(PDOException $e) { |
|
915 | + return "error : ".$e->getMessage(); |
|
916 | + } |
|
917 | 917 | |
918 | 918 | |
919 | 919 | //update_db::unzip($out_file); |
@@ -942,7 +942,7 @@ discard block |
||
942 | 942 | //$Connection->db->commit(); |
943 | 943 | } |
944 | 944 | return ''; |
945 | - } |
|
945 | + } |
|
946 | 946 | |
947 | 947 | public static function modes_fam() { |
948 | 948 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
@@ -952,10 +952,10 @@ discard block |
||
952 | 952 | try { |
953 | 953 | $Connection = new Connection(); |
954 | 954 | $sth = $Connection->db->prepare($query); |
955 | - $sth->execute(array(':source' => 'website_fam')); |
|
956 | - } catch(PDOException $e) { |
|
957 | - return "error : ".$e->getMessage(); |
|
958 | - } |
|
955 | + $sth->execute(array(':source' => 'website_fam')); |
|
956 | + } catch(PDOException $e) { |
|
957 | + return "error : ".$e->getMessage(); |
|
958 | + } |
|
959 | 959 | |
960 | 960 | |
961 | 961 | //update_db::unzip($out_file); |
@@ -985,7 +985,7 @@ discard block |
||
985 | 985 | if ($globalTransaction) $Connection->db->commit(); |
986 | 986 | } |
987 | 987 | return ''; |
988 | - } |
|
988 | + } |
|
989 | 989 | |
990 | 990 | public static function tle($filename,$tletype) { |
991 | 991 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
@@ -996,10 +996,10 @@ discard block |
||
996 | 996 | try { |
997 | 997 | $Connection = new Connection(); |
998 | 998 | $sth = $Connection->db->prepare($query); |
999 | - $sth->execute(array(':source' => $filename)); |
|
1000 | - } catch(PDOException $e) { |
|
1001 | - return "error : ".$e->getMessage(); |
|
1002 | - } |
|
999 | + $sth->execute(array(':source' => $filename)); |
|
1000 | + } catch(PDOException $e) { |
|
1001 | + return "error : ".$e->getMessage(); |
|
1002 | + } |
|
1003 | 1003 | |
1004 | 1004 | $Connection = new Connection(); |
1005 | 1005 | if (($handle = fopen($filename, 'r')) !== FALSE) |
@@ -1034,54 +1034,54 @@ discard block |
||
1034 | 1034 | //$Connection->db->commit(); |
1035 | 1035 | } |
1036 | 1036 | return ''; |
1037 | - } |
|
1037 | + } |
|
1038 | 1038 | |
1039 | 1039 | /** |
1040 | - * Convert a HTML table to an array |
|
1041 | - * @param String $data HTML page |
|
1042 | - * @return Array array of the tables in HTML page |
|
1043 | - */ |
|
1044 | - private static function table2array($data) { |
|
1045 | - $html = str_get_html($data); |
|
1046 | - $tabledata=array(); |
|
1047 | - foreach($html->find('tr') as $element) |
|
1048 | - { |
|
1049 | - $td = array(); |
|
1050 | - foreach( $element->find('th') as $row) |
|
1051 | - { |
|
1052 | - $td [] = trim($row->plaintext); |
|
1053 | - } |
|
1054 | - $td=array_filter($td); |
|
1055 | - $tabledata[] = $td; |
|
1056 | - |
|
1057 | - $td = array(); |
|
1058 | - $tdi = array(); |
|
1059 | - foreach( $element->find('td') as $row) |
|
1060 | - { |
|
1061 | - $td [] = trim($row->plaintext); |
|
1062 | - $tdi [] = trim($row->innertext); |
|
1063 | - } |
|
1064 | - $td=array_filter($td); |
|
1065 | - $tdi=array_filter($tdi); |
|
1066 | - // $tabledata[]=array_merge($td,$tdi); |
|
1067 | - $tabledata[]=$td; |
|
1068 | - } |
|
1069 | - return(array_filter($tabledata)); |
|
1070 | - } |
|
1071 | - |
|
1072 | - /** |
|
1073 | - * Get data from form result |
|
1074 | - * @param String $url form URL |
|
1075 | - * @return String the result |
|
1076 | - */ |
|
1077 | - private static function getData($url) { |
|
1078 | - $ch = curl_init(); |
|
1079 | - curl_setopt($ch, CURLOPT_URL, $url); |
|
1080 | - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
1081 | - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
|
1082 | - 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'); |
|
1083 | - return curl_exec($ch); |
|
1084 | - } |
|
1040 | + * Convert a HTML table to an array |
|
1041 | + * @param String $data HTML page |
|
1042 | + * @return Array array of the tables in HTML page |
|
1043 | + */ |
|
1044 | + private static function table2array($data) { |
|
1045 | + $html = str_get_html($data); |
|
1046 | + $tabledata=array(); |
|
1047 | + foreach($html->find('tr') as $element) |
|
1048 | + { |
|
1049 | + $td = array(); |
|
1050 | + foreach( $element->find('th') as $row) |
|
1051 | + { |
|
1052 | + $td [] = trim($row->plaintext); |
|
1053 | + } |
|
1054 | + $td=array_filter($td); |
|
1055 | + $tabledata[] = $td; |
|
1056 | + |
|
1057 | + $td = array(); |
|
1058 | + $tdi = array(); |
|
1059 | + foreach( $element->find('td') as $row) |
|
1060 | + { |
|
1061 | + $td [] = trim($row->plaintext); |
|
1062 | + $tdi [] = trim($row->innertext); |
|
1063 | + } |
|
1064 | + $td=array_filter($td); |
|
1065 | + $tdi=array_filter($tdi); |
|
1066 | + // $tabledata[]=array_merge($td,$tdi); |
|
1067 | + $tabledata[]=$td; |
|
1068 | + } |
|
1069 | + return(array_filter($tabledata)); |
|
1070 | + } |
|
1071 | + |
|
1072 | + /** |
|
1073 | + * Get data from form result |
|
1074 | + * @param String $url form URL |
|
1075 | + * @return String the result |
|
1076 | + */ |
|
1077 | + private static function getData($url) { |
|
1078 | + $ch = curl_init(); |
|
1079 | + curl_setopt($ch, CURLOPT_URL, $url); |
|
1080 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
1081 | + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
|
1082 | + 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'); |
|
1083 | + return curl_exec($ch); |
|
1084 | + } |
|
1085 | 1085 | /* |
1086 | 1086 | public static function waypoints() { |
1087 | 1087 | $data = update_db::getData('http://www.fallingrain.com/world/FR/waypoints.html'); |
@@ -1164,7 +1164,7 @@ discard block |
||
1164 | 1164 | if ($globalTransaction) $Connection->db->commit(); |
1165 | 1165 | } |
1166 | 1166 | return ''; |
1167 | - } |
|
1167 | + } |
|
1168 | 1168 | |
1169 | 1169 | public static function ivao_airlines($filename) { |
1170 | 1170 | //require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
@@ -1174,10 +1174,10 @@ discard block |
||
1174 | 1174 | try { |
1175 | 1175 | $Connection = new Connection(); |
1176 | 1176 | $sth = $Connection->db->prepare($query); |
1177 | - $sth->execute(); |
|
1178 | - } catch(PDOException $e) { |
|
1179 | - return "error : ".$e->getMessage(); |
|
1180 | - } |
|
1177 | + $sth->execute(); |
|
1178 | + } catch(PDOException $e) { |
|
1179 | + return "error : ".$e->getMessage(); |
|
1180 | + } |
|
1181 | 1181 | |
1182 | 1182 | $header = NULL; |
1183 | 1183 | $delimiter = ':'; |
@@ -1201,7 +1201,7 @@ discard block |
||
1201 | 1201 | if ($globalTransaction) $Connection->db->commit(); |
1202 | 1202 | } |
1203 | 1203 | return ''; |
1204 | - } |
|
1204 | + } |
|
1205 | 1205 | |
1206 | 1206 | public static function update_airspace() { |
1207 | 1207 | global $tmp_dir, $globalDBdriver; |
@@ -1211,11 +1211,11 @@ discard block |
||
1211 | 1211 | $query = 'DROP TABLE airspace'; |
1212 | 1212 | try { |
1213 | 1213 | $sth = $Connection->db->prepare($query); |
1214 | - $sth->execute(); |
|
1215 | - } catch(PDOException $e) { |
|
1214 | + $sth->execute(); |
|
1215 | + } catch(PDOException $e) { |
|
1216 | 1216 | return "error : ".$e->getMessage(); |
1217 | - } |
|
1218 | - } |
|
1217 | + } |
|
1218 | + } |
|
1219 | 1219 | |
1220 | 1220 | |
1221 | 1221 | if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
@@ -1270,10 +1270,10 @@ discard block |
||
1270 | 1270 | $query = 'DROP TABLE countries'; |
1271 | 1271 | try { |
1272 | 1272 | $sth = $Connection->db->prepare($query); |
1273 | - $sth->execute(); |
|
1274 | - } catch(PDOException $e) { |
|
1275 | - echo "error : ".$e->getMessage(); |
|
1276 | - } |
|
1273 | + $sth->execute(); |
|
1274 | + } catch(PDOException $e) { |
|
1275 | + echo "error : ".$e->getMessage(); |
|
1276 | + } |
|
1277 | 1277 | } |
1278 | 1278 | if ($globalDBdriver == 'mysql') { |
1279 | 1279 | update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql'); |
@@ -1683,11 +1683,11 @@ discard block |
||
1683 | 1683 | $query = 'DROP TABLE airspace'; |
1684 | 1684 | try { |
1685 | 1685 | $sth = $Connection->db->prepare($query); |
1686 | - $sth->execute(); |
|
1687 | - } catch(PDOException $e) { |
|
1686 | + $sth->execute(); |
|
1687 | + } catch(PDOException $e) { |
|
1688 | 1688 | return "error : ".$e->getMessage(); |
1689 | - } |
|
1690 | - } |
|
1689 | + } |
|
1690 | + } |
|
1691 | 1691 | $error = create_db::import_file($tmp_dir.'airspace.sql'); |
1692 | 1692 | update_db::insert_airspace_version($airspace_md5); |
1693 | 1693 | } else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed."; |
@@ -1807,12 +1807,12 @@ discard block |
||
1807 | 1807 | echo $data; |
1808 | 1808 | */ |
1809 | 1809 | if (file_exists($tmp_dir.'aircrafts.html')) { |
1810 | - //var_dump(file_get_html($tmp_dir.'aircrafts.html')); |
|
1811 | - $fh = fopen($tmp_dir.'aircrafts.html',"r"); |
|
1812 | - $result = fread($fh,100000000); |
|
1813 | - //echo $result; |
|
1814 | - //var_dump(str_get_html($result)); |
|
1815 | - //print_r(self::table2array($result)); |
|
1810 | + //var_dump(file_get_html($tmp_dir.'aircrafts.html')); |
|
1811 | + $fh = fopen($tmp_dir.'aircrafts.html',"r"); |
|
1812 | + $result = fread($fh,100000000); |
|
1813 | + //echo $result; |
|
1814 | + //var_dump(str_get_html($result)); |
|
1815 | + //print_r(self::table2array($result)); |
|
1816 | 1816 | } |
1817 | 1817 | |
1818 | 1818 | } |
@@ -1826,10 +1826,10 @@ discard block |
||
1826 | 1826 | try { |
1827 | 1827 | $Connection = new Connection(); |
1828 | 1828 | $sth = $Connection->db->prepare($query); |
1829 | - $sth->execute(); |
|
1830 | - } catch(PDOException $e) { |
|
1831 | - return "error : ".$e->getMessage(); |
|
1832 | - } |
|
1829 | + $sth->execute(); |
|
1830 | + } catch(PDOException $e) { |
|
1831 | + return "error : ".$e->getMessage(); |
|
1832 | + } |
|
1833 | 1833 | |
1834 | 1834 | $error = ''; |
1835 | 1835 | if ($globalDebug) echo "Notam : Download..."; |
@@ -1885,8 +1885,8 @@ discard block |
||
1885 | 1885 | $data['date_end'] = date("Y-m-d H:i:s",strtotime($to)); |
1886 | 1886 | $data['permanent'] = 0; |
1887 | 1887 | } else { |
1888 | - $data['date_end'] = NULL; |
|
1889 | - $data['permanent'] = 1; |
|
1888 | + $data['date_end'] = NULL; |
|
1889 | + $data['permanent'] = 1; |
|
1890 | 1890 | } |
1891 | 1891 | $data['full_notam'] = $notam['title'].'<br>'.$notam['description']; |
1892 | 1892 | $NOTAM = new NOTAM(); |
@@ -1945,13 +1945,13 @@ discard block |
||
1945 | 1945 | try { |
1946 | 1946 | $Connection = new Connection(); |
1947 | 1947 | $sth = $Connection->db->prepare($query); |
1948 | - $sth->execute(); |
|
1949 | - } catch(PDOException $e) { |
|
1950 | - return "error : ".$e->getMessage(); |
|
1951 | - } |
|
1952 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
1953 | - if ($row['nb'] > 0) return false; |
|
1954 | - else return true; |
|
1948 | + $sth->execute(); |
|
1949 | + } catch(PDOException $e) { |
|
1950 | + return "error : ".$e->getMessage(); |
|
1951 | + } |
|
1952 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
1953 | + if ($row['nb'] > 0) return false; |
|
1954 | + else return true; |
|
1955 | 1955 | } |
1956 | 1956 | |
1957 | 1957 | public static function insert_last_update() { |
@@ -1960,10 +1960,10 @@ discard block |
||
1960 | 1960 | try { |
1961 | 1961 | $Connection = new Connection(); |
1962 | 1962 | $sth = $Connection->db->prepare($query); |
1963 | - $sth->execute(); |
|
1964 | - } catch(PDOException $e) { |
|
1965 | - return "error : ".$e->getMessage(); |
|
1966 | - } |
|
1963 | + $sth->execute(); |
|
1964 | + } catch(PDOException $e) { |
|
1965 | + return "error : ".$e->getMessage(); |
|
1966 | + } |
|
1967 | 1967 | } |
1968 | 1968 | |
1969 | 1969 | public static function check_airspace_version($version) { |
@@ -1971,13 +1971,13 @@ discard block |
||
1971 | 1971 | try { |
1972 | 1972 | $Connection = new Connection(); |
1973 | 1973 | $sth = $Connection->db->prepare($query); |
1974 | - $sth->execute(array(':version' => $version)); |
|
1975 | - } catch(PDOException $e) { |
|
1976 | - return "error : ".$e->getMessage(); |
|
1977 | - } |
|
1978 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
1979 | - if ($row['nb'] > 0) return true; |
|
1980 | - else return false; |
|
1974 | + $sth->execute(array(':version' => $version)); |
|
1975 | + } catch(PDOException $e) { |
|
1976 | + return "error : ".$e->getMessage(); |
|
1977 | + } |
|
1978 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
1979 | + if ($row['nb'] > 0) return true; |
|
1980 | + else return false; |
|
1981 | 1981 | } |
1982 | 1982 | |
1983 | 1983 | |
@@ -1987,10 +1987,10 @@ discard block |
||
1987 | 1987 | try { |
1988 | 1988 | $Connection = new Connection(); |
1989 | 1989 | $sth = $Connection->db->prepare($query); |
1990 | - $sth->execute(array(':version' => $version)); |
|
1991 | - } catch(PDOException $e) { |
|
1992 | - return "error : ".$e->getMessage(); |
|
1993 | - } |
|
1990 | + $sth->execute(array(':version' => $version)); |
|
1991 | + } catch(PDOException $e) { |
|
1992 | + return "error : ".$e->getMessage(); |
|
1993 | + } |
|
1994 | 1994 | } |
1995 | 1995 | |
1996 | 1996 | public static function check_last_notam_update() { |
@@ -2003,13 +2003,13 @@ discard block |
||
2003 | 2003 | try { |
2004 | 2004 | $Connection = new Connection(); |
2005 | 2005 | $sth = $Connection->db->prepare($query); |
2006 | - $sth->execute(); |
|
2007 | - } catch(PDOException $e) { |
|
2008 | - return "error : ".$e->getMessage(); |
|
2009 | - } |
|
2010 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2011 | - if ($row['nb'] > 0) return false; |
|
2012 | - else return true; |
|
2006 | + $sth->execute(); |
|
2007 | + } catch(PDOException $e) { |
|
2008 | + return "error : ".$e->getMessage(); |
|
2009 | + } |
|
2010 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2011 | + if ($row['nb'] > 0) return false; |
|
2012 | + else return true; |
|
2013 | 2013 | } |
2014 | 2014 | |
2015 | 2015 | public static function insert_last_notam_update() { |
@@ -2018,10 +2018,10 @@ discard block |
||
2018 | 2018 | try { |
2019 | 2019 | $Connection = new Connection(); |
2020 | 2020 | $sth = $Connection->db->prepare($query); |
2021 | - $sth->execute(); |
|
2022 | - } catch(PDOException $e) { |
|
2023 | - return "error : ".$e->getMessage(); |
|
2024 | - } |
|
2021 | + $sth->execute(); |
|
2022 | + } catch(PDOException $e) { |
|
2023 | + return "error : ".$e->getMessage(); |
|
2024 | + } |
|
2025 | 2025 | } |
2026 | 2026 | public static function check_last_airspace_update() { |
2027 | 2027 | global $globalDBdriver; |
@@ -2033,13 +2033,13 @@ discard block |
||
2033 | 2033 | try { |
2034 | 2034 | $Connection = new Connection(); |
2035 | 2035 | $sth = $Connection->db->prepare($query); |
2036 | - $sth->execute(); |
|
2037 | - } catch(PDOException $e) { |
|
2038 | - return "error : ".$e->getMessage(); |
|
2039 | - } |
|
2040 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2041 | - if ($row['nb'] > 0) return false; |
|
2042 | - else return true; |
|
2036 | + $sth->execute(); |
|
2037 | + } catch(PDOException $e) { |
|
2038 | + return "error : ".$e->getMessage(); |
|
2039 | + } |
|
2040 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2041 | + if ($row['nb'] > 0) return false; |
|
2042 | + else return true; |
|
2043 | 2043 | } |
2044 | 2044 | |
2045 | 2045 | public static function insert_last_airspace_update() { |
@@ -2048,10 +2048,10 @@ discard block |
||
2048 | 2048 | try { |
2049 | 2049 | $Connection = new Connection(); |
2050 | 2050 | $sth = $Connection->db->prepare($query); |
2051 | - $sth->execute(); |
|
2052 | - } catch(PDOException $e) { |
|
2053 | - return "error : ".$e->getMessage(); |
|
2054 | - } |
|
2051 | + $sth->execute(); |
|
2052 | + } catch(PDOException $e) { |
|
2053 | + return "error : ".$e->getMessage(); |
|
2054 | + } |
|
2055 | 2055 | } |
2056 | 2056 | |
2057 | 2057 | public static function check_last_owner_update() { |
@@ -2064,13 +2064,13 @@ discard block |
||
2064 | 2064 | try { |
2065 | 2065 | $Connection = new Connection(); |
2066 | 2066 | $sth = $Connection->db->prepare($query); |
2067 | - $sth->execute(); |
|
2068 | - } catch(PDOException $e) { |
|
2069 | - return "error : ".$e->getMessage(); |
|
2070 | - } |
|
2071 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2072 | - if ($row['nb'] > 0) return false; |
|
2073 | - else return true; |
|
2067 | + $sth->execute(); |
|
2068 | + } catch(PDOException $e) { |
|
2069 | + return "error : ".$e->getMessage(); |
|
2070 | + } |
|
2071 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2072 | + if ($row['nb'] > 0) return false; |
|
2073 | + else return true; |
|
2074 | 2074 | } |
2075 | 2075 | |
2076 | 2076 | public static function insert_last_owner_update() { |
@@ -2079,10 +2079,10 @@ discard block |
||
2079 | 2079 | try { |
2080 | 2080 | $Connection = new Connection(); |
2081 | 2081 | $sth = $Connection->db->prepare($query); |
2082 | - $sth->execute(); |
|
2083 | - } catch(PDOException $e) { |
|
2084 | - return "error : ".$e->getMessage(); |
|
2085 | - } |
|
2082 | + $sth->execute(); |
|
2083 | + } catch(PDOException $e) { |
|
2084 | + return "error : ".$e->getMessage(); |
|
2085 | + } |
|
2086 | 2086 | } |
2087 | 2087 | public static function check_last_schedules_update() { |
2088 | 2088 | global $globalDBdriver; |
@@ -2094,13 +2094,13 @@ discard block |
||
2094 | 2094 | try { |
2095 | 2095 | $Connection = new Connection(); |
2096 | 2096 | $sth = $Connection->db->prepare($query); |
2097 | - $sth->execute(); |
|
2098 | - } catch(PDOException $e) { |
|
2099 | - return "error : ".$e->getMessage(); |
|
2100 | - } |
|
2101 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2102 | - if ($row['nb'] > 0) return false; |
|
2103 | - else return true; |
|
2097 | + $sth->execute(); |
|
2098 | + } catch(PDOException $e) { |
|
2099 | + return "error : ".$e->getMessage(); |
|
2100 | + } |
|
2101 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2102 | + if ($row['nb'] > 0) return false; |
|
2103 | + else return true; |
|
2104 | 2104 | } |
2105 | 2105 | |
2106 | 2106 | public static function insert_last_schedules_update() { |
@@ -2109,10 +2109,10 @@ discard block |
||
2109 | 2109 | try { |
2110 | 2110 | $Connection = new Connection(); |
2111 | 2111 | $sth = $Connection->db->prepare($query); |
2112 | - $sth->execute(); |
|
2113 | - } catch(PDOException $e) { |
|
2114 | - return "error : ".$e->getMessage(); |
|
2115 | - } |
|
2112 | + $sth->execute(); |
|
2113 | + } catch(PDOException $e) { |
|
2114 | + return "error : ".$e->getMessage(); |
|
2115 | + } |
|
2116 | 2116 | } |
2117 | 2117 | public static function check_last_tle_update() { |
2118 | 2118 | global $globalDBdriver; |
@@ -2124,13 +2124,13 @@ discard block |
||
2124 | 2124 | try { |
2125 | 2125 | $Connection = new Connection(); |
2126 | 2126 | $sth = $Connection->db->prepare($query); |
2127 | - $sth->execute(); |
|
2128 | - } catch(PDOException $e) { |
|
2129 | - return "error : ".$e->getMessage(); |
|
2130 | - } |
|
2131 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2132 | - if ($row['nb'] > 0) return false; |
|
2133 | - else return true; |
|
2127 | + $sth->execute(); |
|
2128 | + } catch(PDOException $e) { |
|
2129 | + return "error : ".$e->getMessage(); |
|
2130 | + } |
|
2131 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2132 | + if ($row['nb'] > 0) return false; |
|
2133 | + else return true; |
|
2134 | 2134 | } |
2135 | 2135 | |
2136 | 2136 | public static function insert_last_tle_update() { |
@@ -2139,10 +2139,10 @@ discard block |
||
2139 | 2139 | try { |
2140 | 2140 | $Connection = new Connection(); |
2141 | 2141 | $sth = $Connection->db->prepare($query); |
2142 | - $sth->execute(); |
|
2143 | - } catch(PDOException $e) { |
|
2144 | - return "error : ".$e->getMessage(); |
|
2145 | - } |
|
2142 | + $sth->execute(); |
|
2143 | + } catch(PDOException $e) { |
|
2144 | + return "error : ".$e->getMessage(); |
|
2145 | + } |
|
2146 | 2146 | } |
2147 | 2147 | |
2148 | 2148 | public static function update_all() { |
@@ -24,20 +24,20 @@ discard block |
||
24 | 24 | fclose($fp); |
25 | 25 | } |
26 | 26 | |
27 | - public static function gunzip($in_file,$out_file_name = '') { |
|
27 | + public static function gunzip($in_file, $out_file_name = '') { |
|
28 | 28 | //echo $in_file.' -> '.$out_file_name."\n"; |
29 | 29 | $buffer_size = 4096; // read 4kb at a time |
30 | 30 | if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); |
31 | 31 | if ($in_file != '' && file_exists($in_file)) { |
32 | 32 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
33 | - if (function_exists('gzopen')) $file = gzopen($in_file,'rb'); |
|
34 | - elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb'); |
|
33 | + if (function_exists('gzopen')) $file = gzopen($in_file, 'rb'); |
|
34 | + elseif (function_exists('gzopen64')) $file = gzopen64($in_file, 'rb'); |
|
35 | 35 | else { |
36 | 36 | echo 'gzopen not available'; |
37 | 37 | die; |
38 | 38 | } |
39 | 39 | $out_file = fopen($out_file_name, 'wb'); |
40 | - while(!gzeof($file)) { |
|
40 | + while (!gzeof($file)) { |
|
41 | 41 | fwrite($out_file, gzread($file, $buffer_size)); |
42 | 42 | } |
43 | 43 | fclose($out_file); |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | try { |
62 | 62 | self::$db_sqlite = new PDO('sqlite:'.$database); |
63 | 63 | self::$db_sqlite->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
64 | - } catch(PDOException $e) { |
|
64 | + } catch (PDOException $e) { |
|
65 | 65 | return "error : ".$e->getMessage(); |
66 | 66 | } |
67 | 67 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | //$Connection = new Connection(); |
77 | 77 | $sth = $Connection->db->prepare($query); |
78 | 78 | $sth->execute(array(':source' => $database_file)); |
79 | - } catch(PDOException $e) { |
|
79 | + } catch (PDOException $e) { |
|
80 | 80 | return "error : ".$e->getMessage(); |
81 | 81 | } |
82 | 82 | |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | try { |
88 | 88 | $sth = update_db::$db_sqlite->prepare($query); |
89 | 89 | $sth->execute(); |
90 | - } catch(PDOException $e) { |
|
90 | + } catch (PDOException $e) { |
|
91 | 91 | return "error : ".$e->getMessage(); |
92 | 92 | } |
93 | 93 | //$query_dest = 'INSERT INTO routes (`RouteID`,`CallSign`,`Operator_ICAO`,`FromAirport_ICAO`,`ToAirport_ICAO`,`RouteStop`,`Source`) VALUES (:RouteID, :CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)'; |
@@ -98,11 +98,11 @@ discard block |
||
98 | 98 | if ($globalTransaction) $Connection->db->beginTransaction(); |
99 | 99 | while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
100 | 100 | //$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
101 | - $query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
|
101 | + $query_dest_values = array(':CallSign' => $values['Callsign'], ':Operator_ICAO' => $values['operator_icao'], ':FromAirport_ICAO' => $values['FromAirportIcao'], ':ToAirport_ICAO' => $values['ToAirportIcao'], ':routestop' => $values['AllStop'], ':source' => $database_file); |
|
102 | 102 | $sth_dest->execute($query_dest_values); |
103 | 103 | } |
104 | 104 | if ($globalTransaction) $Connection->db->commit(); |
105 | - } catch(PDOException $e) { |
|
105 | + } catch (PDOException $e) { |
|
106 | 106 | if ($globalTransaction) $Connection->db->rollBack(); |
107 | 107 | return "error : ".$e->getMessage(); |
108 | 108 | } |
@@ -118,26 +118,26 @@ discard block |
||
118 | 118 | //$Connection = new Connection(); |
119 | 119 | $sth = $Connection->db->prepare($query); |
120 | 120 | $sth->execute(array(':source' => 'oneworld')); |
121 | - } catch(PDOException $e) { |
|
121 | + } catch (PDOException $e) { |
|
122 | 122 | return "error : ".$e->getMessage(); |
123 | 123 | } |
124 | 124 | |
125 | 125 | if ($globalDebug) echo " - Add routes to DB -"; |
126 | 126 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
127 | 127 | $Spotter = new Spotter(); |
128 | - if ($fh = fopen($database_file,"r")) { |
|
128 | + if ($fh = fopen($database_file, "r")) { |
|
129 | 129 | $query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)'; |
130 | 130 | $Connection = new Connection(); |
131 | 131 | $sth_dest = $Connection->db->prepare($query_dest); |
132 | 132 | if ($globalTransaction) $Connection->db->beginTransaction(); |
133 | 133 | while (!feof($fh)) { |
134 | - $line = fgetcsv($fh,9999,','); |
|
134 | + $line = fgetcsv($fh, 9999, ','); |
|
135 | 135 | if ($line[0] != '') { |
136 | 136 | if (($line[2] == '-' || ($line[2] != '-' && (strtotime($line[2]) > time()))) && ($line[3] == '-' || ($line[3] != '-' && (strtotime($line[3]) < time())))) { |
137 | 137 | try { |
138 | - $query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld'); |
|
138 | + $query_dest_values = array(':CallSign' => str_replace('*', '', $line[7]), ':Operator_ICAO' => '', ':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]), ':FromAirport_Time' => $line[5], ':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]), ':ToAirport_Time' => $line[6], ':routestop' => '', ':source' => 'oneworld'); |
|
139 | 139 | $sth_dest->execute($query_dest_values); |
140 | - } catch(PDOException $e) { |
|
140 | + } catch (PDOException $e) { |
|
141 | 141 | if ($globalTransaction) $Connection->db->rollBack(); |
142 | 142 | return "error : ".$e->getMessage(); |
143 | 143 | } |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | //$Connection = new Connection(); |
160 | 160 | $sth = $Connection->db->prepare($query); |
161 | 161 | $sth->execute(array(':source' => 'skyteam')); |
162 | - } catch(PDOException $e) { |
|
162 | + } catch (PDOException $e) { |
|
163 | 163 | return "error : ".$e->getMessage(); |
164 | 164 | } |
165 | 165 | |
@@ -167,24 +167,24 @@ discard block |
||
167 | 167 | |
168 | 168 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
169 | 169 | $Spotter = new Spotter(); |
170 | - if ($fh = fopen($database_file,"r")) { |
|
170 | + if ($fh = fopen($database_file, "r")) { |
|
171 | 171 | $query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)'; |
172 | 172 | $Connection = new Connection(); |
173 | 173 | $sth_dest = $Connection->db->prepare($query_dest); |
174 | 174 | try { |
175 | 175 | if ($globalTransaction) $Connection->db->beginTransaction(); |
176 | 176 | while (!feof($fh)) { |
177 | - $line = fgetcsv($fh,9999,','); |
|
177 | + $line = fgetcsv($fh, 9999, ','); |
|
178 | 178 | if ($line[0] != '') { |
179 | - $datebe = explode(' - ',$line[2]); |
|
179 | + $datebe = explode(' - ', $line[2]); |
|
180 | 180 | if (strtotime($datebe[0]) > time() && strtotime($datebe[1]) < time()) { |
181 | - $query_dest_values = array(':CallSign' => str_replace('*','',$line[6]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[4],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[5],':routestop' => '',':source' => 'skyteam'); |
|
181 | + $query_dest_values = array(':CallSign' => str_replace('*', '', $line[6]), ':Operator_ICAO' => '', ':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]), ':FromAirport_Time' => $line[4], ':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]), ':ToAirport_Time' => $line[5], ':routestop' => '', ':source' => 'skyteam'); |
|
182 | 182 | $sth_dest->execute($query_dest_values); |
183 | 183 | } |
184 | 184 | } |
185 | 185 | } |
186 | 186 | if ($globalTransaction) $Connection->db->commit(); |
187 | - } catch(PDOException $e) { |
|
187 | + } catch (PDOException $e) { |
|
188 | 188 | if ($globalTransaction) $Connection->db->rollBack(); |
189 | 189 | return "error : ".$e->getMessage(); |
190 | 190 | } |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | $Connection = new Connection(); |
200 | 200 | $sth = $Connection->db->prepare($query); |
201 | 201 | $sth->execute(array(':source' => $database_file)); |
202 | - } catch(PDOException $e) { |
|
202 | + } catch (PDOException $e) { |
|
203 | 203 | return "error : ".$e->getMessage(); |
204 | 204 | } |
205 | 205 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source"; |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | $Connection = new Connection(); |
208 | 208 | $sth = $Connection->db->prepare($query); |
209 | 209 | $sth->execute(array(':source' => $database_file)); |
210 | - } catch(PDOException $e) { |
|
210 | + } catch (PDOException $e) { |
|
211 | 211 | return "error : ".$e->getMessage(); |
212 | 212 | } |
213 | 213 | |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | try { |
217 | 217 | $sth = update_db::$db_sqlite->prepare($query); |
218 | 218 | $sth->execute(); |
219 | - } catch(PDOException $e) { |
|
219 | + } catch (PDOException $e) { |
|
220 | 220 | return "error : ".$e->getMessage(); |
221 | 221 | } |
222 | 222 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
@@ -233,15 +233,15 @@ discard block |
||
233 | 233 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
234 | 234 | if ($values['UserString4'] == 'M') $type = 'military'; |
235 | 235 | else $type = null; |
236 | - $query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type); |
|
236 | + $query_dest_values = array(':LastModified' => $values['LastModified'], ':ModeS' => $values['ModeS'], ':ModeSCountry' => $values['ModeSCountry'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':type' => $type); |
|
237 | 237 | $sth_dest->execute($query_dest_values); |
238 | 238 | if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') { |
239 | - $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']); |
|
239 | + $query_dest_owner_values = array(':registration' => $values['Registration'], ':source' => $database_file, ':owner' => $values['RegisteredOwners']); |
|
240 | 240 | $sth_dest_owner->execute($query_dest_owner_values); |
241 | 241 | } |
242 | 242 | } |
243 | 243 | if ($globalTransaction) $Connection->db->commit(); |
244 | - } catch(PDOException $e) { |
|
244 | + } catch (PDOException $e) { |
|
245 | 245 | return "error : ".$e->getMessage(); |
246 | 246 | } |
247 | 247 | |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | $Connection = new Connection(); |
251 | 251 | $sth = $Connection->db->prepare($query); |
252 | 252 | $sth->execute(array(':source' => $database_file)); |
253 | - } catch(PDOException $e) { |
|
253 | + } catch (PDOException $e) { |
|
254 | 254 | return "error : ".$e->getMessage(); |
255 | 255 | } |
256 | 256 | return ''; |
@@ -265,11 +265,11 @@ discard block |
||
265 | 265 | $Connection = new Connection(); |
266 | 266 | $sth = $Connection->db->prepare($query); |
267 | 267 | $sth->execute(array(':source' => $database_file)); |
268 | - } catch(PDOException $e) { |
|
268 | + } catch (PDOException $e) { |
|
269 | 269 | return "error : ".$e->getMessage(); |
270 | 270 | } |
271 | 271 | |
272 | - if ($fh = fopen($database_file,"r")) { |
|
272 | + if ($fh = fopen($database_file, "r")) { |
|
273 | 273 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
274 | 274 | $query_dest = 'INSERT INTO aircraft_modes (ModeS,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:Registration,:ICAOTypeCode,:source)'; |
275 | 275 | |
@@ -279,13 +279,13 @@ discard block |
||
279 | 279 | if ($globalTransaction) $Connection->db->beginTransaction(); |
280 | 280 | while (!feof($fh)) { |
281 | 281 | $values = array(); |
282 | - $line = $Common->hex2str(fgets($fh,9999)); |
|
282 | + $line = $Common->hex2str(fgets($fh, 9999)); |
|
283 | 283 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
284 | - $values['ModeS'] = substr($line,0,6); |
|
285 | - $values['Registration'] = trim(substr($line,69,6)); |
|
286 | - $aircraft_name = trim(substr($line,48,6)); |
|
284 | + $values['ModeS'] = substr($line, 0, 6); |
|
285 | + $values['Registration'] = trim(substr($line, 69, 6)); |
|
286 | + $aircraft_name = trim(substr($line, 48, 6)); |
|
287 | 287 | // Check if we can find ICAO, else set it to GLID |
288 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
288 | + $aircraft_name_split = explode(' ', $aircraft_name); |
|
289 | 289 | $search_more = ''; |
290 | 290 | if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
291 | 291 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
@@ -297,20 +297,20 @@ discard block |
||
297 | 297 | if (isset($result['icao']) && $result['icao'] != '') { |
298 | 298 | $values['ICAOTypeCode'] = $result['icao']; |
299 | 299 | } |
300 | - } catch(PDOException $e) { |
|
300 | + } catch (PDOException $e) { |
|
301 | 301 | return "error : ".$e->getMessage(); |
302 | 302 | } |
303 | 303 | if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID'; |
304 | 304 | // Add data to db |
305 | 305 | if ($values['ModeS'] != '' && $values['Registration'] != '' && $values['Registration'] != '0000') { |
306 | 306 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
307 | - $query_dest_values = array(':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file); |
|
307 | + $query_dest_values = array(':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file); |
|
308 | 308 | //print_r($query_dest_values); |
309 | 309 | $sth_dest->execute($query_dest_values); |
310 | 310 | } |
311 | 311 | } |
312 | 312 | if ($globalTransaction) $Connection->db->commit(); |
313 | - } catch(PDOException $e) { |
|
313 | + } catch (PDOException $e) { |
|
314 | 314 | return "error : ".$e->getMessage(); |
315 | 315 | } |
316 | 316 | } |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | $Connection = new Connection(); |
321 | 321 | $sth = $Connection->db->prepare($query); |
322 | 322 | $sth->execute(array(':source' => $database_file)); |
323 | - } catch(PDOException $e) { |
|
323 | + } catch (PDOException $e) { |
|
324 | 324 | return "error : ".$e->getMessage(); |
325 | 325 | } |
326 | 326 | return ''; |
@@ -334,11 +334,11 @@ discard block |
||
334 | 334 | $Connection = new Connection(); |
335 | 335 | $sth = $Connection->db->prepare($query); |
336 | 336 | $sth->execute(array(':source' => $database_file)); |
337 | - } catch(PDOException $e) { |
|
337 | + } catch (PDOException $e) { |
|
338 | 338 | return "error : ".$e->getMessage(); |
339 | 339 | } |
340 | 340 | |
341 | - if ($fh = fopen($database_file,"r")) { |
|
341 | + if ($fh = fopen($database_file, "r")) { |
|
342 | 342 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
343 | 343 | $query_dest = 'INSERT INTO aircraft_modes (ModeS,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:Registration,:ICAOTypeCode,:source)'; |
344 | 344 | |
@@ -346,9 +346,9 @@ discard block |
||
346 | 346 | $sth_dest = $Connection->db->prepare($query_dest); |
347 | 347 | try { |
348 | 348 | if ($globalTransaction) $Connection->db->beginTransaction(); |
349 | - $tmp = fgetcsv($fh,9999,',',"'"); |
|
349 | + $tmp = fgetcsv($fh, 9999, ',', "'"); |
|
350 | 350 | while (!feof($fh)) { |
351 | - $line = fgetcsv($fh,9999,',',"'"); |
|
351 | + $line = fgetcsv($fh, 9999, ',', "'"); |
|
352 | 352 | |
353 | 353 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
354 | 354 | //print_r($line); |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | $values['Registration'] = $line[3]; |
357 | 357 | $aircraft_name = $line[2]; |
358 | 358 | // Check if we can find ICAO, else set it to GLID |
359 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
359 | + $aircraft_name_split = explode(' ', $aircraft_name); |
|
360 | 360 | $search_more = ''; |
361 | 361 | if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
362 | 362 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
@@ -365,20 +365,20 @@ discard block |
||
365 | 365 | $sth_search->execute(); |
366 | 366 | $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
367 | 367 | if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
368 | - } catch(PDOException $e) { |
|
368 | + } catch (PDOException $e) { |
|
369 | 369 | return "error : ".$e->getMessage(); |
370 | 370 | } |
371 | 371 | //if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID'; |
372 | 372 | // Add data to db |
373 | 373 | if ($values['ModeS'] != '' && $values['Registration'] != '' && $values['Registration'] != '0000' && $values['ICAOTypeCode'] != '') { |
374 | 374 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
375 | - $query_dest_values = array(':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file); |
|
375 | + $query_dest_values = array(':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file); |
|
376 | 376 | //print_r($query_dest_values); |
377 | 377 | $sth_dest->execute($query_dest_values); |
378 | 378 | } |
379 | 379 | } |
380 | 380 | if ($globalTransaction) $Connection->db->commit(); |
381 | - } catch(PDOException $e) { |
|
381 | + } catch (PDOException $e) { |
|
382 | 382 | return "error : ".$e->getMessage(); |
383 | 383 | } |
384 | 384 | } |
@@ -388,13 +388,13 @@ discard block |
||
388 | 388 | $Connection = new Connection(); |
389 | 389 | $sth = $Connection->db->prepare($query); |
390 | 390 | $sth->execute(array(':source' => $database_file)); |
391 | - } catch(PDOException $e) { |
|
391 | + } catch (PDOException $e) { |
|
392 | 392 | return "error : ".$e->getMessage(); |
393 | 393 | } |
394 | 394 | return ''; |
395 | 395 | } |
396 | 396 | |
397 | - public static function retrieve_owner($database_file,$country = 'F') { |
|
397 | + public static function retrieve_owner($database_file, $country = 'F') { |
|
398 | 398 | global $globalTransaction; |
399 | 399 | //$query = 'TRUNCATE TABLE aircraft_modes'; |
400 | 400 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source"; |
@@ -402,11 +402,11 @@ discard block |
||
402 | 402 | $Connection = new Connection(); |
403 | 403 | $sth = $Connection->db->prepare($query); |
404 | 404 | $sth->execute(array(':source' => $database_file)); |
405 | - } catch(PDOException $e) { |
|
405 | + } catch (PDOException $e) { |
|
406 | 406 | return "error : ".$e->getMessage(); |
407 | 407 | } |
408 | 408 | |
409 | - if ($fh = fopen($database_file,"r")) { |
|
409 | + if ($fh = fopen($database_file, "r")) { |
|
410 | 410 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
411 | 411 | $query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)'; |
412 | 412 | |
@@ -414,9 +414,9 @@ discard block |
||
414 | 414 | $sth_dest = $Connection->db->prepare($query_dest); |
415 | 415 | try { |
416 | 416 | if ($globalTransaction) $Connection->db->beginTransaction(); |
417 | - $tmp = fgetcsv($fh,9999,',','"'); |
|
417 | + $tmp = fgetcsv($fh, 9999, ',', '"'); |
|
418 | 418 | while (!feof($fh)) { |
419 | - $line = fgetcsv($fh,9999,',','"'); |
|
419 | + $line = fgetcsv($fh, 9999, ',', '"'); |
|
420 | 420 | $values = array(); |
421 | 421 | //print_r($line); |
422 | 422 | if ($country == 'F') { |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | $values['base'] = $line[4]; |
425 | 425 | $values['owner'] = $line[5]; |
426 | 426 | if ($line[6] == '') $values['date_first_reg'] = null; |
427 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
427 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6])); |
|
428 | 428 | $values['cancel'] = $line[7]; |
429 | 429 | } elseif ($country == 'EI') { |
430 | 430 | // TODO : add modeS & reg to aircraft_modes |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | $values['base'] = $line[3]; |
433 | 433 | $values['owner'] = $line[2]; |
434 | 434 | if ($line[1] == '') $values['date_first_reg'] = null; |
435 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
435 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[1])); |
|
436 | 436 | $values['cancel'] = ''; |
437 | 437 | } elseif ($country == 'HB') { |
438 | 438 | // TODO : add modeS & reg to aircraft_modes |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | $values['base'] = null; |
448 | 448 | $values['owner'] = $line[5]; |
449 | 449 | if ($line[18] == '') $values['date_first_reg'] = null; |
450 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
450 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[18])); |
|
451 | 451 | $values['cancel'] = ''; |
452 | 452 | } elseif ($country == 'VH') { |
453 | 453 | // TODO : add modeS & reg to aircraft_modes |
@@ -455,7 +455,7 @@ discard block |
||
455 | 455 | $values['base'] = null; |
456 | 456 | $values['owner'] = $line[12]; |
457 | 457 | if ($line[28] == '') $values['date_first_reg'] = null; |
458 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
458 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[28])); |
|
459 | 459 | |
460 | 460 | $values['cancel'] = $line[39]; |
461 | 461 | } elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { |
@@ -475,28 +475,28 @@ discard block |
||
475 | 475 | $values['base'] = null; |
476 | 476 | $values['owner'] = $line[8]; |
477 | 477 | if ($line[7] == '') $values['date_first_reg'] = null; |
478 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
478 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7])); |
|
479 | 479 | $values['cancel'] = ''; |
480 | 480 | } elseif ($country == 'PP') { |
481 | 481 | $values['registration'] = $line[0]; |
482 | 482 | $values['base'] = null; |
483 | 483 | $values['owner'] = $line[4]; |
484 | 484 | if ($line[6] == '') $values['date_first_reg'] = null; |
485 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
485 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6])); |
|
486 | 486 | $values['cancel'] = $line[7]; |
487 | 487 | } elseif ($country == 'E7') { |
488 | 488 | $values['registration'] = $line[0]; |
489 | 489 | $values['base'] = null; |
490 | 490 | $values['owner'] = $line[4]; |
491 | 491 | if ($line[5] == '') $values['date_first_reg'] = null; |
492 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
492 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[5])); |
|
493 | 493 | $values['cancel'] = ''; |
494 | 494 | } elseif ($country == '8Q') { |
495 | 495 | $values['registration'] = $line[0]; |
496 | 496 | $values['base'] = null; |
497 | 497 | $values['owner'] = $line[3]; |
498 | 498 | if ($line[7] == '') $values['date_first_reg'] = null; |
499 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
499 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7])); |
|
500 | 500 | $values['cancel'] = ''; |
501 | 501 | } elseif ($country == 'ZK' || $country == 'OM' || $country == 'TF') { |
502 | 502 | $values['registration'] = $line[0]; |
@@ -506,12 +506,12 @@ discard block |
||
506 | 506 | $values['cancel'] = ''; |
507 | 507 | } |
508 | 508 | if ($values['cancel'] == '' && $values['registration'] != null) { |
509 | - $query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file); |
|
509 | + $query_dest_values = array(':registration' => $values['registration'], ':base' => $values['base'], ':date_first_reg' => $values['date_first_reg'], ':owner' => $values['owner'], ':source' => $database_file); |
|
510 | 510 | $sth_dest->execute($query_dest_values); |
511 | 511 | } |
512 | 512 | } |
513 | 513 | if ($globalTransaction) $Connection->db->commit(); |
514 | - } catch(PDOException $e) { |
|
514 | + } catch (PDOException $e) { |
|
515 | 515 | return "error : ".$e->getMessage(); |
516 | 516 | } |
517 | 517 | } |
@@ -626,7 +626,7 @@ discard block |
||
626 | 626 | $Connection = new Connection(); |
627 | 627 | $sth = $Connection->db->prepare($query); |
628 | 628 | $sth->execute(); |
629 | - } catch(PDOException $e) { |
|
629 | + } catch (PDOException $e) { |
|
630 | 630 | return "error : ".$e->getMessage(); |
631 | 631 | } |
632 | 632 | |
@@ -636,7 +636,7 @@ discard block |
||
636 | 636 | $Connection = new Connection(); |
637 | 637 | $sth = $Connection->db->prepare($query); |
638 | 638 | $sth->execute(); |
639 | - } catch(PDOException $e) { |
|
639 | + } catch (PDOException $e) { |
|
640 | 640 | return "error : ".$e->getMessage(); |
641 | 641 | } |
642 | 642 | |
@@ -647,7 +647,7 @@ discard block |
||
647 | 647 | if ($globalTransaction) $Connection->db->beginTransaction(); |
648 | 648 | |
649 | 649 | $i = 0; |
650 | - while($row = sparql_fetch_array($result)) |
|
650 | + while ($row = sparql_fetch_array($result)) |
|
651 | 651 | { |
652 | 652 | if ($i >= 1) { |
653 | 653 | //print_r($row); |
@@ -667,31 +667,31 @@ discard block |
||
667 | 667 | $row['image'] = ''; |
668 | 668 | $row['image_thumb'] = ''; |
669 | 669 | } else { |
670 | - $image = str_replace(' ','_',$row['image']); |
|
670 | + $image = str_replace(' ', '_', $row['image']); |
|
671 | 671 | $digest = md5($image); |
672 | - $folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image . '/220px-' . $image; |
|
673 | - $row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/' . $folder; |
|
674 | - $folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image; |
|
675 | - $row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/' . $folder; |
|
672 | + $folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image.'/220px-'.$image; |
|
673 | + $row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/'.$folder; |
|
674 | + $folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image; |
|
675 | + $row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/'.$folder; |
|
676 | 676 | } |
677 | 677 | |
678 | - $country = explode('-',$row['country']); |
|
678 | + $country = explode('-', $row['country']); |
|
679 | 679 | $row['country'] = $country[0]; |
680 | 680 | |
681 | 681 | $row['type'] = trim($row['type']); |
682 | - if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i',$row['name'])) { |
|
682 | + if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i', $row['name'])) { |
|
683 | 683 | $row['type'] = 'Military'; |
684 | 684 | } elseif ($row['type'] == 'http://dbpedia.org/resource/Airport' || $row['type'] == 'Civil' || $row['type'] == 'Public use' || $row['type'] == 'Public' || $row['type'] == 'http://dbpedia.org/resource/Civilian' || $row['type'] == 'Public, Civilian' || $row['type'] == 'Public / Military' || $row['type'] == 'Private & Civilian' || $row['type'] == 'Civilian and Military' || $row['type'] == 'Public/military' || $row['type'] == 'Active With Few Facilities' || $row['type'] == '?ivilian' || $row['type'] == 'Civil/Military' || $row['type'] == 'NA' || $row['type'] == 'Public/Military') { |
685 | 685 | $row['type'] = 'small_airport'; |
686 | 686 | } |
687 | 687 | |
688 | - $row['city'] = urldecode(str_replace('_',' ',str_replace('http://dbpedia.org/resource/','',$row['city']))); |
|
689 | - $query_dest_values = array(':airport_id' => $i, ':name' => $row['name'],':iata' => $row['iata'],':icao' => $row['icao'],':latitude' => $row['latitude'],':longitude' => $row['longitude'],':altitude' => $row['altitude'],':type' => $row['type'],':city' => $row['city'],':country' => $row['country'],':home_link' => $row['homepage'],':wikipedia_link' => $row['wikipedia_page'],':image' => $row['image'],':image_thumb' => $row['image_thumb']); |
|
688 | + $row['city'] = urldecode(str_replace('_', ' ', str_replace('http://dbpedia.org/resource/', '', $row['city']))); |
|
689 | + $query_dest_values = array(':airport_id' => $i, ':name' => $row['name'], ':iata' => $row['iata'], ':icao' => $row['icao'], ':latitude' => $row['latitude'], ':longitude' => $row['longitude'], ':altitude' => $row['altitude'], ':type' => $row['type'], ':city' => $row['city'], ':country' => $row['country'], ':home_link' => $row['homepage'], ':wikipedia_link' => $row['wikipedia_page'], ':image' => $row['image'], ':image_thumb' => $row['image_thumb']); |
|
690 | 690 | //print_r($query_dest_values); |
691 | 691 | |
692 | 692 | try { |
693 | 693 | $sth_dest->execute($query_dest_values); |
694 | - } catch(PDOException $e) { |
|
694 | + } catch (PDOException $e) { |
|
695 | 695 | return "error : ".$e->getMessage(); |
696 | 696 | } |
697 | 697 | } |
@@ -705,7 +705,7 @@ discard block |
||
705 | 705 | $Connection = new Connection(); |
706 | 706 | $sth = $Connection->db->prepare($query); |
707 | 707 | $sth->execute(); |
708 | - } catch(PDOException $e) { |
|
708 | + } catch (PDOException $e) { |
|
709 | 709 | return "error : ".$e->getMessage(); |
710 | 710 | } |
711 | 711 | |
@@ -713,12 +713,12 @@ discard block |
||
713 | 713 | if ($globalDebug) echo "Insert Not available Airport...\n"; |
714 | 714 | $query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image`,`image_thumb`) |
715 | 715 | VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image, :image_thumb)"; |
716 | - $query_values = array(':airport_id' => $i, ':name' => 'Not available',':iata' => 'NA',':icao' => 'NA',':latitude' => '0',':longitude' => '0',':altitude' => '0',':type' => 'NA',':city' => 'N/A',':country' => 'N/A',':home_link' => '',':wikipedia_link' => '',':image' => '',':image_thumb' => ''); |
|
716 | + $query_values = array(':airport_id' => $i, ':name' => 'Not available', ':iata' => 'NA', ':icao' => 'NA', ':latitude' => '0', ':longitude' => '0', ':altitude' => '0', ':type' => 'NA', ':city' => 'N/A', ':country' => 'N/A', ':home_link' => '', ':wikipedia_link' => '', ':image' => '', ':image_thumb' => ''); |
|
717 | 717 | try { |
718 | 718 | $Connection = new Connection(); |
719 | 719 | $sth = $Connection->db->prepare($query); |
720 | 720 | $sth->execute($query_values); |
721 | - } catch(PDOException $e) { |
|
721 | + } catch (PDOException $e) { |
|
722 | 722 | return "error : ".$e->getMessage(); |
723 | 723 | } |
724 | 724 | $i++; |
@@ -736,7 +736,7 @@ discard block |
||
736 | 736 | echo "Download data from ourairports.com...\n"; |
737 | 737 | $delimiter = ','; |
738 | 738 | $out_file = $tmp_dir.'airports.csv'; |
739 | - update_db::download('http://ourairports.com/data/airports.csv',$out_file); |
|
739 | + update_db::download('http://ourairports.com/data/airports.csv', $out_file); |
|
740 | 740 | if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
741 | 741 | echo "Add data from ourairports.com...\n"; |
742 | 742 | |
@@ -747,32 +747,32 @@ discard block |
||
747 | 747 | //$Connection->db->beginTransaction(); |
748 | 748 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
749 | 749 | { |
750 | - if(!$header) $header = $row; |
|
750 | + if (!$header) $header = $row; |
|
751 | 751 | else { |
752 | 752 | $data = array(); |
753 | 753 | $data = array_combine($header, $row); |
754 | 754 | try { |
755 | 755 | $sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE `icao` = :icao'); |
756 | 756 | $sth->execute(array(':icao' => $data['gps_code'])); |
757 | - } catch(PDOException $e) { |
|
757 | + } catch (PDOException $e) { |
|
758 | 758 | return "error : ".$e->getMessage(); |
759 | 759 | } |
760 | 760 | if ($sth->fetchColumn() > 0) { |
761 | 761 | $query = 'UPDATE airport SET `type` = :type WHERE icao = :icao'; |
762 | 762 | try { |
763 | 763 | $sth = $Connection->db->prepare($query); |
764 | - $sth->execute(array(':icao' => $data['gps_code'],':type' => $data['type'])); |
|
765 | - } catch(PDOException $e) { |
|
764 | + $sth->execute(array(':icao' => $data['gps_code'], ':type' => $data['type'])); |
|
765 | + } catch (PDOException $e) { |
|
766 | 766 | return "error : ".$e->getMessage(); |
767 | 767 | } |
768 | 768 | } else { |
769 | 769 | $query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`) |
770 | 770 | VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link)"; |
771 | - $query_values = array(':airport_id' => $i, ':name' => $data['name'],':iata' => $data['iata_code'],':icao' => $data['gps_code'],':latitude' => $data['latitude_deg'],':longitude' => $data['longitude_deg'],':altitude' => $data['elevation_ft'],':type' => $data['type'],':city' => $data['municipality'],':country' => $data['iso_country'],':home_link' => $data['home_link'],':wikipedia_link' => $data['wikipedia_link']); |
|
771 | + $query_values = array(':airport_id' => $i, ':name' => $data['name'], ':iata' => $data['iata_code'], ':icao' => $data['gps_code'], ':latitude' => $data['latitude_deg'], ':longitude' => $data['longitude_deg'], ':altitude' => $data['elevation_ft'], ':type' => $data['type'], ':city' => $data['municipality'], ':country' => $data['iso_country'], ':home_link' => $data['home_link'], ':wikipedia_link' => $data['wikipedia_link']); |
|
772 | 772 | try { |
773 | 773 | $sth = $Connection->db->prepare($query); |
774 | 774 | $sth->execute($query_values); |
775 | - } catch(PDOException $e) { |
|
775 | + } catch (PDOException $e) { |
|
776 | 776 | return "error : ".$e->getMessage(); |
777 | 777 | } |
778 | 778 | $i++; |
@@ -785,7 +785,7 @@ discard block |
||
785 | 785 | |
786 | 786 | echo "Download data from another free database...\n"; |
787 | 787 | $out_file = $tmp_dir.'GlobalAirportDatabase.zip'; |
788 | - update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file); |
|
788 | + update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip', $out_file); |
|
789 | 789 | if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
790 | 790 | update_db::unzip($out_file); |
791 | 791 | $header = NULL; |
@@ -797,15 +797,15 @@ discard block |
||
797 | 797 | //$Connection->db->beginTransaction(); |
798 | 798 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
799 | 799 | { |
800 | - if(!$header) $header = $row; |
|
800 | + if (!$header) $header = $row; |
|
801 | 801 | else { |
802 | 802 | $data = $row; |
803 | 803 | |
804 | 804 | $query = 'UPDATE airport SET `city` = :city, `country` = :country WHERE icao = :icao'; |
805 | 805 | try { |
806 | 806 | $sth = $Connection->db->prepare($query); |
807 | - $sth->execute(array(':icao' => $data[0],':city' => ucwords(strtolower($data[3])),':country' => ucwords(strtolower($data[4])))); |
|
808 | - } catch(PDOException $e) { |
|
807 | + $sth->execute(array(':icao' => $data[0], ':city' => ucwords(strtolower($data[3])), ':country' => ucwords(strtolower($data[4])))); |
|
808 | + } catch (PDOException $e) { |
|
809 | 809 | return "error : ".$e->getMessage(); |
810 | 810 | } |
811 | 811 | } |
@@ -819,15 +819,15 @@ discard block |
||
819 | 819 | try { |
820 | 820 | $sth = $Connection->db->prepare("SELECT icao FROM airport WHERE `name` LIKE '%Air Base%'"); |
821 | 821 | $sth->execute(); |
822 | - } catch(PDOException $e) { |
|
822 | + } catch (PDOException $e) { |
|
823 | 823 | return "error : ".$e->getMessage(); |
824 | 824 | } |
825 | 825 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
826 | 826 | $query2 = 'UPDATE airport SET `type` = :type WHERE icao = :icao'; |
827 | 827 | try { |
828 | 828 | $sth2 = $Connection->db->prepare($query2); |
829 | - $sth2->execute(array(':icao' => $row['icao'],':type' => 'military')); |
|
830 | - } catch(PDOException $e) { |
|
829 | + $sth2->execute(array(':icao' => $row['icao'], ':type' => 'military')); |
|
830 | + } catch (PDOException $e) { |
|
831 | 831 | return "error : ".$e->getMessage(); |
832 | 832 | } |
833 | 833 | } |
@@ -851,7 +851,7 @@ discard block |
||
851 | 851 | $Connection = new Connection(); |
852 | 852 | $sth = $Connection->db->prepare($query); |
853 | 853 | $sth->execute(array(':source' => 'translation.csv')); |
854 | - } catch(PDOException $e) { |
|
854 | + } catch (PDOException $e) { |
|
855 | 855 | return "error : ".$e->getMessage(); |
856 | 856 | } |
857 | 857 | |
@@ -868,7 +868,7 @@ discard block |
||
868 | 868 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
869 | 869 | { |
870 | 870 | $i++; |
871 | - if($i > 12) { |
|
871 | + if ($i > 12) { |
|
872 | 872 | $data = $row; |
873 | 873 | $operator = $data[2]; |
874 | 874 | if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) { |
@@ -876,7 +876,7 @@ discard block |
||
876 | 876 | //echo substr($operator, 0, 2)."\n";; |
877 | 877 | if (count($airline_array) > 0) { |
878 | 878 | //print_r($airline_array); |
879 | - $operator = $airline_array[0]['icao'].substr($operator,2); |
|
879 | + $operator = $airline_array[0]['icao'].substr($operator, 2); |
|
880 | 880 | } |
881 | 881 | } |
882 | 882 | |
@@ -884,14 +884,14 @@ discard block |
||
884 | 884 | if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) { |
885 | 885 | $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2)); |
886 | 886 | if (count($airline_array) > 0) { |
887 | - $operator_correct = $airline_array[0]['icao'].substr($operator_correct,2); |
|
887 | + $operator_correct = $airline_array[0]['icao'].substr($operator_correct, 2); |
|
888 | 888 | } |
889 | 889 | } |
890 | 890 | $query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)'; |
891 | 891 | try { |
892 | 892 | $sth = $Connection->db->prepare($query); |
893 | - $sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $operator,':Operator_correct' => $operator_correct, ':source' => 'translation.csv')); |
|
894 | - } catch(PDOException $e) { |
|
893 | + $sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $operator, ':Operator_correct' => $operator_correct, ':source' => 'translation.csv')); |
|
894 | + } catch (PDOException $e) { |
|
895 | 895 | return "error : ".$e->getMessage(); |
896 | 896 | } |
897 | 897 | } |
@@ -911,7 +911,7 @@ discard block |
||
911 | 911 | $Connection = new Connection(); |
912 | 912 | $sth = $Connection->db->prepare($query); |
913 | 913 | $sth->execute(array(':source' => 'website_fam')); |
914 | - } catch(PDOException $e) { |
|
914 | + } catch (PDOException $e) { |
|
915 | 915 | return "error : ".$e->getMessage(); |
916 | 916 | } |
917 | 917 | |
@@ -931,8 +931,8 @@ discard block |
||
931 | 931 | $query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)'; |
932 | 932 | try { |
933 | 933 | $sth = $Connection->db->prepare($query); |
934 | - $sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $data[2],':Operator_correct' => $data[3], ':source' => 'website_fam')); |
|
935 | - } catch(PDOException $e) { |
|
934 | + $sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $data[2], ':Operator_correct' => $data[3], ':source' => 'website_fam')); |
|
935 | + } catch (PDOException $e) { |
|
936 | 936 | return "error : ".$e->getMessage(); |
937 | 937 | } |
938 | 938 | } |
@@ -953,7 +953,7 @@ discard block |
||
953 | 953 | $Connection = new Connection(); |
954 | 954 | $sth = $Connection->db->prepare($query); |
955 | 955 | $sth->execute(array(':source' => 'website_fam')); |
956 | - } catch(PDOException $e) { |
|
956 | + } catch (PDOException $e) { |
|
957 | 957 | return "error : ".$e->getMessage(); |
958 | 958 | } |
959 | 959 | |
@@ -974,8 +974,8 @@ discard block |
||
974 | 974 | $query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)'; |
975 | 975 | try { |
976 | 976 | $sth = $Connection->db->prepare($query); |
977 | - $sth->execute(array(':FirstCreated' => $data[0],':LastModified' => $data[1],':ModeS' => $data[2],':ModeSCountry' => $data[3], ':Registration' => $data[4],':ICAOTypeCode' => $data[5],':type_flight' => $data[6],':source' => 'website_fam')); |
|
978 | - } catch(PDOException $e) { |
|
977 | + $sth->execute(array(':FirstCreated' => $data[0], ':LastModified' => $data[1], ':ModeS' => $data[2], ':ModeSCountry' => $data[3], ':Registration' => $data[4], ':ICAOTypeCode' => $data[5], ':type_flight' => $data[6], ':source' => 'website_fam')); |
|
978 | + } catch (PDOException $e) { |
|
979 | 979 | return "error : ".$e->getMessage(); |
980 | 980 | } |
981 | 981 | } |
@@ -987,7 +987,7 @@ discard block |
||
987 | 987 | return ''; |
988 | 988 | } |
989 | 989 | |
990 | - public static function tle($filename,$tletype) { |
|
990 | + public static function tle($filename, $tletype) { |
|
991 | 991 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
992 | 992 | global $tmp_dir, $globalTransaction; |
993 | 993 | //$Spotter = new Spotter(); |
@@ -997,7 +997,7 @@ discard block |
||
997 | 997 | $Connection = new Connection(); |
998 | 998 | $sth = $Connection->db->prepare($query); |
999 | 999 | $sth->execute(array(':source' => $filename)); |
1000 | - } catch(PDOException $e) { |
|
1000 | + } catch (PDOException $e) { |
|
1001 | 1001 | return "error : ".$e->getMessage(); |
1002 | 1002 | } |
1003 | 1003 | |
@@ -1022,8 +1022,8 @@ discard block |
||
1022 | 1022 | $query = 'INSERT INTO tle (tle_name,tle_tle1,tle_tle2,tle_type,tle_source) VALUES (:name, :tle1, :tle2, :type, :source)'; |
1023 | 1023 | try { |
1024 | 1024 | $sth = $Connection->db->prepare($query); |
1025 | - $sth->execute(array(':name' => $dbdata['name'],':tle1' => $dbdata['tle1'],':tle2' => $dbdata['tle2'], ':type' => $tletype,':source' => $filename)); |
|
1026 | - } catch(PDOException $e) { |
|
1025 | + $sth->execute(array(':name' => $dbdata['name'], ':tle1' => $dbdata['tle1'], ':tle2' => $dbdata['tle2'], ':type' => $tletype, ':source' => $filename)); |
|
1026 | + } catch (PDOException $e) { |
|
1027 | 1027 | return "error : ".$e->getMessage(); |
1028 | 1028 | } |
1029 | 1029 | |
@@ -1043,28 +1043,28 @@ discard block |
||
1043 | 1043 | */ |
1044 | 1044 | private static function table2array($data) { |
1045 | 1045 | $html = str_get_html($data); |
1046 | - $tabledata=array(); |
|
1047 | - foreach($html->find('tr') as $element) |
|
1046 | + $tabledata = array(); |
|
1047 | + foreach ($html->find('tr') as $element) |
|
1048 | 1048 | { |
1049 | 1049 | $td = array(); |
1050 | - foreach( $element->find('th') as $row) |
|
1050 | + foreach ($element->find('th') as $row) |
|
1051 | 1051 | { |
1052 | 1052 | $td [] = trim($row->plaintext); |
1053 | 1053 | } |
1054 | - $td=array_filter($td); |
|
1054 | + $td = array_filter($td); |
|
1055 | 1055 | $tabledata[] = $td; |
1056 | 1056 | |
1057 | 1057 | $td = array(); |
1058 | 1058 | $tdi = array(); |
1059 | - foreach( $element->find('td') as $row) |
|
1059 | + foreach ($element->find('td') as $row) |
|
1060 | 1060 | { |
1061 | 1061 | $td [] = trim($row->plaintext); |
1062 | 1062 | $tdi [] = trim($row->innertext); |
1063 | 1063 | } |
1064 | - $td=array_filter($td); |
|
1065 | - $tdi=array_filter($tdi); |
|
1064 | + $td = array_filter($td); |
|
1065 | + $tdi = array_filter($tdi); |
|
1066 | 1066 | // $tabledata[]=array_merge($td,$tdi); |
1067 | - $tabledata[]=$td; |
|
1067 | + $tabledata[] = $td; |
|
1068 | 1068 | } |
1069 | 1069 | return(array_filter($tabledata)); |
1070 | 1070 | } |
@@ -1137,13 +1137,13 @@ discard block |
||
1137 | 1137 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1138 | 1138 | { |
1139 | 1139 | $i++; |
1140 | - if($i > 3 && count($row) > 2) { |
|
1140 | + if ($i > 3 && count($row) > 2) { |
|
1141 | 1141 | $data = array_values(array_filter($row)); |
1142 | 1142 | $cntdata = count($data); |
1143 | 1143 | if ($cntdata > 10) { |
1144 | 1144 | $value = $data[9]; |
1145 | 1145 | |
1146 | - for ($i =10;$i < $cntdata;$i++) { |
|
1146 | + for ($i = 10; $i < $cntdata; $i++) { |
|
1147 | 1147 | $value .= ' '.$data[$i]; |
1148 | 1148 | } |
1149 | 1149 | $data[9] = $value; |
@@ -1153,8 +1153,8 @@ discard block |
||
1153 | 1153 | $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)'; |
1154 | 1154 | try { |
1155 | 1155 | $sth = $Connection->db->prepare($query); |
1156 | - $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])); |
|
1157 | - } catch(PDOException $e) { |
|
1156 | + $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])); |
|
1157 | + } catch (PDOException $e) { |
|
1158 | 1158 | return "error : ".$e->getMessage(); |
1159 | 1159 | } |
1160 | 1160 | } |
@@ -1175,7 +1175,7 @@ discard block |
||
1175 | 1175 | $Connection = new Connection(); |
1176 | 1176 | $sth = $Connection->db->prepare($query); |
1177 | 1177 | $sth->execute(); |
1178 | - } catch(PDOException $e) { |
|
1178 | + } catch (PDOException $e) { |
|
1179 | 1179 | return "error : ".$e->getMessage(); |
1180 | 1180 | } |
1181 | 1181 | |
@@ -1187,12 +1187,12 @@ discard block |
||
1187 | 1187 | if ($globalTransaction) $Connection->db->beginTransaction(); |
1188 | 1188 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1189 | 1189 | { |
1190 | - if(count($row) > 1) { |
|
1190 | + if (count($row) > 1) { |
|
1191 | 1191 | $query = "INSERT INTO airlines (name,icao,active,forsource) VALUES (:name, :icao, 'Y','ivao')"; |
1192 | 1192 | try { |
1193 | 1193 | $sth = $Connection->db->prepare($query); |
1194 | - $sth->execute(array(':name' => $row[1],':icao' => $row[0])); |
|
1195 | - } catch(PDOException $e) { |
|
1194 | + $sth->execute(array(':name' => $row[1], ':icao' => $row[0])); |
|
1195 | + } catch (PDOException $e) { |
|
1196 | 1196 | return "error : ".$e->getMessage(); |
1197 | 1197 | } |
1198 | 1198 | } |
@@ -1212,21 +1212,21 @@ discard block |
||
1212 | 1212 | try { |
1213 | 1213 | $sth = $Connection->db->prepare($query); |
1214 | 1214 | $sth->execute(); |
1215 | - } catch(PDOException $e) { |
|
1215 | + } catch (PDOException $e) { |
|
1216 | 1216 | return "error : ".$e->getMessage(); |
1217 | 1217 | } |
1218 | 1218 | } |
1219 | 1219 | |
1220 | 1220 | |
1221 | - if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
1221 | + if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz', $tmp_dir.'airspace.sql'); |
|
1222 | 1222 | else { |
1223 | - update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
1223 | + update_db::gunzip('../db/pgsql/airspace.sql.gz', $tmp_dir.'airspace.sql'); |
|
1224 | 1224 | $query = "CREATE EXTENSION postgis"; |
1225 | - $Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']); |
|
1225 | + $Connection = new Connection(null, null, $_SESSION['database_root'], $_SESSION['database_rootpass']); |
|
1226 | 1226 | try { |
1227 | 1227 | $sth = $Connection->db->prepare($query); |
1228 | 1228 | $sth->execute(); |
1229 | - } catch(PDOException $e) { |
|
1229 | + } catch (PDOException $e) { |
|
1230 | 1230 | return "error : ".$e->getMessage(); |
1231 | 1231 | } |
1232 | 1232 | } |
@@ -1239,7 +1239,7 @@ discard block |
||
1239 | 1239 | include_once('class.create_db.php'); |
1240 | 1240 | require_once(dirname(__FILE__).'/../require/class.NOTAM.php'); |
1241 | 1241 | if ($globalDebug) echo "NOTAM from FlightAirMap website : Download..."; |
1242 | - update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz'); |
|
1242 | + update_db::download('http://data.flightairmap.fr/data/notam.txt.gz', $tmp_dir.'notam.txt.gz'); |
|
1243 | 1243 | $error = ''; |
1244 | 1244 | if (file_exists($tmp_dir.'notam.txt.gz')) { |
1245 | 1245 | if ($globalDebug) echo "Gunzip..."; |
@@ -1271,14 +1271,14 @@ discard block |
||
1271 | 1271 | try { |
1272 | 1272 | $sth = $Connection->db->prepare($query); |
1273 | 1273 | $sth->execute(); |
1274 | - } catch(PDOException $e) { |
|
1274 | + } catch (PDOException $e) { |
|
1275 | 1275 | echo "error : ".$e->getMessage(); |
1276 | 1276 | } |
1277 | 1277 | } |
1278 | 1278 | if ($globalDBdriver == 'mysql') { |
1279 | - update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql'); |
|
1279 | + update_db::gunzip('../db/countries.sql.gz', $tmp_dir.'countries.sql'); |
|
1280 | 1280 | } else { |
1281 | - update_db::gunzip('../db/pgsql/countries.sql.gz',$tmp_dir.'countries.sql'); |
|
1281 | + update_db::gunzip('../db/pgsql/countries.sql.gz', $tmp_dir.'countries.sql'); |
|
1282 | 1282 | } |
1283 | 1283 | $error = create_db::import_file($tmp_dir.'countries.sql'); |
1284 | 1284 | return $error; |
@@ -1291,7 +1291,7 @@ discard block |
||
1291 | 1291 | // update_db::unzip($tmp_dir.'AptNav.zip'); |
1292 | 1292 | // update_db::download('https://gitorious.org/fg/fgdata/raw/e81f8a15424a175a7b715f8f7eb8f4147b802a27:Navaids/awy.dat.gz',$tmp_dir.'awy.dat.gz'); |
1293 | 1293 | // 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'); |
1294 | - 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'); |
|
1294 | + 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'); |
|
1295 | 1295 | update_db::gunzip($tmp_dir.'awy.dat.gz'); |
1296 | 1296 | $error = update_db::waypoints($tmp_dir.'awy.dat'); |
1297 | 1297 | return $error; |
@@ -1311,7 +1311,7 @@ discard block |
||
1311 | 1311 | update_db::ivao_airlines($tmp_dir.'data/airlines.dat'); |
1312 | 1312 | if ($globalDebug) echo "Copy airlines logos to airlines images directory..."; |
1313 | 1313 | if (is_writable(dirname(__FILE__).'/../images/airlines')) { |
1314 | - if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
1314 | + if (!$Common->xcopy($tmp_dir.'logos/', dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
1315 | 1315 | } else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
1316 | 1316 | } else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
1317 | 1317 | if ($error != '') { |
@@ -1324,7 +1324,7 @@ discard block |
||
1324 | 1324 | global $tmp_dir, $globalDebug; |
1325 | 1325 | $error = ''; |
1326 | 1326 | if ($globalDebug) echo "Routes : Download..."; |
1327 | - update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz'); |
|
1327 | + update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz', $tmp_dir.'StandingData.sqb.gz'); |
|
1328 | 1328 | if (file_exists($tmp_dir.'StandingData.sqb.gz')) { |
1329 | 1329 | if ($globalDebug) echo "Gunzip..."; |
1330 | 1330 | update_db::gunzip($tmp_dir.'StandingData.sqb.gz'); |
@@ -1340,7 +1340,7 @@ discard block |
||
1340 | 1340 | global $tmp_dir, $globalDebug; |
1341 | 1341 | $error = ''; |
1342 | 1342 | if ($globalDebug) echo "Schedules Oneworld : Download..."; |
1343 | - update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz'); |
|
1343 | + update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz', $tmp_dir.'oneworld.csv.gz'); |
|
1344 | 1344 | if (file_exists($tmp_dir.'oneworld.csv.gz')) { |
1345 | 1345 | if ($globalDebug) echo "Gunzip..."; |
1346 | 1346 | update_db::gunzip($tmp_dir.'oneworld.csv.gz'); |
@@ -1356,7 +1356,7 @@ discard block |
||
1356 | 1356 | global $tmp_dir, $globalDebug; |
1357 | 1357 | $error = ''; |
1358 | 1358 | if ($globalDebug) echo "Schedules Skyteam : Download..."; |
1359 | - update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz'); |
|
1359 | + update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz', $tmp_dir.'skyteam.csv.gz'); |
|
1360 | 1360 | if (file_exists($tmp_dir.'skyteam.csv.gz')) { |
1361 | 1361 | if ($globalDebug) echo "Gunzip..."; |
1362 | 1362 | update_db::gunzip($tmp_dir.'skyteam.csv.gz'); |
@@ -1384,7 +1384,7 @@ discard block |
||
1384 | 1384 | */ |
1385 | 1385 | if ($globalDebug) echo "Modes : Download..."; |
1386 | 1386 | // update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
1387 | - update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz'); |
|
1387 | + update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz', $tmp_dir.'BaseStation.sqb.gz'); |
|
1388 | 1388 | |
1389 | 1389 | // if (file_exists($tmp_dir.'basestation_latest.zip')) { |
1390 | 1390 | if (file_exists($tmp_dir.'BaseStation.sqb.gz')) { |
@@ -1404,7 +1404,7 @@ discard block |
||
1404 | 1404 | public static function update_ModeS_flarm() { |
1405 | 1405 | global $tmp_dir, $globalDebug; |
1406 | 1406 | if ($globalDebug) echo "Modes Flarmnet: Download..."; |
1407 | - update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln'); |
|
1407 | + update_db::download('http://flarmnet.org/files/data.fln', $tmp_dir.'data.fln'); |
|
1408 | 1408 | if (file_exists($tmp_dir.'data.fln')) { |
1409 | 1409 | if ($globalDebug) echo "Add to DB..."; |
1410 | 1410 | $error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln'); |
@@ -1418,7 +1418,7 @@ discard block |
||
1418 | 1418 | public static function update_ModeS_ogn() { |
1419 | 1419 | global $tmp_dir, $globalDebug; |
1420 | 1420 | if ($globalDebug) echo "Modes OGN: Download..."; |
1421 | - update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv'); |
|
1421 | + update_db::download('http://ddb.glidernet.org/download/', $tmp_dir.'ogn.csv'); |
|
1422 | 1422 | if (file_exists($tmp_dir.'ogn.csv')) { |
1423 | 1423 | if ($globalDebug) echo "Add to DB..."; |
1424 | 1424 | $error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv'); |
@@ -1433,173 +1433,173 @@ discard block |
||
1433 | 1433 | global $tmp_dir, $globalDebug; |
1434 | 1434 | |
1435 | 1435 | if ($globalDebug) echo "Owner France: Download..."; |
1436 | - update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv'); |
|
1436 | + update_db::download('http://antonakis.co.uk/registers/France.txt', $tmp_dir.'owner_f.csv'); |
|
1437 | 1437 | if (file_exists($tmp_dir.'owner_f.csv')) { |
1438 | 1438 | if ($globalDebug) echo "Add to DB..."; |
1439 | - $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F'); |
|
1439 | + $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv', 'F'); |
|
1440 | 1440 | } else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
1441 | 1441 | if ($error != '') { |
1442 | 1442 | return $error; |
1443 | 1443 | } elseif ($globalDebug) echo "Done\n"; |
1444 | 1444 | |
1445 | 1445 | if ($globalDebug) echo "Owner Ireland: Download..."; |
1446 | - update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv'); |
|
1446 | + update_db::download('http://antonakis.co.uk/registers/Ireland.txt', $tmp_dir.'owner_ei.csv'); |
|
1447 | 1447 | if (file_exists($tmp_dir.'owner_ei.csv')) { |
1448 | 1448 | if ($globalDebug) echo "Add to DB..."; |
1449 | - $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI'); |
|
1449 | + $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv', 'EI'); |
|
1450 | 1450 | } else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
1451 | 1451 | if ($error != '') { |
1452 | 1452 | return $error; |
1453 | 1453 | } elseif ($globalDebug) echo "Done\n"; |
1454 | 1454 | if ($globalDebug) echo "Owner Switzerland: Download..."; |
1455 | - update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv'); |
|
1455 | + update_db::download('http://antonakis.co.uk/registers/Switzerland.txt', $tmp_dir.'owner_hb.csv'); |
|
1456 | 1456 | if (file_exists($tmp_dir.'owner_hb.csv')) { |
1457 | 1457 | if ($globalDebug) echo "Add to DB..."; |
1458 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB'); |
|
1458 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv', 'HB'); |
|
1459 | 1459 | } else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
1460 | 1460 | if ($error != '') { |
1461 | 1461 | return $error; |
1462 | 1462 | } elseif ($globalDebug) echo "Done\n"; |
1463 | 1463 | if ($globalDebug) echo "Owner Czech Republic: Download..."; |
1464 | - update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv'); |
|
1464 | + update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt', $tmp_dir.'owner_ok.csv'); |
|
1465 | 1465 | if (file_exists($tmp_dir.'owner_ok.csv')) { |
1466 | 1466 | if ($globalDebug) echo "Add to DB..."; |
1467 | - $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK'); |
|
1467 | + $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv', 'OK'); |
|
1468 | 1468 | } else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
1469 | 1469 | if ($error != '') { |
1470 | 1470 | return $error; |
1471 | 1471 | } elseif ($globalDebug) echo "Done\n"; |
1472 | 1472 | if ($globalDebug) echo "Owner Australia: Download..."; |
1473 | - update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv'); |
|
1473 | + update_db::download('http://antonakis.co.uk/registers/Australia.txt', $tmp_dir.'owner_vh.csv'); |
|
1474 | 1474 | if (file_exists($tmp_dir.'owner_vh.csv')) { |
1475 | 1475 | if ($globalDebug) echo "Add to DB..."; |
1476 | - $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH'); |
|
1476 | + $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv', 'VH'); |
|
1477 | 1477 | } else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
1478 | 1478 | if ($error != '') { |
1479 | 1479 | return $error; |
1480 | 1480 | } elseif ($globalDebug) echo "Done\n"; |
1481 | 1481 | if ($globalDebug) echo "Owner Austria: Download..."; |
1482 | - update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv'); |
|
1482 | + update_db::download('http://antonakis.co.uk/registers/Austria.txt', $tmp_dir.'owner_oe.csv'); |
|
1483 | 1483 | if (file_exists($tmp_dir.'owner_oe.csv')) { |
1484 | 1484 | if ($globalDebug) echo "Add to DB..."; |
1485 | - $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE'); |
|
1485 | + $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv', 'OE'); |
|
1486 | 1486 | } else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
1487 | 1487 | if ($error != '') { |
1488 | 1488 | return $error; |
1489 | 1489 | } elseif ($globalDebug) echo "Done\n"; |
1490 | 1490 | if ($globalDebug) echo "Owner Chile: Download..."; |
1491 | - update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv'); |
|
1491 | + update_db::download('http://antonakis.co.uk/registers/Chile.txt', $tmp_dir.'owner_cc.csv'); |
|
1492 | 1492 | if (file_exists($tmp_dir.'owner_cc.csv')) { |
1493 | 1493 | if ($globalDebug) echo "Add to DB..."; |
1494 | - $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC'); |
|
1494 | + $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv', 'CC'); |
|
1495 | 1495 | } else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
1496 | 1496 | if ($error != '') { |
1497 | 1497 | return $error; |
1498 | 1498 | } elseif ($globalDebug) echo "Done\n"; |
1499 | 1499 | if ($globalDebug) echo "Owner Colombia: Download..."; |
1500 | - update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv'); |
|
1500 | + update_db::download('http://antonakis.co.uk/registers/Colombia.txt', $tmp_dir.'owner_hj.csv'); |
|
1501 | 1501 | if (file_exists($tmp_dir.'owner_hj.csv')) { |
1502 | 1502 | if ($globalDebug) echo "Add to DB..."; |
1503 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ'); |
|
1503 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv', 'HJ'); |
|
1504 | 1504 | } else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
1505 | 1505 | if ($error != '') { |
1506 | 1506 | return $error; |
1507 | 1507 | } elseif ($globalDebug) echo "Done\n"; |
1508 | 1508 | if ($globalDebug) echo "Owner Bosnia Herzegobina: Download..."; |
1509 | - update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv'); |
|
1509 | + update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt', $tmp_dir.'owner_e7.csv'); |
|
1510 | 1510 | if (file_exists($tmp_dir.'owner_e7.csv')) { |
1511 | 1511 | if ($globalDebug) echo "Add to DB..."; |
1512 | - $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7'); |
|
1512 | + $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv', 'E7'); |
|
1513 | 1513 | } else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
1514 | 1514 | if ($error != '') { |
1515 | 1515 | return $error; |
1516 | 1516 | } elseif ($globalDebug) echo "Done\n"; |
1517 | 1517 | if ($globalDebug) echo "Owner Brazil: Download..."; |
1518 | - update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv'); |
|
1518 | + update_db::download('http://antonakis.co.uk/registers/Brazil.txt', $tmp_dir.'owner_pp.csv'); |
|
1519 | 1519 | if (file_exists($tmp_dir.'owner_pp.csv')) { |
1520 | 1520 | if ($globalDebug) echo "Add to DB..."; |
1521 | - $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP'); |
|
1521 | + $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv', 'PP'); |
|
1522 | 1522 | } else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
1523 | 1523 | if ($error != '') { |
1524 | 1524 | return $error; |
1525 | 1525 | } elseif ($globalDebug) echo "Done\n"; |
1526 | 1526 | if ($globalDebug) echo "Owner Cayman Islands: Download..."; |
1527 | - update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv'); |
|
1527 | + update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt', $tmp_dir.'owner_vp.csv'); |
|
1528 | 1528 | if (file_exists($tmp_dir.'owner_vp.csv')) { |
1529 | 1529 | if ($globalDebug) echo "Add to DB..."; |
1530 | - $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP'); |
|
1530 | + $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv', 'VP'); |
|
1531 | 1531 | } else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
1532 | 1532 | if ($error != '') { |
1533 | 1533 | return $error; |
1534 | 1534 | } elseif ($globalDebug) echo "Done\n"; |
1535 | 1535 | if ($globalDebug) echo "Owner Croatia: Download..."; |
1536 | - update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv'); |
|
1536 | + update_db::download('http://antonakis.co.uk/registers/Croatia.txt', $tmp_dir.'owner_9a.csv'); |
|
1537 | 1537 | if (file_exists($tmp_dir.'owner_9a.csv')) { |
1538 | 1538 | if ($globalDebug) echo "Add to DB..."; |
1539 | - $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A'); |
|
1539 | + $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv', '9A'); |
|
1540 | 1540 | } else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
1541 | 1541 | if ($error != '') { |
1542 | 1542 | return $error; |
1543 | 1543 | } elseif ($globalDebug) echo "Done\n"; |
1544 | 1544 | if ($globalDebug) echo "Owner Luxembourg: Download..."; |
1545 | - update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv'); |
|
1545 | + update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt', $tmp_dir.'owner_lx.csv'); |
|
1546 | 1546 | if (file_exists($tmp_dir.'owner_lx.csv')) { |
1547 | 1547 | if ($globalDebug) echo "Add to DB..."; |
1548 | - $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX'); |
|
1548 | + $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv', 'LX'); |
|
1549 | 1549 | } else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
1550 | 1550 | if ($error != '') { |
1551 | 1551 | return $error; |
1552 | 1552 | } elseif ($globalDebug) echo "Done\n"; |
1553 | 1553 | if ($globalDebug) echo "Owner Maldives: Download..."; |
1554 | - update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv'); |
|
1554 | + update_db::download('http://antonakis.co.uk/registers/Maldives.txt', $tmp_dir.'owner_8q.csv'); |
|
1555 | 1555 | if (file_exists($tmp_dir.'owner_8q.csv')) { |
1556 | 1556 | if ($globalDebug) echo "Add to DB..."; |
1557 | - $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q'); |
|
1557 | + $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv', '8Q'); |
|
1558 | 1558 | } else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
1559 | 1559 | if ($error != '') { |
1560 | 1560 | return $error; |
1561 | 1561 | } elseif ($globalDebug) echo "Done\n"; |
1562 | 1562 | if ($globalDebug) echo "Owner New Zealand: Download..."; |
1563 | - update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv'); |
|
1563 | + update_db::download('http://antonakis.co.uk/registers/NewZealand.txt', $tmp_dir.'owner_zk.csv'); |
|
1564 | 1564 | if (file_exists($tmp_dir.'owner_zk.csv')) { |
1565 | 1565 | if ($globalDebug) echo "Add to DB..."; |
1566 | - $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK'); |
|
1566 | + $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv', 'ZK'); |
|
1567 | 1567 | } else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
1568 | 1568 | if ($error != '') { |
1569 | 1569 | return $error; |
1570 | 1570 | } elseif ($globalDebug) echo "Done\n"; |
1571 | 1571 | if ($globalDebug) echo "Owner Papua New Guinea: Download..."; |
1572 | - update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv'); |
|
1572 | + update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt', $tmp_dir.'owner_p2.csv'); |
|
1573 | 1573 | if (file_exists($tmp_dir.'owner_p2.csv')) { |
1574 | 1574 | if ($globalDebug) echo "Add to DB..."; |
1575 | - $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2'); |
|
1575 | + $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv', 'P2'); |
|
1576 | 1576 | } else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
1577 | 1577 | if ($error != '') { |
1578 | 1578 | return $error; |
1579 | 1579 | } elseif ($globalDebug) echo "Done\n"; |
1580 | 1580 | if ($globalDebug) echo "Owner Slovakia: Download..."; |
1581 | - update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv'); |
|
1581 | + update_db::download('http://antonakis.co.uk/registers/Slovakia.txt', $tmp_dir.'owner_om.csv'); |
|
1582 | 1582 | if (file_exists($tmp_dir.'owner_om.csv')) { |
1583 | 1583 | if ($globalDebug) echo "Add to DB..."; |
1584 | - $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM'); |
|
1584 | + $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv', 'OM'); |
|
1585 | 1585 | } else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
1586 | 1586 | if ($error != '') { |
1587 | 1587 | return $error; |
1588 | 1588 | } elseif ($globalDebug) echo "Done\n"; |
1589 | 1589 | if ($globalDebug) echo "Owner Ecuador: Download..."; |
1590 | - update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv'); |
|
1590 | + update_db::download('http://antonakis.co.uk/registers/Ecuador.txt', $tmp_dir.'owner_hc.csv'); |
|
1591 | 1591 | if (file_exists($tmp_dir.'owner_hc.csv')) { |
1592 | 1592 | if ($globalDebug) echo "Add to DB..."; |
1593 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC'); |
|
1593 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv', 'HC'); |
|
1594 | 1594 | } else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
1595 | 1595 | if ($error != '') { |
1596 | 1596 | return $error; |
1597 | 1597 | } elseif ($globalDebug) echo "Done\n"; |
1598 | 1598 | if ($globalDebug) echo "Owner Iceland: Download..."; |
1599 | - update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv'); |
|
1599 | + update_db::download('http://antonakis.co.uk/registers/Iceland.txt', $tmp_dir.'owner_tf.csv'); |
|
1600 | 1600 | if (file_exists($tmp_dir.'owner_tf.csv')) { |
1601 | 1601 | if ($globalDebug) echo "Add to DB..."; |
1602 | - $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF'); |
|
1602 | + $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv', 'TF'); |
|
1603 | 1603 | } else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
1604 | 1604 | if ($error != '') { |
1605 | 1605 | return $error; |
@@ -1611,7 +1611,7 @@ discard block |
||
1611 | 1611 | global $tmp_dir, $globalDebug; |
1612 | 1612 | $error = ''; |
1613 | 1613 | if ($globalDebug) echo "Translation : Download..."; |
1614 | - update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip'); |
|
1614 | + update_db::download('http://www.acarsd.org/download/translation.php', $tmp_dir.'translation.zip'); |
|
1615 | 1615 | if (file_exists($tmp_dir.'translation.zip')) { |
1616 | 1616 | if ($globalDebug) echo "Unzip..."; |
1617 | 1617 | update_db::unzip($tmp_dir.'translation.zip'); |
@@ -1627,7 +1627,7 @@ discard block |
||
1627 | 1627 | public static function update_translation_fam() { |
1628 | 1628 | global $tmp_dir, $globalDebug; |
1629 | 1629 | if ($globalDebug) echo "Translation from FlightAirMap website : Download..."; |
1630 | - update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz'); |
|
1630 | + update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz', $tmp_dir.'translation.tsv.gz'); |
|
1631 | 1631 | if (file_exists($tmp_dir.'translation.tsv.gz')) { |
1632 | 1632 | if ($globalDebug) echo "Gunzip..."; |
1633 | 1633 | update_db::gunzip($tmp_dir.'translation.tsv.gz'); |
@@ -1642,7 +1642,7 @@ discard block |
||
1642 | 1642 | public static function update_ModeS_fam() { |
1643 | 1643 | global $tmp_dir, $globalDebug; |
1644 | 1644 | if ($globalDebug) echo "ModeS from FlightAirMap website : Download..."; |
1645 | - update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz'); |
|
1645 | + update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz', $tmp_dir.'modes.tsv.gz'); |
|
1646 | 1646 | if (file_exists($tmp_dir.'modes.tsv.gz')) { |
1647 | 1647 | if ($globalDebug) echo "Gunzip..."; |
1648 | 1648 | update_db::gunzip($tmp_dir.'modes.tsv.gz'); |
@@ -1661,18 +1661,18 @@ discard block |
||
1661 | 1661 | $error = ''; |
1662 | 1662 | if ($globalDebug) echo "Airspace from FlightAirMap website : Download..."; |
1663 | 1663 | if ($globalDBdriver == 'mysql') { |
1664 | - update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); |
|
1664 | + update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5'); |
|
1665 | 1665 | } else { |
1666 | - update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); |
|
1666 | + update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5'); |
|
1667 | 1667 | } |
1668 | 1668 | if (file_exists($tmp_dir.'airspace.sql.gz.md5')) { |
1669 | - $airspace_md5_file = explode(' ',file_get_contents($tmp_dir.'airspace.sql.gz.md5')); |
|
1669 | + $airspace_md5_file = explode(' ', file_get_contents($tmp_dir.'airspace.sql.gz.md5')); |
|
1670 | 1670 | $airspace_md5 = $airspace_md5_file[0]; |
1671 | 1671 | if (!update_db::check_airspace_version($airspace_md5)) { |
1672 | 1672 | if ($globalDBdriver == 'mysql') { |
1673 | - update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz',$tmp_dir.'airspace.sql.gz'); |
|
1673 | + update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz', $tmp_dir.'airspace.sql.gz'); |
|
1674 | 1674 | } else { |
1675 | - update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz'); |
|
1675 | + update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz', $tmp_dir.'airspace.sql.gz'); |
|
1676 | 1676 | } |
1677 | 1677 | if (file_exists($tmp_dir.'airspace.sql.gz')) { |
1678 | 1678 | if ($globalDebug) echo "Gunzip..."; |
@@ -1684,7 +1684,7 @@ discard block |
||
1684 | 1684 | try { |
1685 | 1685 | $sth = $Connection->db->prepare($query); |
1686 | 1686 | $sth->execute(); |
1687 | - } catch(PDOException $e) { |
|
1687 | + } catch (PDOException $e) { |
|
1688 | 1688 | return "error : ".$e->getMessage(); |
1689 | 1689 | } |
1690 | 1690 | } |
@@ -1702,15 +1702,15 @@ discard block |
||
1702 | 1702 | public static function update_tle() { |
1703 | 1703 | global $tmp_dir, $globalDebug; |
1704 | 1704 | if ($globalDebug) echo "Download TLE : Download..."; |
1705 | - $alltle = array('stations.txt','gps-ops.txt','glo-ops.txt','galileo.txt','weather.txt','noaa.txt','goes.txt','resource.txt','dmc.txt','tdrss.txt','geo.txt','intelsat.txt','gorizont.txt', |
|
1706 | - 'raduga.txt','molniya.txt','iridium.txt','orbcomm.txt','globalstar.txt','amateur.txt','x-comm.txt','other-comm.txt','sbas.txt','nnss.txt','musson.txt','science.txt','geodetic.txt', |
|
1707 | - 'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt'); |
|
1705 | + $alltle = array('stations.txt', 'gps-ops.txt', 'glo-ops.txt', 'galileo.txt', 'weather.txt', 'noaa.txt', 'goes.txt', 'resource.txt', 'dmc.txt', 'tdrss.txt', 'geo.txt', 'intelsat.txt', 'gorizont.txt', |
|
1706 | + 'raduga.txt', 'molniya.txt', 'iridium.txt', 'orbcomm.txt', 'globalstar.txt', 'amateur.txt', 'x-comm.txt', 'other-comm.txt', 'sbas.txt', 'nnss.txt', 'musson.txt', 'science.txt', 'geodetic.txt', |
|
1707 | + 'engineering.txt', 'education.txt', 'military.txt', 'radar.txt', 'cubesat.txt', 'other.txt', 'tle-new.txt'); |
|
1708 | 1708 | foreach ($alltle as $filename) { |
1709 | 1709 | if ($globalDebug) echo "downloading ".$filename.'...'; |
1710 | - update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename); |
|
1710 | + update_db::download('http://celestrak.com/NORAD/elements/'.$filename, $tmp_dir.$filename); |
|
1711 | 1711 | if (file_exists($tmp_dir.$filename)) { |
1712 | 1712 | if ($globalDebug) echo "Add to DB ".$filename."..."; |
1713 | - $error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename)); |
|
1713 | + $error = update_db::tle($tmp_dir.$filename, str_replace('.txt', '', $filename)); |
|
1714 | 1714 | } else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
1715 | 1715 | if ($error != '') { |
1716 | 1716 | echo $error."\n"; |
@@ -1723,32 +1723,32 @@ discard block |
||
1723 | 1723 | global $tmp_dir, $globalDebug; |
1724 | 1724 | $error = ''; |
1725 | 1725 | if ($globalDebug) echo "Models from FlightAirMap website : Download..."; |
1726 | - update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum'); |
|
1726 | + update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', $tmp_dir.'models.md5sum'); |
|
1727 | 1727 | if (file_exists($tmp_dir.'models.md5sum')) { |
1728 | 1728 | if ($globalDebug) echo "Check files...\n"; |
1729 | 1729 | $newmodelsdb = array(); |
1730 | - if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) { |
|
1731 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
1730 | + if (($handle = fopen($tmp_dir.'models.md5sum', 'r')) !== FALSE) { |
|
1731 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
1732 | 1732 | $model = trim($row[2]); |
1733 | 1733 | $newmodelsdb[$model] = trim($row[0]); |
1734 | 1734 | } |
1735 | 1735 | } |
1736 | 1736 | $modelsdb = array(); |
1737 | 1737 | if (file_exists(dirname(__FILE__).'/../models/models.md5sum')) { |
1738 | - if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum','r')) !== FALSE) { |
|
1739 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
1738 | + if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum', 'r')) !== FALSE) { |
|
1739 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
1740 | 1740 | $model = trim($row[2]); |
1741 | 1741 | $modelsdb[$model] = trim($row[0]); |
1742 | 1742 | } |
1743 | 1743 | } |
1744 | 1744 | } |
1745 | - $diff = array_diff($newmodelsdb,$modelsdb); |
|
1745 | + $diff = array_diff($newmodelsdb, $modelsdb); |
|
1746 | 1746 | foreach ($diff as $key => $value) { |
1747 | 1747 | if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n"; |
1748 | - update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key); |
|
1748 | + update_db::download('http://data.flightairmap.fr/data/models/'.$key, dirname(__FILE__).'/../models/'.$key); |
|
1749 | 1749 | |
1750 | 1750 | } |
1751 | - update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum'); |
|
1751 | + update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', dirname(__FILE__).'/../models/models.md5sum'); |
|
1752 | 1752 | } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
1753 | 1753 | if ($error != '') { |
1754 | 1754 | return $error; |
@@ -1760,32 +1760,32 @@ discard block |
||
1760 | 1760 | global $tmp_dir, $globalDebug; |
1761 | 1761 | $error = ''; |
1762 | 1762 | if ($globalDebug) echo "Space models from FlightAirMap website : Download..."; |
1763 | - update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum'); |
|
1763 | + update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', $tmp_dir.'space_models.md5sum'); |
|
1764 | 1764 | if (file_exists($tmp_dir.'space_models.md5sum')) { |
1765 | 1765 | if ($globalDebug) echo "Check files...\n"; |
1766 | 1766 | $newmodelsdb = array(); |
1767 | - if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) { |
|
1768 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
1767 | + if (($handle = fopen($tmp_dir.'space_models.md5sum', 'r')) !== FALSE) { |
|
1768 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
1769 | 1769 | $model = trim($row[2]); |
1770 | 1770 | $newmodelsdb[$model] = trim($row[0]); |
1771 | 1771 | } |
1772 | 1772 | } |
1773 | 1773 | $modelsdb = array(); |
1774 | 1774 | if (file_exists(dirname(__FILE__).'/../models/space/space_models.md5sum')) { |
1775 | - if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum','r')) !== FALSE) { |
|
1776 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
1775 | + if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum', 'r')) !== FALSE) { |
|
1776 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
1777 | 1777 | $model = trim($row[2]); |
1778 | 1778 | $modelsdb[$model] = trim($row[0]); |
1779 | 1779 | } |
1780 | 1780 | } |
1781 | 1781 | } |
1782 | - $diff = array_diff($newmodelsdb,$modelsdb); |
|
1782 | + $diff = array_diff($newmodelsdb, $modelsdb); |
|
1783 | 1783 | foreach ($diff as $key => $value) { |
1784 | 1784 | if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n"; |
1785 | - update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key); |
|
1785 | + update_db::download('http://data.flightairmap.fr/data/models/space/'.$key, dirname(__FILE__).'/../models/space/'.$key); |
|
1786 | 1786 | |
1787 | 1787 | } |
1788 | - update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum'); |
|
1788 | + update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', dirname(__FILE__).'/../models/space/space_models.md5sum'); |
|
1789 | 1789 | } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
1790 | 1790 | if ($error != '') { |
1791 | 1791 | return $error; |
@@ -1808,8 +1808,8 @@ discard block |
||
1808 | 1808 | */ |
1809 | 1809 | if (file_exists($tmp_dir.'aircrafts.html')) { |
1810 | 1810 | //var_dump(file_get_html($tmp_dir.'aircrafts.html')); |
1811 | - $fh = fopen($tmp_dir.'aircrafts.html',"r"); |
|
1812 | - $result = fread($fh,100000000); |
|
1811 | + $fh = fopen($tmp_dir.'aircrafts.html', "r"); |
|
1812 | + $result = fread($fh, 100000000); |
|
1813 | 1813 | //echo $result; |
1814 | 1814 | //var_dump(str_get_html($result)); |
1815 | 1815 | //print_r(self::table2array($result)); |
@@ -1827,23 +1827,23 @@ discard block |
||
1827 | 1827 | $Connection = new Connection(); |
1828 | 1828 | $sth = $Connection->db->prepare($query); |
1829 | 1829 | $sth->execute(); |
1830 | - } catch(PDOException $e) { |
|
1830 | + } catch (PDOException $e) { |
|
1831 | 1831 | return "error : ".$e->getMessage(); |
1832 | 1832 | } |
1833 | 1833 | |
1834 | 1834 | $error = ''; |
1835 | 1835 | if ($globalDebug) echo "Notam : Download..."; |
1836 | - update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss'); |
|
1836 | + update_db::download($globalNOTAMSource, $tmp_dir.'notam.rss'); |
|
1837 | 1837 | if (file_exists($tmp_dir.'notam.rss')) { |
1838 | - $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true); |
|
1838 | + $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')), true); |
|
1839 | 1839 | foreach ($notams['channel']['item'] as $notam) { |
1840 | - $title = explode(':',$notam['title']); |
|
1840 | + $title = explode(':', $notam['title']); |
|
1841 | 1841 | $data['ref'] = trim($title[0]); |
1842 | 1842 | unset($title[0]); |
1843 | - $data['title'] = trim(implode(':',$title)); |
|
1844 | - $description = strip_tags($notam['description'],'<pre>'); |
|
1845 | - preg_match(':^(.*?)<pre>:',$description,$match); |
|
1846 | - $q = explode('/',$match[1]); |
|
1843 | + $data['title'] = trim(implode(':', $title)); |
|
1844 | + $description = strip_tags($notam['description'], '<pre>'); |
|
1845 | + preg_match(':^(.*?)<pre>:', $description, $match); |
|
1846 | + $q = explode('/', $match[1]); |
|
1847 | 1847 | $data['fir'] = $q[0]; |
1848 | 1848 | $data['code'] = $q[1]; |
1849 | 1849 | $ifrvfr = $q[2]; |
@@ -1859,30 +1859,30 @@ discard block |
||
1859 | 1859 | $data['lower_limit'] = $q[5]; |
1860 | 1860 | $data['upper_limit'] = $q[6]; |
1861 | 1861 | $latlonrad = $q[7]; |
1862 | - sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius); |
|
1863 | - $latitude = $Common->convertDec($las,'latitude'); |
|
1864 | - $longitude = $Common->convertDec($lns,'longitude'); |
|
1862 | + sscanf($latlonrad, '%4c%c%5c%c%3d', $las, $lac, $lns, $lnc, $radius); |
|
1863 | + $latitude = $Common->convertDec($las, 'latitude'); |
|
1864 | + $longitude = $Common->convertDec($lns, 'longitude'); |
|
1865 | 1865 | if ($lac == 'S') $latitude = '-'.$latitude; |
1866 | 1866 | if ($lnc == 'W') $longitude = '-'.$longitude; |
1867 | 1867 | $data['center_latitude'] = $latitude; |
1868 | 1868 | $data['center_longitude'] = $longitude; |
1869 | 1869 | $data['radius'] = intval($radius); |
1870 | 1870 | |
1871 | - preg_match(':<pre>(.*?)</pre>:',$description,$match); |
|
1871 | + preg_match(':<pre>(.*?)</pre>:', $description, $match); |
|
1872 | 1872 | $data['text'] = $match[1]; |
1873 | - preg_match(':</pre>(.*?)$:',$description,$match); |
|
1873 | + preg_match(':</pre>(.*?)$:', $description, $match); |
|
1874 | 1874 | $fromto = $match[1]; |
1875 | - preg_match('#FROM:(.*?)TO:#',$fromto,$match); |
|
1875 | + preg_match('#FROM:(.*?)TO:#', $fromto, $match); |
|
1876 | 1876 | $fromall = trim($match[1]); |
1877 | - preg_match('#^(.*?) \((.*?)\)$#',$fromall,$match); |
|
1877 | + preg_match('#^(.*?) \((.*?)\)$#', $fromall, $match); |
|
1878 | 1878 | $from = trim($match[1]); |
1879 | - $data['date_begin'] = date("Y-m-d H:i:s",strtotime($from)); |
|
1880 | - preg_match('#TO:(.*?)$#',$fromto,$match); |
|
1879 | + $data['date_begin'] = date("Y-m-d H:i:s", strtotime($from)); |
|
1880 | + preg_match('#TO:(.*?)$#', $fromto, $match); |
|
1881 | 1881 | $toall = trim($match[1]); |
1882 | - if (!preg_match(':Permanent:',$toall)) { |
|
1883 | - preg_match('#^(.*?) \((.*?)\)#',$toall,$match); |
|
1882 | + if (!preg_match(':Permanent:', $toall)) { |
|
1883 | + preg_match('#^(.*?) \((.*?)\)#', $toall, $match); |
|
1884 | 1884 | $to = trim($match[1]); |
1885 | - $data['date_end'] = date("Y-m-d H:i:s",strtotime($to)); |
|
1885 | + $data['date_end'] = date("Y-m-d H:i:s", strtotime($to)); |
|
1886 | 1886 | $data['permanent'] = 0; |
1887 | 1887 | } else { |
1888 | 1888 | $data['date_end'] = NULL; |
@@ -1890,7 +1890,7 @@ discard block |
||
1890 | 1890 | } |
1891 | 1891 | $data['full_notam'] = $notam['title'].'<br>'.$notam['description']; |
1892 | 1892 | $NOTAM = new NOTAM(); |
1893 | - $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']); |
|
1893 | + $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']); |
|
1894 | 1894 | unset($data); |
1895 | 1895 | } |
1896 | 1896 | } else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
@@ -1913,16 +1913,16 @@ discard block |
||
1913 | 1913 | $Connection = new Connection(); |
1914 | 1914 | $sth = $Connection->db->prepare($query); |
1915 | 1915 | $sth->execute(); |
1916 | - } catch(PDOException $e) { |
|
1916 | + } catch (PDOException $e) { |
|
1917 | 1917 | return "error : ".$e->getMessage(); |
1918 | 1918 | } |
1919 | 1919 | } |
1920 | 1920 | $Common = new Common(); |
1921 | 1921 | $airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json'); |
1922 | - $airspace_json = json_decode($airspace_lst,true); |
|
1922 | + $airspace_json = json_decode($airspace_lst, true); |
|
1923 | 1923 | foreach ($airspace_json['records'] as $airspace) { |
1924 | 1924 | if ($globalDebug) echo $airspace['name']."...\n"; |
1925 | - update_db::download($airspace['uri'],$tmp_dir.$airspace['name']); |
|
1925 | + update_db::download($airspace['uri'], $tmp_dir.$airspace['name']); |
|
1926 | 1926 | if (file_exists($tmp_dir.$airspace['name'])) { |
1927 | 1927 | file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name']))); |
1928 | 1928 | //system('recode l9..utf8 '.$tmp_dir.$airspace['name']); |
@@ -1946,7 +1946,7 @@ discard block |
||
1946 | 1946 | $Connection = new Connection(); |
1947 | 1947 | $sth = $Connection->db->prepare($query); |
1948 | 1948 | $sth->execute(); |
1949 | - } catch(PDOException $e) { |
|
1949 | + } catch (PDOException $e) { |
|
1950 | 1950 | return "error : ".$e->getMessage(); |
1951 | 1951 | } |
1952 | 1952 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -1961,7 +1961,7 @@ discard block |
||
1961 | 1961 | $Connection = new Connection(); |
1962 | 1962 | $sth = $Connection->db->prepare($query); |
1963 | 1963 | $sth->execute(); |
1964 | - } catch(PDOException $e) { |
|
1964 | + } catch (PDOException $e) { |
|
1965 | 1965 | return "error : ".$e->getMessage(); |
1966 | 1966 | } |
1967 | 1967 | } |
@@ -1972,7 +1972,7 @@ discard block |
||
1972 | 1972 | $Connection = new Connection(); |
1973 | 1973 | $sth = $Connection->db->prepare($query); |
1974 | 1974 | $sth->execute(array(':version' => $version)); |
1975 | - } catch(PDOException $e) { |
|
1975 | + } catch (PDOException $e) { |
|
1976 | 1976 | return "error : ".$e->getMessage(); |
1977 | 1977 | } |
1978 | 1978 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -1988,7 +1988,7 @@ discard block |
||
1988 | 1988 | $Connection = new Connection(); |
1989 | 1989 | $sth = $Connection->db->prepare($query); |
1990 | 1990 | $sth->execute(array(':version' => $version)); |
1991 | - } catch(PDOException $e) { |
|
1991 | + } catch (PDOException $e) { |
|
1992 | 1992 | return "error : ".$e->getMessage(); |
1993 | 1993 | } |
1994 | 1994 | } |
@@ -2004,7 +2004,7 @@ discard block |
||
2004 | 2004 | $Connection = new Connection(); |
2005 | 2005 | $sth = $Connection->db->prepare($query); |
2006 | 2006 | $sth->execute(); |
2007 | - } catch(PDOException $e) { |
|
2007 | + } catch (PDOException $e) { |
|
2008 | 2008 | return "error : ".$e->getMessage(); |
2009 | 2009 | } |
2010 | 2010 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2019,7 +2019,7 @@ discard block |
||
2019 | 2019 | $Connection = new Connection(); |
2020 | 2020 | $sth = $Connection->db->prepare($query); |
2021 | 2021 | $sth->execute(); |
2022 | - } catch(PDOException $e) { |
|
2022 | + } catch (PDOException $e) { |
|
2023 | 2023 | return "error : ".$e->getMessage(); |
2024 | 2024 | } |
2025 | 2025 | } |
@@ -2034,7 +2034,7 @@ discard block |
||
2034 | 2034 | $Connection = new Connection(); |
2035 | 2035 | $sth = $Connection->db->prepare($query); |
2036 | 2036 | $sth->execute(); |
2037 | - } catch(PDOException $e) { |
|
2037 | + } catch (PDOException $e) { |
|
2038 | 2038 | return "error : ".$e->getMessage(); |
2039 | 2039 | } |
2040 | 2040 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2049,7 +2049,7 @@ discard block |
||
2049 | 2049 | $Connection = new Connection(); |
2050 | 2050 | $sth = $Connection->db->prepare($query); |
2051 | 2051 | $sth->execute(); |
2052 | - } catch(PDOException $e) { |
|
2052 | + } catch (PDOException $e) { |
|
2053 | 2053 | return "error : ".$e->getMessage(); |
2054 | 2054 | } |
2055 | 2055 | } |
@@ -2065,7 +2065,7 @@ discard block |
||
2065 | 2065 | $Connection = new Connection(); |
2066 | 2066 | $sth = $Connection->db->prepare($query); |
2067 | 2067 | $sth->execute(); |
2068 | - } catch(PDOException $e) { |
|
2068 | + } catch (PDOException $e) { |
|
2069 | 2069 | return "error : ".$e->getMessage(); |
2070 | 2070 | } |
2071 | 2071 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2080,7 +2080,7 @@ discard block |
||
2080 | 2080 | $Connection = new Connection(); |
2081 | 2081 | $sth = $Connection->db->prepare($query); |
2082 | 2082 | $sth->execute(); |
2083 | - } catch(PDOException $e) { |
|
2083 | + } catch (PDOException $e) { |
|
2084 | 2084 | return "error : ".$e->getMessage(); |
2085 | 2085 | } |
2086 | 2086 | } |
@@ -2095,7 +2095,7 @@ discard block |
||
2095 | 2095 | $Connection = new Connection(); |
2096 | 2096 | $sth = $Connection->db->prepare($query); |
2097 | 2097 | $sth->execute(); |
2098 | - } catch(PDOException $e) { |
|
2098 | + } catch (PDOException $e) { |
|
2099 | 2099 | return "error : ".$e->getMessage(); |
2100 | 2100 | } |
2101 | 2101 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2110,7 +2110,7 @@ discard block |
||
2110 | 2110 | $Connection = new Connection(); |
2111 | 2111 | $sth = $Connection->db->prepare($query); |
2112 | 2112 | $sth->execute(); |
2113 | - } catch(PDOException $e) { |
|
2113 | + } catch (PDOException $e) { |
|
2114 | 2114 | return "error : ".$e->getMessage(); |
2115 | 2115 | } |
2116 | 2116 | } |
@@ -2125,7 +2125,7 @@ discard block |
||
2125 | 2125 | $Connection = new Connection(); |
2126 | 2126 | $sth = $Connection->db->prepare($query); |
2127 | 2127 | $sth->execute(); |
2128 | - } catch(PDOException $e) { |
|
2128 | + } catch (PDOException $e) { |
|
2129 | 2129 | return "error : ".$e->getMessage(); |
2130 | 2130 | } |
2131 | 2131 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2140,7 +2140,7 @@ discard block |
||
2140 | 2140 | $Connection = new Connection(); |
2141 | 2141 | $sth = $Connection->db->prepare($query); |
2142 | 2142 | $sth->execute(); |
2143 | - } catch(PDOException $e) { |
|
2143 | + } catch (PDOException $e) { |
|
2144 | 2144 | return "error : ".$e->getMessage(); |
2145 | 2145 | } |
2146 | 2146 | } |
@@ -16,7 +16,9 @@ discard block |
||
16 | 16 | curl_setopt($ch, CURLOPT_URL, $url); |
17 | 17 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
18 | 18 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
19 | - if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
19 | + if ($referer != '') { |
|
20 | + curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
21 | + } |
|
20 | 22 | curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5'); |
21 | 23 | curl_setopt($ch, CURLOPT_FILE, $fp); |
22 | 24 | curl_exec($ch); |
@@ -27,12 +29,16 @@ discard block |
||
27 | 29 | public static function gunzip($in_file,$out_file_name = '') { |
28 | 30 | //echo $in_file.' -> '.$out_file_name."\n"; |
29 | 31 | $buffer_size = 4096; // read 4kb at a time |
30 | - if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); |
|
32 | + if ($out_file_name == '') { |
|
33 | + $out_file_name = str_replace('.gz', '', $in_file); |
|
34 | + } |
|
31 | 35 | if ($in_file != '' && file_exists($in_file)) { |
32 | 36 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
33 | - if (function_exists('gzopen')) $file = gzopen($in_file,'rb'); |
|
34 | - elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb'); |
|
35 | - else { |
|
37 | + if (function_exists('gzopen')) { |
|
38 | + $file = gzopen($in_file,'rb'); |
|
39 | + } elseif (function_exists('gzopen64')) { |
|
40 | + $file = gzopen64($in_file,'rb'); |
|
41 | + } else { |
|
36 | 42 | echo 'gzopen not available'; |
37 | 43 | die; |
38 | 44 | } |
@@ -53,8 +59,12 @@ discard block |
||
53 | 59 | if ($res === TRUE) { |
54 | 60 | $zip->extractTo($path); |
55 | 61 | $zip->close(); |
56 | - } else return false; |
|
57 | - } else return false; |
|
62 | + } else { |
|
63 | + return false; |
|
64 | + } |
|
65 | + } else { |
|
66 | + return false; |
|
67 | + } |
|
58 | 68 | } |
59 | 69 | |
60 | 70 | public static function connect_sqlite($database) { |
@@ -69,7 +79,9 @@ discard block |
||
69 | 79 | public static function retrieve_route_sqlite_to_dest($database_file) { |
70 | 80 | global $globalDebug, $globalTransaction; |
71 | 81 | //$query = 'TRUNCATE TABLE routes'; |
72 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
82 | + if ($globalDebug) { |
|
83 | + echo " - Delete previous routes from DB -"; |
|
84 | + } |
|
73 | 85 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
74 | 86 | $Connection = new Connection(); |
75 | 87 | try { |
@@ -80,7 +92,9 @@ discard block |
||
80 | 92 | return "error : ".$e->getMessage(); |
81 | 93 | } |
82 | 94 | |
83 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
95 | + if ($globalDebug) { |
|
96 | + echo " - Add routes to DB -"; |
|
97 | + } |
|
84 | 98 | update_db::connect_sqlite($database_file); |
85 | 99 | //$query = 'select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID'; |
86 | 100 | $query = "select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao, rstp.allstop AS AllStop from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID LEFT JOIN (select RouteId,GROUP_CONCAT(icao,' ') as allstop from routestop left join Airport as air ON routestop.AirportId = air.AirportID group by RouteID) AS rstp ON Route.RouteID = rstp.RouteID"; |
@@ -95,15 +109,21 @@ discard block |
||
95 | 109 | $Connection = new Connection(); |
96 | 110 | $sth_dest = $Connection->db->prepare($query_dest); |
97 | 111 | try { |
98 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
112 | + if ($globalTransaction) { |
|
113 | + $Connection->db->beginTransaction(); |
|
114 | + } |
|
99 | 115 | while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
100 | 116 | //$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
101 | 117 | $query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
102 | 118 | $sth_dest->execute($query_dest_values); |
103 | 119 | } |
104 | - if ($globalTransaction) $Connection->db->commit(); |
|
120 | + if ($globalTransaction) { |
|
121 | + $Connection->db->commit(); |
|
122 | + } |
|
105 | 123 | } catch(PDOException $e) { |
106 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
124 | + if ($globalTransaction) { |
|
125 | + $Connection->db->rollBack(); |
|
126 | + } |
|
107 | 127 | return "error : ".$e->getMessage(); |
108 | 128 | } |
109 | 129 | return ''; |
@@ -111,7 +131,9 @@ discard block |
||
111 | 131 | public static function retrieve_route_oneworld($database_file) { |
112 | 132 | global $globalDebug, $globalTransaction; |
113 | 133 | //$query = 'TRUNCATE TABLE routes'; |
114 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
134 | + if ($globalDebug) { |
|
135 | + echo " - Delete previous routes from DB -"; |
|
136 | + } |
|
115 | 137 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
116 | 138 | $Connection = new Connection(); |
117 | 139 | try { |
@@ -122,14 +144,18 @@ discard block |
||
122 | 144 | return "error : ".$e->getMessage(); |
123 | 145 | } |
124 | 146 | |
125 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
147 | + if ($globalDebug) { |
|
148 | + echo " - Add routes to DB -"; |
|
149 | + } |
|
126 | 150 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
127 | 151 | $Spotter = new Spotter(); |
128 | 152 | if ($fh = fopen($database_file,"r")) { |
129 | 153 | $query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)'; |
130 | 154 | $Connection = new Connection(); |
131 | 155 | $sth_dest = $Connection->db->prepare($query_dest); |
132 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
156 | + if ($globalTransaction) { |
|
157 | + $Connection->db->beginTransaction(); |
|
158 | + } |
|
133 | 159 | while (!feof($fh)) { |
134 | 160 | $line = fgetcsv($fh,9999,','); |
135 | 161 | if ($line[0] != '') { |
@@ -138,13 +164,17 @@ discard block |
||
138 | 164 | $query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld'); |
139 | 165 | $sth_dest->execute($query_dest_values); |
140 | 166 | } catch(PDOException $e) { |
141 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
167 | + if ($globalTransaction) { |
|
168 | + $Connection->db->rollBack(); |
|
169 | + } |
|
142 | 170 | return "error : ".$e->getMessage(); |
143 | 171 | } |
144 | 172 | } |
145 | 173 | } |
146 | 174 | } |
147 | - if ($globalTransaction) $Connection->db->commit(); |
|
175 | + if ($globalTransaction) { |
|
176 | + $Connection->db->commit(); |
|
177 | + } |
|
148 | 178 | } |
149 | 179 | return ''; |
150 | 180 | } |
@@ -152,7 +182,9 @@ discard block |
||
152 | 182 | public static function retrieve_route_skyteam($database_file) { |
153 | 183 | global $globalDebug, $globalTransaction; |
154 | 184 | //$query = 'TRUNCATE TABLE routes'; |
155 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
185 | + if ($globalDebug) { |
|
186 | + echo " - Delete previous routes from DB -"; |
|
187 | + } |
|
156 | 188 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
157 | 189 | $Connection = new Connection(); |
158 | 190 | try { |
@@ -163,7 +195,9 @@ discard block |
||
163 | 195 | return "error : ".$e->getMessage(); |
164 | 196 | } |
165 | 197 | |
166 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
198 | + if ($globalDebug) { |
|
199 | + echo " - Add routes to DB -"; |
|
200 | + } |
|
167 | 201 | |
168 | 202 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
169 | 203 | $Spotter = new Spotter(); |
@@ -172,7 +206,9 @@ discard block |
||
172 | 206 | $Connection = new Connection(); |
173 | 207 | $sth_dest = $Connection->db->prepare($query_dest); |
174 | 208 | try { |
175 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
209 | + if ($globalTransaction) { |
|
210 | + $Connection->db->beginTransaction(); |
|
211 | + } |
|
176 | 212 | while (!feof($fh)) { |
177 | 213 | $line = fgetcsv($fh,9999,','); |
178 | 214 | if ($line[0] != '') { |
@@ -183,9 +219,13 @@ discard block |
||
183 | 219 | } |
184 | 220 | } |
185 | 221 | } |
186 | - if ($globalTransaction) $Connection->db->commit(); |
|
222 | + if ($globalTransaction) { |
|
223 | + $Connection->db->commit(); |
|
224 | + } |
|
187 | 225 | } catch(PDOException $e) { |
188 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
226 | + if ($globalTransaction) { |
|
227 | + $Connection->db->rollBack(); |
|
228 | + } |
|
189 | 229 | return "error : ".$e->getMessage(); |
190 | 230 | } |
191 | 231 | } |
@@ -228,11 +268,16 @@ discard block |
||
228 | 268 | $sth_dest = $Connection->db->prepare($query_dest); |
229 | 269 | $sth_dest_owner = $Connection->db->prepare($query_dest_owner); |
230 | 270 | try { |
231 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
271 | + if ($globalTransaction) { |
|
272 | + $Connection->db->beginTransaction(); |
|
273 | + } |
|
232 | 274 | while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
233 | 275 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
234 | - if ($values['UserString4'] == 'M') $type = 'military'; |
|
235 | - else $type = null; |
|
276 | + if ($values['UserString4'] == 'M') { |
|
277 | + $type = 'military'; |
|
278 | + } else { |
|
279 | + $type = null; |
|
280 | + } |
|
236 | 281 | $query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type); |
237 | 282 | $sth_dest->execute($query_dest_values); |
238 | 283 | if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') { |
@@ -240,7 +285,9 @@ discard block |
||
240 | 285 | $sth_dest_owner->execute($query_dest_owner_values); |
241 | 286 | } |
242 | 287 | } |
243 | - if ($globalTransaction) $Connection->db->commit(); |
|
288 | + if ($globalTransaction) { |
|
289 | + $Connection->db->commit(); |
|
290 | + } |
|
244 | 291 | } catch(PDOException $e) { |
245 | 292 | return "error : ".$e->getMessage(); |
246 | 293 | } |
@@ -276,7 +323,9 @@ discard block |
||
276 | 323 | $Connection = new Connection(); |
277 | 324 | $sth_dest = $Connection->db->prepare($query_dest); |
278 | 325 | try { |
279 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
326 | + if ($globalTransaction) { |
|
327 | + $Connection->db->beginTransaction(); |
|
328 | + } |
|
280 | 329 | while (!feof($fh)) { |
281 | 330 | $values = array(); |
282 | 331 | $line = $Common->hex2str(fgets($fh,9999)); |
@@ -287,7 +336,9 @@ discard block |
||
287 | 336 | // Check if we can find ICAO, else set it to GLID |
288 | 337 | $aircraft_name_split = explode(' ',$aircraft_name); |
289 | 338 | $search_more = ''; |
290 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
339 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) { |
|
340 | + $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
341 | + } |
|
291 | 342 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
292 | 343 | $sth_search = $Connection->db->prepare($query_search); |
293 | 344 | try { |
@@ -300,7 +351,9 @@ discard block |
||
300 | 351 | } catch(PDOException $e) { |
301 | 352 | return "error : ".$e->getMessage(); |
302 | 353 | } |
303 | - if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID'; |
|
354 | + if (!isset($values['ICAOTypeCode'])) { |
|
355 | + $values['ICAOTypeCode'] = 'GLID'; |
|
356 | + } |
|
304 | 357 | // Add data to db |
305 | 358 | if ($values['ModeS'] != '' && $values['Registration'] != '' && $values['Registration'] != '0000') { |
306 | 359 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
@@ -309,7 +362,9 @@ discard block |
||
309 | 362 | $sth_dest->execute($query_dest_values); |
310 | 363 | } |
311 | 364 | } |
312 | - if ($globalTransaction) $Connection->db->commit(); |
|
365 | + if ($globalTransaction) { |
|
366 | + $Connection->db->commit(); |
|
367 | + } |
|
313 | 368 | } catch(PDOException $e) { |
314 | 369 | return "error : ".$e->getMessage(); |
315 | 370 | } |
@@ -345,7 +400,9 @@ discard block |
||
345 | 400 | $Connection = new Connection(); |
346 | 401 | $sth_dest = $Connection->db->prepare($query_dest); |
347 | 402 | try { |
348 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
403 | + if ($globalTransaction) { |
|
404 | + $Connection->db->beginTransaction(); |
|
405 | + } |
|
349 | 406 | $tmp = fgetcsv($fh,9999,',',"'"); |
350 | 407 | while (!feof($fh)) { |
351 | 408 | $line = fgetcsv($fh,9999,',',"'"); |
@@ -358,13 +415,17 @@ discard block |
||
358 | 415 | // Check if we can find ICAO, else set it to GLID |
359 | 416 | $aircraft_name_split = explode(' ',$aircraft_name); |
360 | 417 | $search_more = ''; |
361 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
418 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) { |
|
419 | + $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
420 | + } |
|
362 | 421 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
363 | 422 | $sth_search = $Connection->db->prepare($query_search); |
364 | 423 | try { |
365 | 424 | $sth_search->execute(); |
366 | 425 | $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
367 | - if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
|
426 | + if (isset($result['icao']) && $result['icao'] != '') { |
|
427 | + $values['ICAOTypeCode'] = $result['icao']; |
|
428 | + } |
|
368 | 429 | } catch(PDOException $e) { |
369 | 430 | return "error : ".$e->getMessage(); |
370 | 431 | } |
@@ -377,7 +438,9 @@ discard block |
||
377 | 438 | $sth_dest->execute($query_dest_values); |
378 | 439 | } |
379 | 440 | } |
380 | - if ($globalTransaction) $Connection->db->commit(); |
|
441 | + if ($globalTransaction) { |
|
442 | + $Connection->db->commit(); |
|
443 | + } |
|
381 | 444 | } catch(PDOException $e) { |
382 | 445 | return "error : ".$e->getMessage(); |
383 | 446 | } |
@@ -413,7 +476,9 @@ discard block |
||
413 | 476 | $Connection = new Connection(); |
414 | 477 | $sth_dest = $Connection->db->prepare($query_dest); |
415 | 478 | try { |
416 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
479 | + if ($globalTransaction) { |
|
480 | + $Connection->db->beginTransaction(); |
|
481 | + } |
|
417 | 482 | $tmp = fgetcsv($fh,9999,',','"'); |
418 | 483 | while (!feof($fh)) { |
419 | 484 | $line = fgetcsv($fh,9999,',','"'); |
@@ -423,16 +488,22 @@ discard block |
||
423 | 488 | $values['registration'] = $line[0]; |
424 | 489 | $values['base'] = $line[4]; |
425 | 490 | $values['owner'] = $line[5]; |
426 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
427 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
491 | + if ($line[6] == '') { |
|
492 | + $values['date_first_reg'] = null; |
|
493 | + } else { |
|
494 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
495 | + } |
|
428 | 496 | $values['cancel'] = $line[7]; |
429 | 497 | } elseif ($country == 'EI') { |
430 | 498 | // TODO : add modeS & reg to aircraft_modes |
431 | 499 | $values['registration'] = $line[0]; |
432 | 500 | $values['base'] = $line[3]; |
433 | 501 | $values['owner'] = $line[2]; |
434 | - if ($line[1] == '') $values['date_first_reg'] = null; |
|
435 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
502 | + if ($line[1] == '') { |
|
503 | + $values['date_first_reg'] = null; |
|
504 | + } else { |
|
505 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
506 | + } |
|
436 | 507 | $values['cancel'] = ''; |
437 | 508 | } elseif ($country == 'HB') { |
438 | 509 | // TODO : add modeS & reg to aircraft_modes |
@@ -446,16 +517,22 @@ discard block |
||
446 | 517 | $values['registration'] = $line[3]; |
447 | 518 | $values['base'] = null; |
448 | 519 | $values['owner'] = $line[5]; |
449 | - if ($line[18] == '') $values['date_first_reg'] = null; |
|
450 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
520 | + if ($line[18] == '') { |
|
521 | + $values['date_first_reg'] = null; |
|
522 | + } else { |
|
523 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
524 | + } |
|
451 | 525 | $values['cancel'] = ''; |
452 | 526 | } elseif ($country == 'VH') { |
453 | 527 | // TODO : add modeS & reg to aircraft_modes |
454 | 528 | $values['registration'] = $line[0]; |
455 | 529 | $values['base'] = null; |
456 | 530 | $values['owner'] = $line[12]; |
457 | - if ($line[28] == '') $values['date_first_reg'] = null; |
|
458 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
531 | + if ($line[28] == '') { |
|
532 | + $values['date_first_reg'] = null; |
|
533 | + } else { |
|
534 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
535 | + } |
|
459 | 536 | |
460 | 537 | $values['cancel'] = $line[39]; |
461 | 538 | } elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { |
@@ -474,29 +551,41 @@ discard block |
||
474 | 551 | $values['registration'] = $line[0]; |
475 | 552 | $values['base'] = null; |
476 | 553 | $values['owner'] = $line[8]; |
477 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
478 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
554 | + if ($line[7] == '') { |
|
555 | + $values['date_first_reg'] = null; |
|
556 | + } else { |
|
557 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
558 | + } |
|
479 | 559 | $values['cancel'] = ''; |
480 | 560 | } elseif ($country == 'PP') { |
481 | 561 | $values['registration'] = $line[0]; |
482 | 562 | $values['base'] = null; |
483 | 563 | $values['owner'] = $line[4]; |
484 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
485 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
564 | + if ($line[6] == '') { |
|
565 | + $values['date_first_reg'] = null; |
|
566 | + } else { |
|
567 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
568 | + } |
|
486 | 569 | $values['cancel'] = $line[7]; |
487 | 570 | } elseif ($country == 'E7') { |
488 | 571 | $values['registration'] = $line[0]; |
489 | 572 | $values['base'] = null; |
490 | 573 | $values['owner'] = $line[4]; |
491 | - if ($line[5] == '') $values['date_first_reg'] = null; |
|
492 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
574 | + if ($line[5] == '') { |
|
575 | + $values['date_first_reg'] = null; |
|
576 | + } else { |
|
577 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
578 | + } |
|
493 | 579 | $values['cancel'] = ''; |
494 | 580 | } elseif ($country == '8Q') { |
495 | 581 | $values['registration'] = $line[0]; |
496 | 582 | $values['base'] = null; |
497 | 583 | $values['owner'] = $line[3]; |
498 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
499 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
584 | + if ($line[7] == '') { |
|
585 | + $values['date_first_reg'] = null; |
|
586 | + } else { |
|
587 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
588 | + } |
|
500 | 589 | $values['cancel'] = ''; |
501 | 590 | } elseif ($country == 'ZK' || $country == 'OM' || $country == 'TF') { |
502 | 591 | $values['registration'] = $line[0]; |
@@ -510,7 +599,9 @@ discard block |
||
510 | 599 | $sth_dest->execute($query_dest_values); |
511 | 600 | } |
512 | 601 | } |
513 | - if ($globalTransaction) $Connection->db->commit(); |
|
602 | + if ($globalTransaction) { |
|
603 | + $Connection->db->commit(); |
|
604 | + } |
|
514 | 605 | } catch(PDOException $e) { |
515 | 606 | return "error : ".$e->getMessage(); |
516 | 607 | } |
@@ -644,25 +735,45 @@ discard block |
||
644 | 735 | VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)"; |
645 | 736 | $Connection = new Connection(); |
646 | 737 | $sth_dest = $Connection->db->prepare($query_dest); |
647 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
738 | + if ($globalTransaction) { |
|
739 | + $Connection->db->beginTransaction(); |
|
740 | + } |
|
648 | 741 | |
649 | 742 | $i = 0; |
650 | 743 | while($row = sparql_fetch_array($result)) |
651 | 744 | { |
652 | 745 | if ($i >= 1) { |
653 | 746 | //print_r($row); |
654 | - if (!isset($row['iata'])) $row['iata'] = ''; |
|
655 | - if (!isset($row['icao'])) $row['icao'] = ''; |
|
656 | - if (!isset($row['type'])) $row['type'] = ''; |
|
657 | - if (!isset($row['altitude'])) $row['altitude'] = ''; |
|
747 | + if (!isset($row['iata'])) { |
|
748 | + $row['iata'] = ''; |
|
749 | + } |
|
750 | + if (!isset($row['icao'])) { |
|
751 | + $row['icao'] = ''; |
|
752 | + } |
|
753 | + if (!isset($row['type'])) { |
|
754 | + $row['type'] = ''; |
|
755 | + } |
|
756 | + if (!isset($row['altitude'])) { |
|
757 | + $row['altitude'] = ''; |
|
758 | + } |
|
658 | 759 | if (isset($row['city_bis'])) { |
659 | 760 | $row['city'] = $row['city_bis']; |
660 | 761 | } |
661 | - if (!isset($row['city'])) $row['city'] = ''; |
|
662 | - if (!isset($row['country'])) $row['country'] = ''; |
|
663 | - if (!isset($row['homepage'])) $row['homepage'] = ''; |
|
664 | - if (!isset($row['wikipedia_page'])) $row['wikipedia_page'] = ''; |
|
665 | - if (!isset($row['name'])) continue; |
|
762 | + if (!isset($row['city'])) { |
|
763 | + $row['city'] = ''; |
|
764 | + } |
|
765 | + if (!isset($row['country'])) { |
|
766 | + $row['country'] = ''; |
|
767 | + } |
|
768 | + if (!isset($row['homepage'])) { |
|
769 | + $row['homepage'] = ''; |
|
770 | + } |
|
771 | + if (!isset($row['wikipedia_page'])) { |
|
772 | + $row['wikipedia_page'] = ''; |
|
773 | + } |
|
774 | + if (!isset($row['name'])) { |
|
775 | + continue; |
|
776 | + } |
|
666 | 777 | if (!isset($row['image'])) { |
667 | 778 | $row['image'] = ''; |
668 | 779 | $row['image_thumb'] = ''; |
@@ -698,7 +809,9 @@ discard block |
||
698 | 809 | |
699 | 810 | $i++; |
700 | 811 | } |
701 | - if ($globalTransaction) $Connection->db->commit(); |
|
812 | + if ($globalTransaction) { |
|
813 | + $Connection->db->commit(); |
|
814 | + } |
|
702 | 815 | echo "Delete duplicate rows...\n"; |
703 | 816 | $query = 'ALTER IGNORE TABLE airport ADD UNIQUE INDEX icaoidx (icao)'; |
704 | 817 | try { |
@@ -710,7 +823,9 @@ discard block |
||
710 | 823 | } |
711 | 824 | |
712 | 825 | |
713 | - if ($globalDebug) echo "Insert Not available Airport...\n"; |
|
826 | + if ($globalDebug) { |
|
827 | + echo "Insert Not available Airport...\n"; |
|
828 | + } |
|
714 | 829 | $query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image`,`image_thumb`) |
715 | 830 | VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image, :image_thumb)"; |
716 | 831 | $query_values = array(':airport_id' => $i, ':name' => 'Not available',':iata' => 'NA',':icao' => 'NA',':latitude' => '0',':longitude' => '0',':altitude' => '0',':type' => 'NA',':city' => 'N/A',':country' => 'N/A',':home_link' => '',':wikipedia_link' => '',':image' => '',':image_thumb' => ''); |
@@ -737,7 +852,9 @@ discard block |
||
737 | 852 | $delimiter = ','; |
738 | 853 | $out_file = $tmp_dir.'airports.csv'; |
739 | 854 | update_db::download('http://ourairports.com/data/airports.csv',$out_file); |
740 | - if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
|
855 | + if (!file_exists($out_file) || !is_readable($out_file)) { |
|
856 | + return FALSE; |
|
857 | + } |
|
741 | 858 | echo "Add data from ourairports.com...\n"; |
742 | 859 | |
743 | 860 | $header = NULL; |
@@ -747,8 +864,9 @@ discard block |
||
747 | 864 | //$Connection->db->beginTransaction(); |
748 | 865 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
749 | 866 | { |
750 | - if(!$header) $header = $row; |
|
751 | - else { |
|
867 | + if(!$header) { |
|
868 | + $header = $row; |
|
869 | + } else { |
|
752 | 870 | $data = array(); |
753 | 871 | $data = array_combine($header, $row); |
754 | 872 | try { |
@@ -786,7 +904,9 @@ discard block |
||
786 | 904 | echo "Download data from another free database...\n"; |
787 | 905 | $out_file = $tmp_dir.'GlobalAirportDatabase.zip'; |
788 | 906 | update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file); |
789 | - if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
|
907 | + if (!file_exists($out_file) || !is_readable($out_file)) { |
|
908 | + return FALSE; |
|
909 | + } |
|
790 | 910 | update_db::unzip($out_file); |
791 | 911 | $header = NULL; |
792 | 912 | echo "Add data from another free database...\n"; |
@@ -797,8 +917,9 @@ discard block |
||
797 | 917 | //$Connection->db->beginTransaction(); |
798 | 918 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
799 | 919 | { |
800 | - if(!$header) $header = $row; |
|
801 | - else { |
|
920 | + if(!$header) { |
|
921 | + $header = $row; |
|
922 | + } else { |
|
802 | 923 | $data = $row; |
803 | 924 | |
804 | 925 | $query = 'UPDATE airport SET `city` = :city, `country` = :country WHERE icao = :icao'; |
@@ -967,7 +1088,9 @@ discard block |
||
967 | 1088 | $i = 0; |
968 | 1089 | //$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE); |
969 | 1090 | //$Connection->db->beginTransaction(); |
970 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1091 | + if ($globalTransaction) { |
|
1092 | + $Connection->db->beginTransaction(); |
|
1093 | + } |
|
971 | 1094 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
972 | 1095 | { |
973 | 1096 | if ($i > 0) { |
@@ -982,7 +1105,9 @@ discard block |
||
982 | 1105 | $i++; |
983 | 1106 | } |
984 | 1107 | fclose($handle); |
985 | - if ($globalTransaction) $Connection->db->commit(); |
|
1108 | + if ($globalTransaction) { |
|
1109 | + $Connection->db->commit(); |
|
1110 | + } |
|
986 | 1111 | } |
987 | 1112 | return ''; |
988 | 1113 | } |
@@ -1133,7 +1258,9 @@ discard block |
||
1133 | 1258 | if (($handle = fopen($filename, 'r')) !== FALSE) |
1134 | 1259 | { |
1135 | 1260 | $i = 0; |
1136 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1261 | + if ($globalTransaction) { |
|
1262 | + $Connection->db->beginTransaction(); |
|
1263 | + } |
|
1137 | 1264 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1138 | 1265 | { |
1139 | 1266 | $i++; |
@@ -1161,7 +1288,9 @@ discard block |
||
1161 | 1288 | } |
1162 | 1289 | } |
1163 | 1290 | fclose($handle); |
1164 | - if ($globalTransaction) $Connection->db->commit(); |
|
1291 | + if ($globalTransaction) { |
|
1292 | + $Connection->db->commit(); |
|
1293 | + } |
|
1165 | 1294 | } |
1166 | 1295 | return ''; |
1167 | 1296 | } |
@@ -1184,7 +1313,9 @@ discard block |
||
1184 | 1313 | $Connection = new Connection(); |
1185 | 1314 | if (($handle = fopen($filename, 'r')) !== FALSE) |
1186 | 1315 | { |
1187 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1316 | + if ($globalTransaction) { |
|
1317 | + $Connection->db->beginTransaction(); |
|
1318 | + } |
|
1188 | 1319 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1189 | 1320 | { |
1190 | 1321 | if(count($row) > 1) { |
@@ -1198,7 +1329,9 @@ discard block |
||
1198 | 1329 | } |
1199 | 1330 | } |
1200 | 1331 | fclose($handle); |
1201 | - if ($globalTransaction) $Connection->db->commit(); |
|
1332 | + if ($globalTransaction) { |
|
1333 | + $Connection->db->commit(); |
|
1334 | + } |
|
1202 | 1335 | } |
1203 | 1336 | return ''; |
1204 | 1337 | } |
@@ -1218,8 +1351,9 @@ discard block |
||
1218 | 1351 | } |
1219 | 1352 | |
1220 | 1353 | |
1221 | - if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
1222 | - else { |
|
1354 | + if ($globalDBdriver == 'mysql') { |
|
1355 | + update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
1356 | + } else { |
|
1223 | 1357 | update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
1224 | 1358 | $query = "CREATE EXTENSION postgis"; |
1225 | 1359 | $Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']); |
@@ -1238,20 +1372,30 @@ discard block |
||
1238 | 1372 | global $tmp_dir, $globalDebug; |
1239 | 1373 | include_once('class.create_db.php'); |
1240 | 1374 | require_once(dirname(__FILE__).'/../require/class.NOTAM.php'); |
1241 | - if ($globalDebug) echo "NOTAM from FlightAirMap website : Download..."; |
|
1375 | + if ($globalDebug) { |
|
1376 | + echo "NOTAM from FlightAirMap website : Download..."; |
|
1377 | + } |
|
1242 | 1378 | update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz'); |
1243 | 1379 | $error = ''; |
1244 | 1380 | if (file_exists($tmp_dir.'notam.txt.gz')) { |
1245 | - if ($globalDebug) echo "Gunzip..."; |
|
1381 | + if ($globalDebug) { |
|
1382 | + echo "Gunzip..."; |
|
1383 | + } |
|
1246 | 1384 | update_db::gunzip($tmp_dir.'notam.txt.gz'); |
1247 | - if ($globalDebug) echo "Add to DB..."; |
|
1385 | + if ($globalDebug) { |
|
1386 | + echo "Add to DB..."; |
|
1387 | + } |
|
1248 | 1388 | //$error = create_db::import_file($tmp_dir.'notam.sql'); |
1249 | 1389 | $NOTAM = new NOTAM(); |
1250 | 1390 | $NOTAM->updateNOTAMfromTextFile($tmp_dir.'notam.txt'); |
1251 | - } else $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed."; |
|
1391 | + } else { |
|
1392 | + $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed."; |
|
1393 | + } |
|
1252 | 1394 | if ($error != '') { |
1253 | 1395 | return $error; |
1254 | - } elseif ($globalDebug) echo "Done\n"; |
|
1396 | + } elseif ($globalDebug) { |
|
1397 | + echo "Done\n"; |
|
1398 | + } |
|
1255 | 1399 | return ''; |
1256 | 1400 | } |
1257 | 1401 | |
@@ -1305,67 +1449,111 @@ discard block |
||
1305 | 1449 | //if ($globalDebug) echo "IVAO : Download..."; |
1306 | 1450 | //update_db::download('http://fr.mirror.ivao.aero/software/ivae_feb2013.zip',$tmp_dir.'ivae_feb2013.zip'); |
1307 | 1451 | if (file_exists($tmp_dir.'ivae_feb2013.zip')) { |
1308 | - if ($globalDebug) echo "Unzip..."; |
|
1452 | + if ($globalDebug) { |
|
1453 | + echo "Unzip..."; |
|
1454 | + } |
|
1309 | 1455 | update_db::unzip($tmp_dir.'ivae_feb2013.zip'); |
1310 | - if ($globalDebug) echo "Add to DB..."; |
|
1456 | + if ($globalDebug) { |
|
1457 | + echo "Add to DB..."; |
|
1458 | + } |
|
1311 | 1459 | update_db::ivao_airlines($tmp_dir.'data/airlines.dat'); |
1312 | - if ($globalDebug) echo "Copy airlines logos to airlines images directory..."; |
|
1460 | + if ($globalDebug) { |
|
1461 | + echo "Copy airlines logos to airlines images directory..."; |
|
1462 | + } |
|
1313 | 1463 | if (is_writable(dirname(__FILE__).'/../images/airlines')) { |
1314 | - if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
1315 | - } else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
|
1316 | - } else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
|
1464 | + if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) { |
|
1465 | + $error = "Failed to copy airlines logo."; |
|
1466 | + } |
|
1467 | + } else { |
|
1468 | + $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
|
1469 | + } |
|
1470 | + } else { |
|
1471 | + $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
|
1472 | + } |
|
1317 | 1473 | if ($error != '') { |
1318 | 1474 | return $error; |
1319 | - } elseif ($globalDebug) echo "Done\n"; |
|
1475 | + } elseif ($globalDebug) { |
|
1476 | + echo "Done\n"; |
|
1477 | + } |
|
1320 | 1478 | return ''; |
1321 | 1479 | } |
1322 | 1480 | |
1323 | 1481 | public static function update_routes() { |
1324 | 1482 | global $tmp_dir, $globalDebug; |
1325 | 1483 | $error = ''; |
1326 | - if ($globalDebug) echo "Routes : Download..."; |
|
1484 | + if ($globalDebug) { |
|
1485 | + echo "Routes : Download..."; |
|
1486 | + } |
|
1327 | 1487 | update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz'); |
1328 | 1488 | if (file_exists($tmp_dir.'StandingData.sqb.gz')) { |
1329 | - if ($globalDebug) echo "Gunzip..."; |
|
1489 | + if ($globalDebug) { |
|
1490 | + echo "Gunzip..."; |
|
1491 | + } |
|
1330 | 1492 | update_db::gunzip($tmp_dir.'StandingData.sqb.gz'); |
1331 | - if ($globalDebug) echo "Add to DB..."; |
|
1493 | + if ($globalDebug) { |
|
1494 | + echo "Add to DB..."; |
|
1495 | + } |
|
1332 | 1496 | $error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb'); |
1333 | - } else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed."; |
|
1497 | + } else { |
|
1498 | + $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed."; |
|
1499 | + } |
|
1334 | 1500 | if ($error != '') { |
1335 | 1501 | return $error; |
1336 | - } elseif ($globalDebug) echo "Done\n"; |
|
1502 | + } elseif ($globalDebug) { |
|
1503 | + echo "Done\n"; |
|
1504 | + } |
|
1337 | 1505 | return ''; |
1338 | 1506 | } |
1339 | 1507 | public static function update_oneworld() { |
1340 | 1508 | global $tmp_dir, $globalDebug; |
1341 | 1509 | $error = ''; |
1342 | - if ($globalDebug) echo "Schedules Oneworld : Download..."; |
|
1510 | + if ($globalDebug) { |
|
1511 | + echo "Schedules Oneworld : Download..."; |
|
1512 | + } |
|
1343 | 1513 | update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz'); |
1344 | 1514 | if (file_exists($tmp_dir.'oneworld.csv.gz')) { |
1345 | - if ($globalDebug) echo "Gunzip..."; |
|
1515 | + if ($globalDebug) { |
|
1516 | + echo "Gunzip..."; |
|
1517 | + } |
|
1346 | 1518 | update_db::gunzip($tmp_dir.'oneworld.csv.gz'); |
1347 | - if ($globalDebug) echo "Add to DB..."; |
|
1519 | + if ($globalDebug) { |
|
1520 | + echo "Add to DB..."; |
|
1521 | + } |
|
1348 | 1522 | $error = update_db::retrieve_route_oneworld($tmp_dir.'oneworld.csv'); |
1349 | - } else $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed."; |
|
1523 | + } else { |
|
1524 | + $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed."; |
|
1525 | + } |
|
1350 | 1526 | if ($error != '') { |
1351 | 1527 | return $error; |
1352 | - } elseif ($globalDebug) echo "Done\n"; |
|
1528 | + } elseif ($globalDebug) { |
|
1529 | + echo "Done\n"; |
|
1530 | + } |
|
1353 | 1531 | return ''; |
1354 | 1532 | } |
1355 | 1533 | public static function update_skyteam() { |
1356 | 1534 | global $tmp_dir, $globalDebug; |
1357 | 1535 | $error = ''; |
1358 | - if ($globalDebug) echo "Schedules Skyteam : Download..."; |
|
1536 | + if ($globalDebug) { |
|
1537 | + echo "Schedules Skyteam : Download..."; |
|
1538 | + } |
|
1359 | 1539 | update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz'); |
1360 | 1540 | if (file_exists($tmp_dir.'skyteam.csv.gz')) { |
1361 | - if ($globalDebug) echo "Gunzip..."; |
|
1541 | + if ($globalDebug) { |
|
1542 | + echo "Gunzip..."; |
|
1543 | + } |
|
1362 | 1544 | update_db::gunzip($tmp_dir.'skyteam.csv.gz'); |
1363 | - if ($globalDebug) echo "Add to DB..."; |
|
1545 | + if ($globalDebug) { |
|
1546 | + echo "Add to DB..."; |
|
1547 | + } |
|
1364 | 1548 | $error = update_db::retrieve_route_skyteam($tmp_dir.'skyteam.csv'); |
1365 | - } else $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed."; |
|
1549 | + } else { |
|
1550 | + $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed."; |
|
1551 | + } |
|
1366 | 1552 | if ($error != '') { |
1367 | 1553 | return $error; |
1368 | - } elseif ($globalDebug) echo "Done\n"; |
|
1554 | + } elseif ($globalDebug) { |
|
1555 | + echo "Done\n"; |
|
1556 | + } |
|
1369 | 1557 | return ''; |
1370 | 1558 | } |
1371 | 1559 | public static function update_ModeS() { |
@@ -1382,276 +1570,484 @@ discard block |
||
1382 | 1570 | exit; |
1383 | 1571 | } elseif ($globalDebug) echo "Done\n"; |
1384 | 1572 | */ |
1385 | - if ($globalDebug) echo "Modes : Download..."; |
|
1386 | -// update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
|
1573 | + if ($globalDebug) { |
|
1574 | + echo "Modes : Download..."; |
|
1575 | + } |
|
1576 | + // update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
|
1387 | 1577 | update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz'); |
1388 | 1578 | |
1389 | 1579 | // if (file_exists($tmp_dir.'basestation_latest.zip')) { |
1390 | 1580 | if (file_exists($tmp_dir.'BaseStation.sqb.gz')) { |
1391 | - if ($globalDebug) echo "Unzip..."; |
|
1392 | -// update_db::unzip($tmp_dir.'basestation_latest.zip'); |
|
1581 | + if ($globalDebug) { |
|
1582 | + echo "Unzip..."; |
|
1583 | + } |
|
1584 | + // update_db::unzip($tmp_dir.'basestation_latest.zip'); |
|
1393 | 1585 | update_db::gunzip($tmp_dir.'BaseStation.sqb.gz'); |
1394 | - if ($globalDebug) echo "Add to DB..."; |
|
1586 | + if ($globalDebug) { |
|
1587 | + echo "Add to DB..."; |
|
1588 | + } |
|
1395 | 1589 | $error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb'); |
1396 | 1590 | // $error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'basestation.sqb'); |
1397 | - } else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed."; |
|
1591 | + } else { |
|
1592 | + $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed."; |
|
1593 | + } |
|
1398 | 1594 | if ($error != '') { |
1399 | 1595 | return $error; |
1400 | - } elseif ($globalDebug) echo "Done\n"; |
|
1596 | + } elseif ($globalDebug) { |
|
1597 | + echo "Done\n"; |
|
1598 | + } |
|
1401 | 1599 | return ''; |
1402 | 1600 | } |
1403 | 1601 | |
1404 | 1602 | public static function update_ModeS_flarm() { |
1405 | 1603 | global $tmp_dir, $globalDebug; |
1406 | - if ($globalDebug) echo "Modes Flarmnet: Download..."; |
|
1604 | + if ($globalDebug) { |
|
1605 | + echo "Modes Flarmnet: Download..."; |
|
1606 | + } |
|
1407 | 1607 | update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln'); |
1408 | 1608 | if (file_exists($tmp_dir.'data.fln')) { |
1409 | - if ($globalDebug) echo "Add to DB..."; |
|
1609 | + if ($globalDebug) { |
|
1610 | + echo "Add to DB..."; |
|
1611 | + } |
|
1410 | 1612 | $error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln'); |
1411 | - } else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed."; |
|
1613 | + } else { |
|
1614 | + $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed."; |
|
1615 | + } |
|
1412 | 1616 | if ($error != '') { |
1413 | 1617 | return $error; |
1414 | - } elseif ($globalDebug) echo "Done\n"; |
|
1618 | + } elseif ($globalDebug) { |
|
1619 | + echo "Done\n"; |
|
1620 | + } |
|
1415 | 1621 | return ''; |
1416 | 1622 | } |
1417 | 1623 | |
1418 | 1624 | public static function update_ModeS_ogn() { |
1419 | 1625 | global $tmp_dir, $globalDebug; |
1420 | - if ($globalDebug) echo "Modes OGN: Download..."; |
|
1626 | + if ($globalDebug) { |
|
1627 | + echo "Modes OGN: Download..."; |
|
1628 | + } |
|
1421 | 1629 | update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv'); |
1422 | 1630 | if (file_exists($tmp_dir.'ogn.csv')) { |
1423 | - if ($globalDebug) echo "Add to DB..."; |
|
1631 | + if ($globalDebug) { |
|
1632 | + echo "Add to DB..."; |
|
1633 | + } |
|
1424 | 1634 | $error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv'); |
1425 | - } else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed."; |
|
1635 | + } else { |
|
1636 | + $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed."; |
|
1637 | + } |
|
1426 | 1638 | if ($error != '') { |
1427 | 1639 | return $error; |
1428 | - } elseif ($globalDebug) echo "Done\n"; |
|
1640 | + } elseif ($globalDebug) { |
|
1641 | + echo "Done\n"; |
|
1642 | + } |
|
1429 | 1643 | return ''; |
1430 | 1644 | } |
1431 | 1645 | |
1432 | 1646 | public static function update_owner() { |
1433 | 1647 | global $tmp_dir, $globalDebug; |
1434 | 1648 | |
1435 | - if ($globalDebug) echo "Owner France: Download..."; |
|
1649 | + if ($globalDebug) { |
|
1650 | + echo "Owner France: Download..."; |
|
1651 | + } |
|
1436 | 1652 | update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv'); |
1437 | 1653 | if (file_exists($tmp_dir.'owner_f.csv')) { |
1438 | - if ($globalDebug) echo "Add to DB..."; |
|
1654 | + if ($globalDebug) { |
|
1655 | + echo "Add to DB..."; |
|
1656 | + } |
|
1439 | 1657 | $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F'); |
1440 | - } else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
|
1658 | + } else { |
|
1659 | + $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
|
1660 | + } |
|
1441 | 1661 | if ($error != '') { |
1442 | 1662 | return $error; |
1443 | - } elseif ($globalDebug) echo "Done\n"; |
|
1663 | + } elseif ($globalDebug) { |
|
1664 | + echo "Done\n"; |
|
1665 | + } |
|
1444 | 1666 | |
1445 | - if ($globalDebug) echo "Owner Ireland: Download..."; |
|
1667 | + if ($globalDebug) { |
|
1668 | + echo "Owner Ireland: Download..."; |
|
1669 | + } |
|
1446 | 1670 | update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv'); |
1447 | 1671 | if (file_exists($tmp_dir.'owner_ei.csv')) { |
1448 | - if ($globalDebug) echo "Add to DB..."; |
|
1672 | + if ($globalDebug) { |
|
1673 | + echo "Add to DB..."; |
|
1674 | + } |
|
1449 | 1675 | $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI'); |
1450 | - } else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
|
1676 | + } else { |
|
1677 | + $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
|
1678 | + } |
|
1451 | 1679 | if ($error != '') { |
1452 | 1680 | return $error; |
1453 | - } elseif ($globalDebug) echo "Done\n"; |
|
1454 | - if ($globalDebug) echo "Owner Switzerland: Download..."; |
|
1681 | + } elseif ($globalDebug) { |
|
1682 | + echo "Done\n"; |
|
1683 | + } |
|
1684 | + if ($globalDebug) { |
|
1685 | + echo "Owner Switzerland: Download..."; |
|
1686 | + } |
|
1455 | 1687 | update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv'); |
1456 | 1688 | if (file_exists($tmp_dir.'owner_hb.csv')) { |
1457 | - if ($globalDebug) echo "Add to DB..."; |
|
1689 | + if ($globalDebug) { |
|
1690 | + echo "Add to DB..."; |
|
1691 | + } |
|
1458 | 1692 | $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB'); |
1459 | - } else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
|
1693 | + } else { |
|
1694 | + $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
|
1695 | + } |
|
1460 | 1696 | if ($error != '') { |
1461 | 1697 | return $error; |
1462 | - } elseif ($globalDebug) echo "Done\n"; |
|
1463 | - if ($globalDebug) echo "Owner Czech Republic: Download..."; |
|
1698 | + } elseif ($globalDebug) { |
|
1699 | + echo "Done\n"; |
|
1700 | + } |
|
1701 | + if ($globalDebug) { |
|
1702 | + echo "Owner Czech Republic: Download..."; |
|
1703 | + } |
|
1464 | 1704 | update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv'); |
1465 | 1705 | if (file_exists($tmp_dir.'owner_ok.csv')) { |
1466 | - if ($globalDebug) echo "Add to DB..."; |
|
1706 | + if ($globalDebug) { |
|
1707 | + echo "Add to DB..."; |
|
1708 | + } |
|
1467 | 1709 | $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK'); |
1468 | - } else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
|
1710 | + } else { |
|
1711 | + $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
|
1712 | + } |
|
1469 | 1713 | if ($error != '') { |
1470 | 1714 | return $error; |
1471 | - } elseif ($globalDebug) echo "Done\n"; |
|
1472 | - if ($globalDebug) echo "Owner Australia: Download..."; |
|
1715 | + } elseif ($globalDebug) { |
|
1716 | + echo "Done\n"; |
|
1717 | + } |
|
1718 | + if ($globalDebug) { |
|
1719 | + echo "Owner Australia: Download..."; |
|
1720 | + } |
|
1473 | 1721 | update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv'); |
1474 | 1722 | if (file_exists($tmp_dir.'owner_vh.csv')) { |
1475 | - if ($globalDebug) echo "Add to DB..."; |
|
1723 | + if ($globalDebug) { |
|
1724 | + echo "Add to DB..."; |
|
1725 | + } |
|
1476 | 1726 | $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH'); |
1477 | - } else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
|
1727 | + } else { |
|
1728 | + $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
|
1729 | + } |
|
1478 | 1730 | if ($error != '') { |
1479 | 1731 | return $error; |
1480 | - } elseif ($globalDebug) echo "Done\n"; |
|
1481 | - if ($globalDebug) echo "Owner Austria: Download..."; |
|
1732 | + } elseif ($globalDebug) { |
|
1733 | + echo "Done\n"; |
|
1734 | + } |
|
1735 | + if ($globalDebug) { |
|
1736 | + echo "Owner Austria: Download..."; |
|
1737 | + } |
|
1482 | 1738 | update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv'); |
1483 | 1739 | if (file_exists($tmp_dir.'owner_oe.csv')) { |
1484 | - if ($globalDebug) echo "Add to DB..."; |
|
1740 | + if ($globalDebug) { |
|
1741 | + echo "Add to DB..."; |
|
1742 | + } |
|
1485 | 1743 | $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE'); |
1486 | - } else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
|
1744 | + } else { |
|
1745 | + $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
|
1746 | + } |
|
1487 | 1747 | if ($error != '') { |
1488 | 1748 | return $error; |
1489 | - } elseif ($globalDebug) echo "Done\n"; |
|
1490 | - if ($globalDebug) echo "Owner Chile: Download..."; |
|
1749 | + } elseif ($globalDebug) { |
|
1750 | + echo "Done\n"; |
|
1751 | + } |
|
1752 | + if ($globalDebug) { |
|
1753 | + echo "Owner Chile: Download..."; |
|
1754 | + } |
|
1491 | 1755 | update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv'); |
1492 | 1756 | if (file_exists($tmp_dir.'owner_cc.csv')) { |
1493 | - if ($globalDebug) echo "Add to DB..."; |
|
1757 | + if ($globalDebug) { |
|
1758 | + echo "Add to DB..."; |
|
1759 | + } |
|
1494 | 1760 | $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC'); |
1495 | - } else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
|
1761 | + } else { |
|
1762 | + $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
|
1763 | + } |
|
1496 | 1764 | if ($error != '') { |
1497 | 1765 | return $error; |
1498 | - } elseif ($globalDebug) echo "Done\n"; |
|
1499 | - if ($globalDebug) echo "Owner Colombia: Download..."; |
|
1766 | + } elseif ($globalDebug) { |
|
1767 | + echo "Done\n"; |
|
1768 | + } |
|
1769 | + if ($globalDebug) { |
|
1770 | + echo "Owner Colombia: Download..."; |
|
1771 | + } |
|
1500 | 1772 | update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv'); |
1501 | 1773 | if (file_exists($tmp_dir.'owner_hj.csv')) { |
1502 | - if ($globalDebug) echo "Add to DB..."; |
|
1774 | + if ($globalDebug) { |
|
1775 | + echo "Add to DB..."; |
|
1776 | + } |
|
1503 | 1777 | $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ'); |
1504 | - } else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
|
1778 | + } else { |
|
1779 | + $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
|
1780 | + } |
|
1505 | 1781 | if ($error != '') { |
1506 | 1782 | return $error; |
1507 | - } elseif ($globalDebug) echo "Done\n"; |
|
1508 | - if ($globalDebug) echo "Owner Bosnia Herzegobina: Download..."; |
|
1783 | + } elseif ($globalDebug) { |
|
1784 | + echo "Done\n"; |
|
1785 | + } |
|
1786 | + if ($globalDebug) { |
|
1787 | + echo "Owner Bosnia Herzegobina: Download..."; |
|
1788 | + } |
|
1509 | 1789 | update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv'); |
1510 | 1790 | if (file_exists($tmp_dir.'owner_e7.csv')) { |
1511 | - if ($globalDebug) echo "Add to DB..."; |
|
1791 | + if ($globalDebug) { |
|
1792 | + echo "Add to DB..."; |
|
1793 | + } |
|
1512 | 1794 | $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7'); |
1513 | - } else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
|
1795 | + } else { |
|
1796 | + $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
|
1797 | + } |
|
1514 | 1798 | if ($error != '') { |
1515 | 1799 | return $error; |
1516 | - } elseif ($globalDebug) echo "Done\n"; |
|
1517 | - if ($globalDebug) echo "Owner Brazil: Download..."; |
|
1800 | + } elseif ($globalDebug) { |
|
1801 | + echo "Done\n"; |
|
1802 | + } |
|
1803 | + if ($globalDebug) { |
|
1804 | + echo "Owner Brazil: Download..."; |
|
1805 | + } |
|
1518 | 1806 | update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv'); |
1519 | 1807 | if (file_exists($tmp_dir.'owner_pp.csv')) { |
1520 | - if ($globalDebug) echo "Add to DB..."; |
|
1808 | + if ($globalDebug) { |
|
1809 | + echo "Add to DB..."; |
|
1810 | + } |
|
1521 | 1811 | $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP'); |
1522 | - } else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
|
1812 | + } else { |
|
1813 | + $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
|
1814 | + } |
|
1523 | 1815 | if ($error != '') { |
1524 | 1816 | return $error; |
1525 | - } elseif ($globalDebug) echo "Done\n"; |
|
1526 | - if ($globalDebug) echo "Owner Cayman Islands: Download..."; |
|
1817 | + } elseif ($globalDebug) { |
|
1818 | + echo "Done\n"; |
|
1819 | + } |
|
1820 | + if ($globalDebug) { |
|
1821 | + echo "Owner Cayman Islands: Download..."; |
|
1822 | + } |
|
1527 | 1823 | update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv'); |
1528 | 1824 | if (file_exists($tmp_dir.'owner_vp.csv')) { |
1529 | - if ($globalDebug) echo "Add to DB..."; |
|
1825 | + if ($globalDebug) { |
|
1826 | + echo "Add to DB..."; |
|
1827 | + } |
|
1530 | 1828 | $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP'); |
1531 | - } else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
|
1829 | + } else { |
|
1830 | + $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
|
1831 | + } |
|
1532 | 1832 | if ($error != '') { |
1533 | 1833 | return $error; |
1534 | - } elseif ($globalDebug) echo "Done\n"; |
|
1535 | - if ($globalDebug) echo "Owner Croatia: Download..."; |
|
1834 | + } elseif ($globalDebug) { |
|
1835 | + echo "Done\n"; |
|
1836 | + } |
|
1837 | + if ($globalDebug) { |
|
1838 | + echo "Owner Croatia: Download..."; |
|
1839 | + } |
|
1536 | 1840 | update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv'); |
1537 | 1841 | if (file_exists($tmp_dir.'owner_9a.csv')) { |
1538 | - if ($globalDebug) echo "Add to DB..."; |
|
1842 | + if ($globalDebug) { |
|
1843 | + echo "Add to DB..."; |
|
1844 | + } |
|
1539 | 1845 | $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A'); |
1540 | - } else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
|
1846 | + } else { |
|
1847 | + $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
|
1848 | + } |
|
1541 | 1849 | if ($error != '') { |
1542 | 1850 | return $error; |
1543 | - } elseif ($globalDebug) echo "Done\n"; |
|
1544 | - if ($globalDebug) echo "Owner Luxembourg: Download..."; |
|
1851 | + } elseif ($globalDebug) { |
|
1852 | + echo "Done\n"; |
|
1853 | + } |
|
1854 | + if ($globalDebug) { |
|
1855 | + echo "Owner Luxembourg: Download..."; |
|
1856 | + } |
|
1545 | 1857 | update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv'); |
1546 | 1858 | if (file_exists($tmp_dir.'owner_lx.csv')) { |
1547 | - if ($globalDebug) echo "Add to DB..."; |
|
1859 | + if ($globalDebug) { |
|
1860 | + echo "Add to DB..."; |
|
1861 | + } |
|
1548 | 1862 | $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX'); |
1549 | - } else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
|
1863 | + } else { |
|
1864 | + $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
|
1865 | + } |
|
1550 | 1866 | if ($error != '') { |
1551 | 1867 | return $error; |
1552 | - } elseif ($globalDebug) echo "Done\n"; |
|
1553 | - if ($globalDebug) echo "Owner Maldives: Download..."; |
|
1868 | + } elseif ($globalDebug) { |
|
1869 | + echo "Done\n"; |
|
1870 | + } |
|
1871 | + if ($globalDebug) { |
|
1872 | + echo "Owner Maldives: Download..."; |
|
1873 | + } |
|
1554 | 1874 | update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv'); |
1555 | 1875 | if (file_exists($tmp_dir.'owner_8q.csv')) { |
1556 | - if ($globalDebug) echo "Add to DB..."; |
|
1876 | + if ($globalDebug) { |
|
1877 | + echo "Add to DB..."; |
|
1878 | + } |
|
1557 | 1879 | $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q'); |
1558 | - } else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
|
1880 | + } else { |
|
1881 | + $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
|
1882 | + } |
|
1559 | 1883 | if ($error != '') { |
1560 | 1884 | return $error; |
1561 | - } elseif ($globalDebug) echo "Done\n"; |
|
1562 | - if ($globalDebug) echo "Owner New Zealand: Download..."; |
|
1885 | + } elseif ($globalDebug) { |
|
1886 | + echo "Done\n"; |
|
1887 | + } |
|
1888 | + if ($globalDebug) { |
|
1889 | + echo "Owner New Zealand: Download..."; |
|
1890 | + } |
|
1563 | 1891 | update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv'); |
1564 | 1892 | if (file_exists($tmp_dir.'owner_zk.csv')) { |
1565 | - if ($globalDebug) echo "Add to DB..."; |
|
1893 | + if ($globalDebug) { |
|
1894 | + echo "Add to DB..."; |
|
1895 | + } |
|
1566 | 1896 | $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK'); |
1567 | - } else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
|
1897 | + } else { |
|
1898 | + $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
|
1899 | + } |
|
1568 | 1900 | if ($error != '') { |
1569 | 1901 | return $error; |
1570 | - } elseif ($globalDebug) echo "Done\n"; |
|
1571 | - if ($globalDebug) echo "Owner Papua New Guinea: Download..."; |
|
1902 | + } elseif ($globalDebug) { |
|
1903 | + echo "Done\n"; |
|
1904 | + } |
|
1905 | + if ($globalDebug) { |
|
1906 | + echo "Owner Papua New Guinea: Download..."; |
|
1907 | + } |
|
1572 | 1908 | update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv'); |
1573 | 1909 | if (file_exists($tmp_dir.'owner_p2.csv')) { |
1574 | - if ($globalDebug) echo "Add to DB..."; |
|
1910 | + if ($globalDebug) { |
|
1911 | + echo "Add to DB..."; |
|
1912 | + } |
|
1575 | 1913 | $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2'); |
1576 | - } else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
|
1914 | + } else { |
|
1915 | + $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
|
1916 | + } |
|
1577 | 1917 | if ($error != '') { |
1578 | 1918 | return $error; |
1579 | - } elseif ($globalDebug) echo "Done\n"; |
|
1580 | - if ($globalDebug) echo "Owner Slovakia: Download..."; |
|
1919 | + } elseif ($globalDebug) { |
|
1920 | + echo "Done\n"; |
|
1921 | + } |
|
1922 | + if ($globalDebug) { |
|
1923 | + echo "Owner Slovakia: Download..."; |
|
1924 | + } |
|
1581 | 1925 | update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv'); |
1582 | 1926 | if (file_exists($tmp_dir.'owner_om.csv')) { |
1583 | - if ($globalDebug) echo "Add to DB..."; |
|
1927 | + if ($globalDebug) { |
|
1928 | + echo "Add to DB..."; |
|
1929 | + } |
|
1584 | 1930 | $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM'); |
1585 | - } else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
|
1931 | + } else { |
|
1932 | + $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
|
1933 | + } |
|
1586 | 1934 | if ($error != '') { |
1587 | 1935 | return $error; |
1588 | - } elseif ($globalDebug) echo "Done\n"; |
|
1589 | - if ($globalDebug) echo "Owner Ecuador: Download..."; |
|
1936 | + } elseif ($globalDebug) { |
|
1937 | + echo "Done\n"; |
|
1938 | + } |
|
1939 | + if ($globalDebug) { |
|
1940 | + echo "Owner Ecuador: Download..."; |
|
1941 | + } |
|
1590 | 1942 | update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv'); |
1591 | 1943 | if (file_exists($tmp_dir.'owner_hc.csv')) { |
1592 | - if ($globalDebug) echo "Add to DB..."; |
|
1944 | + if ($globalDebug) { |
|
1945 | + echo "Add to DB..."; |
|
1946 | + } |
|
1593 | 1947 | $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC'); |
1594 | - } else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
|
1948 | + } else { |
|
1949 | + $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
|
1950 | + } |
|
1595 | 1951 | if ($error != '') { |
1596 | 1952 | return $error; |
1597 | - } elseif ($globalDebug) echo "Done\n"; |
|
1598 | - if ($globalDebug) echo "Owner Iceland: Download..."; |
|
1953 | + } elseif ($globalDebug) { |
|
1954 | + echo "Done\n"; |
|
1955 | + } |
|
1956 | + if ($globalDebug) { |
|
1957 | + echo "Owner Iceland: Download..."; |
|
1958 | + } |
|
1599 | 1959 | update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv'); |
1600 | 1960 | if (file_exists($tmp_dir.'owner_tf.csv')) { |
1601 | - if ($globalDebug) echo "Add to DB..."; |
|
1961 | + if ($globalDebug) { |
|
1962 | + echo "Add to DB..."; |
|
1963 | + } |
|
1602 | 1964 | $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF'); |
1603 | - } else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
|
1965 | + } else { |
|
1966 | + $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
|
1967 | + } |
|
1604 | 1968 | if ($error != '') { |
1605 | 1969 | return $error; |
1606 | - } elseif ($globalDebug) echo "Done\n"; |
|
1970 | + } elseif ($globalDebug) { |
|
1971 | + echo "Done\n"; |
|
1972 | + } |
|
1607 | 1973 | return ''; |
1608 | 1974 | } |
1609 | 1975 | |
1610 | 1976 | public static function update_translation() { |
1611 | 1977 | global $tmp_dir, $globalDebug; |
1612 | 1978 | $error = ''; |
1613 | - if ($globalDebug) echo "Translation : Download..."; |
|
1979 | + if ($globalDebug) { |
|
1980 | + echo "Translation : Download..."; |
|
1981 | + } |
|
1614 | 1982 | update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip'); |
1615 | 1983 | if (file_exists($tmp_dir.'translation.zip')) { |
1616 | - if ($globalDebug) echo "Unzip..."; |
|
1984 | + if ($globalDebug) { |
|
1985 | + echo "Unzip..."; |
|
1986 | + } |
|
1617 | 1987 | update_db::unzip($tmp_dir.'translation.zip'); |
1618 | - if ($globalDebug) echo "Add to DB..."; |
|
1988 | + if ($globalDebug) { |
|
1989 | + echo "Add to DB..."; |
|
1990 | + } |
|
1619 | 1991 | $error = update_db::translation(); |
1620 | - } else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed."; |
|
1992 | + } else { |
|
1993 | + $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed."; |
|
1994 | + } |
|
1621 | 1995 | if ($error != '') { |
1622 | 1996 | return $error; |
1623 | - } elseif ($globalDebug) echo "Done\n"; |
|
1997 | + } elseif ($globalDebug) { |
|
1998 | + echo "Done\n"; |
|
1999 | + } |
|
1624 | 2000 | return ''; |
1625 | 2001 | } |
1626 | 2002 | |
1627 | 2003 | public static function update_translation_fam() { |
1628 | 2004 | global $tmp_dir, $globalDebug; |
1629 | - if ($globalDebug) echo "Translation from FlightAirMap website : Download..."; |
|
2005 | + if ($globalDebug) { |
|
2006 | + echo "Translation from FlightAirMap website : Download..."; |
|
2007 | + } |
|
1630 | 2008 | update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz'); |
1631 | 2009 | if (file_exists($tmp_dir.'translation.tsv.gz')) { |
1632 | - if ($globalDebug) echo "Gunzip..."; |
|
2010 | + if ($globalDebug) { |
|
2011 | + echo "Gunzip..."; |
|
2012 | + } |
|
1633 | 2013 | update_db::gunzip($tmp_dir.'translation.tsv.gz'); |
1634 | - if ($globalDebug) echo "Add to DB..."; |
|
2014 | + if ($globalDebug) { |
|
2015 | + echo "Add to DB..."; |
|
2016 | + } |
|
1635 | 2017 | $error = update_db::translation_fam(); |
1636 | - } else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed."; |
|
2018 | + } else { |
|
2019 | + $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed."; |
|
2020 | + } |
|
1637 | 2021 | if ($error != '') { |
1638 | 2022 | return $error; |
1639 | - } elseif ($globalDebug) echo "Done\n"; |
|
2023 | + } elseif ($globalDebug) { |
|
2024 | + echo "Done\n"; |
|
2025 | + } |
|
1640 | 2026 | return ''; |
1641 | 2027 | } |
1642 | 2028 | public static function update_ModeS_fam() { |
1643 | 2029 | global $tmp_dir, $globalDebug; |
1644 | - if ($globalDebug) echo "ModeS from FlightAirMap website : Download..."; |
|
2030 | + if ($globalDebug) { |
|
2031 | + echo "ModeS from FlightAirMap website : Download..."; |
|
2032 | + } |
|
1645 | 2033 | update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz'); |
1646 | 2034 | if (file_exists($tmp_dir.'modes.tsv.gz')) { |
1647 | - if ($globalDebug) echo "Gunzip..."; |
|
2035 | + if ($globalDebug) { |
|
2036 | + echo "Gunzip..."; |
|
2037 | + } |
|
1648 | 2038 | update_db::gunzip($tmp_dir.'modes.tsv.gz'); |
1649 | - if ($globalDebug) echo "Add to DB..."; |
|
2039 | + if ($globalDebug) { |
|
2040 | + echo "Add to DB..."; |
|
2041 | + } |
|
1650 | 2042 | $error = update_db::modes_fam(); |
1651 | - } else $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed."; |
|
2043 | + } else { |
|
2044 | + $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed."; |
|
2045 | + } |
|
1652 | 2046 | if ($error != '') { |
1653 | 2047 | return $error; |
1654 | - } elseif ($globalDebug) echo "Done\n"; |
|
2048 | + } elseif ($globalDebug) { |
|
2049 | + echo "Done\n"; |
|
2050 | + } |
|
1655 | 2051 | return ''; |
1656 | 2052 | } |
1657 | 2053 | |
@@ -1659,7 +2055,9 @@ discard block |
||
1659 | 2055 | global $tmp_dir, $globalDebug, $globalDBdriver; |
1660 | 2056 | include_once('class.create_db.php'); |
1661 | 2057 | $error = ''; |
1662 | - if ($globalDebug) echo "Airspace from FlightAirMap website : Download..."; |
|
2058 | + if ($globalDebug) { |
|
2059 | + echo "Airspace from FlightAirMap website : Download..."; |
|
2060 | + } |
|
1663 | 2061 | if ($globalDBdriver == 'mysql') { |
1664 | 2062 | update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); |
1665 | 2063 | } else { |
@@ -1675,9 +2073,13 @@ discard block |
||
1675 | 2073 | update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz'); |
1676 | 2074 | } |
1677 | 2075 | if (file_exists($tmp_dir.'airspace.sql.gz')) { |
1678 | - if ($globalDebug) echo "Gunzip..."; |
|
2076 | + if ($globalDebug) { |
|
2077 | + echo "Gunzip..."; |
|
2078 | + } |
|
1679 | 2079 | update_db::gunzip($tmp_dir.'airspace.sql.gz'); |
1680 | - if ($globalDebug) echo "Add to DB..."; |
|
2080 | + if ($globalDebug) { |
|
2081 | + echo "Add to DB..."; |
|
2082 | + } |
|
1681 | 2083 | $Connection = new Connection(); |
1682 | 2084 | if ($Connection->tableExists('airspace')) { |
1683 | 2085 | $query = 'DROP TABLE airspace'; |
@@ -1690,31 +2092,47 @@ discard block |
||
1690 | 2092 | } |
1691 | 2093 | $error = create_db::import_file($tmp_dir.'airspace.sql'); |
1692 | 2094 | update_db::insert_airspace_version($airspace_md5); |
1693 | - } else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed."; |
|
2095 | + } else { |
|
2096 | + $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed."; |
|
2097 | + } |
|
1694 | 2098 | } |
1695 | - } else $error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed."; |
|
2099 | + } else { |
|
2100 | + $error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed."; |
|
2101 | + } |
|
1696 | 2102 | if ($error != '') { |
1697 | 2103 | return $error; |
1698 | - } elseif ($globalDebug) echo "Done\n"; |
|
2104 | + } elseif ($globalDebug) { |
|
2105 | + echo "Done\n"; |
|
2106 | + } |
|
1699 | 2107 | return ''; |
1700 | 2108 | } |
1701 | 2109 | |
1702 | 2110 | public static function update_tle() { |
1703 | 2111 | global $tmp_dir, $globalDebug; |
1704 | - if ($globalDebug) echo "Download TLE : Download..."; |
|
2112 | + if ($globalDebug) { |
|
2113 | + echo "Download TLE : Download..."; |
|
2114 | + } |
|
1705 | 2115 | $alltle = array('stations.txt','gps-ops.txt','glo-ops.txt','galileo.txt','weather.txt','noaa.txt','goes.txt','resource.txt','dmc.txt','tdrss.txt','geo.txt','intelsat.txt','gorizont.txt', |
1706 | 2116 | 'raduga.txt','molniya.txt','iridium.txt','orbcomm.txt','globalstar.txt','amateur.txt','x-comm.txt','other-comm.txt','sbas.txt','nnss.txt','musson.txt','science.txt','geodetic.txt', |
1707 | 2117 | 'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt'); |
1708 | 2118 | foreach ($alltle as $filename) { |
1709 | - if ($globalDebug) echo "downloading ".$filename.'...'; |
|
2119 | + if ($globalDebug) { |
|
2120 | + echo "downloading ".$filename.'...'; |
|
2121 | + } |
|
1710 | 2122 | update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename); |
1711 | 2123 | if (file_exists($tmp_dir.$filename)) { |
1712 | - if ($globalDebug) echo "Add to DB ".$filename."..."; |
|
2124 | + if ($globalDebug) { |
|
2125 | + echo "Add to DB ".$filename."..."; |
|
2126 | + } |
|
1713 | 2127 | $error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename)); |
1714 | - } else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
|
2128 | + } else { |
|
2129 | + $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
|
2130 | + } |
|
1715 | 2131 | if ($error != '') { |
1716 | 2132 | echo $error."\n"; |
1717 | - } elseif ($globalDebug) echo "Done\n"; |
|
2133 | + } elseif ($globalDebug) { |
|
2134 | + echo "Done\n"; |
|
2135 | + } |
|
1718 | 2136 | } |
1719 | 2137 | return ''; |
1720 | 2138 | } |
@@ -1722,10 +2140,14 @@ discard block |
||
1722 | 2140 | public static function update_models() { |
1723 | 2141 | global $tmp_dir, $globalDebug; |
1724 | 2142 | $error = ''; |
1725 | - if ($globalDebug) echo "Models from FlightAirMap website : Download..."; |
|
2143 | + if ($globalDebug) { |
|
2144 | + echo "Models from FlightAirMap website : Download..."; |
|
2145 | + } |
|
1726 | 2146 | update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum'); |
1727 | 2147 | if (file_exists($tmp_dir.'models.md5sum')) { |
1728 | - if ($globalDebug) echo "Check files...\n"; |
|
2148 | + if ($globalDebug) { |
|
2149 | + echo "Check files...\n"; |
|
2150 | + } |
|
1729 | 2151 | $newmodelsdb = array(); |
1730 | 2152 | if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) { |
1731 | 2153 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -1744,25 +2166,35 @@ discard block |
||
1744 | 2166 | } |
1745 | 2167 | $diff = array_diff($newmodelsdb,$modelsdb); |
1746 | 2168 | foreach ($diff as $key => $value) { |
1747 | - if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n"; |
|
2169 | + if ($globalDebug) { |
|
2170 | + echo 'Downloading model '.$key.' ...'."\n"; |
|
2171 | + } |
|
1748 | 2172 | update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key); |
1749 | 2173 | |
1750 | 2174 | } |
1751 | 2175 | update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum'); |
1752 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
2176 | + } else { |
|
2177 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
2178 | + } |
|
1753 | 2179 | if ($error != '') { |
1754 | 2180 | return $error; |
1755 | - } elseif ($globalDebug) echo "Done\n"; |
|
2181 | + } elseif ($globalDebug) { |
|
2182 | + echo "Done\n"; |
|
2183 | + } |
|
1756 | 2184 | return ''; |
1757 | 2185 | } |
1758 | 2186 | |
1759 | 2187 | public static function update_space_models() { |
1760 | 2188 | global $tmp_dir, $globalDebug; |
1761 | 2189 | $error = ''; |
1762 | - if ($globalDebug) echo "Space models from FlightAirMap website : Download..."; |
|
2190 | + if ($globalDebug) { |
|
2191 | + echo "Space models from FlightAirMap website : Download..."; |
|
2192 | + } |
|
1763 | 2193 | update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum'); |
1764 | 2194 | if (file_exists($tmp_dir.'space_models.md5sum')) { |
1765 | - if ($globalDebug) echo "Check files...\n"; |
|
2195 | + if ($globalDebug) { |
|
2196 | + echo "Check files...\n"; |
|
2197 | + } |
|
1766 | 2198 | $newmodelsdb = array(); |
1767 | 2199 | if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) { |
1768 | 2200 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -1781,15 +2213,21 @@ discard block |
||
1781 | 2213 | } |
1782 | 2214 | $diff = array_diff($newmodelsdb,$modelsdb); |
1783 | 2215 | foreach ($diff as $key => $value) { |
1784 | - if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n"; |
|
2216 | + if ($globalDebug) { |
|
2217 | + echo 'Downloading space model '.$key.' ...'."\n"; |
|
2218 | + } |
|
1785 | 2219 | update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key); |
1786 | 2220 | |
1787 | 2221 | } |
1788 | 2222 | update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum'); |
1789 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
2223 | + } else { |
|
2224 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
2225 | + } |
|
1790 | 2226 | if ($error != '') { |
1791 | 2227 | return $error; |
1792 | - } elseif ($globalDebug) echo "Done\n"; |
|
2228 | + } elseif ($globalDebug) { |
|
2229 | + echo "Done\n"; |
|
2230 | + } |
|
1793 | 2231 | return ''; |
1794 | 2232 | } |
1795 | 2233 | |
@@ -1832,7 +2270,9 @@ discard block |
||
1832 | 2270 | } |
1833 | 2271 | |
1834 | 2272 | $error = ''; |
1835 | - if ($globalDebug) echo "Notam : Download..."; |
|
2273 | + if ($globalDebug) { |
|
2274 | + echo "Notam : Download..."; |
|
2275 | + } |
|
1836 | 2276 | update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss'); |
1837 | 2277 | if (file_exists($tmp_dir.'notam.rss')) { |
1838 | 2278 | $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true); |
@@ -1847,14 +2287,30 @@ discard block |
||
1847 | 2287 | $data['fir'] = $q[0]; |
1848 | 2288 | $data['code'] = $q[1]; |
1849 | 2289 | $ifrvfr = $q[2]; |
1850 | - if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR'; |
|
1851 | - if ($ifrvfr == 'I') $data['rules'] = 'IFR'; |
|
1852 | - if ($ifrvfr == 'V') $data['rules'] = 'VFR'; |
|
1853 | - if ($q[4] == 'A') $data['scope'] = 'Airport warning'; |
|
1854 | - if ($q[4] == 'E') $data['scope'] = 'Enroute warning'; |
|
1855 | - if ($q[4] == 'W') $data['scope'] = 'Navigation warning'; |
|
1856 | - if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning'; |
|
1857 | - if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning'; |
|
2290 | + if ($ifrvfr == 'IV') { |
|
2291 | + $data['rules'] = 'IFR/VFR'; |
|
2292 | + } |
|
2293 | + if ($ifrvfr == 'I') { |
|
2294 | + $data['rules'] = 'IFR'; |
|
2295 | + } |
|
2296 | + if ($ifrvfr == 'V') { |
|
2297 | + $data['rules'] = 'VFR'; |
|
2298 | + } |
|
2299 | + if ($q[4] == 'A') { |
|
2300 | + $data['scope'] = 'Airport warning'; |
|
2301 | + } |
|
2302 | + if ($q[4] == 'E') { |
|
2303 | + $data['scope'] = 'Enroute warning'; |
|
2304 | + } |
|
2305 | + if ($q[4] == 'W') { |
|
2306 | + $data['scope'] = 'Navigation warning'; |
|
2307 | + } |
|
2308 | + if ($q[4] == 'AE') { |
|
2309 | + $data['scope'] = 'Airport/Enroute warning'; |
|
2310 | + } |
|
2311 | + if ($q[4] == 'AW') { |
|
2312 | + $data['scope'] = 'Airport/Navigation warning'; |
|
2313 | + } |
|
1858 | 2314 | //$data['scope'] = $q[4]; |
1859 | 2315 | $data['lower_limit'] = $q[5]; |
1860 | 2316 | $data['upper_limit'] = $q[6]; |
@@ -1862,8 +2318,12 @@ discard block |
||
1862 | 2318 | sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius); |
1863 | 2319 | $latitude = $Common->convertDec($las,'latitude'); |
1864 | 2320 | $longitude = $Common->convertDec($lns,'longitude'); |
1865 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
1866 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
2321 | + if ($lac == 'S') { |
|
2322 | + $latitude = '-'.$latitude; |
|
2323 | + } |
|
2324 | + if ($lnc == 'W') { |
|
2325 | + $longitude = '-'.$longitude; |
|
2326 | + } |
|
1867 | 2327 | $data['center_latitude'] = $latitude; |
1868 | 2328 | $data['center_longitude'] = $longitude; |
1869 | 2329 | $data['radius'] = intval($radius); |
@@ -1893,10 +2353,14 @@ discard block |
||
1893 | 2353 | $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']); |
1894 | 2354 | unset($data); |
1895 | 2355 | } |
1896 | - } else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
|
2356 | + } else { |
|
2357 | + $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
|
2358 | + } |
|
1897 | 2359 | if ($error != '') { |
1898 | 2360 | return $error; |
1899 | - } elseif ($globalDebug) echo "Done\n"; |
|
2361 | + } elseif ($globalDebug) { |
|
2362 | + echo "Done\n"; |
|
2363 | + } |
|
1900 | 2364 | return ''; |
1901 | 2365 | } |
1902 | 2366 | |
@@ -1921,7 +2385,9 @@ discard block |
||
1921 | 2385 | $airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json'); |
1922 | 2386 | $airspace_json = json_decode($airspace_lst,true); |
1923 | 2387 | foreach ($airspace_json['records'] as $airspace) { |
1924 | - if ($globalDebug) echo $airspace['name']."...\n"; |
|
2388 | + if ($globalDebug) { |
|
2389 | + echo $airspace['name']."...\n"; |
|
2390 | + } |
|
1925 | 2391 | update_db::download($airspace['uri'],$tmp_dir.$airspace['name']); |
1926 | 2392 | if (file_exists($tmp_dir.$airspace['name'])) { |
1927 | 2393 | file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name']))); |
@@ -1950,8 +2416,11 @@ discard block |
||
1950 | 2416 | return "error : ".$e->getMessage(); |
1951 | 2417 | } |
1952 | 2418 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
1953 | - if ($row['nb'] > 0) return false; |
|
1954 | - else return true; |
|
2419 | + if ($row['nb'] > 0) { |
|
2420 | + return false; |
|
2421 | + } else { |
|
2422 | + return true; |
|
2423 | + } |
|
1955 | 2424 | } |
1956 | 2425 | |
1957 | 2426 | public static function insert_last_update() { |
@@ -1976,8 +2445,11 @@ discard block |
||
1976 | 2445 | return "error : ".$e->getMessage(); |
1977 | 2446 | } |
1978 | 2447 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
1979 | - if ($row['nb'] > 0) return true; |
|
1980 | - else return false; |
|
2448 | + if ($row['nb'] > 0) { |
|
2449 | + return true; |
|
2450 | + } else { |
|
2451 | + return false; |
|
2452 | + } |
|
1981 | 2453 | } |
1982 | 2454 | |
1983 | 2455 | |
@@ -2008,8 +2480,11 @@ discard block |
||
2008 | 2480 | return "error : ".$e->getMessage(); |
2009 | 2481 | } |
2010 | 2482 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2011 | - if ($row['nb'] > 0) return false; |
|
2012 | - else return true; |
|
2483 | + if ($row['nb'] > 0) { |
|
2484 | + return false; |
|
2485 | + } else { |
|
2486 | + return true; |
|
2487 | + } |
|
2013 | 2488 | } |
2014 | 2489 | |
2015 | 2490 | public static function insert_last_notam_update() { |
@@ -2038,8 +2513,11 @@ discard block |
||
2038 | 2513 | return "error : ".$e->getMessage(); |
2039 | 2514 | } |
2040 | 2515 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2041 | - if ($row['nb'] > 0) return false; |
|
2042 | - else return true; |
|
2516 | + if ($row['nb'] > 0) { |
|
2517 | + return false; |
|
2518 | + } else { |
|
2519 | + return true; |
|
2520 | + } |
|
2043 | 2521 | } |
2044 | 2522 | |
2045 | 2523 | public static function insert_last_airspace_update() { |
@@ -2069,8 +2547,11 @@ discard block |
||
2069 | 2547 | return "error : ".$e->getMessage(); |
2070 | 2548 | } |
2071 | 2549 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2072 | - if ($row['nb'] > 0) return false; |
|
2073 | - else return true; |
|
2550 | + if ($row['nb'] > 0) { |
|
2551 | + return false; |
|
2552 | + } else { |
|
2553 | + return true; |
|
2554 | + } |
|
2074 | 2555 | } |
2075 | 2556 | |
2076 | 2557 | public static function insert_last_owner_update() { |
@@ -2099,8 +2580,11 @@ discard block |
||
2099 | 2580 | return "error : ".$e->getMessage(); |
2100 | 2581 | } |
2101 | 2582 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2102 | - if ($row['nb'] > 0) return false; |
|
2103 | - else return true; |
|
2583 | + if ($row['nb'] > 0) { |
|
2584 | + return false; |
|
2585 | + } else { |
|
2586 | + return true; |
|
2587 | + } |
|
2104 | 2588 | } |
2105 | 2589 | |
2106 | 2590 | public static function insert_last_schedules_update() { |
@@ -2129,8 +2613,11 @@ discard block |
||
2129 | 2613 | return "error : ".$e->getMessage(); |
2130 | 2614 | } |
2131 | 2615 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2132 | - if ($row['nb'] > 0) return false; |
|
2133 | - else return true; |
|
2616 | + if ($row['nb'] > 0) { |
|
2617 | + return false; |
|
2618 | + } else { |
|
2619 | + return true; |
|
2620 | + } |
|
2134 | 2621 | } |
2135 | 2622 | |
2136 | 2623 | public static function insert_last_tle_update() { |