@@ -36,7 +36,9 @@ discard block |
||
36 | 36 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
37 | 37 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
38 | 38 | curl_setopt($ch, CURLOPT_TIMEOUT, 200); |
39 | - if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
39 | + if ($referer != '') { |
|
40 | + curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
41 | + } |
|
40 | 42 | 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'); |
41 | 43 | curl_setopt($ch, CURLOPT_FILE, $fp); |
42 | 44 | curl_exec($ch); |
@@ -47,12 +49,16 @@ discard block |
||
47 | 49 | public static function gunzip($in_file,$out_file_name = '') { |
48 | 50 | //echo $in_file.' -> '.$out_file_name."\n"; |
49 | 51 | $buffer_size = 4096; // read 4kb at a time |
50 | - if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); |
|
52 | + if ($out_file_name == '') { |
|
53 | + $out_file_name = str_replace('.gz', '', $in_file); |
|
54 | + } |
|
51 | 55 | if ($in_file != '' && file_exists($in_file)) { |
52 | 56 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
53 | - if (function_exists('gzopen')) $file = gzopen($in_file,'rb'); |
|
54 | - elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb'); |
|
55 | - else { |
|
57 | + if (function_exists('gzopen')) { |
|
58 | + $file = gzopen($in_file,'rb'); |
|
59 | + } elseif (function_exists('gzopen64')) { |
|
60 | + $file = gzopen64($in_file,'rb'); |
|
61 | + } else { |
|
56 | 62 | echo 'gzopen not available'; |
57 | 63 | die; |
58 | 64 | } |
@@ -73,8 +79,12 @@ discard block |
||
73 | 79 | if ($res === TRUE) { |
74 | 80 | $zip->extractTo($path); |
75 | 81 | $zip->close(); |
76 | - } else return false; |
|
77 | - } else return false; |
|
82 | + } else { |
|
83 | + return false; |
|
84 | + } |
|
85 | + } else { |
|
86 | + return false; |
|
87 | + } |
|
78 | 88 | } |
79 | 89 | |
80 | 90 | public static function connect_sqlite($database) { |
@@ -89,7 +99,9 @@ discard block |
||
89 | 99 | public static function retrieve_route_sqlite_to_dest($database_file) { |
90 | 100 | global $globalDebug, $globalTransaction; |
91 | 101 | //$query = 'TRUNCATE TABLE routes'; |
92 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
102 | + if ($globalDebug) { |
|
103 | + echo " - Delete previous routes from DB -"; |
|
104 | + } |
|
93 | 105 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
94 | 106 | $Connection = new Connection(); |
95 | 107 | try { |
@@ -100,7 +112,9 @@ discard block |
||
100 | 112 | return "error : ".$e->getMessage(); |
101 | 113 | } |
102 | 114 | |
103 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
115 | + if ($globalDebug) { |
|
116 | + echo " - Add routes to DB -"; |
|
117 | + } |
|
104 | 118 | update_db::connect_sqlite($database_file); |
105 | 119 | //$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'; |
106 | 120 | $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"; |
@@ -115,15 +129,21 @@ discard block |
||
115 | 129 | $Connection = new Connection(); |
116 | 130 | $sth_dest = $Connection->db->prepare($query_dest); |
117 | 131 | try { |
118 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
132 | + if ($globalTransaction) { |
|
133 | + $Connection->db->beginTransaction(); |
|
134 | + } |
|
119 | 135 | while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
120 | 136 | //$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); |
121 | 137 | $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); |
122 | 138 | $sth_dest->execute($query_dest_values); |
123 | 139 | } |
124 | - if ($globalTransaction) $Connection->db->commit(); |
|
140 | + if ($globalTransaction) { |
|
141 | + $Connection->db->commit(); |
|
142 | + } |
|
125 | 143 | } catch(PDOException $e) { |
126 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
144 | + if ($globalTransaction) { |
|
145 | + $Connection->db->rollBack(); |
|
146 | + } |
|
127 | 147 | return "error : ".$e->getMessage(); |
128 | 148 | } |
129 | 149 | return ''; |
@@ -131,7 +151,9 @@ discard block |
||
131 | 151 | public static function retrieve_route_oneworld($database_file) { |
132 | 152 | global $globalDebug, $globalTransaction; |
133 | 153 | //$query = 'TRUNCATE TABLE routes'; |
134 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
154 | + if ($globalDebug) { |
|
155 | + echo " - Delete previous routes from DB -"; |
|
156 | + } |
|
135 | 157 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
136 | 158 | $Connection = new Connection(); |
137 | 159 | try { |
@@ -142,14 +164,18 @@ discard block |
||
142 | 164 | return "error : ".$e->getMessage(); |
143 | 165 | } |
144 | 166 | |
145 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
167 | + if ($globalDebug) { |
|
168 | + echo " - Add routes to DB -"; |
|
169 | + } |
|
146 | 170 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
147 | 171 | $Spotter = new Spotter(); |
148 | 172 | if ($fh = fopen($database_file,"r")) { |
149 | 173 | $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)'; |
150 | 174 | $Connection = new Connection(); |
151 | 175 | $sth_dest = $Connection->db->prepare($query_dest); |
152 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
176 | + if ($globalTransaction) { |
|
177 | + $Connection->db->beginTransaction(); |
|
178 | + } |
|
153 | 179 | while (!feof($fh)) { |
154 | 180 | $line = fgetcsv($fh,9999,','); |
155 | 181 | if ($line[0] != '') { |
@@ -158,13 +184,17 @@ discard block |
||
158 | 184 | $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'); |
159 | 185 | $sth_dest->execute($query_dest_values); |
160 | 186 | } catch(PDOException $e) { |
161 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
187 | + if ($globalTransaction) { |
|
188 | + $Connection->db->rollBack(); |
|
189 | + } |
|
162 | 190 | return "error : ".$e->getMessage(); |
163 | 191 | } |
164 | 192 | } |
165 | 193 | } |
166 | 194 | } |
167 | - if ($globalTransaction) $Connection->db->commit(); |
|
195 | + if ($globalTransaction) { |
|
196 | + $Connection->db->commit(); |
|
197 | + } |
|
168 | 198 | } |
169 | 199 | return ''; |
170 | 200 | } |
@@ -172,7 +202,9 @@ discard block |
||
172 | 202 | public static function retrieve_route_skyteam($database_file) { |
173 | 203 | global $globalDebug, $globalTransaction; |
174 | 204 | //$query = 'TRUNCATE TABLE routes'; |
175 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
205 | + if ($globalDebug) { |
|
206 | + echo " - Delete previous routes from DB -"; |
|
207 | + } |
|
176 | 208 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
177 | 209 | $Connection = new Connection(); |
178 | 210 | try { |
@@ -183,7 +215,9 @@ discard block |
||
183 | 215 | return "error : ".$e->getMessage(); |
184 | 216 | } |
185 | 217 | |
186 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
218 | + if ($globalDebug) { |
|
219 | + echo " - Add routes to DB -"; |
|
220 | + } |
|
187 | 221 | |
188 | 222 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
189 | 223 | $Spotter = new Spotter(); |
@@ -192,7 +226,9 @@ discard block |
||
192 | 226 | $Connection = new Connection(); |
193 | 227 | $sth_dest = $Connection->db->prepare($query_dest); |
194 | 228 | try { |
195 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
229 | + if ($globalTransaction) { |
|
230 | + $Connection->db->beginTransaction(); |
|
231 | + } |
|
196 | 232 | while (!feof($fh)) { |
197 | 233 | $line = fgetcsv($fh,9999,','); |
198 | 234 | if ($line[0] != '') { |
@@ -203,9 +239,13 @@ discard block |
||
203 | 239 | } |
204 | 240 | } |
205 | 241 | } |
206 | - if ($globalTransaction) $Connection->db->commit(); |
|
242 | + if ($globalTransaction) { |
|
243 | + $Connection->db->commit(); |
|
244 | + } |
|
207 | 245 | } catch(PDOException $e) { |
208 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
246 | + if ($globalTransaction) { |
|
247 | + $Connection->db->rollBack(); |
|
248 | + } |
|
209 | 249 | return "error : ".$e->getMessage(); |
210 | 250 | } |
211 | 251 | } |
@@ -248,11 +288,16 @@ discard block |
||
248 | 288 | $sth_dest = $Connection->db->prepare($query_dest); |
249 | 289 | $sth_dest_owner = $Connection->db->prepare($query_dest_owner); |
250 | 290 | try { |
251 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
291 | + if ($globalTransaction) { |
|
292 | + $Connection->db->beginTransaction(); |
|
293 | + } |
|
252 | 294 | while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
253 | 295 | //$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']); |
254 | - if ($values['UserString4'] == 'M') $type = 'military'; |
|
255 | - else $type = null; |
|
296 | + if ($values['UserString4'] == 'M') { |
|
297 | + $type = 'military'; |
|
298 | + } else { |
|
299 | + $type = null; |
|
300 | + } |
|
256 | 301 | $query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type); |
257 | 302 | $sth_dest->execute($query_dest_values); |
258 | 303 | if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') { |
@@ -260,7 +305,9 @@ discard block |
||
260 | 305 | $sth_dest_owner->execute($query_dest_owner_values); |
261 | 306 | } |
262 | 307 | } |
263 | - if ($globalTransaction) $Connection->db->commit(); |
|
308 | + if ($globalTransaction) { |
|
309 | + $Connection->db->commit(); |
|
310 | + } |
|
264 | 311 | } catch(PDOException $e) { |
265 | 312 | return "error : ".$e->getMessage(); |
266 | 313 | } |
@@ -297,7 +344,9 @@ discard block |
||
297 | 344 | $Connection = new Connection(); |
298 | 345 | $sth_dest = $Connection->db->prepare($query_dest); |
299 | 346 | try { |
300 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
347 | + if ($globalTransaction) { |
|
348 | + $Connection->db->beginTransaction(); |
|
349 | + } |
|
301 | 350 | while (!feof($fh)) { |
302 | 351 | $values = array(); |
303 | 352 | $line = $Common->hex2str(fgets($fh,9999)); |
@@ -308,7 +357,9 @@ discard block |
||
308 | 357 | // Check if we can find ICAO, else set it to GLID |
309 | 358 | $aircraft_name_split = explode(' ',$aircraft_name); |
310 | 359 | $search_more = ''; |
311 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
360 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) { |
|
361 | + $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
362 | + } |
|
312 | 363 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
313 | 364 | $sth_search = $Connection->db->prepare($query_search); |
314 | 365 | try { |
@@ -321,7 +372,9 @@ discard block |
||
321 | 372 | } catch(PDOException $e) { |
322 | 373 | return "error : ".$e->getMessage(); |
323 | 374 | } |
324 | - if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID'; |
|
375 | + if (!isset($values['ICAOTypeCode'])) { |
|
376 | + $values['ICAOTypeCode'] = 'GLID'; |
|
377 | + } |
|
325 | 378 | // Add data to db |
326 | 379 | if ($values['Registration'] != '' && $values['Registration'] != '0000') { |
327 | 380 | //$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']); |
@@ -330,7 +383,9 @@ discard block |
||
330 | 383 | $sth_dest->execute($query_dest_values); |
331 | 384 | } |
332 | 385 | } |
333 | - if ($globalTransaction) $Connection->db->commit(); |
|
386 | + if ($globalTransaction) { |
|
387 | + $Connection->db->commit(); |
|
388 | + } |
|
334 | 389 | } catch(PDOException $e) { |
335 | 390 | return "error : ".$e->getMessage(); |
336 | 391 | } |
@@ -366,7 +421,9 @@ discard block |
||
366 | 421 | $Connection = new Connection(); |
367 | 422 | $sth_dest = $Connection->db->prepare($query_dest); |
368 | 423 | try { |
369 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
424 | + if ($globalTransaction) { |
|
425 | + $Connection->db->beginTransaction(); |
|
426 | + } |
|
370 | 427 | $tmp = fgetcsv($fh,9999,',',"'"); |
371 | 428 | while (!feof($fh)) { |
372 | 429 | $line = fgetcsv($fh,9999,',',"'"); |
@@ -380,13 +437,17 @@ discard block |
||
380 | 437 | // Check if we can find ICAO, else set it to GLID |
381 | 438 | $aircraft_name_split = explode(' ',$aircraft_name); |
382 | 439 | $search_more = ''; |
383 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
440 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) { |
|
441 | + $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
442 | + } |
|
384 | 443 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
385 | 444 | $sth_search = $Connection->db->prepare($query_search); |
386 | 445 | try { |
387 | 446 | $sth_search->execute(); |
388 | 447 | $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
389 | - if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
|
448 | + if (isset($result['icao']) && $result['icao'] != '') { |
|
449 | + $values['ICAOTypeCode'] = $result['icao']; |
|
450 | + } |
|
390 | 451 | } catch(PDOException $e) { |
391 | 452 | return "error : ".$e->getMessage(); |
392 | 453 | } |
@@ -399,7 +460,9 @@ discard block |
||
399 | 460 | $sth_dest->execute($query_dest_values); |
400 | 461 | } |
401 | 462 | } |
402 | - if ($globalTransaction) $Connection->db->commit(); |
|
463 | + if ($globalTransaction) { |
|
464 | + $Connection->db->commit(); |
|
465 | + } |
|
403 | 466 | } catch(PDOException $e) { |
404 | 467 | return "error : ".$e->getMessage(); |
405 | 468 | } |
@@ -438,7 +501,9 @@ discard block |
||
438 | 501 | $sth_dest = $Connection->db->prepare($query_dest); |
439 | 502 | $sth_modes = $Connection->db->prepare($query_modes); |
440 | 503 | try { |
441 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
504 | + if ($globalTransaction) { |
|
505 | + $Connection->db->beginTransaction(); |
|
506 | + } |
|
442 | 507 | $tmp = fgetcsv($fh,9999,',','"'); |
443 | 508 | while (!feof($fh)) { |
444 | 509 | $line = fgetcsv($fh,9999,',','"'); |
@@ -448,16 +513,22 @@ discard block |
||
448 | 513 | $values['registration'] = $line[0]; |
449 | 514 | $values['base'] = $line[4]; |
450 | 515 | $values['owner'] = $line[5]; |
451 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
452 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
516 | + if ($line[6] == '') { |
|
517 | + $values['date_first_reg'] = null; |
|
518 | + } else { |
|
519 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
520 | + } |
|
453 | 521 | $values['cancel'] = $line[7]; |
454 | 522 | } elseif ($country == 'EI') { |
455 | 523 | // TODO : add modeS & reg to aircraft_modes |
456 | 524 | $values['registration'] = $line[0]; |
457 | 525 | $values['base'] = $line[3]; |
458 | 526 | $values['owner'] = $line[2]; |
459 | - if ($line[1] == '') $values['date_first_reg'] = null; |
|
460 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
527 | + if ($line[1] == '') { |
|
528 | + $values['date_first_reg'] = null; |
|
529 | + } else { |
|
530 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
531 | + } |
|
461 | 532 | $values['cancel'] = ''; |
462 | 533 | $values['modes'] = $line[7]; |
463 | 534 | $values['icao'] = $line[8]; |
@@ -476,16 +547,22 @@ discard block |
||
476 | 547 | $values['registration'] = $line[3]; |
477 | 548 | $values['base'] = null; |
478 | 549 | $values['owner'] = $line[5]; |
479 | - if ($line[18] == '') $values['date_first_reg'] = null; |
|
480 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
550 | + if ($line[18] == '') { |
|
551 | + $values['date_first_reg'] = null; |
|
552 | + } else { |
|
553 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
554 | + } |
|
481 | 555 | $values['cancel'] = ''; |
482 | 556 | } elseif ($country == 'VH') { |
483 | 557 | // TODO : add modeS & reg to aircraft_modes |
484 | 558 | $values['registration'] = $line[0]; |
485 | 559 | $values['base'] = null; |
486 | 560 | $values['owner'] = $line[12]; |
487 | - if ($line[28] == '') $values['date_first_reg'] = null; |
|
488 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
561 | + if ($line[28] == '') { |
|
562 | + $values['date_first_reg'] = null; |
|
563 | + } else { |
|
564 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
565 | + } |
|
489 | 566 | |
490 | 567 | $values['cancel'] = $line[39]; |
491 | 568 | } elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { |
@@ -504,29 +581,41 @@ discard block |
||
504 | 581 | $values['registration'] = $line[0]; |
505 | 582 | $values['base'] = null; |
506 | 583 | $values['owner'] = $line[8]; |
507 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
508 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
584 | + if ($line[7] == '') { |
|
585 | + $values['date_first_reg'] = null; |
|
586 | + } else { |
|
587 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
588 | + } |
|
509 | 589 | $values['cancel'] = ''; |
510 | 590 | } elseif ($country == 'PP') { |
511 | 591 | $values['registration'] = $line[0]; |
512 | 592 | $values['base'] = null; |
513 | 593 | $values['owner'] = $line[4]; |
514 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
515 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
594 | + if ($line[6] == '') { |
|
595 | + $values['date_first_reg'] = null; |
|
596 | + } else { |
|
597 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
598 | + } |
|
516 | 599 | $values['cancel'] = $line[7]; |
517 | 600 | } elseif ($country == 'E7') { |
518 | 601 | $values['registration'] = $line[0]; |
519 | 602 | $values['base'] = null; |
520 | 603 | $values['owner'] = $line[4]; |
521 | - if ($line[5] == '') $values['date_first_reg'] = null; |
|
522 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
604 | + if ($line[5] == '') { |
|
605 | + $values['date_first_reg'] = null; |
|
606 | + } else { |
|
607 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
608 | + } |
|
523 | 609 | $values['cancel'] = ''; |
524 | 610 | } elseif ($country == '8Q') { |
525 | 611 | $values['registration'] = $line[0]; |
526 | 612 | $values['base'] = null; |
527 | 613 | $values['owner'] = $line[3]; |
528 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
529 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
614 | + if ($line[7] == '') { |
|
615 | + $values['date_first_reg'] = null; |
|
616 | + } else { |
|
617 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
618 | + } |
|
530 | 619 | $values['cancel'] = ''; |
531 | 620 | } elseif ($country == 'ZK') { |
532 | 621 | $values['registration'] = $line[0]; |
@@ -571,7 +660,9 @@ discard block |
||
571 | 660 | $sth_modes->execute($query_modes_values); |
572 | 661 | } |
573 | 662 | } |
574 | - if ($globalTransaction) $Connection->db->commit(); |
|
663 | + if ($globalTransaction) { |
|
664 | + $Connection->db->commit(); |
|
665 | + } |
|
575 | 666 | } catch(PDOException $e) { |
576 | 667 | return "error : ".$e->getMessage(); |
577 | 668 | } |
@@ -707,25 +798,45 @@ discard block |
||
707 | 798 | VALUES (:name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)"; |
708 | 799 | $Connection = new Connection(); |
709 | 800 | $sth_dest = $Connection->db->prepare($query_dest); |
710 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
801 | + if ($globalTransaction) { |
|
802 | + $Connection->db->beginTransaction(); |
|
803 | + } |
|
711 | 804 | |
712 | 805 | $i = 0; |
713 | 806 | while($row = sparql_fetch_array($result)) |
714 | 807 | { |
715 | 808 | if ($i >= 1) { |
716 | 809 | //print_r($row); |
717 | - if (!isset($row['iata'])) $row['iata'] = ''; |
|
718 | - if (!isset($row['icao'])) $row['icao'] = ''; |
|
719 | - if (!isset($row['type'])) $row['type'] = ''; |
|
720 | - if (!isset($row['altitude'])) $row['altitude'] = ''; |
|
810 | + if (!isset($row['iata'])) { |
|
811 | + $row['iata'] = ''; |
|
812 | + } |
|
813 | + if (!isset($row['icao'])) { |
|
814 | + $row['icao'] = ''; |
|
815 | + } |
|
816 | + if (!isset($row['type'])) { |
|
817 | + $row['type'] = ''; |
|
818 | + } |
|
819 | + if (!isset($row['altitude'])) { |
|
820 | + $row['altitude'] = ''; |
|
821 | + } |
|
721 | 822 | if (isset($row['city_bis'])) { |
722 | 823 | $row['city'] = $row['city_bis']; |
723 | 824 | } |
724 | - if (!isset($row['city'])) $row['city'] = ''; |
|
725 | - if (!isset($row['country'])) $row['country'] = ''; |
|
726 | - if (!isset($row['homepage'])) $row['homepage'] = ''; |
|
727 | - if (!isset($row['wikipedia_page'])) $row['wikipedia_page'] = ''; |
|
728 | - if (!isset($row['name'])) continue; |
|
825 | + if (!isset($row['city'])) { |
|
826 | + $row['city'] = ''; |
|
827 | + } |
|
828 | + if (!isset($row['country'])) { |
|
829 | + $row['country'] = ''; |
|
830 | + } |
|
831 | + if (!isset($row['homepage'])) { |
|
832 | + $row['homepage'] = ''; |
|
833 | + } |
|
834 | + if (!isset($row['wikipedia_page'])) { |
|
835 | + $row['wikipedia_page'] = ''; |
|
836 | + } |
|
837 | + if (!isset($row['name'])) { |
|
838 | + continue; |
|
839 | + } |
|
729 | 840 | if (!isset($row['image'])) { |
730 | 841 | $row['image'] = ''; |
731 | 842 | $row['image_thumb'] = ''; |
@@ -781,7 +892,9 @@ discard block |
||
781 | 892 | |
782 | 893 | $i++; |
783 | 894 | } |
784 | - if ($globalTransaction) $Connection->db->commit(); |
|
895 | + if ($globalTransaction) { |
|
896 | + $Connection->db->commit(); |
|
897 | + } |
|
785 | 898 | /* |
786 | 899 | echo "Delete duplicate rows...\n"; |
787 | 900 | $query = 'ALTER IGNORE TABLE airport ADD UNIQUE INDEX icaoidx (icao)'; |
@@ -824,7 +937,9 @@ discard block |
||
824 | 937 | $delimiter = ','; |
825 | 938 | $out_file = $tmp_dir.'airports.csv'; |
826 | 939 | update_db::download('http://ourairports.com/data/airports.csv',$out_file); |
827 | - if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
|
940 | + if (!file_exists($out_file) || !is_readable($out_file)) { |
|
941 | + return FALSE; |
|
942 | + } |
|
828 | 943 | echo "Add data from ourairports.com...\n"; |
829 | 944 | |
830 | 945 | $header = NULL; |
@@ -834,8 +949,9 @@ discard block |
||
834 | 949 | //$Connection->db->beginTransaction(); |
835 | 950 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
836 | 951 | { |
837 | - if(!$header) $header = $row; |
|
838 | - else { |
|
952 | + if(!$header) { |
|
953 | + $header = $row; |
|
954 | + } else { |
|
839 | 955 | $data = array(); |
840 | 956 | $data = array_combine($header, $row); |
841 | 957 | try { |
@@ -876,7 +992,9 @@ discard block |
||
876 | 992 | echo "Download data from another free database...\n"; |
877 | 993 | $out_file = $tmp_dir.'GlobalAirportDatabase.zip'; |
878 | 994 | update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file); |
879 | - if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
|
995 | + if (!file_exists($out_file) || !is_readable($out_file)) { |
|
996 | + return FALSE; |
|
997 | + } |
|
880 | 998 | update_db::unzip($out_file); |
881 | 999 | $header = NULL; |
882 | 1000 | echo "Add data from another free database...\n"; |
@@ -887,8 +1005,9 @@ discard block |
||
887 | 1005 | //$Connection->db->beginTransaction(); |
888 | 1006 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
889 | 1007 | { |
890 | - if(!$header) $header = $row; |
|
891 | - else { |
|
1008 | + if(!$header) { |
|
1009 | + $header = $row; |
|
1010 | + } else { |
|
892 | 1011 | $data = $row; |
893 | 1012 | |
894 | 1013 | $query = 'UPDATE airport SET city = :city, country = :country WHERE icao = :icao'; |
@@ -1082,7 +1201,9 @@ discard block |
||
1082 | 1201 | if (($handle = fopen($tmp_dir.'MASTER.txt', 'r')) !== FALSE) |
1083 | 1202 | { |
1084 | 1203 | $i = 0; |
1085 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1204 | + if ($globalTransaction) { |
|
1205 | + $Connection->db->beginTransaction(); |
|
1206 | + } |
|
1086 | 1207 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1087 | 1208 | { |
1088 | 1209 | if ($i > 0) { |
@@ -1095,7 +1216,9 @@ discard block |
||
1095 | 1216 | } |
1096 | 1217 | $result_search = $sths->fetchAll(PDO::FETCH_ASSOC); |
1097 | 1218 | if (!empty($result_search)) { |
1098 | - if ($globalDebug) echo '.'; |
|
1219 | + if ($globalDebug) { |
|
1220 | + echo '.'; |
|
1221 | + } |
|
1099 | 1222 | //if ($globalDBdriver == 'mysql') { |
1100 | 1223 | // $queryi = 'INSERT INTO faamfr (mfr,icao) VALUES (:mfr,:icao) ON DUPLICATE KEY UPDATE icao = :icao'; |
1101 | 1224 | //} else { |
@@ -1117,8 +1240,12 @@ discard block |
||
1117 | 1240 | } |
1118 | 1241 | $result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC); |
1119 | 1242 | if (!empty($result_search_mfr)) { |
1120 | - if (trim($data[16]) == '' && trim($data[23]) != '') $data[16] = $data[23]; |
|
1121 | - if (trim($data[16]) == '' && trim($data[15]) != '') $data[16] = $data[15]; |
|
1243 | + if (trim($data[16]) == '' && trim($data[23]) != '') { |
|
1244 | + $data[16] = $data[23]; |
|
1245 | + } |
|
1246 | + if (trim($data[16]) == '' && trim($data[15]) != '') { |
|
1247 | + $data[16] = $data[15]; |
|
1248 | + } |
|
1122 | 1249 | $queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)'; |
1123 | 1250 | try { |
1124 | 1251 | $sthf = $Connection->db->prepare($queryf); |
@@ -1129,7 +1256,9 @@ discard block |
||
1129 | 1256 | } |
1130 | 1257 | } |
1131 | 1258 | if (strtotime($data[29]) > time()) { |
1132 | - if ($globalDebug) echo 'i'; |
|
1259 | + if ($globalDebug) { |
|
1260 | + echo 'i'; |
|
1261 | + } |
|
1133 | 1262 | $query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)'; |
1134 | 1263 | try { |
1135 | 1264 | $sth = $Connection->db->prepare($query); |
@@ -1140,13 +1269,19 @@ discard block |
||
1140 | 1269 | } |
1141 | 1270 | } |
1142 | 1271 | if ($i % 90 == 0) { |
1143 | - if ($globalTransaction) $Connection->db->commit(); |
|
1144 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1272 | + if ($globalTransaction) { |
|
1273 | + $Connection->db->commit(); |
|
1274 | + } |
|
1275 | + if ($globalTransaction) { |
|
1276 | + $Connection->db->beginTransaction(); |
|
1277 | + } |
|
1145 | 1278 | } |
1146 | 1279 | $i++; |
1147 | 1280 | } |
1148 | 1281 | fclose($handle); |
1149 | - if ($globalTransaction) $Connection->db->commit(); |
|
1282 | + if ($globalTransaction) { |
|
1283 | + $Connection->db->commit(); |
|
1284 | + } |
|
1150 | 1285 | } |
1151 | 1286 | return ''; |
1152 | 1287 | } |
@@ -1166,11 +1301,15 @@ discard block |
||
1166 | 1301 | if (($handle = fopen($tmp_dir.'modes.tsv', 'r')) !== FALSE) |
1167 | 1302 | { |
1168 | 1303 | $i = 0; |
1169 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1304 | + if ($globalTransaction) { |
|
1305 | + $Connection->db->beginTransaction(); |
|
1306 | + } |
|
1170 | 1307 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1171 | 1308 | { |
1172 | 1309 | if ($i > 0) { |
1173 | - if ($data[1] == 'NULL') $data[1] = $data[0]; |
|
1310 | + if ($data[1] == 'NULL') { |
|
1311 | + $data[1] = $data[0]; |
|
1312 | + } |
|
1174 | 1313 | $query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)'; |
1175 | 1314 | try { |
1176 | 1315 | $sth = $Connection->db->prepare($query); |
@@ -1182,7 +1321,9 @@ discard block |
||
1182 | 1321 | $i++; |
1183 | 1322 | } |
1184 | 1323 | fclose($handle); |
1185 | - if ($globalTransaction) $Connection->db->commit(); |
|
1324 | + if ($globalTransaction) { |
|
1325 | + $Connection->db->commit(); |
|
1326 | + } |
|
1186 | 1327 | } |
1187 | 1328 | return ''; |
1188 | 1329 | } |
@@ -1214,11 +1355,15 @@ discard block |
||
1214 | 1355 | if (($handle = fopen($tmp_dir.'airlines.tsv', 'r')) !== FALSE) |
1215 | 1356 | { |
1216 | 1357 | $i = 0; |
1217 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1358 | + if ($globalTransaction) { |
|
1359 | + $Connection->db->beginTransaction(); |
|
1360 | + } |
|
1218 | 1361 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1219 | 1362 | { |
1220 | 1363 | if ($i > 0) { |
1221 | - if ($data[1] == 'NULL') $data[1] = $data[0]; |
|
1364 | + if ($data[1] == 'NULL') { |
|
1365 | + $data[1] = $data[0]; |
|
1366 | + } |
|
1222 | 1367 | $query = 'INSERT INTO airlines (airline_id,name,alias,iata,icao,callsign,country,active,type,home_link,wikipedia_link,alliance,ban_eu) VALUES (0,:name,:alias,:iata,:icao,:callsign,:country,:active,:type,:home,:wikipedia_link,:alliance,:ban_eu)'; |
1223 | 1368 | try { |
1224 | 1369 | $sth = $Connection->db->prepare($query); |
@@ -1230,7 +1375,9 @@ discard block |
||
1230 | 1375 | $i++; |
1231 | 1376 | } |
1232 | 1377 | fclose($handle); |
1233 | - if ($globalTransaction) $Connection->db->commit(); |
|
1378 | + if ($globalTransaction) { |
|
1379 | + $Connection->db->commit(); |
|
1380 | + } |
|
1234 | 1381 | } |
1235 | 1382 | /* |
1236 | 1383 | $query = "UNLOCK TABLES"; |
@@ -1260,7 +1407,9 @@ discard block |
||
1260 | 1407 | if (($handle = fopen($tmp_dir.'owners.tsv', 'r')) !== FALSE) |
1261 | 1408 | { |
1262 | 1409 | $i = 0; |
1263 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1410 | + if ($globalTransaction) { |
|
1411 | + $Connection->db->beginTransaction(); |
|
1412 | + } |
|
1264 | 1413 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1265 | 1414 | { |
1266 | 1415 | if ($i > 0) { |
@@ -1276,7 +1425,9 @@ discard block |
||
1276 | 1425 | $i++; |
1277 | 1426 | } |
1278 | 1427 | fclose($handle); |
1279 | - if ($globalTransaction) $Connection->db->commit(); |
|
1428 | + if ($globalTransaction) { |
|
1429 | + $Connection->db->commit(); |
|
1430 | + } |
|
1280 | 1431 | } |
1281 | 1432 | return ''; |
1282 | 1433 | } |
@@ -1296,7 +1447,9 @@ discard block |
||
1296 | 1447 | if (($handle = fopen($tmp_dir.'routes.tsv', 'r')) !== FALSE) |
1297 | 1448 | { |
1298 | 1449 | $i = 0; |
1299 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1450 | + if ($globalTransaction) { |
|
1451 | + $Connection->db->beginTransaction(); |
|
1452 | + } |
|
1300 | 1453 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1301 | 1454 | { |
1302 | 1455 | if ($i > 0) { |
@@ -1306,19 +1459,25 @@ discard block |
||
1306 | 1459 | $sth = $Connection->db->prepare($query); |
1307 | 1460 | $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')); |
1308 | 1461 | } catch(PDOException $e) { |
1309 | - if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".implode(',',$data); |
|
1462 | + if ($globalDebug) { |
|
1463 | + echo "error: ".$e->getMessage()." - data: ".implode(',',$data); |
|
1464 | + } |
|
1310 | 1465 | die(); |
1311 | 1466 | } |
1312 | 1467 | } |
1313 | 1468 | if ($globalTransaction && $i % 2000 == 0) { |
1314 | 1469 | $Connection->db->commit(); |
1315 | - if ($globalDebug) echo '.'; |
|
1470 | + if ($globalDebug) { |
|
1471 | + echo '.'; |
|
1472 | + } |
|
1316 | 1473 | $Connection->db->beginTransaction(); |
1317 | 1474 | } |
1318 | 1475 | $i++; |
1319 | 1476 | } |
1320 | 1477 | fclose($handle); |
1321 | - if ($globalTransaction) $Connection->db->commit(); |
|
1478 | + if ($globalTransaction) { |
|
1479 | + $Connection->db->commit(); |
|
1480 | + } |
|
1322 | 1481 | } |
1323 | 1482 | return ''; |
1324 | 1483 | } |
@@ -1337,7 +1496,9 @@ discard block |
||
1337 | 1496 | if (($handle = fopen($tmp_dir.'block.tsv', 'r')) !== FALSE) |
1338 | 1497 | { |
1339 | 1498 | $i = 0; |
1340 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1499 | + if ($globalTransaction) { |
|
1500 | + $Connection->db->beginTransaction(); |
|
1501 | + } |
|
1341 | 1502 | while (($data = fgets($handle, 1000)) !== FALSE) |
1342 | 1503 | { |
1343 | 1504 | $query = 'INSERT INTO aircraft_block (callSign,Source) VALUES (:callSign,:source)'; |
@@ -1345,18 +1506,24 @@ discard block |
||
1345 | 1506 | $sth = $Connection->db->prepare($query); |
1346 | 1507 | $sth->execute(array(':callSign' => trim($data),':source' => 'website_fam')); |
1347 | 1508 | } catch(PDOException $e) { |
1348 | - if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".$data; |
|
1509 | + if ($globalDebug) { |
|
1510 | + echo "error: ".$e->getMessage()." - data: ".$data; |
|
1511 | + } |
|
1349 | 1512 | die(); |
1350 | 1513 | } |
1351 | 1514 | if ($globalTransaction && $i % 2000 == 0) { |
1352 | 1515 | $Connection->db->commit(); |
1353 | - if ($globalDebug) echo '.'; |
|
1516 | + if ($globalDebug) { |
|
1517 | + echo '.'; |
|
1518 | + } |
|
1354 | 1519 | $Connection->db->beginTransaction(); |
1355 | 1520 | } |
1356 | 1521 | $i++; |
1357 | 1522 | } |
1358 | 1523 | fclose($handle); |
1359 | - if ($globalTransaction) $Connection->db->commit(); |
|
1524 | + if ($globalTransaction) { |
|
1525 | + $Connection->db->commit(); |
|
1526 | + } |
|
1360 | 1527 | } |
1361 | 1528 | return ''; |
1362 | 1529 | } |
@@ -1381,7 +1548,9 @@ discard block |
||
1381 | 1548 | $i = 0; |
1382 | 1549 | //$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE); |
1383 | 1550 | //$Connection->db->beginTransaction(); |
1384 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1551 | + if ($globalTransaction) { |
|
1552 | + $Connection->db->beginTransaction(); |
|
1553 | + } |
|
1385 | 1554 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1386 | 1555 | { |
1387 | 1556 | if ($i > 0) { |
@@ -1397,7 +1566,9 @@ discard block |
||
1397 | 1566 | $i++; |
1398 | 1567 | } |
1399 | 1568 | fclose($handle); |
1400 | - if ($globalTransaction) $Connection->db->commit(); |
|
1569 | + if ($globalTransaction) { |
|
1570 | + $Connection->db->commit(); |
|
1571 | + } |
|
1401 | 1572 | } |
1402 | 1573 | return ''; |
1403 | 1574 | } |
@@ -1417,7 +1588,9 @@ discard block |
||
1417 | 1588 | if (($handle = fopen($tmp_dir.'satellite.tsv', 'r')) !== FALSE) |
1418 | 1589 | { |
1419 | 1590 | $i = 0; |
1420 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1591 | + if ($globalTransaction) { |
|
1592 | + $Connection->db->beginTransaction(); |
|
1593 | + } |
|
1421 | 1594 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1422 | 1595 | { |
1423 | 1596 | if ($i > 0) { |
@@ -1434,7 +1607,9 @@ discard block |
||
1434 | 1607 | $i++; |
1435 | 1608 | } |
1436 | 1609 | fclose($handle); |
1437 | - if ($globalTransaction) $Connection->db->commit(); |
|
1610 | + if ($globalTransaction) { |
|
1611 | + $Connection->db->commit(); |
|
1612 | + } |
|
1438 | 1613 | } |
1439 | 1614 | return ''; |
1440 | 1615 | } |
@@ -1453,7 +1628,9 @@ discard block |
||
1453 | 1628 | $Connection = new Connection(); |
1454 | 1629 | if (($handle = fopen($tmp_dir.'ban_eu.csv', 'r')) !== FALSE) |
1455 | 1630 | { |
1456 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1631 | + if ($globalTransaction) { |
|
1632 | + $Connection->db->beginTransaction(); |
|
1633 | + } |
|
1457 | 1634 | while (($data = fgetcsv($handle, 1000)) !== FALSE) |
1458 | 1635 | { |
1459 | 1636 | $query = 'UPDATE airlines SET ban_eu = 1 WHERE icao = :icao AND forsource IS NULL'; |
@@ -1468,7 +1645,9 @@ discard block |
||
1468 | 1645 | } |
1469 | 1646 | } |
1470 | 1647 | fclose($handle); |
1471 | - if ($globalTransaction) $Connection->db->commit(); |
|
1648 | + if ($globalTransaction) { |
|
1649 | + $Connection->db->commit(); |
|
1650 | + } |
|
1472 | 1651 | } |
1473 | 1652 | return ''; |
1474 | 1653 | } |
@@ -1546,9 +1725,14 @@ discard block |
||
1546 | 1725 | if ($i > 0 && $data[0] != '') { |
1547 | 1726 | $sources = trim($data[28].' '.$data[29].' '.$data[30].' '.$data[31].' '.$data[32].' '.$data[33]); |
1548 | 1727 | $period = str_replace(',','',$data[14]); |
1549 | - if (!empty($period) && strpos($period,'days')) $period = str_replace(' days','',$period)*24*60; |
|
1550 | - if ($data[18] != '') $launch_date = date('Y-m-d',strtotime($data[18])); |
|
1551 | - else $launch_date = NULL; |
|
1728 | + if (!empty($period) && strpos($period,'days')) { |
|
1729 | + $period = str_replace(' days','',$period)*24*60; |
|
1730 | + } |
|
1731 | + if ($data[18] != '') { |
|
1732 | + $launch_date = date('Y-m-d',strtotime($data[18])); |
|
1733 | + } else { |
|
1734 | + $launch_date = NULL; |
|
1735 | + } |
|
1552 | 1736 | $data = array_map(function($value) { |
1553 | 1737 | return trim($value) === '' ? null : $value; |
1554 | 1738 | }, $data); |
@@ -1740,10 +1924,14 @@ discard block |
||
1740 | 1924 | $owner_code = trim(substr($data,49,5)); |
1741 | 1925 | |
1742 | 1926 | if (!isset($satcat_sources[$owner_code]) && $owner_code != 'TBD') { |
1743 | - if ($globalDebug) echo $data.'owner_code: '.$owner_code."\n"; |
|
1927 | + if ($globalDebug) { |
|
1928 | + echo $data.'owner_code: '.$owner_code."\n"; |
|
1929 | + } |
|
1744 | 1930 | } |
1745 | 1931 | if (!isset($satcat_launch_site[trim(substr($data,68,5))])) { |
1746 | - if ($globalDebug) echo 'launch_site_code: '.trim(substr($data,68,5))."\n"; |
|
1932 | + if ($globalDebug) { |
|
1933 | + echo 'launch_site_code: '.trim(substr($data,68,5))."\n"; |
|
1934 | + } |
|
1747 | 1935 | } |
1748 | 1936 | |
1749 | 1937 | if ($owner_code != 'TBD' && isset($satcat_sources[$owner_code]) && isset($satcat_launch_site[trim(substr($data,68,5))])) { |
@@ -1910,7 +2098,9 @@ discard block |
||
1910 | 2098 | if (($handle = fopen($filename, 'r')) !== FALSE) |
1911 | 2099 | { |
1912 | 2100 | $i = 0; |
1913 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
2101 | + if ($globalTransaction) { |
|
2102 | + $Connection->db->beginTransaction(); |
|
2103 | + } |
|
1914 | 2104 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1915 | 2105 | { |
1916 | 2106 | $i++; |
@@ -1938,7 +2128,9 @@ discard block |
||
1938 | 2128 | } |
1939 | 2129 | } |
1940 | 2130 | fclose($handle); |
1941 | - if ($globalTransaction) $Connection->db->commit(); |
|
2131 | + if ($globalTransaction) { |
|
2132 | + $Connection->db->commit(); |
|
2133 | + } |
|
1942 | 2134 | } |
1943 | 2135 | return ''; |
1944 | 2136 | } |
@@ -1954,7 +2146,9 @@ discard block |
||
1954 | 2146 | $Source->deleteLocationByType('fires'); |
1955 | 2147 | $i = 0; |
1956 | 2148 | if (($handle = fopen($tmp_dir.'fires.csv','r')) !== false) { |
1957 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
2149 | + if ($globalTransaction) { |
|
2150 | + $Connection->db->beginTransaction(); |
|
2151 | + } |
|
1958 | 2152 | while (($row = fgetcsv($handle,1000)) !== false) { |
1959 | 2153 | if ($i > 0 && $row[0] != '' && $row[8] != 'low') { |
1960 | 2154 | $description = array('bright_t14' => $row[2],'scan' => $row[3],'track' => $row[4],'sat' => $row[7],'confidence' => $row[8],'version' => $row[9],'bright_t15' => $row[10],'frp' => $row[11],'daynight' => $row[12]); |
@@ -1969,7 +2163,9 @@ discard block |
||
1969 | 2163 | } |
1970 | 2164 | $i++; |
1971 | 2165 | } |
1972 | - if ($globalTransaction) $Connection->db->commit(); |
|
2166 | + if ($globalTransaction) { |
|
2167 | + $Connection->db->commit(); |
|
2168 | + } |
|
1973 | 2169 | } |
1974 | 2170 | } |
1975 | 2171 | |
@@ -1990,7 +2186,9 @@ discard block |
||
1990 | 2186 | $Connection = new Connection(); |
1991 | 2187 | if (($handle = fopen($filename, 'r')) !== FALSE) |
1992 | 2188 | { |
1993 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
2189 | + if ($globalTransaction) { |
|
2190 | + $Connection->db->beginTransaction(); |
|
2191 | + } |
|
1994 | 2192 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1995 | 2193 | { |
1996 | 2194 | if(count($row) > 1) { |
@@ -2004,7 +2202,9 @@ discard block |
||
2004 | 2202 | } |
2005 | 2203 | } |
2006 | 2204 | fclose($handle); |
2007 | - if ($globalTransaction) $Connection->db->commit(); |
|
2205 | + if ($globalTransaction) { |
|
2206 | + $Connection->db->commit(); |
|
2207 | + } |
|
2008 | 2208 | } |
2009 | 2209 | return ''; |
2010 | 2210 | } |
@@ -2024,8 +2224,9 @@ discard block |
||
2024 | 2224 | } |
2025 | 2225 | |
2026 | 2226 | |
2027 | - if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
2028 | - else { |
|
2227 | + if ($globalDBdriver == 'mysql') { |
|
2228 | + update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
2229 | + } else { |
|
2029 | 2230 | update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
2030 | 2231 | $query = "CREATE EXTENSION postgis"; |
2031 | 2232 | $Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']); |
@@ -2044,7 +2245,9 @@ discard block |
||
2044 | 2245 | global $tmp_dir, $globalDebug; |
2045 | 2246 | include_once('class.create_db.php'); |
2046 | 2247 | require_once(dirname(__FILE__).'/../require/class.NOTAM.php'); |
2047 | - if ($globalDebug) echo "NOTAM from FlightAirMap website : Download..."; |
|
2248 | + if ($globalDebug) { |
|
2249 | + echo "NOTAM from FlightAirMap website : Download..."; |
|
2250 | + } |
|
2048 | 2251 | update_db::download('http://data.flightairmap.com/data/notam.txt.gz.md5',$tmp_dir.'notam.txt.gz.md5'); |
2049 | 2252 | $error = ''; |
2050 | 2253 | if (file_exists($tmp_dir.'notam.txt.gz.md5')) { |
@@ -2054,20 +2257,34 @@ discard block |
||
2054 | 2257 | update_db::download('http://data.flightairmap.com/data/notam.txt.gz',$tmp_dir.'notam.txt.gz'); |
2055 | 2258 | if (file_exists($tmp_dir.'notam.txt.gz')) { |
2056 | 2259 | if (md5_file($tmp_dir.'notam.txt.gz') == $notam_md5) { |
2057 | - if ($globalDebug) echo "Gunzip..."; |
|
2260 | + if ($globalDebug) { |
|
2261 | + echo "Gunzip..."; |
|
2262 | + } |
|
2058 | 2263 | update_db::gunzip($tmp_dir.'notam.txt.gz'); |
2059 | - if ($globalDebug) echo "Add to DB..."; |
|
2264 | + if ($globalDebug) { |
|
2265 | + echo "Add to DB..."; |
|
2266 | + } |
|
2060 | 2267 | //$error = create_db::import_file($tmp_dir.'notam.sql'); |
2061 | 2268 | $NOTAM = new NOTAM(); |
2062 | 2269 | $NOTAM->updateNOTAMfromTextFile($tmp_dir.'notam.txt'); |
2063 | 2270 | update_db::insert_notam_version($notam_md5); |
2064 | - } else $error = "File ".$tmp_dir.'notam.txt.gz'." md5 failed. Download failed."; |
|
2065 | - } else $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed."; |
|
2066 | - } elseif ($globalDebug) echo "No new version."; |
|
2067 | - } else $error = "File ".$tmp_dir.'notam.txt.gz.md5'." doesn't exist. Download failed."; |
|
2271 | + } else { |
|
2272 | + $error = "File ".$tmp_dir.'notam.txt.gz'." md5 failed. Download failed."; |
|
2273 | + } |
|
2274 | + } else { |
|
2275 | + $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed."; |
|
2276 | + } |
|
2277 | + } elseif ($globalDebug) { |
|
2278 | + echo "No new version."; |
|
2279 | + } |
|
2280 | + } else { |
|
2281 | + $error = "File ".$tmp_dir.'notam.txt.gz.md5'." doesn't exist. Download failed."; |
|
2282 | + } |
|
2068 | 2283 | if ($error != '') { |
2069 | 2284 | return $error; |
2070 | - } elseif ($globalDebug) echo "Done\n"; |
|
2285 | + } elseif ($globalDebug) { |
|
2286 | + echo "Done\n"; |
|
2287 | + } |
|
2071 | 2288 | return ''; |
2072 | 2289 | } |
2073 | 2290 | |
@@ -2122,68 +2339,114 @@ discard block |
||
2122 | 2339 | //update_db::download('http://fr.mirror.ivao.aero/software/ivae_feb2013.zip',$tmp_dir.'ivae_feb2013.zip'); |
2123 | 2340 | if (extension_loaded('zip')) { |
2124 | 2341 | if (file_exists($tmp_dir.'ivae_feb2013.zip')) { |
2125 | - if ($globalDebug) echo "Unzip..."; |
|
2342 | + if ($globalDebug) { |
|
2343 | + echo "Unzip..."; |
|
2344 | + } |
|
2126 | 2345 | update_db::unzip($tmp_dir.'ivae_feb2013.zip'); |
2127 | - if ($globalDebug) echo "Add to DB..."; |
|
2346 | + if ($globalDebug) { |
|
2347 | + echo "Add to DB..."; |
|
2348 | + } |
|
2128 | 2349 | update_db::ivao_airlines($tmp_dir.'data/airlines.dat'); |
2129 | - if ($globalDebug) echo "Copy airlines logos to airlines images directory..."; |
|
2350 | + if ($globalDebug) { |
|
2351 | + echo "Copy airlines logos to airlines images directory..."; |
|
2352 | + } |
|
2130 | 2353 | if (is_writable(dirname(__FILE__).'/../images/airlines')) { |
2131 | - if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
2132 | - } else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
|
2133 | - } else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
|
2134 | - } else $error = "ZIP module not loaded but required for IVAO."; |
|
2354 | + if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) { |
|
2355 | + $error = "Failed to copy airlines logo."; |
|
2356 | + } |
|
2357 | + } else { |
|
2358 | + $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
|
2359 | + } |
|
2360 | + } else { |
|
2361 | + $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
|
2362 | + } |
|
2363 | + } else { |
|
2364 | + $error = "ZIP module not loaded but required for IVAO."; |
|
2365 | + } |
|
2135 | 2366 | if ($error != '') { |
2136 | 2367 | return $error; |
2137 | - } elseif ($globalDebug) echo "Done\n"; |
|
2368 | + } elseif ($globalDebug) { |
|
2369 | + echo "Done\n"; |
|
2370 | + } |
|
2138 | 2371 | return ''; |
2139 | 2372 | } |
2140 | 2373 | |
2141 | 2374 | public static function update_routes() { |
2142 | 2375 | global $tmp_dir, $globalDebug; |
2143 | 2376 | $error = ''; |
2144 | - if ($globalDebug) echo "Routes : Download..."; |
|
2377 | + if ($globalDebug) { |
|
2378 | + echo "Routes : Download..."; |
|
2379 | + } |
|
2145 | 2380 | update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz'); |
2146 | 2381 | if (file_exists($tmp_dir.'StandingData.sqb.gz')) { |
2147 | - if ($globalDebug) echo "Gunzip..."; |
|
2382 | + if ($globalDebug) { |
|
2383 | + echo "Gunzip..."; |
|
2384 | + } |
|
2148 | 2385 | update_db::gunzip($tmp_dir.'StandingData.sqb.gz'); |
2149 | - if ($globalDebug) echo "Add to DB..."; |
|
2386 | + if ($globalDebug) { |
|
2387 | + echo "Add to DB..."; |
|
2388 | + } |
|
2150 | 2389 | $error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb'); |
2151 | - } else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed."; |
|
2390 | + } else { |
|
2391 | + $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed."; |
|
2392 | + } |
|
2152 | 2393 | if ($error != '') { |
2153 | 2394 | return $error; |
2154 | - } elseif ($globalDebug) echo "Done\n"; |
|
2395 | + } elseif ($globalDebug) { |
|
2396 | + echo "Done\n"; |
|
2397 | + } |
|
2155 | 2398 | return ''; |
2156 | 2399 | } |
2157 | 2400 | public static function update_oneworld() { |
2158 | 2401 | global $tmp_dir, $globalDebug; |
2159 | 2402 | $error = ''; |
2160 | - if ($globalDebug) echo "Schedules Oneworld : Download..."; |
|
2403 | + if ($globalDebug) { |
|
2404 | + echo "Schedules Oneworld : Download..."; |
|
2405 | + } |
|
2161 | 2406 | update_db::download('http://data.flightairmap.com/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz'); |
2162 | 2407 | if (file_exists($tmp_dir.'oneworld.csv.gz')) { |
2163 | - if ($globalDebug) echo "Gunzip..."; |
|
2408 | + if ($globalDebug) { |
|
2409 | + echo "Gunzip..."; |
|
2410 | + } |
|
2164 | 2411 | update_db::gunzip($tmp_dir.'oneworld.csv.gz'); |
2165 | - if ($globalDebug) echo "Add to DB..."; |
|
2412 | + if ($globalDebug) { |
|
2413 | + echo "Add to DB..."; |
|
2414 | + } |
|
2166 | 2415 | $error = update_db::retrieve_route_oneworld($tmp_dir.'oneworld.csv'); |
2167 | - } else $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed."; |
|
2416 | + } else { |
|
2417 | + $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed."; |
|
2418 | + } |
|
2168 | 2419 | if ($error != '') { |
2169 | 2420 | return $error; |
2170 | - } elseif ($globalDebug) echo "Done\n"; |
|
2421 | + } elseif ($globalDebug) { |
|
2422 | + echo "Done\n"; |
|
2423 | + } |
|
2171 | 2424 | return ''; |
2172 | 2425 | } |
2173 | 2426 | public static function update_skyteam() { |
2174 | 2427 | global $tmp_dir, $globalDebug; |
2175 | 2428 | $error = ''; |
2176 | - if ($globalDebug) echo "Schedules Skyteam : Download..."; |
|
2429 | + if ($globalDebug) { |
|
2430 | + echo "Schedules Skyteam : Download..."; |
|
2431 | + } |
|
2177 | 2432 | update_db::download('http://data.flightairmap.com/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz'); |
2178 | 2433 | if (file_exists($tmp_dir.'skyteam.csv.gz')) { |
2179 | - if ($globalDebug) echo "Gunzip..."; |
|
2434 | + if ($globalDebug) { |
|
2435 | + echo "Gunzip..."; |
|
2436 | + } |
|
2180 | 2437 | update_db::gunzip($tmp_dir.'skyteam.csv.gz'); |
2181 | - if ($globalDebug) echo "Add to DB..."; |
|
2438 | + if ($globalDebug) { |
|
2439 | + echo "Add to DB..."; |
|
2440 | + } |
|
2182 | 2441 | $error = update_db::retrieve_route_skyteam($tmp_dir.'skyteam.csv'); |
2183 | - } else $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed."; |
|
2442 | + } else { |
|
2443 | + $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed."; |
|
2444 | + } |
|
2184 | 2445 | if ($error != '') { |
2185 | 2446 | return $error; |
2186 | - } elseif ($globalDebug) echo "Done\n"; |
|
2447 | + } elseif ($globalDebug) { |
|
2448 | + echo "Done\n"; |
|
2449 | + } |
|
2187 | 2450 | return ''; |
2188 | 2451 | } |
2189 | 2452 | public static function update_ModeS() { |
@@ -2200,340 +2463,590 @@ discard block |
||
2200 | 2463 | exit; |
2201 | 2464 | } elseif ($globalDebug) echo "Done\n"; |
2202 | 2465 | */ |
2203 | - if ($globalDebug) echo "Modes : Download..."; |
|
2204 | -// update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
|
2466 | + if ($globalDebug) { |
|
2467 | + echo "Modes : Download..."; |
|
2468 | + } |
|
2469 | + // update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
|
2205 | 2470 | update_db::download('http://data.flightairmap.com/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz'); |
2206 | 2471 | |
2207 | 2472 | // if (file_exists($tmp_dir.'basestation_latest.zip')) { |
2208 | 2473 | if (file_exists($tmp_dir.'BaseStation.sqb.gz')) { |
2209 | - if ($globalDebug) echo "Unzip..."; |
|
2210 | -// update_db::unzip($tmp_dir.'basestation_latest.zip'); |
|
2474 | + if ($globalDebug) { |
|
2475 | + echo "Unzip..."; |
|
2476 | + } |
|
2477 | + // update_db::unzip($tmp_dir.'basestation_latest.zip'); |
|
2211 | 2478 | update_db::gunzip($tmp_dir.'BaseStation.sqb.gz'); |
2212 | - if ($globalDebug) echo "Add to DB..."; |
|
2479 | + if ($globalDebug) { |
|
2480 | + echo "Add to DB..."; |
|
2481 | + } |
|
2213 | 2482 | $error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb'); |
2214 | 2483 | // $error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'basestation.sqb'); |
2215 | - } else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed."; |
|
2484 | + } else { |
|
2485 | + $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed."; |
|
2486 | + } |
|
2216 | 2487 | if ($error != '') { |
2217 | 2488 | return $error; |
2218 | - } elseif ($globalDebug) echo "Done\n"; |
|
2489 | + } elseif ($globalDebug) { |
|
2490 | + echo "Done\n"; |
|
2491 | + } |
|
2219 | 2492 | return ''; |
2220 | 2493 | } |
2221 | 2494 | |
2222 | 2495 | public static function update_ModeS_faa() { |
2223 | 2496 | global $tmp_dir, $globalDebug; |
2224 | - if ($globalDebug) echo "Modes FAA: Download..."; |
|
2497 | + if ($globalDebug) { |
|
2498 | + echo "Modes FAA: Download..."; |
|
2499 | + } |
|
2225 | 2500 | update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip'); |
2226 | 2501 | if (file_exists($tmp_dir.'ReleasableAircraft.zip')) { |
2227 | - if ($globalDebug) echo "Unzip..."; |
|
2502 | + if ($globalDebug) { |
|
2503 | + echo "Unzip..."; |
|
2504 | + } |
|
2228 | 2505 | update_db::unzip($tmp_dir.'ReleasableAircraft.zip'); |
2229 | - if ($globalDebug) echo "Add to DB..."; |
|
2506 | + if ($globalDebug) { |
|
2507 | + echo "Add to DB..."; |
|
2508 | + } |
|
2230 | 2509 | $error = update_db::modes_faa(); |
2231 | - } else $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed."; |
|
2510 | + } else { |
|
2511 | + $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed."; |
|
2512 | + } |
|
2232 | 2513 | if ($error != '') { |
2233 | 2514 | return $error; |
2234 | - } elseif ($globalDebug) echo "Done\n"; |
|
2515 | + } elseif ($globalDebug) { |
|
2516 | + echo "Done\n"; |
|
2517 | + } |
|
2235 | 2518 | return ''; |
2236 | 2519 | } |
2237 | 2520 | |
2238 | 2521 | public static function update_ModeS_flarm() { |
2239 | 2522 | global $tmp_dir, $globalDebug; |
2240 | - if ($globalDebug) echo "Modes Flarmnet: Download..."; |
|
2523 | + if ($globalDebug) { |
|
2524 | + echo "Modes Flarmnet: Download..."; |
|
2525 | + } |
|
2241 | 2526 | update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln'); |
2242 | 2527 | if (file_exists($tmp_dir.'data.fln')) { |
2243 | - if ($globalDebug) echo "Add to DB..."; |
|
2528 | + if ($globalDebug) { |
|
2529 | + echo "Add to DB..."; |
|
2530 | + } |
|
2244 | 2531 | $error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln'); |
2245 | - } else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed."; |
|
2532 | + } else { |
|
2533 | + $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed."; |
|
2534 | + } |
|
2246 | 2535 | if ($error != '') { |
2247 | 2536 | return $error; |
2248 | - } elseif ($globalDebug) echo "Done\n"; |
|
2537 | + } elseif ($globalDebug) { |
|
2538 | + echo "Done\n"; |
|
2539 | + } |
|
2249 | 2540 | return ''; |
2250 | 2541 | } |
2251 | 2542 | |
2252 | 2543 | public static function update_ModeS_ogn() { |
2253 | 2544 | global $tmp_dir, $globalDebug; |
2254 | - if ($globalDebug) echo "Modes OGN: Download..."; |
|
2545 | + if ($globalDebug) { |
|
2546 | + echo "Modes OGN: Download..."; |
|
2547 | + } |
|
2255 | 2548 | update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv'); |
2256 | 2549 | if (file_exists($tmp_dir.'ogn.csv')) { |
2257 | - if ($globalDebug) echo "Add to DB..."; |
|
2550 | + if ($globalDebug) { |
|
2551 | + echo "Add to DB..."; |
|
2552 | + } |
|
2258 | 2553 | $error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv'); |
2259 | - } else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed."; |
|
2554 | + } else { |
|
2555 | + $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed."; |
|
2556 | + } |
|
2260 | 2557 | if ($error != '') { |
2261 | 2558 | return $error; |
2262 | - } elseif ($globalDebug) echo "Done\n"; |
|
2559 | + } elseif ($globalDebug) { |
|
2560 | + echo "Done\n"; |
|
2561 | + } |
|
2263 | 2562 | return ''; |
2264 | 2563 | } |
2265 | 2564 | |
2266 | 2565 | public static function update_owner() { |
2267 | 2566 | global $tmp_dir, $globalDebug, $globalMasterSource; |
2268 | 2567 | |
2269 | - if ($globalDebug) echo "Owner France: Download..."; |
|
2568 | + if ($globalDebug) { |
|
2569 | + echo "Owner France: Download..."; |
|
2570 | + } |
|
2270 | 2571 | update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv'); |
2271 | 2572 | if (file_exists($tmp_dir.'owner_f.csv')) { |
2272 | - if ($globalDebug) echo "Add to DB..."; |
|
2573 | + if ($globalDebug) { |
|
2574 | + echo "Add to DB..."; |
|
2575 | + } |
|
2273 | 2576 | $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F'); |
2274 | - } else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
|
2577 | + } else { |
|
2578 | + $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
|
2579 | + } |
|
2275 | 2580 | if ($error != '') { |
2276 | 2581 | return $error; |
2277 | - } elseif ($globalDebug) echo "Done\n"; |
|
2582 | + } elseif ($globalDebug) { |
|
2583 | + echo "Done\n"; |
|
2584 | + } |
|
2278 | 2585 | |
2279 | - if ($globalDebug) echo "Owner Ireland: Download..."; |
|
2586 | + if ($globalDebug) { |
|
2587 | + echo "Owner Ireland: Download..."; |
|
2588 | + } |
|
2280 | 2589 | update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv'); |
2281 | 2590 | if (file_exists($tmp_dir.'owner_ei.csv')) { |
2282 | - if ($globalDebug) echo "Add to DB..."; |
|
2591 | + if ($globalDebug) { |
|
2592 | + echo "Add to DB..."; |
|
2593 | + } |
|
2283 | 2594 | $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI'); |
2284 | - } else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
|
2595 | + } else { |
|
2596 | + $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
|
2597 | + } |
|
2285 | 2598 | if ($error != '') { |
2286 | 2599 | return $error; |
2287 | - } elseif ($globalDebug) echo "Done\n"; |
|
2288 | - if ($globalDebug) echo "Owner Switzerland: Download..."; |
|
2600 | + } elseif ($globalDebug) { |
|
2601 | + echo "Done\n"; |
|
2602 | + } |
|
2603 | + if ($globalDebug) { |
|
2604 | + echo "Owner Switzerland: Download..."; |
|
2605 | + } |
|
2289 | 2606 | update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv'); |
2290 | 2607 | if (file_exists($tmp_dir.'owner_hb.csv')) { |
2291 | - if ($globalDebug) echo "Add to DB..."; |
|
2608 | + if ($globalDebug) { |
|
2609 | + echo "Add to DB..."; |
|
2610 | + } |
|
2292 | 2611 | $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB'); |
2293 | - } else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
|
2612 | + } else { |
|
2613 | + $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
|
2614 | + } |
|
2294 | 2615 | if ($error != '') { |
2295 | 2616 | return $error; |
2296 | - } elseif ($globalDebug) echo "Done\n"; |
|
2297 | - if ($globalDebug) echo "Owner Czech Republic: Download..."; |
|
2617 | + } elseif ($globalDebug) { |
|
2618 | + echo "Done\n"; |
|
2619 | + } |
|
2620 | + if ($globalDebug) { |
|
2621 | + echo "Owner Czech Republic: Download..."; |
|
2622 | + } |
|
2298 | 2623 | update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv'); |
2299 | 2624 | if (file_exists($tmp_dir.'owner_ok.csv')) { |
2300 | - if ($globalDebug) echo "Add to DB..."; |
|
2625 | + if ($globalDebug) { |
|
2626 | + echo "Add to DB..."; |
|
2627 | + } |
|
2301 | 2628 | $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK'); |
2302 | - } else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
|
2629 | + } else { |
|
2630 | + $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
|
2631 | + } |
|
2303 | 2632 | if ($error != '') { |
2304 | 2633 | return $error; |
2305 | - } elseif ($globalDebug) echo "Done\n"; |
|
2306 | - if ($globalDebug) echo "Owner Australia: Download..."; |
|
2634 | + } elseif ($globalDebug) { |
|
2635 | + echo "Done\n"; |
|
2636 | + } |
|
2637 | + if ($globalDebug) { |
|
2638 | + echo "Owner Australia: Download..."; |
|
2639 | + } |
|
2307 | 2640 | update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv'); |
2308 | 2641 | if (file_exists($tmp_dir.'owner_vh.csv')) { |
2309 | - if ($globalDebug) echo "Add to DB..."; |
|
2642 | + if ($globalDebug) { |
|
2643 | + echo "Add to DB..."; |
|
2644 | + } |
|
2310 | 2645 | $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH'); |
2311 | - } else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
|
2646 | + } else { |
|
2647 | + $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
|
2648 | + } |
|
2312 | 2649 | if ($error != '') { |
2313 | 2650 | return $error; |
2314 | - } elseif ($globalDebug) echo "Done\n"; |
|
2315 | - if ($globalDebug) echo "Owner Austria: Download..."; |
|
2651 | + } elseif ($globalDebug) { |
|
2652 | + echo "Done\n"; |
|
2653 | + } |
|
2654 | + if ($globalDebug) { |
|
2655 | + echo "Owner Austria: Download..."; |
|
2656 | + } |
|
2316 | 2657 | update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv'); |
2317 | 2658 | if (file_exists($tmp_dir.'owner_oe.csv')) { |
2318 | - if ($globalDebug) echo "Add to DB..."; |
|
2659 | + if ($globalDebug) { |
|
2660 | + echo "Add to DB..."; |
|
2661 | + } |
|
2319 | 2662 | $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE'); |
2320 | - } else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
|
2663 | + } else { |
|
2664 | + $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
|
2665 | + } |
|
2321 | 2666 | if ($error != '') { |
2322 | 2667 | return $error; |
2323 | - } elseif ($globalDebug) echo "Done\n"; |
|
2324 | - if ($globalDebug) echo "Owner Chile: Download..."; |
|
2668 | + } elseif ($globalDebug) { |
|
2669 | + echo "Done\n"; |
|
2670 | + } |
|
2671 | + if ($globalDebug) { |
|
2672 | + echo "Owner Chile: Download..."; |
|
2673 | + } |
|
2325 | 2674 | update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv'); |
2326 | 2675 | if (file_exists($tmp_dir.'owner_cc.csv')) { |
2327 | - if ($globalDebug) echo "Add to DB..."; |
|
2676 | + if ($globalDebug) { |
|
2677 | + echo "Add to DB..."; |
|
2678 | + } |
|
2328 | 2679 | $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC'); |
2329 | - } else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
|
2680 | + } else { |
|
2681 | + $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
|
2682 | + } |
|
2330 | 2683 | if ($error != '') { |
2331 | 2684 | return $error; |
2332 | - } elseif ($globalDebug) echo "Done\n"; |
|
2333 | - if ($globalDebug) echo "Owner Colombia: Download..."; |
|
2685 | + } elseif ($globalDebug) { |
|
2686 | + echo "Done\n"; |
|
2687 | + } |
|
2688 | + if ($globalDebug) { |
|
2689 | + echo "Owner Colombia: Download..."; |
|
2690 | + } |
|
2334 | 2691 | update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv'); |
2335 | 2692 | if (file_exists($tmp_dir.'owner_hj.csv')) { |
2336 | - if ($globalDebug) echo "Add to DB..."; |
|
2693 | + if ($globalDebug) { |
|
2694 | + echo "Add to DB..."; |
|
2695 | + } |
|
2337 | 2696 | $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ'); |
2338 | - } else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
|
2697 | + } else { |
|
2698 | + $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
|
2699 | + } |
|
2339 | 2700 | if ($error != '') { |
2340 | 2701 | return $error; |
2341 | - } elseif ($globalDebug) echo "Done\n"; |
|
2342 | - if ($globalDebug) echo "Owner Bosnia Herzegobina: Download..."; |
|
2702 | + } elseif ($globalDebug) { |
|
2703 | + echo "Done\n"; |
|
2704 | + } |
|
2705 | + if ($globalDebug) { |
|
2706 | + echo "Owner Bosnia Herzegobina: Download..."; |
|
2707 | + } |
|
2343 | 2708 | update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv'); |
2344 | 2709 | if (file_exists($tmp_dir.'owner_e7.csv')) { |
2345 | - if ($globalDebug) echo "Add to DB..."; |
|
2710 | + if ($globalDebug) { |
|
2711 | + echo "Add to DB..."; |
|
2712 | + } |
|
2346 | 2713 | $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7'); |
2347 | - } else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
|
2714 | + } else { |
|
2715 | + $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
|
2716 | + } |
|
2348 | 2717 | if ($error != '') { |
2349 | 2718 | return $error; |
2350 | - } elseif ($globalDebug) echo "Done\n"; |
|
2351 | - if ($globalDebug) echo "Owner Brazil: Download..."; |
|
2719 | + } elseif ($globalDebug) { |
|
2720 | + echo "Done\n"; |
|
2721 | + } |
|
2722 | + if ($globalDebug) { |
|
2723 | + echo "Owner Brazil: Download..."; |
|
2724 | + } |
|
2352 | 2725 | update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv'); |
2353 | 2726 | if (file_exists($tmp_dir.'owner_pp.csv')) { |
2354 | - if ($globalDebug) echo "Add to DB..."; |
|
2727 | + if ($globalDebug) { |
|
2728 | + echo "Add to DB..."; |
|
2729 | + } |
|
2355 | 2730 | $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP'); |
2356 | - } else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
|
2731 | + } else { |
|
2732 | + $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
|
2733 | + } |
|
2357 | 2734 | if ($error != '') { |
2358 | 2735 | return $error; |
2359 | - } elseif ($globalDebug) echo "Done\n"; |
|
2360 | - if ($globalDebug) echo "Owner Cayman Islands: Download..."; |
|
2736 | + } elseif ($globalDebug) { |
|
2737 | + echo "Done\n"; |
|
2738 | + } |
|
2739 | + if ($globalDebug) { |
|
2740 | + echo "Owner Cayman Islands: Download..."; |
|
2741 | + } |
|
2361 | 2742 | update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv'); |
2362 | 2743 | if (file_exists($tmp_dir.'owner_vp.csv')) { |
2363 | - if ($globalDebug) echo "Add to DB..."; |
|
2744 | + if ($globalDebug) { |
|
2745 | + echo "Add to DB..."; |
|
2746 | + } |
|
2364 | 2747 | $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP'); |
2365 | - } else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
|
2748 | + } else { |
|
2749 | + $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
|
2750 | + } |
|
2366 | 2751 | if ($error != '') { |
2367 | 2752 | return $error; |
2368 | - } elseif ($globalDebug) echo "Done\n"; |
|
2369 | - if ($globalDebug) echo "Owner Croatia: Download..."; |
|
2753 | + } elseif ($globalDebug) { |
|
2754 | + echo "Done\n"; |
|
2755 | + } |
|
2756 | + if ($globalDebug) { |
|
2757 | + echo "Owner Croatia: Download..."; |
|
2758 | + } |
|
2370 | 2759 | update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv'); |
2371 | 2760 | if (file_exists($tmp_dir.'owner_9a.csv')) { |
2372 | - if ($globalDebug) echo "Add to DB..."; |
|
2761 | + if ($globalDebug) { |
|
2762 | + echo "Add to DB..."; |
|
2763 | + } |
|
2373 | 2764 | $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A'); |
2374 | - } else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
|
2765 | + } else { |
|
2766 | + $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
|
2767 | + } |
|
2375 | 2768 | if ($error != '') { |
2376 | 2769 | return $error; |
2377 | - } elseif ($globalDebug) echo "Done\n"; |
|
2378 | - if ($globalDebug) echo "Owner Luxembourg: Download..."; |
|
2770 | + } elseif ($globalDebug) { |
|
2771 | + echo "Done\n"; |
|
2772 | + } |
|
2773 | + if ($globalDebug) { |
|
2774 | + echo "Owner Luxembourg: Download..."; |
|
2775 | + } |
|
2379 | 2776 | update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv'); |
2380 | 2777 | if (file_exists($tmp_dir.'owner_lx.csv')) { |
2381 | - if ($globalDebug) echo "Add to DB..."; |
|
2778 | + if ($globalDebug) { |
|
2779 | + echo "Add to DB..."; |
|
2780 | + } |
|
2382 | 2781 | $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX'); |
2383 | - } else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
|
2782 | + } else { |
|
2783 | + $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
|
2784 | + } |
|
2384 | 2785 | if ($error != '') { |
2385 | 2786 | return $error; |
2386 | - } elseif ($globalDebug) echo "Done\n"; |
|
2387 | - if ($globalDebug) echo "Owner Maldives: Download..."; |
|
2787 | + } elseif ($globalDebug) { |
|
2788 | + echo "Done\n"; |
|
2789 | + } |
|
2790 | + if ($globalDebug) { |
|
2791 | + echo "Owner Maldives: Download..."; |
|
2792 | + } |
|
2388 | 2793 | update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv'); |
2389 | 2794 | if (file_exists($tmp_dir.'owner_8q.csv')) { |
2390 | - if ($globalDebug) echo "Add to DB..."; |
|
2795 | + if ($globalDebug) { |
|
2796 | + echo "Add to DB..."; |
|
2797 | + } |
|
2391 | 2798 | $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q'); |
2392 | - } else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
|
2799 | + } else { |
|
2800 | + $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
|
2801 | + } |
|
2393 | 2802 | if ($error != '') { |
2394 | 2803 | return $error; |
2395 | - } elseif ($globalDebug) echo "Done\n"; |
|
2396 | - if ($globalDebug) echo "Owner New Zealand: Download..."; |
|
2804 | + } elseif ($globalDebug) { |
|
2805 | + echo "Done\n"; |
|
2806 | + } |
|
2807 | + if ($globalDebug) { |
|
2808 | + echo "Owner New Zealand: Download..."; |
|
2809 | + } |
|
2397 | 2810 | update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv'); |
2398 | 2811 | if (file_exists($tmp_dir.'owner_zk.csv')) { |
2399 | - if ($globalDebug) echo "Add to DB..."; |
|
2812 | + if ($globalDebug) { |
|
2813 | + echo "Add to DB..."; |
|
2814 | + } |
|
2400 | 2815 | $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK'); |
2401 | - } else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
|
2816 | + } else { |
|
2817 | + $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
|
2818 | + } |
|
2402 | 2819 | if ($error != '') { |
2403 | 2820 | return $error; |
2404 | - } elseif ($globalDebug) echo "Done\n"; |
|
2405 | - if ($globalDebug) echo "Owner Papua New Guinea: Download..."; |
|
2821 | + } elseif ($globalDebug) { |
|
2822 | + echo "Done\n"; |
|
2823 | + } |
|
2824 | + if ($globalDebug) { |
|
2825 | + echo "Owner Papua New Guinea: Download..."; |
|
2826 | + } |
|
2406 | 2827 | update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv'); |
2407 | 2828 | if (file_exists($tmp_dir.'owner_p2.csv')) { |
2408 | - if ($globalDebug) echo "Add to DB..."; |
|
2829 | + if ($globalDebug) { |
|
2830 | + echo "Add to DB..."; |
|
2831 | + } |
|
2409 | 2832 | $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2'); |
2410 | - } else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
|
2833 | + } else { |
|
2834 | + $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
|
2835 | + } |
|
2411 | 2836 | if ($error != '') { |
2412 | 2837 | return $error; |
2413 | - } elseif ($globalDebug) echo "Done\n"; |
|
2414 | - if ($globalDebug) echo "Owner Slovakia: Download..."; |
|
2838 | + } elseif ($globalDebug) { |
|
2839 | + echo "Done\n"; |
|
2840 | + } |
|
2841 | + if ($globalDebug) { |
|
2842 | + echo "Owner Slovakia: Download..."; |
|
2843 | + } |
|
2415 | 2844 | update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv'); |
2416 | 2845 | if (file_exists($tmp_dir.'owner_om.csv')) { |
2417 | - if ($globalDebug) echo "Add to DB..."; |
|
2846 | + if ($globalDebug) { |
|
2847 | + echo "Add to DB..."; |
|
2848 | + } |
|
2418 | 2849 | $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM'); |
2419 | - } else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
|
2850 | + } else { |
|
2851 | + $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
|
2852 | + } |
|
2420 | 2853 | if ($error != '') { |
2421 | 2854 | return $error; |
2422 | - } elseif ($globalDebug) echo "Done\n"; |
|
2423 | - if ($globalDebug) echo "Owner Ecuador: Download..."; |
|
2855 | + } elseif ($globalDebug) { |
|
2856 | + echo "Done\n"; |
|
2857 | + } |
|
2858 | + if ($globalDebug) { |
|
2859 | + echo "Owner Ecuador: Download..."; |
|
2860 | + } |
|
2424 | 2861 | update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv'); |
2425 | 2862 | if (file_exists($tmp_dir.'owner_hc.csv')) { |
2426 | - if ($globalDebug) echo "Add to DB..."; |
|
2863 | + if ($globalDebug) { |
|
2864 | + echo "Add to DB..."; |
|
2865 | + } |
|
2427 | 2866 | $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC'); |
2428 | - } else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
|
2867 | + } else { |
|
2868 | + $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
|
2869 | + } |
|
2429 | 2870 | if ($error != '') { |
2430 | 2871 | return $error; |
2431 | - } elseif ($globalDebug) echo "Done\n"; |
|
2432 | - if ($globalDebug) echo "Owner Iceland: Download..."; |
|
2872 | + } elseif ($globalDebug) { |
|
2873 | + echo "Done\n"; |
|
2874 | + } |
|
2875 | + if ($globalDebug) { |
|
2876 | + echo "Owner Iceland: Download..."; |
|
2877 | + } |
|
2433 | 2878 | update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv'); |
2434 | 2879 | if (file_exists($tmp_dir.'owner_tf.csv')) { |
2435 | - if ($globalDebug) echo "Add to DB..."; |
|
2880 | + if ($globalDebug) { |
|
2881 | + echo "Add to DB..."; |
|
2882 | + } |
|
2436 | 2883 | $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF'); |
2437 | - } else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
|
2884 | + } else { |
|
2885 | + $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
|
2886 | + } |
|
2438 | 2887 | if ($error != '') { |
2439 | 2888 | return $error; |
2440 | - } elseif ($globalDebug) echo "Done\n"; |
|
2441 | - if ($globalDebug) echo "Owner Isle of Man: Download..."; |
|
2889 | + } elseif ($globalDebug) { |
|
2890 | + echo "Done\n"; |
|
2891 | + } |
|
2892 | + if ($globalDebug) { |
|
2893 | + echo "Owner Isle of Man: Download..."; |
|
2894 | + } |
|
2442 | 2895 | update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv'); |
2443 | 2896 | if (file_exists($tmp_dir.'owner_m.csv')) { |
2444 | - if ($globalDebug) echo "Add to DB..."; |
|
2897 | + if ($globalDebug) { |
|
2898 | + echo "Add to DB..."; |
|
2899 | + } |
|
2445 | 2900 | $error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M'); |
2446 | - } else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed."; |
|
2901 | + } else { |
|
2902 | + $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed."; |
|
2903 | + } |
|
2447 | 2904 | if ($error != '') { |
2448 | 2905 | return $error; |
2449 | - } elseif ($globalDebug) echo "Done\n"; |
|
2906 | + } elseif ($globalDebug) { |
|
2907 | + echo "Done\n"; |
|
2908 | + } |
|
2450 | 2909 | if ($globalMasterSource) { |
2451 | - if ($globalDebug) echo "ModeS Netherlands: Download..."; |
|
2910 | + if ($globalDebug) { |
|
2911 | + echo "ModeS Netherlands: Download..."; |
|
2912 | + } |
|
2452 | 2913 | update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv'); |
2453 | 2914 | if (file_exists($tmp_dir.'owner_ph.csv')) { |
2454 | - if ($globalDebug) echo "Add to DB..."; |
|
2915 | + if ($globalDebug) { |
|
2916 | + echo "Add to DB..."; |
|
2917 | + } |
|
2455 | 2918 | $error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH'); |
2456 | - } else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed."; |
|
2919 | + } else { |
|
2920 | + $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed."; |
|
2921 | + } |
|
2457 | 2922 | if ($error != '') { |
2458 | 2923 | return $error; |
2459 | - } elseif ($globalDebug) echo "Done\n"; |
|
2460 | - if ($globalDebug) echo "ModeS Denmark: Download..."; |
|
2924 | + } elseif ($globalDebug) { |
|
2925 | + echo "Done\n"; |
|
2926 | + } |
|
2927 | + if ($globalDebug) { |
|
2928 | + echo "ModeS Denmark: Download..."; |
|
2929 | + } |
|
2461 | 2930 | update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv'); |
2462 | 2931 | if (file_exists($tmp_dir.'owner_oy.csv')) { |
2463 | - if ($globalDebug) echo "Add to DB..."; |
|
2932 | + if ($globalDebug) { |
|
2933 | + echo "Add to DB..."; |
|
2934 | + } |
|
2464 | 2935 | $error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY'); |
2465 | - } else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed."; |
|
2936 | + } else { |
|
2937 | + $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed."; |
|
2938 | + } |
|
2466 | 2939 | if ($error != '') { |
2467 | 2940 | return $error; |
2468 | - } elseif ($globalDebug) echo "Done\n"; |
|
2469 | - } elseif ($globalDebug) echo "Done\n"; |
|
2941 | + } elseif ($globalDebug) { |
|
2942 | + echo "Done\n"; |
|
2943 | + } |
|
2944 | + } elseif ($globalDebug) { |
|
2945 | + echo "Done\n"; |
|
2946 | + } |
|
2470 | 2947 | return ''; |
2471 | 2948 | } |
2472 | 2949 | |
2473 | 2950 | public static function update_translation() { |
2474 | 2951 | global $tmp_dir, $globalDebug; |
2475 | 2952 | $error = ''; |
2476 | - if ($globalDebug) echo "Translation : Download..."; |
|
2953 | + if ($globalDebug) { |
|
2954 | + echo "Translation : Download..."; |
|
2955 | + } |
|
2477 | 2956 | update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip'); |
2478 | 2957 | if (file_exists($tmp_dir.'translation.zip')) { |
2479 | - if ($globalDebug) echo "Unzip..."; |
|
2958 | + if ($globalDebug) { |
|
2959 | + echo "Unzip..."; |
|
2960 | + } |
|
2480 | 2961 | update_db::unzip($tmp_dir.'translation.zip'); |
2481 | - if ($globalDebug) echo "Add to DB..."; |
|
2962 | + if ($globalDebug) { |
|
2963 | + echo "Add to DB..."; |
|
2964 | + } |
|
2482 | 2965 | $error = update_db::translation(); |
2483 | - } else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed."; |
|
2966 | + } else { |
|
2967 | + $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed."; |
|
2968 | + } |
|
2484 | 2969 | if ($error != '') { |
2485 | 2970 | return $error; |
2486 | - } elseif ($globalDebug) echo "Done\n"; |
|
2971 | + } elseif ($globalDebug) { |
|
2972 | + echo "Done\n"; |
|
2973 | + } |
|
2487 | 2974 | return ''; |
2488 | 2975 | } |
2489 | 2976 | |
2490 | 2977 | public static function update_translation_fam() { |
2491 | 2978 | global $tmp_dir, $globalDebug; |
2492 | 2979 | $error = ''; |
2493 | - if ($globalDebug) echo "Translation from FlightAirMap website : Download..."; |
|
2980 | + if ($globalDebug) { |
|
2981 | + echo "Translation from FlightAirMap website : Download..."; |
|
2982 | + } |
|
2494 | 2983 | update_db::download('http://data.flightairmap.com/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz'); |
2495 | 2984 | update_db::download('http://data.flightairmap.com/data/translation.tsv.gz.md5',$tmp_dir.'translation.tsv.gz.md5'); |
2496 | 2985 | if (file_exists($tmp_dir.'translation.tsv.gz') && file_exists($tmp_dir.'translation.tsv.gz')) { |
2497 | 2986 | $translation_md5_file = explode(' ',file_get_contents($tmp_dir.'translation.tsv.gz.md5')); |
2498 | 2987 | $translation_md5 = $translation_md5_file[0]; |
2499 | 2988 | if (md5_file($tmp_dir.'translation.tsv.gz') == $translation_md5) { |
2500 | - if ($globalDebug) echo "Gunzip..."; |
|
2989 | + if ($globalDebug) { |
|
2990 | + echo "Gunzip..."; |
|
2991 | + } |
|
2501 | 2992 | update_db::gunzip($tmp_dir.'translation.tsv.gz'); |
2502 | - if ($globalDebug) echo "Add to DB..."; |
|
2993 | + if ($globalDebug) { |
|
2994 | + echo "Add to DB..."; |
|
2995 | + } |
|
2503 | 2996 | $error = update_db::translation_fam(); |
2504 | - } else $error = "File ".$tmp_dir.'translation.tsv.gz'." md5 failed. Download failed."; |
|
2505 | - } else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed."; |
|
2997 | + } else { |
|
2998 | + $error = "File ".$tmp_dir.'translation.tsv.gz'." md5 failed. Download failed."; |
|
2999 | + } |
|
3000 | + } else { |
|
3001 | + $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed."; |
|
3002 | + } |
|
2506 | 3003 | if ($error != '') { |
2507 | 3004 | return $error; |
2508 | - } elseif ($globalDebug) echo "Done\n"; |
|
3005 | + } elseif ($globalDebug) { |
|
3006 | + echo "Done\n"; |
|
3007 | + } |
|
2509 | 3008 | return ''; |
2510 | 3009 | } |
2511 | 3010 | public static function update_ModeS_fam() { |
2512 | 3011 | global $tmp_dir, $globalDebug; |
2513 | 3012 | $error = ''; |
2514 | - if ($globalDebug) echo "ModeS from FlightAirMap website : Download..."; |
|
3013 | + if ($globalDebug) { |
|
3014 | + echo "ModeS from FlightAirMap website : Download..."; |
|
3015 | + } |
|
2515 | 3016 | update_db::download('http://data.flightairmap.com/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz'); |
2516 | 3017 | update_db::download('http://data.flightairmap.com/data/modes.tsv.gz.md5',$tmp_dir.'modes.tsv.gz.md5'); |
2517 | 3018 | if (file_exists($tmp_dir.'modes.tsv.gz') && file_exists($tmp_dir.'modes.tsv.gz.md5')) { |
2518 | 3019 | $modes_md5_file = explode(' ',file_get_contents($tmp_dir.'modes.tsv.gz.md5')); |
2519 | 3020 | $modes_md5 = $modes_md5_file[0]; |
2520 | 3021 | if (md5_file($tmp_dir.'modes.tsv.gz') == $modes_md5) { |
2521 | - if ($globalDebug) echo "Gunzip..."; |
|
3022 | + if ($globalDebug) { |
|
3023 | + echo "Gunzip..."; |
|
3024 | + } |
|
2522 | 3025 | update_db::gunzip($tmp_dir.'modes.tsv.gz'); |
2523 | - if ($globalDebug) echo "Add to DB..."; |
|
3026 | + if ($globalDebug) { |
|
3027 | + echo "Add to DB..."; |
|
3028 | + } |
|
2524 | 3029 | $error = update_db::modes_fam(); |
2525 | - } else $error = "File ".$tmp_dir.'modes.tsv.gz'." md5 failed. Download failed."; |
|
2526 | - } else $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed."; |
|
3030 | + } else { |
|
3031 | + $error = "File ".$tmp_dir.'modes.tsv.gz'." md5 failed. Download failed."; |
|
3032 | + } |
|
3033 | + } else { |
|
3034 | + $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed."; |
|
3035 | + } |
|
2527 | 3036 | if ($error != '') { |
2528 | 3037 | return $error; |
2529 | - } elseif ($globalDebug) echo "Done\n"; |
|
3038 | + } elseif ($globalDebug) { |
|
3039 | + echo "Done\n"; |
|
3040 | + } |
|
2530 | 3041 | return ''; |
2531 | 3042 | } |
2532 | 3043 | |
2533 | 3044 | public static function update_airlines_fam() { |
2534 | 3045 | global $tmp_dir, $globalDebug; |
2535 | 3046 | $error = ''; |
2536 | - if ($globalDebug) echo "Airlines from FlightAirMap website : Download..."; |
|
3047 | + if ($globalDebug) { |
|
3048 | + echo "Airlines from FlightAirMap website : Download..."; |
|
3049 | + } |
|
2537 | 3050 | update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz.md5',$tmp_dir.'airlines.tsv.gz.md5'); |
2538 | 3051 | if (file_exists($tmp_dir.'airlines.tsv.gz.md5')) { |
2539 | 3052 | $airlines_md5_file = explode(' ',file_get_contents($tmp_dir.'airlines.tsv.gz.md5')); |
@@ -2542,26 +3055,42 @@ discard block |
||
2542 | 3055 | update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz',$tmp_dir.'airlines.tsv.gz'); |
2543 | 3056 | if (file_exists($tmp_dir.'airlines.tsv.gz')) { |
2544 | 3057 | if (md5_file($tmp_dir.'airlines.tsv.gz') == $airlines_md5) { |
2545 | - if ($globalDebug) echo "Gunzip..."; |
|
3058 | + if ($globalDebug) { |
|
3059 | + echo "Gunzip..."; |
|
3060 | + } |
|
2546 | 3061 | update_db::gunzip($tmp_dir.'airlines.tsv.gz'); |
2547 | - if ($globalDebug) echo "Add to DB..."; |
|
3062 | + if ($globalDebug) { |
|
3063 | + echo "Add to DB..."; |
|
3064 | + } |
|
2548 | 3065 | $error = update_db::airlines_fam(); |
2549 | 3066 | update_db::insert_airlines_version($airlines_md5); |
2550 | - } else $error = "File ".$tmp_dir.'airlines.tsv.gz'." md5 failed. Download failed."; |
|
2551 | - } else $error = "File ".$tmp_dir.'airlines.tsv.gz'." doesn't exist. Download failed."; |
|
2552 | - } elseif ($globalDebug) echo "No update."; |
|
2553 | - } else $error = "File ".$tmp_dir.'airlines.tsv.gz.md5'." doesn't exist. Download failed."; |
|
3067 | + } else { |
|
3068 | + $error = "File ".$tmp_dir.'airlines.tsv.gz'." md5 failed. Download failed."; |
|
3069 | + } |
|
3070 | + } else { |
|
3071 | + $error = "File ".$tmp_dir.'airlines.tsv.gz'." doesn't exist. Download failed."; |
|
3072 | + } |
|
3073 | + } elseif ($globalDebug) { |
|
3074 | + echo "No update."; |
|
3075 | + } |
|
3076 | + } else { |
|
3077 | + $error = "File ".$tmp_dir.'airlines.tsv.gz.md5'." doesn't exist. Download failed."; |
|
3078 | + } |
|
2554 | 3079 | if ($error != '') { |
2555 | 3080 | return $error; |
2556 | 3081 | } else { |
2557 | - if ($globalDebug) echo "Done\n"; |
|
3082 | + if ($globalDebug) { |
|
3083 | + echo "Done\n"; |
|
3084 | + } |
|
2558 | 3085 | } |
2559 | 3086 | return ''; |
2560 | 3087 | } |
2561 | 3088 | |
2562 | 3089 | public static function update_owner_fam() { |
2563 | 3090 | global $tmp_dir, $globalDebug, $globalOwner; |
2564 | - if ($globalDebug) echo "owner from FlightAirMap website : Download..."; |
|
3091 | + if ($globalDebug) { |
|
3092 | + echo "owner from FlightAirMap website : Download..."; |
|
3093 | + } |
|
2565 | 3094 | $error = ''; |
2566 | 3095 | if ($globalOwner === TRUE) { |
2567 | 3096 | update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz'); |
@@ -2574,55 +3103,89 @@ discard block |
||
2574 | 3103 | $owners_md5_file = explode(' ',file_get_contents($tmp_dir.'owners.tsv.gz.md5')); |
2575 | 3104 | $owners_md5 = $owners_md5_file[0]; |
2576 | 3105 | if (md5_file($tmp_dir.'owners.tsv.gz') == $owners_md5) { |
2577 | - if ($globalDebug) echo "Gunzip..."; |
|
3106 | + if ($globalDebug) { |
|
3107 | + echo "Gunzip..."; |
|
3108 | + } |
|
2578 | 3109 | update_db::gunzip($tmp_dir.'owners.tsv.gz'); |
2579 | - if ($globalDebug) echo "Add to DB..."; |
|
3110 | + if ($globalDebug) { |
|
3111 | + echo "Add to DB..."; |
|
3112 | + } |
|
2580 | 3113 | $error = update_db::owner_fam(); |
2581 | - } else $error = "File ".$tmp_dir.'owners.tsv.gz'." md5 failed. Download failed."; |
|
2582 | - } else $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed."; |
|
3114 | + } else { |
|
3115 | + $error = "File ".$tmp_dir.'owners.tsv.gz'." md5 failed. Download failed."; |
|
3116 | + } |
|
3117 | + } else { |
|
3118 | + $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed."; |
|
3119 | + } |
|
2583 | 3120 | if ($error != '') { |
2584 | 3121 | return $error; |
2585 | - } elseif ($globalDebug) echo "Done\n"; |
|
3122 | + } elseif ($globalDebug) { |
|
3123 | + echo "Done\n"; |
|
3124 | + } |
|
2586 | 3125 | return ''; |
2587 | 3126 | } |
2588 | 3127 | public static function update_routes_fam() { |
2589 | 3128 | global $tmp_dir, $globalDebug; |
2590 | - if ($globalDebug) echo "Routes from FlightAirMap website : Download..."; |
|
3129 | + if ($globalDebug) { |
|
3130 | + echo "Routes from FlightAirMap website : Download..."; |
|
3131 | + } |
|
2591 | 3132 | update_db::download('http://data.flightairmap.com/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz'); |
2592 | 3133 | update_db::download('http://data.flightairmap.com/data/routes.tsv.gz.md5',$tmp_dir.'routes.tsv.gz.md5'); |
2593 | 3134 | if (file_exists($tmp_dir.'routes.tsv.gz') && file_exists($tmp_dir.'routes.tsv.gz.md5')) { |
2594 | 3135 | $routes_md5_file = explode(' ',file_get_contents($tmp_dir.'routes.tsv.gz.md5')); |
2595 | 3136 | $routes_md5 = $routes_md5_file[0]; |
2596 | 3137 | if (md5_file($tmp_dir.'routes.tsv.gz') == $routes_md5) { |
2597 | - if ($globalDebug) echo "Gunzip..."; |
|
3138 | + if ($globalDebug) { |
|
3139 | + echo "Gunzip..."; |
|
3140 | + } |
|
2598 | 3141 | update_db::gunzip($tmp_dir.'routes.tsv.gz'); |
2599 | - if ($globalDebug) echo "Add to DB..."; |
|
3142 | + if ($globalDebug) { |
|
3143 | + echo "Add to DB..."; |
|
3144 | + } |
|
2600 | 3145 | $error = update_db::routes_fam(); |
2601 | - } else $error = "File ".$tmp_dir.'routes.tsv.gz'." md5 failed. Download failed."; |
|
2602 | - } else $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed."; |
|
3146 | + } else { |
|
3147 | + $error = "File ".$tmp_dir.'routes.tsv.gz'." md5 failed. Download failed."; |
|
3148 | + } |
|
3149 | + } else { |
|
3150 | + $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed."; |
|
3151 | + } |
|
2603 | 3152 | if ($error != '') { |
2604 | 3153 | return $error; |
2605 | - } elseif ($globalDebug) echo "Done\n"; |
|
3154 | + } elseif ($globalDebug) { |
|
3155 | + echo "Done\n"; |
|
3156 | + } |
|
2606 | 3157 | return ''; |
2607 | 3158 | } |
2608 | 3159 | public static function update_block_fam() { |
2609 | 3160 | global $tmp_dir, $globalDebug; |
2610 | - if ($globalDebug) echo "Blocked aircraft from FlightAirMap website : Download..."; |
|
3161 | + if ($globalDebug) { |
|
3162 | + echo "Blocked aircraft from FlightAirMap website : Download..."; |
|
3163 | + } |
|
2611 | 3164 | update_db::download('http://data.flightairmap.com/data/block.tsv.gz',$tmp_dir.'block.tsv.gz'); |
2612 | 3165 | update_db::download('http://data.flightairmap.com/data/block.tsv.gz.md5',$tmp_dir.'block.tsv.gz.md5'); |
2613 | 3166 | if (file_exists($tmp_dir.'block.tsv.gz') && file_exists($tmp_dir.'block.tsv.gz.md5')) { |
2614 | 3167 | $block_md5_file = explode(' ',file_get_contents($tmp_dir.'block.tsv.gz.md5')); |
2615 | 3168 | $block_md5 = $block_md5_file[0]; |
2616 | 3169 | if (md5_file($tmp_dir.'block.tsv.gz') == $block_md5) { |
2617 | - if ($globalDebug) echo "Gunzip..."; |
|
3170 | + if ($globalDebug) { |
|
3171 | + echo "Gunzip..."; |
|
3172 | + } |
|
2618 | 3173 | update_db::gunzip($tmp_dir.'block.tsv.gz'); |
2619 | - if ($globalDebug) echo "Add to DB..."; |
|
3174 | + if ($globalDebug) { |
|
3175 | + echo "Add to DB..."; |
|
3176 | + } |
|
2620 | 3177 | $error = update_db::block_fam(); |
2621 | - } else $error = "File ".$tmp_dir.'block.tsv.gz'." md5 failed. Download failed."; |
|
2622 | - } else $error = "File ".$tmp_dir.'block.tsv.gz'." doesn't exist. Download failed."; |
|
3178 | + } else { |
|
3179 | + $error = "File ".$tmp_dir.'block.tsv.gz'." md5 failed. Download failed."; |
|
3180 | + } |
|
3181 | + } else { |
|
3182 | + $error = "File ".$tmp_dir.'block.tsv.gz'." doesn't exist. Download failed."; |
|
3183 | + } |
|
2623 | 3184 | if ($error != '') { |
2624 | 3185 | return $error; |
2625 | - } elseif ($globalDebug) echo "Done\n"; |
|
3186 | + } elseif ($globalDebug) { |
|
3187 | + echo "Done\n"; |
|
3188 | + } |
|
2626 | 3189 | return ''; |
2627 | 3190 | } |
2628 | 3191 | public static function update_marine_identity_fam() { |
@@ -2632,21 +3195,33 @@ discard block |
||
2632 | 3195 | $marine_identity_md5_file = explode(' ',file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5')); |
2633 | 3196 | $marine_identity_md5 = $marine_identity_md5_file[0]; |
2634 | 3197 | if (!update_db::check_marine_identity_version($marine_identity_md5)) { |
2635 | - if ($globalDebug) echo "Marine identity from FlightAirMap website : Download..."; |
|
3198 | + if ($globalDebug) { |
|
3199 | + echo "Marine identity from FlightAirMap website : Download..."; |
|
3200 | + } |
|
2636 | 3201 | update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz',$tmp_dir.'marine_identity.tsv.gz'); |
2637 | 3202 | if (file_exists($tmp_dir.'marine_identity.tsv.gz')) { |
2638 | 3203 | if (md5_file($tmp_dir.'marine_identity.tsv.gz') == $marine_identity_md5) { |
2639 | - if ($globalDebug) echo "Gunzip..."; |
|
3204 | + if ($globalDebug) { |
|
3205 | + echo "Gunzip..."; |
|
3206 | + } |
|
2640 | 3207 | update_db::gunzip($tmp_dir.'marine_identity.tsv.gz'); |
2641 | - if ($globalDebug) echo "Add to DB..."; |
|
3208 | + if ($globalDebug) { |
|
3209 | + echo "Add to DB..."; |
|
3210 | + } |
|
2642 | 3211 | $error = update_db::marine_identity_fam(); |
2643 | - } else $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." md5 failed. Download failed."; |
|
2644 | - } else $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed."; |
|
3212 | + } else { |
|
3213 | + $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." md5 failed. Download failed."; |
|
3214 | + } |
|
3215 | + } else { |
|
3216 | + $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed."; |
|
3217 | + } |
|
2645 | 3218 | if ($error != '') { |
2646 | 3219 | return $error; |
2647 | 3220 | } else { |
2648 | 3221 | update_db::insert_marine_identity_version($marine_identity_md5); |
2649 | - if ($globalDebug) echo "Done\n"; |
|
3222 | + if ($globalDebug) { |
|
3223 | + echo "Done\n"; |
|
3224 | + } |
|
2650 | 3225 | } |
2651 | 3226 | } |
2652 | 3227 | } |
@@ -2660,21 +3235,33 @@ discard block |
||
2660 | 3235 | $satellite_md5_file = explode(' ',file_get_contents($tmp_dir.'satellite.tsv.gz.md5')); |
2661 | 3236 | $satellite_md5 = $satellite_md5_file[0]; |
2662 | 3237 | if (!update_db::check_satellite_version($satellite_md5)) { |
2663 | - if ($globalDebug) echo "Satellite from FlightAirMap website : Download..."; |
|
3238 | + if ($globalDebug) { |
|
3239 | + echo "Satellite from FlightAirMap website : Download..."; |
|
3240 | + } |
|
2664 | 3241 | update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz',$tmp_dir.'satellite.tsv.gz'); |
2665 | 3242 | if (file_exists($tmp_dir.'satellite.tsv.gz')) { |
2666 | 3243 | if (md5_file($tmp_dir.'satellite.tsv.gz') == $satellite_md5) { |
2667 | - if ($globalDebug) echo "Gunzip..."; |
|
3244 | + if ($globalDebug) { |
|
3245 | + echo "Gunzip..."; |
|
3246 | + } |
|
2668 | 3247 | update_db::gunzip($tmp_dir.'satellite.tsv.gz'); |
2669 | - if ($globalDebug) echo "Add to DB..."; |
|
3248 | + if ($globalDebug) { |
|
3249 | + echo "Add to DB..."; |
|
3250 | + } |
|
2670 | 3251 | $error = update_db::satellite_fam(); |
2671 | - } else $error = "File ".$tmp_dir.'satellite.tsv.gz'." md5 failed. Download failed."; |
|
2672 | - } else $error = "File ".$tmp_dir.'satellite.tsv.gz'." doesn't exist. Download failed."; |
|
3252 | + } else { |
|
3253 | + $error = "File ".$tmp_dir.'satellite.tsv.gz'." md5 failed. Download failed."; |
|
3254 | + } |
|
3255 | + } else { |
|
3256 | + $error = "File ".$tmp_dir.'satellite.tsv.gz'." doesn't exist. Download failed."; |
|
3257 | + } |
|
2673 | 3258 | if ($error != '') { |
2674 | 3259 | return $error; |
2675 | 3260 | } else { |
2676 | 3261 | update_db::insert_satellite_version($satellite_md5); |
2677 | - if ($globalDebug) echo "Done\n"; |
|
3262 | + if ($globalDebug) { |
|
3263 | + echo "Done\n"; |
|
3264 | + } |
|
2678 | 3265 | } |
2679 | 3266 | } |
2680 | 3267 | } |
@@ -2687,19 +3274,29 @@ discard block |
||
2687 | 3274 | $diagrams_md5_file = explode(' ',file_get_contents($tmp_dir.'diagramspdf.md5')); |
2688 | 3275 | $diagrams_md5 = $diagrams_md5_file[0]; |
2689 | 3276 | if (!update_db::check_diagrams_version($diagrams_md5)) { |
2690 | - if ($globalDebug) echo "Airports diagrams from FlightAirMap website : Download..."; |
|
3277 | + if ($globalDebug) { |
|
3278 | + echo "Airports diagrams from FlightAirMap website : Download..."; |
|
3279 | + } |
|
2691 | 3280 | update_db::download('http://data.flightairmap.com/data/diagrams/diagramspdf',$tmp_dir.'diagramspdf'); |
2692 | 3281 | if (file_exists($tmp_dir.'diagramspdf')) { |
2693 | 3282 | if (md5_file($tmp_dir.'diagramspdf') == $diagrams_md5) { |
2694 | - if ($globalDebug) echo "Add to DB..."; |
|
3283 | + if ($globalDebug) { |
|
3284 | + echo "Add to DB..."; |
|
3285 | + } |
|
2695 | 3286 | $error = update_db::diagrams_fam(); |
2696 | - } else $error = "File ".$tmp_dir.'diagramspdf'." md5 failed. Download failed."; |
|
2697 | - } else $error = "File ".$tmp_dir.'diagramspdf'." doesn't exist. Download failed."; |
|
3287 | + } else { |
|
3288 | + $error = "File ".$tmp_dir.'diagramspdf'." md5 failed. Download failed."; |
|
3289 | + } |
|
3290 | + } else { |
|
3291 | + $error = "File ".$tmp_dir.'diagramspdf'." doesn't exist. Download failed."; |
|
3292 | + } |
|
2698 | 3293 | if ($error != '') { |
2699 | 3294 | return $error; |
2700 | 3295 | } else { |
2701 | 3296 | update_db::insert_diagrams_version($diagrams_md5); |
2702 | - if ($globalDebug) echo "Done\n"; |
|
3297 | + if ($globalDebug) { |
|
3298 | + echo "Done\n"; |
|
3299 | + } |
|
2703 | 3300 | } |
2704 | 3301 | } |
2705 | 3302 | } |
@@ -2707,17 +3304,25 @@ discard block |
||
2707 | 3304 | } |
2708 | 3305 | public static function update_banned_fam() { |
2709 | 3306 | global $tmp_dir, $globalDebug; |
2710 | - if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download..."; |
|
3307 | + if ($globalDebug) { |
|
3308 | + echo "Banned airlines in Europe from FlightAirMap website : Download..."; |
|
3309 | + } |
|
2711 | 3310 | update_db::download('http://data.flightairmap.com/data/ban-eu.csv',$tmp_dir.'ban_eu.csv'); |
2712 | 3311 | if (file_exists($tmp_dir.'ban_eu.csv')) { |
2713 | 3312 | //if ($globalDebug) echo "Gunzip..."; |
2714 | 3313 | //update_db::gunzip($tmp_dir.'ban_ue.csv'); |
2715 | - if ($globalDebug) echo "Add to DB..."; |
|
3314 | + if ($globalDebug) { |
|
3315 | + echo "Add to DB..."; |
|
3316 | + } |
|
2716 | 3317 | $error = update_db::banned_fam(); |
2717 | - } else $error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed."; |
|
3318 | + } else { |
|
3319 | + $error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed."; |
|
3320 | + } |
|
2718 | 3321 | if ($error != '') { |
2719 | 3322 | return $error; |
2720 | - } elseif ($globalDebug) echo "Done\n"; |
|
3323 | + } elseif ($globalDebug) { |
|
3324 | + echo "Done\n"; |
|
3325 | + } |
|
2721 | 3326 | return ''; |
2722 | 3327 | } |
2723 | 3328 | |
@@ -2725,7 +3330,9 @@ discard block |
||
2725 | 3330 | global $tmp_dir, $globalDebug, $globalDBdriver; |
2726 | 3331 | include_once('class.create_db.php'); |
2727 | 3332 | $error = ''; |
2728 | - if ($globalDebug) echo "Airspace from FlightAirMap website : Download..."; |
|
3333 | + if ($globalDebug) { |
|
3334 | + echo "Airspace from FlightAirMap website : Download..."; |
|
3335 | + } |
|
2729 | 3336 | if ($globalDBdriver == 'mysql') { |
2730 | 3337 | update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); |
2731 | 3338 | } else { |
@@ -2742,9 +3349,13 @@ discard block |
||
2742 | 3349 | } |
2743 | 3350 | if (file_exists($tmp_dir.'airspace.sql.gz')) { |
2744 | 3351 | if (md5_file($tmp_dir.'airspace.sql.gz') == $airspace_md5) { |
2745 | - if ($globalDebug) echo "Gunzip..."; |
|
3352 | + if ($globalDebug) { |
|
3353 | + echo "Gunzip..."; |
|
3354 | + } |
|
2746 | 3355 | update_db::gunzip($tmp_dir.'airspace.sql.gz'); |
2747 | - if ($globalDebug) echo "Add to DB..."; |
|
3356 | + if ($globalDebug) { |
|
3357 | + echo "Add to DB..."; |
|
3358 | + } |
|
2748 | 3359 | $Connection = new Connection(); |
2749 | 3360 | if ($Connection->tableExists('airspace')) { |
2750 | 3361 | $query = 'DROP TABLE airspace'; |
@@ -2757,20 +3368,30 @@ discard block |
||
2757 | 3368 | } |
2758 | 3369 | $error = create_db::import_file($tmp_dir.'airspace.sql'); |
2759 | 3370 | update_db::insert_airspace_version($airspace_md5); |
2760 | - } else $error = "File ".$tmp_dir.'airspace.sql.gz'." md5 failed. Download failed."; |
|
2761 | - } else $error = "File ".$tmp_dir.'airspace.sql.gz'." doesn't exist. Download failed."; |
|
3371 | + } else { |
|
3372 | + $error = "File ".$tmp_dir.'airspace.sql.gz'." md5 failed. Download failed."; |
|
3373 | + } |
|
3374 | + } else { |
|
3375 | + $error = "File ".$tmp_dir.'airspace.sql.gz'." doesn't exist. Download failed."; |
|
3376 | + } |
|
2762 | 3377 | } |
2763 | - } else $error = "File ".$tmp_dir.'airspace.sql.gz.md5'." doesn't exist. Download failed."; |
|
3378 | + } else { |
|
3379 | + $error = "File ".$tmp_dir.'airspace.sql.gz.md5'." doesn't exist. Download failed."; |
|
3380 | + } |
|
2764 | 3381 | if ($error != '') { |
2765 | 3382 | return $error; |
2766 | - } elseif ($globalDebug) echo "Done\n"; |
|
3383 | + } elseif ($globalDebug) { |
|
3384 | + echo "Done\n"; |
|
3385 | + } |
|
2767 | 3386 | return ''; |
2768 | 3387 | } |
2769 | 3388 | |
2770 | 3389 | public static function update_geoid_fam() { |
2771 | 3390 | global $tmp_dir, $globalDebug, $globalGeoidSource; |
2772 | 3391 | $error = ''; |
2773 | - if ($globalDebug) echo "Geoid from FlightAirMap website : Download..."; |
|
3392 | + if ($globalDebug) { |
|
3393 | + echo "Geoid from FlightAirMap website : Download..."; |
|
3394 | + } |
|
2774 | 3395 | update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5',$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'); |
2775 | 3396 | if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')) { |
2776 | 3397 | $geoid_md5_file = explode(' ',file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')); |
@@ -2779,80 +3400,126 @@ discard block |
||
2779 | 3400 | update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz',$tmp_dir.$globalGeoidSource.'.pgm.gz'); |
2780 | 3401 | if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz')) { |
2781 | 3402 | if (md5_file($tmp_dir.$globalGeoidSource.'.pgm.gz') == $geoid_md5) { |
2782 | - if ($globalDebug) echo "Gunzip..."; |
|
3403 | + if ($globalDebug) { |
|
3404 | + echo "Gunzip..."; |
|
3405 | + } |
|
2783 | 3406 | update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz',dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm'); |
2784 | 3407 | if (file_exists(dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm')) { |
2785 | 3408 | update_db::insert_geoid_version($geoid_md5); |
2786 | - } else $error = "File data/".$globalGeoidSource.'.pgm'." doesn't exist. Gunzip failed."; |
|
2787 | - } else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." md5 failed. Download failed."; |
|
2788 | - } else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed."; |
|
2789 | - } elseif ($globalDebug) echo 'No new version'."\n"; |
|
2790 | - } else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed."; |
|
3409 | + } else { |
|
3410 | + $error = "File data/".$globalGeoidSource.'.pgm'." doesn't exist. Gunzip failed."; |
|
3411 | + } |
|
3412 | + } else { |
|
3413 | + $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." md5 failed. Download failed."; |
|
3414 | + } |
|
3415 | + } else { |
|
3416 | + $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed."; |
|
3417 | + } |
|
3418 | + } elseif ($globalDebug) { |
|
3419 | + echo 'No new version'."\n"; |
|
3420 | + } |
|
3421 | + } else { |
|
3422 | + $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed."; |
|
3423 | + } |
|
2791 | 3424 | if ($error != '') { |
2792 | 3425 | return $error; |
2793 | - } elseif ($globalDebug) echo "Done\n"; |
|
3426 | + } elseif ($globalDebug) { |
|
3427 | + echo "Done\n"; |
|
3428 | + } |
|
2794 | 3429 | return ''; |
2795 | 3430 | } |
2796 | 3431 | |
2797 | 3432 | public static function update_tle() { |
2798 | 3433 | global $tmp_dir, $globalDebug; |
2799 | - if ($globalDebug) echo "Download TLE : Download..."; |
|
3434 | + if ($globalDebug) { |
|
3435 | + echo "Download TLE : Download..."; |
|
3436 | + } |
|
2800 | 3437 | $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', |
2801 | 3438 | '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', |
2802 | 3439 | 'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt','visual.txt','sarsat.txt','argos.txt','ses.txt','iridium-NEXT.txt','beidou.txt'); |
2803 | 3440 | foreach ($alltle as $filename) { |
2804 | - if ($globalDebug) echo "downloading ".$filename.'...'; |
|
3441 | + if ($globalDebug) { |
|
3442 | + echo "downloading ".$filename.'...'; |
|
3443 | + } |
|
2805 | 3444 | update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename); |
2806 | 3445 | if (file_exists($tmp_dir.$filename)) { |
2807 | - if ($globalDebug) echo "Add to DB ".$filename."..."; |
|
3446 | + if ($globalDebug) { |
|
3447 | + echo "Add to DB ".$filename."..."; |
|
3448 | + } |
|
2808 | 3449 | $error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename)); |
2809 | - } else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
|
3450 | + } else { |
|
3451 | + $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
|
3452 | + } |
|
2810 | 3453 | if ($error != '') { |
2811 | 3454 | echo $error."\n"; |
2812 | - } elseif ($globalDebug) echo "Done\n"; |
|
3455 | + } elseif ($globalDebug) { |
|
3456 | + echo "Done\n"; |
|
3457 | + } |
|
2813 | 3458 | } |
2814 | 3459 | return ''; |
2815 | 3460 | } |
2816 | 3461 | |
2817 | 3462 | public static function update_ucsdb() { |
2818 | 3463 | global $tmp_dir, $globalDebug; |
2819 | - if ($globalDebug) echo "Download UCS DB : Download..."; |
|
3464 | + if ($globalDebug) { |
|
3465 | + echo "Download UCS DB : Download..."; |
|
3466 | + } |
|
2820 | 3467 | update_db::download('https://s3.amazonaws.com/ucs-documents/nuclear-weapons/sat-database/8-10-18-update/UCS_Satellite_Database_officialname_5-1-2018.txt',$tmp_dir.'UCS_Satellite_Database_officialname_9-1-2017.txt'); |
2821 | 3468 | if (file_exists($tmp_dir.'UCS_Satellite_Database_officialname_5-1-2018.txt')) { |
2822 | - if ($globalDebug) echo "Add to DB..."; |
|
3469 | + if ($globalDebug) { |
|
3470 | + echo "Add to DB..."; |
|
3471 | + } |
|
2823 | 3472 | $error = update_db::satellite_ucsdb($tmp_dir.'UCS_Satellite_Database_officialname_5-1-2018.txt'); |
2824 | - } else $error = "File ".$tmp_dir.'UCS_Satellite_Database_officialname_5-1-2018.txt'." doesn't exist. Download failed."; |
|
3473 | + } else { |
|
3474 | + $error = "File ".$tmp_dir.'UCS_Satellite_Database_officialname_5-1-2018.txt'." doesn't exist. Download failed."; |
|
3475 | + } |
|
2825 | 3476 | if ($error != '') { |
2826 | 3477 | echo $error."\n"; |
2827 | - } elseif ($globalDebug) echo "Done\n"; |
|
3478 | + } elseif ($globalDebug) { |
|
3479 | + echo "Done\n"; |
|
3480 | + } |
|
2828 | 3481 | return ''; |
2829 | 3482 | } |
2830 | 3483 | |
2831 | 3484 | public static function update_celestrak() { |
2832 | 3485 | global $tmp_dir, $globalDebug; |
2833 | - if ($globalDebug) echo "Download Celestrak DB : Download..."; |
|
3486 | + if ($globalDebug) { |
|
3487 | + echo "Download Celestrak DB : Download..."; |
|
3488 | + } |
|
2834 | 3489 | update_db::download('http://celestrak.com/pub/satcat.txt',$tmp_dir.'satcat.txt'); |
2835 | 3490 | if (file_exists($tmp_dir.'satcat.txt')) { |
2836 | - if ($globalDebug) echo "Add to DB..."; |
|
3491 | + if ($globalDebug) { |
|
3492 | + echo "Add to DB..."; |
|
3493 | + } |
|
2837 | 3494 | $error = update_db::satellite_celestrak($tmp_dir.'satcat.txt'); |
2838 | - } else $error = "File ".$tmp_dir.'satcat.txt'." doesn't exist. Download failed."; |
|
3495 | + } else { |
|
3496 | + $error = "File ".$tmp_dir.'satcat.txt'." doesn't exist. Download failed."; |
|
3497 | + } |
|
2839 | 3498 | if ($error != '') { |
2840 | 3499 | echo $error."\n"; |
2841 | - } elseif ($globalDebug) echo "Done\n"; |
|
3500 | + } elseif ($globalDebug) { |
|
3501 | + echo "Done\n"; |
|
3502 | + } |
|
2842 | 3503 | return ''; |
2843 | 3504 | } |
2844 | 3505 | |
2845 | 3506 | public static function update_models() { |
2846 | 3507 | global $tmp_dir, $globalDebug; |
2847 | 3508 | $error = ''; |
2848 | - if ($globalDebug) echo "Models from FlightAirMap website : Download..."; |
|
3509 | + if ($globalDebug) { |
|
3510 | + echo "Models from FlightAirMap website : Download..."; |
|
3511 | + } |
|
2849 | 3512 | if (!is_writable(dirname(__FILE__).'/../models')) { |
2850 | - if ($globalDebug) echo dirname(__FILE__).'/../models'.' is not writable !'; |
|
3513 | + if ($globalDebug) { |
|
3514 | + echo dirname(__FILE__).'/../models'.' is not writable !'; |
|
3515 | + } |
|
2851 | 3516 | return ''; |
2852 | 3517 | } |
2853 | 3518 | update_db::download('http://data.flightairmap.com/data/models/models.md5sum',$tmp_dir.'models.md5sum'); |
2854 | 3519 | if (file_exists($tmp_dir.'models.md5sum')) { |
2855 | - if ($globalDebug) echo "Check files...\n"; |
|
3520 | + if ($globalDebug) { |
|
3521 | + echo "Check files...\n"; |
|
3522 | + } |
|
2856 | 3523 | $newmodelsdb = array(); |
2857 | 3524 | if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) { |
2858 | 3525 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2871,18 +3538,28 @@ discard block |
||
2871 | 3538 | } |
2872 | 3539 | $diff = array_diff($newmodelsdb,$modelsdb); |
2873 | 3540 | foreach ($diff as $key => $value) { |
2874 | - if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n"; |
|
3541 | + if ($globalDebug) { |
|
3542 | + echo 'Downloading model '.$key.' ...'."\n"; |
|
3543 | + } |
|
2875 | 3544 | update_db::download('http://data.flightairmap.com/data/models/'.$key,dirname(__FILE__).'/../models/'.$key); |
2876 | 3545 | } |
2877 | 3546 | update_db::download('http://data.flightairmap.com/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum'); |
2878 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
3547 | + } else { |
|
3548 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
3549 | + } |
|
2879 | 3550 | if ($error != '') { |
2880 | 3551 | return $error; |
2881 | - } elseif ($globalDebug) echo "Done\n"; |
|
2882 | - if ($globalDebug) echo "glTF 2.0 Models from FlightAirMap website : Download..."; |
|
3552 | + } elseif ($globalDebug) { |
|
3553 | + echo "Done\n"; |
|
3554 | + } |
|
3555 | + if ($globalDebug) { |
|
3556 | + echo "glTF 2.0 Models from FlightAirMap website : Download..."; |
|
3557 | + } |
|
2883 | 3558 | update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum',$tmp_dir.'modelsgltf2.md5sum'); |
2884 | 3559 | if (file_exists($tmp_dir.'modelsgltf2.md5sum')) { |
2885 | - if ($globalDebug) echo "Check files...\n"; |
|
3560 | + if ($globalDebug) { |
|
3561 | + echo "Check files...\n"; |
|
3562 | + } |
|
2886 | 3563 | $newmodelsdb = array(); |
2887 | 3564 | if (($handle = fopen($tmp_dir.'modelsgltf2.md5sum','r')) !== FALSE) { |
2888 | 3565 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2901,29 +3578,43 @@ discard block |
||
2901 | 3578 | } |
2902 | 3579 | $diff = array_diff($newmodelsdb,$modelsdb); |
2903 | 3580 | foreach ($diff as $key => $value) { |
2904 | - if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n"; |
|
3581 | + if ($globalDebug) { |
|
3582 | + echo 'Downloading model '.$key.' ...'."\n"; |
|
3583 | + } |
|
2905 | 3584 | update_db::download('http://data.flightairmap.com/data/models/gltf2/'.$key,dirname(__FILE__).'/../models/gltf2/'.$key); |
2906 | 3585 | |
2907 | 3586 | } |
2908 | 3587 | update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum',dirname(__FILE__).'/../models/gltf2/models.md5sum'); |
2909 | - } else $error = "File ".$tmp_dir.'modelsgltf2.md5sum'." doesn't exist. Download failed."; |
|
3588 | + } else { |
|
3589 | + $error = "File ".$tmp_dir.'modelsgltf2.md5sum'." doesn't exist. Download failed."; |
|
3590 | + } |
|
2910 | 3591 | if ($error != '') { |
2911 | 3592 | return $error; |
2912 | - } elseif ($globalDebug) echo "Done\n"; |
|
3593 | + } elseif ($globalDebug) { |
|
3594 | + echo "Done\n"; |
|
3595 | + } |
|
2913 | 3596 | return ''; |
2914 | 3597 | } |
2915 | 3598 | public static function update_weather_models() { |
2916 | 3599 | global $tmp_dir, $globalDebug; |
2917 | 3600 | $error = ''; |
2918 | - if ($globalDebug) echo "Models from FlightAirMap website : Download..."; |
|
3601 | + if ($globalDebug) { |
|
3602 | + echo "Models from FlightAirMap website : Download..."; |
|
3603 | + } |
|
2919 | 3604 | if (!is_writable(dirname(__FILE__).'/../models/gltf2/weather')) { |
2920 | - if ($globalDebug) echo dirname(__FILE__).'/../models/gltf2/weather'.' is not writable !'; |
|
3605 | + if ($globalDebug) { |
|
3606 | + echo dirname(__FILE__).'/../models/gltf2/weather'.' is not writable !'; |
|
3607 | + } |
|
2921 | 3608 | return ''; |
2922 | 3609 | } |
2923 | - if ($globalDebug) echo "Weather Models from FlightAirMap website : Download..."; |
|
3610 | + if ($globalDebug) { |
|
3611 | + echo "Weather Models from FlightAirMap website : Download..."; |
|
3612 | + } |
|
2924 | 3613 | update_db::download('http://data.flightairmap.com/data/models/gltf2/weather/models.md5sum',$tmp_dir.'modelsweather.md5sum'); |
2925 | 3614 | if (file_exists($tmp_dir.'modelsweather.md5sum')) { |
2926 | - if ($globalDebug) echo "Check files...\n"; |
|
3615 | + if ($globalDebug) { |
|
3616 | + echo "Check files...\n"; |
|
3617 | + } |
|
2927 | 3618 | $newmodelsdb = array(); |
2928 | 3619 | if (($handle = fopen($tmp_dir.'modelsweather.md5sum','r')) !== FALSE) { |
2929 | 3620 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2942,25 +3633,35 @@ discard block |
||
2942 | 3633 | } |
2943 | 3634 | $diff = array_diff($newmodelsdb,$modelsdb); |
2944 | 3635 | foreach ($diff as $key => $value) { |
2945 | - if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n"; |
|
3636 | + if ($globalDebug) { |
|
3637 | + echo 'Downloading model '.$key.' ...'."\n"; |
|
3638 | + } |
|
2946 | 3639 | update_db::download('http://data.flightairmap.com/data/models/gltf2/weather/'.$key,dirname(__FILE__).'/../models/gltf2/weather/'.$key); |
2947 | 3640 | |
2948 | 3641 | } |
2949 | 3642 | update_db::download('http://data.flightairmap.com/data/models/gltf2/weather/models.md5sum',dirname(__FILE__).'/../models/gltf2/weather/models.md5sum'); |
2950 | - } else $error = "File ".$tmp_dir.'modelsweather.md5sum'." doesn't exist. Download failed."; |
|
3643 | + } else { |
|
3644 | + $error = "File ".$tmp_dir.'modelsweather.md5sum'." doesn't exist. Download failed."; |
|
3645 | + } |
|
2951 | 3646 | if ($error != '') { |
2952 | 3647 | return $error; |
2953 | - } elseif ($globalDebug) echo "Done\n"; |
|
3648 | + } elseif ($globalDebug) { |
|
3649 | + echo "Done\n"; |
|
3650 | + } |
|
2954 | 3651 | return ''; |
2955 | 3652 | } |
2956 | 3653 | |
2957 | 3654 | public static function update_liveries() { |
2958 | 3655 | global $tmp_dir, $globalDebug; |
2959 | 3656 | $error = ''; |
2960 | - if ($globalDebug) echo "Liveries from FlightAirMap website : Download..."; |
|
3657 | + if ($globalDebug) { |
|
3658 | + echo "Liveries from FlightAirMap website : Download..."; |
|
3659 | + } |
|
2961 | 3660 | update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum',$tmp_dir.'liveries.md5sum'); |
2962 | 3661 | if (file_exists($tmp_dir.'liveries.md5sum')) { |
2963 | - if ($globalDebug) echo "Check files...\n"; |
|
3662 | + if ($globalDebug) { |
|
3663 | + echo "Check files...\n"; |
|
3664 | + } |
|
2964 | 3665 | $newmodelsdb = array(); |
2965 | 3666 | if (($handle = fopen($tmp_dir.'liveries.md5sum','r')) !== FALSE) { |
2966 | 3667 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2979,15 +3680,21 @@ discard block |
||
2979 | 3680 | } |
2980 | 3681 | $diff = array_diff($newmodelsdb,$modelsdb); |
2981 | 3682 | foreach ($diff as $key => $value) { |
2982 | - if ($globalDebug) echo 'Downloading liveries '.$key.' ...'."\n"; |
|
3683 | + if ($globalDebug) { |
|
3684 | + echo 'Downloading liveries '.$key.' ...'."\n"; |
|
3685 | + } |
|
2983 | 3686 | update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/'.$key,dirname(__FILE__).'/../models/gltf2/liveries/'.$key); |
2984 | 3687 | |
2985 | 3688 | } |
2986 | 3689 | update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum',dirname(__FILE__).'/../models/gltf2/liveries/liveries.md5sum'); |
2987 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
3690 | + } else { |
|
3691 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
3692 | + } |
|
2988 | 3693 | if ($error != '') { |
2989 | 3694 | return $error; |
2990 | - } elseif ($globalDebug) echo "Done\n"; |
|
3695 | + } elseif ($globalDebug) { |
|
3696 | + echo "Done\n"; |
|
3697 | + } |
|
2991 | 3698 | return ''; |
2992 | 3699 | } |
2993 | 3700 | |
@@ -2995,13 +3702,19 @@ discard block |
||
2995 | 3702 | global $tmp_dir, $globalDebug; |
2996 | 3703 | $error = ''; |
2997 | 3704 | if (!is_writable(dirname(__FILE__).'/../models')) { |
2998 | - if ($globalDebug) echo dirname(__FILE__).'/../models'.' is not writable !'; |
|
3705 | + if ($globalDebug) { |
|
3706 | + echo dirname(__FILE__).'/../models'.' is not writable !'; |
|
3707 | + } |
|
2999 | 3708 | return ''; |
3000 | 3709 | } |
3001 | - if ($globalDebug) echo "Space models from FlightAirMap website : Download..."; |
|
3710 | + if ($globalDebug) { |
|
3711 | + echo "Space models from FlightAirMap website : Download..."; |
|
3712 | + } |
|
3002 | 3713 | update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum'); |
3003 | 3714 | if (file_exists($tmp_dir.'space_models.md5sum')) { |
3004 | - if ($globalDebug) echo "Check files...\n"; |
|
3715 | + if ($globalDebug) { |
|
3716 | + echo "Check files...\n"; |
|
3717 | + } |
|
3005 | 3718 | $newmodelsdb = array(); |
3006 | 3719 | if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) { |
3007 | 3720 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -3020,15 +3733,21 @@ discard block |
||
3020 | 3733 | } |
3021 | 3734 | $diff = array_diff($newmodelsdb,$modelsdb); |
3022 | 3735 | foreach ($diff as $key => $value) { |
3023 | - if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n"; |
|
3736 | + if ($globalDebug) { |
|
3737 | + echo 'Downloading space model '.$key.' ...'."\n"; |
|
3738 | + } |
|
3024 | 3739 | update_db::download('http://data.flightairmap.com/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key); |
3025 | 3740 | |
3026 | 3741 | } |
3027 | 3742 | update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum'); |
3028 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
3743 | + } else { |
|
3744 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
3745 | + } |
|
3029 | 3746 | if ($error != '') { |
3030 | 3747 | return $error; |
3031 | - } elseif ($globalDebug) echo "Done\n"; |
|
3748 | + } elseif ($globalDebug) { |
|
3749 | + echo "Done\n"; |
|
3750 | + } |
|
3032 | 3751 | return ''; |
3033 | 3752 | } |
3034 | 3753 | |
@@ -3036,13 +3755,19 @@ discard block |
||
3036 | 3755 | global $tmp_dir, $globalDebug; |
3037 | 3756 | $error = ''; |
3038 | 3757 | if (!is_writable(dirname(__FILE__).'/../models/vehicules')) { |
3039 | - if ($globalDebug) echo dirname(__FILE__).'/../models/vehicules'.' is not writable !'; |
|
3758 | + if ($globalDebug) { |
|
3759 | + echo dirname(__FILE__).'/../models/vehicules'.' is not writable !'; |
|
3760 | + } |
|
3040 | 3761 | return ''; |
3041 | 3762 | } |
3042 | - if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download..."; |
|
3763 | + if ($globalDebug) { |
|
3764 | + echo "Vehicules models from FlightAirMap website : Download..."; |
|
3765 | + } |
|
3043 | 3766 | update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum'); |
3044 | 3767 | if (file_exists($tmp_dir.'vehicules_models.md5sum')) { |
3045 | - if ($globalDebug) echo "Check files...\n"; |
|
3768 | + if ($globalDebug) { |
|
3769 | + echo "Check files...\n"; |
|
3770 | + } |
|
3046 | 3771 | $newmodelsdb = array(); |
3047 | 3772 | if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) { |
3048 | 3773 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -3061,15 +3786,21 @@ discard block |
||
3061 | 3786 | } |
3062 | 3787 | $diff = array_diff($newmodelsdb,$modelsdb); |
3063 | 3788 | foreach ($diff as $key => $value) { |
3064 | - if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n"; |
|
3789 | + if ($globalDebug) { |
|
3790 | + echo 'Downloading vehicules model '.$key.' ...'."\n"; |
|
3791 | + } |
|
3065 | 3792 | update_db::download('http://data.flightairmap.com/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key); |
3066 | 3793 | |
3067 | 3794 | } |
3068 | 3795 | update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum'); |
3069 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
3796 | + } else { |
|
3797 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
3798 | + } |
|
3070 | 3799 | if ($error != '') { |
3071 | 3800 | return $error; |
3072 | - } elseif ($globalDebug) echo "Done\n"; |
|
3801 | + } elseif ($globalDebug) { |
|
3802 | + echo "Done\n"; |
|
3803 | + } |
|
3073 | 3804 | return ''; |
3074 | 3805 | } |
3075 | 3806 | |
@@ -3142,7 +3873,9 @@ discard block |
||
3142 | 3873 | } |
3143 | 3874 | |
3144 | 3875 | $error = ''; |
3145 | - if ($globalDebug) echo "Notam : Download..."; |
|
3876 | + if ($globalDebug) { |
|
3877 | + echo "Notam : Download..."; |
|
3878 | + } |
|
3146 | 3879 | update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss'); |
3147 | 3880 | if (file_exists($tmp_dir.'notam.rss')) { |
3148 | 3881 | $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true); |
@@ -3157,14 +3890,30 @@ discard block |
||
3157 | 3890 | $data['fir'] = $q[0]; |
3158 | 3891 | $data['code'] = $q[1]; |
3159 | 3892 | $ifrvfr = $q[2]; |
3160 | - if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR'; |
|
3161 | - if ($ifrvfr == 'I') $data['rules'] = 'IFR'; |
|
3162 | - if ($ifrvfr == 'V') $data['rules'] = 'VFR'; |
|
3163 | - if ($q[4] == 'A') $data['scope'] = 'Airport warning'; |
|
3164 | - if ($q[4] == 'E') $data['scope'] = 'Enroute warning'; |
|
3165 | - if ($q[4] == 'W') $data['scope'] = 'Navigation warning'; |
|
3166 | - if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning'; |
|
3167 | - if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning'; |
|
3893 | + if ($ifrvfr == 'IV') { |
|
3894 | + $data['rules'] = 'IFR/VFR'; |
|
3895 | + } |
|
3896 | + if ($ifrvfr == 'I') { |
|
3897 | + $data['rules'] = 'IFR'; |
|
3898 | + } |
|
3899 | + if ($ifrvfr == 'V') { |
|
3900 | + $data['rules'] = 'VFR'; |
|
3901 | + } |
|
3902 | + if ($q[4] == 'A') { |
|
3903 | + $data['scope'] = 'Airport warning'; |
|
3904 | + } |
|
3905 | + if ($q[4] == 'E') { |
|
3906 | + $data['scope'] = 'Enroute warning'; |
|
3907 | + } |
|
3908 | + if ($q[4] == 'W') { |
|
3909 | + $data['scope'] = 'Navigation warning'; |
|
3910 | + } |
|
3911 | + if ($q[4] == 'AE') { |
|
3912 | + $data['scope'] = 'Airport/Enroute warning'; |
|
3913 | + } |
|
3914 | + if ($q[4] == 'AW') { |
|
3915 | + $data['scope'] = 'Airport/Navigation warning'; |
|
3916 | + } |
|
3168 | 3917 | //$data['scope'] = $q[4]; |
3169 | 3918 | $data['lower_limit'] = $q[5]; |
3170 | 3919 | $data['upper_limit'] = $q[6]; |
@@ -3172,8 +3921,12 @@ discard block |
||
3172 | 3921 | sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius); |
3173 | 3922 | $latitude = $Common->convertDec($las,'latitude'); |
3174 | 3923 | $longitude = $Common->convertDec($lns,'longitude'); |
3175 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
3176 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
3924 | + if ($lac == 'S') { |
|
3925 | + $latitude = '-'.$latitude; |
|
3926 | + } |
|
3927 | + if ($lnc == 'W') { |
|
3928 | + $longitude = '-'.$longitude; |
|
3929 | + } |
|
3177 | 3930 | $data['center_latitude'] = $latitude; |
3178 | 3931 | $data['center_longitude'] = $longitude; |
3179 | 3932 | $data['radius'] = intval($radius); |
@@ -3203,10 +3956,14 @@ discard block |
||
3203 | 3956 | $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']); |
3204 | 3957 | unset($data); |
3205 | 3958 | } |
3206 | - } else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
|
3959 | + } else { |
|
3960 | + $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
|
3961 | + } |
|
3207 | 3962 | if ($error != '') { |
3208 | 3963 | return $error; |
3209 | - } elseif ($globalDebug) echo "Done\n"; |
|
3964 | + } elseif ($globalDebug) { |
|
3965 | + echo "Done\n"; |
|
3966 | + } |
|
3210 | 3967 | return ''; |
3211 | 3968 | } |
3212 | 3969 | |
@@ -3231,7 +3988,9 @@ discard block |
||
3231 | 3988 | $airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json'); |
3232 | 3989 | $airspace_json = json_decode($airspace_lst,true); |
3233 | 3990 | foreach ($airspace_json['records'] as $airspace) { |
3234 | - if ($globalDebug) echo $airspace['name']."...\n"; |
|
3991 | + if ($globalDebug) { |
|
3992 | + echo $airspace['name']."...\n"; |
|
3993 | + } |
|
3235 | 3994 | update_db::download($airspace['uri'],$tmp_dir.$airspace['name']); |
3236 | 3995 | if (file_exists($tmp_dir.$airspace['name'])) { |
3237 | 3996 | file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name']))); |
@@ -3275,8 +4034,11 @@ discard block |
||
3275 | 4034 | return "error : ".$e->getMessage(); |
3276 | 4035 | } |
3277 | 4036 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3278 | - if ($row['nb'] > 0) return false; |
|
3279 | - else return true; |
|
4037 | + if ($row['nb'] > 0) { |
|
4038 | + return false; |
|
4039 | + } else { |
|
4040 | + return true; |
|
4041 | + } |
|
3280 | 4042 | } |
3281 | 4043 | |
3282 | 4044 | public static function insert_last_update() { |
@@ -3301,8 +4063,11 @@ discard block |
||
3301 | 4063 | return "error : ".$e->getMessage(); |
3302 | 4064 | } |
3303 | 4065 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3304 | - if ($row['nb'] > 0) return true; |
|
3305 | - else return false; |
|
4066 | + if ($row['nb'] > 0) { |
|
4067 | + return true; |
|
4068 | + } else { |
|
4069 | + return false; |
|
4070 | + } |
|
3306 | 4071 | } |
3307 | 4072 | |
3308 | 4073 | public static function check_geoid_version($version) { |
@@ -3315,8 +4080,11 @@ discard block |
||
3315 | 4080 | return "error : ".$e->getMessage(); |
3316 | 4081 | } |
3317 | 4082 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3318 | - if ($row['nb'] > 0) return true; |
|
3319 | - else return false; |
|
4083 | + if ($row['nb'] > 0) { |
|
4084 | + return true; |
|
4085 | + } else { |
|
4086 | + return false; |
|
4087 | + } |
|
3320 | 4088 | } |
3321 | 4089 | |
3322 | 4090 | public static function check_marine_identity_version($version) { |
@@ -3329,8 +4097,11 @@ discard block |
||
3329 | 4097 | return "error : ".$e->getMessage(); |
3330 | 4098 | } |
3331 | 4099 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3332 | - if ($row['nb'] > 0) return true; |
|
3333 | - else return false; |
|
4100 | + if ($row['nb'] > 0) { |
|
4101 | + return true; |
|
4102 | + } else { |
|
4103 | + return false; |
|
4104 | + } |
|
3334 | 4105 | } |
3335 | 4106 | |
3336 | 4107 | public static function check_satellite_version($version) { |
@@ -3343,8 +4114,11 @@ discard block |
||
3343 | 4114 | return "error : ".$e->getMessage(); |
3344 | 4115 | } |
3345 | 4116 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3346 | - if ($row['nb'] > 0) return true; |
|
3347 | - else return false; |
|
4117 | + if ($row['nb'] > 0) { |
|
4118 | + return true; |
|
4119 | + } else { |
|
4120 | + return false; |
|
4121 | + } |
|
3348 | 4122 | } |
3349 | 4123 | public static function check_diagrams_version($version) { |
3350 | 4124 | $query = "SELECT COUNT(*) as nb FROM config WHERE name = 'diagrams_version' AND value = :version"; |
@@ -3356,8 +4130,11 @@ discard block |
||
3356 | 4130 | return "error : ".$e->getMessage(); |
3357 | 4131 | } |
3358 | 4132 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3359 | - if ($row['nb'] > 0) return true; |
|
3360 | - else return false; |
|
4133 | + if ($row['nb'] > 0) { |
|
4134 | + return true; |
|
4135 | + } else { |
|
4136 | + return false; |
|
4137 | + } |
|
3361 | 4138 | } |
3362 | 4139 | |
3363 | 4140 | public static function check_airlines_version($version) { |
@@ -3370,8 +4147,11 @@ discard block |
||
3370 | 4147 | return "error : ".$e->getMessage(); |
3371 | 4148 | } |
3372 | 4149 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3373 | - if ($row['nb'] > 0) return true; |
|
3374 | - else return false; |
|
4150 | + if ($row['nb'] > 0) { |
|
4151 | + return true; |
|
4152 | + } else { |
|
4153 | + return false; |
|
4154 | + } |
|
3375 | 4155 | } |
3376 | 4156 | |
3377 | 4157 | public static function check_notam_version($version) { |
@@ -3384,8 +4164,11 @@ discard block |
||
3384 | 4164 | return "error : ".$e->getMessage(); |
3385 | 4165 | } |
3386 | 4166 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3387 | - if ($row['nb'] > 0) return true; |
|
3388 | - else return false; |
|
4167 | + if ($row['nb'] > 0) { |
|
4168 | + return true; |
|
4169 | + } else { |
|
4170 | + return false; |
|
4171 | + } |
|
3389 | 4172 | } |
3390 | 4173 | |
3391 | 4174 | public static function insert_airlines_version($version) { |
@@ -3486,8 +4269,11 @@ discard block |
||
3486 | 4269 | return "error : ".$e->getMessage(); |
3487 | 4270 | } |
3488 | 4271 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3489 | - if ($row['nb'] > 0) return false; |
|
3490 | - else return true; |
|
4272 | + if ($row['nb'] > 0) { |
|
4273 | + return false; |
|
4274 | + } else { |
|
4275 | + return true; |
|
4276 | + } |
|
3491 | 4277 | } |
3492 | 4278 | |
3493 | 4279 | public static function insert_last_notam_update() { |
@@ -3517,8 +4303,11 @@ discard block |
||
3517 | 4303 | return "error : ".$e->getMessage(); |
3518 | 4304 | } |
3519 | 4305 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3520 | - if ($row['nb'] > 0) return false; |
|
3521 | - else return true; |
|
4306 | + if ($row['nb'] > 0) { |
|
4307 | + return false; |
|
4308 | + } else { |
|
4309 | + return true; |
|
4310 | + } |
|
3522 | 4311 | } |
3523 | 4312 | |
3524 | 4313 | public static function insert_last_airspace_update() { |
@@ -3548,8 +4337,11 @@ discard block |
||
3548 | 4337 | return "error : ".$e->getMessage(); |
3549 | 4338 | } |
3550 | 4339 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3551 | - if ($row['nb'] > 0) return false; |
|
3552 | - else return true; |
|
4340 | + if ($row['nb'] > 0) { |
|
4341 | + return false; |
|
4342 | + } else { |
|
4343 | + return true; |
|
4344 | + } |
|
3553 | 4345 | } |
3554 | 4346 | |
3555 | 4347 | public static function insert_last_geoid_update() { |
@@ -3579,8 +4371,11 @@ discard block |
||
3579 | 4371 | return "error : ".$e->getMessage(); |
3580 | 4372 | } |
3581 | 4373 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3582 | - if ($row['nb'] > 0) return false; |
|
3583 | - else return true; |
|
4374 | + if ($row['nb'] > 0) { |
|
4375 | + return false; |
|
4376 | + } else { |
|
4377 | + return true; |
|
4378 | + } |
|
3584 | 4379 | } |
3585 | 4380 | |
3586 | 4381 | public static function insert_last_owner_update() { |
@@ -3610,8 +4405,11 @@ discard block |
||
3610 | 4405 | return "error : ".$e->getMessage(); |
3611 | 4406 | } |
3612 | 4407 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3613 | - if ($row['nb'] > 0) return false; |
|
3614 | - else return true; |
|
4408 | + if ($row['nb'] > 0) { |
|
4409 | + return false; |
|
4410 | + } else { |
|
4411 | + return true; |
|
4412 | + } |
|
3615 | 4413 | } |
3616 | 4414 | |
3617 | 4415 | public static function insert_last_fires_update() { |
@@ -3641,8 +4439,11 @@ discard block |
||
3641 | 4439 | return "error : ".$e->getMessage(); |
3642 | 4440 | } |
3643 | 4441 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3644 | - if ($row['nb'] > 0) return false; |
|
3645 | - else return true; |
|
4442 | + if ($row['nb'] > 0) { |
|
4443 | + return false; |
|
4444 | + } else { |
|
4445 | + return true; |
|
4446 | + } |
|
3646 | 4447 | } |
3647 | 4448 | |
3648 | 4449 | public static function insert_last_airlines_update() { |
@@ -3672,8 +4473,11 @@ discard block |
||
3672 | 4473 | return "error : ".$e->getMessage(); |
3673 | 4474 | } |
3674 | 4475 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3675 | - if ($row['nb'] > 0) return false; |
|
3676 | - else return true; |
|
4476 | + if ($row['nb'] > 0) { |
|
4477 | + return false; |
|
4478 | + } else { |
|
4479 | + return true; |
|
4480 | + } |
|
3677 | 4481 | } |
3678 | 4482 | |
3679 | 4483 | public static function insert_last_schedules_update() { |
@@ -3703,8 +4507,11 @@ discard block |
||
3703 | 4507 | return "error : ".$e->getMessage(); |
3704 | 4508 | } |
3705 | 4509 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3706 | - if ($row['nb'] > 0) return false; |
|
3707 | - else return true; |
|
4510 | + if ($row['nb'] > 0) { |
|
4511 | + return false; |
|
4512 | + } else { |
|
4513 | + return true; |
|
4514 | + } |
|
3708 | 4515 | } |
3709 | 4516 | |
3710 | 4517 | public static function insert_last_tle_update() { |
@@ -3734,8 +4541,11 @@ discard block |
||
3734 | 4541 | return "error : ".$e->getMessage(); |
3735 | 4542 | } |
3736 | 4543 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3737 | - if ($row['nb'] > 0) return false; |
|
3738 | - else return true; |
|
4544 | + if ($row['nb'] > 0) { |
|
4545 | + return false; |
|
4546 | + } else { |
|
4547 | + return true; |
|
4548 | + } |
|
3739 | 4549 | } |
3740 | 4550 | |
3741 | 4551 | public static function insert_last_ucsdb_update() { |
@@ -3765,8 +4575,11 @@ discard block |
||
3765 | 4575 | return "error : ".$e->getMessage(); |
3766 | 4576 | } |
3767 | 4577 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3768 | - if ($row['nb'] > 0) return false; |
|
3769 | - else return true; |
|
4578 | + if ($row['nb'] > 0) { |
|
4579 | + return false; |
|
4580 | + } else { |
|
4581 | + return true; |
|
4582 | + } |
|
3770 | 4583 | } |
3771 | 4584 | |
3772 | 4585 | public static function insert_last_celestrak_update() { |
@@ -3796,8 +4609,11 @@ discard block |
||
3796 | 4609 | return "error : ".$e->getMessage(); |
3797 | 4610 | } |
3798 | 4611 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3799 | - if ($row['nb'] > 0) return false; |
|
3800 | - else return true; |
|
4612 | + if ($row['nb'] > 0) { |
|
4613 | + return false; |
|
4614 | + } else { |
|
4615 | + return true; |
|
4616 | + } |
|
3801 | 4617 | } |
3802 | 4618 | |
3803 | 4619 | public static function check_last_satellite_update() { |
@@ -3815,8 +4631,11 @@ discard block |
||
3815 | 4631 | return "error : ".$e->getMessage(); |
3816 | 4632 | } |
3817 | 4633 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3818 | - if ($row['nb'] > 0) return false; |
|
3819 | - else return true; |
|
4634 | + if ($row['nb'] > 0) { |
|
4635 | + return false; |
|
4636 | + } else { |
|
4637 | + return true; |
|
4638 | + } |
|
3820 | 4639 | } |
3821 | 4640 | |
3822 | 4641 | public static function insert_last_marine_identity_update() { |