@@ -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(); |
@@ -250,10 +250,10 @@ discard block |
||
250 | 250 | try { |
251 | 251 | $Connection = new Connection(); |
252 | 252 | $sth = $Connection->db->prepare($query); |
253 | - $sth->execute(array(':source' => $database_file)); |
|
254 | - } catch(PDOException $e) { |
|
255 | - return "error : ".$e->getMessage(); |
|
256 | - } |
|
253 | + $sth->execute(array(':source' => $database_file)); |
|
254 | + } catch(PDOException $e) { |
|
255 | + return "error : ".$e->getMessage(); |
|
256 | + } |
|
257 | 257 | return ''; |
258 | 258 | } |
259 | 259 | |
@@ -265,10 +265,10 @@ discard block |
||
265 | 265 | try { |
266 | 266 | $Connection = new Connection(); |
267 | 267 | $sth = $Connection->db->prepare($query); |
268 | - $sth->execute(array(':source' => $database_file)); |
|
269 | - } catch(PDOException $e) { |
|
270 | - return "error : ".$e->getMessage(); |
|
271 | - } |
|
268 | + $sth->execute(array(':source' => $database_file)); |
|
269 | + } catch(PDOException $e) { |
|
270 | + return "error : ".$e->getMessage(); |
|
271 | + } |
|
272 | 272 | |
273 | 273 | if ($fh = fopen($database_file,"r")) { |
274 | 274 | //$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)'; |
@@ -278,26 +278,26 @@ discard block |
||
278 | 278 | $sth_dest = $Connection->db->prepare($query_dest); |
279 | 279 | try { |
280 | 280 | if ($globalTransaction) $Connection->db->beginTransaction(); |
281 | - while (!feof($fh)) { |
|
282 | - $values = array(); |
|
283 | - $line = $Common->hex2str(fgets($fh,9999)); |
|
281 | + while (!feof($fh)) { |
|
282 | + $values = array(); |
|
283 | + $line = $Common->hex2str(fgets($fh,9999)); |
|
284 | 284 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
285 | - $values['ModeS'] = substr($line,0,6); |
|
286 | - $values['Registration'] = trim(substr($line,69,6)); |
|
287 | - $aircraft_name = trim(substr($line,48,6)); |
|
288 | - // Check if we can find ICAO, else set it to GLID |
|
289 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
290 | - $search_more = ''; |
|
291 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
292 | - $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
293 | - $sth_search = $Connection->db->prepare($query_search); |
|
285 | + $values['ModeS'] = substr($line,0,6); |
|
286 | + $values['Registration'] = trim(substr($line,69,6)); |
|
287 | + $aircraft_name = trim(substr($line,48,6)); |
|
288 | + // Check if we can find ICAO, else set it to GLID |
|
289 | + $aircraft_name_split = explode(' ',$aircraft_name); |
|
290 | + $search_more = ''; |
|
291 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
292 | + $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
293 | + $sth_search = $Connection->db->prepare($query_search); |
|
294 | 294 | try { |
295 | - $sth_search->execute(); |
|
296 | - $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
297 | - //if (count($result) > 0) { |
|
298 | - if (isset($result['icao']) && $result['icao'] != '') { |
|
299 | - $values['ICAOTypeCode'] = $result['icao']; |
|
300 | - } |
|
295 | + $sth_search->execute(); |
|
296 | + $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
297 | + //if (count($result) > 0) { |
|
298 | + if (isset($result['icao']) && $result['icao'] != '') { |
|
299 | + $values['ICAOTypeCode'] = $result['icao']; |
|
300 | + } |
|
301 | 301 | } catch(PDOException $e) { |
302 | 302 | return "error : ".$e->getMessage(); |
303 | 303 | } |
@@ -320,10 +320,10 @@ discard block |
||
320 | 320 | try { |
321 | 321 | $Connection = new Connection(); |
322 | 322 | $sth = $Connection->db->prepare($query); |
323 | - $sth->execute(array(':source' => $database_file)); |
|
324 | - } catch(PDOException $e) { |
|
325 | - return "error : ".$e->getMessage(); |
|
326 | - } |
|
323 | + $sth->execute(array(':source' => $database_file)); |
|
324 | + } catch(PDOException $e) { |
|
325 | + return "error : ".$e->getMessage(); |
|
326 | + } |
|
327 | 327 | return ''; |
328 | 328 | } |
329 | 329 | |
@@ -334,10 +334,10 @@ discard block |
||
334 | 334 | try { |
335 | 335 | $Connection = new Connection(); |
336 | 336 | $sth = $Connection->db->prepare($query); |
337 | - $sth->execute(array(':source' => $database_file)); |
|
338 | - } catch(PDOException $e) { |
|
339 | - return "error : ".$e->getMessage(); |
|
340 | - } |
|
337 | + $sth->execute(array(':source' => $database_file)); |
|
338 | + } catch(PDOException $e) { |
|
339 | + return "error : ".$e->getMessage(); |
|
340 | + } |
|
341 | 341 | |
342 | 342 | if ($fh = fopen($database_file,"r")) { |
343 | 343 | //$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)'; |
@@ -348,24 +348,24 @@ discard block |
||
348 | 348 | try { |
349 | 349 | if ($globalTransaction) $Connection->db->beginTransaction(); |
350 | 350 | $tmp = fgetcsv($fh,9999,',',"'"); |
351 | - while (!feof($fh)) { |
|
352 | - $line = fgetcsv($fh,9999,',',"'"); |
|
351 | + while (!feof($fh)) { |
|
352 | + $line = fgetcsv($fh,9999,',',"'"); |
|
353 | 353 | |
354 | 354 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
355 | 355 | //print_r($line); |
356 | - $values['ModeS'] = $line[1]; |
|
357 | - $values['Registration'] = $line[3]; |
|
358 | - $aircraft_name = $line[2]; |
|
359 | - // Check if we can find ICAO, else set it to GLID |
|
360 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
361 | - $search_more = ''; |
|
362 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
363 | - $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
364 | - $sth_search = $Connection->db->prepare($query_search); |
|
356 | + $values['ModeS'] = $line[1]; |
|
357 | + $values['Registration'] = $line[3]; |
|
358 | + $aircraft_name = $line[2]; |
|
359 | + // Check if we can find ICAO, else set it to GLID |
|
360 | + $aircraft_name_split = explode(' ',$aircraft_name); |
|
361 | + $search_more = ''; |
|
362 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
363 | + $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
364 | + $sth_search = $Connection->db->prepare($query_search); |
|
365 | 365 | try { |
366 | - $sth_search->execute(); |
|
367 | - $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
368 | - if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
|
366 | + $sth_search->execute(); |
|
367 | + $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
368 | + if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
|
369 | 369 | } catch(PDOException $e) { |
370 | 370 | return "error : ".$e->getMessage(); |
371 | 371 | } |
@@ -388,10 +388,10 @@ discard block |
||
388 | 388 | try { |
389 | 389 | $Connection = new Connection(); |
390 | 390 | $sth = $Connection->db->prepare($query); |
391 | - $sth->execute(array(':source' => $database_file)); |
|
392 | - } catch(PDOException $e) { |
|
393 | - return "error : ".$e->getMessage(); |
|
394 | - } |
|
391 | + $sth->execute(array(':source' => $database_file)); |
|
392 | + } catch(PDOException $e) { |
|
393 | + return "error : ".$e->getMessage(); |
|
394 | + } |
|
395 | 395 | return ''; |
396 | 396 | } |
397 | 397 | |
@@ -402,10 +402,10 @@ discard block |
||
402 | 402 | try { |
403 | 403 | $Connection = new Connection(); |
404 | 404 | $sth = $Connection->db->prepare($query); |
405 | - $sth->execute(array(':source' => $database_file)); |
|
406 | - } catch(PDOException $e) { |
|
407 | - return "error : ".$e->getMessage(); |
|
408 | - } |
|
405 | + $sth->execute(array(':source' => $database_file)); |
|
406 | + } catch(PDOException $e) { |
|
407 | + return "error : ".$e->getMessage(); |
|
408 | + } |
|
409 | 409 | |
410 | 410 | if ($fh = fopen($database_file,"r")) { |
411 | 411 | //$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)'; |
@@ -416,95 +416,95 @@ discard block |
||
416 | 416 | try { |
417 | 417 | if ($globalTransaction) $Connection->db->beginTransaction(); |
418 | 418 | $tmp = fgetcsv($fh,9999,',','"'); |
419 | - while (!feof($fh)) { |
|
420 | - $line = fgetcsv($fh,9999,',','"'); |
|
421 | - $values = array(); |
|
422 | - //print_r($line); |
|
423 | - if ($country == 'F') { |
|
424 | - $values['registration'] = $line[0]; |
|
425 | - $values['base'] = $line[4]; |
|
426 | - $values['owner'] = $line[5]; |
|
427 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
428 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
429 | - $values['cancel'] = $line[7]; |
|
419 | + while (!feof($fh)) { |
|
420 | + $line = fgetcsv($fh,9999,',','"'); |
|
421 | + $values = array(); |
|
422 | + //print_r($line); |
|
423 | + if ($country == 'F') { |
|
424 | + $values['registration'] = $line[0]; |
|
425 | + $values['base'] = $line[4]; |
|
426 | + $values['owner'] = $line[5]; |
|
427 | + if ($line[6] == '') $values['date_first_reg'] = null; |
|
428 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
429 | + $values['cancel'] = $line[7]; |
|
430 | 430 | } elseif ($country == 'EI') { |
431 | - // TODO : add modeS & reg to aircraft_modes |
|
432 | - $values['registration'] = $line[0]; |
|
433 | - $values['base'] = $line[3]; |
|
434 | - $values['owner'] = $line[2]; |
|
435 | - if ($line[1] == '') $values['date_first_reg'] = null; |
|
436 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
437 | - $values['cancel'] = ''; |
|
431 | + // TODO : add modeS & reg to aircraft_modes |
|
432 | + $values['registration'] = $line[0]; |
|
433 | + $values['base'] = $line[3]; |
|
434 | + $values['owner'] = $line[2]; |
|
435 | + if ($line[1] == '') $values['date_first_reg'] = null; |
|
436 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
437 | + $values['cancel'] = ''; |
|
438 | 438 | } elseif ($country == 'HB') { |
439 | - // TODO : add modeS & reg to aircraft_modes |
|
440 | - $values['registration'] = $line[0]; |
|
441 | - $values['base'] = null; |
|
442 | - $values['owner'] = $line[5]; |
|
443 | - $values['date_first_reg'] = null; |
|
444 | - $values['cancel'] = ''; |
|
439 | + // TODO : add modeS & reg to aircraft_modes |
|
440 | + $values['registration'] = $line[0]; |
|
441 | + $values['base'] = null; |
|
442 | + $values['owner'] = $line[5]; |
|
443 | + $values['date_first_reg'] = null; |
|
444 | + $values['cancel'] = ''; |
|
445 | 445 | } elseif ($country == 'OK') { |
446 | - // TODO : add modeS & reg to aircraft_modes |
|
447 | - $values['registration'] = $line[3]; |
|
448 | - $values['base'] = null; |
|
449 | - $values['owner'] = $line[5]; |
|
450 | - if ($line[18] == '') $values['date_first_reg'] = null; |
|
451 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
452 | - $values['cancel'] = ''; |
|
446 | + // TODO : add modeS & reg to aircraft_modes |
|
447 | + $values['registration'] = $line[3]; |
|
448 | + $values['base'] = null; |
|
449 | + $values['owner'] = $line[5]; |
|
450 | + if ($line[18] == '') $values['date_first_reg'] = null; |
|
451 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
452 | + $values['cancel'] = ''; |
|
453 | 453 | } elseif ($country == 'VH') { |
454 | - // TODO : add modeS & reg to aircraft_modes |
|
455 | - $values['registration'] = $line[0]; |
|
456 | - $values['base'] = null; |
|
457 | - $values['owner'] = $line[12]; |
|
458 | - if ($line[28] == '') $values['date_first_reg'] = null; |
|
459 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
460 | - |
|
461 | - $values['cancel'] = $line[39]; |
|
454 | + // TODO : add modeS & reg to aircraft_modes |
|
455 | + $values['registration'] = $line[0]; |
|
456 | + $values['base'] = null; |
|
457 | + $values['owner'] = $line[12]; |
|
458 | + if ($line[28] == '') $values['date_first_reg'] = null; |
|
459 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
460 | + |
|
461 | + $values['cancel'] = $line[39]; |
|
462 | 462 | } elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { |
463 | - $values['registration'] = $line[0]; |
|
464 | - $values['base'] = null; |
|
465 | - $values['owner'] = $line[4]; |
|
466 | - $values['date_first_reg'] = null; |
|
467 | - $values['cancel'] = ''; |
|
463 | + $values['registration'] = $line[0]; |
|
464 | + $values['base'] = null; |
|
465 | + $values['owner'] = $line[4]; |
|
466 | + $values['date_first_reg'] = null; |
|
467 | + $values['cancel'] = ''; |
|
468 | 468 | } elseif ($country == 'CC') { |
469 | - $values['registration'] = $line[0]; |
|
470 | - $values['base'] = null; |
|
471 | - $values['owner'] = $line[6]; |
|
472 | - $values['date_first_reg'] = null; |
|
473 | - $values['cancel'] = ''; |
|
469 | + $values['registration'] = $line[0]; |
|
470 | + $values['base'] = null; |
|
471 | + $values['owner'] = $line[6]; |
|
472 | + $values['date_first_reg'] = null; |
|
473 | + $values['cancel'] = ''; |
|
474 | 474 | } elseif ($country == 'HJ') { |
475 | - $values['registration'] = $line[0]; |
|
476 | - $values['base'] = null; |
|
477 | - $values['owner'] = $line[8]; |
|
478 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
479 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
480 | - $values['cancel'] = ''; |
|
475 | + $values['registration'] = $line[0]; |
|
476 | + $values['base'] = null; |
|
477 | + $values['owner'] = $line[8]; |
|
478 | + if ($line[7] == '') $values['date_first_reg'] = null; |
|
479 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
480 | + $values['cancel'] = ''; |
|
481 | 481 | } elseif ($country == 'PP') { |
482 | - $values['registration'] = $line[0]; |
|
483 | - $values['base'] = null; |
|
484 | - $values['owner'] = $line[4]; |
|
485 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
486 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
487 | - $values['cancel'] = $line[7]; |
|
482 | + $values['registration'] = $line[0]; |
|
483 | + $values['base'] = null; |
|
484 | + $values['owner'] = $line[4]; |
|
485 | + if ($line[6] == '') $values['date_first_reg'] = null; |
|
486 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
487 | + $values['cancel'] = $line[7]; |
|
488 | 488 | } elseif ($country == 'E7') { |
489 | - $values['registration'] = $line[0]; |
|
490 | - $values['base'] = null; |
|
491 | - $values['owner'] = $line[4]; |
|
492 | - if ($line[5] == '') $values['date_first_reg'] = null; |
|
493 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
494 | - $values['cancel'] = ''; |
|
489 | + $values['registration'] = $line[0]; |
|
490 | + $values['base'] = null; |
|
491 | + $values['owner'] = $line[4]; |
|
492 | + if ($line[5] == '') $values['date_first_reg'] = null; |
|
493 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
494 | + $values['cancel'] = ''; |
|
495 | 495 | } elseif ($country == '8Q') { |
496 | - $values['registration'] = $line[0]; |
|
497 | - $values['base'] = null; |
|
498 | - $values['owner'] = $line[3]; |
|
499 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
500 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
501 | - $values['cancel'] = ''; |
|
496 | + $values['registration'] = $line[0]; |
|
497 | + $values['base'] = null; |
|
498 | + $values['owner'] = $line[3]; |
|
499 | + if ($line[7] == '') $values['date_first_reg'] = null; |
|
500 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
501 | + $values['cancel'] = ''; |
|
502 | 502 | } elseif ($country == 'ZK' || $country == 'OM' || $country == 'TF') { |
503 | - $values['registration'] = $line[0]; |
|
504 | - $values['base'] = null; |
|
505 | - $values['owner'] = $line[3]; |
|
506 | - $values['date_first_reg'] = null; |
|
507 | - $values['cancel'] = ''; |
|
503 | + $values['registration'] = $line[0]; |
|
504 | + $values['base'] = null; |
|
505 | + $values['owner'] = $line[3]; |
|
506 | + $values['date_first_reg'] = null; |
|
507 | + $values['cancel'] = ''; |
|
508 | 508 | } |
509 | 509 | if ($values['cancel'] == '' && $values['registration'] != null) { |
510 | 510 | $query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file); |
@@ -626,20 +626,20 @@ discard block |
||
626 | 626 | try { |
627 | 627 | $Connection = new Connection(); |
628 | 628 | $sth = $Connection->db->prepare($query); |
629 | - $sth->execute(); |
|
630 | - } catch(PDOException $e) { |
|
631 | - return "error : ".$e->getMessage(); |
|
632 | - } |
|
629 | + $sth->execute(); |
|
630 | + } catch(PDOException $e) { |
|
631 | + return "error : ".$e->getMessage(); |
|
632 | + } |
|
633 | 633 | |
634 | 634 | |
635 | 635 | $query = 'ALTER TABLE airport DROP INDEX icaoidx'; |
636 | 636 | try { |
637 | 637 | $Connection = new Connection(); |
638 | 638 | $sth = $Connection->db->prepare($query); |
639 | - $sth->execute(); |
|
640 | - } catch(PDOException $e) { |
|
641 | - return "error : ".$e->getMessage(); |
|
642 | - } |
|
639 | + $sth->execute(); |
|
640 | + } catch(PDOException $e) { |
|
641 | + return "error : ".$e->getMessage(); |
|
642 | + } |
|
643 | 643 | |
644 | 644 | $query_dest = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image_thumb`,`image`) |
645 | 645 | VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)"; |
@@ -705,10 +705,10 @@ discard block |
||
705 | 705 | try { |
706 | 706 | $Connection = new Connection(); |
707 | 707 | $sth = $Connection->db->prepare($query); |
708 | - $sth->execute(); |
|
709 | - } catch(PDOException $e) { |
|
710 | - return "error : ".$e->getMessage(); |
|
711 | - } |
|
708 | + $sth->execute(); |
|
709 | + } catch(PDOException $e) { |
|
710 | + return "error : ".$e->getMessage(); |
|
711 | + } |
|
712 | 712 | |
713 | 713 | |
714 | 714 | if ($globalDebug) echo "Insert Not available Airport...\n"; |
@@ -718,10 +718,10 @@ discard block |
||
718 | 718 | try { |
719 | 719 | $Connection = new Connection(); |
720 | 720 | $sth = $Connection->db->prepare($query); |
721 | - $sth->execute($query_values); |
|
722 | - } catch(PDOException $e) { |
|
723 | - return "error : ".$e->getMessage(); |
|
724 | - } |
|
721 | + $sth->execute($query_values); |
|
722 | + } catch(PDOException $e) { |
|
723 | + return "error : ".$e->getMessage(); |
|
724 | + } |
|
725 | 725 | $i++; |
726 | 726 | /* |
727 | 727 | $query = 'DELETE FROM airport WHERE airport_id IN (SELECT * FROM (SELECT min(a.airport_id) FROM airport a GROUP BY a.icao) x)'; |
@@ -835,7 +835,7 @@ discard block |
||
835 | 835 | |
836 | 836 | |
837 | 837 | |
838 | - return "success"; |
|
838 | + return "success"; |
|
839 | 839 | } |
840 | 840 | |
841 | 841 | public static function translation() { |
@@ -851,10 +851,10 @@ discard block |
||
851 | 851 | try { |
852 | 852 | $Connection = new Connection(); |
853 | 853 | $sth = $Connection->db->prepare($query); |
854 | - $sth->execute(array(':source' => 'translation.csv')); |
|
855 | - } catch(PDOException $e) { |
|
856 | - return "error : ".$e->getMessage(); |
|
857 | - } |
|
854 | + $sth->execute(array(':source' => 'translation.csv')); |
|
855 | + } catch(PDOException $e) { |
|
856 | + return "error : ".$e->getMessage(); |
|
857 | + } |
|
858 | 858 | |
859 | 859 | |
860 | 860 | //update_db::unzip($out_file); |
@@ -873,21 +873,21 @@ discard block |
||
873 | 873 | $data = $row; |
874 | 874 | $operator = $data[2]; |
875 | 875 | if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) { |
876 | - $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2)); |
|
877 | - //echo substr($operator, 0, 2)."\n";; |
|
878 | - if (count($airline_array) > 0) { |
|
876 | + $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2)); |
|
877 | + //echo substr($operator, 0, 2)."\n";; |
|
878 | + if (count($airline_array) > 0) { |
|
879 | 879 | //print_r($airline_array); |
880 | 880 | $operator = $airline_array[0]['icao'].substr($operator,2); |
881 | - } |
|
882 | - } |
|
881 | + } |
|
882 | + } |
|
883 | 883 | |
884 | 884 | $operator_correct = $data[3]; |
885 | 885 | if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) { |
886 | - $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2)); |
|
887 | - if (count($airline_array) > 0) { |
|
888 | - $operator_correct = $airline_array[0]['icao'].substr($operator_correct,2); |
|
889 | - } |
|
890 | - } |
|
886 | + $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2)); |
|
887 | + if (count($airline_array) > 0) { |
|
888 | + $operator_correct = $airline_array[0]['icao'].substr($operator_correct,2); |
|
889 | + } |
|
890 | + } |
|
891 | 891 | $query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)'; |
892 | 892 | try { |
893 | 893 | $sth = $Connection->db->prepare($query); |
@@ -901,7 +901,7 @@ discard block |
||
901 | 901 | //$Connection->db->commit(); |
902 | 902 | } |
903 | 903 | return ''; |
904 | - } |
|
904 | + } |
|
905 | 905 | |
906 | 906 | public static function translation_fam() { |
907 | 907 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
@@ -911,10 +911,10 @@ discard block |
||
911 | 911 | try { |
912 | 912 | $Connection = new Connection(); |
913 | 913 | $sth = $Connection->db->prepare($query); |
914 | - $sth->execute(array(':source' => 'website_fam')); |
|
915 | - } catch(PDOException $e) { |
|
916 | - return "error : ".$e->getMessage(); |
|
917 | - } |
|
914 | + $sth->execute(array(':source' => 'website_fam')); |
|
915 | + } catch(PDOException $e) { |
|
916 | + return "error : ".$e->getMessage(); |
|
917 | + } |
|
918 | 918 | |
919 | 919 | |
920 | 920 | //update_db::unzip($out_file); |
@@ -943,7 +943,7 @@ discard block |
||
943 | 943 | //$Connection->db->commit(); |
944 | 944 | } |
945 | 945 | return ''; |
946 | - } |
|
946 | + } |
|
947 | 947 | |
948 | 948 | /* |
949 | 949 | * This function use FAA public data. |
@@ -955,19 +955,19 @@ discard block |
||
955 | 955 | try { |
956 | 956 | $Connection = new Connection(); |
957 | 957 | $sth = $Connection->db->prepare($query); |
958 | - $sth->execute(array(':source' => 'website_faa')); |
|
959 | - } catch(PDOException $e) { |
|
960 | - return "error : ".$e->getMessage(); |
|
961 | - } |
|
958 | + $sth->execute(array(':source' => 'website_faa')); |
|
959 | + } catch(PDOException $e) { |
|
960 | + return "error : ".$e->getMessage(); |
|
961 | + } |
|
962 | 962 | |
963 | 963 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source = :source"; |
964 | 964 | try { |
965 | 965 | $Connection = new Connection(); |
966 | 966 | $sth = $Connection->db->prepare($query); |
967 | - $sth->execute(array(':source' => 'website_faa')); |
|
968 | - } catch(PDOException $e) { |
|
969 | - return "error : ".$e->getMessage(); |
|
970 | - } |
|
967 | + $sth->execute(array(':source' => 'website_faa')); |
|
968 | + } catch(PDOException $e) { |
|
969 | + return "error : ".$e->getMessage(); |
|
970 | + } |
|
971 | 971 | |
972 | 972 | $delimiter = ","; |
973 | 973 | $mfr = array(); |
@@ -1043,17 +1043,17 @@ discard block |
||
1043 | 1043 | } |
1044 | 1044 | print_r($mfr); |
1045 | 1045 | return ''; |
1046 | - } |
|
1046 | + } |
|
1047 | 1047 | public static function modes_fam() { |
1048 | 1048 | global $tmp_dir, $globalTransaction; |
1049 | 1049 | $query = "DELETE FROM aircraft_modes WHERE Source = '' OR Source = :source"; |
1050 | 1050 | try { |
1051 | 1051 | $Connection = new Connection(); |
1052 | 1052 | $sth = $Connection->db->prepare($query); |
1053 | - $sth->execute(array(':source' => 'website_fam')); |
|
1054 | - } catch(PDOException $e) { |
|
1055 | - return "error : ".$e->getMessage(); |
|
1056 | - } |
|
1053 | + $sth->execute(array(':source' => 'website_fam')); |
|
1054 | + } catch(PDOException $e) { |
|
1055 | + return "error : ".$e->getMessage(); |
|
1056 | + } |
|
1057 | 1057 | |
1058 | 1058 | |
1059 | 1059 | //update_db::unzip($out_file); |
@@ -1082,7 +1082,7 @@ discard block |
||
1082 | 1082 | if ($globalTransaction) $Connection->db->commit(); |
1083 | 1083 | } |
1084 | 1084 | return ''; |
1085 | - } |
|
1085 | + } |
|
1086 | 1086 | |
1087 | 1087 | public static function owner_fam() { |
1088 | 1088 | global $tmp_dir, $globalTransaction; |
@@ -1090,10 +1090,10 @@ discard block |
||
1090 | 1090 | try { |
1091 | 1091 | $Connection = new Connection(); |
1092 | 1092 | $sth = $Connection->db->prepare($query); |
1093 | - $sth->execute(array(':source' => 'website_fam')); |
|
1094 | - } catch(PDOException $e) { |
|
1095 | - return "error : ".$e->getMessage(); |
|
1096 | - } |
|
1093 | + $sth->execute(array(':source' => 'website_fam')); |
|
1094 | + } catch(PDOException $e) { |
|
1095 | + return "error : ".$e->getMessage(); |
|
1096 | + } |
|
1097 | 1097 | |
1098 | 1098 | $delimiter = "\t"; |
1099 | 1099 | $Connection = new Connection(); |
@@ -1119,7 +1119,7 @@ discard block |
||
1119 | 1119 | if ($globalTransaction) $Connection->db->commit(); |
1120 | 1120 | } |
1121 | 1121 | return ''; |
1122 | - } |
|
1122 | + } |
|
1123 | 1123 | |
1124 | 1124 | public static function routes_fam() { |
1125 | 1125 | global $tmp_dir, $globalTransaction; |
@@ -1127,10 +1127,10 @@ discard block |
||
1127 | 1127 | try { |
1128 | 1128 | $Connection = new Connection(); |
1129 | 1129 | $sth = $Connection->db->prepare($query); |
1130 | - $sth->execute(array(':source' => 'website_fam')); |
|
1131 | - } catch(PDOException $e) { |
|
1132 | - return "error : ".$e->getMessage(); |
|
1133 | - } |
|
1130 | + $sth->execute(array(':source' => 'website_fam')); |
|
1131 | + } catch(PDOException $e) { |
|
1132 | + return "error : ".$e->getMessage(); |
|
1133 | + } |
|
1134 | 1134 | |
1135 | 1135 | |
1136 | 1136 | //update_db::unzip($out_file); |
@@ -1159,7 +1159,7 @@ discard block |
||
1159 | 1159 | if ($globalTransaction) $Connection->db->commit(); |
1160 | 1160 | } |
1161 | 1161 | return ''; |
1162 | - } |
|
1162 | + } |
|
1163 | 1163 | |
1164 | 1164 | public static function banned_fam() { |
1165 | 1165 | global $tmp_dir, $globalTransaction; |
@@ -1193,7 +1193,7 @@ discard block |
||
1193 | 1193 | if ($globalTransaction) $Connection->db->commit(); |
1194 | 1194 | } |
1195 | 1195 | return ''; |
1196 | - } |
|
1196 | + } |
|
1197 | 1197 | |
1198 | 1198 | public static function tle($filename,$tletype) { |
1199 | 1199 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
@@ -1204,10 +1204,10 @@ discard block |
||
1204 | 1204 | try { |
1205 | 1205 | $Connection = new Connection(); |
1206 | 1206 | $sth = $Connection->db->prepare($query); |
1207 | - $sth->execute(array(':source' => $filename)); |
|
1208 | - } catch(PDOException $e) { |
|
1209 | - return "error : ".$e->getMessage(); |
|
1210 | - } |
|
1207 | + $sth->execute(array(':source' => $filename)); |
|
1208 | + } catch(PDOException $e) { |
|
1209 | + return "error : ".$e->getMessage(); |
|
1210 | + } |
|
1211 | 1211 | |
1212 | 1212 | $Connection = new Connection(); |
1213 | 1213 | if (($handle = fopen($filename, 'r')) !== FALSE) |
@@ -1242,54 +1242,54 @@ discard block |
||
1242 | 1242 | //$Connection->db->commit(); |
1243 | 1243 | } |
1244 | 1244 | return ''; |
1245 | - } |
|
1245 | + } |
|
1246 | 1246 | |
1247 | 1247 | /** |
1248 | - * Convert a HTML table to an array |
|
1249 | - * @param String $data HTML page |
|
1250 | - * @return Array array of the tables in HTML page |
|
1251 | - */ |
|
1252 | - private static function table2array($data) { |
|
1253 | - $html = str_get_html($data); |
|
1254 | - $tabledata=array(); |
|
1255 | - foreach($html->find('tr') as $element) |
|
1256 | - { |
|
1257 | - $td = array(); |
|
1258 | - foreach( $element->find('th') as $row) |
|
1259 | - { |
|
1260 | - $td [] = trim($row->plaintext); |
|
1261 | - } |
|
1262 | - $td=array_filter($td); |
|
1263 | - $tabledata[] = $td; |
|
1264 | - |
|
1265 | - $td = array(); |
|
1266 | - $tdi = array(); |
|
1267 | - foreach( $element->find('td') as $row) |
|
1268 | - { |
|
1269 | - $td [] = trim($row->plaintext); |
|
1270 | - $tdi [] = trim($row->innertext); |
|
1271 | - } |
|
1272 | - $td=array_filter($td); |
|
1273 | - $tdi=array_filter($tdi); |
|
1274 | - // $tabledata[]=array_merge($td,$tdi); |
|
1275 | - $tabledata[]=$td; |
|
1276 | - } |
|
1277 | - return(array_filter($tabledata)); |
|
1278 | - } |
|
1279 | - |
|
1280 | - /** |
|
1281 | - * Get data from form result |
|
1282 | - * @param String $url form URL |
|
1283 | - * @return String the result |
|
1284 | - */ |
|
1285 | - private static function getData($url) { |
|
1286 | - $ch = curl_init(); |
|
1287 | - curl_setopt($ch, CURLOPT_URL, $url); |
|
1288 | - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
1289 | - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
|
1290 | - 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'); |
|
1291 | - return curl_exec($ch); |
|
1292 | - } |
|
1248 | + * Convert a HTML table to an array |
|
1249 | + * @param String $data HTML page |
|
1250 | + * @return Array array of the tables in HTML page |
|
1251 | + */ |
|
1252 | + private static function table2array($data) { |
|
1253 | + $html = str_get_html($data); |
|
1254 | + $tabledata=array(); |
|
1255 | + foreach($html->find('tr') as $element) |
|
1256 | + { |
|
1257 | + $td = array(); |
|
1258 | + foreach( $element->find('th') as $row) |
|
1259 | + { |
|
1260 | + $td [] = trim($row->plaintext); |
|
1261 | + } |
|
1262 | + $td=array_filter($td); |
|
1263 | + $tabledata[] = $td; |
|
1264 | + |
|
1265 | + $td = array(); |
|
1266 | + $tdi = array(); |
|
1267 | + foreach( $element->find('td') as $row) |
|
1268 | + { |
|
1269 | + $td [] = trim($row->plaintext); |
|
1270 | + $tdi [] = trim($row->innertext); |
|
1271 | + } |
|
1272 | + $td=array_filter($td); |
|
1273 | + $tdi=array_filter($tdi); |
|
1274 | + // $tabledata[]=array_merge($td,$tdi); |
|
1275 | + $tabledata[]=$td; |
|
1276 | + } |
|
1277 | + return(array_filter($tabledata)); |
|
1278 | + } |
|
1279 | + |
|
1280 | + /** |
|
1281 | + * Get data from form result |
|
1282 | + * @param String $url form URL |
|
1283 | + * @return String the result |
|
1284 | + */ |
|
1285 | + private static function getData($url) { |
|
1286 | + $ch = curl_init(); |
|
1287 | + curl_setopt($ch, CURLOPT_URL, $url); |
|
1288 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
1289 | + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
|
1290 | + 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'); |
|
1291 | + return curl_exec($ch); |
|
1292 | + } |
|
1293 | 1293 | /* |
1294 | 1294 | public static function waypoints() { |
1295 | 1295 | $data = update_db::getData('http://www.fallingrain.com/world/FR/waypoints.html'); |
@@ -1372,7 +1372,7 @@ discard block |
||
1372 | 1372 | if ($globalTransaction) $Connection->db->commit(); |
1373 | 1373 | } |
1374 | 1374 | return ''; |
1375 | - } |
|
1375 | + } |
|
1376 | 1376 | |
1377 | 1377 | public static function ivao_airlines($filename) { |
1378 | 1378 | //require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
@@ -1382,10 +1382,10 @@ discard block |
||
1382 | 1382 | try { |
1383 | 1383 | $Connection = new Connection(); |
1384 | 1384 | $sth = $Connection->db->prepare($query); |
1385 | - $sth->execute(); |
|
1386 | - } catch(PDOException $e) { |
|
1387 | - return "error : ".$e->getMessage(); |
|
1388 | - } |
|
1385 | + $sth->execute(); |
|
1386 | + } catch(PDOException $e) { |
|
1387 | + return "error : ".$e->getMessage(); |
|
1388 | + } |
|
1389 | 1389 | |
1390 | 1390 | $header = NULL; |
1391 | 1391 | $delimiter = ':'; |
@@ -1409,7 +1409,7 @@ discard block |
||
1409 | 1409 | if ($globalTransaction) $Connection->db->commit(); |
1410 | 1410 | } |
1411 | 1411 | return ''; |
1412 | - } |
|
1412 | + } |
|
1413 | 1413 | |
1414 | 1414 | public static function update_airspace() { |
1415 | 1415 | global $tmp_dir, $globalDBdriver; |
@@ -1419,11 +1419,11 @@ discard block |
||
1419 | 1419 | $query = 'DROP TABLE airspace'; |
1420 | 1420 | try { |
1421 | 1421 | $sth = $Connection->db->prepare($query); |
1422 | - $sth->execute(); |
|
1423 | - } catch(PDOException $e) { |
|
1422 | + $sth->execute(); |
|
1423 | + } catch(PDOException $e) { |
|
1424 | 1424 | return "error : ".$e->getMessage(); |
1425 | - } |
|
1426 | - } |
|
1425 | + } |
|
1426 | + } |
|
1427 | 1427 | |
1428 | 1428 | |
1429 | 1429 | if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
@@ -1478,10 +1478,10 @@ discard block |
||
1478 | 1478 | $query = 'DROP TABLE countries'; |
1479 | 1479 | try { |
1480 | 1480 | $sth = $Connection->db->prepare($query); |
1481 | - $sth->execute(); |
|
1482 | - } catch(PDOException $e) { |
|
1483 | - echo "error : ".$e->getMessage(); |
|
1484 | - } |
|
1481 | + $sth->execute(); |
|
1482 | + } catch(PDOException $e) { |
|
1483 | + echo "error : ".$e->getMessage(); |
|
1484 | + } |
|
1485 | 1485 | } |
1486 | 1486 | if ($globalDBdriver == 'mysql') { |
1487 | 1487 | update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql'); |
@@ -1956,11 +1956,11 @@ discard block |
||
1956 | 1956 | $query = 'DROP TABLE airspace'; |
1957 | 1957 | try { |
1958 | 1958 | $sth = $Connection->db->prepare($query); |
1959 | - $sth->execute(); |
|
1960 | - } catch(PDOException $e) { |
|
1959 | + $sth->execute(); |
|
1960 | + } catch(PDOException $e) { |
|
1961 | 1961 | return "error : ".$e->getMessage(); |
1962 | - } |
|
1963 | - } |
|
1962 | + } |
|
1963 | + } |
|
1964 | 1964 | $error = create_db::import_file($tmp_dir.'airspace.sql'); |
1965 | 1965 | update_db::insert_airspace_version($airspace_md5); |
1966 | 1966 | } else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed."; |
@@ -2080,12 +2080,12 @@ discard block |
||
2080 | 2080 | echo $data; |
2081 | 2081 | */ |
2082 | 2082 | if (file_exists($tmp_dir.'aircrafts.html')) { |
2083 | - //var_dump(file_get_html($tmp_dir.'aircrafts.html')); |
|
2084 | - $fh = fopen($tmp_dir.'aircrafts.html',"r"); |
|
2085 | - $result = fread($fh,100000000); |
|
2086 | - //echo $result; |
|
2087 | - //var_dump(str_get_html($result)); |
|
2088 | - //print_r(self::table2array($result)); |
|
2083 | + //var_dump(file_get_html($tmp_dir.'aircrafts.html')); |
|
2084 | + $fh = fopen($tmp_dir.'aircrafts.html',"r"); |
|
2085 | + $result = fread($fh,100000000); |
|
2086 | + //echo $result; |
|
2087 | + //var_dump(str_get_html($result)); |
|
2088 | + //print_r(self::table2array($result)); |
|
2089 | 2089 | } |
2090 | 2090 | |
2091 | 2091 | } |
@@ -2099,10 +2099,10 @@ discard block |
||
2099 | 2099 | try { |
2100 | 2100 | $Connection = new Connection(); |
2101 | 2101 | $sth = $Connection->db->prepare($query); |
2102 | - $sth->execute(); |
|
2103 | - } catch(PDOException $e) { |
|
2104 | - return "error : ".$e->getMessage(); |
|
2105 | - } |
|
2102 | + $sth->execute(); |
|
2103 | + } catch(PDOException $e) { |
|
2104 | + return "error : ".$e->getMessage(); |
|
2105 | + } |
|
2106 | 2106 | |
2107 | 2107 | $error = ''; |
2108 | 2108 | if ($globalDebug) echo "Notam : Download..."; |
@@ -2158,8 +2158,8 @@ discard block |
||
2158 | 2158 | $data['date_end'] = date("Y-m-d H:i:s",strtotime($to)); |
2159 | 2159 | $data['permanent'] = 0; |
2160 | 2160 | } else { |
2161 | - $data['date_end'] = NULL; |
|
2162 | - $data['permanent'] = 1; |
|
2161 | + $data['date_end'] = NULL; |
|
2162 | + $data['permanent'] = 1; |
|
2163 | 2163 | } |
2164 | 2164 | $data['full_notam'] = $notam['title'].'<br>'.$notam['description']; |
2165 | 2165 | $NOTAM = new NOTAM(); |
@@ -2218,13 +2218,13 @@ discard block |
||
2218 | 2218 | try { |
2219 | 2219 | $Connection = new Connection(); |
2220 | 2220 | $sth = $Connection->db->prepare($query); |
2221 | - $sth->execute(); |
|
2222 | - } catch(PDOException $e) { |
|
2223 | - return "error : ".$e->getMessage(); |
|
2224 | - } |
|
2225 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2226 | - if ($row['nb'] > 0) return false; |
|
2227 | - else return true; |
|
2221 | + $sth->execute(); |
|
2222 | + } catch(PDOException $e) { |
|
2223 | + return "error : ".$e->getMessage(); |
|
2224 | + } |
|
2225 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2226 | + if ($row['nb'] > 0) return false; |
|
2227 | + else return true; |
|
2228 | 2228 | } |
2229 | 2229 | |
2230 | 2230 | public static function insert_last_update() { |
@@ -2233,10 +2233,10 @@ discard block |
||
2233 | 2233 | try { |
2234 | 2234 | $Connection = new Connection(); |
2235 | 2235 | $sth = $Connection->db->prepare($query); |
2236 | - $sth->execute(); |
|
2237 | - } catch(PDOException $e) { |
|
2238 | - return "error : ".$e->getMessage(); |
|
2239 | - } |
|
2236 | + $sth->execute(); |
|
2237 | + } catch(PDOException $e) { |
|
2238 | + return "error : ".$e->getMessage(); |
|
2239 | + } |
|
2240 | 2240 | } |
2241 | 2241 | |
2242 | 2242 | public static function check_airspace_version($version) { |
@@ -2244,13 +2244,13 @@ discard block |
||
2244 | 2244 | try { |
2245 | 2245 | $Connection = new Connection(); |
2246 | 2246 | $sth = $Connection->db->prepare($query); |
2247 | - $sth->execute(array(':version' => $version)); |
|
2248 | - } catch(PDOException $e) { |
|
2249 | - return "error : ".$e->getMessage(); |
|
2250 | - } |
|
2251 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2252 | - if ($row['nb'] > 0) return true; |
|
2253 | - else return false; |
|
2247 | + $sth->execute(array(':version' => $version)); |
|
2248 | + } catch(PDOException $e) { |
|
2249 | + return "error : ".$e->getMessage(); |
|
2250 | + } |
|
2251 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2252 | + if ($row['nb'] > 0) return true; |
|
2253 | + else return false; |
|
2254 | 2254 | } |
2255 | 2255 | |
2256 | 2256 | |
@@ -2260,10 +2260,10 @@ discard block |
||
2260 | 2260 | try { |
2261 | 2261 | $Connection = new Connection(); |
2262 | 2262 | $sth = $Connection->db->prepare($query); |
2263 | - $sth->execute(array(':version' => $version)); |
|
2264 | - } catch(PDOException $e) { |
|
2265 | - return "error : ".$e->getMessage(); |
|
2266 | - } |
|
2263 | + $sth->execute(array(':version' => $version)); |
|
2264 | + } catch(PDOException $e) { |
|
2265 | + return "error : ".$e->getMessage(); |
|
2266 | + } |
|
2267 | 2267 | } |
2268 | 2268 | |
2269 | 2269 | public static function check_last_notam_update() { |
@@ -2276,13 +2276,13 @@ discard block |
||
2276 | 2276 | try { |
2277 | 2277 | $Connection = new Connection(); |
2278 | 2278 | $sth = $Connection->db->prepare($query); |
2279 | - $sth->execute(); |
|
2280 | - } catch(PDOException $e) { |
|
2281 | - return "error : ".$e->getMessage(); |
|
2282 | - } |
|
2283 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2284 | - if ($row['nb'] > 0) return false; |
|
2285 | - else return true; |
|
2279 | + $sth->execute(); |
|
2280 | + } catch(PDOException $e) { |
|
2281 | + return "error : ".$e->getMessage(); |
|
2282 | + } |
|
2283 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2284 | + if ($row['nb'] > 0) return false; |
|
2285 | + else return true; |
|
2286 | 2286 | } |
2287 | 2287 | |
2288 | 2288 | public static function insert_last_notam_update() { |
@@ -2291,10 +2291,10 @@ discard block |
||
2291 | 2291 | try { |
2292 | 2292 | $Connection = new Connection(); |
2293 | 2293 | $sth = $Connection->db->prepare($query); |
2294 | - $sth->execute(); |
|
2295 | - } catch(PDOException $e) { |
|
2296 | - return "error : ".$e->getMessage(); |
|
2297 | - } |
|
2294 | + $sth->execute(); |
|
2295 | + } catch(PDOException $e) { |
|
2296 | + return "error : ".$e->getMessage(); |
|
2297 | + } |
|
2298 | 2298 | } |
2299 | 2299 | public static function check_last_airspace_update() { |
2300 | 2300 | global $globalDBdriver; |
@@ -2306,13 +2306,13 @@ discard block |
||
2306 | 2306 | try { |
2307 | 2307 | $Connection = new Connection(); |
2308 | 2308 | $sth = $Connection->db->prepare($query); |
2309 | - $sth->execute(); |
|
2310 | - } catch(PDOException $e) { |
|
2311 | - return "error : ".$e->getMessage(); |
|
2312 | - } |
|
2313 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2314 | - if ($row['nb'] > 0) return false; |
|
2315 | - else return true; |
|
2309 | + $sth->execute(); |
|
2310 | + } catch(PDOException $e) { |
|
2311 | + return "error : ".$e->getMessage(); |
|
2312 | + } |
|
2313 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2314 | + if ($row['nb'] > 0) return false; |
|
2315 | + else return true; |
|
2316 | 2316 | } |
2317 | 2317 | |
2318 | 2318 | public static function insert_last_airspace_update() { |
@@ -2321,10 +2321,10 @@ discard block |
||
2321 | 2321 | try { |
2322 | 2322 | $Connection = new Connection(); |
2323 | 2323 | $sth = $Connection->db->prepare($query); |
2324 | - $sth->execute(); |
|
2325 | - } catch(PDOException $e) { |
|
2326 | - return "error : ".$e->getMessage(); |
|
2327 | - } |
|
2324 | + $sth->execute(); |
|
2325 | + } catch(PDOException $e) { |
|
2326 | + return "error : ".$e->getMessage(); |
|
2327 | + } |
|
2328 | 2328 | } |
2329 | 2329 | |
2330 | 2330 | public static function check_last_owner_update() { |
@@ -2337,13 +2337,13 @@ discard block |
||
2337 | 2337 | try { |
2338 | 2338 | $Connection = new Connection(); |
2339 | 2339 | $sth = $Connection->db->prepare($query); |
2340 | - $sth->execute(); |
|
2341 | - } catch(PDOException $e) { |
|
2342 | - return "error : ".$e->getMessage(); |
|
2343 | - } |
|
2344 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2345 | - if ($row['nb'] > 0) return false; |
|
2346 | - else return true; |
|
2340 | + $sth->execute(); |
|
2341 | + } catch(PDOException $e) { |
|
2342 | + return "error : ".$e->getMessage(); |
|
2343 | + } |
|
2344 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2345 | + if ($row['nb'] > 0) return false; |
|
2346 | + else return true; |
|
2347 | 2347 | } |
2348 | 2348 | |
2349 | 2349 | public static function insert_last_owner_update() { |
@@ -2352,10 +2352,10 @@ discard block |
||
2352 | 2352 | try { |
2353 | 2353 | $Connection = new Connection(); |
2354 | 2354 | $sth = $Connection->db->prepare($query); |
2355 | - $sth->execute(); |
|
2356 | - } catch(PDOException $e) { |
|
2357 | - return "error : ".$e->getMessage(); |
|
2358 | - } |
|
2355 | + $sth->execute(); |
|
2356 | + } catch(PDOException $e) { |
|
2357 | + return "error : ".$e->getMessage(); |
|
2358 | + } |
|
2359 | 2359 | } |
2360 | 2360 | public static function check_last_schedules_update() { |
2361 | 2361 | global $globalDBdriver; |
@@ -2367,13 +2367,13 @@ discard block |
||
2367 | 2367 | try { |
2368 | 2368 | $Connection = new Connection(); |
2369 | 2369 | $sth = $Connection->db->prepare($query); |
2370 | - $sth->execute(); |
|
2371 | - } catch(PDOException $e) { |
|
2372 | - return "error : ".$e->getMessage(); |
|
2373 | - } |
|
2374 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2375 | - if ($row['nb'] > 0) return false; |
|
2376 | - else return true; |
|
2370 | + $sth->execute(); |
|
2371 | + } catch(PDOException $e) { |
|
2372 | + return "error : ".$e->getMessage(); |
|
2373 | + } |
|
2374 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2375 | + if ($row['nb'] > 0) return false; |
|
2376 | + else return true; |
|
2377 | 2377 | } |
2378 | 2378 | |
2379 | 2379 | public static function insert_last_schedules_update() { |
@@ -2382,10 +2382,10 @@ discard block |
||
2382 | 2382 | try { |
2383 | 2383 | $Connection = new Connection(); |
2384 | 2384 | $sth = $Connection->db->prepare($query); |
2385 | - $sth->execute(); |
|
2386 | - } catch(PDOException $e) { |
|
2387 | - return "error : ".$e->getMessage(); |
|
2388 | - } |
|
2385 | + $sth->execute(); |
|
2386 | + } catch(PDOException $e) { |
|
2387 | + return "error : ".$e->getMessage(); |
|
2388 | + } |
|
2389 | 2389 | } |
2390 | 2390 | public static function check_last_tle_update() { |
2391 | 2391 | global $globalDBdriver; |
@@ -2397,13 +2397,13 @@ discard block |
||
2397 | 2397 | try { |
2398 | 2398 | $Connection = new Connection(); |
2399 | 2399 | $sth = $Connection->db->prepare($query); |
2400 | - $sth->execute(); |
|
2401 | - } catch(PDOException $e) { |
|
2402 | - return "error : ".$e->getMessage(); |
|
2403 | - } |
|
2404 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2405 | - if ($row['nb'] > 0) return false; |
|
2406 | - else return true; |
|
2400 | + $sth->execute(); |
|
2401 | + } catch(PDOException $e) { |
|
2402 | + return "error : ".$e->getMessage(); |
|
2403 | + } |
|
2404 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2405 | + if ($row['nb'] > 0) return false; |
|
2406 | + else return true; |
|
2407 | 2407 | } |
2408 | 2408 | |
2409 | 2409 | public static function insert_last_tle_update() { |
@@ -2412,10 +2412,10 @@ discard block |
||
2412 | 2412 | try { |
2413 | 2413 | $Connection = new Connection(); |
2414 | 2414 | $sth = $Connection->db->prepare($query); |
2415 | - $sth->execute(); |
|
2416 | - } catch(PDOException $e) { |
|
2417 | - return "error : ".$e->getMessage(); |
|
2418 | - } |
|
2415 | + $sth->execute(); |
|
2416 | + } catch(PDOException $e) { |
|
2417 | + return "error : ".$e->getMessage(); |
|
2418 | + } |
|
2419 | 2419 | } |
2420 | 2420 | public static function delete_duplicatemodes() { |
2421 | 2421 | global $globalDBdriver; |
@@ -2427,10 +2427,10 @@ discard block |
||
2427 | 2427 | try { |
2428 | 2428 | $Connection = new Connection(); |
2429 | 2429 | $sth = $Connection->db->prepare($query); |
2430 | - $sth->execute(); |
|
2431 | - } catch(PDOException $e) { |
|
2432 | - return "error : ".$e->getMessage(); |
|
2433 | - } |
|
2430 | + $sth->execute(); |
|
2431 | + } catch(PDOException $e) { |
|
2432 | + return "error : ".$e->getMessage(); |
|
2433 | + } |
|
2434 | 2434 | } |
2435 | 2435 | public static function delete_duplicateowner() { |
2436 | 2436 | global $globalDBdriver; |
@@ -2442,10 +2442,10 @@ discard block |
||
2442 | 2442 | try { |
2443 | 2443 | $Connection = new Connection(); |
2444 | 2444 | $sth = $Connection->db->prepare($query); |
2445 | - $sth->execute(); |
|
2446 | - } catch(PDOException $e) { |
|
2447 | - return "error : ".$e->getMessage(); |
|
2448 | - } |
|
2445 | + $sth->execute(); |
|
2446 | + } catch(PDOException $e) { |
|
2447 | + return "error : ".$e->getMessage(); |
|
2448 | + } |
|
2449 | 2449 | } |
2450 | 2450 | |
2451 | 2451 | 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 | |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | $Connection = new Connection(); |
252 | 252 | $sth = $Connection->db->prepare($query); |
253 | 253 | $sth->execute(array(':source' => $database_file)); |
254 | - } catch(PDOException $e) { |
|
254 | + } catch (PDOException $e) { |
|
255 | 255 | return "error : ".$e->getMessage(); |
256 | 256 | } |
257 | 257 | return ''; |
@@ -266,11 +266,11 @@ discard block |
||
266 | 266 | $Connection = new Connection(); |
267 | 267 | $sth = $Connection->db->prepare($query); |
268 | 268 | $sth->execute(array(':source' => $database_file)); |
269 | - } catch(PDOException $e) { |
|
269 | + } catch (PDOException $e) { |
|
270 | 270 | return "error : ".$e->getMessage(); |
271 | 271 | } |
272 | 272 | |
273 | - if ($fh = fopen($database_file,"r")) { |
|
273 | + if ($fh = fopen($database_file, "r")) { |
|
274 | 274 | //$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)'; |
275 | 275 | $query_dest = 'INSERT INTO aircraft_modes (ModeS,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:Registration,:ICAOTypeCode,:source)'; |
276 | 276 | |
@@ -280,13 +280,13 @@ discard block |
||
280 | 280 | if ($globalTransaction) $Connection->db->beginTransaction(); |
281 | 281 | while (!feof($fh)) { |
282 | 282 | $values = array(); |
283 | - $line = $Common->hex2str(fgets($fh,9999)); |
|
283 | + $line = $Common->hex2str(fgets($fh, 9999)); |
|
284 | 284 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
285 | - $values['ModeS'] = substr($line,0,6); |
|
286 | - $values['Registration'] = trim(substr($line,69,6)); |
|
287 | - $aircraft_name = trim(substr($line,48,6)); |
|
285 | + $values['ModeS'] = substr($line, 0, 6); |
|
286 | + $values['Registration'] = trim(substr($line, 69, 6)); |
|
287 | + $aircraft_name = trim(substr($line, 48, 6)); |
|
288 | 288 | // Check if we can find ICAO, else set it to GLID |
289 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
289 | + $aircraft_name_split = explode(' ', $aircraft_name); |
|
290 | 290 | $search_more = ''; |
291 | 291 | if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
292 | 292 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
@@ -298,20 +298,20 @@ discard block |
||
298 | 298 | if (isset($result['icao']) && $result['icao'] != '') { |
299 | 299 | $values['ICAOTypeCode'] = $result['icao']; |
300 | 300 | } |
301 | - } catch(PDOException $e) { |
|
301 | + } catch (PDOException $e) { |
|
302 | 302 | return "error : ".$e->getMessage(); |
303 | 303 | } |
304 | 304 | if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID'; |
305 | 305 | // Add data to db |
306 | 306 | if ($values['Registration'] != '' && $values['Registration'] != '0000') { |
307 | 307 | //$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']); |
308 | - $query_dest_values = array(':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file); |
|
308 | + $query_dest_values = array(':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file); |
|
309 | 309 | //print_r($query_dest_values); |
310 | 310 | $sth_dest->execute($query_dest_values); |
311 | 311 | } |
312 | 312 | } |
313 | 313 | if ($globalTransaction) $Connection->db->commit(); |
314 | - } catch(PDOException $e) { |
|
314 | + } catch (PDOException $e) { |
|
315 | 315 | return "error : ".$e->getMessage(); |
316 | 316 | } |
317 | 317 | } |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | $Connection = new Connection(); |
322 | 322 | $sth = $Connection->db->prepare($query); |
323 | 323 | $sth->execute(array(':source' => $database_file)); |
324 | - } catch(PDOException $e) { |
|
324 | + } catch (PDOException $e) { |
|
325 | 325 | return "error : ".$e->getMessage(); |
326 | 326 | } |
327 | 327 | return ''; |
@@ -335,11 +335,11 @@ discard block |
||
335 | 335 | $Connection = new Connection(); |
336 | 336 | $sth = $Connection->db->prepare($query); |
337 | 337 | $sth->execute(array(':source' => $database_file)); |
338 | - } catch(PDOException $e) { |
|
338 | + } catch (PDOException $e) { |
|
339 | 339 | return "error : ".$e->getMessage(); |
340 | 340 | } |
341 | 341 | |
342 | - if ($fh = fopen($database_file,"r")) { |
|
342 | + if ($fh = fopen($database_file, "r")) { |
|
343 | 343 | //$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)'; |
344 | 344 | $query_dest = 'INSERT INTO aircraft_modes (LastModified,ModeS,Registration,ICAOTypeCode,Source) VALUES (:lastmodified,:ModeS,:Registration,:ICAOTypeCode,:source)'; |
345 | 345 | |
@@ -347,9 +347,9 @@ discard block |
||
347 | 347 | $sth_dest = $Connection->db->prepare($query_dest); |
348 | 348 | try { |
349 | 349 | if ($globalTransaction) $Connection->db->beginTransaction(); |
350 | - $tmp = fgetcsv($fh,9999,',',"'"); |
|
350 | + $tmp = fgetcsv($fh, 9999, ',', "'"); |
|
351 | 351 | while (!feof($fh)) { |
352 | - $line = fgetcsv($fh,9999,',',"'"); |
|
352 | + $line = fgetcsv($fh, 9999, ',', "'"); |
|
353 | 353 | |
354 | 354 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
355 | 355 | //print_r($line); |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | $values['Registration'] = $line[3]; |
358 | 358 | $aircraft_name = $line[2]; |
359 | 359 | // Check if we can find ICAO, else set it to GLID |
360 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
360 | + $aircraft_name_split = explode(' ', $aircraft_name); |
|
361 | 361 | $search_more = ''; |
362 | 362 | if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
363 | 363 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
@@ -366,20 +366,20 @@ discard block |
||
366 | 366 | $sth_search->execute(); |
367 | 367 | $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
368 | 368 | if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
369 | - } catch(PDOException $e) { |
|
369 | + } catch (PDOException $e) { |
|
370 | 370 | return "error : ".$e->getMessage(); |
371 | 371 | } |
372 | 372 | //if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID'; |
373 | 373 | // Add data to db |
374 | 374 | if ($values['Registration'] != '' && $values['Registration'] != '0000' && $values['ICAOTypeCode'] != '') { |
375 | 375 | //$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']); |
376 | - $query_dest_values = array(':lastmodified' => date('Y-m-d H:m:s'),':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file); |
|
376 | + $query_dest_values = array(':lastmodified' => date('Y-m-d H:m:s'), ':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file); |
|
377 | 377 | //print_r($query_dest_values); |
378 | 378 | $sth_dest->execute($query_dest_values); |
379 | 379 | } |
380 | 380 | } |
381 | 381 | if ($globalTransaction) $Connection->db->commit(); |
382 | - } catch(PDOException $e) { |
|
382 | + } catch (PDOException $e) { |
|
383 | 383 | return "error : ".$e->getMessage(); |
384 | 384 | } |
385 | 385 | } |
@@ -389,13 +389,13 @@ discard block |
||
389 | 389 | $Connection = new Connection(); |
390 | 390 | $sth = $Connection->db->prepare($query); |
391 | 391 | $sth->execute(array(':source' => $database_file)); |
392 | - } catch(PDOException $e) { |
|
392 | + } catch (PDOException $e) { |
|
393 | 393 | return "error : ".$e->getMessage(); |
394 | 394 | } |
395 | 395 | return ''; |
396 | 396 | } |
397 | 397 | |
398 | - public static function retrieve_owner($database_file,$country = 'F') { |
|
398 | + public static function retrieve_owner($database_file, $country = 'F') { |
|
399 | 399 | global $globalTransaction; |
400 | 400 | //$query = 'TRUNCATE TABLE aircraft_modes'; |
401 | 401 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source"; |
@@ -403,11 +403,11 @@ discard block |
||
403 | 403 | $Connection = new Connection(); |
404 | 404 | $sth = $Connection->db->prepare($query); |
405 | 405 | $sth->execute(array(':source' => $database_file)); |
406 | - } catch(PDOException $e) { |
|
406 | + } catch (PDOException $e) { |
|
407 | 407 | return "error : ".$e->getMessage(); |
408 | 408 | } |
409 | 409 | |
410 | - if ($fh = fopen($database_file,"r")) { |
|
410 | + if ($fh = fopen($database_file, "r")) { |
|
411 | 411 | //$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)'; |
412 | 412 | $query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)'; |
413 | 413 | |
@@ -415,9 +415,9 @@ discard block |
||
415 | 415 | $sth_dest = $Connection->db->prepare($query_dest); |
416 | 416 | try { |
417 | 417 | if ($globalTransaction) $Connection->db->beginTransaction(); |
418 | - $tmp = fgetcsv($fh,9999,',','"'); |
|
418 | + $tmp = fgetcsv($fh, 9999, ',', '"'); |
|
419 | 419 | while (!feof($fh)) { |
420 | - $line = fgetcsv($fh,9999,',','"'); |
|
420 | + $line = fgetcsv($fh, 9999, ',', '"'); |
|
421 | 421 | $values = array(); |
422 | 422 | //print_r($line); |
423 | 423 | if ($country == 'F') { |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | $values['base'] = $line[4]; |
426 | 426 | $values['owner'] = $line[5]; |
427 | 427 | if ($line[6] == '') $values['date_first_reg'] = null; |
428 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
428 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6])); |
|
429 | 429 | $values['cancel'] = $line[7]; |
430 | 430 | } elseif ($country == 'EI') { |
431 | 431 | // TODO : add modeS & reg to aircraft_modes |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | $values['base'] = $line[3]; |
434 | 434 | $values['owner'] = $line[2]; |
435 | 435 | if ($line[1] == '') $values['date_first_reg'] = null; |
436 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
436 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[1])); |
|
437 | 437 | $values['cancel'] = ''; |
438 | 438 | } elseif ($country == 'HB') { |
439 | 439 | // TODO : add modeS & reg to aircraft_modes |
@@ -448,7 +448,7 @@ discard block |
||
448 | 448 | $values['base'] = null; |
449 | 449 | $values['owner'] = $line[5]; |
450 | 450 | if ($line[18] == '') $values['date_first_reg'] = null; |
451 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
451 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[18])); |
|
452 | 452 | $values['cancel'] = ''; |
453 | 453 | } elseif ($country == 'VH') { |
454 | 454 | // TODO : add modeS & reg to aircraft_modes |
@@ -456,7 +456,7 @@ discard block |
||
456 | 456 | $values['base'] = null; |
457 | 457 | $values['owner'] = $line[12]; |
458 | 458 | if ($line[28] == '') $values['date_first_reg'] = null; |
459 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
459 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[28])); |
|
460 | 460 | |
461 | 461 | $values['cancel'] = $line[39]; |
462 | 462 | } elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { |
@@ -476,28 +476,28 @@ discard block |
||
476 | 476 | $values['base'] = null; |
477 | 477 | $values['owner'] = $line[8]; |
478 | 478 | if ($line[7] == '') $values['date_first_reg'] = null; |
479 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
479 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7])); |
|
480 | 480 | $values['cancel'] = ''; |
481 | 481 | } elseif ($country == 'PP') { |
482 | 482 | $values['registration'] = $line[0]; |
483 | 483 | $values['base'] = null; |
484 | 484 | $values['owner'] = $line[4]; |
485 | 485 | if ($line[6] == '') $values['date_first_reg'] = null; |
486 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
486 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6])); |
|
487 | 487 | $values['cancel'] = $line[7]; |
488 | 488 | } elseif ($country == 'E7') { |
489 | 489 | $values['registration'] = $line[0]; |
490 | 490 | $values['base'] = null; |
491 | 491 | $values['owner'] = $line[4]; |
492 | 492 | if ($line[5] == '') $values['date_first_reg'] = null; |
493 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
493 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[5])); |
|
494 | 494 | $values['cancel'] = ''; |
495 | 495 | } elseif ($country == '8Q') { |
496 | 496 | $values['registration'] = $line[0]; |
497 | 497 | $values['base'] = null; |
498 | 498 | $values['owner'] = $line[3]; |
499 | 499 | if ($line[7] == '') $values['date_first_reg'] = null; |
500 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
500 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7])); |
|
501 | 501 | $values['cancel'] = ''; |
502 | 502 | } elseif ($country == 'ZK' || $country == 'OM' || $country == 'TF') { |
503 | 503 | $values['registration'] = $line[0]; |
@@ -507,12 +507,12 @@ discard block |
||
507 | 507 | $values['cancel'] = ''; |
508 | 508 | } |
509 | 509 | if ($values['cancel'] == '' && $values['registration'] != null) { |
510 | - $query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file); |
|
510 | + $query_dest_values = array(':registration' => $values['registration'], ':base' => $values['base'], ':date_first_reg' => $values['date_first_reg'], ':owner' => $values['owner'], ':source' => $database_file); |
|
511 | 511 | $sth_dest->execute($query_dest_values); |
512 | 512 | } |
513 | 513 | } |
514 | 514 | if ($globalTransaction) $Connection->db->commit(); |
515 | - } catch(PDOException $e) { |
|
515 | + } catch (PDOException $e) { |
|
516 | 516 | return "error : ".$e->getMessage(); |
517 | 517 | } |
518 | 518 | } |
@@ -627,7 +627,7 @@ discard block |
||
627 | 627 | $Connection = new Connection(); |
628 | 628 | $sth = $Connection->db->prepare($query); |
629 | 629 | $sth->execute(); |
630 | - } catch(PDOException $e) { |
|
630 | + } catch (PDOException $e) { |
|
631 | 631 | return "error : ".$e->getMessage(); |
632 | 632 | } |
633 | 633 | |
@@ -637,7 +637,7 @@ discard block |
||
637 | 637 | $Connection = new Connection(); |
638 | 638 | $sth = $Connection->db->prepare($query); |
639 | 639 | $sth->execute(); |
640 | - } catch(PDOException $e) { |
|
640 | + } catch (PDOException $e) { |
|
641 | 641 | return "error : ".$e->getMessage(); |
642 | 642 | } |
643 | 643 | |
@@ -648,7 +648,7 @@ discard block |
||
648 | 648 | if ($globalTransaction) $Connection->db->beginTransaction(); |
649 | 649 | |
650 | 650 | $i = 0; |
651 | - while($row = sparql_fetch_array($result)) |
|
651 | + while ($row = sparql_fetch_array($result)) |
|
652 | 652 | { |
653 | 653 | if ($i >= 1) { |
654 | 654 | //print_r($row); |
@@ -668,31 +668,31 @@ discard block |
||
668 | 668 | $row['image'] = ''; |
669 | 669 | $row['image_thumb'] = ''; |
670 | 670 | } else { |
671 | - $image = str_replace(' ','_',$row['image']); |
|
671 | + $image = str_replace(' ', '_', $row['image']); |
|
672 | 672 | $digest = md5($image); |
673 | - $folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image . '/220px-' . $image; |
|
674 | - $row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/' . $folder; |
|
675 | - $folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image; |
|
676 | - $row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/' . $folder; |
|
673 | + $folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image.'/220px-'.$image; |
|
674 | + $row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/'.$folder; |
|
675 | + $folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image; |
|
676 | + $row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/'.$folder; |
|
677 | 677 | } |
678 | 678 | |
679 | - $country = explode('-',$row['country']); |
|
679 | + $country = explode('-', $row['country']); |
|
680 | 680 | $row['country'] = $country[0]; |
681 | 681 | |
682 | 682 | $row['type'] = trim($row['type']); |
683 | - 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 | + 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'])) { |
|
684 | 684 | $row['type'] = 'Military'; |
685 | 685 | } 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') { |
686 | 686 | $row['type'] = 'small_airport'; |
687 | 687 | } |
688 | 688 | |
689 | - $row['city'] = urldecode(str_replace('_',' ',str_replace('http://dbpedia.org/resource/','',$row['city']))); |
|
690 | - $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']); |
|
689 | + $row['city'] = urldecode(str_replace('_', ' ', str_replace('http://dbpedia.org/resource/', '', $row['city']))); |
|
690 | + $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']); |
|
691 | 691 | //print_r($query_dest_values); |
692 | 692 | |
693 | 693 | try { |
694 | 694 | $sth_dest->execute($query_dest_values); |
695 | - } catch(PDOException $e) { |
|
695 | + } catch (PDOException $e) { |
|
696 | 696 | return "error : ".$e->getMessage(); |
697 | 697 | } |
698 | 698 | } |
@@ -706,7 +706,7 @@ discard block |
||
706 | 706 | $Connection = new Connection(); |
707 | 707 | $sth = $Connection->db->prepare($query); |
708 | 708 | $sth->execute(); |
709 | - } catch(PDOException $e) { |
|
709 | + } catch (PDOException $e) { |
|
710 | 710 | return "error : ".$e->getMessage(); |
711 | 711 | } |
712 | 712 | |
@@ -714,12 +714,12 @@ discard block |
||
714 | 714 | if ($globalDebug) echo "Insert Not available Airport...\n"; |
715 | 715 | $query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image`,`image_thumb`) |
716 | 716 | VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image, :image_thumb)"; |
717 | - $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 | + $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' => ''); |
|
718 | 718 | try { |
719 | 719 | $Connection = new Connection(); |
720 | 720 | $sth = $Connection->db->prepare($query); |
721 | 721 | $sth->execute($query_values); |
722 | - } catch(PDOException $e) { |
|
722 | + } catch (PDOException $e) { |
|
723 | 723 | return "error : ".$e->getMessage(); |
724 | 724 | } |
725 | 725 | $i++; |
@@ -737,7 +737,7 @@ discard block |
||
737 | 737 | echo "Download data from ourairports.com...\n"; |
738 | 738 | $delimiter = ','; |
739 | 739 | $out_file = $tmp_dir.'airports.csv'; |
740 | - update_db::download('http://ourairports.com/data/airports.csv',$out_file); |
|
740 | + update_db::download('http://ourairports.com/data/airports.csv', $out_file); |
|
741 | 741 | if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
742 | 742 | echo "Add data from ourairports.com...\n"; |
743 | 743 | |
@@ -748,32 +748,32 @@ discard block |
||
748 | 748 | //$Connection->db->beginTransaction(); |
749 | 749 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
750 | 750 | { |
751 | - if(!$header) $header = $row; |
|
751 | + if (!$header) $header = $row; |
|
752 | 752 | else { |
753 | 753 | $data = array(); |
754 | 754 | $data = array_combine($header, $row); |
755 | 755 | try { |
756 | 756 | $sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE `icao` = :icao'); |
757 | 757 | $sth->execute(array(':icao' => $data['gps_code'])); |
758 | - } catch(PDOException $e) { |
|
758 | + } catch (PDOException $e) { |
|
759 | 759 | return "error : ".$e->getMessage(); |
760 | 760 | } |
761 | 761 | if ($sth->fetchColumn() > 0) { |
762 | 762 | $query = 'UPDATE airport SET `type` = :type WHERE icao = :icao'; |
763 | 763 | try { |
764 | 764 | $sth = $Connection->db->prepare($query); |
765 | - $sth->execute(array(':icao' => $data['gps_code'],':type' => $data['type'])); |
|
766 | - } catch(PDOException $e) { |
|
765 | + $sth->execute(array(':icao' => $data['gps_code'], ':type' => $data['type'])); |
|
766 | + } catch (PDOException $e) { |
|
767 | 767 | return "error : ".$e->getMessage(); |
768 | 768 | } |
769 | 769 | } else { |
770 | 770 | $query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`) |
771 | 771 | VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link)"; |
772 | - $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 | + $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']); |
|
773 | 773 | try { |
774 | 774 | $sth = $Connection->db->prepare($query); |
775 | 775 | $sth->execute($query_values); |
776 | - } catch(PDOException $e) { |
|
776 | + } catch (PDOException $e) { |
|
777 | 777 | return "error : ".$e->getMessage(); |
778 | 778 | } |
779 | 779 | $i++; |
@@ -786,7 +786,7 @@ discard block |
||
786 | 786 | |
787 | 787 | echo "Download data from another free database...\n"; |
788 | 788 | $out_file = $tmp_dir.'GlobalAirportDatabase.zip'; |
789 | - update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file); |
|
789 | + update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip', $out_file); |
|
790 | 790 | if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
791 | 791 | update_db::unzip($out_file); |
792 | 792 | $header = NULL; |
@@ -798,15 +798,15 @@ discard block |
||
798 | 798 | //$Connection->db->beginTransaction(); |
799 | 799 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
800 | 800 | { |
801 | - if(!$header) $header = $row; |
|
801 | + if (!$header) $header = $row; |
|
802 | 802 | else { |
803 | 803 | $data = $row; |
804 | 804 | |
805 | 805 | $query = 'UPDATE airport SET `city` = :city, `country` = :country WHERE icao = :icao'; |
806 | 806 | try { |
807 | 807 | $sth = $Connection->db->prepare($query); |
808 | - $sth->execute(array(':icao' => $data[0],':city' => ucwords(strtolower($data[3])),':country' => ucwords(strtolower($data[4])))); |
|
809 | - } catch(PDOException $e) { |
|
808 | + $sth->execute(array(':icao' => $data[0], ':city' => ucwords(strtolower($data[3])), ':country' => ucwords(strtolower($data[4])))); |
|
809 | + } catch (PDOException $e) { |
|
810 | 810 | return "error : ".$e->getMessage(); |
811 | 811 | } |
812 | 812 | } |
@@ -820,15 +820,15 @@ discard block |
||
820 | 820 | try { |
821 | 821 | $sth = $Connection->db->prepare("SELECT icao FROM airport WHERE `name` LIKE '%Air Base%'"); |
822 | 822 | $sth->execute(); |
823 | - } catch(PDOException $e) { |
|
823 | + } catch (PDOException $e) { |
|
824 | 824 | return "error : ".$e->getMessage(); |
825 | 825 | } |
826 | 826 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
827 | 827 | $query2 = 'UPDATE airport SET `type` = :type WHERE icao = :icao'; |
828 | 828 | try { |
829 | 829 | $sth2 = $Connection->db->prepare($query2); |
830 | - $sth2->execute(array(':icao' => $row['icao'],':type' => 'military')); |
|
831 | - } catch(PDOException $e) { |
|
830 | + $sth2->execute(array(':icao' => $row['icao'], ':type' => 'military')); |
|
831 | + } catch (PDOException $e) { |
|
832 | 832 | return "error : ".$e->getMessage(); |
833 | 833 | } |
834 | 834 | } |
@@ -852,7 +852,7 @@ discard block |
||
852 | 852 | $Connection = new Connection(); |
853 | 853 | $sth = $Connection->db->prepare($query); |
854 | 854 | $sth->execute(array(':source' => 'translation.csv')); |
855 | - } catch(PDOException $e) { |
|
855 | + } catch (PDOException $e) { |
|
856 | 856 | return "error : ".$e->getMessage(); |
857 | 857 | } |
858 | 858 | |
@@ -869,7 +869,7 @@ discard block |
||
869 | 869 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
870 | 870 | { |
871 | 871 | $i++; |
872 | - if($i > 12) { |
|
872 | + if ($i > 12) { |
|
873 | 873 | $data = $row; |
874 | 874 | $operator = $data[2]; |
875 | 875 | if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) { |
@@ -877,7 +877,7 @@ discard block |
||
877 | 877 | //echo substr($operator, 0, 2)."\n";; |
878 | 878 | if (count($airline_array) > 0) { |
879 | 879 | //print_r($airline_array); |
880 | - $operator = $airline_array[0]['icao'].substr($operator,2); |
|
880 | + $operator = $airline_array[0]['icao'].substr($operator, 2); |
|
881 | 881 | } |
882 | 882 | } |
883 | 883 | |
@@ -885,14 +885,14 @@ discard block |
||
885 | 885 | if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) { |
886 | 886 | $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2)); |
887 | 887 | if (count($airline_array) > 0) { |
888 | - $operator_correct = $airline_array[0]['icao'].substr($operator_correct,2); |
|
888 | + $operator_correct = $airline_array[0]['icao'].substr($operator_correct, 2); |
|
889 | 889 | } |
890 | 890 | } |
891 | 891 | $query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)'; |
892 | 892 | try { |
893 | 893 | $sth = $Connection->db->prepare($query); |
894 | - $sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $operator,':Operator_correct' => $operator_correct, ':source' => 'translation.csv')); |
|
895 | - } catch(PDOException $e) { |
|
894 | + $sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $operator, ':Operator_correct' => $operator_correct, ':source' => 'translation.csv')); |
|
895 | + } catch (PDOException $e) { |
|
896 | 896 | return "error : ".$e->getMessage(); |
897 | 897 | } |
898 | 898 | } |
@@ -912,7 +912,7 @@ discard block |
||
912 | 912 | $Connection = new Connection(); |
913 | 913 | $sth = $Connection->db->prepare($query); |
914 | 914 | $sth->execute(array(':source' => 'website_fam')); |
915 | - } catch(PDOException $e) { |
|
915 | + } catch (PDOException $e) { |
|
916 | 916 | return "error : ".$e->getMessage(); |
917 | 917 | } |
918 | 918 | |
@@ -932,8 +932,8 @@ discard block |
||
932 | 932 | $query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)'; |
933 | 933 | try { |
934 | 934 | $sth = $Connection->db->prepare($query); |
935 | - $sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $data[2],':Operator_correct' => $data[3], ':source' => 'website_fam')); |
|
936 | - } catch(PDOException $e) { |
|
935 | + $sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $data[2], ':Operator_correct' => $data[3], ':source' => 'website_fam')); |
|
936 | + } catch (PDOException $e) { |
|
937 | 937 | return "error : ".$e->getMessage(); |
938 | 938 | } |
939 | 939 | } |
@@ -956,7 +956,7 @@ discard block |
||
956 | 956 | $Connection = new Connection(); |
957 | 957 | $sth = $Connection->db->prepare($query); |
958 | 958 | $sth->execute(array(':source' => 'website_faa')); |
959 | - } catch(PDOException $e) { |
|
959 | + } catch (PDOException $e) { |
|
960 | 960 | return "error : ".$e->getMessage(); |
961 | 961 | } |
962 | 962 | |
@@ -965,7 +965,7 @@ discard block |
||
965 | 965 | $Connection = new Connection(); |
966 | 966 | $sth = $Connection->db->prepare($query); |
967 | 967 | $sth->execute(array(':source' => 'website_faa')); |
968 | - } catch(PDOException $e) { |
|
968 | + } catch (PDOException $e) { |
|
969 | 969 | return "error : ".$e->getMessage(); |
970 | 970 | } |
971 | 971 | |
@@ -982,8 +982,8 @@ discard block |
||
982 | 982 | $query_search = 'SELECT icaotypecode FROM aircraft_modes WHERE registration = :registration AND Source <> :source LIMIT 1'; |
983 | 983 | try { |
984 | 984 | $sths = $Connection->db->prepare($query_search); |
985 | - $sths->execute(array(':registration' => 'N'.$data[0],':source' => 'website_faa')); |
|
986 | - } catch(PDOException $e) { |
|
985 | + $sths->execute(array(':registration' => 'N'.$data[0], ':source' => 'website_faa')); |
|
986 | + } catch (PDOException $e) { |
|
987 | 987 | return "error s : ".$e->getMessage(); |
988 | 988 | } |
989 | 989 | $result_search = $sths->fetchAll(PDO::FETCH_ASSOC); |
@@ -996,8 +996,8 @@ discard block |
||
996 | 996 | //} |
997 | 997 | try { |
998 | 998 | $sthi = $Connection->db->prepare($queryi); |
999 | - $sthi->execute(array(':mfr' => $data[2],':icao' => $result_search[0]['icaotypecode'])); |
|
1000 | - } catch(PDOException $e) { |
|
999 | + $sthi->execute(array(':mfr' => $data[2], ':icao' => $result_search[0]['icaotypecode'])); |
|
1000 | + } catch (PDOException $e) { |
|
1001 | 1001 | return "error u : ".$e->getMessage(); |
1002 | 1002 | } |
1003 | 1003 | } else { |
@@ -1005,7 +1005,7 @@ discard block |
||
1005 | 1005 | try { |
1006 | 1006 | $sthsm = $Connection->db->prepare($query_search_mfr); |
1007 | 1007 | $sthsm->execute(array(':mfr' => $data[2])); |
1008 | - } catch(PDOException $e) { |
|
1008 | + } catch (PDOException $e) { |
|
1009 | 1009 | return "error mfr : ".$e->getMessage(); |
1010 | 1010 | } |
1011 | 1011 | $result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC); |
@@ -1015,8 +1015,8 @@ discard block |
||
1015 | 1015 | $queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)'; |
1016 | 1016 | try { |
1017 | 1017 | $sthf = $Connection->db->prepare($queryf); |
1018 | - $sthf->execute(array(':FirstCreated' => $data[16],':LastModified' => $data[15],':ModeS' => $data[33],':ModeSCountry' => $data[14], ':Registration' => 'N'.$data[0],':ICAOTypeCode' => $result_search_mfr[0]['icao'],':source' => 'website_faa')); |
|
1019 | - } catch(PDOException $e) { |
|
1018 | + $sthf->execute(array(':FirstCreated' => $data[16], ':LastModified' => $data[15], ':ModeS' => $data[33], ':ModeSCountry' => $data[14], ':Registration' => 'N'.$data[0], ':ICAOTypeCode' => $result_search_mfr[0]['icao'], ':source' => 'website_faa')); |
|
1019 | + } catch (PDOException $e) { |
|
1020 | 1020 | return "error f : ".$e->getMessage(); |
1021 | 1021 | } |
1022 | 1022 | } |
@@ -1026,13 +1026,13 @@ discard block |
||
1026 | 1026 | $query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)'; |
1027 | 1027 | try { |
1028 | 1028 | $sth = $Connection->db->prepare($query); |
1029 | - $sth->execute(array(':registration' => 'N'.$data[0],':base' => $data[9],':owner' => ucwords(strtolower($data[6])),':date_first_reg' => date('Y-m-d',strtotime($data[23])), ':source' => 'website_faa')); |
|
1030 | - } catch(PDOException $e) { |
|
1029 | + $sth->execute(array(':registration' => 'N'.$data[0], ':base' => $data[9], ':owner' => ucwords(strtolower($data[6])), ':date_first_reg' => date('Y-m-d', strtotime($data[23])), ':source' => 'website_faa')); |
|
1030 | + } catch (PDOException $e) { |
|
1031 | 1031 | return "error i : ".$e->getMessage(); |
1032 | 1032 | } |
1033 | 1033 | } |
1034 | 1034 | } |
1035 | - if ($i % 90 == 0) { |
|
1035 | + if ($i%90 == 0) { |
|
1036 | 1036 | if ($globalTransaction) $Connection->db->commit(); |
1037 | 1037 | if ($globalTransaction) $Connection->db->beginTransaction(); |
1038 | 1038 | } |
@@ -1051,7 +1051,7 @@ discard block |
||
1051 | 1051 | $Connection = new Connection(); |
1052 | 1052 | $sth = $Connection->db->prepare($query); |
1053 | 1053 | $sth->execute(array(':source' => 'website_fam')); |
1054 | - } catch(PDOException $e) { |
|
1054 | + } catch (PDOException $e) { |
|
1055 | 1055 | return "error : ".$e->getMessage(); |
1056 | 1056 | } |
1057 | 1057 | |
@@ -1071,8 +1071,8 @@ discard block |
||
1071 | 1071 | $query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)'; |
1072 | 1072 | try { |
1073 | 1073 | $sth = $Connection->db->prepare($query); |
1074 | - $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')); |
|
1075 | - } catch(PDOException $e) { |
|
1074 | + $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')); |
|
1075 | + } catch (PDOException $e) { |
|
1076 | 1076 | return "error : ".$e->getMessage(); |
1077 | 1077 | } |
1078 | 1078 | } |
@@ -1091,7 +1091,7 @@ discard block |
||
1091 | 1091 | $Connection = new Connection(); |
1092 | 1092 | $sth = $Connection->db->prepare($query); |
1093 | 1093 | $sth->execute(array(':source' => 'website_fam')); |
1094 | - } catch(PDOException $e) { |
|
1094 | + } catch (PDOException $e) { |
|
1095 | 1095 | return "error : ".$e->getMessage(); |
1096 | 1096 | } |
1097 | 1097 | |
@@ -1107,8 +1107,8 @@ discard block |
||
1107 | 1107 | $query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,NULL,:source)'; |
1108 | 1108 | try { |
1109 | 1109 | $sth = $Connection->db->prepare($query); |
1110 | - $sth->execute(array(':registration' => $data[0],':base' => $data[1],':owner' => $data[2], ':source' => 'website_fam')); |
|
1111 | - } catch(PDOException $e) { |
|
1110 | + $sth->execute(array(':registration' => $data[0], ':base' => $data[1], ':owner' => $data[2], ':source' => 'website_fam')); |
|
1111 | + } catch (PDOException $e) { |
|
1112 | 1112 | print_r($data); |
1113 | 1113 | return "error : ".$e->getMessage(); |
1114 | 1114 | } |
@@ -1128,7 +1128,7 @@ discard block |
||
1128 | 1128 | $Connection = new Connection(); |
1129 | 1129 | $sth = $Connection->db->prepare($query); |
1130 | 1130 | $sth->execute(array(':source' => 'website_fam')); |
1131 | - } catch(PDOException $e) { |
|
1131 | + } catch (PDOException $e) { |
|
1132 | 1132 | return "error : ".$e->getMessage(); |
1133 | 1133 | } |
1134 | 1134 | |
@@ -1148,8 +1148,8 @@ discard block |
||
1148 | 1148 | $query = '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)'; |
1149 | 1149 | try { |
1150 | 1150 | $sth = $Connection->db->prepare($query); |
1151 | - $sth->execute(array(':CallSign' => $data[0],':Operator_ICAO' => $data[1],':FromAirport_ICAO' => $data[2],':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4],':ToAirport_Time' => $data[5],':RouteStop' => $data[6],':source' => 'website_fam')); |
|
1152 | - } catch(PDOException $e) { |
|
1151 | + $sth->execute(array(':CallSign' => $data[0], ':Operator_ICAO' => $data[1], ':FromAirport_ICAO' => $data[2], ':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4], ':ToAirport_Time' => $data[5], ':RouteStop' => $data[6], ':source' => 'website_fam')); |
|
1152 | + } catch (PDOException $e) { |
|
1153 | 1153 | return "error : ".$e->getMessage(); |
1154 | 1154 | } |
1155 | 1155 | } |
@@ -1168,7 +1168,7 @@ discard block |
||
1168 | 1168 | $Connection = new Connection(); |
1169 | 1169 | $sth = $Connection->db->prepare($query); |
1170 | 1170 | $sth->execute(); |
1171 | - } catch(PDOException $e) { |
|
1171 | + } catch (PDOException $e) { |
|
1172 | 1172 | return "error : ".$e->getMessage(); |
1173 | 1173 | } |
1174 | 1174 | |
@@ -1184,7 +1184,7 @@ discard block |
||
1184 | 1184 | try { |
1185 | 1185 | $sth = $Connection->db->prepare($query); |
1186 | 1186 | $sth->execute(array(':icao' => $icao)); |
1187 | - } catch(PDOException $e) { |
|
1187 | + } catch (PDOException $e) { |
|
1188 | 1188 | return "error : ".$e->getMessage(); |
1189 | 1189 | } |
1190 | 1190 | } |
@@ -1195,7 +1195,7 @@ discard block |
||
1195 | 1195 | return ''; |
1196 | 1196 | } |
1197 | 1197 | |
1198 | - public static function tle($filename,$tletype) { |
|
1198 | + public static function tle($filename, $tletype) { |
|
1199 | 1199 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
1200 | 1200 | global $tmp_dir, $globalTransaction; |
1201 | 1201 | //$Spotter = new Spotter(); |
@@ -1205,7 +1205,7 @@ discard block |
||
1205 | 1205 | $Connection = new Connection(); |
1206 | 1206 | $sth = $Connection->db->prepare($query); |
1207 | 1207 | $sth->execute(array(':source' => $filename)); |
1208 | - } catch(PDOException $e) { |
|
1208 | + } catch (PDOException $e) { |
|
1209 | 1209 | return "error : ".$e->getMessage(); |
1210 | 1210 | } |
1211 | 1211 | |
@@ -1230,8 +1230,8 @@ discard block |
||
1230 | 1230 | $query = 'INSERT INTO tle (tle_name,tle_tle1,tle_tle2,tle_type,tle_source) VALUES (:name, :tle1, :tle2, :type, :source)'; |
1231 | 1231 | try { |
1232 | 1232 | $sth = $Connection->db->prepare($query); |
1233 | - $sth->execute(array(':name' => $dbdata['name'],':tle1' => $dbdata['tle1'],':tle2' => $dbdata['tle2'], ':type' => $tletype,':source' => $filename)); |
|
1234 | - } catch(PDOException $e) { |
|
1233 | + $sth->execute(array(':name' => $dbdata['name'], ':tle1' => $dbdata['tle1'], ':tle2' => $dbdata['tle2'], ':type' => $tletype, ':source' => $filename)); |
|
1234 | + } catch (PDOException $e) { |
|
1235 | 1235 | return "error : ".$e->getMessage(); |
1236 | 1236 | } |
1237 | 1237 | |
@@ -1251,28 +1251,28 @@ discard block |
||
1251 | 1251 | */ |
1252 | 1252 | private static function table2array($data) { |
1253 | 1253 | $html = str_get_html($data); |
1254 | - $tabledata=array(); |
|
1255 | - foreach($html->find('tr') as $element) |
|
1254 | + $tabledata = array(); |
|
1255 | + foreach ($html->find('tr') as $element) |
|
1256 | 1256 | { |
1257 | 1257 | $td = array(); |
1258 | - foreach( $element->find('th') as $row) |
|
1258 | + foreach ($element->find('th') as $row) |
|
1259 | 1259 | { |
1260 | 1260 | $td [] = trim($row->plaintext); |
1261 | 1261 | } |
1262 | - $td=array_filter($td); |
|
1262 | + $td = array_filter($td); |
|
1263 | 1263 | $tabledata[] = $td; |
1264 | 1264 | |
1265 | 1265 | $td = array(); |
1266 | 1266 | $tdi = array(); |
1267 | - foreach( $element->find('td') as $row) |
|
1267 | + foreach ($element->find('td') as $row) |
|
1268 | 1268 | { |
1269 | 1269 | $td [] = trim($row->plaintext); |
1270 | 1270 | $tdi [] = trim($row->innertext); |
1271 | 1271 | } |
1272 | - $td=array_filter($td); |
|
1273 | - $tdi=array_filter($tdi); |
|
1272 | + $td = array_filter($td); |
|
1273 | + $tdi = array_filter($tdi); |
|
1274 | 1274 | // $tabledata[]=array_merge($td,$tdi); |
1275 | - $tabledata[]=$td; |
|
1275 | + $tabledata[] = $td; |
|
1276 | 1276 | } |
1277 | 1277 | return(array_filter($tabledata)); |
1278 | 1278 | } |
@@ -1345,13 +1345,13 @@ discard block |
||
1345 | 1345 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1346 | 1346 | { |
1347 | 1347 | $i++; |
1348 | - if($i > 3 && count($row) > 2) { |
|
1348 | + if ($i > 3 && count($row) > 2) { |
|
1349 | 1349 | $data = array_values(array_filter($row)); |
1350 | 1350 | $cntdata = count($data); |
1351 | 1351 | if ($cntdata > 10) { |
1352 | 1352 | $value = $data[9]; |
1353 | 1353 | |
1354 | - for ($i =10;$i < $cntdata;$i++) { |
|
1354 | + for ($i = 10; $i < $cntdata; $i++) { |
|
1355 | 1355 | $value .= ' '.$data[$i]; |
1356 | 1356 | } |
1357 | 1357 | $data[9] = $value; |
@@ -1361,8 +1361,8 @@ discard block |
||
1361 | 1361 | $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)'; |
1362 | 1362 | try { |
1363 | 1363 | $sth = $Connection->db->prepare($query); |
1364 | - $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])); |
|
1365 | - } catch(PDOException $e) { |
|
1364 | + $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])); |
|
1365 | + } catch (PDOException $e) { |
|
1366 | 1366 | return "error : ".$e->getMessage(); |
1367 | 1367 | } |
1368 | 1368 | } |
@@ -1383,7 +1383,7 @@ discard block |
||
1383 | 1383 | $Connection = new Connection(); |
1384 | 1384 | $sth = $Connection->db->prepare($query); |
1385 | 1385 | $sth->execute(); |
1386 | - } catch(PDOException $e) { |
|
1386 | + } catch (PDOException $e) { |
|
1387 | 1387 | return "error : ".$e->getMessage(); |
1388 | 1388 | } |
1389 | 1389 | |
@@ -1395,12 +1395,12 @@ discard block |
||
1395 | 1395 | if ($globalTransaction) $Connection->db->beginTransaction(); |
1396 | 1396 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1397 | 1397 | { |
1398 | - if(count($row) > 1) { |
|
1398 | + if (count($row) > 1) { |
|
1399 | 1399 | $query = "INSERT INTO airlines (name,icao,active,forsource) VALUES (:name, :icao, 'Y','ivao')"; |
1400 | 1400 | try { |
1401 | 1401 | $sth = $Connection->db->prepare($query); |
1402 | - $sth->execute(array(':name' => $row[1],':icao' => $row[0])); |
|
1403 | - } catch(PDOException $e) { |
|
1402 | + $sth->execute(array(':name' => $row[1], ':icao' => $row[0])); |
|
1403 | + } catch (PDOException $e) { |
|
1404 | 1404 | return "error : ".$e->getMessage(); |
1405 | 1405 | } |
1406 | 1406 | } |
@@ -1420,21 +1420,21 @@ discard block |
||
1420 | 1420 | try { |
1421 | 1421 | $sth = $Connection->db->prepare($query); |
1422 | 1422 | $sth->execute(); |
1423 | - } catch(PDOException $e) { |
|
1423 | + } catch (PDOException $e) { |
|
1424 | 1424 | return "error : ".$e->getMessage(); |
1425 | 1425 | } |
1426 | 1426 | } |
1427 | 1427 | |
1428 | 1428 | |
1429 | - if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
1429 | + if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz', $tmp_dir.'airspace.sql'); |
|
1430 | 1430 | else { |
1431 | - update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
1431 | + update_db::gunzip('../db/pgsql/airspace.sql.gz', $tmp_dir.'airspace.sql'); |
|
1432 | 1432 | $query = "CREATE EXTENSION postgis"; |
1433 | - $Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']); |
|
1433 | + $Connection = new Connection(null, null, $_SESSION['database_root'], $_SESSION['database_rootpass']); |
|
1434 | 1434 | try { |
1435 | 1435 | $sth = $Connection->db->prepare($query); |
1436 | 1436 | $sth->execute(); |
1437 | - } catch(PDOException $e) { |
|
1437 | + } catch (PDOException $e) { |
|
1438 | 1438 | return "error : ".$e->getMessage(); |
1439 | 1439 | } |
1440 | 1440 | } |
@@ -1447,7 +1447,7 @@ discard block |
||
1447 | 1447 | include_once('class.create_db.php'); |
1448 | 1448 | require_once(dirname(__FILE__).'/../require/class.NOTAM.php'); |
1449 | 1449 | if ($globalDebug) echo "NOTAM from FlightAirMap website : Download..."; |
1450 | - update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz'); |
|
1450 | + update_db::download('http://data.flightairmap.fr/data/notam.txt.gz', $tmp_dir.'notam.txt.gz'); |
|
1451 | 1451 | $error = ''; |
1452 | 1452 | if (file_exists($tmp_dir.'notam.txt.gz')) { |
1453 | 1453 | if ($globalDebug) echo "Gunzip..."; |
@@ -1479,14 +1479,14 @@ discard block |
||
1479 | 1479 | try { |
1480 | 1480 | $sth = $Connection->db->prepare($query); |
1481 | 1481 | $sth->execute(); |
1482 | - } catch(PDOException $e) { |
|
1482 | + } catch (PDOException $e) { |
|
1483 | 1483 | echo "error : ".$e->getMessage(); |
1484 | 1484 | } |
1485 | 1485 | } |
1486 | 1486 | if ($globalDBdriver == 'mysql') { |
1487 | - update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql'); |
|
1487 | + update_db::gunzip('../db/countries.sql.gz', $tmp_dir.'countries.sql'); |
|
1488 | 1488 | } else { |
1489 | - update_db::gunzip('../db/pgsql/countries.sql.gz',$tmp_dir.'countries.sql'); |
|
1489 | + update_db::gunzip('../db/pgsql/countries.sql.gz', $tmp_dir.'countries.sql'); |
|
1490 | 1490 | } |
1491 | 1491 | $error = create_db::import_file($tmp_dir.'countries.sql'); |
1492 | 1492 | return $error; |
@@ -1499,7 +1499,7 @@ discard block |
||
1499 | 1499 | // update_db::unzip($tmp_dir.'AptNav.zip'); |
1500 | 1500 | // update_db::download('https://gitorious.org/fg/fgdata/raw/e81f8a15424a175a7b715f8f7eb8f4147b802a27:Navaids/awy.dat.gz',$tmp_dir.'awy.dat.gz'); |
1501 | 1501 | // 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'); |
1502 | - 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'); |
|
1502 | + 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'); |
|
1503 | 1503 | update_db::gunzip($tmp_dir.'awy.dat.gz'); |
1504 | 1504 | $error = update_db::waypoints($tmp_dir.'awy.dat'); |
1505 | 1505 | return $error; |
@@ -1519,7 +1519,7 @@ discard block |
||
1519 | 1519 | update_db::ivao_airlines($tmp_dir.'data/airlines.dat'); |
1520 | 1520 | if ($globalDebug) echo "Copy airlines logos to airlines images directory..."; |
1521 | 1521 | if (is_writable(dirname(__FILE__).'/../images/airlines')) { |
1522 | - if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
1522 | + if (!$Common->xcopy($tmp_dir.'logos/', dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
1523 | 1523 | } else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
1524 | 1524 | } else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
1525 | 1525 | if ($error != '') { |
@@ -1532,7 +1532,7 @@ discard block |
||
1532 | 1532 | global $tmp_dir, $globalDebug; |
1533 | 1533 | $error = ''; |
1534 | 1534 | if ($globalDebug) echo "Routes : Download..."; |
1535 | - update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz'); |
|
1535 | + update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz', $tmp_dir.'StandingData.sqb.gz'); |
|
1536 | 1536 | if (file_exists($tmp_dir.'StandingData.sqb.gz')) { |
1537 | 1537 | if ($globalDebug) echo "Gunzip..."; |
1538 | 1538 | update_db::gunzip($tmp_dir.'StandingData.sqb.gz'); |
@@ -1548,7 +1548,7 @@ discard block |
||
1548 | 1548 | global $tmp_dir, $globalDebug; |
1549 | 1549 | $error = ''; |
1550 | 1550 | if ($globalDebug) echo "Schedules Oneworld : Download..."; |
1551 | - update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz'); |
|
1551 | + update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz', $tmp_dir.'oneworld.csv.gz'); |
|
1552 | 1552 | if (file_exists($tmp_dir.'oneworld.csv.gz')) { |
1553 | 1553 | if ($globalDebug) echo "Gunzip..."; |
1554 | 1554 | update_db::gunzip($tmp_dir.'oneworld.csv.gz'); |
@@ -1564,7 +1564,7 @@ discard block |
||
1564 | 1564 | global $tmp_dir, $globalDebug; |
1565 | 1565 | $error = ''; |
1566 | 1566 | if ($globalDebug) echo "Schedules Skyteam : Download..."; |
1567 | - update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz'); |
|
1567 | + update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz', $tmp_dir.'skyteam.csv.gz'); |
|
1568 | 1568 | if (file_exists($tmp_dir.'skyteam.csv.gz')) { |
1569 | 1569 | if ($globalDebug) echo "Gunzip..."; |
1570 | 1570 | update_db::gunzip($tmp_dir.'skyteam.csv.gz'); |
@@ -1592,7 +1592,7 @@ discard block |
||
1592 | 1592 | */ |
1593 | 1593 | if ($globalDebug) echo "Modes : Download..."; |
1594 | 1594 | // update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
1595 | - update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz'); |
|
1595 | + update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz', $tmp_dir.'BaseStation.sqb.gz'); |
|
1596 | 1596 | |
1597 | 1597 | // if (file_exists($tmp_dir.'basestation_latest.zip')) { |
1598 | 1598 | if (file_exists($tmp_dir.'BaseStation.sqb.gz')) { |
@@ -1612,7 +1612,7 @@ discard block |
||
1612 | 1612 | public static function update_ModeS_faa() { |
1613 | 1613 | global $tmp_dir, $globalDebug; |
1614 | 1614 | if ($globalDebug) echo "Modes FAA: Download..."; |
1615 | - update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip'); |
|
1615 | + update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip', $tmp_dir.'ReleasableAircraft.zip'); |
|
1616 | 1616 | if (file_exists($tmp_dir.'ReleasableAircraft.zip')) { |
1617 | 1617 | if ($globalDebug) echo "Unzip..."; |
1618 | 1618 | update_db::unzip($tmp_dir.'ReleasableAircraft.zip'); |
@@ -1628,7 +1628,7 @@ discard block |
||
1628 | 1628 | public static function update_ModeS_flarm() { |
1629 | 1629 | global $tmp_dir, $globalDebug; |
1630 | 1630 | if ($globalDebug) echo "Modes Flarmnet: Download..."; |
1631 | - update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln'); |
|
1631 | + update_db::download('http://flarmnet.org/files/data.fln', $tmp_dir.'data.fln'); |
|
1632 | 1632 | if (file_exists($tmp_dir.'data.fln')) { |
1633 | 1633 | if ($globalDebug) echo "Add to DB..."; |
1634 | 1634 | $error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln'); |
@@ -1642,7 +1642,7 @@ discard block |
||
1642 | 1642 | public static function update_ModeS_ogn() { |
1643 | 1643 | global $tmp_dir, $globalDebug; |
1644 | 1644 | if ($globalDebug) echo "Modes OGN: Download..."; |
1645 | - update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv'); |
|
1645 | + update_db::download('http://ddb.glidernet.org/download/', $tmp_dir.'ogn.csv'); |
|
1646 | 1646 | if (file_exists($tmp_dir.'ogn.csv')) { |
1647 | 1647 | if ($globalDebug) echo "Add to DB..."; |
1648 | 1648 | $error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv'); |
@@ -1657,173 +1657,173 @@ discard block |
||
1657 | 1657 | global $tmp_dir, $globalDebug; |
1658 | 1658 | |
1659 | 1659 | if ($globalDebug) echo "Owner France: Download..."; |
1660 | - update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv'); |
|
1660 | + update_db::download('http://antonakis.co.uk/registers/France.txt', $tmp_dir.'owner_f.csv'); |
|
1661 | 1661 | if (file_exists($tmp_dir.'owner_f.csv')) { |
1662 | 1662 | if ($globalDebug) echo "Add to DB..."; |
1663 | - $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F'); |
|
1663 | + $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv', 'F'); |
|
1664 | 1664 | } else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
1665 | 1665 | if ($error != '') { |
1666 | 1666 | return $error; |
1667 | 1667 | } elseif ($globalDebug) echo "Done\n"; |
1668 | 1668 | |
1669 | 1669 | if ($globalDebug) echo "Owner Ireland: Download..."; |
1670 | - update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv'); |
|
1670 | + update_db::download('http://antonakis.co.uk/registers/Ireland.txt', $tmp_dir.'owner_ei.csv'); |
|
1671 | 1671 | if (file_exists($tmp_dir.'owner_ei.csv')) { |
1672 | 1672 | if ($globalDebug) echo "Add to DB..."; |
1673 | - $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI'); |
|
1673 | + $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv', 'EI'); |
|
1674 | 1674 | } else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
1675 | 1675 | if ($error != '') { |
1676 | 1676 | return $error; |
1677 | 1677 | } elseif ($globalDebug) echo "Done\n"; |
1678 | 1678 | if ($globalDebug) echo "Owner Switzerland: Download..."; |
1679 | - update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv'); |
|
1679 | + update_db::download('http://antonakis.co.uk/registers/Switzerland.txt', $tmp_dir.'owner_hb.csv'); |
|
1680 | 1680 | if (file_exists($tmp_dir.'owner_hb.csv')) { |
1681 | 1681 | if ($globalDebug) echo "Add to DB..."; |
1682 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB'); |
|
1682 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv', 'HB'); |
|
1683 | 1683 | } else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
1684 | 1684 | if ($error != '') { |
1685 | 1685 | return $error; |
1686 | 1686 | } elseif ($globalDebug) echo "Done\n"; |
1687 | 1687 | if ($globalDebug) echo "Owner Czech Republic: Download..."; |
1688 | - update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv'); |
|
1688 | + update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt', $tmp_dir.'owner_ok.csv'); |
|
1689 | 1689 | if (file_exists($tmp_dir.'owner_ok.csv')) { |
1690 | 1690 | if ($globalDebug) echo "Add to DB..."; |
1691 | - $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK'); |
|
1691 | + $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv', 'OK'); |
|
1692 | 1692 | } else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
1693 | 1693 | if ($error != '') { |
1694 | 1694 | return $error; |
1695 | 1695 | } elseif ($globalDebug) echo "Done\n"; |
1696 | 1696 | if ($globalDebug) echo "Owner Australia: Download..."; |
1697 | - update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv'); |
|
1697 | + update_db::download('http://antonakis.co.uk/registers/Australia.txt', $tmp_dir.'owner_vh.csv'); |
|
1698 | 1698 | if (file_exists($tmp_dir.'owner_vh.csv')) { |
1699 | 1699 | if ($globalDebug) echo "Add to DB..."; |
1700 | - $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH'); |
|
1700 | + $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv', 'VH'); |
|
1701 | 1701 | } else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
1702 | 1702 | if ($error != '') { |
1703 | 1703 | return $error; |
1704 | 1704 | } elseif ($globalDebug) echo "Done\n"; |
1705 | 1705 | if ($globalDebug) echo "Owner Austria: Download..."; |
1706 | - update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv'); |
|
1706 | + update_db::download('http://antonakis.co.uk/registers/Austria.txt', $tmp_dir.'owner_oe.csv'); |
|
1707 | 1707 | if (file_exists($tmp_dir.'owner_oe.csv')) { |
1708 | 1708 | if ($globalDebug) echo "Add to DB..."; |
1709 | - $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE'); |
|
1709 | + $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv', 'OE'); |
|
1710 | 1710 | } else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
1711 | 1711 | if ($error != '') { |
1712 | 1712 | return $error; |
1713 | 1713 | } elseif ($globalDebug) echo "Done\n"; |
1714 | 1714 | if ($globalDebug) echo "Owner Chile: Download..."; |
1715 | - update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv'); |
|
1715 | + update_db::download('http://antonakis.co.uk/registers/Chile.txt', $tmp_dir.'owner_cc.csv'); |
|
1716 | 1716 | if (file_exists($tmp_dir.'owner_cc.csv')) { |
1717 | 1717 | if ($globalDebug) echo "Add to DB..."; |
1718 | - $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC'); |
|
1718 | + $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv', 'CC'); |
|
1719 | 1719 | } else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
1720 | 1720 | if ($error != '') { |
1721 | 1721 | return $error; |
1722 | 1722 | } elseif ($globalDebug) echo "Done\n"; |
1723 | 1723 | if ($globalDebug) echo "Owner Colombia: Download..."; |
1724 | - update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv'); |
|
1724 | + update_db::download('http://antonakis.co.uk/registers/Colombia.txt', $tmp_dir.'owner_hj.csv'); |
|
1725 | 1725 | if (file_exists($tmp_dir.'owner_hj.csv')) { |
1726 | 1726 | if ($globalDebug) echo "Add to DB..."; |
1727 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ'); |
|
1727 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv', 'HJ'); |
|
1728 | 1728 | } else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
1729 | 1729 | if ($error != '') { |
1730 | 1730 | return $error; |
1731 | 1731 | } elseif ($globalDebug) echo "Done\n"; |
1732 | 1732 | if ($globalDebug) echo "Owner Bosnia Herzegobina: Download..."; |
1733 | - update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv'); |
|
1733 | + update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt', $tmp_dir.'owner_e7.csv'); |
|
1734 | 1734 | if (file_exists($tmp_dir.'owner_e7.csv')) { |
1735 | 1735 | if ($globalDebug) echo "Add to DB..."; |
1736 | - $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7'); |
|
1736 | + $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv', 'E7'); |
|
1737 | 1737 | } else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
1738 | 1738 | if ($error != '') { |
1739 | 1739 | return $error; |
1740 | 1740 | } elseif ($globalDebug) echo "Done\n"; |
1741 | 1741 | if ($globalDebug) echo "Owner Brazil: Download..."; |
1742 | - update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv'); |
|
1742 | + update_db::download('http://antonakis.co.uk/registers/Brazil.txt', $tmp_dir.'owner_pp.csv'); |
|
1743 | 1743 | if (file_exists($tmp_dir.'owner_pp.csv')) { |
1744 | 1744 | if ($globalDebug) echo "Add to DB..."; |
1745 | - $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP'); |
|
1745 | + $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv', 'PP'); |
|
1746 | 1746 | } else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
1747 | 1747 | if ($error != '') { |
1748 | 1748 | return $error; |
1749 | 1749 | } elseif ($globalDebug) echo "Done\n"; |
1750 | 1750 | if ($globalDebug) echo "Owner Cayman Islands: Download..."; |
1751 | - update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv'); |
|
1751 | + update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt', $tmp_dir.'owner_vp.csv'); |
|
1752 | 1752 | if (file_exists($tmp_dir.'owner_vp.csv')) { |
1753 | 1753 | if ($globalDebug) echo "Add to DB..."; |
1754 | - $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP'); |
|
1754 | + $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv', 'VP'); |
|
1755 | 1755 | } else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
1756 | 1756 | if ($error != '') { |
1757 | 1757 | return $error; |
1758 | 1758 | } elseif ($globalDebug) echo "Done\n"; |
1759 | 1759 | if ($globalDebug) echo "Owner Croatia: Download..."; |
1760 | - update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv'); |
|
1760 | + update_db::download('http://antonakis.co.uk/registers/Croatia.txt', $tmp_dir.'owner_9a.csv'); |
|
1761 | 1761 | if (file_exists($tmp_dir.'owner_9a.csv')) { |
1762 | 1762 | if ($globalDebug) echo "Add to DB..."; |
1763 | - $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A'); |
|
1763 | + $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv', '9A'); |
|
1764 | 1764 | } else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
1765 | 1765 | if ($error != '') { |
1766 | 1766 | return $error; |
1767 | 1767 | } elseif ($globalDebug) echo "Done\n"; |
1768 | 1768 | if ($globalDebug) echo "Owner Luxembourg: Download..."; |
1769 | - update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv'); |
|
1769 | + update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt', $tmp_dir.'owner_lx.csv'); |
|
1770 | 1770 | if (file_exists($tmp_dir.'owner_lx.csv')) { |
1771 | 1771 | if ($globalDebug) echo "Add to DB..."; |
1772 | - $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX'); |
|
1772 | + $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv', 'LX'); |
|
1773 | 1773 | } else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
1774 | 1774 | if ($error != '') { |
1775 | 1775 | return $error; |
1776 | 1776 | } elseif ($globalDebug) echo "Done\n"; |
1777 | 1777 | if ($globalDebug) echo "Owner Maldives: Download..."; |
1778 | - update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv'); |
|
1778 | + update_db::download('http://antonakis.co.uk/registers/Maldives.txt', $tmp_dir.'owner_8q.csv'); |
|
1779 | 1779 | if (file_exists($tmp_dir.'owner_8q.csv')) { |
1780 | 1780 | if ($globalDebug) echo "Add to DB..."; |
1781 | - $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q'); |
|
1781 | + $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv', '8Q'); |
|
1782 | 1782 | } else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
1783 | 1783 | if ($error != '') { |
1784 | 1784 | return $error; |
1785 | 1785 | } elseif ($globalDebug) echo "Done\n"; |
1786 | 1786 | if ($globalDebug) echo "Owner New Zealand: Download..."; |
1787 | - update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv'); |
|
1787 | + update_db::download('http://antonakis.co.uk/registers/NewZealand.txt', $tmp_dir.'owner_zk.csv'); |
|
1788 | 1788 | if (file_exists($tmp_dir.'owner_zk.csv')) { |
1789 | 1789 | if ($globalDebug) echo "Add to DB..."; |
1790 | - $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK'); |
|
1790 | + $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv', 'ZK'); |
|
1791 | 1791 | } else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
1792 | 1792 | if ($error != '') { |
1793 | 1793 | return $error; |
1794 | 1794 | } elseif ($globalDebug) echo "Done\n"; |
1795 | 1795 | if ($globalDebug) echo "Owner Papua New Guinea: Download..."; |
1796 | - update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv'); |
|
1796 | + update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt', $tmp_dir.'owner_p2.csv'); |
|
1797 | 1797 | if (file_exists($tmp_dir.'owner_p2.csv')) { |
1798 | 1798 | if ($globalDebug) echo "Add to DB..."; |
1799 | - $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2'); |
|
1799 | + $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv', 'P2'); |
|
1800 | 1800 | } else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
1801 | 1801 | if ($error != '') { |
1802 | 1802 | return $error; |
1803 | 1803 | } elseif ($globalDebug) echo "Done\n"; |
1804 | 1804 | if ($globalDebug) echo "Owner Slovakia: Download..."; |
1805 | - update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv'); |
|
1805 | + update_db::download('http://antonakis.co.uk/registers/Slovakia.txt', $tmp_dir.'owner_om.csv'); |
|
1806 | 1806 | if (file_exists($tmp_dir.'owner_om.csv')) { |
1807 | 1807 | if ($globalDebug) echo "Add to DB..."; |
1808 | - $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM'); |
|
1808 | + $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv', 'OM'); |
|
1809 | 1809 | } else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
1810 | 1810 | if ($error != '') { |
1811 | 1811 | return $error; |
1812 | 1812 | } elseif ($globalDebug) echo "Done\n"; |
1813 | 1813 | if ($globalDebug) echo "Owner Ecuador: Download..."; |
1814 | - update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv'); |
|
1814 | + update_db::download('http://antonakis.co.uk/registers/Ecuador.txt', $tmp_dir.'owner_hc.csv'); |
|
1815 | 1815 | if (file_exists($tmp_dir.'owner_hc.csv')) { |
1816 | 1816 | if ($globalDebug) echo "Add to DB..."; |
1817 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC'); |
|
1817 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv', 'HC'); |
|
1818 | 1818 | } else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
1819 | 1819 | if ($error != '') { |
1820 | 1820 | return $error; |
1821 | 1821 | } elseif ($globalDebug) echo "Done\n"; |
1822 | 1822 | if ($globalDebug) echo "Owner Iceland: Download..."; |
1823 | - update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv'); |
|
1823 | + update_db::download('http://antonakis.co.uk/registers/Iceland.txt', $tmp_dir.'owner_tf.csv'); |
|
1824 | 1824 | if (file_exists($tmp_dir.'owner_tf.csv')) { |
1825 | 1825 | if ($globalDebug) echo "Add to DB..."; |
1826 | - $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF'); |
|
1826 | + $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv', 'TF'); |
|
1827 | 1827 | } else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
1828 | 1828 | if ($error != '') { |
1829 | 1829 | return $error; |
@@ -1835,7 +1835,7 @@ discard block |
||
1835 | 1835 | global $tmp_dir, $globalDebug; |
1836 | 1836 | $error = ''; |
1837 | 1837 | if ($globalDebug) echo "Translation : Download..."; |
1838 | - update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip'); |
|
1838 | + update_db::download('http://www.acarsd.org/download/translation.php', $tmp_dir.'translation.zip'); |
|
1839 | 1839 | if (file_exists($tmp_dir.'translation.zip')) { |
1840 | 1840 | if ($globalDebug) echo "Unzip..."; |
1841 | 1841 | update_db::unzip($tmp_dir.'translation.zip'); |
@@ -1851,7 +1851,7 @@ discard block |
||
1851 | 1851 | public static function update_translation_fam() { |
1852 | 1852 | global $tmp_dir, $globalDebug; |
1853 | 1853 | if ($globalDebug) echo "Translation from FlightAirMap website : Download..."; |
1854 | - update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz'); |
|
1854 | + update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz', $tmp_dir.'translation.tsv.gz'); |
|
1855 | 1855 | if (file_exists($tmp_dir.'translation.tsv.gz')) { |
1856 | 1856 | if ($globalDebug) echo "Gunzip..."; |
1857 | 1857 | update_db::gunzip($tmp_dir.'translation.tsv.gz'); |
@@ -1866,7 +1866,7 @@ discard block |
||
1866 | 1866 | public static function update_ModeS_fam() { |
1867 | 1867 | global $tmp_dir, $globalDebug; |
1868 | 1868 | if ($globalDebug) echo "ModeS from FlightAirMap website : Download..."; |
1869 | - update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz'); |
|
1869 | + update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz', $tmp_dir.'modes.tsv.gz'); |
|
1870 | 1870 | if (file_exists($tmp_dir.'modes.tsv.gz')) { |
1871 | 1871 | if ($globalDebug) echo "Gunzip..."; |
1872 | 1872 | update_db::gunzip($tmp_dir.'modes.tsv.gz'); |
@@ -1882,9 +1882,9 @@ discard block |
||
1882 | 1882 | global $tmp_dir, $globalDebug, $globalOwner; |
1883 | 1883 | if ($globalDebug) echo "owner from FlightAirMap website : Download..."; |
1884 | 1884 | if ($globalOwner === TRUE) { |
1885 | - update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz'); |
|
1885 | + update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz', $tmp_dir.'owners.tsv.gz'); |
|
1886 | 1886 | } else { |
1887 | - update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz',$tmp_dir.'owners.tsv.gz'); |
|
1887 | + update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz', $tmp_dir.'owners.tsv.gz'); |
|
1888 | 1888 | } |
1889 | 1889 | if (file_exists($tmp_dir.'owners.tsv.gz')) { |
1890 | 1890 | if ($globalDebug) echo "Gunzip..."; |
@@ -1900,7 +1900,7 @@ discard block |
||
1900 | 1900 | public static function update_routes_fam() { |
1901 | 1901 | global $tmp_dir, $globalDebug; |
1902 | 1902 | if ($globalDebug) echo "Routes from FlightAirMap website : Download..."; |
1903 | - update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz'); |
|
1903 | + update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz', $tmp_dir.'routes.tsv.gz'); |
|
1904 | 1904 | if (file_exists($tmp_dir.'routes.tsv.gz')) { |
1905 | 1905 | if ($globalDebug) echo "Gunzip..."; |
1906 | 1906 | update_db::gunzip($tmp_dir.'routes.tsv.gz'); |
@@ -1915,7 +1915,7 @@ discard block |
||
1915 | 1915 | public static function update_banned_fam() { |
1916 | 1916 | global $tmp_dir, $globalDebug; |
1917 | 1917 | if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download..."; |
1918 | - update_db::download('http://data.flightairmap.fr/data/ban_eu.csv',$tmp_dir.'ban_eu.csv'); |
|
1918 | + update_db::download('http://data.flightairmap.fr/data/ban_eu.csv', $tmp_dir.'ban_eu.csv'); |
|
1919 | 1919 | if (file_exists($tmp_dir.'ban_eu.csv')) { |
1920 | 1920 | //if ($globalDebug) echo "Gunzip..."; |
1921 | 1921 | //update_db::gunzip($tmp_dir.'ban_ue.csv'); |
@@ -1934,18 +1934,18 @@ discard block |
||
1934 | 1934 | $error = ''; |
1935 | 1935 | if ($globalDebug) echo "Airspace from FlightAirMap website : Download..."; |
1936 | 1936 | if ($globalDBdriver == 'mysql') { |
1937 | - update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); |
|
1937 | + update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5'); |
|
1938 | 1938 | } else { |
1939 | - update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); |
|
1939 | + update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5'); |
|
1940 | 1940 | } |
1941 | 1941 | if (file_exists($tmp_dir.'airspace.sql.gz.md5')) { |
1942 | - $airspace_md5_file = explode(' ',file_get_contents($tmp_dir.'airspace.sql.gz.md5')); |
|
1942 | + $airspace_md5_file = explode(' ', file_get_contents($tmp_dir.'airspace.sql.gz.md5')); |
|
1943 | 1943 | $airspace_md5 = $airspace_md5_file[0]; |
1944 | 1944 | if (!update_db::check_airspace_version($airspace_md5)) { |
1945 | 1945 | if ($globalDBdriver == 'mysql') { |
1946 | - update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz',$tmp_dir.'airspace.sql.gz'); |
|
1946 | + update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz', $tmp_dir.'airspace.sql.gz'); |
|
1947 | 1947 | } else { |
1948 | - update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz'); |
|
1948 | + update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz', $tmp_dir.'airspace.sql.gz'); |
|
1949 | 1949 | } |
1950 | 1950 | if (file_exists($tmp_dir.'airspace.sql.gz')) { |
1951 | 1951 | if ($globalDebug) echo "Gunzip..."; |
@@ -1957,7 +1957,7 @@ discard block |
||
1957 | 1957 | try { |
1958 | 1958 | $sth = $Connection->db->prepare($query); |
1959 | 1959 | $sth->execute(); |
1960 | - } catch(PDOException $e) { |
|
1960 | + } catch (PDOException $e) { |
|
1961 | 1961 | return "error : ".$e->getMessage(); |
1962 | 1962 | } |
1963 | 1963 | } |
@@ -1975,15 +1975,15 @@ discard block |
||
1975 | 1975 | public static function update_tle() { |
1976 | 1976 | global $tmp_dir, $globalDebug; |
1977 | 1977 | if ($globalDebug) echo "Download TLE : Download..."; |
1978 | - $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', |
|
1979 | - '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', |
|
1980 | - 'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt'); |
|
1978 | + $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', |
|
1979 | + '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', |
|
1980 | + 'engineering.txt', 'education.txt', 'military.txt', 'radar.txt', 'cubesat.txt', 'other.txt', 'tle-new.txt'); |
|
1981 | 1981 | foreach ($alltle as $filename) { |
1982 | 1982 | if ($globalDebug) echo "downloading ".$filename.'...'; |
1983 | - update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename); |
|
1983 | + update_db::download('http://celestrak.com/NORAD/elements/'.$filename, $tmp_dir.$filename); |
|
1984 | 1984 | if (file_exists($tmp_dir.$filename)) { |
1985 | 1985 | if ($globalDebug) echo "Add to DB ".$filename."..."; |
1986 | - $error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename)); |
|
1986 | + $error = update_db::tle($tmp_dir.$filename, str_replace('.txt', '', $filename)); |
|
1987 | 1987 | } else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
1988 | 1988 | if ($error != '') { |
1989 | 1989 | echo $error."\n"; |
@@ -1996,32 +1996,32 @@ discard block |
||
1996 | 1996 | global $tmp_dir, $globalDebug; |
1997 | 1997 | $error = ''; |
1998 | 1998 | if ($globalDebug) echo "Models from FlightAirMap website : Download..."; |
1999 | - update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum'); |
|
1999 | + update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', $tmp_dir.'models.md5sum'); |
|
2000 | 2000 | if (file_exists($tmp_dir.'models.md5sum')) { |
2001 | 2001 | if ($globalDebug) echo "Check files...\n"; |
2002 | 2002 | $newmodelsdb = array(); |
2003 | - if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) { |
|
2004 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
2003 | + if (($handle = fopen($tmp_dir.'models.md5sum', 'r')) !== FALSE) { |
|
2004 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
2005 | 2005 | $model = trim($row[2]); |
2006 | 2006 | $newmodelsdb[$model] = trim($row[0]); |
2007 | 2007 | } |
2008 | 2008 | } |
2009 | 2009 | $modelsdb = array(); |
2010 | 2010 | if (file_exists(dirname(__FILE__).'/../models/models.md5sum')) { |
2011 | - if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum','r')) !== FALSE) { |
|
2012 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
2011 | + if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum', 'r')) !== FALSE) { |
|
2012 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
2013 | 2013 | $model = trim($row[2]); |
2014 | 2014 | $modelsdb[$model] = trim($row[0]); |
2015 | 2015 | } |
2016 | 2016 | } |
2017 | 2017 | } |
2018 | - $diff = array_diff($newmodelsdb,$modelsdb); |
|
2018 | + $diff = array_diff($newmodelsdb, $modelsdb); |
|
2019 | 2019 | foreach ($diff as $key => $value) { |
2020 | 2020 | if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n"; |
2021 | - update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key); |
|
2021 | + update_db::download('http://data.flightairmap.fr/data/models/'.$key, dirname(__FILE__).'/../models/'.$key); |
|
2022 | 2022 | |
2023 | 2023 | } |
2024 | - update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum'); |
|
2024 | + update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', dirname(__FILE__).'/../models/models.md5sum'); |
|
2025 | 2025 | } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
2026 | 2026 | if ($error != '') { |
2027 | 2027 | return $error; |
@@ -2033,32 +2033,32 @@ discard block |
||
2033 | 2033 | global $tmp_dir, $globalDebug; |
2034 | 2034 | $error = ''; |
2035 | 2035 | if ($globalDebug) echo "Space models from FlightAirMap website : Download..."; |
2036 | - update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum'); |
|
2036 | + update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', $tmp_dir.'space_models.md5sum'); |
|
2037 | 2037 | if (file_exists($tmp_dir.'space_models.md5sum')) { |
2038 | 2038 | if ($globalDebug) echo "Check files...\n"; |
2039 | 2039 | $newmodelsdb = array(); |
2040 | - if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) { |
|
2041 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
2040 | + if (($handle = fopen($tmp_dir.'space_models.md5sum', 'r')) !== FALSE) { |
|
2041 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
2042 | 2042 | $model = trim($row[2]); |
2043 | 2043 | $newmodelsdb[$model] = trim($row[0]); |
2044 | 2044 | } |
2045 | 2045 | } |
2046 | 2046 | $modelsdb = array(); |
2047 | 2047 | if (file_exists(dirname(__FILE__).'/../models/space/space_models.md5sum')) { |
2048 | - if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum','r')) !== FALSE) { |
|
2049 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
2048 | + if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum', 'r')) !== FALSE) { |
|
2049 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
2050 | 2050 | $model = trim($row[2]); |
2051 | 2051 | $modelsdb[$model] = trim($row[0]); |
2052 | 2052 | } |
2053 | 2053 | } |
2054 | 2054 | } |
2055 | - $diff = array_diff($newmodelsdb,$modelsdb); |
|
2055 | + $diff = array_diff($newmodelsdb, $modelsdb); |
|
2056 | 2056 | foreach ($diff as $key => $value) { |
2057 | 2057 | if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n"; |
2058 | - update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key); |
|
2058 | + update_db::download('http://data.flightairmap.fr/data/models/space/'.$key, dirname(__FILE__).'/../models/space/'.$key); |
|
2059 | 2059 | |
2060 | 2060 | } |
2061 | - update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum'); |
|
2061 | + update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', dirname(__FILE__).'/../models/space/space_models.md5sum'); |
|
2062 | 2062 | } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
2063 | 2063 | if ($error != '') { |
2064 | 2064 | return $error; |
@@ -2081,8 +2081,8 @@ discard block |
||
2081 | 2081 | */ |
2082 | 2082 | if (file_exists($tmp_dir.'aircrafts.html')) { |
2083 | 2083 | //var_dump(file_get_html($tmp_dir.'aircrafts.html')); |
2084 | - $fh = fopen($tmp_dir.'aircrafts.html',"r"); |
|
2085 | - $result = fread($fh,100000000); |
|
2084 | + $fh = fopen($tmp_dir.'aircrafts.html', "r"); |
|
2085 | + $result = fread($fh, 100000000); |
|
2086 | 2086 | //echo $result; |
2087 | 2087 | //var_dump(str_get_html($result)); |
2088 | 2088 | //print_r(self::table2array($result)); |
@@ -2100,23 +2100,23 @@ discard block |
||
2100 | 2100 | $Connection = new Connection(); |
2101 | 2101 | $sth = $Connection->db->prepare($query); |
2102 | 2102 | $sth->execute(); |
2103 | - } catch(PDOException $e) { |
|
2103 | + } catch (PDOException $e) { |
|
2104 | 2104 | return "error : ".$e->getMessage(); |
2105 | 2105 | } |
2106 | 2106 | |
2107 | 2107 | $error = ''; |
2108 | 2108 | if ($globalDebug) echo "Notam : Download..."; |
2109 | - update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss'); |
|
2109 | + update_db::download($globalNOTAMSource, $tmp_dir.'notam.rss'); |
|
2110 | 2110 | if (file_exists($tmp_dir.'notam.rss')) { |
2111 | - $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true); |
|
2111 | + $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')), true); |
|
2112 | 2112 | foreach ($notams['channel']['item'] as $notam) { |
2113 | - $title = explode(':',$notam['title']); |
|
2113 | + $title = explode(':', $notam['title']); |
|
2114 | 2114 | $data['ref'] = trim($title[0]); |
2115 | 2115 | unset($title[0]); |
2116 | - $data['title'] = trim(implode(':',$title)); |
|
2117 | - $description = strip_tags($notam['description'],'<pre>'); |
|
2118 | - preg_match(':^(.*?)<pre>:',$description,$match); |
|
2119 | - $q = explode('/',$match[1]); |
|
2116 | + $data['title'] = trim(implode(':', $title)); |
|
2117 | + $description = strip_tags($notam['description'], '<pre>'); |
|
2118 | + preg_match(':^(.*?)<pre>:', $description, $match); |
|
2119 | + $q = explode('/', $match[1]); |
|
2120 | 2120 | $data['fir'] = $q[0]; |
2121 | 2121 | $data['code'] = $q[1]; |
2122 | 2122 | $ifrvfr = $q[2]; |
@@ -2132,30 +2132,30 @@ discard block |
||
2132 | 2132 | $data['lower_limit'] = $q[5]; |
2133 | 2133 | $data['upper_limit'] = $q[6]; |
2134 | 2134 | $latlonrad = $q[7]; |
2135 | - sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius); |
|
2136 | - $latitude = $Common->convertDec($las,'latitude'); |
|
2137 | - $longitude = $Common->convertDec($lns,'longitude'); |
|
2135 | + sscanf($latlonrad, '%4c%c%5c%c%3d', $las, $lac, $lns, $lnc, $radius); |
|
2136 | + $latitude = $Common->convertDec($las, 'latitude'); |
|
2137 | + $longitude = $Common->convertDec($lns, 'longitude'); |
|
2138 | 2138 | if ($lac == 'S') $latitude = '-'.$latitude; |
2139 | 2139 | if ($lnc == 'W') $longitude = '-'.$longitude; |
2140 | 2140 | $data['center_latitude'] = $latitude; |
2141 | 2141 | $data['center_longitude'] = $longitude; |
2142 | 2142 | $data['radius'] = intval($radius); |
2143 | 2143 | |
2144 | - preg_match(':<pre>(.*?)</pre>:',$description,$match); |
|
2144 | + preg_match(':<pre>(.*?)</pre>:', $description, $match); |
|
2145 | 2145 | $data['text'] = $match[1]; |
2146 | - preg_match(':</pre>(.*?)$:',$description,$match); |
|
2146 | + preg_match(':</pre>(.*?)$:', $description, $match); |
|
2147 | 2147 | $fromto = $match[1]; |
2148 | - preg_match('#FROM:(.*?)TO:#',$fromto,$match); |
|
2148 | + preg_match('#FROM:(.*?)TO:#', $fromto, $match); |
|
2149 | 2149 | $fromall = trim($match[1]); |
2150 | - preg_match('#^(.*?) \((.*?)\)$#',$fromall,$match); |
|
2150 | + preg_match('#^(.*?) \((.*?)\)$#', $fromall, $match); |
|
2151 | 2151 | $from = trim($match[1]); |
2152 | - $data['date_begin'] = date("Y-m-d H:i:s",strtotime($from)); |
|
2153 | - preg_match('#TO:(.*?)$#',$fromto,$match); |
|
2152 | + $data['date_begin'] = date("Y-m-d H:i:s", strtotime($from)); |
|
2153 | + preg_match('#TO:(.*?)$#', $fromto, $match); |
|
2154 | 2154 | $toall = trim($match[1]); |
2155 | - if (!preg_match(':Permanent:',$toall)) { |
|
2156 | - preg_match('#^(.*?) \((.*?)\)#',$toall,$match); |
|
2155 | + if (!preg_match(':Permanent:', $toall)) { |
|
2156 | + preg_match('#^(.*?) \((.*?)\)#', $toall, $match); |
|
2157 | 2157 | $to = trim($match[1]); |
2158 | - $data['date_end'] = date("Y-m-d H:i:s",strtotime($to)); |
|
2158 | + $data['date_end'] = date("Y-m-d H:i:s", strtotime($to)); |
|
2159 | 2159 | $data['permanent'] = 0; |
2160 | 2160 | } else { |
2161 | 2161 | $data['date_end'] = NULL; |
@@ -2163,7 +2163,7 @@ discard block |
||
2163 | 2163 | } |
2164 | 2164 | $data['full_notam'] = $notam['title'].'<br>'.$notam['description']; |
2165 | 2165 | $NOTAM = new NOTAM(); |
2166 | - $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']); |
|
2166 | + $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']); |
|
2167 | 2167 | unset($data); |
2168 | 2168 | } |
2169 | 2169 | } else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
@@ -2186,16 +2186,16 @@ discard block |
||
2186 | 2186 | $Connection = new Connection(); |
2187 | 2187 | $sth = $Connection->db->prepare($query); |
2188 | 2188 | $sth->execute(); |
2189 | - } catch(PDOException $e) { |
|
2189 | + } catch (PDOException $e) { |
|
2190 | 2190 | return "error : ".$e->getMessage(); |
2191 | 2191 | } |
2192 | 2192 | } |
2193 | 2193 | $Common = new Common(); |
2194 | 2194 | $airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json'); |
2195 | - $airspace_json = json_decode($airspace_lst,true); |
|
2195 | + $airspace_json = json_decode($airspace_lst, true); |
|
2196 | 2196 | foreach ($airspace_json['records'] as $airspace) { |
2197 | 2197 | if ($globalDebug) echo $airspace['name']."...\n"; |
2198 | - update_db::download($airspace['uri'],$tmp_dir.$airspace['name']); |
|
2198 | + update_db::download($airspace['uri'], $tmp_dir.$airspace['name']); |
|
2199 | 2199 | if (file_exists($tmp_dir.$airspace['name'])) { |
2200 | 2200 | file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name']))); |
2201 | 2201 | //system('recode l9..utf8 '.$tmp_dir.$airspace['name']); |
@@ -2219,7 +2219,7 @@ discard block |
||
2219 | 2219 | $Connection = new Connection(); |
2220 | 2220 | $sth = $Connection->db->prepare($query); |
2221 | 2221 | $sth->execute(); |
2222 | - } catch(PDOException $e) { |
|
2222 | + } catch (PDOException $e) { |
|
2223 | 2223 | return "error : ".$e->getMessage(); |
2224 | 2224 | } |
2225 | 2225 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2234,7 +2234,7 @@ discard block |
||
2234 | 2234 | $Connection = new Connection(); |
2235 | 2235 | $sth = $Connection->db->prepare($query); |
2236 | 2236 | $sth->execute(); |
2237 | - } catch(PDOException $e) { |
|
2237 | + } catch (PDOException $e) { |
|
2238 | 2238 | return "error : ".$e->getMessage(); |
2239 | 2239 | } |
2240 | 2240 | } |
@@ -2245,7 +2245,7 @@ discard block |
||
2245 | 2245 | $Connection = new Connection(); |
2246 | 2246 | $sth = $Connection->db->prepare($query); |
2247 | 2247 | $sth->execute(array(':version' => $version)); |
2248 | - } catch(PDOException $e) { |
|
2248 | + } catch (PDOException $e) { |
|
2249 | 2249 | return "error : ".$e->getMessage(); |
2250 | 2250 | } |
2251 | 2251 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2261,7 +2261,7 @@ discard block |
||
2261 | 2261 | $Connection = new Connection(); |
2262 | 2262 | $sth = $Connection->db->prepare($query); |
2263 | 2263 | $sth->execute(array(':version' => $version)); |
2264 | - } catch(PDOException $e) { |
|
2264 | + } catch (PDOException $e) { |
|
2265 | 2265 | return "error : ".$e->getMessage(); |
2266 | 2266 | } |
2267 | 2267 | } |
@@ -2277,7 +2277,7 @@ discard block |
||
2277 | 2277 | $Connection = new Connection(); |
2278 | 2278 | $sth = $Connection->db->prepare($query); |
2279 | 2279 | $sth->execute(); |
2280 | - } catch(PDOException $e) { |
|
2280 | + } catch (PDOException $e) { |
|
2281 | 2281 | return "error : ".$e->getMessage(); |
2282 | 2282 | } |
2283 | 2283 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2292,7 +2292,7 @@ discard block |
||
2292 | 2292 | $Connection = new Connection(); |
2293 | 2293 | $sth = $Connection->db->prepare($query); |
2294 | 2294 | $sth->execute(); |
2295 | - } catch(PDOException $e) { |
|
2295 | + } catch (PDOException $e) { |
|
2296 | 2296 | return "error : ".$e->getMessage(); |
2297 | 2297 | } |
2298 | 2298 | } |
@@ -2307,7 +2307,7 @@ discard block |
||
2307 | 2307 | $Connection = new Connection(); |
2308 | 2308 | $sth = $Connection->db->prepare($query); |
2309 | 2309 | $sth->execute(); |
2310 | - } catch(PDOException $e) { |
|
2310 | + } catch (PDOException $e) { |
|
2311 | 2311 | return "error : ".$e->getMessage(); |
2312 | 2312 | } |
2313 | 2313 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2322,7 +2322,7 @@ discard block |
||
2322 | 2322 | $Connection = new Connection(); |
2323 | 2323 | $sth = $Connection->db->prepare($query); |
2324 | 2324 | $sth->execute(); |
2325 | - } catch(PDOException $e) { |
|
2325 | + } catch (PDOException $e) { |
|
2326 | 2326 | return "error : ".$e->getMessage(); |
2327 | 2327 | } |
2328 | 2328 | } |
@@ -2338,7 +2338,7 @@ discard block |
||
2338 | 2338 | $Connection = new Connection(); |
2339 | 2339 | $sth = $Connection->db->prepare($query); |
2340 | 2340 | $sth->execute(); |
2341 | - } catch(PDOException $e) { |
|
2341 | + } catch (PDOException $e) { |
|
2342 | 2342 | return "error : ".$e->getMessage(); |
2343 | 2343 | } |
2344 | 2344 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2353,7 +2353,7 @@ discard block |
||
2353 | 2353 | $Connection = new Connection(); |
2354 | 2354 | $sth = $Connection->db->prepare($query); |
2355 | 2355 | $sth->execute(); |
2356 | - } catch(PDOException $e) { |
|
2356 | + } catch (PDOException $e) { |
|
2357 | 2357 | return "error : ".$e->getMessage(); |
2358 | 2358 | } |
2359 | 2359 | } |
@@ -2368,7 +2368,7 @@ discard block |
||
2368 | 2368 | $Connection = new Connection(); |
2369 | 2369 | $sth = $Connection->db->prepare($query); |
2370 | 2370 | $sth->execute(); |
2371 | - } catch(PDOException $e) { |
|
2371 | + } catch (PDOException $e) { |
|
2372 | 2372 | return "error : ".$e->getMessage(); |
2373 | 2373 | } |
2374 | 2374 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2383,7 +2383,7 @@ discard block |
||
2383 | 2383 | $Connection = new Connection(); |
2384 | 2384 | $sth = $Connection->db->prepare($query); |
2385 | 2385 | $sth->execute(); |
2386 | - } catch(PDOException $e) { |
|
2386 | + } catch (PDOException $e) { |
|
2387 | 2387 | return "error : ".$e->getMessage(); |
2388 | 2388 | } |
2389 | 2389 | } |
@@ -2398,7 +2398,7 @@ discard block |
||
2398 | 2398 | $Connection = new Connection(); |
2399 | 2399 | $sth = $Connection->db->prepare($query); |
2400 | 2400 | $sth->execute(); |
2401 | - } catch(PDOException $e) { |
|
2401 | + } catch (PDOException $e) { |
|
2402 | 2402 | return "error : ".$e->getMessage(); |
2403 | 2403 | } |
2404 | 2404 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2413,7 +2413,7 @@ discard block |
||
2413 | 2413 | $Connection = new Connection(); |
2414 | 2414 | $sth = $Connection->db->prepare($query); |
2415 | 2415 | $sth->execute(); |
2416 | - } catch(PDOException $e) { |
|
2416 | + } catch (PDOException $e) { |
|
2417 | 2417 | return "error : ".$e->getMessage(); |
2418 | 2418 | } |
2419 | 2419 | } |
@@ -2428,7 +2428,7 @@ discard block |
||
2428 | 2428 | $Connection = new Connection(); |
2429 | 2429 | $sth = $Connection->db->prepare($query); |
2430 | 2430 | $sth->execute(); |
2431 | - } catch(PDOException $e) { |
|
2431 | + } catch (PDOException $e) { |
|
2432 | 2432 | return "error : ".$e->getMessage(); |
2433 | 2433 | } |
2434 | 2434 | } |
@@ -2443,7 +2443,7 @@ discard block |
||
2443 | 2443 | $Connection = new Connection(); |
2444 | 2444 | $sth = $Connection->db->prepare($query); |
2445 | 2445 | $sth->execute(); |
2446 | - } catch(PDOException $e) { |
|
2446 | + } catch (PDOException $e) { |
|
2447 | 2447 | return "error : ".$e->getMessage(); |
2448 | 2448 | } |
2449 | 2449 | } |
@@ -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 | } |
@@ -277,7 +324,9 @@ discard block |
||
277 | 324 | $Connection = new Connection(); |
278 | 325 | $sth_dest = $Connection->db->prepare($query_dest); |
279 | 326 | try { |
280 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
327 | + if ($globalTransaction) { |
|
328 | + $Connection->db->beginTransaction(); |
|
329 | + } |
|
281 | 330 | while (!feof($fh)) { |
282 | 331 | $values = array(); |
283 | 332 | $line = $Common->hex2str(fgets($fh,9999)); |
@@ -288,7 +337,9 @@ discard block |
||
288 | 337 | // Check if we can find ICAO, else set it to GLID |
289 | 338 | $aircraft_name_split = explode(' ',$aircraft_name); |
290 | 339 | $search_more = ''; |
291 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
340 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) { |
|
341 | + $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
342 | + } |
|
292 | 343 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
293 | 344 | $sth_search = $Connection->db->prepare($query_search); |
294 | 345 | try { |
@@ -301,7 +352,9 @@ discard block |
||
301 | 352 | } catch(PDOException $e) { |
302 | 353 | return "error : ".$e->getMessage(); |
303 | 354 | } |
304 | - if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID'; |
|
355 | + if (!isset($values['ICAOTypeCode'])) { |
|
356 | + $values['ICAOTypeCode'] = 'GLID'; |
|
357 | + } |
|
305 | 358 | // Add data to db |
306 | 359 | if ($values['Registration'] != '' && $values['Registration'] != '0000') { |
307 | 360 | //$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']); |
@@ -310,7 +363,9 @@ discard block |
||
310 | 363 | $sth_dest->execute($query_dest_values); |
311 | 364 | } |
312 | 365 | } |
313 | - if ($globalTransaction) $Connection->db->commit(); |
|
366 | + if ($globalTransaction) { |
|
367 | + $Connection->db->commit(); |
|
368 | + } |
|
314 | 369 | } catch(PDOException $e) { |
315 | 370 | return "error : ".$e->getMessage(); |
316 | 371 | } |
@@ -346,7 +401,9 @@ discard block |
||
346 | 401 | $Connection = new Connection(); |
347 | 402 | $sth_dest = $Connection->db->prepare($query_dest); |
348 | 403 | try { |
349 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
404 | + if ($globalTransaction) { |
|
405 | + $Connection->db->beginTransaction(); |
|
406 | + } |
|
350 | 407 | $tmp = fgetcsv($fh,9999,',',"'"); |
351 | 408 | while (!feof($fh)) { |
352 | 409 | $line = fgetcsv($fh,9999,',',"'"); |
@@ -359,13 +416,17 @@ discard block |
||
359 | 416 | // Check if we can find ICAO, else set it to GLID |
360 | 417 | $aircraft_name_split = explode(' ',$aircraft_name); |
361 | 418 | $search_more = ''; |
362 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
419 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) { |
|
420 | + $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
421 | + } |
|
363 | 422 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
364 | 423 | $sth_search = $Connection->db->prepare($query_search); |
365 | 424 | try { |
366 | 425 | $sth_search->execute(); |
367 | 426 | $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
368 | - if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
|
427 | + if (isset($result['icao']) && $result['icao'] != '') { |
|
428 | + $values['ICAOTypeCode'] = $result['icao']; |
|
429 | + } |
|
369 | 430 | } catch(PDOException $e) { |
370 | 431 | return "error : ".$e->getMessage(); |
371 | 432 | } |
@@ -378,7 +439,9 @@ discard block |
||
378 | 439 | $sth_dest->execute($query_dest_values); |
379 | 440 | } |
380 | 441 | } |
381 | - if ($globalTransaction) $Connection->db->commit(); |
|
442 | + if ($globalTransaction) { |
|
443 | + $Connection->db->commit(); |
|
444 | + } |
|
382 | 445 | } catch(PDOException $e) { |
383 | 446 | return "error : ".$e->getMessage(); |
384 | 447 | } |
@@ -414,7 +477,9 @@ discard block |
||
414 | 477 | $Connection = new Connection(); |
415 | 478 | $sth_dest = $Connection->db->prepare($query_dest); |
416 | 479 | try { |
417 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
480 | + if ($globalTransaction) { |
|
481 | + $Connection->db->beginTransaction(); |
|
482 | + } |
|
418 | 483 | $tmp = fgetcsv($fh,9999,',','"'); |
419 | 484 | while (!feof($fh)) { |
420 | 485 | $line = fgetcsv($fh,9999,',','"'); |
@@ -424,16 +489,22 @@ discard block |
||
424 | 489 | $values['registration'] = $line[0]; |
425 | 490 | $values['base'] = $line[4]; |
426 | 491 | $values['owner'] = $line[5]; |
427 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
428 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
492 | + if ($line[6] == '') { |
|
493 | + $values['date_first_reg'] = null; |
|
494 | + } else { |
|
495 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
496 | + } |
|
429 | 497 | $values['cancel'] = $line[7]; |
430 | 498 | } elseif ($country == 'EI') { |
431 | 499 | // TODO : add modeS & reg to aircraft_modes |
432 | 500 | $values['registration'] = $line[0]; |
433 | 501 | $values['base'] = $line[3]; |
434 | 502 | $values['owner'] = $line[2]; |
435 | - if ($line[1] == '') $values['date_first_reg'] = null; |
|
436 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
503 | + if ($line[1] == '') { |
|
504 | + $values['date_first_reg'] = null; |
|
505 | + } else { |
|
506 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
507 | + } |
|
437 | 508 | $values['cancel'] = ''; |
438 | 509 | } elseif ($country == 'HB') { |
439 | 510 | // TODO : add modeS & reg to aircraft_modes |
@@ -447,16 +518,22 @@ discard block |
||
447 | 518 | $values['registration'] = $line[3]; |
448 | 519 | $values['base'] = null; |
449 | 520 | $values['owner'] = $line[5]; |
450 | - if ($line[18] == '') $values['date_first_reg'] = null; |
|
451 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
521 | + if ($line[18] == '') { |
|
522 | + $values['date_first_reg'] = null; |
|
523 | + } else { |
|
524 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
525 | + } |
|
452 | 526 | $values['cancel'] = ''; |
453 | 527 | } elseif ($country == 'VH') { |
454 | 528 | // TODO : add modeS & reg to aircraft_modes |
455 | 529 | $values['registration'] = $line[0]; |
456 | 530 | $values['base'] = null; |
457 | 531 | $values['owner'] = $line[12]; |
458 | - if ($line[28] == '') $values['date_first_reg'] = null; |
|
459 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
532 | + if ($line[28] == '') { |
|
533 | + $values['date_first_reg'] = null; |
|
534 | + } else { |
|
535 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
536 | + } |
|
460 | 537 | |
461 | 538 | $values['cancel'] = $line[39]; |
462 | 539 | } elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { |
@@ -475,29 +552,41 @@ discard block |
||
475 | 552 | $values['registration'] = $line[0]; |
476 | 553 | $values['base'] = null; |
477 | 554 | $values['owner'] = $line[8]; |
478 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
479 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
555 | + if ($line[7] == '') { |
|
556 | + $values['date_first_reg'] = null; |
|
557 | + } else { |
|
558 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
559 | + } |
|
480 | 560 | $values['cancel'] = ''; |
481 | 561 | } elseif ($country == 'PP') { |
482 | 562 | $values['registration'] = $line[0]; |
483 | 563 | $values['base'] = null; |
484 | 564 | $values['owner'] = $line[4]; |
485 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
486 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
565 | + if ($line[6] == '') { |
|
566 | + $values['date_first_reg'] = null; |
|
567 | + } else { |
|
568 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
569 | + } |
|
487 | 570 | $values['cancel'] = $line[7]; |
488 | 571 | } elseif ($country == 'E7') { |
489 | 572 | $values['registration'] = $line[0]; |
490 | 573 | $values['base'] = null; |
491 | 574 | $values['owner'] = $line[4]; |
492 | - if ($line[5] == '') $values['date_first_reg'] = null; |
|
493 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
575 | + if ($line[5] == '') { |
|
576 | + $values['date_first_reg'] = null; |
|
577 | + } else { |
|
578 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
579 | + } |
|
494 | 580 | $values['cancel'] = ''; |
495 | 581 | } elseif ($country == '8Q') { |
496 | 582 | $values['registration'] = $line[0]; |
497 | 583 | $values['base'] = null; |
498 | 584 | $values['owner'] = $line[3]; |
499 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
500 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
585 | + if ($line[7] == '') { |
|
586 | + $values['date_first_reg'] = null; |
|
587 | + } else { |
|
588 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
589 | + } |
|
501 | 590 | $values['cancel'] = ''; |
502 | 591 | } elseif ($country == 'ZK' || $country == 'OM' || $country == 'TF') { |
503 | 592 | $values['registration'] = $line[0]; |
@@ -511,7 +600,9 @@ discard block |
||
511 | 600 | $sth_dest->execute($query_dest_values); |
512 | 601 | } |
513 | 602 | } |
514 | - if ($globalTransaction) $Connection->db->commit(); |
|
603 | + if ($globalTransaction) { |
|
604 | + $Connection->db->commit(); |
|
605 | + } |
|
515 | 606 | } catch(PDOException $e) { |
516 | 607 | return "error : ".$e->getMessage(); |
517 | 608 | } |
@@ -645,25 +736,45 @@ discard block |
||
645 | 736 | VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)"; |
646 | 737 | $Connection = new Connection(); |
647 | 738 | $sth_dest = $Connection->db->prepare($query_dest); |
648 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
739 | + if ($globalTransaction) { |
|
740 | + $Connection->db->beginTransaction(); |
|
741 | + } |
|
649 | 742 | |
650 | 743 | $i = 0; |
651 | 744 | while($row = sparql_fetch_array($result)) |
652 | 745 | { |
653 | 746 | if ($i >= 1) { |
654 | 747 | //print_r($row); |
655 | - if (!isset($row['iata'])) $row['iata'] = ''; |
|
656 | - if (!isset($row['icao'])) $row['icao'] = ''; |
|
657 | - if (!isset($row['type'])) $row['type'] = ''; |
|
658 | - if (!isset($row['altitude'])) $row['altitude'] = ''; |
|
748 | + if (!isset($row['iata'])) { |
|
749 | + $row['iata'] = ''; |
|
750 | + } |
|
751 | + if (!isset($row['icao'])) { |
|
752 | + $row['icao'] = ''; |
|
753 | + } |
|
754 | + if (!isset($row['type'])) { |
|
755 | + $row['type'] = ''; |
|
756 | + } |
|
757 | + if (!isset($row['altitude'])) { |
|
758 | + $row['altitude'] = ''; |
|
759 | + } |
|
659 | 760 | if (isset($row['city_bis'])) { |
660 | 761 | $row['city'] = $row['city_bis']; |
661 | 762 | } |
662 | - if (!isset($row['city'])) $row['city'] = ''; |
|
663 | - if (!isset($row['country'])) $row['country'] = ''; |
|
664 | - if (!isset($row['homepage'])) $row['homepage'] = ''; |
|
665 | - if (!isset($row['wikipedia_page'])) $row['wikipedia_page'] = ''; |
|
666 | - if (!isset($row['name'])) continue; |
|
763 | + if (!isset($row['city'])) { |
|
764 | + $row['city'] = ''; |
|
765 | + } |
|
766 | + if (!isset($row['country'])) { |
|
767 | + $row['country'] = ''; |
|
768 | + } |
|
769 | + if (!isset($row['homepage'])) { |
|
770 | + $row['homepage'] = ''; |
|
771 | + } |
|
772 | + if (!isset($row['wikipedia_page'])) { |
|
773 | + $row['wikipedia_page'] = ''; |
|
774 | + } |
|
775 | + if (!isset($row['name'])) { |
|
776 | + continue; |
|
777 | + } |
|
667 | 778 | if (!isset($row['image'])) { |
668 | 779 | $row['image'] = ''; |
669 | 780 | $row['image_thumb'] = ''; |
@@ -699,7 +810,9 @@ discard block |
||
699 | 810 | |
700 | 811 | $i++; |
701 | 812 | } |
702 | - if ($globalTransaction) $Connection->db->commit(); |
|
813 | + if ($globalTransaction) { |
|
814 | + $Connection->db->commit(); |
|
815 | + } |
|
703 | 816 | echo "Delete duplicate rows...\n"; |
704 | 817 | $query = 'ALTER IGNORE TABLE airport ADD UNIQUE INDEX icaoidx (icao)'; |
705 | 818 | try { |
@@ -711,7 +824,9 @@ discard block |
||
711 | 824 | } |
712 | 825 | |
713 | 826 | |
714 | - if ($globalDebug) echo "Insert Not available Airport...\n"; |
|
827 | + if ($globalDebug) { |
|
828 | + echo "Insert Not available Airport...\n"; |
|
829 | + } |
|
715 | 830 | $query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image`,`image_thumb`) |
716 | 831 | VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image, :image_thumb)"; |
717 | 832 | $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' => ''); |
@@ -738,7 +853,9 @@ discard block |
||
738 | 853 | $delimiter = ','; |
739 | 854 | $out_file = $tmp_dir.'airports.csv'; |
740 | 855 | update_db::download('http://ourairports.com/data/airports.csv',$out_file); |
741 | - if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
|
856 | + if (!file_exists($out_file) || !is_readable($out_file)) { |
|
857 | + return FALSE; |
|
858 | + } |
|
742 | 859 | echo "Add data from ourairports.com...\n"; |
743 | 860 | |
744 | 861 | $header = NULL; |
@@ -748,8 +865,9 @@ discard block |
||
748 | 865 | //$Connection->db->beginTransaction(); |
749 | 866 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
750 | 867 | { |
751 | - if(!$header) $header = $row; |
|
752 | - else { |
|
868 | + if(!$header) { |
|
869 | + $header = $row; |
|
870 | + } else { |
|
753 | 871 | $data = array(); |
754 | 872 | $data = array_combine($header, $row); |
755 | 873 | try { |
@@ -787,7 +905,9 @@ discard block |
||
787 | 905 | echo "Download data from another free database...\n"; |
788 | 906 | $out_file = $tmp_dir.'GlobalAirportDatabase.zip'; |
789 | 907 | update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file); |
790 | - if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
|
908 | + if (!file_exists($out_file) || !is_readable($out_file)) { |
|
909 | + return FALSE; |
|
910 | + } |
|
791 | 911 | update_db::unzip($out_file); |
792 | 912 | $header = NULL; |
793 | 913 | echo "Add data from another free database...\n"; |
@@ -798,8 +918,9 @@ discard block |
||
798 | 918 | //$Connection->db->beginTransaction(); |
799 | 919 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
800 | 920 | { |
801 | - if(!$header) $header = $row; |
|
802 | - else { |
|
921 | + if(!$header) { |
|
922 | + $header = $row; |
|
923 | + } else { |
|
803 | 924 | $data = $row; |
804 | 925 | |
805 | 926 | $query = 'UPDATE airport SET `city` = :city, `country` = :country WHERE icao = :icao'; |
@@ -975,7 +1096,9 @@ discard block |
||
975 | 1096 | if (($handle = fopen($tmp_dir.'MASTER.txt', 'r')) !== FALSE) |
976 | 1097 | { |
977 | 1098 | $i = 0; |
978 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1099 | + if ($globalTransaction) { |
|
1100 | + $Connection->db->beginTransaction(); |
|
1101 | + } |
|
979 | 1102 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
980 | 1103 | { |
981 | 1104 | if ($i > 0) { |
@@ -988,7 +1111,9 @@ discard block |
||
988 | 1111 | } |
989 | 1112 | $result_search = $sths->fetchAll(PDO::FETCH_ASSOC); |
990 | 1113 | if (!empty($result_search)) { |
991 | - if ($globalDebug) echo '.'; |
|
1114 | + if ($globalDebug) { |
|
1115 | + echo '.'; |
|
1116 | + } |
|
992 | 1117 | //if ($globalDBdriver == 'mysql') { |
993 | 1118 | // $queryi = 'INSERT INTO faamfr (mfr,icao) VALUES (:mfr,:icao) ON DUPLICATE KEY UPDATE icao = :icao'; |
994 | 1119 | //} else { |
@@ -1010,8 +1135,12 @@ discard block |
||
1010 | 1135 | } |
1011 | 1136 | $result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC); |
1012 | 1137 | if (!empty($result_search_mfr)) { |
1013 | - if (trim($data[16]) == '' && trim($data[23]) != '') $data[16] = $data[23]; |
|
1014 | - if (trim($data[16]) == '' && trim($data[15]) != '') $data[16] = $data[15]; |
|
1138 | + if (trim($data[16]) == '' && trim($data[23]) != '') { |
|
1139 | + $data[16] = $data[23]; |
|
1140 | + } |
|
1141 | + if (trim($data[16]) == '' && trim($data[15]) != '') { |
|
1142 | + $data[16] = $data[15]; |
|
1143 | + } |
|
1015 | 1144 | $queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)'; |
1016 | 1145 | try { |
1017 | 1146 | $sthf = $Connection->db->prepare($queryf); |
@@ -1022,7 +1151,9 @@ discard block |
||
1022 | 1151 | } |
1023 | 1152 | } |
1024 | 1153 | if (strtotime($data[29]) > time()) { |
1025 | - if ($globalDebug) echo 'i'; |
|
1154 | + if ($globalDebug) { |
|
1155 | + echo 'i'; |
|
1156 | + } |
|
1026 | 1157 | $query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)'; |
1027 | 1158 | try { |
1028 | 1159 | $sth = $Connection->db->prepare($query); |
@@ -1033,13 +1164,19 @@ discard block |
||
1033 | 1164 | } |
1034 | 1165 | } |
1035 | 1166 | if ($i % 90 == 0) { |
1036 | - if ($globalTransaction) $Connection->db->commit(); |
|
1037 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1167 | + if ($globalTransaction) { |
|
1168 | + $Connection->db->commit(); |
|
1169 | + } |
|
1170 | + if ($globalTransaction) { |
|
1171 | + $Connection->db->beginTransaction(); |
|
1172 | + } |
|
1038 | 1173 | } |
1039 | 1174 | $i++; |
1040 | 1175 | } |
1041 | 1176 | fclose($handle); |
1042 | - if ($globalTransaction) $Connection->db->commit(); |
|
1177 | + if ($globalTransaction) { |
|
1178 | + $Connection->db->commit(); |
|
1179 | + } |
|
1043 | 1180 | } |
1044 | 1181 | print_r($mfr); |
1045 | 1182 | return ''; |
@@ -1064,7 +1201,9 @@ discard block |
||
1064 | 1201 | $i = 0; |
1065 | 1202 | //$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE); |
1066 | 1203 | //$Connection->db->beginTransaction(); |
1067 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1204 | + if ($globalTransaction) { |
|
1205 | + $Connection->db->beginTransaction(); |
|
1206 | + } |
|
1068 | 1207 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1069 | 1208 | { |
1070 | 1209 | if ($i > 0) { |
@@ -1079,7 +1218,9 @@ discard block |
||
1079 | 1218 | $i++; |
1080 | 1219 | } |
1081 | 1220 | fclose($handle); |
1082 | - if ($globalTransaction) $Connection->db->commit(); |
|
1221 | + if ($globalTransaction) { |
|
1222 | + $Connection->db->commit(); |
|
1223 | + } |
|
1083 | 1224 | } |
1084 | 1225 | return ''; |
1085 | 1226 | } |
@@ -1100,7 +1241,9 @@ discard block |
||
1100 | 1241 | if (($handle = fopen($tmp_dir.'owners.tsv', 'r')) !== FALSE) |
1101 | 1242 | { |
1102 | 1243 | $i = 0; |
1103 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1244 | + if ($globalTransaction) { |
|
1245 | + $Connection->db->beginTransaction(); |
|
1246 | + } |
|
1104 | 1247 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1105 | 1248 | { |
1106 | 1249 | if ($i > 0) { |
@@ -1116,7 +1259,9 @@ discard block |
||
1116 | 1259 | $i++; |
1117 | 1260 | } |
1118 | 1261 | fclose($handle); |
1119 | - if ($globalTransaction) $Connection->db->commit(); |
|
1262 | + if ($globalTransaction) { |
|
1263 | + $Connection->db->commit(); |
|
1264 | + } |
|
1120 | 1265 | } |
1121 | 1266 | return ''; |
1122 | 1267 | } |
@@ -1141,7 +1286,9 @@ discard block |
||
1141 | 1286 | $i = 0; |
1142 | 1287 | //$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE); |
1143 | 1288 | //$Connection->db->beginTransaction(); |
1144 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1289 | + if ($globalTransaction) { |
|
1290 | + $Connection->db->beginTransaction(); |
|
1291 | + } |
|
1145 | 1292 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1146 | 1293 | { |
1147 | 1294 | if ($i > 0) { |
@@ -1156,7 +1303,9 @@ discard block |
||
1156 | 1303 | $i++; |
1157 | 1304 | } |
1158 | 1305 | fclose($handle); |
1159 | - if ($globalTransaction) $Connection->db->commit(); |
|
1306 | + if ($globalTransaction) { |
|
1307 | + $Connection->db->commit(); |
|
1308 | + } |
|
1160 | 1309 | } |
1161 | 1310 | return ''; |
1162 | 1311 | } |
@@ -1175,7 +1324,9 @@ discard block |
||
1175 | 1324 | $Connection = new Connection(); |
1176 | 1325 | if (($handle = fopen($tmp_dir.'ban_eu.csv', 'r')) !== FALSE) |
1177 | 1326 | { |
1178 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1327 | + if ($globalTransaction) { |
|
1328 | + $Connection->db->beginTransaction(); |
|
1329 | + } |
|
1179 | 1330 | while (($data = fgetcsv($handle, 1000)) !== FALSE) |
1180 | 1331 | { |
1181 | 1332 | $query = 'UPDATE airlines SET ban_eu = 1 WHERE icao = :icao AND forsource IS NULL'; |
@@ -1190,7 +1341,9 @@ discard block |
||
1190 | 1341 | } |
1191 | 1342 | } |
1192 | 1343 | fclose($handle); |
1193 | - if ($globalTransaction) $Connection->db->commit(); |
|
1344 | + if ($globalTransaction) { |
|
1345 | + $Connection->db->commit(); |
|
1346 | + } |
|
1194 | 1347 | } |
1195 | 1348 | return ''; |
1196 | 1349 | } |
@@ -1341,7 +1494,9 @@ discard block |
||
1341 | 1494 | if (($handle = fopen($filename, 'r')) !== FALSE) |
1342 | 1495 | { |
1343 | 1496 | $i = 0; |
1344 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1497 | + if ($globalTransaction) { |
|
1498 | + $Connection->db->beginTransaction(); |
|
1499 | + } |
|
1345 | 1500 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1346 | 1501 | { |
1347 | 1502 | $i++; |
@@ -1369,7 +1524,9 @@ discard block |
||
1369 | 1524 | } |
1370 | 1525 | } |
1371 | 1526 | fclose($handle); |
1372 | - if ($globalTransaction) $Connection->db->commit(); |
|
1527 | + if ($globalTransaction) { |
|
1528 | + $Connection->db->commit(); |
|
1529 | + } |
|
1373 | 1530 | } |
1374 | 1531 | return ''; |
1375 | 1532 | } |
@@ -1392,7 +1549,9 @@ discard block |
||
1392 | 1549 | $Connection = new Connection(); |
1393 | 1550 | if (($handle = fopen($filename, 'r')) !== FALSE) |
1394 | 1551 | { |
1395 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1552 | + if ($globalTransaction) { |
|
1553 | + $Connection->db->beginTransaction(); |
|
1554 | + } |
|
1396 | 1555 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1397 | 1556 | { |
1398 | 1557 | if(count($row) > 1) { |
@@ -1406,7 +1565,9 @@ discard block |
||
1406 | 1565 | } |
1407 | 1566 | } |
1408 | 1567 | fclose($handle); |
1409 | - if ($globalTransaction) $Connection->db->commit(); |
|
1568 | + if ($globalTransaction) { |
|
1569 | + $Connection->db->commit(); |
|
1570 | + } |
|
1410 | 1571 | } |
1411 | 1572 | return ''; |
1412 | 1573 | } |
@@ -1426,8 +1587,9 @@ discard block |
||
1426 | 1587 | } |
1427 | 1588 | |
1428 | 1589 | |
1429 | - if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
1430 | - else { |
|
1590 | + if ($globalDBdriver == 'mysql') { |
|
1591 | + update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
1592 | + } else { |
|
1431 | 1593 | update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
1432 | 1594 | $query = "CREATE EXTENSION postgis"; |
1433 | 1595 | $Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']); |
@@ -1446,20 +1608,30 @@ discard block |
||
1446 | 1608 | global $tmp_dir, $globalDebug; |
1447 | 1609 | include_once('class.create_db.php'); |
1448 | 1610 | require_once(dirname(__FILE__).'/../require/class.NOTAM.php'); |
1449 | - if ($globalDebug) echo "NOTAM from FlightAirMap website : Download..."; |
|
1611 | + if ($globalDebug) { |
|
1612 | + echo "NOTAM from FlightAirMap website : Download..."; |
|
1613 | + } |
|
1450 | 1614 | update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz'); |
1451 | 1615 | $error = ''; |
1452 | 1616 | if (file_exists($tmp_dir.'notam.txt.gz')) { |
1453 | - if ($globalDebug) echo "Gunzip..."; |
|
1617 | + if ($globalDebug) { |
|
1618 | + echo "Gunzip..."; |
|
1619 | + } |
|
1454 | 1620 | update_db::gunzip($tmp_dir.'notam.txt.gz'); |
1455 | - if ($globalDebug) echo "Add to DB..."; |
|
1621 | + if ($globalDebug) { |
|
1622 | + echo "Add to DB..."; |
|
1623 | + } |
|
1456 | 1624 | //$error = create_db::import_file($tmp_dir.'notam.sql'); |
1457 | 1625 | $NOTAM = new NOTAM(); |
1458 | 1626 | $NOTAM->updateNOTAMfromTextFile($tmp_dir.'notam.txt'); |
1459 | - } else $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed."; |
|
1627 | + } else { |
|
1628 | + $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed."; |
|
1629 | + } |
|
1460 | 1630 | if ($error != '') { |
1461 | 1631 | return $error; |
1462 | - } elseif ($globalDebug) echo "Done\n"; |
|
1632 | + } elseif ($globalDebug) { |
|
1633 | + echo "Done\n"; |
|
1634 | + } |
|
1463 | 1635 | return ''; |
1464 | 1636 | } |
1465 | 1637 | |
@@ -1513,67 +1685,111 @@ discard block |
||
1513 | 1685 | //if ($globalDebug) echo "IVAO : Download..."; |
1514 | 1686 | //update_db::download('http://fr.mirror.ivao.aero/software/ivae_feb2013.zip',$tmp_dir.'ivae_feb2013.zip'); |
1515 | 1687 | if (file_exists($tmp_dir.'ivae_feb2013.zip')) { |
1516 | - if ($globalDebug) echo "Unzip..."; |
|
1688 | + if ($globalDebug) { |
|
1689 | + echo "Unzip..."; |
|
1690 | + } |
|
1517 | 1691 | update_db::unzip($tmp_dir.'ivae_feb2013.zip'); |
1518 | - if ($globalDebug) echo "Add to DB..."; |
|
1692 | + if ($globalDebug) { |
|
1693 | + echo "Add to DB..."; |
|
1694 | + } |
|
1519 | 1695 | update_db::ivao_airlines($tmp_dir.'data/airlines.dat'); |
1520 | - if ($globalDebug) echo "Copy airlines logos to airlines images directory..."; |
|
1696 | + if ($globalDebug) { |
|
1697 | + echo "Copy airlines logos to airlines images directory..."; |
|
1698 | + } |
|
1521 | 1699 | if (is_writable(dirname(__FILE__).'/../images/airlines')) { |
1522 | - if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
1523 | - } else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
|
1524 | - } else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
|
1700 | + if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) { |
|
1701 | + $error = "Failed to copy airlines logo."; |
|
1702 | + } |
|
1703 | + } else { |
|
1704 | + $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
|
1705 | + } |
|
1706 | + } else { |
|
1707 | + $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
|
1708 | + } |
|
1525 | 1709 | if ($error != '') { |
1526 | 1710 | return $error; |
1527 | - } elseif ($globalDebug) echo "Done\n"; |
|
1711 | + } elseif ($globalDebug) { |
|
1712 | + echo "Done\n"; |
|
1713 | + } |
|
1528 | 1714 | return ''; |
1529 | 1715 | } |
1530 | 1716 | |
1531 | 1717 | public static function update_routes() { |
1532 | 1718 | global $tmp_dir, $globalDebug; |
1533 | 1719 | $error = ''; |
1534 | - if ($globalDebug) echo "Routes : Download..."; |
|
1720 | + if ($globalDebug) { |
|
1721 | + echo "Routes : Download..."; |
|
1722 | + } |
|
1535 | 1723 | update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz'); |
1536 | 1724 | if (file_exists($tmp_dir.'StandingData.sqb.gz')) { |
1537 | - if ($globalDebug) echo "Gunzip..."; |
|
1725 | + if ($globalDebug) { |
|
1726 | + echo "Gunzip..."; |
|
1727 | + } |
|
1538 | 1728 | update_db::gunzip($tmp_dir.'StandingData.sqb.gz'); |
1539 | - if ($globalDebug) echo "Add to DB..."; |
|
1729 | + if ($globalDebug) { |
|
1730 | + echo "Add to DB..."; |
|
1731 | + } |
|
1540 | 1732 | $error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb'); |
1541 | - } else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed."; |
|
1733 | + } else { |
|
1734 | + $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed."; |
|
1735 | + } |
|
1542 | 1736 | if ($error != '') { |
1543 | 1737 | return $error; |
1544 | - } elseif ($globalDebug) echo "Done\n"; |
|
1738 | + } elseif ($globalDebug) { |
|
1739 | + echo "Done\n"; |
|
1740 | + } |
|
1545 | 1741 | return ''; |
1546 | 1742 | } |
1547 | 1743 | public static function update_oneworld() { |
1548 | 1744 | global $tmp_dir, $globalDebug; |
1549 | 1745 | $error = ''; |
1550 | - if ($globalDebug) echo "Schedules Oneworld : Download..."; |
|
1746 | + if ($globalDebug) { |
|
1747 | + echo "Schedules Oneworld : Download..."; |
|
1748 | + } |
|
1551 | 1749 | update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz'); |
1552 | 1750 | if (file_exists($tmp_dir.'oneworld.csv.gz')) { |
1553 | - if ($globalDebug) echo "Gunzip..."; |
|
1751 | + if ($globalDebug) { |
|
1752 | + echo "Gunzip..."; |
|
1753 | + } |
|
1554 | 1754 | update_db::gunzip($tmp_dir.'oneworld.csv.gz'); |
1555 | - if ($globalDebug) echo "Add to DB..."; |
|
1755 | + if ($globalDebug) { |
|
1756 | + echo "Add to DB..."; |
|
1757 | + } |
|
1556 | 1758 | $error = update_db::retrieve_route_oneworld($tmp_dir.'oneworld.csv'); |
1557 | - } else $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed."; |
|
1759 | + } else { |
|
1760 | + $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed."; |
|
1761 | + } |
|
1558 | 1762 | if ($error != '') { |
1559 | 1763 | return $error; |
1560 | - } elseif ($globalDebug) echo "Done\n"; |
|
1764 | + } elseif ($globalDebug) { |
|
1765 | + echo "Done\n"; |
|
1766 | + } |
|
1561 | 1767 | return ''; |
1562 | 1768 | } |
1563 | 1769 | public static function update_skyteam() { |
1564 | 1770 | global $tmp_dir, $globalDebug; |
1565 | 1771 | $error = ''; |
1566 | - if ($globalDebug) echo "Schedules Skyteam : Download..."; |
|
1772 | + if ($globalDebug) { |
|
1773 | + echo "Schedules Skyteam : Download..."; |
|
1774 | + } |
|
1567 | 1775 | update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz'); |
1568 | 1776 | if (file_exists($tmp_dir.'skyteam.csv.gz')) { |
1569 | - if ($globalDebug) echo "Gunzip..."; |
|
1777 | + if ($globalDebug) { |
|
1778 | + echo "Gunzip..."; |
|
1779 | + } |
|
1570 | 1780 | update_db::gunzip($tmp_dir.'skyteam.csv.gz'); |
1571 | - if ($globalDebug) echo "Add to DB..."; |
|
1781 | + if ($globalDebug) { |
|
1782 | + echo "Add to DB..."; |
|
1783 | + } |
|
1572 | 1784 | $error = update_db::retrieve_route_skyteam($tmp_dir.'skyteam.csv'); |
1573 | - } else $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed."; |
|
1785 | + } else { |
|
1786 | + $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed."; |
|
1787 | + } |
|
1574 | 1788 | if ($error != '') { |
1575 | 1789 | return $error; |
1576 | - } elseif ($globalDebug) echo "Done\n"; |
|
1790 | + } elseif ($globalDebug) { |
|
1791 | + echo "Done\n"; |
|
1792 | + } |
|
1577 | 1793 | return ''; |
1578 | 1794 | } |
1579 | 1795 | public static function update_ModeS() { |
@@ -1590,341 +1806,587 @@ discard block |
||
1590 | 1806 | exit; |
1591 | 1807 | } elseif ($globalDebug) echo "Done\n"; |
1592 | 1808 | */ |
1593 | - if ($globalDebug) echo "Modes : Download..."; |
|
1594 | -// update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
|
1809 | + if ($globalDebug) { |
|
1810 | + echo "Modes : Download..."; |
|
1811 | + } |
|
1812 | + // update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
|
1595 | 1813 | update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz'); |
1596 | 1814 | |
1597 | 1815 | // if (file_exists($tmp_dir.'basestation_latest.zip')) { |
1598 | 1816 | if (file_exists($tmp_dir.'BaseStation.sqb.gz')) { |
1599 | - if ($globalDebug) echo "Unzip..."; |
|
1600 | -// update_db::unzip($tmp_dir.'basestation_latest.zip'); |
|
1817 | + if ($globalDebug) { |
|
1818 | + echo "Unzip..."; |
|
1819 | + } |
|
1820 | + // update_db::unzip($tmp_dir.'basestation_latest.zip'); |
|
1601 | 1821 | update_db::gunzip($tmp_dir.'BaseStation.sqb.gz'); |
1602 | - if ($globalDebug) echo "Add to DB..."; |
|
1822 | + if ($globalDebug) { |
|
1823 | + echo "Add to DB..."; |
|
1824 | + } |
|
1603 | 1825 | $error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb'); |
1604 | 1826 | // $error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'basestation.sqb'); |
1605 | - } else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed."; |
|
1827 | + } else { |
|
1828 | + $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed."; |
|
1829 | + } |
|
1606 | 1830 | if ($error != '') { |
1607 | 1831 | return $error; |
1608 | - } elseif ($globalDebug) echo "Done\n"; |
|
1832 | + } elseif ($globalDebug) { |
|
1833 | + echo "Done\n"; |
|
1834 | + } |
|
1609 | 1835 | return ''; |
1610 | 1836 | } |
1611 | 1837 | |
1612 | 1838 | public static function update_ModeS_faa() { |
1613 | 1839 | global $tmp_dir, $globalDebug; |
1614 | - if ($globalDebug) echo "Modes FAA: Download..."; |
|
1840 | + if ($globalDebug) { |
|
1841 | + echo "Modes FAA: Download..."; |
|
1842 | + } |
|
1615 | 1843 | update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip'); |
1616 | 1844 | if (file_exists($tmp_dir.'ReleasableAircraft.zip')) { |
1617 | - if ($globalDebug) echo "Unzip..."; |
|
1845 | + if ($globalDebug) { |
|
1846 | + echo "Unzip..."; |
|
1847 | + } |
|
1618 | 1848 | update_db::unzip($tmp_dir.'ReleasableAircraft.zip'); |
1619 | - if ($globalDebug) echo "Add to DB..."; |
|
1849 | + if ($globalDebug) { |
|
1850 | + echo "Add to DB..."; |
|
1851 | + } |
|
1620 | 1852 | $error = update_db::modes_faa(); |
1621 | - } else $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed."; |
|
1853 | + } else { |
|
1854 | + $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed."; |
|
1855 | + } |
|
1622 | 1856 | if ($error != '') { |
1623 | 1857 | return $error; |
1624 | - } elseif ($globalDebug) echo "Done\n"; |
|
1858 | + } elseif ($globalDebug) { |
|
1859 | + echo "Done\n"; |
|
1860 | + } |
|
1625 | 1861 | return ''; |
1626 | 1862 | } |
1627 | 1863 | |
1628 | 1864 | public static function update_ModeS_flarm() { |
1629 | 1865 | global $tmp_dir, $globalDebug; |
1630 | - if ($globalDebug) echo "Modes Flarmnet: Download..."; |
|
1866 | + if ($globalDebug) { |
|
1867 | + echo "Modes Flarmnet: Download..."; |
|
1868 | + } |
|
1631 | 1869 | update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln'); |
1632 | 1870 | if (file_exists($tmp_dir.'data.fln')) { |
1633 | - if ($globalDebug) echo "Add to DB..."; |
|
1871 | + if ($globalDebug) { |
|
1872 | + echo "Add to DB..."; |
|
1873 | + } |
|
1634 | 1874 | $error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln'); |
1635 | - } else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed."; |
|
1875 | + } else { |
|
1876 | + $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed."; |
|
1877 | + } |
|
1636 | 1878 | if ($error != '') { |
1637 | 1879 | return $error; |
1638 | - } elseif ($globalDebug) echo "Done\n"; |
|
1880 | + } elseif ($globalDebug) { |
|
1881 | + echo "Done\n"; |
|
1882 | + } |
|
1639 | 1883 | return ''; |
1640 | 1884 | } |
1641 | 1885 | |
1642 | 1886 | public static function update_ModeS_ogn() { |
1643 | 1887 | global $tmp_dir, $globalDebug; |
1644 | - if ($globalDebug) echo "Modes OGN: Download..."; |
|
1888 | + if ($globalDebug) { |
|
1889 | + echo "Modes OGN: Download..."; |
|
1890 | + } |
|
1645 | 1891 | update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv'); |
1646 | 1892 | if (file_exists($tmp_dir.'ogn.csv')) { |
1647 | - if ($globalDebug) echo "Add to DB..."; |
|
1893 | + if ($globalDebug) { |
|
1894 | + echo "Add to DB..."; |
|
1895 | + } |
|
1648 | 1896 | $error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv'); |
1649 | - } else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed."; |
|
1897 | + } else { |
|
1898 | + $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed."; |
|
1899 | + } |
|
1650 | 1900 | if ($error != '') { |
1651 | 1901 | return $error; |
1652 | - } elseif ($globalDebug) echo "Done\n"; |
|
1902 | + } elseif ($globalDebug) { |
|
1903 | + echo "Done\n"; |
|
1904 | + } |
|
1653 | 1905 | return ''; |
1654 | 1906 | } |
1655 | 1907 | |
1656 | 1908 | public static function update_owner() { |
1657 | 1909 | global $tmp_dir, $globalDebug; |
1658 | 1910 | |
1659 | - if ($globalDebug) echo "Owner France: Download..."; |
|
1911 | + if ($globalDebug) { |
|
1912 | + echo "Owner France: Download..."; |
|
1913 | + } |
|
1660 | 1914 | update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv'); |
1661 | 1915 | if (file_exists($tmp_dir.'owner_f.csv')) { |
1662 | - if ($globalDebug) echo "Add to DB..."; |
|
1916 | + if ($globalDebug) { |
|
1917 | + echo "Add to DB..."; |
|
1918 | + } |
|
1663 | 1919 | $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F'); |
1664 | - } else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
|
1920 | + } else { |
|
1921 | + $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
|
1922 | + } |
|
1665 | 1923 | if ($error != '') { |
1666 | 1924 | return $error; |
1667 | - } elseif ($globalDebug) echo "Done\n"; |
|
1925 | + } elseif ($globalDebug) { |
|
1926 | + echo "Done\n"; |
|
1927 | + } |
|
1668 | 1928 | |
1669 | - if ($globalDebug) echo "Owner Ireland: Download..."; |
|
1929 | + if ($globalDebug) { |
|
1930 | + echo "Owner Ireland: Download..."; |
|
1931 | + } |
|
1670 | 1932 | update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv'); |
1671 | 1933 | if (file_exists($tmp_dir.'owner_ei.csv')) { |
1672 | - if ($globalDebug) echo "Add to DB..."; |
|
1934 | + if ($globalDebug) { |
|
1935 | + echo "Add to DB..."; |
|
1936 | + } |
|
1673 | 1937 | $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI'); |
1674 | - } else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
|
1938 | + } else { |
|
1939 | + $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
|
1940 | + } |
|
1675 | 1941 | if ($error != '') { |
1676 | 1942 | return $error; |
1677 | - } elseif ($globalDebug) echo "Done\n"; |
|
1678 | - if ($globalDebug) echo "Owner Switzerland: Download..."; |
|
1943 | + } elseif ($globalDebug) { |
|
1944 | + echo "Done\n"; |
|
1945 | + } |
|
1946 | + if ($globalDebug) { |
|
1947 | + echo "Owner Switzerland: Download..."; |
|
1948 | + } |
|
1679 | 1949 | update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv'); |
1680 | 1950 | if (file_exists($tmp_dir.'owner_hb.csv')) { |
1681 | - if ($globalDebug) echo "Add to DB..."; |
|
1951 | + if ($globalDebug) { |
|
1952 | + echo "Add to DB..."; |
|
1953 | + } |
|
1682 | 1954 | $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB'); |
1683 | - } else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
|
1955 | + } else { |
|
1956 | + $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
|
1957 | + } |
|
1684 | 1958 | if ($error != '') { |
1685 | 1959 | return $error; |
1686 | - } elseif ($globalDebug) echo "Done\n"; |
|
1687 | - if ($globalDebug) echo "Owner Czech Republic: Download..."; |
|
1960 | + } elseif ($globalDebug) { |
|
1961 | + echo "Done\n"; |
|
1962 | + } |
|
1963 | + if ($globalDebug) { |
|
1964 | + echo "Owner Czech Republic: Download..."; |
|
1965 | + } |
|
1688 | 1966 | update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv'); |
1689 | 1967 | if (file_exists($tmp_dir.'owner_ok.csv')) { |
1690 | - if ($globalDebug) echo "Add to DB..."; |
|
1968 | + if ($globalDebug) { |
|
1969 | + echo "Add to DB..."; |
|
1970 | + } |
|
1691 | 1971 | $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK'); |
1692 | - } else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
|
1972 | + } else { |
|
1973 | + $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
|
1974 | + } |
|
1693 | 1975 | if ($error != '') { |
1694 | 1976 | return $error; |
1695 | - } elseif ($globalDebug) echo "Done\n"; |
|
1696 | - if ($globalDebug) echo "Owner Australia: Download..."; |
|
1977 | + } elseif ($globalDebug) { |
|
1978 | + echo "Done\n"; |
|
1979 | + } |
|
1980 | + if ($globalDebug) { |
|
1981 | + echo "Owner Australia: Download..."; |
|
1982 | + } |
|
1697 | 1983 | update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv'); |
1698 | 1984 | if (file_exists($tmp_dir.'owner_vh.csv')) { |
1699 | - if ($globalDebug) echo "Add to DB..."; |
|
1985 | + if ($globalDebug) { |
|
1986 | + echo "Add to DB..."; |
|
1987 | + } |
|
1700 | 1988 | $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH'); |
1701 | - } else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
|
1989 | + } else { |
|
1990 | + $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
|
1991 | + } |
|
1702 | 1992 | if ($error != '') { |
1703 | 1993 | return $error; |
1704 | - } elseif ($globalDebug) echo "Done\n"; |
|
1705 | - if ($globalDebug) echo "Owner Austria: Download..."; |
|
1994 | + } elseif ($globalDebug) { |
|
1995 | + echo "Done\n"; |
|
1996 | + } |
|
1997 | + if ($globalDebug) { |
|
1998 | + echo "Owner Austria: Download..."; |
|
1999 | + } |
|
1706 | 2000 | update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv'); |
1707 | 2001 | if (file_exists($tmp_dir.'owner_oe.csv')) { |
1708 | - if ($globalDebug) echo "Add to DB..."; |
|
2002 | + if ($globalDebug) { |
|
2003 | + echo "Add to DB..."; |
|
2004 | + } |
|
1709 | 2005 | $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE'); |
1710 | - } else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
|
2006 | + } else { |
|
2007 | + $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
|
2008 | + } |
|
1711 | 2009 | if ($error != '') { |
1712 | 2010 | return $error; |
1713 | - } elseif ($globalDebug) echo "Done\n"; |
|
1714 | - if ($globalDebug) echo "Owner Chile: Download..."; |
|
2011 | + } elseif ($globalDebug) { |
|
2012 | + echo "Done\n"; |
|
2013 | + } |
|
2014 | + if ($globalDebug) { |
|
2015 | + echo "Owner Chile: Download..."; |
|
2016 | + } |
|
1715 | 2017 | update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv'); |
1716 | 2018 | if (file_exists($tmp_dir.'owner_cc.csv')) { |
1717 | - if ($globalDebug) echo "Add to DB..."; |
|
2019 | + if ($globalDebug) { |
|
2020 | + echo "Add to DB..."; |
|
2021 | + } |
|
1718 | 2022 | $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC'); |
1719 | - } else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
|
2023 | + } else { |
|
2024 | + $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
|
2025 | + } |
|
1720 | 2026 | if ($error != '') { |
1721 | 2027 | return $error; |
1722 | - } elseif ($globalDebug) echo "Done\n"; |
|
1723 | - if ($globalDebug) echo "Owner Colombia: Download..."; |
|
2028 | + } elseif ($globalDebug) { |
|
2029 | + echo "Done\n"; |
|
2030 | + } |
|
2031 | + if ($globalDebug) { |
|
2032 | + echo "Owner Colombia: Download..."; |
|
2033 | + } |
|
1724 | 2034 | update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv'); |
1725 | 2035 | if (file_exists($tmp_dir.'owner_hj.csv')) { |
1726 | - if ($globalDebug) echo "Add to DB..."; |
|
2036 | + if ($globalDebug) { |
|
2037 | + echo "Add to DB..."; |
|
2038 | + } |
|
1727 | 2039 | $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ'); |
1728 | - } else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
|
2040 | + } else { |
|
2041 | + $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
|
2042 | + } |
|
1729 | 2043 | if ($error != '') { |
1730 | 2044 | return $error; |
1731 | - } elseif ($globalDebug) echo "Done\n"; |
|
1732 | - if ($globalDebug) echo "Owner Bosnia Herzegobina: Download..."; |
|
2045 | + } elseif ($globalDebug) { |
|
2046 | + echo "Done\n"; |
|
2047 | + } |
|
2048 | + if ($globalDebug) { |
|
2049 | + echo "Owner Bosnia Herzegobina: Download..."; |
|
2050 | + } |
|
1733 | 2051 | update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv'); |
1734 | 2052 | if (file_exists($tmp_dir.'owner_e7.csv')) { |
1735 | - if ($globalDebug) echo "Add to DB..."; |
|
2053 | + if ($globalDebug) { |
|
2054 | + echo "Add to DB..."; |
|
2055 | + } |
|
1736 | 2056 | $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7'); |
1737 | - } else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
|
2057 | + } else { |
|
2058 | + $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
|
2059 | + } |
|
1738 | 2060 | if ($error != '') { |
1739 | 2061 | return $error; |
1740 | - } elseif ($globalDebug) echo "Done\n"; |
|
1741 | - if ($globalDebug) echo "Owner Brazil: Download..."; |
|
2062 | + } elseif ($globalDebug) { |
|
2063 | + echo "Done\n"; |
|
2064 | + } |
|
2065 | + if ($globalDebug) { |
|
2066 | + echo "Owner Brazil: Download..."; |
|
2067 | + } |
|
1742 | 2068 | update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv'); |
1743 | 2069 | if (file_exists($tmp_dir.'owner_pp.csv')) { |
1744 | - if ($globalDebug) echo "Add to DB..."; |
|
2070 | + if ($globalDebug) { |
|
2071 | + echo "Add to DB..."; |
|
2072 | + } |
|
1745 | 2073 | $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP'); |
1746 | - } else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
|
2074 | + } else { |
|
2075 | + $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
|
2076 | + } |
|
1747 | 2077 | if ($error != '') { |
1748 | 2078 | return $error; |
1749 | - } elseif ($globalDebug) echo "Done\n"; |
|
1750 | - if ($globalDebug) echo "Owner Cayman Islands: Download..."; |
|
2079 | + } elseif ($globalDebug) { |
|
2080 | + echo "Done\n"; |
|
2081 | + } |
|
2082 | + if ($globalDebug) { |
|
2083 | + echo "Owner Cayman Islands: Download..."; |
|
2084 | + } |
|
1751 | 2085 | update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv'); |
1752 | 2086 | if (file_exists($tmp_dir.'owner_vp.csv')) { |
1753 | - if ($globalDebug) echo "Add to DB..."; |
|
2087 | + if ($globalDebug) { |
|
2088 | + echo "Add to DB..."; |
|
2089 | + } |
|
1754 | 2090 | $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP'); |
1755 | - } else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
|
2091 | + } else { |
|
2092 | + $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
|
2093 | + } |
|
1756 | 2094 | if ($error != '') { |
1757 | 2095 | return $error; |
1758 | - } elseif ($globalDebug) echo "Done\n"; |
|
1759 | - if ($globalDebug) echo "Owner Croatia: Download..."; |
|
2096 | + } elseif ($globalDebug) { |
|
2097 | + echo "Done\n"; |
|
2098 | + } |
|
2099 | + if ($globalDebug) { |
|
2100 | + echo "Owner Croatia: Download..."; |
|
2101 | + } |
|
1760 | 2102 | update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv'); |
1761 | 2103 | if (file_exists($tmp_dir.'owner_9a.csv')) { |
1762 | - if ($globalDebug) echo "Add to DB..."; |
|
2104 | + if ($globalDebug) { |
|
2105 | + echo "Add to DB..."; |
|
2106 | + } |
|
1763 | 2107 | $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A'); |
1764 | - } else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
|
2108 | + } else { |
|
2109 | + $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
|
2110 | + } |
|
1765 | 2111 | if ($error != '') { |
1766 | 2112 | return $error; |
1767 | - } elseif ($globalDebug) echo "Done\n"; |
|
1768 | - if ($globalDebug) echo "Owner Luxembourg: Download..."; |
|
2113 | + } elseif ($globalDebug) { |
|
2114 | + echo "Done\n"; |
|
2115 | + } |
|
2116 | + if ($globalDebug) { |
|
2117 | + echo "Owner Luxembourg: Download..."; |
|
2118 | + } |
|
1769 | 2119 | update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv'); |
1770 | 2120 | if (file_exists($tmp_dir.'owner_lx.csv')) { |
1771 | - if ($globalDebug) echo "Add to DB..."; |
|
2121 | + if ($globalDebug) { |
|
2122 | + echo "Add to DB..."; |
|
2123 | + } |
|
1772 | 2124 | $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX'); |
1773 | - } else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
|
2125 | + } else { |
|
2126 | + $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
|
2127 | + } |
|
1774 | 2128 | if ($error != '') { |
1775 | 2129 | return $error; |
1776 | - } elseif ($globalDebug) echo "Done\n"; |
|
1777 | - if ($globalDebug) echo "Owner Maldives: Download..."; |
|
2130 | + } elseif ($globalDebug) { |
|
2131 | + echo "Done\n"; |
|
2132 | + } |
|
2133 | + if ($globalDebug) { |
|
2134 | + echo "Owner Maldives: Download..."; |
|
2135 | + } |
|
1778 | 2136 | update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv'); |
1779 | 2137 | if (file_exists($tmp_dir.'owner_8q.csv')) { |
1780 | - if ($globalDebug) echo "Add to DB..."; |
|
2138 | + if ($globalDebug) { |
|
2139 | + echo "Add to DB..."; |
|
2140 | + } |
|
1781 | 2141 | $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q'); |
1782 | - } else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
|
2142 | + } else { |
|
2143 | + $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
|
2144 | + } |
|
1783 | 2145 | if ($error != '') { |
1784 | 2146 | return $error; |
1785 | - } elseif ($globalDebug) echo "Done\n"; |
|
1786 | - if ($globalDebug) echo "Owner New Zealand: Download..."; |
|
2147 | + } elseif ($globalDebug) { |
|
2148 | + echo "Done\n"; |
|
2149 | + } |
|
2150 | + if ($globalDebug) { |
|
2151 | + echo "Owner New Zealand: Download..."; |
|
2152 | + } |
|
1787 | 2153 | update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv'); |
1788 | 2154 | if (file_exists($tmp_dir.'owner_zk.csv')) { |
1789 | - if ($globalDebug) echo "Add to DB..."; |
|
2155 | + if ($globalDebug) { |
|
2156 | + echo "Add to DB..."; |
|
2157 | + } |
|
1790 | 2158 | $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK'); |
1791 | - } else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
|
2159 | + } else { |
|
2160 | + $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
|
2161 | + } |
|
1792 | 2162 | if ($error != '') { |
1793 | 2163 | return $error; |
1794 | - } elseif ($globalDebug) echo "Done\n"; |
|
1795 | - if ($globalDebug) echo "Owner Papua New Guinea: Download..."; |
|
2164 | + } elseif ($globalDebug) { |
|
2165 | + echo "Done\n"; |
|
2166 | + } |
|
2167 | + if ($globalDebug) { |
|
2168 | + echo "Owner Papua New Guinea: Download..."; |
|
2169 | + } |
|
1796 | 2170 | update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv'); |
1797 | 2171 | if (file_exists($tmp_dir.'owner_p2.csv')) { |
1798 | - if ($globalDebug) echo "Add to DB..."; |
|
2172 | + if ($globalDebug) { |
|
2173 | + echo "Add to DB..."; |
|
2174 | + } |
|
1799 | 2175 | $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2'); |
1800 | - } else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
|
2176 | + } else { |
|
2177 | + $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
|
2178 | + } |
|
1801 | 2179 | if ($error != '') { |
1802 | 2180 | return $error; |
1803 | - } elseif ($globalDebug) echo "Done\n"; |
|
1804 | - if ($globalDebug) echo "Owner Slovakia: Download..."; |
|
2181 | + } elseif ($globalDebug) { |
|
2182 | + echo "Done\n"; |
|
2183 | + } |
|
2184 | + if ($globalDebug) { |
|
2185 | + echo "Owner Slovakia: Download..."; |
|
2186 | + } |
|
1805 | 2187 | update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv'); |
1806 | 2188 | if (file_exists($tmp_dir.'owner_om.csv')) { |
1807 | - if ($globalDebug) echo "Add to DB..."; |
|
2189 | + if ($globalDebug) { |
|
2190 | + echo "Add to DB..."; |
|
2191 | + } |
|
1808 | 2192 | $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM'); |
1809 | - } else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
|
2193 | + } else { |
|
2194 | + $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
|
2195 | + } |
|
1810 | 2196 | if ($error != '') { |
1811 | 2197 | return $error; |
1812 | - } elseif ($globalDebug) echo "Done\n"; |
|
1813 | - if ($globalDebug) echo "Owner Ecuador: Download..."; |
|
2198 | + } elseif ($globalDebug) { |
|
2199 | + echo "Done\n"; |
|
2200 | + } |
|
2201 | + if ($globalDebug) { |
|
2202 | + echo "Owner Ecuador: Download..."; |
|
2203 | + } |
|
1814 | 2204 | update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv'); |
1815 | 2205 | if (file_exists($tmp_dir.'owner_hc.csv')) { |
1816 | - if ($globalDebug) echo "Add to DB..."; |
|
2206 | + if ($globalDebug) { |
|
2207 | + echo "Add to DB..."; |
|
2208 | + } |
|
1817 | 2209 | $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC'); |
1818 | - } else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
|
2210 | + } else { |
|
2211 | + $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
|
2212 | + } |
|
1819 | 2213 | if ($error != '') { |
1820 | 2214 | return $error; |
1821 | - } elseif ($globalDebug) echo "Done\n"; |
|
1822 | - if ($globalDebug) echo "Owner Iceland: Download..."; |
|
2215 | + } elseif ($globalDebug) { |
|
2216 | + echo "Done\n"; |
|
2217 | + } |
|
2218 | + if ($globalDebug) { |
|
2219 | + echo "Owner Iceland: Download..."; |
|
2220 | + } |
|
1823 | 2221 | update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv'); |
1824 | 2222 | if (file_exists($tmp_dir.'owner_tf.csv')) { |
1825 | - if ($globalDebug) echo "Add to DB..."; |
|
2223 | + if ($globalDebug) { |
|
2224 | + echo "Add to DB..."; |
|
2225 | + } |
|
1826 | 2226 | $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF'); |
1827 | - } else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
|
2227 | + } else { |
|
2228 | + $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
|
2229 | + } |
|
1828 | 2230 | if ($error != '') { |
1829 | 2231 | return $error; |
1830 | - } elseif ($globalDebug) echo "Done\n"; |
|
2232 | + } elseif ($globalDebug) { |
|
2233 | + echo "Done\n"; |
|
2234 | + } |
|
1831 | 2235 | return ''; |
1832 | 2236 | } |
1833 | 2237 | |
1834 | 2238 | public static function update_translation() { |
1835 | 2239 | global $tmp_dir, $globalDebug; |
1836 | 2240 | $error = ''; |
1837 | - if ($globalDebug) echo "Translation : Download..."; |
|
2241 | + if ($globalDebug) { |
|
2242 | + echo "Translation : Download..."; |
|
2243 | + } |
|
1838 | 2244 | update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip'); |
1839 | 2245 | if (file_exists($tmp_dir.'translation.zip')) { |
1840 | - if ($globalDebug) echo "Unzip..."; |
|
2246 | + if ($globalDebug) { |
|
2247 | + echo "Unzip..."; |
|
2248 | + } |
|
1841 | 2249 | update_db::unzip($tmp_dir.'translation.zip'); |
1842 | - if ($globalDebug) echo "Add to DB..."; |
|
2250 | + if ($globalDebug) { |
|
2251 | + echo "Add to DB..."; |
|
2252 | + } |
|
1843 | 2253 | $error = update_db::translation(); |
1844 | - } else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed."; |
|
2254 | + } else { |
|
2255 | + $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed."; |
|
2256 | + } |
|
1845 | 2257 | if ($error != '') { |
1846 | 2258 | return $error; |
1847 | - } elseif ($globalDebug) echo "Done\n"; |
|
2259 | + } elseif ($globalDebug) { |
|
2260 | + echo "Done\n"; |
|
2261 | + } |
|
1848 | 2262 | return ''; |
1849 | 2263 | } |
1850 | 2264 | |
1851 | 2265 | public static function update_translation_fam() { |
1852 | 2266 | global $tmp_dir, $globalDebug; |
1853 | - if ($globalDebug) echo "Translation from FlightAirMap website : Download..."; |
|
2267 | + if ($globalDebug) { |
|
2268 | + echo "Translation from FlightAirMap website : Download..."; |
|
2269 | + } |
|
1854 | 2270 | update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz'); |
1855 | 2271 | if (file_exists($tmp_dir.'translation.tsv.gz')) { |
1856 | - if ($globalDebug) echo "Gunzip..."; |
|
2272 | + if ($globalDebug) { |
|
2273 | + echo "Gunzip..."; |
|
2274 | + } |
|
1857 | 2275 | update_db::gunzip($tmp_dir.'translation.tsv.gz'); |
1858 | - if ($globalDebug) echo "Add to DB..."; |
|
2276 | + if ($globalDebug) { |
|
2277 | + echo "Add to DB..."; |
|
2278 | + } |
|
1859 | 2279 | $error = update_db::translation_fam(); |
1860 | - } else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed."; |
|
2280 | + } else { |
|
2281 | + $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed."; |
|
2282 | + } |
|
1861 | 2283 | if ($error != '') { |
1862 | 2284 | return $error; |
1863 | - } elseif ($globalDebug) echo "Done\n"; |
|
2285 | + } elseif ($globalDebug) { |
|
2286 | + echo "Done\n"; |
|
2287 | + } |
|
1864 | 2288 | return ''; |
1865 | 2289 | } |
1866 | 2290 | public static function update_ModeS_fam() { |
1867 | 2291 | global $tmp_dir, $globalDebug; |
1868 | - if ($globalDebug) echo "ModeS from FlightAirMap website : Download..."; |
|
2292 | + if ($globalDebug) { |
|
2293 | + echo "ModeS from FlightAirMap website : Download..."; |
|
2294 | + } |
|
1869 | 2295 | update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz'); |
1870 | 2296 | if (file_exists($tmp_dir.'modes.tsv.gz')) { |
1871 | - if ($globalDebug) echo "Gunzip..."; |
|
2297 | + if ($globalDebug) { |
|
2298 | + echo "Gunzip..."; |
|
2299 | + } |
|
1872 | 2300 | update_db::gunzip($tmp_dir.'modes.tsv.gz'); |
1873 | - if ($globalDebug) echo "Add to DB..."; |
|
2301 | + if ($globalDebug) { |
|
2302 | + echo "Add to DB..."; |
|
2303 | + } |
|
1874 | 2304 | $error = update_db::modes_fam(); |
1875 | - } else $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed."; |
|
2305 | + } else { |
|
2306 | + $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed."; |
|
2307 | + } |
|
1876 | 2308 | if ($error != '') { |
1877 | 2309 | return $error; |
1878 | - } elseif ($globalDebug) echo "Done\n"; |
|
2310 | + } elseif ($globalDebug) { |
|
2311 | + echo "Done\n"; |
|
2312 | + } |
|
1879 | 2313 | return ''; |
1880 | 2314 | } |
1881 | 2315 | public static function update_owner_fam() { |
1882 | 2316 | global $tmp_dir, $globalDebug, $globalOwner; |
1883 | - if ($globalDebug) echo "owner from FlightAirMap website : Download..."; |
|
2317 | + if ($globalDebug) { |
|
2318 | + echo "owner from FlightAirMap website : Download..."; |
|
2319 | + } |
|
1884 | 2320 | if ($globalOwner === TRUE) { |
1885 | 2321 | update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz'); |
1886 | 2322 | } else { |
1887 | 2323 | update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz',$tmp_dir.'owners.tsv.gz'); |
1888 | 2324 | } |
1889 | 2325 | if (file_exists($tmp_dir.'owners.tsv.gz')) { |
1890 | - if ($globalDebug) echo "Gunzip..."; |
|
2326 | + if ($globalDebug) { |
|
2327 | + echo "Gunzip..."; |
|
2328 | + } |
|
1891 | 2329 | update_db::gunzip($tmp_dir.'owners.tsv.gz'); |
1892 | - if ($globalDebug) echo "Add to DB..."; |
|
2330 | + if ($globalDebug) { |
|
2331 | + echo "Add to DB..."; |
|
2332 | + } |
|
1893 | 2333 | $error = update_db::owner_fam(); |
1894 | - } else $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed."; |
|
2334 | + } else { |
|
2335 | + $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed."; |
|
2336 | + } |
|
1895 | 2337 | if ($error != '') { |
1896 | 2338 | return $error; |
1897 | - } elseif ($globalDebug) echo "Done\n"; |
|
2339 | + } elseif ($globalDebug) { |
|
2340 | + echo "Done\n"; |
|
2341 | + } |
|
1898 | 2342 | return ''; |
1899 | 2343 | } |
1900 | 2344 | public static function update_routes_fam() { |
1901 | 2345 | global $tmp_dir, $globalDebug; |
1902 | - if ($globalDebug) echo "Routes from FlightAirMap website : Download..."; |
|
2346 | + if ($globalDebug) { |
|
2347 | + echo "Routes from FlightAirMap website : Download..."; |
|
2348 | + } |
|
1903 | 2349 | update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz'); |
1904 | 2350 | if (file_exists($tmp_dir.'routes.tsv.gz')) { |
1905 | - if ($globalDebug) echo "Gunzip..."; |
|
2351 | + if ($globalDebug) { |
|
2352 | + echo "Gunzip..."; |
|
2353 | + } |
|
1906 | 2354 | update_db::gunzip($tmp_dir.'routes.tsv.gz'); |
1907 | - if ($globalDebug) echo "Add to DB..."; |
|
2355 | + if ($globalDebug) { |
|
2356 | + echo "Add to DB..."; |
|
2357 | + } |
|
1908 | 2358 | $error = update_db::routes_fam(); |
1909 | - } else $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed."; |
|
2359 | + } else { |
|
2360 | + $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed."; |
|
2361 | + } |
|
1910 | 2362 | if ($error != '') { |
1911 | 2363 | return $error; |
1912 | - } elseif ($globalDebug) echo "Done\n"; |
|
2364 | + } elseif ($globalDebug) { |
|
2365 | + echo "Done\n"; |
|
2366 | + } |
|
1913 | 2367 | return ''; |
1914 | 2368 | } |
1915 | 2369 | public static function update_banned_fam() { |
1916 | 2370 | global $tmp_dir, $globalDebug; |
1917 | - if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download..."; |
|
2371 | + if ($globalDebug) { |
|
2372 | + echo "Banned airlines in Europe from FlightAirMap website : Download..."; |
|
2373 | + } |
|
1918 | 2374 | update_db::download('http://data.flightairmap.fr/data/ban_eu.csv',$tmp_dir.'ban_eu.csv'); |
1919 | 2375 | if (file_exists($tmp_dir.'ban_eu.csv')) { |
1920 | 2376 | //if ($globalDebug) echo "Gunzip..."; |
1921 | 2377 | //update_db::gunzip($tmp_dir.'ban_ue.csv'); |
1922 | - if ($globalDebug) echo "Add to DB..."; |
|
2378 | + if ($globalDebug) { |
|
2379 | + echo "Add to DB..."; |
|
2380 | + } |
|
1923 | 2381 | $error = update_db::banned_fam(); |
1924 | - } else $error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed."; |
|
2382 | + } else { |
|
2383 | + $error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed."; |
|
2384 | + } |
|
1925 | 2385 | if ($error != '') { |
1926 | 2386 | return $error; |
1927 | - } elseif ($globalDebug) echo "Done\n"; |
|
2387 | + } elseif ($globalDebug) { |
|
2388 | + echo "Done\n"; |
|
2389 | + } |
|
1928 | 2390 | return ''; |
1929 | 2391 | } |
1930 | 2392 | |
@@ -1932,7 +2394,9 @@ discard block |
||
1932 | 2394 | global $tmp_dir, $globalDebug, $globalDBdriver; |
1933 | 2395 | include_once('class.create_db.php'); |
1934 | 2396 | $error = ''; |
1935 | - if ($globalDebug) echo "Airspace from FlightAirMap website : Download..."; |
|
2397 | + if ($globalDebug) { |
|
2398 | + echo "Airspace from FlightAirMap website : Download..."; |
|
2399 | + } |
|
1936 | 2400 | if ($globalDBdriver == 'mysql') { |
1937 | 2401 | update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); |
1938 | 2402 | } else { |
@@ -1948,9 +2412,13 @@ discard block |
||
1948 | 2412 | update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz'); |
1949 | 2413 | } |
1950 | 2414 | if (file_exists($tmp_dir.'airspace.sql.gz')) { |
1951 | - if ($globalDebug) echo "Gunzip..."; |
|
2415 | + if ($globalDebug) { |
|
2416 | + echo "Gunzip..."; |
|
2417 | + } |
|
1952 | 2418 | update_db::gunzip($tmp_dir.'airspace.sql.gz'); |
1953 | - if ($globalDebug) echo "Add to DB..."; |
|
2419 | + if ($globalDebug) { |
|
2420 | + echo "Add to DB..."; |
|
2421 | + } |
|
1954 | 2422 | $Connection = new Connection(); |
1955 | 2423 | if ($Connection->tableExists('airspace')) { |
1956 | 2424 | $query = 'DROP TABLE airspace'; |
@@ -1963,31 +2431,47 @@ discard block |
||
1963 | 2431 | } |
1964 | 2432 | $error = create_db::import_file($tmp_dir.'airspace.sql'); |
1965 | 2433 | update_db::insert_airspace_version($airspace_md5); |
1966 | - } else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed."; |
|
2434 | + } else { |
|
2435 | + $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed."; |
|
2436 | + } |
|
1967 | 2437 | } |
1968 | - } else $error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed."; |
|
2438 | + } else { |
|
2439 | + $error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed."; |
|
2440 | + } |
|
1969 | 2441 | if ($error != '') { |
1970 | 2442 | return $error; |
1971 | - } elseif ($globalDebug) echo "Done\n"; |
|
2443 | + } elseif ($globalDebug) { |
|
2444 | + echo "Done\n"; |
|
2445 | + } |
|
1972 | 2446 | return ''; |
1973 | 2447 | } |
1974 | 2448 | |
1975 | 2449 | public static function update_tle() { |
1976 | 2450 | global $tmp_dir, $globalDebug; |
1977 | - if ($globalDebug) echo "Download TLE : Download..."; |
|
2451 | + if ($globalDebug) { |
|
2452 | + echo "Download TLE : Download..."; |
|
2453 | + } |
|
1978 | 2454 | $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', |
1979 | 2455 | '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', |
1980 | 2456 | 'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt'); |
1981 | 2457 | foreach ($alltle as $filename) { |
1982 | - if ($globalDebug) echo "downloading ".$filename.'...'; |
|
2458 | + if ($globalDebug) { |
|
2459 | + echo "downloading ".$filename.'...'; |
|
2460 | + } |
|
1983 | 2461 | update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename); |
1984 | 2462 | if (file_exists($tmp_dir.$filename)) { |
1985 | - if ($globalDebug) echo "Add to DB ".$filename."..."; |
|
2463 | + if ($globalDebug) { |
|
2464 | + echo "Add to DB ".$filename."..."; |
|
2465 | + } |
|
1986 | 2466 | $error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename)); |
1987 | - } else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
|
2467 | + } else { |
|
2468 | + $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
|
2469 | + } |
|
1988 | 2470 | if ($error != '') { |
1989 | 2471 | echo $error."\n"; |
1990 | - } elseif ($globalDebug) echo "Done\n"; |
|
2472 | + } elseif ($globalDebug) { |
|
2473 | + echo "Done\n"; |
|
2474 | + } |
|
1991 | 2475 | } |
1992 | 2476 | return ''; |
1993 | 2477 | } |
@@ -1995,10 +2479,14 @@ discard block |
||
1995 | 2479 | public static function update_models() { |
1996 | 2480 | global $tmp_dir, $globalDebug; |
1997 | 2481 | $error = ''; |
1998 | - if ($globalDebug) echo "Models from FlightAirMap website : Download..."; |
|
2482 | + if ($globalDebug) { |
|
2483 | + echo "Models from FlightAirMap website : Download..."; |
|
2484 | + } |
|
1999 | 2485 | update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum'); |
2000 | 2486 | if (file_exists($tmp_dir.'models.md5sum')) { |
2001 | - if ($globalDebug) echo "Check files...\n"; |
|
2487 | + if ($globalDebug) { |
|
2488 | + echo "Check files...\n"; |
|
2489 | + } |
|
2002 | 2490 | $newmodelsdb = array(); |
2003 | 2491 | if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) { |
2004 | 2492 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2017,25 +2505,35 @@ discard block |
||
2017 | 2505 | } |
2018 | 2506 | $diff = array_diff($newmodelsdb,$modelsdb); |
2019 | 2507 | foreach ($diff as $key => $value) { |
2020 | - if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n"; |
|
2508 | + if ($globalDebug) { |
|
2509 | + echo 'Downloading model '.$key.' ...'."\n"; |
|
2510 | + } |
|
2021 | 2511 | update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key); |
2022 | 2512 | |
2023 | 2513 | } |
2024 | 2514 | update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum'); |
2025 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
2515 | + } else { |
|
2516 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
2517 | + } |
|
2026 | 2518 | if ($error != '') { |
2027 | 2519 | return $error; |
2028 | - } elseif ($globalDebug) echo "Done\n"; |
|
2520 | + } elseif ($globalDebug) { |
|
2521 | + echo "Done\n"; |
|
2522 | + } |
|
2029 | 2523 | return ''; |
2030 | 2524 | } |
2031 | 2525 | |
2032 | 2526 | public static function update_space_models() { |
2033 | 2527 | global $tmp_dir, $globalDebug; |
2034 | 2528 | $error = ''; |
2035 | - if ($globalDebug) echo "Space models from FlightAirMap website : Download..."; |
|
2529 | + if ($globalDebug) { |
|
2530 | + echo "Space models from FlightAirMap website : Download..."; |
|
2531 | + } |
|
2036 | 2532 | update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum'); |
2037 | 2533 | if (file_exists($tmp_dir.'space_models.md5sum')) { |
2038 | - if ($globalDebug) echo "Check files...\n"; |
|
2534 | + if ($globalDebug) { |
|
2535 | + echo "Check files...\n"; |
|
2536 | + } |
|
2039 | 2537 | $newmodelsdb = array(); |
2040 | 2538 | if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) { |
2041 | 2539 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2054,15 +2552,21 @@ discard block |
||
2054 | 2552 | } |
2055 | 2553 | $diff = array_diff($newmodelsdb,$modelsdb); |
2056 | 2554 | foreach ($diff as $key => $value) { |
2057 | - if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n"; |
|
2555 | + if ($globalDebug) { |
|
2556 | + echo 'Downloading space model '.$key.' ...'."\n"; |
|
2557 | + } |
|
2058 | 2558 | update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key); |
2059 | 2559 | |
2060 | 2560 | } |
2061 | 2561 | update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum'); |
2062 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
2562 | + } else { |
|
2563 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
2564 | + } |
|
2063 | 2565 | if ($error != '') { |
2064 | 2566 | return $error; |
2065 | - } elseif ($globalDebug) echo "Done\n"; |
|
2567 | + } elseif ($globalDebug) { |
|
2568 | + echo "Done\n"; |
|
2569 | + } |
|
2066 | 2570 | return ''; |
2067 | 2571 | } |
2068 | 2572 | |
@@ -2105,7 +2609,9 @@ discard block |
||
2105 | 2609 | } |
2106 | 2610 | |
2107 | 2611 | $error = ''; |
2108 | - if ($globalDebug) echo "Notam : Download..."; |
|
2612 | + if ($globalDebug) { |
|
2613 | + echo "Notam : Download..."; |
|
2614 | + } |
|
2109 | 2615 | update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss'); |
2110 | 2616 | if (file_exists($tmp_dir.'notam.rss')) { |
2111 | 2617 | $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true); |
@@ -2120,14 +2626,30 @@ discard block |
||
2120 | 2626 | $data['fir'] = $q[0]; |
2121 | 2627 | $data['code'] = $q[1]; |
2122 | 2628 | $ifrvfr = $q[2]; |
2123 | - if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR'; |
|
2124 | - if ($ifrvfr == 'I') $data['rules'] = 'IFR'; |
|
2125 | - if ($ifrvfr == 'V') $data['rules'] = 'VFR'; |
|
2126 | - if ($q[4] == 'A') $data['scope'] = 'Airport warning'; |
|
2127 | - if ($q[4] == 'E') $data['scope'] = 'Enroute warning'; |
|
2128 | - if ($q[4] == 'W') $data['scope'] = 'Navigation warning'; |
|
2129 | - if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning'; |
|
2130 | - if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning'; |
|
2629 | + if ($ifrvfr == 'IV') { |
|
2630 | + $data['rules'] = 'IFR/VFR'; |
|
2631 | + } |
|
2632 | + if ($ifrvfr == 'I') { |
|
2633 | + $data['rules'] = 'IFR'; |
|
2634 | + } |
|
2635 | + if ($ifrvfr == 'V') { |
|
2636 | + $data['rules'] = 'VFR'; |
|
2637 | + } |
|
2638 | + if ($q[4] == 'A') { |
|
2639 | + $data['scope'] = 'Airport warning'; |
|
2640 | + } |
|
2641 | + if ($q[4] == 'E') { |
|
2642 | + $data['scope'] = 'Enroute warning'; |
|
2643 | + } |
|
2644 | + if ($q[4] == 'W') { |
|
2645 | + $data['scope'] = 'Navigation warning'; |
|
2646 | + } |
|
2647 | + if ($q[4] == 'AE') { |
|
2648 | + $data['scope'] = 'Airport/Enroute warning'; |
|
2649 | + } |
|
2650 | + if ($q[4] == 'AW') { |
|
2651 | + $data['scope'] = 'Airport/Navigation warning'; |
|
2652 | + } |
|
2131 | 2653 | //$data['scope'] = $q[4]; |
2132 | 2654 | $data['lower_limit'] = $q[5]; |
2133 | 2655 | $data['upper_limit'] = $q[6]; |
@@ -2135,8 +2657,12 @@ discard block |
||
2135 | 2657 | sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius); |
2136 | 2658 | $latitude = $Common->convertDec($las,'latitude'); |
2137 | 2659 | $longitude = $Common->convertDec($lns,'longitude'); |
2138 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
2139 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
2660 | + if ($lac == 'S') { |
|
2661 | + $latitude = '-'.$latitude; |
|
2662 | + } |
|
2663 | + if ($lnc == 'W') { |
|
2664 | + $longitude = '-'.$longitude; |
|
2665 | + } |
|
2140 | 2666 | $data['center_latitude'] = $latitude; |
2141 | 2667 | $data['center_longitude'] = $longitude; |
2142 | 2668 | $data['radius'] = intval($radius); |
@@ -2166,10 +2692,14 @@ discard block |
||
2166 | 2692 | $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']); |
2167 | 2693 | unset($data); |
2168 | 2694 | } |
2169 | - } else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
|
2695 | + } else { |
|
2696 | + $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
|
2697 | + } |
|
2170 | 2698 | if ($error != '') { |
2171 | 2699 | return $error; |
2172 | - } elseif ($globalDebug) echo "Done\n"; |
|
2700 | + } elseif ($globalDebug) { |
|
2701 | + echo "Done\n"; |
|
2702 | + } |
|
2173 | 2703 | return ''; |
2174 | 2704 | } |
2175 | 2705 | |
@@ -2194,7 +2724,9 @@ discard block |
||
2194 | 2724 | $airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json'); |
2195 | 2725 | $airspace_json = json_decode($airspace_lst,true); |
2196 | 2726 | foreach ($airspace_json['records'] as $airspace) { |
2197 | - if ($globalDebug) echo $airspace['name']."...\n"; |
|
2727 | + if ($globalDebug) { |
|
2728 | + echo $airspace['name']."...\n"; |
|
2729 | + } |
|
2198 | 2730 | update_db::download($airspace['uri'],$tmp_dir.$airspace['name']); |
2199 | 2731 | if (file_exists($tmp_dir.$airspace['name'])) { |
2200 | 2732 | file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name']))); |
@@ -2223,8 +2755,11 @@ discard block |
||
2223 | 2755 | return "error : ".$e->getMessage(); |
2224 | 2756 | } |
2225 | 2757 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2226 | - if ($row['nb'] > 0) return false; |
|
2227 | - else return true; |
|
2758 | + if ($row['nb'] > 0) { |
|
2759 | + return false; |
|
2760 | + } else { |
|
2761 | + return true; |
|
2762 | + } |
|
2228 | 2763 | } |
2229 | 2764 | |
2230 | 2765 | public static function insert_last_update() { |
@@ -2249,8 +2784,11 @@ discard block |
||
2249 | 2784 | return "error : ".$e->getMessage(); |
2250 | 2785 | } |
2251 | 2786 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2252 | - if ($row['nb'] > 0) return true; |
|
2253 | - else return false; |
|
2787 | + if ($row['nb'] > 0) { |
|
2788 | + return true; |
|
2789 | + } else { |
|
2790 | + return false; |
|
2791 | + } |
|
2254 | 2792 | } |
2255 | 2793 | |
2256 | 2794 | |
@@ -2281,8 +2819,11 @@ discard block |
||
2281 | 2819 | return "error : ".$e->getMessage(); |
2282 | 2820 | } |
2283 | 2821 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2284 | - if ($row['nb'] > 0) return false; |
|
2285 | - else return true; |
|
2822 | + if ($row['nb'] > 0) { |
|
2823 | + return false; |
|
2824 | + } else { |
|
2825 | + return true; |
|
2826 | + } |
|
2286 | 2827 | } |
2287 | 2828 | |
2288 | 2829 | public static function insert_last_notam_update() { |
@@ -2311,8 +2852,11 @@ discard block |
||
2311 | 2852 | return "error : ".$e->getMessage(); |
2312 | 2853 | } |
2313 | 2854 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2314 | - if ($row['nb'] > 0) return false; |
|
2315 | - else return true; |
|
2855 | + if ($row['nb'] > 0) { |
|
2856 | + return false; |
|
2857 | + } else { |
|
2858 | + return true; |
|
2859 | + } |
|
2316 | 2860 | } |
2317 | 2861 | |
2318 | 2862 | public static function insert_last_airspace_update() { |
@@ -2342,8 +2886,11 @@ discard block |
||
2342 | 2886 | return "error : ".$e->getMessage(); |
2343 | 2887 | } |
2344 | 2888 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2345 | - if ($row['nb'] > 0) return false; |
|
2346 | - else return true; |
|
2889 | + if ($row['nb'] > 0) { |
|
2890 | + return false; |
|
2891 | + } else { |
|
2892 | + return true; |
|
2893 | + } |
|
2347 | 2894 | } |
2348 | 2895 | |
2349 | 2896 | public static function insert_last_owner_update() { |
@@ -2372,8 +2919,11 @@ discard block |
||
2372 | 2919 | return "error : ".$e->getMessage(); |
2373 | 2920 | } |
2374 | 2921 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2375 | - if ($row['nb'] > 0) return false; |
|
2376 | - else return true; |
|
2922 | + if ($row['nb'] > 0) { |
|
2923 | + return false; |
|
2924 | + } else { |
|
2925 | + return true; |
|
2926 | + } |
|
2377 | 2927 | } |
2378 | 2928 | |
2379 | 2929 | public static function insert_last_schedules_update() { |
@@ -2402,8 +2952,11 @@ discard block |
||
2402 | 2952 | return "error : ".$e->getMessage(); |
2403 | 2953 | } |
2404 | 2954 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2405 | - if ($row['nb'] > 0) return false; |
|
2406 | - else return true; |
|
2955 | + if ($row['nb'] > 0) { |
|
2956 | + return false; |
|
2957 | + } else { |
|
2958 | + return true; |
|
2959 | + } |
|
2407 | 2960 | } |
2408 | 2961 | |
2409 | 2962 | public static function insert_last_tle_update() { |