@@ -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,source_type) VALUES (:ModeS,:Registration,:ICAOTypeCode,:source,:source_type)'; |
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,':source_type' => 'flarm'); |
|
308 | + $query_dest_values = array(':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':source_type' => 'flarm'); |
|
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,source_type) VALUES (:lastmodified,:ModeS,:Registration,:ICAOTypeCode,:source,:source_type)'; |
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,':source_type' => 'flarm'); |
|
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, ':source_type' => 'flarm'); |
|
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, $globalMasterSource; |
400 | 400 | //$query = 'TRUNCATE TABLE aircraft_modes'; |
401 | 401 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source; DELETE FROM aircraft_modes WHERE Source = :source;"; |
@@ -403,12 +403,12 @@ 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 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
410 | 410 | $Spotter = new Spotter(); |
411 | - if ($fh = fopen($database_file,"r")) { |
|
411 | + if ($fh = fopen($database_file, "r")) { |
|
412 | 412 | //$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)'; |
413 | 413 | $query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)'; |
414 | 414 | $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)'; |
@@ -418,9 +418,9 @@ discard block |
||
418 | 418 | $sth_modes = $Connection->db->prepare($query_modes); |
419 | 419 | try { |
420 | 420 | if ($globalTransaction) $Connection->db->beginTransaction(); |
421 | - $tmp = fgetcsv($fh,9999,',','"'); |
|
421 | + $tmp = fgetcsv($fh, 9999, ',', '"'); |
|
422 | 422 | while (!feof($fh)) { |
423 | - $line = fgetcsv($fh,9999,',','"'); |
|
423 | + $line = fgetcsv($fh, 9999, ',', '"'); |
|
424 | 424 | $values = array(); |
425 | 425 | //print_r($line); |
426 | 426 | if ($country == 'F') { |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | $values['base'] = $line[4]; |
429 | 429 | $values['owner'] = $line[5]; |
430 | 430 | if ($line[6] == '') $values['date_first_reg'] = null; |
431 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
431 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6])); |
|
432 | 432 | $values['cancel'] = $line[7]; |
433 | 433 | } elseif ($country == 'EI') { |
434 | 434 | // TODO : add modeS & reg to aircraft_modes |
@@ -436,7 +436,7 @@ discard block |
||
436 | 436 | $values['base'] = $line[3]; |
437 | 437 | $values['owner'] = $line[2]; |
438 | 438 | if ($line[1] == '') $values['date_first_reg'] = null; |
439 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
439 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[1])); |
|
440 | 440 | $values['cancel'] = ''; |
441 | 441 | $values['modes'] = $line[7]; |
442 | 442 | $values['icao'] = $line[8]; |
@@ -456,7 +456,7 @@ discard block |
||
456 | 456 | $values['base'] = null; |
457 | 457 | $values['owner'] = $line[5]; |
458 | 458 | if ($line[18] == '') $values['date_first_reg'] = null; |
459 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
459 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[18])); |
|
460 | 460 | $values['cancel'] = ''; |
461 | 461 | } elseif ($country == 'VH') { |
462 | 462 | // TODO : add modeS & reg to aircraft_modes |
@@ -464,7 +464,7 @@ discard block |
||
464 | 464 | $values['base'] = null; |
465 | 465 | $values['owner'] = $line[12]; |
466 | 466 | if ($line[28] == '') $values['date_first_reg'] = null; |
467 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
467 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[28])); |
|
468 | 468 | |
469 | 469 | $values['cancel'] = $line[39]; |
470 | 470 | } elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { |
@@ -484,28 +484,28 @@ discard block |
||
484 | 484 | $values['base'] = null; |
485 | 485 | $values['owner'] = $line[8]; |
486 | 486 | if ($line[7] == '') $values['date_first_reg'] = null; |
487 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
487 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7])); |
|
488 | 488 | $values['cancel'] = ''; |
489 | 489 | } elseif ($country == 'PP') { |
490 | 490 | $values['registration'] = $line[0]; |
491 | 491 | $values['base'] = null; |
492 | 492 | $values['owner'] = $line[4]; |
493 | 493 | if ($line[6] == '') $values['date_first_reg'] = null; |
494 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
494 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6])); |
|
495 | 495 | $values['cancel'] = $line[7]; |
496 | 496 | } elseif ($country == 'E7') { |
497 | 497 | $values['registration'] = $line[0]; |
498 | 498 | $values['base'] = null; |
499 | 499 | $values['owner'] = $line[4]; |
500 | 500 | if ($line[5] == '') $values['date_first_reg'] = null; |
501 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
501 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[5])); |
|
502 | 502 | $values['cancel'] = ''; |
503 | 503 | } elseif ($country == '8Q') { |
504 | 504 | $values['registration'] = $line[0]; |
505 | 505 | $values['base'] = null; |
506 | 506 | $values['owner'] = $line[3]; |
507 | 507 | if ($line[7] == '') $values['date_first_reg'] = null; |
508 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
508 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7])); |
|
509 | 509 | $values['cancel'] = ''; |
510 | 510 | } elseif ($country == 'ZK') { |
511 | 511 | $values['registration'] = $line[0]; |
@@ -519,18 +519,18 @@ discard block |
||
519 | 519 | $values['registration'] = $line[0]; |
520 | 520 | $values['base'] = null; |
521 | 521 | $values['owner'] = $line[6]; |
522 | - $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
523 | - $values['cancel'] = date("Y-m-d",strtotime($line[8])); |
|
522 | + $values['date_first_reg'] = date("Y-m-d", strtotime($line[5])); |
|
523 | + $values['cancel'] = date("Y-m-d", strtotime($line[8])); |
|
524 | 524 | $values['modes'] = $line[4]; |
525 | 525 | $values['icao'] = $line[10]; |
526 | 526 | } elseif ($country == 'OY') { |
527 | 527 | $values['registration'] = $line[0]; |
528 | - $values['date_first_reg'] = date("Y-m-d",strtotime($line[4])); |
|
528 | + $values['date_first_reg'] = date("Y-m-d", strtotime($line[4])); |
|
529 | 529 | $values['modes'] = $line[5]; |
530 | 530 | $values['icao'] = $line[6]; |
531 | 531 | } elseif ($country == 'PH') { |
532 | 532 | $values['registration'] = $line[0]; |
533 | - $values['date_first_reg'] = date("Y-m-d",strtotime($line[3])); |
|
533 | + $values['date_first_reg'] = date("Y-m-d", strtotime($line[3])); |
|
534 | 534 | $values['modes'] = $line[4]; |
535 | 535 | $values['icao'] = $line[5]; |
536 | 536 | } elseif ($country == 'OM' || $country == 'TF') { |
@@ -541,17 +541,17 @@ discard block |
||
541 | 541 | $values['cancel'] = ''; |
542 | 542 | } |
543 | 543 | if (isset($values['cancel']) && $values['cancel'] == '' && $values['registration'] != null && isset($values['owner'])) { |
544 | - $query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file); |
|
544 | + $query_dest_values = array(':registration' => $values['registration'], ':base' => $values['base'], ':date_first_reg' => $values['date_first_reg'], ':owner' => $values['owner'], ':source' => $database_file); |
|
545 | 545 | $sth_dest->execute($query_dest_values); |
546 | 546 | } |
547 | 547 | if ($globalMasterSource && $values['registration'] != null && isset($values['modes']) && $values['modes'] != '') { |
548 | 548 | $modescountry = $Spotter->countryFromAircraftRegistration($values['registration']); |
549 | - $query_modes_values = array(':registration' => $values['registration'],':modes' => $values['modes'],':modescountry' => $modescountry,':icaotypecode' => $values['icao'],':source' => $database_file); |
|
549 | + $query_modes_values = array(':registration' => $values['registration'], ':modes' => $values['modes'], ':modescountry' => $modescountry, ':icaotypecode' => $values['icao'], ':source' => $database_file); |
|
550 | 550 | $sth_modes->execute($query_modes_values); |
551 | 551 | } |
552 | 552 | } |
553 | 553 | if ($globalTransaction) $Connection->db->commit(); |
554 | - } catch(PDOException $e) { |
|
554 | + } catch (PDOException $e) { |
|
555 | 555 | return "error : ".$e->getMessage(); |
556 | 556 | } |
557 | 557 | } |
@@ -666,7 +666,7 @@ discard block |
||
666 | 666 | $Connection = new Connection(); |
667 | 667 | $sth = $Connection->db->prepare($query); |
668 | 668 | $sth->execute(); |
669 | - } catch(PDOException $e) { |
|
669 | + } catch (PDOException $e) { |
|
670 | 670 | return "error : ".$e->getMessage(); |
671 | 671 | } |
672 | 672 | |
@@ -676,7 +676,7 @@ discard block |
||
676 | 676 | $Connection = new Connection(); |
677 | 677 | $sth = $Connection->db->prepare($query); |
678 | 678 | $sth->execute(); |
679 | - } catch(PDOException $e) { |
|
679 | + } catch (PDOException $e) { |
|
680 | 680 | return "error : ".$e->getMessage(); |
681 | 681 | } |
682 | 682 | |
@@ -687,7 +687,7 @@ discard block |
||
687 | 687 | if ($globalTransaction) $Connection->db->beginTransaction(); |
688 | 688 | |
689 | 689 | $i = 0; |
690 | - while($row = sparql_fetch_array($result)) |
|
690 | + while ($row = sparql_fetch_array($result)) |
|
691 | 691 | { |
692 | 692 | if ($i >= 1) { |
693 | 693 | //print_r($row); |
@@ -707,31 +707,31 @@ discard block |
||
707 | 707 | $row['image'] = ''; |
708 | 708 | $row['image_thumb'] = ''; |
709 | 709 | } else { |
710 | - $image = str_replace(' ','_',$row['image']); |
|
710 | + $image = str_replace(' ', '_', $row['image']); |
|
711 | 711 | $digest = md5($image); |
712 | - $folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image . '/220px-' . $image; |
|
713 | - $row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/' . $folder; |
|
714 | - $folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image; |
|
715 | - $row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/' . $folder; |
|
712 | + $folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image.'/220px-'.$image; |
|
713 | + $row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/'.$folder; |
|
714 | + $folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image; |
|
715 | + $row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/'.$folder; |
|
716 | 716 | } |
717 | 717 | |
718 | - $country = explode('-',$row['country']); |
|
718 | + $country = explode('-', $row['country']); |
|
719 | 719 | $row['country'] = $country[0]; |
720 | 720 | |
721 | 721 | $row['type'] = trim($row['type']); |
722 | - 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'])) { |
|
722 | + 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'])) { |
|
723 | 723 | $row['type'] = 'Military'; |
724 | 724 | } 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') { |
725 | 725 | $row['type'] = 'small_airport'; |
726 | 726 | } |
727 | 727 | |
728 | - $row['city'] = urldecode(str_replace('_',' ',str_replace('http://dbpedia.org/resource/','',$row['city']))); |
|
729 | - $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']); |
|
728 | + $row['city'] = urldecode(str_replace('_', ' ', str_replace('http://dbpedia.org/resource/', '', $row['city']))); |
|
729 | + $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']); |
|
730 | 730 | //print_r($query_dest_values); |
731 | 731 | |
732 | 732 | try { |
733 | 733 | $sth_dest->execute($query_dest_values); |
734 | - } catch(PDOException $e) { |
|
734 | + } catch (PDOException $e) { |
|
735 | 735 | return "error : ".$e->getMessage(); |
736 | 736 | } |
737 | 737 | } |
@@ -745,7 +745,7 @@ discard block |
||
745 | 745 | $Connection = new Connection(); |
746 | 746 | $sth = $Connection->db->prepare($query); |
747 | 747 | $sth->execute(); |
748 | - } catch(PDOException $e) { |
|
748 | + } catch (PDOException $e) { |
|
749 | 749 | return "error : ".$e->getMessage(); |
750 | 750 | } |
751 | 751 | |
@@ -753,12 +753,12 @@ discard block |
||
753 | 753 | if ($globalDebug) echo "Insert Not available Airport...\n"; |
754 | 754 | $query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image`,`image_thumb`) |
755 | 755 | VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image, :image_thumb)"; |
756 | - $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' => ''); |
|
756 | + $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' => ''); |
|
757 | 757 | try { |
758 | 758 | $Connection = new Connection(); |
759 | 759 | $sth = $Connection->db->prepare($query); |
760 | 760 | $sth->execute($query_values); |
761 | - } catch(PDOException $e) { |
|
761 | + } catch (PDOException $e) { |
|
762 | 762 | return "error : ".$e->getMessage(); |
763 | 763 | } |
764 | 764 | $i++; |
@@ -776,7 +776,7 @@ discard block |
||
776 | 776 | echo "Download data from ourairports.com...\n"; |
777 | 777 | $delimiter = ','; |
778 | 778 | $out_file = $tmp_dir.'airports.csv'; |
779 | - update_db::download('http://ourairports.com/data/airports.csv',$out_file); |
|
779 | + update_db::download('http://ourairports.com/data/airports.csv', $out_file); |
|
780 | 780 | if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
781 | 781 | echo "Add data from ourairports.com...\n"; |
782 | 782 | |
@@ -787,32 +787,32 @@ discard block |
||
787 | 787 | //$Connection->db->beginTransaction(); |
788 | 788 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
789 | 789 | { |
790 | - if(!$header) $header = $row; |
|
790 | + if (!$header) $header = $row; |
|
791 | 791 | else { |
792 | 792 | $data = array(); |
793 | 793 | $data = array_combine($header, $row); |
794 | 794 | try { |
795 | 795 | $sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE `icao` = :icao'); |
796 | 796 | $sth->execute(array(':icao' => $data['gps_code'])); |
797 | - } catch(PDOException $e) { |
|
797 | + } catch (PDOException $e) { |
|
798 | 798 | return "error : ".$e->getMessage(); |
799 | 799 | } |
800 | 800 | if ($sth->fetchColumn() > 0) { |
801 | 801 | $query = 'UPDATE airport SET `type` = :type WHERE icao = :icao'; |
802 | 802 | try { |
803 | 803 | $sth = $Connection->db->prepare($query); |
804 | - $sth->execute(array(':icao' => $data['gps_code'],':type' => $data['type'])); |
|
805 | - } catch(PDOException $e) { |
|
804 | + $sth->execute(array(':icao' => $data['gps_code'], ':type' => $data['type'])); |
|
805 | + } catch (PDOException $e) { |
|
806 | 806 | return "error : ".$e->getMessage(); |
807 | 807 | } |
808 | 808 | } else { |
809 | 809 | $query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`) |
810 | 810 | VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link)"; |
811 | - $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']); |
|
811 | + $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']); |
|
812 | 812 | try { |
813 | 813 | $sth = $Connection->db->prepare($query); |
814 | 814 | $sth->execute($query_values); |
815 | - } catch(PDOException $e) { |
|
815 | + } catch (PDOException $e) { |
|
816 | 816 | return "error : ".$e->getMessage(); |
817 | 817 | } |
818 | 818 | $i++; |
@@ -825,7 +825,7 @@ discard block |
||
825 | 825 | |
826 | 826 | echo "Download data from another free database...\n"; |
827 | 827 | $out_file = $tmp_dir.'GlobalAirportDatabase.zip'; |
828 | - update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file); |
|
828 | + update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip', $out_file); |
|
829 | 829 | if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
830 | 830 | update_db::unzip($out_file); |
831 | 831 | $header = NULL; |
@@ -837,15 +837,15 @@ discard block |
||
837 | 837 | //$Connection->db->beginTransaction(); |
838 | 838 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
839 | 839 | { |
840 | - if(!$header) $header = $row; |
|
840 | + if (!$header) $header = $row; |
|
841 | 841 | else { |
842 | 842 | $data = $row; |
843 | 843 | |
844 | 844 | $query = 'UPDATE airport SET `city` = :city, `country` = :country WHERE icao = :icao'; |
845 | 845 | try { |
846 | 846 | $sth = $Connection->db->prepare($query); |
847 | - $sth->execute(array(':icao' => $data[0],':city' => ucwords(strtolower($data[3])),':country' => ucwords(strtolower($data[4])))); |
|
848 | - } catch(PDOException $e) { |
|
847 | + $sth->execute(array(':icao' => $data[0], ':city' => ucwords(strtolower($data[3])), ':country' => ucwords(strtolower($data[4])))); |
|
848 | + } catch (PDOException $e) { |
|
849 | 849 | return "error : ".$e->getMessage(); |
850 | 850 | } |
851 | 851 | } |
@@ -859,15 +859,15 @@ discard block |
||
859 | 859 | try { |
860 | 860 | $sth = $Connection->db->prepare("SELECT icao FROM airport WHERE `name` LIKE '%Air Base%'"); |
861 | 861 | $sth->execute(); |
862 | - } catch(PDOException $e) { |
|
862 | + } catch (PDOException $e) { |
|
863 | 863 | return "error : ".$e->getMessage(); |
864 | 864 | } |
865 | 865 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
866 | 866 | $query2 = 'UPDATE airport SET `type` = :type WHERE icao = :icao'; |
867 | 867 | try { |
868 | 868 | $sth2 = $Connection->db->prepare($query2); |
869 | - $sth2->execute(array(':icao' => $row['icao'],':type' => 'military')); |
|
870 | - } catch(PDOException $e) { |
|
869 | + $sth2->execute(array(':icao' => $row['icao'], ':type' => 'military')); |
|
870 | + } catch (PDOException $e) { |
|
871 | 871 | return "error : ".$e->getMessage(); |
872 | 872 | } |
873 | 873 | } |
@@ -891,7 +891,7 @@ discard block |
||
891 | 891 | $Connection = new Connection(); |
892 | 892 | $sth = $Connection->db->prepare($query); |
893 | 893 | $sth->execute(array(':source' => 'translation.csv')); |
894 | - } catch(PDOException $e) { |
|
894 | + } catch (PDOException $e) { |
|
895 | 895 | return "error : ".$e->getMessage(); |
896 | 896 | } |
897 | 897 | |
@@ -908,7 +908,7 @@ discard block |
||
908 | 908 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
909 | 909 | { |
910 | 910 | $i++; |
911 | - if($i > 12) { |
|
911 | + if ($i > 12) { |
|
912 | 912 | $data = $row; |
913 | 913 | $operator = $data[2]; |
914 | 914 | if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) { |
@@ -916,7 +916,7 @@ discard block |
||
916 | 916 | //echo substr($operator, 0, 2)."\n";; |
917 | 917 | if (count($airline_array) > 0) { |
918 | 918 | //print_r($airline_array); |
919 | - $operator = $airline_array[0]['icao'].substr($operator,2); |
|
919 | + $operator = $airline_array[0]['icao'].substr($operator, 2); |
|
920 | 920 | } |
921 | 921 | } |
922 | 922 | |
@@ -924,14 +924,14 @@ discard block |
||
924 | 924 | if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) { |
925 | 925 | $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2)); |
926 | 926 | if (count($airline_array) > 0) { |
927 | - $operator_correct = $airline_array[0]['icao'].substr($operator_correct,2); |
|
927 | + $operator_correct = $airline_array[0]['icao'].substr($operator_correct, 2); |
|
928 | 928 | } |
929 | 929 | } |
930 | 930 | $query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)'; |
931 | 931 | try { |
932 | 932 | $sth = $Connection->db->prepare($query); |
933 | - $sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $operator,':Operator_correct' => $operator_correct, ':source' => 'translation.csv')); |
|
934 | - } catch(PDOException $e) { |
|
933 | + $sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $operator, ':Operator_correct' => $operator_correct, ':source' => 'translation.csv')); |
|
934 | + } catch (PDOException $e) { |
|
935 | 935 | return "error : ".$e->getMessage(); |
936 | 936 | } |
937 | 937 | } |
@@ -951,7 +951,7 @@ discard block |
||
951 | 951 | $Connection = new Connection(); |
952 | 952 | $sth = $Connection->db->prepare($query); |
953 | 953 | $sth->execute(array(':source' => 'website_fam')); |
954 | - } catch(PDOException $e) { |
|
954 | + } catch (PDOException $e) { |
|
955 | 955 | return "error : ".$e->getMessage(); |
956 | 956 | } |
957 | 957 | |
@@ -971,8 +971,8 @@ discard block |
||
971 | 971 | $query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)'; |
972 | 972 | try { |
973 | 973 | $sth = $Connection->db->prepare($query); |
974 | - $sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $data[2],':Operator_correct' => $data[3], ':source' => 'website_fam')); |
|
975 | - } catch(PDOException $e) { |
|
974 | + $sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $data[2], ':Operator_correct' => $data[3], ':source' => 'website_fam')); |
|
975 | + } catch (PDOException $e) { |
|
976 | 976 | return "error : ".$e->getMessage(); |
977 | 977 | } |
978 | 978 | } |
@@ -995,7 +995,7 @@ discard block |
||
995 | 995 | $Connection = new Connection(); |
996 | 996 | $sth = $Connection->db->prepare($query); |
997 | 997 | $sth->execute(array(':source' => 'website_faa')); |
998 | - } catch(PDOException $e) { |
|
998 | + } catch (PDOException $e) { |
|
999 | 999 | return "error : ".$e->getMessage(); |
1000 | 1000 | } |
1001 | 1001 | |
@@ -1004,7 +1004,7 @@ discard block |
||
1004 | 1004 | $Connection = new Connection(); |
1005 | 1005 | $sth = $Connection->db->prepare($query); |
1006 | 1006 | $sth->execute(array(':source' => 'website_faa')); |
1007 | - } catch(PDOException $e) { |
|
1007 | + } catch (PDOException $e) { |
|
1008 | 1008 | return "error : ".$e->getMessage(); |
1009 | 1009 | } |
1010 | 1010 | |
@@ -1021,8 +1021,8 @@ discard block |
||
1021 | 1021 | $query_search = 'SELECT icaotypecode FROM aircraft_modes WHERE registration = :registration AND Source <> :source LIMIT 1'; |
1022 | 1022 | try { |
1023 | 1023 | $sths = $Connection->db->prepare($query_search); |
1024 | - $sths->execute(array(':registration' => 'N'.$data[0],':source' => 'website_faa')); |
|
1025 | - } catch(PDOException $e) { |
|
1024 | + $sths->execute(array(':registration' => 'N'.$data[0], ':source' => 'website_faa')); |
|
1025 | + } catch (PDOException $e) { |
|
1026 | 1026 | return "error s : ".$e->getMessage(); |
1027 | 1027 | } |
1028 | 1028 | $result_search = $sths->fetchAll(PDO::FETCH_ASSOC); |
@@ -1035,8 +1035,8 @@ discard block |
||
1035 | 1035 | //} |
1036 | 1036 | try { |
1037 | 1037 | $sthi = $Connection->db->prepare($queryi); |
1038 | - $sthi->execute(array(':mfr' => $data[2],':icao' => $result_search[0]['icaotypecode'])); |
|
1039 | - } catch(PDOException $e) { |
|
1038 | + $sthi->execute(array(':mfr' => $data[2], ':icao' => $result_search[0]['icaotypecode'])); |
|
1039 | + } catch (PDOException $e) { |
|
1040 | 1040 | return "error u : ".$e->getMessage(); |
1041 | 1041 | } |
1042 | 1042 | } else { |
@@ -1044,7 +1044,7 @@ discard block |
||
1044 | 1044 | try { |
1045 | 1045 | $sthsm = $Connection->db->prepare($query_search_mfr); |
1046 | 1046 | $sthsm->execute(array(':mfr' => $data[2])); |
1047 | - } catch(PDOException $e) { |
|
1047 | + } catch (PDOException $e) { |
|
1048 | 1048 | return "error mfr : ".$e->getMessage(); |
1049 | 1049 | } |
1050 | 1050 | $result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC); |
@@ -1054,8 +1054,8 @@ discard block |
||
1054 | 1054 | $queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)'; |
1055 | 1055 | try { |
1056 | 1056 | $sthf = $Connection->db->prepare($queryf); |
1057 | - $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')); |
|
1058 | - } catch(PDOException $e) { |
|
1057 | + $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')); |
|
1058 | + } catch (PDOException $e) { |
|
1059 | 1059 | return "error f : ".$e->getMessage(); |
1060 | 1060 | } |
1061 | 1061 | } |
@@ -1065,13 +1065,13 @@ discard block |
||
1065 | 1065 | $query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)'; |
1066 | 1066 | try { |
1067 | 1067 | $sth = $Connection->db->prepare($query); |
1068 | - $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')); |
|
1069 | - } catch(PDOException $e) { |
|
1068 | + $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')); |
|
1069 | + } catch (PDOException $e) { |
|
1070 | 1070 | return "error i : ".$e->getMessage(); |
1071 | 1071 | } |
1072 | 1072 | } |
1073 | 1073 | } |
1074 | - if ($i % 90 == 0) { |
|
1074 | + if ($i%90 == 0) { |
|
1075 | 1075 | if ($globalTransaction) $Connection->db->commit(); |
1076 | 1076 | if ($globalTransaction) $Connection->db->beginTransaction(); |
1077 | 1077 | } |
@@ -1090,7 +1090,7 @@ discard block |
||
1090 | 1090 | $Connection = new Connection(); |
1091 | 1091 | $sth = $Connection->db->prepare($query); |
1092 | 1092 | $sth->execute(array(':source' => 'website_fam')); |
1093 | - } catch(PDOException $e) { |
|
1093 | + } catch (PDOException $e) { |
|
1094 | 1094 | return "error : ".$e->getMessage(); |
1095 | 1095 | } |
1096 | 1096 | |
@@ -1111,8 +1111,8 @@ discard block |
||
1111 | 1111 | $query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)'; |
1112 | 1112 | try { |
1113 | 1113 | $sth = $Connection->db->prepare($query); |
1114 | - $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')); |
|
1115 | - } catch(PDOException $e) { |
|
1114 | + $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')); |
|
1115 | + } catch (PDOException $e) { |
|
1116 | 1116 | return "error : ".$e->getMessage(); |
1117 | 1117 | } |
1118 | 1118 | } |
@@ -1131,7 +1131,7 @@ discard block |
||
1131 | 1131 | $Connection = new Connection(); |
1132 | 1132 | $sth = $Connection->db->prepare($query); |
1133 | 1133 | $sth->execute(array(':source' => 'website_fam')); |
1134 | - } catch(PDOException $e) { |
|
1134 | + } catch (PDOException $e) { |
|
1135 | 1135 | return "error : ".$e->getMessage(); |
1136 | 1136 | } |
1137 | 1137 | |
@@ -1147,8 +1147,8 @@ discard block |
||
1147 | 1147 | $query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,NULL,:source)'; |
1148 | 1148 | try { |
1149 | 1149 | $sth = $Connection->db->prepare($query); |
1150 | - $sth->execute(array(':registration' => $data[0],':base' => $data[1],':owner' => $data[2], ':source' => 'website_fam')); |
|
1151 | - } catch(PDOException $e) { |
|
1150 | + $sth->execute(array(':registration' => $data[0], ':base' => $data[1], ':owner' => $data[2], ':source' => 'website_fam')); |
|
1151 | + } catch (PDOException $e) { |
|
1152 | 1152 | print_r($data); |
1153 | 1153 | return "error : ".$e->getMessage(); |
1154 | 1154 | } |
@@ -1168,7 +1168,7 @@ discard block |
||
1168 | 1168 | $Connection = new Connection(); |
1169 | 1169 | $sth = $Connection->db->prepare($query); |
1170 | 1170 | $sth->execute(array(':source' => 'website_fam')); |
1171 | - } catch(PDOException $e) { |
|
1171 | + } catch (PDOException $e) { |
|
1172 | 1172 | return "error : ".$e->getMessage(); |
1173 | 1173 | } |
1174 | 1174 | |
@@ -1188,8 +1188,8 @@ discard block |
||
1188 | 1188 | $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)'; |
1189 | 1189 | try { |
1190 | 1190 | $sth = $Connection->db->prepare($query); |
1191 | - $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')); |
|
1192 | - } catch(PDOException $e) { |
|
1191 | + $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')); |
|
1192 | + } catch (PDOException $e) { |
|
1193 | 1193 | return "error : ".$e->getMessage(); |
1194 | 1194 | } |
1195 | 1195 | } |
@@ -1208,7 +1208,7 @@ discard block |
||
1208 | 1208 | $Connection = new Connection(); |
1209 | 1209 | $sth = $Connection->db->prepare($query); |
1210 | 1210 | $sth->execute(); |
1211 | - } catch(PDOException $e) { |
|
1211 | + } catch (PDOException $e) { |
|
1212 | 1212 | return "error : ".$e->getMessage(); |
1213 | 1213 | } |
1214 | 1214 | |
@@ -1224,7 +1224,7 @@ discard block |
||
1224 | 1224 | try { |
1225 | 1225 | $sth = $Connection->db->prepare($query); |
1226 | 1226 | $sth->execute(array(':icao' => $icao)); |
1227 | - } catch(PDOException $e) { |
|
1227 | + } catch (PDOException $e) { |
|
1228 | 1228 | return "error : ".$e->getMessage(); |
1229 | 1229 | } |
1230 | 1230 | } |
@@ -1235,7 +1235,7 @@ discard block |
||
1235 | 1235 | return ''; |
1236 | 1236 | } |
1237 | 1237 | |
1238 | - public static function tle($filename,$tletype) { |
|
1238 | + public static function tle($filename, $tletype) { |
|
1239 | 1239 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
1240 | 1240 | global $tmp_dir, $globalTransaction; |
1241 | 1241 | //$Spotter = new Spotter(); |
@@ -1245,7 +1245,7 @@ discard block |
||
1245 | 1245 | $Connection = new Connection(); |
1246 | 1246 | $sth = $Connection->db->prepare($query); |
1247 | 1247 | $sth->execute(array(':source' => $filename)); |
1248 | - } catch(PDOException $e) { |
|
1248 | + } catch (PDOException $e) { |
|
1249 | 1249 | return "error : ".$e->getMessage(); |
1250 | 1250 | } |
1251 | 1251 | |
@@ -1270,8 +1270,8 @@ discard block |
||
1270 | 1270 | $query = 'INSERT INTO tle (tle_name,tle_tle1,tle_tle2,tle_type,tle_source) VALUES (:name, :tle1, :tle2, :type, :source)'; |
1271 | 1271 | try { |
1272 | 1272 | $sth = $Connection->db->prepare($query); |
1273 | - $sth->execute(array(':name' => $dbdata['name'],':tle1' => $dbdata['tle1'],':tle2' => $dbdata['tle2'], ':type' => $tletype,':source' => $filename)); |
|
1274 | - } catch(PDOException $e) { |
|
1273 | + $sth->execute(array(':name' => $dbdata['name'], ':tle1' => $dbdata['tle1'], ':tle2' => $dbdata['tle2'], ':type' => $tletype, ':source' => $filename)); |
|
1274 | + } catch (PDOException $e) { |
|
1275 | 1275 | return "error : ".$e->getMessage(); |
1276 | 1276 | } |
1277 | 1277 | |
@@ -1291,28 +1291,28 @@ discard block |
||
1291 | 1291 | */ |
1292 | 1292 | private static function table2array($data) { |
1293 | 1293 | $html = str_get_html($data); |
1294 | - $tabledata=array(); |
|
1295 | - foreach($html->find('tr') as $element) |
|
1294 | + $tabledata = array(); |
|
1295 | + foreach ($html->find('tr') as $element) |
|
1296 | 1296 | { |
1297 | 1297 | $td = array(); |
1298 | - foreach( $element->find('th') as $row) |
|
1298 | + foreach ($element->find('th') as $row) |
|
1299 | 1299 | { |
1300 | 1300 | $td [] = trim($row->plaintext); |
1301 | 1301 | } |
1302 | - $td=array_filter($td); |
|
1302 | + $td = array_filter($td); |
|
1303 | 1303 | $tabledata[] = $td; |
1304 | 1304 | |
1305 | 1305 | $td = array(); |
1306 | 1306 | $tdi = array(); |
1307 | - foreach( $element->find('td') as $row) |
|
1307 | + foreach ($element->find('td') as $row) |
|
1308 | 1308 | { |
1309 | 1309 | $td [] = trim($row->plaintext); |
1310 | 1310 | $tdi [] = trim($row->innertext); |
1311 | 1311 | } |
1312 | - $td=array_filter($td); |
|
1313 | - $tdi=array_filter($tdi); |
|
1312 | + $td = array_filter($td); |
|
1313 | + $tdi = array_filter($tdi); |
|
1314 | 1314 | // $tabledata[]=array_merge($td,$tdi); |
1315 | - $tabledata[]=$td; |
|
1315 | + $tabledata[] = $td; |
|
1316 | 1316 | } |
1317 | 1317 | return(array_filter($tabledata)); |
1318 | 1318 | } |
@@ -1385,13 +1385,13 @@ discard block |
||
1385 | 1385 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1386 | 1386 | { |
1387 | 1387 | $i++; |
1388 | - if($i > 3 && count($row) > 2) { |
|
1388 | + if ($i > 3 && count($row) > 2) { |
|
1389 | 1389 | $data = array_values(array_filter($row)); |
1390 | 1390 | $cntdata = count($data); |
1391 | 1391 | if ($cntdata > 10) { |
1392 | 1392 | $value = $data[9]; |
1393 | 1393 | |
1394 | - for ($i =10;$i < $cntdata;$i++) { |
|
1394 | + for ($i = 10; $i < $cntdata; $i++) { |
|
1395 | 1395 | $value .= ' '.$data[$i]; |
1396 | 1396 | } |
1397 | 1397 | $data[9] = $value; |
@@ -1401,8 +1401,8 @@ discard block |
||
1401 | 1401 | $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)'; |
1402 | 1402 | try { |
1403 | 1403 | $sth = $Connection->db->prepare($query); |
1404 | - $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])); |
|
1405 | - } catch(PDOException $e) { |
|
1404 | + $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])); |
|
1405 | + } catch (PDOException $e) { |
|
1406 | 1406 | return "error : ".$e->getMessage(); |
1407 | 1407 | } |
1408 | 1408 | } |
@@ -1423,7 +1423,7 @@ discard block |
||
1423 | 1423 | $Connection = new Connection(); |
1424 | 1424 | $sth = $Connection->db->prepare($query); |
1425 | 1425 | $sth->execute(); |
1426 | - } catch(PDOException $e) { |
|
1426 | + } catch (PDOException $e) { |
|
1427 | 1427 | return "error : ".$e->getMessage(); |
1428 | 1428 | } |
1429 | 1429 | |
@@ -1435,12 +1435,12 @@ discard block |
||
1435 | 1435 | if ($globalTransaction) $Connection->db->beginTransaction(); |
1436 | 1436 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1437 | 1437 | { |
1438 | - if(count($row) > 1) { |
|
1438 | + if (count($row) > 1) { |
|
1439 | 1439 | $query = "INSERT INTO airlines (name,icao,active,forsource) VALUES (:name, :icao, 'Y','ivao')"; |
1440 | 1440 | try { |
1441 | 1441 | $sth = $Connection->db->prepare($query); |
1442 | - $sth->execute(array(':name' => $row[1],':icao' => $row[0])); |
|
1443 | - } catch(PDOException $e) { |
|
1442 | + $sth->execute(array(':name' => $row[1], ':icao' => $row[0])); |
|
1443 | + } catch (PDOException $e) { |
|
1444 | 1444 | return "error : ".$e->getMessage(); |
1445 | 1445 | } |
1446 | 1446 | } |
@@ -1460,21 +1460,21 @@ discard block |
||
1460 | 1460 | try { |
1461 | 1461 | $sth = $Connection->db->prepare($query); |
1462 | 1462 | $sth->execute(); |
1463 | - } catch(PDOException $e) { |
|
1463 | + } catch (PDOException $e) { |
|
1464 | 1464 | return "error : ".$e->getMessage(); |
1465 | 1465 | } |
1466 | 1466 | } |
1467 | 1467 | |
1468 | 1468 | |
1469 | - if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
1469 | + if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz', $tmp_dir.'airspace.sql'); |
|
1470 | 1470 | else { |
1471 | - update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
1471 | + update_db::gunzip('../db/pgsql/airspace.sql.gz', $tmp_dir.'airspace.sql'); |
|
1472 | 1472 | $query = "CREATE EXTENSION postgis"; |
1473 | - $Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']); |
|
1473 | + $Connection = new Connection(null, null, $_SESSION['database_root'], $_SESSION['database_rootpass']); |
|
1474 | 1474 | try { |
1475 | 1475 | $sth = $Connection->db->prepare($query); |
1476 | 1476 | $sth->execute(); |
1477 | - } catch(PDOException $e) { |
|
1477 | + } catch (PDOException $e) { |
|
1478 | 1478 | return "error : ".$e->getMessage(); |
1479 | 1479 | } |
1480 | 1480 | } |
@@ -1487,7 +1487,7 @@ discard block |
||
1487 | 1487 | include_once('class.create_db.php'); |
1488 | 1488 | require_once(dirname(__FILE__).'/../require/class.NOTAM.php'); |
1489 | 1489 | if ($globalDebug) echo "NOTAM from FlightAirMap website : Download..."; |
1490 | - update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz'); |
|
1490 | + update_db::download('http://data.flightairmap.fr/data/notam.txt.gz', $tmp_dir.'notam.txt.gz'); |
|
1491 | 1491 | $error = ''; |
1492 | 1492 | if (file_exists($tmp_dir.'notam.txt.gz')) { |
1493 | 1493 | if ($globalDebug) echo "Gunzip..."; |
@@ -1519,14 +1519,14 @@ discard block |
||
1519 | 1519 | try { |
1520 | 1520 | $sth = $Connection->db->prepare($query); |
1521 | 1521 | $sth->execute(); |
1522 | - } catch(PDOException $e) { |
|
1522 | + } catch (PDOException $e) { |
|
1523 | 1523 | echo "error : ".$e->getMessage(); |
1524 | 1524 | } |
1525 | 1525 | } |
1526 | 1526 | if ($globalDBdriver == 'mysql') { |
1527 | - update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql'); |
|
1527 | + update_db::gunzip('../db/countries.sql.gz', $tmp_dir.'countries.sql'); |
|
1528 | 1528 | } else { |
1529 | - update_db::gunzip('../db/pgsql/countries.sql.gz',$tmp_dir.'countries.sql'); |
|
1529 | + update_db::gunzip('../db/pgsql/countries.sql.gz', $tmp_dir.'countries.sql'); |
|
1530 | 1530 | } |
1531 | 1531 | $error = create_db::import_file($tmp_dir.'countries.sql'); |
1532 | 1532 | return $error; |
@@ -1539,7 +1539,7 @@ discard block |
||
1539 | 1539 | // update_db::unzip($tmp_dir.'AptNav.zip'); |
1540 | 1540 | // update_db::download('https://gitorious.org/fg/fgdata/raw/e81f8a15424a175a7b715f8f7eb8f4147b802a27:Navaids/awy.dat.gz',$tmp_dir.'awy.dat.gz'); |
1541 | 1541 | // 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'); |
1542 | - 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'); |
|
1542 | + 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'); |
|
1543 | 1543 | update_db::gunzip($tmp_dir.'awy.dat.gz'); |
1544 | 1544 | $error = update_db::waypoints($tmp_dir.'awy.dat'); |
1545 | 1545 | return $error; |
@@ -1559,7 +1559,7 @@ discard block |
||
1559 | 1559 | update_db::ivao_airlines($tmp_dir.'data/airlines.dat'); |
1560 | 1560 | if ($globalDebug) echo "Copy airlines logos to airlines images directory..."; |
1561 | 1561 | if (is_writable(dirname(__FILE__).'/../images/airlines')) { |
1562 | - if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
1562 | + if (!$Common->xcopy($tmp_dir.'logos/', dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
1563 | 1563 | } else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
1564 | 1564 | } else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
1565 | 1565 | if ($error != '') { |
@@ -1572,7 +1572,7 @@ discard block |
||
1572 | 1572 | global $tmp_dir, $globalDebug; |
1573 | 1573 | $error = ''; |
1574 | 1574 | if ($globalDebug) echo "Routes : Download..."; |
1575 | - update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz'); |
|
1575 | + update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz', $tmp_dir.'StandingData.sqb.gz'); |
|
1576 | 1576 | if (file_exists($tmp_dir.'StandingData.sqb.gz')) { |
1577 | 1577 | if ($globalDebug) echo "Gunzip..."; |
1578 | 1578 | update_db::gunzip($tmp_dir.'StandingData.sqb.gz'); |
@@ -1588,7 +1588,7 @@ discard block |
||
1588 | 1588 | global $tmp_dir, $globalDebug; |
1589 | 1589 | $error = ''; |
1590 | 1590 | if ($globalDebug) echo "Schedules Oneworld : Download..."; |
1591 | - update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz'); |
|
1591 | + update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz', $tmp_dir.'oneworld.csv.gz'); |
|
1592 | 1592 | if (file_exists($tmp_dir.'oneworld.csv.gz')) { |
1593 | 1593 | if ($globalDebug) echo "Gunzip..."; |
1594 | 1594 | update_db::gunzip($tmp_dir.'oneworld.csv.gz'); |
@@ -1604,7 +1604,7 @@ discard block |
||
1604 | 1604 | global $tmp_dir, $globalDebug; |
1605 | 1605 | $error = ''; |
1606 | 1606 | if ($globalDebug) echo "Schedules Skyteam : Download..."; |
1607 | - update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz'); |
|
1607 | + update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz', $tmp_dir.'skyteam.csv.gz'); |
|
1608 | 1608 | if (file_exists($tmp_dir.'skyteam.csv.gz')) { |
1609 | 1609 | if ($globalDebug) echo "Gunzip..."; |
1610 | 1610 | update_db::gunzip($tmp_dir.'skyteam.csv.gz'); |
@@ -1632,7 +1632,7 @@ discard block |
||
1632 | 1632 | */ |
1633 | 1633 | if ($globalDebug) echo "Modes : Download..."; |
1634 | 1634 | // update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
1635 | - update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz'); |
|
1635 | + update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz', $tmp_dir.'BaseStation.sqb.gz'); |
|
1636 | 1636 | |
1637 | 1637 | // if (file_exists($tmp_dir.'basestation_latest.zip')) { |
1638 | 1638 | if (file_exists($tmp_dir.'BaseStation.sqb.gz')) { |
@@ -1652,7 +1652,7 @@ discard block |
||
1652 | 1652 | public static function update_ModeS_faa() { |
1653 | 1653 | global $tmp_dir, $globalDebug; |
1654 | 1654 | if ($globalDebug) echo "Modes FAA: Download..."; |
1655 | - update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip'); |
|
1655 | + update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip', $tmp_dir.'ReleasableAircraft.zip'); |
|
1656 | 1656 | if (file_exists($tmp_dir.'ReleasableAircraft.zip')) { |
1657 | 1657 | if ($globalDebug) echo "Unzip..."; |
1658 | 1658 | update_db::unzip($tmp_dir.'ReleasableAircraft.zip'); |
@@ -1668,7 +1668,7 @@ discard block |
||
1668 | 1668 | public static function update_ModeS_flarm() { |
1669 | 1669 | global $tmp_dir, $globalDebug; |
1670 | 1670 | if ($globalDebug) echo "Modes Flarmnet: Download..."; |
1671 | - update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln'); |
|
1671 | + update_db::download('http://flarmnet.org/files/data.fln', $tmp_dir.'data.fln'); |
|
1672 | 1672 | if (file_exists($tmp_dir.'data.fln')) { |
1673 | 1673 | if ($globalDebug) echo "Add to DB..."; |
1674 | 1674 | $error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln'); |
@@ -1682,7 +1682,7 @@ discard block |
||
1682 | 1682 | public static function update_ModeS_ogn() { |
1683 | 1683 | global $tmp_dir, $globalDebug; |
1684 | 1684 | if ($globalDebug) echo "Modes OGN: Download..."; |
1685 | - update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv'); |
|
1685 | + update_db::download('http://ddb.glidernet.org/download/', $tmp_dir.'ogn.csv'); |
|
1686 | 1686 | if (file_exists($tmp_dir.'ogn.csv')) { |
1687 | 1687 | if ($globalDebug) echo "Add to DB..."; |
1688 | 1688 | $error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv'); |
@@ -1697,201 +1697,201 @@ discard block |
||
1697 | 1697 | global $tmp_dir, $globalDebug, $globalMasterSource; |
1698 | 1698 | |
1699 | 1699 | if ($globalDebug) echo "Owner France: Download..."; |
1700 | - update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv'); |
|
1700 | + update_db::download('http://antonakis.co.uk/registers/France.txt', $tmp_dir.'owner_f.csv'); |
|
1701 | 1701 | if (file_exists($tmp_dir.'owner_f.csv')) { |
1702 | 1702 | if ($globalDebug) echo "Add to DB..."; |
1703 | - $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F'); |
|
1703 | + $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv', 'F'); |
|
1704 | 1704 | } else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
1705 | 1705 | if ($error != '') { |
1706 | 1706 | return $error; |
1707 | 1707 | } elseif ($globalDebug) echo "Done\n"; |
1708 | 1708 | |
1709 | 1709 | if ($globalDebug) echo "Owner Ireland: Download..."; |
1710 | - update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv'); |
|
1710 | + update_db::download('http://antonakis.co.uk/registers/Ireland.txt', $tmp_dir.'owner_ei.csv'); |
|
1711 | 1711 | if (file_exists($tmp_dir.'owner_ei.csv')) { |
1712 | 1712 | if ($globalDebug) echo "Add to DB..."; |
1713 | - $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI'); |
|
1713 | + $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv', 'EI'); |
|
1714 | 1714 | } else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
1715 | 1715 | if ($error != '') { |
1716 | 1716 | return $error; |
1717 | 1717 | } elseif ($globalDebug) echo "Done\n"; |
1718 | 1718 | if ($globalDebug) echo "Owner Switzerland: Download..."; |
1719 | - update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv'); |
|
1719 | + update_db::download('http://antonakis.co.uk/registers/Switzerland.txt', $tmp_dir.'owner_hb.csv'); |
|
1720 | 1720 | if (file_exists($tmp_dir.'owner_hb.csv')) { |
1721 | 1721 | if ($globalDebug) echo "Add to DB..."; |
1722 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB'); |
|
1722 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv', 'HB'); |
|
1723 | 1723 | } else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
1724 | 1724 | if ($error != '') { |
1725 | 1725 | return $error; |
1726 | 1726 | } elseif ($globalDebug) echo "Done\n"; |
1727 | 1727 | if ($globalDebug) echo "Owner Czech Republic: Download..."; |
1728 | - update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv'); |
|
1728 | + update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt', $tmp_dir.'owner_ok.csv'); |
|
1729 | 1729 | if (file_exists($tmp_dir.'owner_ok.csv')) { |
1730 | 1730 | if ($globalDebug) echo "Add to DB..."; |
1731 | - $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK'); |
|
1731 | + $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv', 'OK'); |
|
1732 | 1732 | } else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
1733 | 1733 | if ($error != '') { |
1734 | 1734 | return $error; |
1735 | 1735 | } elseif ($globalDebug) echo "Done\n"; |
1736 | 1736 | if ($globalDebug) echo "Owner Australia: Download..."; |
1737 | - update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv'); |
|
1737 | + update_db::download('http://antonakis.co.uk/registers/Australia.txt', $tmp_dir.'owner_vh.csv'); |
|
1738 | 1738 | if (file_exists($tmp_dir.'owner_vh.csv')) { |
1739 | 1739 | if ($globalDebug) echo "Add to DB..."; |
1740 | - $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH'); |
|
1740 | + $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv', 'VH'); |
|
1741 | 1741 | } else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
1742 | 1742 | if ($error != '') { |
1743 | 1743 | return $error; |
1744 | 1744 | } elseif ($globalDebug) echo "Done\n"; |
1745 | 1745 | if ($globalDebug) echo "Owner Austria: Download..."; |
1746 | - update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv'); |
|
1746 | + update_db::download('http://antonakis.co.uk/registers/Austria.txt', $tmp_dir.'owner_oe.csv'); |
|
1747 | 1747 | if (file_exists($tmp_dir.'owner_oe.csv')) { |
1748 | 1748 | if ($globalDebug) echo "Add to DB..."; |
1749 | - $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE'); |
|
1749 | + $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv', 'OE'); |
|
1750 | 1750 | } else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
1751 | 1751 | if ($error != '') { |
1752 | 1752 | return $error; |
1753 | 1753 | } elseif ($globalDebug) echo "Done\n"; |
1754 | 1754 | if ($globalDebug) echo "Owner Chile: Download..."; |
1755 | - update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv'); |
|
1755 | + update_db::download('http://antonakis.co.uk/registers/Chile.txt', $tmp_dir.'owner_cc.csv'); |
|
1756 | 1756 | if (file_exists($tmp_dir.'owner_cc.csv')) { |
1757 | 1757 | if ($globalDebug) echo "Add to DB..."; |
1758 | - $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC'); |
|
1758 | + $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv', 'CC'); |
|
1759 | 1759 | } else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
1760 | 1760 | if ($error != '') { |
1761 | 1761 | return $error; |
1762 | 1762 | } elseif ($globalDebug) echo "Done\n"; |
1763 | 1763 | if ($globalDebug) echo "Owner Colombia: Download..."; |
1764 | - update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv'); |
|
1764 | + update_db::download('http://antonakis.co.uk/registers/Colombia.txt', $tmp_dir.'owner_hj.csv'); |
|
1765 | 1765 | if (file_exists($tmp_dir.'owner_hj.csv')) { |
1766 | 1766 | if ($globalDebug) echo "Add to DB..."; |
1767 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ'); |
|
1767 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv', 'HJ'); |
|
1768 | 1768 | } else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
1769 | 1769 | if ($error != '') { |
1770 | 1770 | return $error; |
1771 | 1771 | } elseif ($globalDebug) echo "Done\n"; |
1772 | 1772 | if ($globalDebug) echo "Owner Bosnia Herzegobina: Download..."; |
1773 | - update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv'); |
|
1773 | + update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt', $tmp_dir.'owner_e7.csv'); |
|
1774 | 1774 | if (file_exists($tmp_dir.'owner_e7.csv')) { |
1775 | 1775 | if ($globalDebug) echo "Add to DB..."; |
1776 | - $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7'); |
|
1776 | + $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv', 'E7'); |
|
1777 | 1777 | } else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
1778 | 1778 | if ($error != '') { |
1779 | 1779 | return $error; |
1780 | 1780 | } elseif ($globalDebug) echo "Done\n"; |
1781 | 1781 | if ($globalDebug) echo "Owner Brazil: Download..."; |
1782 | - update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv'); |
|
1782 | + update_db::download('http://antonakis.co.uk/registers/Brazil.txt', $tmp_dir.'owner_pp.csv'); |
|
1783 | 1783 | if (file_exists($tmp_dir.'owner_pp.csv')) { |
1784 | 1784 | if ($globalDebug) echo "Add to DB..."; |
1785 | - $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP'); |
|
1785 | + $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv', 'PP'); |
|
1786 | 1786 | } else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
1787 | 1787 | if ($error != '') { |
1788 | 1788 | return $error; |
1789 | 1789 | } elseif ($globalDebug) echo "Done\n"; |
1790 | 1790 | if ($globalDebug) echo "Owner Cayman Islands: Download..."; |
1791 | - update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv'); |
|
1791 | + update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt', $tmp_dir.'owner_vp.csv'); |
|
1792 | 1792 | if (file_exists($tmp_dir.'owner_vp.csv')) { |
1793 | 1793 | if ($globalDebug) echo "Add to DB..."; |
1794 | - $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP'); |
|
1794 | + $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv', 'VP'); |
|
1795 | 1795 | } else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
1796 | 1796 | if ($error != '') { |
1797 | 1797 | return $error; |
1798 | 1798 | } elseif ($globalDebug) echo "Done\n"; |
1799 | 1799 | if ($globalDebug) echo "Owner Croatia: Download..."; |
1800 | - update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv'); |
|
1800 | + update_db::download('http://antonakis.co.uk/registers/Croatia.txt', $tmp_dir.'owner_9a.csv'); |
|
1801 | 1801 | if (file_exists($tmp_dir.'owner_9a.csv')) { |
1802 | 1802 | if ($globalDebug) echo "Add to DB..."; |
1803 | - $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A'); |
|
1803 | + $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv', '9A'); |
|
1804 | 1804 | } else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
1805 | 1805 | if ($error != '') { |
1806 | 1806 | return $error; |
1807 | 1807 | } elseif ($globalDebug) echo "Done\n"; |
1808 | 1808 | if ($globalDebug) echo "Owner Luxembourg: Download..."; |
1809 | - update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv'); |
|
1809 | + update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt', $tmp_dir.'owner_lx.csv'); |
|
1810 | 1810 | if (file_exists($tmp_dir.'owner_lx.csv')) { |
1811 | 1811 | if ($globalDebug) echo "Add to DB..."; |
1812 | - $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX'); |
|
1812 | + $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv', 'LX'); |
|
1813 | 1813 | } else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
1814 | 1814 | if ($error != '') { |
1815 | 1815 | return $error; |
1816 | 1816 | } elseif ($globalDebug) echo "Done\n"; |
1817 | 1817 | if ($globalDebug) echo "Owner Maldives: Download..."; |
1818 | - update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv'); |
|
1818 | + update_db::download('http://antonakis.co.uk/registers/Maldives.txt', $tmp_dir.'owner_8q.csv'); |
|
1819 | 1819 | if (file_exists($tmp_dir.'owner_8q.csv')) { |
1820 | 1820 | if ($globalDebug) echo "Add to DB..."; |
1821 | - $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q'); |
|
1821 | + $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv', '8Q'); |
|
1822 | 1822 | } else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
1823 | 1823 | if ($error != '') { |
1824 | 1824 | return $error; |
1825 | 1825 | } elseif ($globalDebug) echo "Done\n"; |
1826 | 1826 | if ($globalDebug) echo "Owner New Zealand: Download..."; |
1827 | - update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv'); |
|
1827 | + update_db::download('http://antonakis.co.uk/registers/NewZealand.txt', $tmp_dir.'owner_zk.csv'); |
|
1828 | 1828 | if (file_exists($tmp_dir.'owner_zk.csv')) { |
1829 | 1829 | if ($globalDebug) echo "Add to DB..."; |
1830 | - $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK'); |
|
1830 | + $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv', 'ZK'); |
|
1831 | 1831 | } else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
1832 | 1832 | if ($error != '') { |
1833 | 1833 | return $error; |
1834 | 1834 | } elseif ($globalDebug) echo "Done\n"; |
1835 | 1835 | if ($globalDebug) echo "Owner Papua New Guinea: Download..."; |
1836 | - update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv'); |
|
1836 | + update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt', $tmp_dir.'owner_p2.csv'); |
|
1837 | 1837 | if (file_exists($tmp_dir.'owner_p2.csv')) { |
1838 | 1838 | if ($globalDebug) echo "Add to DB..."; |
1839 | - $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2'); |
|
1839 | + $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv', 'P2'); |
|
1840 | 1840 | } else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
1841 | 1841 | if ($error != '') { |
1842 | 1842 | return $error; |
1843 | 1843 | } elseif ($globalDebug) echo "Done\n"; |
1844 | 1844 | if ($globalDebug) echo "Owner Slovakia: Download..."; |
1845 | - update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv'); |
|
1845 | + update_db::download('http://antonakis.co.uk/registers/Slovakia.txt', $tmp_dir.'owner_om.csv'); |
|
1846 | 1846 | if (file_exists($tmp_dir.'owner_om.csv')) { |
1847 | 1847 | if ($globalDebug) echo "Add to DB..."; |
1848 | - $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM'); |
|
1848 | + $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv', 'OM'); |
|
1849 | 1849 | } else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
1850 | 1850 | if ($error != '') { |
1851 | 1851 | return $error; |
1852 | 1852 | } elseif ($globalDebug) echo "Done\n"; |
1853 | 1853 | if ($globalDebug) echo "Owner Ecuador: Download..."; |
1854 | - update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv'); |
|
1854 | + update_db::download('http://antonakis.co.uk/registers/Ecuador.txt', $tmp_dir.'owner_hc.csv'); |
|
1855 | 1855 | if (file_exists($tmp_dir.'owner_hc.csv')) { |
1856 | 1856 | if ($globalDebug) echo "Add to DB..."; |
1857 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC'); |
|
1857 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv', 'HC'); |
|
1858 | 1858 | } else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
1859 | 1859 | if ($error != '') { |
1860 | 1860 | return $error; |
1861 | 1861 | } elseif ($globalDebug) echo "Done\n"; |
1862 | 1862 | if ($globalDebug) echo "Owner Iceland: Download..."; |
1863 | - update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv'); |
|
1863 | + update_db::download('http://antonakis.co.uk/registers/Iceland.txt', $tmp_dir.'owner_tf.csv'); |
|
1864 | 1864 | if (file_exists($tmp_dir.'owner_tf.csv')) { |
1865 | 1865 | if ($globalDebug) echo "Add to DB..."; |
1866 | - $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF'); |
|
1866 | + $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv', 'TF'); |
|
1867 | 1867 | } else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
1868 | 1868 | if ($error != '') { |
1869 | 1869 | return $error; |
1870 | 1870 | } elseif ($globalDebug) echo "Done\n"; |
1871 | 1871 | if ($globalDebug) echo "Owner Isle of Man: Download..."; |
1872 | - update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv'); |
|
1872 | + update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt', $tmp_dir.'owner_m.csv'); |
|
1873 | 1873 | if (file_exists($tmp_dir.'owner_m.csv')) { |
1874 | 1874 | if ($globalDebug) echo "Add to DB..."; |
1875 | - $error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M'); |
|
1875 | + $error = update_db::retrieve_owner($tmp_dir.'owner_m.csv', 'M'); |
|
1876 | 1876 | } else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed."; |
1877 | 1877 | if ($error != '') { |
1878 | 1878 | return $error; |
1879 | 1879 | } elseif ($globalDebug) echo "Done\n"; |
1880 | 1880 | if ($globalMasterSource) { |
1881 | 1881 | if ($globalDebug) echo "ModeS Netherlands: Download..."; |
1882 | - update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv'); |
|
1882 | + update_db::download('http://antonakis.co.uk/registers/Netherlands.txt', $tmp_dir.'owner_ph.csv'); |
|
1883 | 1883 | if (file_exists($tmp_dir.'owner_ph.csv')) { |
1884 | 1884 | if ($globalDebug) echo "Add to DB..."; |
1885 | - $error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH'); |
|
1885 | + $error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv', 'PH'); |
|
1886 | 1886 | } else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed."; |
1887 | 1887 | if ($error != '') { |
1888 | 1888 | return $error; |
1889 | 1889 | } elseif ($globalDebug) echo "Done\n"; |
1890 | 1890 | if ($globalDebug) echo "ModeS Denmark: Download..."; |
1891 | - update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv'); |
|
1891 | + update_db::download('http://antonakis.co.uk/registers/Denmark.txt', $tmp_dir.'owner_oy.csv'); |
|
1892 | 1892 | if (file_exists($tmp_dir.'owner_oy.csv')) { |
1893 | 1893 | if ($globalDebug) echo "Add to DB..."; |
1894 | - $error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY'); |
|
1894 | + $error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv', 'OY'); |
|
1895 | 1895 | } else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed."; |
1896 | 1896 | if ($error != '') { |
1897 | 1897 | return $error; |
@@ -1904,7 +1904,7 @@ discard block |
||
1904 | 1904 | global $tmp_dir, $globalDebug; |
1905 | 1905 | $error = ''; |
1906 | 1906 | if ($globalDebug) echo "Translation : Download..."; |
1907 | - update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip'); |
|
1907 | + update_db::download('http://www.acarsd.org/download/translation.php', $tmp_dir.'translation.zip'); |
|
1908 | 1908 | if (file_exists($tmp_dir.'translation.zip')) { |
1909 | 1909 | if ($globalDebug) echo "Unzip..."; |
1910 | 1910 | update_db::unzip($tmp_dir.'translation.zip'); |
@@ -1920,7 +1920,7 @@ discard block |
||
1920 | 1920 | public static function update_translation_fam() { |
1921 | 1921 | global $tmp_dir, $globalDebug; |
1922 | 1922 | if ($globalDebug) echo "Translation from FlightAirMap website : Download..."; |
1923 | - update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz'); |
|
1923 | + update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz', $tmp_dir.'translation.tsv.gz'); |
|
1924 | 1924 | if (file_exists($tmp_dir.'translation.tsv.gz')) { |
1925 | 1925 | if ($globalDebug) echo "Gunzip..."; |
1926 | 1926 | update_db::gunzip($tmp_dir.'translation.tsv.gz'); |
@@ -1935,7 +1935,7 @@ discard block |
||
1935 | 1935 | public static function update_ModeS_fam() { |
1936 | 1936 | global $tmp_dir, $globalDebug; |
1937 | 1937 | if ($globalDebug) echo "ModeS from FlightAirMap website : Download..."; |
1938 | - update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz'); |
|
1938 | + update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz', $tmp_dir.'modes.tsv.gz'); |
|
1939 | 1939 | if (file_exists($tmp_dir.'modes.tsv.gz')) { |
1940 | 1940 | if ($globalDebug) echo "Gunzip..."; |
1941 | 1941 | update_db::gunzip($tmp_dir.'modes.tsv.gz'); |
@@ -1951,9 +1951,9 @@ discard block |
||
1951 | 1951 | global $tmp_dir, $globalDebug, $globalOwner; |
1952 | 1952 | if ($globalDebug) echo "owner from FlightAirMap website : Download..."; |
1953 | 1953 | if ($globalOwner === TRUE) { |
1954 | - update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz'); |
|
1954 | + update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz', $tmp_dir.'owners.tsv.gz'); |
|
1955 | 1955 | } else { |
1956 | - update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz',$tmp_dir.'owners.tsv.gz'); |
|
1956 | + update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz', $tmp_dir.'owners.tsv.gz'); |
|
1957 | 1957 | } |
1958 | 1958 | if (file_exists($tmp_dir.'owners.tsv.gz')) { |
1959 | 1959 | if ($globalDebug) echo "Gunzip..."; |
@@ -1969,7 +1969,7 @@ discard block |
||
1969 | 1969 | public static function update_routes_fam() { |
1970 | 1970 | global $tmp_dir, $globalDebug; |
1971 | 1971 | if ($globalDebug) echo "Routes from FlightAirMap website : Download..."; |
1972 | - update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz'); |
|
1972 | + update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz', $tmp_dir.'routes.tsv.gz'); |
|
1973 | 1973 | if (file_exists($tmp_dir.'routes.tsv.gz')) { |
1974 | 1974 | if ($globalDebug) echo "Gunzip..."; |
1975 | 1975 | update_db::gunzip($tmp_dir.'routes.tsv.gz'); |
@@ -1984,7 +1984,7 @@ discard block |
||
1984 | 1984 | public static function update_banned_fam() { |
1985 | 1985 | global $tmp_dir, $globalDebug; |
1986 | 1986 | if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download..."; |
1987 | - update_db::download('http://data.flightairmap.fr/data/ban_eu.csv',$tmp_dir.'ban_eu.csv'); |
|
1987 | + update_db::download('http://data.flightairmap.fr/data/ban_eu.csv', $tmp_dir.'ban_eu.csv'); |
|
1988 | 1988 | if (file_exists($tmp_dir.'ban_eu.csv')) { |
1989 | 1989 | //if ($globalDebug) echo "Gunzip..."; |
1990 | 1990 | //update_db::gunzip($tmp_dir.'ban_ue.csv'); |
@@ -2003,18 +2003,18 @@ discard block |
||
2003 | 2003 | $error = ''; |
2004 | 2004 | if ($globalDebug) echo "Airspace from FlightAirMap website : Download..."; |
2005 | 2005 | if ($globalDBdriver == 'mysql') { |
2006 | - update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); |
|
2006 | + update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5'); |
|
2007 | 2007 | } else { |
2008 | - update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); |
|
2008 | + update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5'); |
|
2009 | 2009 | } |
2010 | 2010 | if (file_exists($tmp_dir.'airspace.sql.gz.md5')) { |
2011 | - $airspace_md5_file = explode(' ',file_get_contents($tmp_dir.'airspace.sql.gz.md5')); |
|
2011 | + $airspace_md5_file = explode(' ', file_get_contents($tmp_dir.'airspace.sql.gz.md5')); |
|
2012 | 2012 | $airspace_md5 = $airspace_md5_file[0]; |
2013 | 2013 | if (!update_db::check_airspace_version($airspace_md5)) { |
2014 | 2014 | if ($globalDBdriver == 'mysql') { |
2015 | - update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz',$tmp_dir.'airspace.sql.gz'); |
|
2015 | + update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz', $tmp_dir.'airspace.sql.gz'); |
|
2016 | 2016 | } else { |
2017 | - update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz'); |
|
2017 | + update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz', $tmp_dir.'airspace.sql.gz'); |
|
2018 | 2018 | } |
2019 | 2019 | if (file_exists($tmp_dir.'airspace.sql.gz')) { |
2020 | 2020 | if ($globalDebug) echo "Gunzip..."; |
@@ -2026,7 +2026,7 @@ discard block |
||
2026 | 2026 | try { |
2027 | 2027 | $sth = $Connection->db->prepare($query); |
2028 | 2028 | $sth->execute(); |
2029 | - } catch(PDOException $e) { |
|
2029 | + } catch (PDOException $e) { |
|
2030 | 2030 | return "error : ".$e->getMessage(); |
2031 | 2031 | } |
2032 | 2032 | } |
@@ -2044,15 +2044,15 @@ discard block |
||
2044 | 2044 | public static function update_tle() { |
2045 | 2045 | global $tmp_dir, $globalDebug; |
2046 | 2046 | if ($globalDebug) echo "Download TLE : Download..."; |
2047 | - $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', |
|
2048 | - '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', |
|
2049 | - 'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt'); |
|
2047 | + $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', |
|
2048 | + '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', |
|
2049 | + 'engineering.txt', 'education.txt', 'military.txt', 'radar.txt', 'cubesat.txt', 'other.txt', 'tle-new.txt'); |
|
2050 | 2050 | foreach ($alltle as $filename) { |
2051 | 2051 | if ($globalDebug) echo "downloading ".$filename.'...'; |
2052 | - update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename); |
|
2052 | + update_db::download('http://celestrak.com/NORAD/elements/'.$filename, $tmp_dir.$filename); |
|
2053 | 2053 | if (file_exists($tmp_dir.$filename)) { |
2054 | 2054 | if ($globalDebug) echo "Add to DB ".$filename."..."; |
2055 | - $error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename)); |
|
2055 | + $error = update_db::tle($tmp_dir.$filename, str_replace('.txt', '', $filename)); |
|
2056 | 2056 | } else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
2057 | 2057 | if ($error != '') { |
2058 | 2058 | echo $error."\n"; |
@@ -2065,32 +2065,32 @@ discard block |
||
2065 | 2065 | global $tmp_dir, $globalDebug; |
2066 | 2066 | $error = ''; |
2067 | 2067 | if ($globalDebug) echo "Models from FlightAirMap website : Download..."; |
2068 | - update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum'); |
|
2068 | + update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', $tmp_dir.'models.md5sum'); |
|
2069 | 2069 | if (file_exists($tmp_dir.'models.md5sum')) { |
2070 | 2070 | if ($globalDebug) echo "Check files...\n"; |
2071 | 2071 | $newmodelsdb = array(); |
2072 | - if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) { |
|
2073 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
2072 | + if (($handle = fopen($tmp_dir.'models.md5sum', 'r')) !== FALSE) { |
|
2073 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
2074 | 2074 | $model = trim($row[2]); |
2075 | 2075 | $newmodelsdb[$model] = trim($row[0]); |
2076 | 2076 | } |
2077 | 2077 | } |
2078 | 2078 | $modelsdb = array(); |
2079 | 2079 | if (file_exists(dirname(__FILE__).'/../models/models.md5sum')) { |
2080 | - if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum','r')) !== FALSE) { |
|
2081 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
2080 | + if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum', 'r')) !== FALSE) { |
|
2081 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
2082 | 2082 | $model = trim($row[2]); |
2083 | 2083 | $modelsdb[$model] = trim($row[0]); |
2084 | 2084 | } |
2085 | 2085 | } |
2086 | 2086 | } |
2087 | - $diff = array_diff($newmodelsdb,$modelsdb); |
|
2087 | + $diff = array_diff($newmodelsdb, $modelsdb); |
|
2088 | 2088 | foreach ($diff as $key => $value) { |
2089 | 2089 | if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n"; |
2090 | - update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key); |
|
2090 | + update_db::download('http://data.flightairmap.fr/data/models/'.$key, dirname(__FILE__).'/../models/'.$key); |
|
2091 | 2091 | |
2092 | 2092 | } |
2093 | - update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum'); |
|
2093 | + update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', dirname(__FILE__).'/../models/models.md5sum'); |
|
2094 | 2094 | } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
2095 | 2095 | if ($error != '') { |
2096 | 2096 | return $error; |
@@ -2102,32 +2102,32 @@ discard block |
||
2102 | 2102 | global $tmp_dir, $globalDebug; |
2103 | 2103 | $error = ''; |
2104 | 2104 | if ($globalDebug) echo "Space models from FlightAirMap website : Download..."; |
2105 | - update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum'); |
|
2105 | + update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', $tmp_dir.'space_models.md5sum'); |
|
2106 | 2106 | if (file_exists($tmp_dir.'space_models.md5sum')) { |
2107 | 2107 | if ($globalDebug) echo "Check files...\n"; |
2108 | 2108 | $newmodelsdb = array(); |
2109 | - if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) { |
|
2110 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
2109 | + if (($handle = fopen($tmp_dir.'space_models.md5sum', 'r')) !== FALSE) { |
|
2110 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
2111 | 2111 | $model = trim($row[2]); |
2112 | 2112 | $newmodelsdb[$model] = trim($row[0]); |
2113 | 2113 | } |
2114 | 2114 | } |
2115 | 2115 | $modelsdb = array(); |
2116 | 2116 | if (file_exists(dirname(__FILE__).'/../models/space/space_models.md5sum')) { |
2117 | - if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum','r')) !== FALSE) { |
|
2118 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
2117 | + if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum', 'r')) !== FALSE) { |
|
2118 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
2119 | 2119 | $model = trim($row[2]); |
2120 | 2120 | $modelsdb[$model] = trim($row[0]); |
2121 | 2121 | } |
2122 | 2122 | } |
2123 | 2123 | } |
2124 | - $diff = array_diff($newmodelsdb,$modelsdb); |
|
2124 | + $diff = array_diff($newmodelsdb, $modelsdb); |
|
2125 | 2125 | foreach ($diff as $key => $value) { |
2126 | 2126 | if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n"; |
2127 | - update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key); |
|
2127 | + update_db::download('http://data.flightairmap.fr/data/models/space/'.$key, dirname(__FILE__).'/../models/space/'.$key); |
|
2128 | 2128 | |
2129 | 2129 | } |
2130 | - update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum'); |
|
2130 | + update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', dirname(__FILE__).'/../models/space/space_models.md5sum'); |
|
2131 | 2131 | } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
2132 | 2132 | if ($error != '') { |
2133 | 2133 | return $error; |
@@ -2139,32 +2139,32 @@ discard block |
||
2139 | 2139 | global $tmp_dir, $globalDebug; |
2140 | 2140 | $error = ''; |
2141 | 2141 | if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download..."; |
2142 | - update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum'); |
|
2142 | + update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum', $tmp_dir.'vehicules_models.md5sum'); |
|
2143 | 2143 | if (file_exists($tmp_dir.'vehicules_models.md5sum')) { |
2144 | 2144 | if ($globalDebug) echo "Check files...\n"; |
2145 | 2145 | $newmodelsdb = array(); |
2146 | - if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) { |
|
2147 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
2146 | + if (($handle = fopen($tmp_dir.'vehicules_models.md5sum', 'r')) !== FALSE) { |
|
2147 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
2148 | 2148 | $model = trim($row[2]); |
2149 | 2149 | $newmodelsdb[$model] = trim($row[0]); |
2150 | 2150 | } |
2151 | 2151 | } |
2152 | 2152 | $modelsdb = array(); |
2153 | 2153 | if (file_exists(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum')) { |
2154 | - if (($handle = fopen(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum','r')) !== FALSE) { |
|
2155 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
2154 | + if (($handle = fopen(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum', 'r')) !== FALSE) { |
|
2155 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
2156 | 2156 | $model = trim($row[2]); |
2157 | 2157 | $modelsdb[$model] = trim($row[0]); |
2158 | 2158 | } |
2159 | 2159 | } |
2160 | 2160 | } |
2161 | - $diff = array_diff($newmodelsdb,$modelsdb); |
|
2161 | + $diff = array_diff($newmodelsdb, $modelsdb); |
|
2162 | 2162 | foreach ($diff as $key => $value) { |
2163 | 2163 | if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n"; |
2164 | - update_db::download('http://data.flightairmap.fr/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key); |
|
2164 | + update_db::download('http://data.flightairmap.fr/data/models/vehicules/'.$key, dirname(__FILE__).'/../models/vehicules/'.$key); |
|
2165 | 2165 | |
2166 | 2166 | } |
2167 | - update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum'); |
|
2167 | + update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum', dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum'); |
|
2168 | 2168 | } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
2169 | 2169 | if ($error != '') { |
2170 | 2170 | return $error; |
@@ -2187,8 +2187,8 @@ discard block |
||
2187 | 2187 | */ |
2188 | 2188 | if (file_exists($tmp_dir.'aircrafts.html')) { |
2189 | 2189 | //var_dump(file_get_html($tmp_dir.'aircrafts.html')); |
2190 | - $fh = fopen($tmp_dir.'aircrafts.html',"r"); |
|
2191 | - $result = fread($fh,100000000); |
|
2190 | + $fh = fopen($tmp_dir.'aircrafts.html', "r"); |
|
2191 | + $result = fread($fh, 100000000); |
|
2192 | 2192 | //echo $result; |
2193 | 2193 | //var_dump(str_get_html($result)); |
2194 | 2194 | //print_r(self::table2array($result)); |
@@ -2206,23 +2206,23 @@ discard block |
||
2206 | 2206 | $Connection = new Connection(); |
2207 | 2207 | $sth = $Connection->db->prepare($query); |
2208 | 2208 | $sth->execute(); |
2209 | - } catch(PDOException $e) { |
|
2209 | + } catch (PDOException $e) { |
|
2210 | 2210 | return "error : ".$e->getMessage(); |
2211 | 2211 | } |
2212 | 2212 | |
2213 | 2213 | $error = ''; |
2214 | 2214 | if ($globalDebug) echo "Notam : Download..."; |
2215 | - update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss'); |
|
2215 | + update_db::download($globalNOTAMSource, $tmp_dir.'notam.rss'); |
|
2216 | 2216 | if (file_exists($tmp_dir.'notam.rss')) { |
2217 | - $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true); |
|
2217 | + $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')), true); |
|
2218 | 2218 | foreach ($notams['channel']['item'] as $notam) { |
2219 | - $title = explode(':',$notam['title']); |
|
2219 | + $title = explode(':', $notam['title']); |
|
2220 | 2220 | $data['ref'] = trim($title[0]); |
2221 | 2221 | unset($title[0]); |
2222 | - $data['title'] = trim(implode(':',$title)); |
|
2223 | - $description = strip_tags($notam['description'],'<pre>'); |
|
2224 | - preg_match(':^(.*?)<pre>:',$description,$match); |
|
2225 | - $q = explode('/',$match[1]); |
|
2222 | + $data['title'] = trim(implode(':', $title)); |
|
2223 | + $description = strip_tags($notam['description'], '<pre>'); |
|
2224 | + preg_match(':^(.*?)<pre>:', $description, $match); |
|
2225 | + $q = explode('/', $match[1]); |
|
2226 | 2226 | $data['fir'] = $q[0]; |
2227 | 2227 | $data['code'] = $q[1]; |
2228 | 2228 | $ifrvfr = $q[2]; |
@@ -2238,30 +2238,30 @@ discard block |
||
2238 | 2238 | $data['lower_limit'] = $q[5]; |
2239 | 2239 | $data['upper_limit'] = $q[6]; |
2240 | 2240 | $latlonrad = $q[7]; |
2241 | - sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius); |
|
2242 | - $latitude = $Common->convertDec($las,'latitude'); |
|
2243 | - $longitude = $Common->convertDec($lns,'longitude'); |
|
2241 | + sscanf($latlonrad, '%4c%c%5c%c%3d', $las, $lac, $lns, $lnc, $radius); |
|
2242 | + $latitude = $Common->convertDec($las, 'latitude'); |
|
2243 | + $longitude = $Common->convertDec($lns, 'longitude'); |
|
2244 | 2244 | if ($lac == 'S') $latitude = '-'.$latitude; |
2245 | 2245 | if ($lnc == 'W') $longitude = '-'.$longitude; |
2246 | 2246 | $data['center_latitude'] = $latitude; |
2247 | 2247 | $data['center_longitude'] = $longitude; |
2248 | 2248 | $data['radius'] = intval($radius); |
2249 | 2249 | |
2250 | - preg_match(':<pre>(.*?)</pre>:',$description,$match); |
|
2250 | + preg_match(':<pre>(.*?)</pre>:', $description, $match); |
|
2251 | 2251 | $data['text'] = $match[1]; |
2252 | - preg_match(':</pre>(.*?)$:',$description,$match); |
|
2252 | + preg_match(':</pre>(.*?)$:', $description, $match); |
|
2253 | 2253 | $fromto = $match[1]; |
2254 | - preg_match('#FROM:(.*?)TO:#',$fromto,$match); |
|
2254 | + preg_match('#FROM:(.*?)TO:#', $fromto, $match); |
|
2255 | 2255 | $fromall = trim($match[1]); |
2256 | - preg_match('#^(.*?) \((.*?)\)$#',$fromall,$match); |
|
2256 | + preg_match('#^(.*?) \((.*?)\)$#', $fromall, $match); |
|
2257 | 2257 | $from = trim($match[1]); |
2258 | - $data['date_begin'] = date("Y-m-d H:i:s",strtotime($from)); |
|
2259 | - preg_match('#TO:(.*?)$#',$fromto,$match); |
|
2258 | + $data['date_begin'] = date("Y-m-d H:i:s", strtotime($from)); |
|
2259 | + preg_match('#TO:(.*?)$#', $fromto, $match); |
|
2260 | 2260 | $toall = trim($match[1]); |
2261 | - if (!preg_match(':Permanent:',$toall)) { |
|
2262 | - preg_match('#^(.*?) \((.*?)\)#',$toall,$match); |
|
2261 | + if (!preg_match(':Permanent:', $toall)) { |
|
2262 | + preg_match('#^(.*?) \((.*?)\)#', $toall, $match); |
|
2263 | 2263 | $to = trim($match[1]); |
2264 | - $data['date_end'] = date("Y-m-d H:i:s",strtotime($to)); |
|
2264 | + $data['date_end'] = date("Y-m-d H:i:s", strtotime($to)); |
|
2265 | 2265 | $data['permanent'] = 0; |
2266 | 2266 | } else { |
2267 | 2267 | $data['date_end'] = NULL; |
@@ -2269,7 +2269,7 @@ discard block |
||
2269 | 2269 | } |
2270 | 2270 | $data['full_notam'] = $notam['title'].'<br>'.$notam['description']; |
2271 | 2271 | $NOTAM = new NOTAM(); |
2272 | - $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']); |
|
2272 | + $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']); |
|
2273 | 2273 | unset($data); |
2274 | 2274 | } |
2275 | 2275 | } else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
@@ -2292,16 +2292,16 @@ 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 | } |
2299 | 2299 | $Common = new Common(); |
2300 | 2300 | $airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json'); |
2301 | - $airspace_json = json_decode($airspace_lst,true); |
|
2301 | + $airspace_json = json_decode($airspace_lst, true); |
|
2302 | 2302 | foreach ($airspace_json['records'] as $airspace) { |
2303 | 2303 | if ($globalDebug) echo $airspace['name']."...\n"; |
2304 | - update_db::download($airspace['uri'],$tmp_dir.$airspace['name']); |
|
2304 | + update_db::download($airspace['uri'], $tmp_dir.$airspace['name']); |
|
2305 | 2305 | if (file_exists($tmp_dir.$airspace['name'])) { |
2306 | 2306 | file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name']))); |
2307 | 2307 | //system('recode l9..utf8 '.$tmp_dir.$airspace['name']); |
@@ -2323,7 +2323,7 @@ discard block |
||
2323 | 2323 | $Connection = new Connection(); |
2324 | 2324 | $sth = $Connection->db->prepare($query); |
2325 | 2325 | $sth->execute(array(':new' => $new, ':old' => $old)); |
2326 | - } catch(PDOException $e) { |
|
2326 | + } catch (PDOException $e) { |
|
2327 | 2327 | return "error : ".$e->getMessage(); |
2328 | 2328 | } |
2329 | 2329 | } |
@@ -2340,7 +2340,7 @@ discard block |
||
2340 | 2340 | $Connection = new Connection(); |
2341 | 2341 | $sth = $Connection->db->prepare($query); |
2342 | 2342 | $sth->execute(); |
2343 | - } catch(PDOException $e) { |
|
2343 | + } catch (PDOException $e) { |
|
2344 | 2344 | return "error : ".$e->getMessage(); |
2345 | 2345 | } |
2346 | 2346 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2355,7 +2355,7 @@ discard block |
||
2355 | 2355 | $Connection = new Connection(); |
2356 | 2356 | $sth = $Connection->db->prepare($query); |
2357 | 2357 | $sth->execute(); |
2358 | - } catch(PDOException $e) { |
|
2358 | + } catch (PDOException $e) { |
|
2359 | 2359 | return "error : ".$e->getMessage(); |
2360 | 2360 | } |
2361 | 2361 | } |
@@ -2366,7 +2366,7 @@ discard block |
||
2366 | 2366 | $Connection = new Connection(); |
2367 | 2367 | $sth = $Connection->db->prepare($query); |
2368 | 2368 | $sth->execute(array(':version' => $version)); |
2369 | - } catch(PDOException $e) { |
|
2369 | + } catch (PDOException $e) { |
|
2370 | 2370 | return "error : ".$e->getMessage(); |
2371 | 2371 | } |
2372 | 2372 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2382,7 +2382,7 @@ discard block |
||
2382 | 2382 | $Connection = new Connection(); |
2383 | 2383 | $sth = $Connection->db->prepare($query); |
2384 | 2384 | $sth->execute(array(':version' => $version)); |
2385 | - } catch(PDOException $e) { |
|
2385 | + } catch (PDOException $e) { |
|
2386 | 2386 | return "error : ".$e->getMessage(); |
2387 | 2387 | } |
2388 | 2388 | } |
@@ -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 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -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 | } |
@@ -2459,7 +2459,7 @@ discard block |
||
2459 | 2459 | $Connection = new Connection(); |
2460 | 2460 | $sth = $Connection->db->prepare($query); |
2461 | 2461 | $sth->execute(); |
2462 | - } catch(PDOException $e) { |
|
2462 | + } catch (PDOException $e) { |
|
2463 | 2463 | return "error : ".$e->getMessage(); |
2464 | 2464 | } |
2465 | 2465 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2474,7 +2474,7 @@ discard block |
||
2474 | 2474 | $Connection = new Connection(); |
2475 | 2475 | $sth = $Connection->db->prepare($query); |
2476 | 2476 | $sth->execute(); |
2477 | - } catch(PDOException $e) { |
|
2477 | + } catch (PDOException $e) { |
|
2478 | 2478 | return "error : ".$e->getMessage(); |
2479 | 2479 | } |
2480 | 2480 | } |
@@ -2489,7 +2489,7 @@ discard block |
||
2489 | 2489 | $Connection = new Connection(); |
2490 | 2490 | $sth = $Connection->db->prepare($query); |
2491 | 2491 | $sth->execute(); |
2492 | - } catch(PDOException $e) { |
|
2492 | + } catch (PDOException $e) { |
|
2493 | 2493 | return "error : ".$e->getMessage(); |
2494 | 2494 | } |
2495 | 2495 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2504,7 +2504,7 @@ discard block |
||
2504 | 2504 | $Connection = new Connection(); |
2505 | 2505 | $sth = $Connection->db->prepare($query); |
2506 | 2506 | $sth->execute(); |
2507 | - } catch(PDOException $e) { |
|
2507 | + } catch (PDOException $e) { |
|
2508 | 2508 | return "error : ".$e->getMessage(); |
2509 | 2509 | } |
2510 | 2510 | } |
@@ -2519,7 +2519,7 @@ discard block |
||
2519 | 2519 | $Connection = new Connection(); |
2520 | 2520 | $sth = $Connection->db->prepare($query); |
2521 | 2521 | $sth->execute(); |
2522 | - } catch(PDOException $e) { |
|
2522 | + } catch (PDOException $e) { |
|
2523 | 2523 | return "error : ".$e->getMessage(); |
2524 | 2524 | } |
2525 | 2525 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2534,7 +2534,7 @@ discard block |
||
2534 | 2534 | $Connection = new Connection(); |
2535 | 2535 | $sth = $Connection->db->prepare($query); |
2536 | 2536 | $sth->execute(); |
2537 | - } catch(PDOException $e) { |
|
2537 | + } catch (PDOException $e) { |
|
2538 | 2538 | return "error : ".$e->getMessage(); |
2539 | 2539 | } |
2540 | 2540 | } |
@@ -2549,7 +2549,7 @@ discard block |
||
2549 | 2549 | $Connection = new Connection(); |
2550 | 2550 | $sth = $Connection->db->prepare($query); |
2551 | 2551 | $sth->execute(); |
2552 | - } catch(PDOException $e) { |
|
2552 | + } catch (PDOException $e) { |
|
2553 | 2553 | return "error : ".$e->getMessage(); |
2554 | 2554 | } |
2555 | 2555 | } |
@@ -2564,7 +2564,7 @@ discard block |
||
2564 | 2564 | $Connection = new Connection(); |
2565 | 2565 | $sth = $Connection->db->prepare($query); |
2566 | 2566 | $sth->execute(); |
2567 | - } catch(PDOException $e) { |
|
2567 | + } catch (PDOException $e) { |
|
2568 | 2568 | return "error : ".$e->getMessage(); |
2569 | 2569 | } |
2570 | 2570 | } |
@@ -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 | } |
@@ -417,7 +480,9 @@ discard block |
||
417 | 480 | $sth_dest = $Connection->db->prepare($query_dest); |
418 | 481 | $sth_modes = $Connection->db->prepare($query_modes); |
419 | 482 | try { |
420 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
483 | + if ($globalTransaction) { |
|
484 | + $Connection->db->beginTransaction(); |
|
485 | + } |
|
421 | 486 | $tmp = fgetcsv($fh,9999,',','"'); |
422 | 487 | while (!feof($fh)) { |
423 | 488 | $line = fgetcsv($fh,9999,',','"'); |
@@ -427,16 +492,22 @@ discard block |
||
427 | 492 | $values['registration'] = $line[0]; |
428 | 493 | $values['base'] = $line[4]; |
429 | 494 | $values['owner'] = $line[5]; |
430 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
431 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
495 | + if ($line[6] == '') { |
|
496 | + $values['date_first_reg'] = null; |
|
497 | + } else { |
|
498 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
499 | + } |
|
432 | 500 | $values['cancel'] = $line[7]; |
433 | 501 | } elseif ($country == 'EI') { |
434 | 502 | // TODO : add modeS & reg to aircraft_modes |
435 | 503 | $values['registration'] = $line[0]; |
436 | 504 | $values['base'] = $line[3]; |
437 | 505 | $values['owner'] = $line[2]; |
438 | - if ($line[1] == '') $values['date_first_reg'] = null; |
|
439 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
506 | + if ($line[1] == '') { |
|
507 | + $values['date_first_reg'] = null; |
|
508 | + } else { |
|
509 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
510 | + } |
|
440 | 511 | $values['cancel'] = ''; |
441 | 512 | $values['modes'] = $line[7]; |
442 | 513 | $values['icao'] = $line[8]; |
@@ -455,16 +526,22 @@ discard block |
||
455 | 526 | $values['registration'] = $line[3]; |
456 | 527 | $values['base'] = null; |
457 | 528 | $values['owner'] = $line[5]; |
458 | - if ($line[18] == '') $values['date_first_reg'] = null; |
|
459 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
529 | + if ($line[18] == '') { |
|
530 | + $values['date_first_reg'] = null; |
|
531 | + } else { |
|
532 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
533 | + } |
|
460 | 534 | $values['cancel'] = ''; |
461 | 535 | } elseif ($country == 'VH') { |
462 | 536 | // TODO : add modeS & reg to aircraft_modes |
463 | 537 | $values['registration'] = $line[0]; |
464 | 538 | $values['base'] = null; |
465 | 539 | $values['owner'] = $line[12]; |
466 | - if ($line[28] == '') $values['date_first_reg'] = null; |
|
467 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
540 | + if ($line[28] == '') { |
|
541 | + $values['date_first_reg'] = null; |
|
542 | + } else { |
|
543 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
544 | + } |
|
468 | 545 | |
469 | 546 | $values['cancel'] = $line[39]; |
470 | 547 | } elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { |
@@ -483,29 +560,41 @@ discard block |
||
483 | 560 | $values['registration'] = $line[0]; |
484 | 561 | $values['base'] = null; |
485 | 562 | $values['owner'] = $line[8]; |
486 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
487 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
563 | + if ($line[7] == '') { |
|
564 | + $values['date_first_reg'] = null; |
|
565 | + } else { |
|
566 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
567 | + } |
|
488 | 568 | $values['cancel'] = ''; |
489 | 569 | } elseif ($country == 'PP') { |
490 | 570 | $values['registration'] = $line[0]; |
491 | 571 | $values['base'] = null; |
492 | 572 | $values['owner'] = $line[4]; |
493 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
494 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
573 | + if ($line[6] == '') { |
|
574 | + $values['date_first_reg'] = null; |
|
575 | + } else { |
|
576 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
577 | + } |
|
495 | 578 | $values['cancel'] = $line[7]; |
496 | 579 | } elseif ($country == 'E7') { |
497 | 580 | $values['registration'] = $line[0]; |
498 | 581 | $values['base'] = null; |
499 | 582 | $values['owner'] = $line[4]; |
500 | - if ($line[5] == '') $values['date_first_reg'] = null; |
|
501 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
583 | + if ($line[5] == '') { |
|
584 | + $values['date_first_reg'] = null; |
|
585 | + } else { |
|
586 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
587 | + } |
|
502 | 588 | $values['cancel'] = ''; |
503 | 589 | } elseif ($country == '8Q') { |
504 | 590 | $values['registration'] = $line[0]; |
505 | 591 | $values['base'] = null; |
506 | 592 | $values['owner'] = $line[3]; |
507 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
508 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
593 | + if ($line[7] == '') { |
|
594 | + $values['date_first_reg'] = null; |
|
595 | + } else { |
|
596 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
597 | + } |
|
509 | 598 | $values['cancel'] = ''; |
510 | 599 | } elseif ($country == 'ZK') { |
511 | 600 | $values['registration'] = $line[0]; |
@@ -550,7 +639,9 @@ discard block |
||
550 | 639 | $sth_modes->execute($query_modes_values); |
551 | 640 | } |
552 | 641 | } |
553 | - if ($globalTransaction) $Connection->db->commit(); |
|
642 | + if ($globalTransaction) { |
|
643 | + $Connection->db->commit(); |
|
644 | + } |
|
554 | 645 | } catch(PDOException $e) { |
555 | 646 | return "error : ".$e->getMessage(); |
556 | 647 | } |
@@ -684,25 +775,45 @@ discard block |
||
684 | 775 | VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)"; |
685 | 776 | $Connection = new Connection(); |
686 | 777 | $sth_dest = $Connection->db->prepare($query_dest); |
687 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
778 | + if ($globalTransaction) { |
|
779 | + $Connection->db->beginTransaction(); |
|
780 | + } |
|
688 | 781 | |
689 | 782 | $i = 0; |
690 | 783 | while($row = sparql_fetch_array($result)) |
691 | 784 | { |
692 | 785 | if ($i >= 1) { |
693 | 786 | //print_r($row); |
694 | - if (!isset($row['iata'])) $row['iata'] = ''; |
|
695 | - if (!isset($row['icao'])) $row['icao'] = ''; |
|
696 | - if (!isset($row['type'])) $row['type'] = ''; |
|
697 | - if (!isset($row['altitude'])) $row['altitude'] = ''; |
|
787 | + if (!isset($row['iata'])) { |
|
788 | + $row['iata'] = ''; |
|
789 | + } |
|
790 | + if (!isset($row['icao'])) { |
|
791 | + $row['icao'] = ''; |
|
792 | + } |
|
793 | + if (!isset($row['type'])) { |
|
794 | + $row['type'] = ''; |
|
795 | + } |
|
796 | + if (!isset($row['altitude'])) { |
|
797 | + $row['altitude'] = ''; |
|
798 | + } |
|
698 | 799 | if (isset($row['city_bis'])) { |
699 | 800 | $row['city'] = $row['city_bis']; |
700 | 801 | } |
701 | - if (!isset($row['city'])) $row['city'] = ''; |
|
702 | - if (!isset($row['country'])) $row['country'] = ''; |
|
703 | - if (!isset($row['homepage'])) $row['homepage'] = ''; |
|
704 | - if (!isset($row['wikipedia_page'])) $row['wikipedia_page'] = ''; |
|
705 | - if (!isset($row['name'])) continue; |
|
802 | + if (!isset($row['city'])) { |
|
803 | + $row['city'] = ''; |
|
804 | + } |
|
805 | + if (!isset($row['country'])) { |
|
806 | + $row['country'] = ''; |
|
807 | + } |
|
808 | + if (!isset($row['homepage'])) { |
|
809 | + $row['homepage'] = ''; |
|
810 | + } |
|
811 | + if (!isset($row['wikipedia_page'])) { |
|
812 | + $row['wikipedia_page'] = ''; |
|
813 | + } |
|
814 | + if (!isset($row['name'])) { |
|
815 | + continue; |
|
816 | + } |
|
706 | 817 | if (!isset($row['image'])) { |
707 | 818 | $row['image'] = ''; |
708 | 819 | $row['image_thumb'] = ''; |
@@ -738,7 +849,9 @@ discard block |
||
738 | 849 | |
739 | 850 | $i++; |
740 | 851 | } |
741 | - if ($globalTransaction) $Connection->db->commit(); |
|
852 | + if ($globalTransaction) { |
|
853 | + $Connection->db->commit(); |
|
854 | + } |
|
742 | 855 | echo "Delete duplicate rows...\n"; |
743 | 856 | $query = 'ALTER IGNORE TABLE airport ADD UNIQUE INDEX icaoidx (icao)'; |
744 | 857 | try { |
@@ -750,7 +863,9 @@ discard block |
||
750 | 863 | } |
751 | 864 | |
752 | 865 | |
753 | - if ($globalDebug) echo "Insert Not available Airport...\n"; |
|
866 | + if ($globalDebug) { |
|
867 | + echo "Insert Not available Airport...\n"; |
|
868 | + } |
|
754 | 869 | $query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image`,`image_thumb`) |
755 | 870 | VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image, :image_thumb)"; |
756 | 871 | $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' => ''); |
@@ -777,7 +892,9 @@ discard block |
||
777 | 892 | $delimiter = ','; |
778 | 893 | $out_file = $tmp_dir.'airports.csv'; |
779 | 894 | update_db::download('http://ourairports.com/data/airports.csv',$out_file); |
780 | - if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
|
895 | + if (!file_exists($out_file) || !is_readable($out_file)) { |
|
896 | + return FALSE; |
|
897 | + } |
|
781 | 898 | echo "Add data from ourairports.com...\n"; |
782 | 899 | |
783 | 900 | $header = NULL; |
@@ -787,8 +904,9 @@ discard block |
||
787 | 904 | //$Connection->db->beginTransaction(); |
788 | 905 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
789 | 906 | { |
790 | - if(!$header) $header = $row; |
|
791 | - else { |
|
907 | + if(!$header) { |
|
908 | + $header = $row; |
|
909 | + } else { |
|
792 | 910 | $data = array(); |
793 | 911 | $data = array_combine($header, $row); |
794 | 912 | try { |
@@ -826,7 +944,9 @@ discard block |
||
826 | 944 | echo "Download data from another free database...\n"; |
827 | 945 | $out_file = $tmp_dir.'GlobalAirportDatabase.zip'; |
828 | 946 | update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file); |
829 | - if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
|
947 | + if (!file_exists($out_file) || !is_readable($out_file)) { |
|
948 | + return FALSE; |
|
949 | + } |
|
830 | 950 | update_db::unzip($out_file); |
831 | 951 | $header = NULL; |
832 | 952 | echo "Add data from another free database...\n"; |
@@ -837,8 +957,9 @@ discard block |
||
837 | 957 | //$Connection->db->beginTransaction(); |
838 | 958 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
839 | 959 | { |
840 | - if(!$header) $header = $row; |
|
841 | - else { |
|
960 | + if(!$header) { |
|
961 | + $header = $row; |
|
962 | + } else { |
|
842 | 963 | $data = $row; |
843 | 964 | |
844 | 965 | $query = 'UPDATE airport SET `city` = :city, `country` = :country WHERE icao = :icao'; |
@@ -1014,7 +1135,9 @@ discard block |
||
1014 | 1135 | if (($handle = fopen($tmp_dir.'MASTER.txt', 'r')) !== FALSE) |
1015 | 1136 | { |
1016 | 1137 | $i = 0; |
1017 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1138 | + if ($globalTransaction) { |
|
1139 | + $Connection->db->beginTransaction(); |
|
1140 | + } |
|
1018 | 1141 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1019 | 1142 | { |
1020 | 1143 | if ($i > 0) { |
@@ -1027,7 +1150,9 @@ discard block |
||
1027 | 1150 | } |
1028 | 1151 | $result_search = $sths->fetchAll(PDO::FETCH_ASSOC); |
1029 | 1152 | if (!empty($result_search)) { |
1030 | - if ($globalDebug) echo '.'; |
|
1153 | + if ($globalDebug) { |
|
1154 | + echo '.'; |
|
1155 | + } |
|
1031 | 1156 | //if ($globalDBdriver == 'mysql') { |
1032 | 1157 | // $queryi = 'INSERT INTO faamfr (mfr,icao) VALUES (:mfr,:icao) ON DUPLICATE KEY UPDATE icao = :icao'; |
1033 | 1158 | //} else { |
@@ -1049,8 +1174,12 @@ discard block |
||
1049 | 1174 | } |
1050 | 1175 | $result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC); |
1051 | 1176 | if (!empty($result_search_mfr)) { |
1052 | - if (trim($data[16]) == '' && trim($data[23]) != '') $data[16] = $data[23]; |
|
1053 | - if (trim($data[16]) == '' && trim($data[15]) != '') $data[16] = $data[15]; |
|
1177 | + if (trim($data[16]) == '' && trim($data[23]) != '') { |
|
1178 | + $data[16] = $data[23]; |
|
1179 | + } |
|
1180 | + if (trim($data[16]) == '' && trim($data[15]) != '') { |
|
1181 | + $data[16] = $data[15]; |
|
1182 | + } |
|
1054 | 1183 | $queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)'; |
1055 | 1184 | try { |
1056 | 1185 | $sthf = $Connection->db->prepare($queryf); |
@@ -1061,7 +1190,9 @@ discard block |
||
1061 | 1190 | } |
1062 | 1191 | } |
1063 | 1192 | if (strtotime($data[29]) > time()) { |
1064 | - if ($globalDebug) echo 'i'; |
|
1193 | + if ($globalDebug) { |
|
1194 | + echo 'i'; |
|
1195 | + } |
|
1065 | 1196 | $query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)'; |
1066 | 1197 | try { |
1067 | 1198 | $sth = $Connection->db->prepare($query); |
@@ -1072,13 +1203,19 @@ discard block |
||
1072 | 1203 | } |
1073 | 1204 | } |
1074 | 1205 | if ($i % 90 == 0) { |
1075 | - if ($globalTransaction) $Connection->db->commit(); |
|
1076 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1206 | + if ($globalTransaction) { |
|
1207 | + $Connection->db->commit(); |
|
1208 | + } |
|
1209 | + if ($globalTransaction) { |
|
1210 | + $Connection->db->beginTransaction(); |
|
1211 | + } |
|
1077 | 1212 | } |
1078 | 1213 | $i++; |
1079 | 1214 | } |
1080 | 1215 | fclose($handle); |
1081 | - if ($globalTransaction) $Connection->db->commit(); |
|
1216 | + if ($globalTransaction) { |
|
1217 | + $Connection->db->commit(); |
|
1218 | + } |
|
1082 | 1219 | } |
1083 | 1220 | print_r($mfr); |
1084 | 1221 | return ''; |
@@ -1103,11 +1240,15 @@ discard block |
||
1103 | 1240 | $i = 0; |
1104 | 1241 | //$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE); |
1105 | 1242 | //$Connection->db->beginTransaction(); |
1106 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1243 | + if ($globalTransaction) { |
|
1244 | + $Connection->db->beginTransaction(); |
|
1245 | + } |
|
1107 | 1246 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1108 | 1247 | { |
1109 | 1248 | if ($i > 0) { |
1110 | - if ($data[1] == 'NULL') $data[1] = $data[0]; |
|
1249 | + if ($data[1] == 'NULL') { |
|
1250 | + $data[1] = $data[0]; |
|
1251 | + } |
|
1111 | 1252 | $query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)'; |
1112 | 1253 | try { |
1113 | 1254 | $sth = $Connection->db->prepare($query); |
@@ -1119,7 +1260,9 @@ discard block |
||
1119 | 1260 | $i++; |
1120 | 1261 | } |
1121 | 1262 | fclose($handle); |
1122 | - if ($globalTransaction) $Connection->db->commit(); |
|
1263 | + if ($globalTransaction) { |
|
1264 | + $Connection->db->commit(); |
|
1265 | + } |
|
1123 | 1266 | } |
1124 | 1267 | return ''; |
1125 | 1268 | } |
@@ -1140,7 +1283,9 @@ discard block |
||
1140 | 1283 | if (($handle = fopen($tmp_dir.'owners.tsv', 'r')) !== FALSE) |
1141 | 1284 | { |
1142 | 1285 | $i = 0; |
1143 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1286 | + if ($globalTransaction) { |
|
1287 | + $Connection->db->beginTransaction(); |
|
1288 | + } |
|
1144 | 1289 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1145 | 1290 | { |
1146 | 1291 | if ($i > 0) { |
@@ -1156,7 +1301,9 @@ discard block |
||
1156 | 1301 | $i++; |
1157 | 1302 | } |
1158 | 1303 | fclose($handle); |
1159 | - if ($globalTransaction) $Connection->db->commit(); |
|
1304 | + if ($globalTransaction) { |
|
1305 | + $Connection->db->commit(); |
|
1306 | + } |
|
1160 | 1307 | } |
1161 | 1308 | return ''; |
1162 | 1309 | } |
@@ -1181,7 +1328,9 @@ discard block |
||
1181 | 1328 | $i = 0; |
1182 | 1329 | //$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE); |
1183 | 1330 | //$Connection->db->beginTransaction(); |
1184 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1331 | + if ($globalTransaction) { |
|
1332 | + $Connection->db->beginTransaction(); |
|
1333 | + } |
|
1185 | 1334 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1186 | 1335 | { |
1187 | 1336 | if ($i > 0) { |
@@ -1196,7 +1345,9 @@ discard block |
||
1196 | 1345 | $i++; |
1197 | 1346 | } |
1198 | 1347 | fclose($handle); |
1199 | - if ($globalTransaction) $Connection->db->commit(); |
|
1348 | + if ($globalTransaction) { |
|
1349 | + $Connection->db->commit(); |
|
1350 | + } |
|
1200 | 1351 | } |
1201 | 1352 | return ''; |
1202 | 1353 | } |
@@ -1215,7 +1366,9 @@ discard block |
||
1215 | 1366 | $Connection = new Connection(); |
1216 | 1367 | if (($handle = fopen($tmp_dir.'ban_eu.csv', 'r')) !== FALSE) |
1217 | 1368 | { |
1218 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1369 | + if ($globalTransaction) { |
|
1370 | + $Connection->db->beginTransaction(); |
|
1371 | + } |
|
1219 | 1372 | while (($data = fgetcsv($handle, 1000)) !== FALSE) |
1220 | 1373 | { |
1221 | 1374 | $query = 'UPDATE airlines SET ban_eu = 1 WHERE icao = :icao AND forsource IS NULL'; |
@@ -1230,7 +1383,9 @@ discard block |
||
1230 | 1383 | } |
1231 | 1384 | } |
1232 | 1385 | fclose($handle); |
1233 | - if ($globalTransaction) $Connection->db->commit(); |
|
1386 | + if ($globalTransaction) { |
|
1387 | + $Connection->db->commit(); |
|
1388 | + } |
|
1234 | 1389 | } |
1235 | 1390 | return ''; |
1236 | 1391 | } |
@@ -1381,7 +1536,9 @@ discard block |
||
1381 | 1536 | if (($handle = fopen($filename, 'r')) !== FALSE) |
1382 | 1537 | { |
1383 | 1538 | $i = 0; |
1384 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1539 | + if ($globalTransaction) { |
|
1540 | + $Connection->db->beginTransaction(); |
|
1541 | + } |
|
1385 | 1542 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1386 | 1543 | { |
1387 | 1544 | $i++; |
@@ -1409,7 +1566,9 @@ discard block |
||
1409 | 1566 | } |
1410 | 1567 | } |
1411 | 1568 | fclose($handle); |
1412 | - if ($globalTransaction) $Connection->db->commit(); |
|
1569 | + if ($globalTransaction) { |
|
1570 | + $Connection->db->commit(); |
|
1571 | + } |
|
1413 | 1572 | } |
1414 | 1573 | return ''; |
1415 | 1574 | } |
@@ -1432,7 +1591,9 @@ discard block |
||
1432 | 1591 | $Connection = new Connection(); |
1433 | 1592 | if (($handle = fopen($filename, 'r')) !== FALSE) |
1434 | 1593 | { |
1435 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1594 | + if ($globalTransaction) { |
|
1595 | + $Connection->db->beginTransaction(); |
|
1596 | + } |
|
1436 | 1597 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1437 | 1598 | { |
1438 | 1599 | if(count($row) > 1) { |
@@ -1446,7 +1607,9 @@ discard block |
||
1446 | 1607 | } |
1447 | 1608 | } |
1448 | 1609 | fclose($handle); |
1449 | - if ($globalTransaction) $Connection->db->commit(); |
|
1610 | + if ($globalTransaction) { |
|
1611 | + $Connection->db->commit(); |
|
1612 | + } |
|
1450 | 1613 | } |
1451 | 1614 | return ''; |
1452 | 1615 | } |
@@ -1466,8 +1629,9 @@ discard block |
||
1466 | 1629 | } |
1467 | 1630 | |
1468 | 1631 | |
1469 | - if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
1470 | - else { |
|
1632 | + if ($globalDBdriver == 'mysql') { |
|
1633 | + update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
1634 | + } else { |
|
1471 | 1635 | update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
1472 | 1636 | $query = "CREATE EXTENSION postgis"; |
1473 | 1637 | $Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']); |
@@ -1486,20 +1650,30 @@ discard block |
||
1486 | 1650 | global $tmp_dir, $globalDebug; |
1487 | 1651 | include_once('class.create_db.php'); |
1488 | 1652 | require_once(dirname(__FILE__).'/../require/class.NOTAM.php'); |
1489 | - if ($globalDebug) echo "NOTAM from FlightAirMap website : Download..."; |
|
1653 | + if ($globalDebug) { |
|
1654 | + echo "NOTAM from FlightAirMap website : Download..."; |
|
1655 | + } |
|
1490 | 1656 | update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz'); |
1491 | 1657 | $error = ''; |
1492 | 1658 | if (file_exists($tmp_dir.'notam.txt.gz')) { |
1493 | - if ($globalDebug) echo "Gunzip..."; |
|
1659 | + if ($globalDebug) { |
|
1660 | + echo "Gunzip..."; |
|
1661 | + } |
|
1494 | 1662 | update_db::gunzip($tmp_dir.'notam.txt.gz'); |
1495 | - if ($globalDebug) echo "Add to DB..."; |
|
1663 | + if ($globalDebug) { |
|
1664 | + echo "Add to DB..."; |
|
1665 | + } |
|
1496 | 1666 | //$error = create_db::import_file($tmp_dir.'notam.sql'); |
1497 | 1667 | $NOTAM = new NOTAM(); |
1498 | 1668 | $NOTAM->updateNOTAMfromTextFile($tmp_dir.'notam.txt'); |
1499 | - } else $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed."; |
|
1669 | + } else { |
|
1670 | + $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed."; |
|
1671 | + } |
|
1500 | 1672 | if ($error != '') { |
1501 | 1673 | return $error; |
1502 | - } elseif ($globalDebug) echo "Done\n"; |
|
1674 | + } elseif ($globalDebug) { |
|
1675 | + echo "Done\n"; |
|
1676 | + } |
|
1503 | 1677 | return ''; |
1504 | 1678 | } |
1505 | 1679 | |
@@ -1553,67 +1727,111 @@ discard block |
||
1553 | 1727 | //if ($globalDebug) echo "IVAO : Download..."; |
1554 | 1728 | //update_db::download('http://fr.mirror.ivao.aero/software/ivae_feb2013.zip',$tmp_dir.'ivae_feb2013.zip'); |
1555 | 1729 | if (file_exists($tmp_dir.'ivae_feb2013.zip')) { |
1556 | - if ($globalDebug) echo "Unzip..."; |
|
1730 | + if ($globalDebug) { |
|
1731 | + echo "Unzip..."; |
|
1732 | + } |
|
1557 | 1733 | update_db::unzip($tmp_dir.'ivae_feb2013.zip'); |
1558 | - if ($globalDebug) echo "Add to DB..."; |
|
1734 | + if ($globalDebug) { |
|
1735 | + echo "Add to DB..."; |
|
1736 | + } |
|
1559 | 1737 | update_db::ivao_airlines($tmp_dir.'data/airlines.dat'); |
1560 | - if ($globalDebug) echo "Copy airlines logos to airlines images directory..."; |
|
1738 | + if ($globalDebug) { |
|
1739 | + echo "Copy airlines logos to airlines images directory..."; |
|
1740 | + } |
|
1561 | 1741 | if (is_writable(dirname(__FILE__).'/../images/airlines')) { |
1562 | - if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
1563 | - } else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
|
1564 | - } else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
|
1742 | + if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) { |
|
1743 | + $error = "Failed to copy airlines logo."; |
|
1744 | + } |
|
1745 | + } else { |
|
1746 | + $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
|
1747 | + } |
|
1748 | + } else { |
|
1749 | + $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
|
1750 | + } |
|
1565 | 1751 | if ($error != '') { |
1566 | 1752 | return $error; |
1567 | - } elseif ($globalDebug) echo "Done\n"; |
|
1753 | + } elseif ($globalDebug) { |
|
1754 | + echo "Done\n"; |
|
1755 | + } |
|
1568 | 1756 | return ''; |
1569 | 1757 | } |
1570 | 1758 | |
1571 | 1759 | public static function update_routes() { |
1572 | 1760 | global $tmp_dir, $globalDebug; |
1573 | 1761 | $error = ''; |
1574 | - if ($globalDebug) echo "Routes : Download..."; |
|
1762 | + if ($globalDebug) { |
|
1763 | + echo "Routes : Download..."; |
|
1764 | + } |
|
1575 | 1765 | update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz'); |
1576 | 1766 | if (file_exists($tmp_dir.'StandingData.sqb.gz')) { |
1577 | - if ($globalDebug) echo "Gunzip..."; |
|
1767 | + if ($globalDebug) { |
|
1768 | + echo "Gunzip..."; |
|
1769 | + } |
|
1578 | 1770 | update_db::gunzip($tmp_dir.'StandingData.sqb.gz'); |
1579 | - if ($globalDebug) echo "Add to DB..."; |
|
1771 | + if ($globalDebug) { |
|
1772 | + echo "Add to DB..."; |
|
1773 | + } |
|
1580 | 1774 | $error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb'); |
1581 | - } else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed."; |
|
1775 | + } else { |
|
1776 | + $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed."; |
|
1777 | + } |
|
1582 | 1778 | if ($error != '') { |
1583 | 1779 | return $error; |
1584 | - } elseif ($globalDebug) echo "Done\n"; |
|
1780 | + } elseif ($globalDebug) { |
|
1781 | + echo "Done\n"; |
|
1782 | + } |
|
1585 | 1783 | return ''; |
1586 | 1784 | } |
1587 | 1785 | public static function update_oneworld() { |
1588 | 1786 | global $tmp_dir, $globalDebug; |
1589 | 1787 | $error = ''; |
1590 | - if ($globalDebug) echo "Schedules Oneworld : Download..."; |
|
1788 | + if ($globalDebug) { |
|
1789 | + echo "Schedules Oneworld : Download..."; |
|
1790 | + } |
|
1591 | 1791 | update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz'); |
1592 | 1792 | if (file_exists($tmp_dir.'oneworld.csv.gz')) { |
1593 | - if ($globalDebug) echo "Gunzip..."; |
|
1793 | + if ($globalDebug) { |
|
1794 | + echo "Gunzip..."; |
|
1795 | + } |
|
1594 | 1796 | update_db::gunzip($tmp_dir.'oneworld.csv.gz'); |
1595 | - if ($globalDebug) echo "Add to DB..."; |
|
1797 | + if ($globalDebug) { |
|
1798 | + echo "Add to DB..."; |
|
1799 | + } |
|
1596 | 1800 | $error = update_db::retrieve_route_oneworld($tmp_dir.'oneworld.csv'); |
1597 | - } else $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed."; |
|
1801 | + } else { |
|
1802 | + $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed."; |
|
1803 | + } |
|
1598 | 1804 | if ($error != '') { |
1599 | 1805 | return $error; |
1600 | - } elseif ($globalDebug) echo "Done\n"; |
|
1806 | + } elseif ($globalDebug) { |
|
1807 | + echo "Done\n"; |
|
1808 | + } |
|
1601 | 1809 | return ''; |
1602 | 1810 | } |
1603 | 1811 | public static function update_skyteam() { |
1604 | 1812 | global $tmp_dir, $globalDebug; |
1605 | 1813 | $error = ''; |
1606 | - if ($globalDebug) echo "Schedules Skyteam : Download..."; |
|
1814 | + if ($globalDebug) { |
|
1815 | + echo "Schedules Skyteam : Download..."; |
|
1816 | + } |
|
1607 | 1817 | update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz'); |
1608 | 1818 | if (file_exists($tmp_dir.'skyteam.csv.gz')) { |
1609 | - if ($globalDebug) echo "Gunzip..."; |
|
1819 | + if ($globalDebug) { |
|
1820 | + echo "Gunzip..."; |
|
1821 | + } |
|
1610 | 1822 | update_db::gunzip($tmp_dir.'skyteam.csv.gz'); |
1611 | - if ($globalDebug) echo "Add to DB..."; |
|
1823 | + if ($globalDebug) { |
|
1824 | + echo "Add to DB..."; |
|
1825 | + } |
|
1612 | 1826 | $error = update_db::retrieve_route_skyteam($tmp_dir.'skyteam.csv'); |
1613 | - } else $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed."; |
|
1827 | + } else { |
|
1828 | + $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed."; |
|
1829 | + } |
|
1614 | 1830 | if ($error != '') { |
1615 | 1831 | return $error; |
1616 | - } elseif ($globalDebug) echo "Done\n"; |
|
1832 | + } elseif ($globalDebug) { |
|
1833 | + echo "Done\n"; |
|
1834 | + } |
|
1617 | 1835 | return ''; |
1618 | 1836 | } |
1619 | 1837 | public static function update_ModeS() { |
@@ -1630,370 +1848,642 @@ discard block |
||
1630 | 1848 | exit; |
1631 | 1849 | } elseif ($globalDebug) echo "Done\n"; |
1632 | 1850 | */ |
1633 | - if ($globalDebug) echo "Modes : Download..."; |
|
1634 | -// update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
|
1851 | + if ($globalDebug) { |
|
1852 | + echo "Modes : Download..."; |
|
1853 | + } |
|
1854 | + // update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
|
1635 | 1855 | update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz'); |
1636 | 1856 | |
1637 | 1857 | // if (file_exists($tmp_dir.'basestation_latest.zip')) { |
1638 | 1858 | if (file_exists($tmp_dir.'BaseStation.sqb.gz')) { |
1639 | - if ($globalDebug) echo "Unzip..."; |
|
1640 | -// update_db::unzip($tmp_dir.'basestation_latest.zip'); |
|
1859 | + if ($globalDebug) { |
|
1860 | + echo "Unzip..."; |
|
1861 | + } |
|
1862 | + // update_db::unzip($tmp_dir.'basestation_latest.zip'); |
|
1641 | 1863 | update_db::gunzip($tmp_dir.'BaseStation.sqb.gz'); |
1642 | - if ($globalDebug) echo "Add to DB..."; |
|
1864 | + if ($globalDebug) { |
|
1865 | + echo "Add to DB..."; |
|
1866 | + } |
|
1643 | 1867 | $error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb'); |
1644 | 1868 | // $error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'basestation.sqb'); |
1645 | - } else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed."; |
|
1869 | + } else { |
|
1870 | + $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed."; |
|
1871 | + } |
|
1646 | 1872 | if ($error != '') { |
1647 | 1873 | return $error; |
1648 | - } elseif ($globalDebug) echo "Done\n"; |
|
1874 | + } elseif ($globalDebug) { |
|
1875 | + echo "Done\n"; |
|
1876 | + } |
|
1649 | 1877 | return ''; |
1650 | 1878 | } |
1651 | 1879 | |
1652 | 1880 | public static function update_ModeS_faa() { |
1653 | 1881 | global $tmp_dir, $globalDebug; |
1654 | - if ($globalDebug) echo "Modes FAA: Download..."; |
|
1882 | + if ($globalDebug) { |
|
1883 | + echo "Modes FAA: Download..."; |
|
1884 | + } |
|
1655 | 1885 | update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip'); |
1656 | 1886 | if (file_exists($tmp_dir.'ReleasableAircraft.zip')) { |
1657 | - if ($globalDebug) echo "Unzip..."; |
|
1887 | + if ($globalDebug) { |
|
1888 | + echo "Unzip..."; |
|
1889 | + } |
|
1658 | 1890 | update_db::unzip($tmp_dir.'ReleasableAircraft.zip'); |
1659 | - if ($globalDebug) echo "Add to DB..."; |
|
1891 | + if ($globalDebug) { |
|
1892 | + echo "Add to DB..."; |
|
1893 | + } |
|
1660 | 1894 | $error = update_db::modes_faa(); |
1661 | - } else $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed."; |
|
1895 | + } else { |
|
1896 | + $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed."; |
|
1897 | + } |
|
1662 | 1898 | if ($error != '') { |
1663 | 1899 | return $error; |
1664 | - } elseif ($globalDebug) echo "Done\n"; |
|
1900 | + } elseif ($globalDebug) { |
|
1901 | + echo "Done\n"; |
|
1902 | + } |
|
1665 | 1903 | return ''; |
1666 | 1904 | } |
1667 | 1905 | |
1668 | 1906 | public static function update_ModeS_flarm() { |
1669 | 1907 | global $tmp_dir, $globalDebug; |
1670 | - if ($globalDebug) echo "Modes Flarmnet: Download..."; |
|
1908 | + if ($globalDebug) { |
|
1909 | + echo "Modes Flarmnet: Download..."; |
|
1910 | + } |
|
1671 | 1911 | update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln'); |
1672 | 1912 | if (file_exists($tmp_dir.'data.fln')) { |
1673 | - if ($globalDebug) echo "Add to DB..."; |
|
1913 | + if ($globalDebug) { |
|
1914 | + echo "Add to DB..."; |
|
1915 | + } |
|
1674 | 1916 | $error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln'); |
1675 | - } else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed."; |
|
1917 | + } else { |
|
1918 | + $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed."; |
|
1919 | + } |
|
1676 | 1920 | if ($error != '') { |
1677 | 1921 | return $error; |
1678 | - } elseif ($globalDebug) echo "Done\n"; |
|
1922 | + } elseif ($globalDebug) { |
|
1923 | + echo "Done\n"; |
|
1924 | + } |
|
1679 | 1925 | return ''; |
1680 | 1926 | } |
1681 | 1927 | |
1682 | 1928 | public static function update_ModeS_ogn() { |
1683 | 1929 | global $tmp_dir, $globalDebug; |
1684 | - if ($globalDebug) echo "Modes OGN: Download..."; |
|
1930 | + if ($globalDebug) { |
|
1931 | + echo "Modes OGN: Download..."; |
|
1932 | + } |
|
1685 | 1933 | update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv'); |
1686 | 1934 | if (file_exists($tmp_dir.'ogn.csv')) { |
1687 | - if ($globalDebug) echo "Add to DB..."; |
|
1935 | + if ($globalDebug) { |
|
1936 | + echo "Add to DB..."; |
|
1937 | + } |
|
1688 | 1938 | $error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv'); |
1689 | - } else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed."; |
|
1939 | + } else { |
|
1940 | + $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed."; |
|
1941 | + } |
|
1690 | 1942 | if ($error != '') { |
1691 | 1943 | return $error; |
1692 | - } elseif ($globalDebug) echo "Done\n"; |
|
1944 | + } elseif ($globalDebug) { |
|
1945 | + echo "Done\n"; |
|
1946 | + } |
|
1693 | 1947 | return ''; |
1694 | 1948 | } |
1695 | 1949 | |
1696 | 1950 | public static function update_owner() { |
1697 | 1951 | global $tmp_dir, $globalDebug, $globalMasterSource; |
1698 | 1952 | |
1699 | - if ($globalDebug) echo "Owner France: Download..."; |
|
1953 | + if ($globalDebug) { |
|
1954 | + echo "Owner France: Download..."; |
|
1955 | + } |
|
1700 | 1956 | update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv'); |
1701 | 1957 | if (file_exists($tmp_dir.'owner_f.csv')) { |
1702 | - if ($globalDebug) echo "Add to DB..."; |
|
1958 | + if ($globalDebug) { |
|
1959 | + echo "Add to DB..."; |
|
1960 | + } |
|
1703 | 1961 | $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F'); |
1704 | - } else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
|
1962 | + } else { |
|
1963 | + $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
|
1964 | + } |
|
1705 | 1965 | if ($error != '') { |
1706 | 1966 | return $error; |
1707 | - } elseif ($globalDebug) echo "Done\n"; |
|
1967 | + } elseif ($globalDebug) { |
|
1968 | + echo "Done\n"; |
|
1969 | + } |
|
1708 | 1970 | |
1709 | - if ($globalDebug) echo "Owner Ireland: Download..."; |
|
1971 | + if ($globalDebug) { |
|
1972 | + echo "Owner Ireland: Download..."; |
|
1973 | + } |
|
1710 | 1974 | update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv'); |
1711 | 1975 | if (file_exists($tmp_dir.'owner_ei.csv')) { |
1712 | - if ($globalDebug) echo "Add to DB..."; |
|
1976 | + if ($globalDebug) { |
|
1977 | + echo "Add to DB..."; |
|
1978 | + } |
|
1713 | 1979 | $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI'); |
1714 | - } else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
|
1980 | + } else { |
|
1981 | + $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
|
1982 | + } |
|
1715 | 1983 | if ($error != '') { |
1716 | 1984 | return $error; |
1717 | - } elseif ($globalDebug) echo "Done\n"; |
|
1718 | - if ($globalDebug) echo "Owner Switzerland: Download..."; |
|
1985 | + } elseif ($globalDebug) { |
|
1986 | + echo "Done\n"; |
|
1987 | + } |
|
1988 | + if ($globalDebug) { |
|
1989 | + echo "Owner Switzerland: Download..."; |
|
1990 | + } |
|
1719 | 1991 | update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv'); |
1720 | 1992 | if (file_exists($tmp_dir.'owner_hb.csv')) { |
1721 | - if ($globalDebug) echo "Add to DB..."; |
|
1993 | + if ($globalDebug) { |
|
1994 | + echo "Add to DB..."; |
|
1995 | + } |
|
1722 | 1996 | $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB'); |
1723 | - } else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
|
1997 | + } else { |
|
1998 | + $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
|
1999 | + } |
|
1724 | 2000 | if ($error != '') { |
1725 | 2001 | return $error; |
1726 | - } elseif ($globalDebug) echo "Done\n"; |
|
1727 | - if ($globalDebug) echo "Owner Czech Republic: Download..."; |
|
2002 | + } elseif ($globalDebug) { |
|
2003 | + echo "Done\n"; |
|
2004 | + } |
|
2005 | + if ($globalDebug) { |
|
2006 | + echo "Owner Czech Republic: Download..."; |
|
2007 | + } |
|
1728 | 2008 | update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv'); |
1729 | 2009 | if (file_exists($tmp_dir.'owner_ok.csv')) { |
1730 | - if ($globalDebug) echo "Add to DB..."; |
|
2010 | + if ($globalDebug) { |
|
2011 | + echo "Add to DB..."; |
|
2012 | + } |
|
1731 | 2013 | $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK'); |
1732 | - } else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
|
2014 | + } else { |
|
2015 | + $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
|
2016 | + } |
|
1733 | 2017 | if ($error != '') { |
1734 | 2018 | return $error; |
1735 | - } elseif ($globalDebug) echo "Done\n"; |
|
1736 | - if ($globalDebug) echo "Owner Australia: Download..."; |
|
2019 | + } elseif ($globalDebug) { |
|
2020 | + echo "Done\n"; |
|
2021 | + } |
|
2022 | + if ($globalDebug) { |
|
2023 | + echo "Owner Australia: Download..."; |
|
2024 | + } |
|
1737 | 2025 | update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv'); |
1738 | 2026 | if (file_exists($tmp_dir.'owner_vh.csv')) { |
1739 | - if ($globalDebug) echo "Add to DB..."; |
|
2027 | + if ($globalDebug) { |
|
2028 | + echo "Add to DB..."; |
|
2029 | + } |
|
1740 | 2030 | $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH'); |
1741 | - } else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
|
2031 | + } else { |
|
2032 | + $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
|
2033 | + } |
|
1742 | 2034 | if ($error != '') { |
1743 | 2035 | return $error; |
1744 | - } elseif ($globalDebug) echo "Done\n"; |
|
1745 | - if ($globalDebug) echo "Owner Austria: Download..."; |
|
2036 | + } elseif ($globalDebug) { |
|
2037 | + echo "Done\n"; |
|
2038 | + } |
|
2039 | + if ($globalDebug) { |
|
2040 | + echo "Owner Austria: Download..."; |
|
2041 | + } |
|
1746 | 2042 | update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv'); |
1747 | 2043 | if (file_exists($tmp_dir.'owner_oe.csv')) { |
1748 | - if ($globalDebug) echo "Add to DB..."; |
|
2044 | + if ($globalDebug) { |
|
2045 | + echo "Add to DB..."; |
|
2046 | + } |
|
1749 | 2047 | $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE'); |
1750 | - } else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
|
2048 | + } else { |
|
2049 | + $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
|
2050 | + } |
|
1751 | 2051 | if ($error != '') { |
1752 | 2052 | return $error; |
1753 | - } elseif ($globalDebug) echo "Done\n"; |
|
1754 | - if ($globalDebug) echo "Owner Chile: Download..."; |
|
2053 | + } elseif ($globalDebug) { |
|
2054 | + echo "Done\n"; |
|
2055 | + } |
|
2056 | + if ($globalDebug) { |
|
2057 | + echo "Owner Chile: Download..."; |
|
2058 | + } |
|
1755 | 2059 | update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv'); |
1756 | 2060 | if (file_exists($tmp_dir.'owner_cc.csv')) { |
1757 | - if ($globalDebug) echo "Add to DB..."; |
|
2061 | + if ($globalDebug) { |
|
2062 | + echo "Add to DB..."; |
|
2063 | + } |
|
1758 | 2064 | $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC'); |
1759 | - } else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
|
2065 | + } else { |
|
2066 | + $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
|
2067 | + } |
|
1760 | 2068 | if ($error != '') { |
1761 | 2069 | return $error; |
1762 | - } elseif ($globalDebug) echo "Done\n"; |
|
1763 | - if ($globalDebug) echo "Owner Colombia: Download..."; |
|
2070 | + } elseif ($globalDebug) { |
|
2071 | + echo "Done\n"; |
|
2072 | + } |
|
2073 | + if ($globalDebug) { |
|
2074 | + echo "Owner Colombia: Download..."; |
|
2075 | + } |
|
1764 | 2076 | update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv'); |
1765 | 2077 | if (file_exists($tmp_dir.'owner_hj.csv')) { |
1766 | - if ($globalDebug) echo "Add to DB..."; |
|
2078 | + if ($globalDebug) { |
|
2079 | + echo "Add to DB..."; |
|
2080 | + } |
|
1767 | 2081 | $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ'); |
1768 | - } else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
|
2082 | + } else { |
|
2083 | + $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
|
2084 | + } |
|
1769 | 2085 | if ($error != '') { |
1770 | 2086 | return $error; |
1771 | - } elseif ($globalDebug) echo "Done\n"; |
|
1772 | - if ($globalDebug) echo "Owner Bosnia Herzegobina: Download..."; |
|
2087 | + } elseif ($globalDebug) { |
|
2088 | + echo "Done\n"; |
|
2089 | + } |
|
2090 | + if ($globalDebug) { |
|
2091 | + echo "Owner Bosnia Herzegobina: Download..."; |
|
2092 | + } |
|
1773 | 2093 | update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv'); |
1774 | 2094 | if (file_exists($tmp_dir.'owner_e7.csv')) { |
1775 | - if ($globalDebug) echo "Add to DB..."; |
|
2095 | + if ($globalDebug) { |
|
2096 | + echo "Add to DB..."; |
|
2097 | + } |
|
1776 | 2098 | $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7'); |
1777 | - } else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
|
2099 | + } else { |
|
2100 | + $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
|
2101 | + } |
|
1778 | 2102 | if ($error != '') { |
1779 | 2103 | return $error; |
1780 | - } elseif ($globalDebug) echo "Done\n"; |
|
1781 | - if ($globalDebug) echo "Owner Brazil: Download..."; |
|
2104 | + } elseif ($globalDebug) { |
|
2105 | + echo "Done\n"; |
|
2106 | + } |
|
2107 | + if ($globalDebug) { |
|
2108 | + echo "Owner Brazil: Download..."; |
|
2109 | + } |
|
1782 | 2110 | update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv'); |
1783 | 2111 | if (file_exists($tmp_dir.'owner_pp.csv')) { |
1784 | - if ($globalDebug) echo "Add to DB..."; |
|
2112 | + if ($globalDebug) { |
|
2113 | + echo "Add to DB..."; |
|
2114 | + } |
|
1785 | 2115 | $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP'); |
1786 | - } else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
|
2116 | + } else { |
|
2117 | + $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
|
2118 | + } |
|
1787 | 2119 | if ($error != '') { |
1788 | 2120 | return $error; |
1789 | - } elseif ($globalDebug) echo "Done\n"; |
|
1790 | - if ($globalDebug) echo "Owner Cayman Islands: Download..."; |
|
2121 | + } elseif ($globalDebug) { |
|
2122 | + echo "Done\n"; |
|
2123 | + } |
|
2124 | + if ($globalDebug) { |
|
2125 | + echo "Owner Cayman Islands: Download..."; |
|
2126 | + } |
|
1791 | 2127 | update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv'); |
1792 | 2128 | if (file_exists($tmp_dir.'owner_vp.csv')) { |
1793 | - if ($globalDebug) echo "Add to DB..."; |
|
2129 | + if ($globalDebug) { |
|
2130 | + echo "Add to DB..."; |
|
2131 | + } |
|
1794 | 2132 | $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP'); |
1795 | - } else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
|
2133 | + } else { |
|
2134 | + $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
|
2135 | + } |
|
1796 | 2136 | if ($error != '') { |
1797 | 2137 | return $error; |
1798 | - } elseif ($globalDebug) echo "Done\n"; |
|
1799 | - if ($globalDebug) echo "Owner Croatia: Download..."; |
|
2138 | + } elseif ($globalDebug) { |
|
2139 | + echo "Done\n"; |
|
2140 | + } |
|
2141 | + if ($globalDebug) { |
|
2142 | + echo "Owner Croatia: Download..."; |
|
2143 | + } |
|
1800 | 2144 | update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv'); |
1801 | 2145 | if (file_exists($tmp_dir.'owner_9a.csv')) { |
1802 | - if ($globalDebug) echo "Add to DB..."; |
|
2146 | + if ($globalDebug) { |
|
2147 | + echo "Add to DB..."; |
|
2148 | + } |
|
1803 | 2149 | $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A'); |
1804 | - } else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
|
2150 | + } else { |
|
2151 | + $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
|
2152 | + } |
|
1805 | 2153 | if ($error != '') { |
1806 | 2154 | return $error; |
1807 | - } elseif ($globalDebug) echo "Done\n"; |
|
1808 | - if ($globalDebug) echo "Owner Luxembourg: Download..."; |
|
2155 | + } elseif ($globalDebug) { |
|
2156 | + echo "Done\n"; |
|
2157 | + } |
|
2158 | + if ($globalDebug) { |
|
2159 | + echo "Owner Luxembourg: Download..."; |
|
2160 | + } |
|
1809 | 2161 | update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv'); |
1810 | 2162 | if (file_exists($tmp_dir.'owner_lx.csv')) { |
1811 | - if ($globalDebug) echo "Add to DB..."; |
|
2163 | + if ($globalDebug) { |
|
2164 | + echo "Add to DB..."; |
|
2165 | + } |
|
1812 | 2166 | $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX'); |
1813 | - } else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
|
2167 | + } else { |
|
2168 | + $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
|
2169 | + } |
|
1814 | 2170 | if ($error != '') { |
1815 | 2171 | return $error; |
1816 | - } elseif ($globalDebug) echo "Done\n"; |
|
1817 | - if ($globalDebug) echo "Owner Maldives: Download..."; |
|
2172 | + } elseif ($globalDebug) { |
|
2173 | + echo "Done\n"; |
|
2174 | + } |
|
2175 | + if ($globalDebug) { |
|
2176 | + echo "Owner Maldives: Download..."; |
|
2177 | + } |
|
1818 | 2178 | update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv'); |
1819 | 2179 | if (file_exists($tmp_dir.'owner_8q.csv')) { |
1820 | - if ($globalDebug) echo "Add to DB..."; |
|
2180 | + if ($globalDebug) { |
|
2181 | + echo "Add to DB..."; |
|
2182 | + } |
|
1821 | 2183 | $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q'); |
1822 | - } else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
|
2184 | + } else { |
|
2185 | + $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
|
2186 | + } |
|
1823 | 2187 | if ($error != '') { |
1824 | 2188 | return $error; |
1825 | - } elseif ($globalDebug) echo "Done\n"; |
|
1826 | - if ($globalDebug) echo "Owner New Zealand: Download..."; |
|
2189 | + } elseif ($globalDebug) { |
|
2190 | + echo "Done\n"; |
|
2191 | + } |
|
2192 | + if ($globalDebug) { |
|
2193 | + echo "Owner New Zealand: Download..."; |
|
2194 | + } |
|
1827 | 2195 | update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv'); |
1828 | 2196 | if (file_exists($tmp_dir.'owner_zk.csv')) { |
1829 | - if ($globalDebug) echo "Add to DB..."; |
|
2197 | + if ($globalDebug) { |
|
2198 | + echo "Add to DB..."; |
|
2199 | + } |
|
1830 | 2200 | $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK'); |
1831 | - } else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
|
2201 | + } else { |
|
2202 | + $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
|
2203 | + } |
|
1832 | 2204 | if ($error != '') { |
1833 | 2205 | return $error; |
1834 | - } elseif ($globalDebug) echo "Done\n"; |
|
1835 | - if ($globalDebug) echo "Owner Papua New Guinea: Download..."; |
|
2206 | + } elseif ($globalDebug) { |
|
2207 | + echo "Done\n"; |
|
2208 | + } |
|
2209 | + if ($globalDebug) { |
|
2210 | + echo "Owner Papua New Guinea: Download..."; |
|
2211 | + } |
|
1836 | 2212 | update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv'); |
1837 | 2213 | if (file_exists($tmp_dir.'owner_p2.csv')) { |
1838 | - if ($globalDebug) echo "Add to DB..."; |
|
2214 | + if ($globalDebug) { |
|
2215 | + echo "Add to DB..."; |
|
2216 | + } |
|
1839 | 2217 | $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2'); |
1840 | - } else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
|
2218 | + } else { |
|
2219 | + $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
|
2220 | + } |
|
1841 | 2221 | if ($error != '') { |
1842 | 2222 | return $error; |
1843 | - } elseif ($globalDebug) echo "Done\n"; |
|
1844 | - if ($globalDebug) echo "Owner Slovakia: Download..."; |
|
2223 | + } elseif ($globalDebug) { |
|
2224 | + echo "Done\n"; |
|
2225 | + } |
|
2226 | + if ($globalDebug) { |
|
2227 | + echo "Owner Slovakia: Download..."; |
|
2228 | + } |
|
1845 | 2229 | update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv'); |
1846 | 2230 | if (file_exists($tmp_dir.'owner_om.csv')) { |
1847 | - if ($globalDebug) echo "Add to DB..."; |
|
2231 | + if ($globalDebug) { |
|
2232 | + echo "Add to DB..."; |
|
2233 | + } |
|
1848 | 2234 | $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM'); |
1849 | - } else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
|
2235 | + } else { |
|
2236 | + $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
|
2237 | + } |
|
1850 | 2238 | if ($error != '') { |
1851 | 2239 | return $error; |
1852 | - } elseif ($globalDebug) echo "Done\n"; |
|
1853 | - if ($globalDebug) echo "Owner Ecuador: Download..."; |
|
2240 | + } elseif ($globalDebug) { |
|
2241 | + echo "Done\n"; |
|
2242 | + } |
|
2243 | + if ($globalDebug) { |
|
2244 | + echo "Owner Ecuador: Download..."; |
|
2245 | + } |
|
1854 | 2246 | update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv'); |
1855 | 2247 | if (file_exists($tmp_dir.'owner_hc.csv')) { |
1856 | - if ($globalDebug) echo "Add to DB..."; |
|
2248 | + if ($globalDebug) { |
|
2249 | + echo "Add to DB..."; |
|
2250 | + } |
|
1857 | 2251 | $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC'); |
1858 | - } else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
|
2252 | + } else { |
|
2253 | + $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
|
2254 | + } |
|
1859 | 2255 | if ($error != '') { |
1860 | 2256 | return $error; |
1861 | - } elseif ($globalDebug) echo "Done\n"; |
|
1862 | - if ($globalDebug) echo "Owner Iceland: Download..."; |
|
2257 | + } elseif ($globalDebug) { |
|
2258 | + echo "Done\n"; |
|
2259 | + } |
|
2260 | + if ($globalDebug) { |
|
2261 | + echo "Owner Iceland: Download..."; |
|
2262 | + } |
|
1863 | 2263 | update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv'); |
1864 | 2264 | if (file_exists($tmp_dir.'owner_tf.csv')) { |
1865 | - if ($globalDebug) echo "Add to DB..."; |
|
2265 | + if ($globalDebug) { |
|
2266 | + echo "Add to DB..."; |
|
2267 | + } |
|
1866 | 2268 | $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF'); |
1867 | - } else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
|
2269 | + } else { |
|
2270 | + $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
|
2271 | + } |
|
1868 | 2272 | if ($error != '') { |
1869 | 2273 | return $error; |
1870 | - } elseif ($globalDebug) echo "Done\n"; |
|
1871 | - if ($globalDebug) echo "Owner Isle of Man: Download..."; |
|
2274 | + } elseif ($globalDebug) { |
|
2275 | + echo "Done\n"; |
|
2276 | + } |
|
2277 | + if ($globalDebug) { |
|
2278 | + echo "Owner Isle of Man: Download..."; |
|
2279 | + } |
|
1872 | 2280 | update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv'); |
1873 | 2281 | if (file_exists($tmp_dir.'owner_m.csv')) { |
1874 | - if ($globalDebug) echo "Add to DB..."; |
|
2282 | + if ($globalDebug) { |
|
2283 | + echo "Add to DB..."; |
|
2284 | + } |
|
1875 | 2285 | $error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M'); |
1876 | - } else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed."; |
|
2286 | + } else { |
|
2287 | + $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed."; |
|
2288 | + } |
|
1877 | 2289 | if ($error != '') { |
1878 | 2290 | return $error; |
1879 | - } elseif ($globalDebug) echo "Done\n"; |
|
2291 | + } elseif ($globalDebug) { |
|
2292 | + echo "Done\n"; |
|
2293 | + } |
|
1880 | 2294 | if ($globalMasterSource) { |
1881 | - if ($globalDebug) echo "ModeS Netherlands: Download..."; |
|
2295 | + if ($globalDebug) { |
|
2296 | + echo "ModeS Netherlands: Download..."; |
|
2297 | + } |
|
1882 | 2298 | update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv'); |
1883 | 2299 | if (file_exists($tmp_dir.'owner_ph.csv')) { |
1884 | - if ($globalDebug) echo "Add to DB..."; |
|
2300 | + if ($globalDebug) { |
|
2301 | + echo "Add to DB..."; |
|
2302 | + } |
|
1885 | 2303 | $error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH'); |
1886 | - } else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed."; |
|
2304 | + } else { |
|
2305 | + $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed."; |
|
2306 | + } |
|
1887 | 2307 | if ($error != '') { |
1888 | 2308 | return $error; |
1889 | - } elseif ($globalDebug) echo "Done\n"; |
|
1890 | - if ($globalDebug) echo "ModeS Denmark: Download..."; |
|
2309 | + } elseif ($globalDebug) { |
|
2310 | + echo "Done\n"; |
|
2311 | + } |
|
2312 | + if ($globalDebug) { |
|
2313 | + echo "ModeS Denmark: Download..."; |
|
2314 | + } |
|
1891 | 2315 | update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv'); |
1892 | 2316 | if (file_exists($tmp_dir.'owner_oy.csv')) { |
1893 | - if ($globalDebug) echo "Add to DB..."; |
|
2317 | + if ($globalDebug) { |
|
2318 | + echo "Add to DB..."; |
|
2319 | + } |
|
1894 | 2320 | $error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY'); |
1895 | - } else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed."; |
|
2321 | + } else { |
|
2322 | + $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed."; |
|
2323 | + } |
|
1896 | 2324 | if ($error != '') { |
1897 | 2325 | return $error; |
1898 | - } elseif ($globalDebug) echo "Done\n"; |
|
1899 | - } elseif ($globalDebug) echo "Done\n"; |
|
2326 | + } elseif ($globalDebug) { |
|
2327 | + echo "Done\n"; |
|
2328 | + } |
|
2329 | + } elseif ($globalDebug) { |
|
2330 | + echo "Done\n"; |
|
2331 | + } |
|
1900 | 2332 | return ''; |
1901 | 2333 | } |
1902 | 2334 | |
1903 | 2335 | public static function update_translation() { |
1904 | 2336 | global $tmp_dir, $globalDebug; |
1905 | 2337 | $error = ''; |
1906 | - if ($globalDebug) echo "Translation : Download..."; |
|
2338 | + if ($globalDebug) { |
|
2339 | + echo "Translation : Download..."; |
|
2340 | + } |
|
1907 | 2341 | update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip'); |
1908 | 2342 | if (file_exists($tmp_dir.'translation.zip')) { |
1909 | - if ($globalDebug) echo "Unzip..."; |
|
2343 | + if ($globalDebug) { |
|
2344 | + echo "Unzip..."; |
|
2345 | + } |
|
1910 | 2346 | update_db::unzip($tmp_dir.'translation.zip'); |
1911 | - if ($globalDebug) echo "Add to DB..."; |
|
2347 | + if ($globalDebug) { |
|
2348 | + echo "Add to DB..."; |
|
2349 | + } |
|
1912 | 2350 | $error = update_db::translation(); |
1913 | - } else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed."; |
|
2351 | + } else { |
|
2352 | + $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed."; |
|
2353 | + } |
|
1914 | 2354 | if ($error != '') { |
1915 | 2355 | return $error; |
1916 | - } elseif ($globalDebug) echo "Done\n"; |
|
2356 | + } elseif ($globalDebug) { |
|
2357 | + echo "Done\n"; |
|
2358 | + } |
|
1917 | 2359 | return ''; |
1918 | 2360 | } |
1919 | 2361 | |
1920 | 2362 | public static function update_translation_fam() { |
1921 | 2363 | global $tmp_dir, $globalDebug; |
1922 | - if ($globalDebug) echo "Translation from FlightAirMap website : Download..."; |
|
2364 | + if ($globalDebug) { |
|
2365 | + echo "Translation from FlightAirMap website : Download..."; |
|
2366 | + } |
|
1923 | 2367 | update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz'); |
1924 | 2368 | if (file_exists($tmp_dir.'translation.tsv.gz')) { |
1925 | - if ($globalDebug) echo "Gunzip..."; |
|
2369 | + if ($globalDebug) { |
|
2370 | + echo "Gunzip..."; |
|
2371 | + } |
|
1926 | 2372 | update_db::gunzip($tmp_dir.'translation.tsv.gz'); |
1927 | - if ($globalDebug) echo "Add to DB..."; |
|
2373 | + if ($globalDebug) { |
|
2374 | + echo "Add to DB..."; |
|
2375 | + } |
|
1928 | 2376 | $error = update_db::translation_fam(); |
1929 | - } else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed."; |
|
2377 | + } else { |
|
2378 | + $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed."; |
|
2379 | + } |
|
1930 | 2380 | if ($error != '') { |
1931 | 2381 | return $error; |
1932 | - } elseif ($globalDebug) echo "Done\n"; |
|
2382 | + } elseif ($globalDebug) { |
|
2383 | + echo "Done\n"; |
|
2384 | + } |
|
1933 | 2385 | return ''; |
1934 | 2386 | } |
1935 | 2387 | public static function update_ModeS_fam() { |
1936 | 2388 | global $tmp_dir, $globalDebug; |
1937 | - if ($globalDebug) echo "ModeS from FlightAirMap website : Download..."; |
|
2389 | + if ($globalDebug) { |
|
2390 | + echo "ModeS from FlightAirMap website : Download..."; |
|
2391 | + } |
|
1938 | 2392 | update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz'); |
1939 | 2393 | if (file_exists($tmp_dir.'modes.tsv.gz')) { |
1940 | - if ($globalDebug) echo "Gunzip..."; |
|
2394 | + if ($globalDebug) { |
|
2395 | + echo "Gunzip..."; |
|
2396 | + } |
|
1941 | 2397 | update_db::gunzip($tmp_dir.'modes.tsv.gz'); |
1942 | - if ($globalDebug) echo "Add to DB..."; |
|
2398 | + if ($globalDebug) { |
|
2399 | + echo "Add to DB..."; |
|
2400 | + } |
|
1943 | 2401 | $error = update_db::modes_fam(); |
1944 | - } else $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed."; |
|
2402 | + } else { |
|
2403 | + $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed."; |
|
2404 | + } |
|
1945 | 2405 | if ($error != '') { |
1946 | 2406 | return $error; |
1947 | - } elseif ($globalDebug) echo "Done\n"; |
|
2407 | + } elseif ($globalDebug) { |
|
2408 | + echo "Done\n"; |
|
2409 | + } |
|
1948 | 2410 | return ''; |
1949 | 2411 | } |
1950 | 2412 | public static function update_owner_fam() { |
1951 | 2413 | global $tmp_dir, $globalDebug, $globalOwner; |
1952 | - if ($globalDebug) echo "owner from FlightAirMap website : Download..."; |
|
2414 | + if ($globalDebug) { |
|
2415 | + echo "owner from FlightAirMap website : Download..."; |
|
2416 | + } |
|
1953 | 2417 | if ($globalOwner === TRUE) { |
1954 | 2418 | update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz'); |
1955 | 2419 | } else { |
1956 | 2420 | update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz',$tmp_dir.'owners.tsv.gz'); |
1957 | 2421 | } |
1958 | 2422 | if (file_exists($tmp_dir.'owners.tsv.gz')) { |
1959 | - if ($globalDebug) echo "Gunzip..."; |
|
2423 | + if ($globalDebug) { |
|
2424 | + echo "Gunzip..."; |
|
2425 | + } |
|
1960 | 2426 | update_db::gunzip($tmp_dir.'owners.tsv.gz'); |
1961 | - if ($globalDebug) echo "Add to DB..."; |
|
2427 | + if ($globalDebug) { |
|
2428 | + echo "Add to DB..."; |
|
2429 | + } |
|
1962 | 2430 | $error = update_db::owner_fam(); |
1963 | - } else $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed."; |
|
2431 | + } else { |
|
2432 | + $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed."; |
|
2433 | + } |
|
1964 | 2434 | if ($error != '') { |
1965 | 2435 | return $error; |
1966 | - } elseif ($globalDebug) echo "Done\n"; |
|
2436 | + } elseif ($globalDebug) { |
|
2437 | + echo "Done\n"; |
|
2438 | + } |
|
1967 | 2439 | return ''; |
1968 | 2440 | } |
1969 | 2441 | public static function update_routes_fam() { |
1970 | 2442 | global $tmp_dir, $globalDebug; |
1971 | - if ($globalDebug) echo "Routes from FlightAirMap website : Download..."; |
|
2443 | + if ($globalDebug) { |
|
2444 | + echo "Routes from FlightAirMap website : Download..."; |
|
2445 | + } |
|
1972 | 2446 | update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz'); |
1973 | 2447 | if (file_exists($tmp_dir.'routes.tsv.gz')) { |
1974 | - if ($globalDebug) echo "Gunzip..."; |
|
2448 | + if ($globalDebug) { |
|
2449 | + echo "Gunzip..."; |
|
2450 | + } |
|
1975 | 2451 | update_db::gunzip($tmp_dir.'routes.tsv.gz'); |
1976 | - if ($globalDebug) echo "Add to DB..."; |
|
2452 | + if ($globalDebug) { |
|
2453 | + echo "Add to DB..."; |
|
2454 | + } |
|
1977 | 2455 | $error = update_db::routes_fam(); |
1978 | - } else $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed."; |
|
2456 | + } else { |
|
2457 | + $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed."; |
|
2458 | + } |
|
1979 | 2459 | if ($error != '') { |
1980 | 2460 | return $error; |
1981 | - } elseif ($globalDebug) echo "Done\n"; |
|
2461 | + } elseif ($globalDebug) { |
|
2462 | + echo "Done\n"; |
|
2463 | + } |
|
1982 | 2464 | return ''; |
1983 | 2465 | } |
1984 | 2466 | public static function update_banned_fam() { |
1985 | 2467 | global $tmp_dir, $globalDebug; |
1986 | - if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download..."; |
|
2468 | + if ($globalDebug) { |
|
2469 | + echo "Banned airlines in Europe from FlightAirMap website : Download..."; |
|
2470 | + } |
|
1987 | 2471 | update_db::download('http://data.flightairmap.fr/data/ban_eu.csv',$tmp_dir.'ban_eu.csv'); |
1988 | 2472 | if (file_exists($tmp_dir.'ban_eu.csv')) { |
1989 | 2473 | //if ($globalDebug) echo "Gunzip..."; |
1990 | 2474 | //update_db::gunzip($tmp_dir.'ban_ue.csv'); |
1991 | - if ($globalDebug) echo "Add to DB..."; |
|
2475 | + if ($globalDebug) { |
|
2476 | + echo "Add to DB..."; |
|
2477 | + } |
|
1992 | 2478 | $error = update_db::banned_fam(); |
1993 | - } else $error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed."; |
|
2479 | + } else { |
|
2480 | + $error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed."; |
|
2481 | + } |
|
1994 | 2482 | if ($error != '') { |
1995 | 2483 | return $error; |
1996 | - } elseif ($globalDebug) echo "Done\n"; |
|
2484 | + } elseif ($globalDebug) { |
|
2485 | + echo "Done\n"; |
|
2486 | + } |
|
1997 | 2487 | return ''; |
1998 | 2488 | } |
1999 | 2489 | |
@@ -2001,7 +2491,9 @@ discard block |
||
2001 | 2491 | global $tmp_dir, $globalDebug, $globalDBdriver; |
2002 | 2492 | include_once('class.create_db.php'); |
2003 | 2493 | $error = ''; |
2004 | - if ($globalDebug) echo "Airspace from FlightAirMap website : Download..."; |
|
2494 | + if ($globalDebug) { |
|
2495 | + echo "Airspace from FlightAirMap website : Download..."; |
|
2496 | + } |
|
2005 | 2497 | if ($globalDBdriver == 'mysql') { |
2006 | 2498 | update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); |
2007 | 2499 | } else { |
@@ -2017,9 +2509,13 @@ discard block |
||
2017 | 2509 | update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz'); |
2018 | 2510 | } |
2019 | 2511 | if (file_exists($tmp_dir.'airspace.sql.gz')) { |
2020 | - if ($globalDebug) echo "Gunzip..."; |
|
2512 | + if ($globalDebug) { |
|
2513 | + echo "Gunzip..."; |
|
2514 | + } |
|
2021 | 2515 | update_db::gunzip($tmp_dir.'airspace.sql.gz'); |
2022 | - if ($globalDebug) echo "Add to DB..."; |
|
2516 | + if ($globalDebug) { |
|
2517 | + echo "Add to DB..."; |
|
2518 | + } |
|
2023 | 2519 | $Connection = new Connection(); |
2024 | 2520 | if ($Connection->tableExists('airspace')) { |
2025 | 2521 | $query = 'DROP TABLE airspace'; |
@@ -2032,31 +2528,47 @@ discard block |
||
2032 | 2528 | } |
2033 | 2529 | $error = create_db::import_file($tmp_dir.'airspace.sql'); |
2034 | 2530 | update_db::insert_airspace_version($airspace_md5); |
2035 | - } else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed."; |
|
2531 | + } else { |
|
2532 | + $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed."; |
|
2533 | + } |
|
2036 | 2534 | } |
2037 | - } else $error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed."; |
|
2535 | + } else { |
|
2536 | + $error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed."; |
|
2537 | + } |
|
2038 | 2538 | if ($error != '') { |
2039 | 2539 | return $error; |
2040 | - } elseif ($globalDebug) echo "Done\n"; |
|
2540 | + } elseif ($globalDebug) { |
|
2541 | + echo "Done\n"; |
|
2542 | + } |
|
2041 | 2543 | return ''; |
2042 | 2544 | } |
2043 | 2545 | |
2044 | 2546 | public static function update_tle() { |
2045 | 2547 | global $tmp_dir, $globalDebug; |
2046 | - if ($globalDebug) echo "Download TLE : Download..."; |
|
2548 | + if ($globalDebug) { |
|
2549 | + echo "Download TLE : Download..."; |
|
2550 | + } |
|
2047 | 2551 | $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', |
2048 | 2552 | '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', |
2049 | 2553 | 'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt'); |
2050 | 2554 | foreach ($alltle as $filename) { |
2051 | - if ($globalDebug) echo "downloading ".$filename.'...'; |
|
2555 | + if ($globalDebug) { |
|
2556 | + echo "downloading ".$filename.'...'; |
|
2557 | + } |
|
2052 | 2558 | update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename); |
2053 | 2559 | if (file_exists($tmp_dir.$filename)) { |
2054 | - if ($globalDebug) echo "Add to DB ".$filename."..."; |
|
2560 | + if ($globalDebug) { |
|
2561 | + echo "Add to DB ".$filename."..."; |
|
2562 | + } |
|
2055 | 2563 | $error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename)); |
2056 | - } else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
|
2564 | + } else { |
|
2565 | + $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
|
2566 | + } |
|
2057 | 2567 | if ($error != '') { |
2058 | 2568 | echo $error."\n"; |
2059 | - } elseif ($globalDebug) echo "Done\n"; |
|
2569 | + } elseif ($globalDebug) { |
|
2570 | + echo "Done\n"; |
|
2571 | + } |
|
2060 | 2572 | } |
2061 | 2573 | return ''; |
2062 | 2574 | } |
@@ -2064,10 +2576,14 @@ discard block |
||
2064 | 2576 | public static function update_models() { |
2065 | 2577 | global $tmp_dir, $globalDebug; |
2066 | 2578 | $error = ''; |
2067 | - if ($globalDebug) echo "Models from FlightAirMap website : Download..."; |
|
2579 | + if ($globalDebug) { |
|
2580 | + echo "Models from FlightAirMap website : Download..."; |
|
2581 | + } |
|
2068 | 2582 | update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum'); |
2069 | 2583 | if (file_exists($tmp_dir.'models.md5sum')) { |
2070 | - if ($globalDebug) echo "Check files...\n"; |
|
2584 | + if ($globalDebug) { |
|
2585 | + echo "Check files...\n"; |
|
2586 | + } |
|
2071 | 2587 | $newmodelsdb = array(); |
2072 | 2588 | if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) { |
2073 | 2589 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2086,25 +2602,35 @@ discard block |
||
2086 | 2602 | } |
2087 | 2603 | $diff = array_diff($newmodelsdb,$modelsdb); |
2088 | 2604 | foreach ($diff as $key => $value) { |
2089 | - if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n"; |
|
2605 | + if ($globalDebug) { |
|
2606 | + echo 'Downloading model '.$key.' ...'."\n"; |
|
2607 | + } |
|
2090 | 2608 | update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key); |
2091 | 2609 | |
2092 | 2610 | } |
2093 | 2611 | update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum'); |
2094 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
2612 | + } else { |
|
2613 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
2614 | + } |
|
2095 | 2615 | if ($error != '') { |
2096 | 2616 | return $error; |
2097 | - } elseif ($globalDebug) echo "Done\n"; |
|
2617 | + } elseif ($globalDebug) { |
|
2618 | + echo "Done\n"; |
|
2619 | + } |
|
2098 | 2620 | return ''; |
2099 | 2621 | } |
2100 | 2622 | |
2101 | 2623 | public static function update_space_models() { |
2102 | 2624 | global $tmp_dir, $globalDebug; |
2103 | 2625 | $error = ''; |
2104 | - if ($globalDebug) echo "Space models from FlightAirMap website : Download..."; |
|
2626 | + if ($globalDebug) { |
|
2627 | + echo "Space models from FlightAirMap website : Download..."; |
|
2628 | + } |
|
2105 | 2629 | update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum'); |
2106 | 2630 | if (file_exists($tmp_dir.'space_models.md5sum')) { |
2107 | - if ($globalDebug) echo "Check files...\n"; |
|
2631 | + if ($globalDebug) { |
|
2632 | + echo "Check files...\n"; |
|
2633 | + } |
|
2108 | 2634 | $newmodelsdb = array(); |
2109 | 2635 | if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) { |
2110 | 2636 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2123,25 +2649,35 @@ discard block |
||
2123 | 2649 | } |
2124 | 2650 | $diff = array_diff($newmodelsdb,$modelsdb); |
2125 | 2651 | foreach ($diff as $key => $value) { |
2126 | - if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n"; |
|
2652 | + if ($globalDebug) { |
|
2653 | + echo 'Downloading space model '.$key.' ...'."\n"; |
|
2654 | + } |
|
2127 | 2655 | update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key); |
2128 | 2656 | |
2129 | 2657 | } |
2130 | 2658 | update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum'); |
2131 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
2659 | + } else { |
|
2660 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
2661 | + } |
|
2132 | 2662 | if ($error != '') { |
2133 | 2663 | return $error; |
2134 | - } elseif ($globalDebug) echo "Done\n"; |
|
2664 | + } elseif ($globalDebug) { |
|
2665 | + echo "Done\n"; |
|
2666 | + } |
|
2135 | 2667 | return ''; |
2136 | 2668 | } |
2137 | 2669 | |
2138 | 2670 | public static function update_vehicules_models() { |
2139 | 2671 | global $tmp_dir, $globalDebug; |
2140 | 2672 | $error = ''; |
2141 | - if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download..."; |
|
2673 | + if ($globalDebug) { |
|
2674 | + echo "Vehicules models from FlightAirMap website : Download..."; |
|
2675 | + } |
|
2142 | 2676 | update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum'); |
2143 | 2677 | if (file_exists($tmp_dir.'vehicules_models.md5sum')) { |
2144 | - if ($globalDebug) echo "Check files...\n"; |
|
2678 | + if ($globalDebug) { |
|
2679 | + echo "Check files...\n"; |
|
2680 | + } |
|
2145 | 2681 | $newmodelsdb = array(); |
2146 | 2682 | if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) { |
2147 | 2683 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2160,15 +2696,21 @@ discard block |
||
2160 | 2696 | } |
2161 | 2697 | $diff = array_diff($newmodelsdb,$modelsdb); |
2162 | 2698 | foreach ($diff as $key => $value) { |
2163 | - if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n"; |
|
2699 | + if ($globalDebug) { |
|
2700 | + echo 'Downloading vehicules model '.$key.' ...'."\n"; |
|
2701 | + } |
|
2164 | 2702 | update_db::download('http://data.flightairmap.fr/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key); |
2165 | 2703 | |
2166 | 2704 | } |
2167 | 2705 | update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum'); |
2168 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
2706 | + } else { |
|
2707 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
2708 | + } |
|
2169 | 2709 | if ($error != '') { |
2170 | 2710 | return $error; |
2171 | - } elseif ($globalDebug) echo "Done\n"; |
|
2711 | + } elseif ($globalDebug) { |
|
2712 | + echo "Done\n"; |
|
2713 | + } |
|
2172 | 2714 | return ''; |
2173 | 2715 | } |
2174 | 2716 | |
@@ -2211,7 +2753,9 @@ discard block |
||
2211 | 2753 | } |
2212 | 2754 | |
2213 | 2755 | $error = ''; |
2214 | - if ($globalDebug) echo "Notam : Download..."; |
|
2756 | + if ($globalDebug) { |
|
2757 | + echo "Notam : Download..."; |
|
2758 | + } |
|
2215 | 2759 | update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss'); |
2216 | 2760 | if (file_exists($tmp_dir.'notam.rss')) { |
2217 | 2761 | $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true); |
@@ -2226,14 +2770,30 @@ discard block |
||
2226 | 2770 | $data['fir'] = $q[0]; |
2227 | 2771 | $data['code'] = $q[1]; |
2228 | 2772 | $ifrvfr = $q[2]; |
2229 | - if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR'; |
|
2230 | - if ($ifrvfr == 'I') $data['rules'] = 'IFR'; |
|
2231 | - if ($ifrvfr == 'V') $data['rules'] = 'VFR'; |
|
2232 | - if ($q[4] == 'A') $data['scope'] = 'Airport warning'; |
|
2233 | - if ($q[4] == 'E') $data['scope'] = 'Enroute warning'; |
|
2234 | - if ($q[4] == 'W') $data['scope'] = 'Navigation warning'; |
|
2235 | - if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning'; |
|
2236 | - if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning'; |
|
2773 | + if ($ifrvfr == 'IV') { |
|
2774 | + $data['rules'] = 'IFR/VFR'; |
|
2775 | + } |
|
2776 | + if ($ifrvfr == 'I') { |
|
2777 | + $data['rules'] = 'IFR'; |
|
2778 | + } |
|
2779 | + if ($ifrvfr == 'V') { |
|
2780 | + $data['rules'] = 'VFR'; |
|
2781 | + } |
|
2782 | + if ($q[4] == 'A') { |
|
2783 | + $data['scope'] = 'Airport warning'; |
|
2784 | + } |
|
2785 | + if ($q[4] == 'E') { |
|
2786 | + $data['scope'] = 'Enroute warning'; |
|
2787 | + } |
|
2788 | + if ($q[4] == 'W') { |
|
2789 | + $data['scope'] = 'Navigation warning'; |
|
2790 | + } |
|
2791 | + if ($q[4] == 'AE') { |
|
2792 | + $data['scope'] = 'Airport/Enroute warning'; |
|
2793 | + } |
|
2794 | + if ($q[4] == 'AW') { |
|
2795 | + $data['scope'] = 'Airport/Navigation warning'; |
|
2796 | + } |
|
2237 | 2797 | //$data['scope'] = $q[4]; |
2238 | 2798 | $data['lower_limit'] = $q[5]; |
2239 | 2799 | $data['upper_limit'] = $q[6]; |
@@ -2241,8 +2801,12 @@ discard block |
||
2241 | 2801 | sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius); |
2242 | 2802 | $latitude = $Common->convertDec($las,'latitude'); |
2243 | 2803 | $longitude = $Common->convertDec($lns,'longitude'); |
2244 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
2245 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
2804 | + if ($lac == 'S') { |
|
2805 | + $latitude = '-'.$latitude; |
|
2806 | + } |
|
2807 | + if ($lnc == 'W') { |
|
2808 | + $longitude = '-'.$longitude; |
|
2809 | + } |
|
2246 | 2810 | $data['center_latitude'] = $latitude; |
2247 | 2811 | $data['center_longitude'] = $longitude; |
2248 | 2812 | $data['radius'] = intval($radius); |
@@ -2272,10 +2836,14 @@ discard block |
||
2272 | 2836 | $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']); |
2273 | 2837 | unset($data); |
2274 | 2838 | } |
2275 | - } else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
|
2839 | + } else { |
|
2840 | + $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
|
2841 | + } |
|
2276 | 2842 | if ($error != '') { |
2277 | 2843 | return $error; |
2278 | - } elseif ($globalDebug) echo "Done\n"; |
|
2844 | + } elseif ($globalDebug) { |
|
2845 | + echo "Done\n"; |
|
2846 | + } |
|
2279 | 2847 | return ''; |
2280 | 2848 | } |
2281 | 2849 | |
@@ -2300,7 +2868,9 @@ discard block |
||
2300 | 2868 | $airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json'); |
2301 | 2869 | $airspace_json = json_decode($airspace_lst,true); |
2302 | 2870 | foreach ($airspace_json['records'] as $airspace) { |
2303 | - if ($globalDebug) echo $airspace['name']."...\n"; |
|
2871 | + if ($globalDebug) { |
|
2872 | + echo $airspace['name']."...\n"; |
|
2873 | + } |
|
2304 | 2874 | update_db::download($airspace['uri'],$tmp_dir.$airspace['name']); |
2305 | 2875 | if (file_exists($tmp_dir.$airspace['name'])) { |
2306 | 2876 | file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name']))); |
@@ -2344,8 +2914,11 @@ discard block |
||
2344 | 2914 | return "error : ".$e->getMessage(); |
2345 | 2915 | } |
2346 | 2916 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2347 | - if ($row['nb'] > 0) return false; |
|
2348 | - else return true; |
|
2917 | + if ($row['nb'] > 0) { |
|
2918 | + return false; |
|
2919 | + } else { |
|
2920 | + return true; |
|
2921 | + } |
|
2349 | 2922 | } |
2350 | 2923 | |
2351 | 2924 | public static function insert_last_update() { |
@@ -2370,8 +2943,11 @@ discard block |
||
2370 | 2943 | return "error : ".$e->getMessage(); |
2371 | 2944 | } |
2372 | 2945 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2373 | - if ($row['nb'] > 0) return true; |
|
2374 | - else return false; |
|
2946 | + if ($row['nb'] > 0) { |
|
2947 | + return true; |
|
2948 | + } else { |
|
2949 | + return false; |
|
2950 | + } |
|
2375 | 2951 | } |
2376 | 2952 | |
2377 | 2953 | |
@@ -2402,8 +2978,11 @@ discard block |
||
2402 | 2978 | return "error : ".$e->getMessage(); |
2403 | 2979 | } |
2404 | 2980 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2405 | - if ($row['nb'] > 0) return false; |
|
2406 | - else return true; |
|
2981 | + if ($row['nb'] > 0) { |
|
2982 | + return false; |
|
2983 | + } else { |
|
2984 | + return true; |
|
2985 | + } |
|
2407 | 2986 | } |
2408 | 2987 | |
2409 | 2988 | public static function insert_last_notam_update() { |
@@ -2432,8 +3011,11 @@ discard block |
||
2432 | 3011 | return "error : ".$e->getMessage(); |
2433 | 3012 | } |
2434 | 3013 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2435 | - if ($row['nb'] > 0) return false; |
|
2436 | - else return true; |
|
3014 | + if ($row['nb'] > 0) { |
|
3015 | + return false; |
|
3016 | + } else { |
|
3017 | + return true; |
|
3018 | + } |
|
2437 | 3019 | } |
2438 | 3020 | |
2439 | 3021 | public static function insert_last_airspace_update() { |
@@ -2463,8 +3045,11 @@ discard block |
||
2463 | 3045 | return "error : ".$e->getMessage(); |
2464 | 3046 | } |
2465 | 3047 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2466 | - if ($row['nb'] > 0) return false; |
|
2467 | - else return true; |
|
3048 | + if ($row['nb'] > 0) { |
|
3049 | + return false; |
|
3050 | + } else { |
|
3051 | + return true; |
|
3052 | + } |
|
2468 | 3053 | } |
2469 | 3054 | |
2470 | 3055 | public static function insert_last_owner_update() { |
@@ -2493,8 +3078,11 @@ discard block |
||
2493 | 3078 | return "error : ".$e->getMessage(); |
2494 | 3079 | } |
2495 | 3080 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2496 | - if ($row['nb'] > 0) return false; |
|
2497 | - else return true; |
|
3081 | + if ($row['nb'] > 0) { |
|
3082 | + return false; |
|
3083 | + } else { |
|
3084 | + return true; |
|
3085 | + } |
|
2498 | 3086 | } |
2499 | 3087 | |
2500 | 3088 | public static function insert_last_schedules_update() { |
@@ -2523,8 +3111,11 @@ discard block |
||
2523 | 3111 | return "error : ".$e->getMessage(); |
2524 | 3112 | } |
2525 | 3113 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2526 | - if ($row['nb'] > 0) return false; |
|
2527 | - else return true; |
|
3114 | + if ($row['nb'] > 0) { |
|
3115 | + return false; |
|
3116 | + } else { |
|
3117 | + return true; |
|
3118 | + } |
|
2528 | 3119 | } |
2529 | 3120 | |
2530 | 3121 | public static function insert_last_tle_update() { |