@@ -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'; |
@@ -1083,7 +1202,9 @@ discard block |
||
1083 | 1202 | if (($handle = fopen($tmp_dir.'MASTER.txt', 'r')) !== FALSE) |
1084 | 1203 | { |
1085 | 1204 | $i = 0; |
1086 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1205 | + if ($globalTransaction) { |
|
1206 | + $Connection->db->beginTransaction(); |
|
1207 | + } |
|
1087 | 1208 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1088 | 1209 | { |
1089 | 1210 | if ($i > 0) { |
@@ -1096,7 +1217,9 @@ discard block |
||
1096 | 1217 | } |
1097 | 1218 | $result_search = $sths->fetchAll(PDO::FETCH_ASSOC); |
1098 | 1219 | if (!empty($result_search)) { |
1099 | - if ($globalDebug) echo '.'; |
|
1220 | + if ($globalDebug) { |
|
1221 | + echo '.'; |
|
1222 | + } |
|
1100 | 1223 | //if ($globalDBdriver == 'mysql') { |
1101 | 1224 | // $queryi = 'INSERT INTO faamfr (mfr,icao) VALUES (:mfr,:icao) ON DUPLICATE KEY UPDATE icao = :icao'; |
1102 | 1225 | //} else { |
@@ -1118,8 +1241,12 @@ discard block |
||
1118 | 1241 | } |
1119 | 1242 | $result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC); |
1120 | 1243 | if (!empty($result_search_mfr)) { |
1121 | - if (trim($data[16]) == '' && trim($data[23]) != '') $data[16] = $data[23]; |
|
1122 | - if (trim($data[16]) == '' && trim($data[15]) != '') $data[16] = $data[15]; |
|
1244 | + if (trim($data[16]) == '' && trim($data[23]) != '') { |
|
1245 | + $data[16] = $data[23]; |
|
1246 | + } |
|
1247 | + if (trim($data[16]) == '' && trim($data[15]) != '') { |
|
1248 | + $data[16] = $data[15]; |
|
1249 | + } |
|
1123 | 1250 | $queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)'; |
1124 | 1251 | try { |
1125 | 1252 | $sthf = $Connection->db->prepare($queryf); |
@@ -1130,7 +1257,9 @@ discard block |
||
1130 | 1257 | } |
1131 | 1258 | } |
1132 | 1259 | if (strtotime($data[29]) > time()) { |
1133 | - if ($globalDebug) echo 'i'; |
|
1260 | + if ($globalDebug) { |
|
1261 | + echo 'i'; |
|
1262 | + } |
|
1134 | 1263 | $query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)'; |
1135 | 1264 | try { |
1136 | 1265 | $sth = $Connection->db->prepare($query); |
@@ -1141,13 +1270,19 @@ discard block |
||
1141 | 1270 | } |
1142 | 1271 | } |
1143 | 1272 | if ($i % 90 == 0) { |
1144 | - if ($globalTransaction) $Connection->db->commit(); |
|
1145 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1273 | + if ($globalTransaction) { |
|
1274 | + $Connection->db->commit(); |
|
1275 | + } |
|
1276 | + if ($globalTransaction) { |
|
1277 | + $Connection->db->beginTransaction(); |
|
1278 | + } |
|
1146 | 1279 | } |
1147 | 1280 | $i++; |
1148 | 1281 | } |
1149 | 1282 | fclose($handle); |
1150 | - if ($globalTransaction) $Connection->db->commit(); |
|
1283 | + if ($globalTransaction) { |
|
1284 | + $Connection->db->commit(); |
|
1285 | + } |
|
1151 | 1286 | } |
1152 | 1287 | return ''; |
1153 | 1288 | } |
@@ -1167,11 +1302,15 @@ discard block |
||
1167 | 1302 | if (($handle = fopen($tmp_dir.'modes.tsv', 'r')) !== FALSE) |
1168 | 1303 | { |
1169 | 1304 | $i = 0; |
1170 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1305 | + if ($globalTransaction) { |
|
1306 | + $Connection->db->beginTransaction(); |
|
1307 | + } |
|
1171 | 1308 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1172 | 1309 | { |
1173 | 1310 | if ($i > 0) { |
1174 | - if ($data[1] == 'NULL') $data[1] = $data[0]; |
|
1311 | + if ($data[1] == 'NULL') { |
|
1312 | + $data[1] = $data[0]; |
|
1313 | + } |
|
1175 | 1314 | $query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)'; |
1176 | 1315 | try { |
1177 | 1316 | $sth = $Connection->db->prepare($query); |
@@ -1183,7 +1322,9 @@ discard block |
||
1183 | 1322 | $i++; |
1184 | 1323 | } |
1185 | 1324 | fclose($handle); |
1186 | - if ($globalTransaction) $Connection->db->commit(); |
|
1325 | + if ($globalTransaction) { |
|
1326 | + $Connection->db->commit(); |
|
1327 | + } |
|
1187 | 1328 | } |
1188 | 1329 | return ''; |
1189 | 1330 | } |
@@ -1215,11 +1356,15 @@ discard block |
||
1215 | 1356 | if (($handle = fopen($tmp_dir.'airlines.tsv', 'r')) !== FALSE) |
1216 | 1357 | { |
1217 | 1358 | $i = 0; |
1218 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1359 | + if ($globalTransaction) { |
|
1360 | + $Connection->db->beginTransaction(); |
|
1361 | + } |
|
1219 | 1362 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1220 | 1363 | { |
1221 | 1364 | if ($i > 0) { |
1222 | - if ($data[1] == 'NULL') $data[1] = $data[0]; |
|
1365 | + if ($data[1] == 'NULL') { |
|
1366 | + $data[1] = $data[0]; |
|
1367 | + } |
|
1223 | 1368 | $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)'; |
1224 | 1369 | try { |
1225 | 1370 | $sth = $Connection->db->prepare($query); |
@@ -1231,7 +1376,9 @@ discard block |
||
1231 | 1376 | $i++; |
1232 | 1377 | } |
1233 | 1378 | fclose($handle); |
1234 | - if ($globalTransaction) $Connection->db->commit(); |
|
1379 | + if ($globalTransaction) { |
|
1380 | + $Connection->db->commit(); |
|
1381 | + } |
|
1235 | 1382 | } |
1236 | 1383 | /* |
1237 | 1384 | $query = "UNLOCK TABLES"; |
@@ -1261,7 +1408,9 @@ discard block |
||
1261 | 1408 | if (($handle = fopen($tmp_dir.'owners.tsv', 'r')) !== FALSE) |
1262 | 1409 | { |
1263 | 1410 | $i = 0; |
1264 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1411 | + if ($globalTransaction) { |
|
1412 | + $Connection->db->beginTransaction(); |
|
1413 | + } |
|
1265 | 1414 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1266 | 1415 | { |
1267 | 1416 | if ($i > 0) { |
@@ -1277,7 +1426,9 @@ discard block |
||
1277 | 1426 | $i++; |
1278 | 1427 | } |
1279 | 1428 | fclose($handle); |
1280 | - if ($globalTransaction) $Connection->db->commit(); |
|
1429 | + if ($globalTransaction) { |
|
1430 | + $Connection->db->commit(); |
|
1431 | + } |
|
1281 | 1432 | } |
1282 | 1433 | return ''; |
1283 | 1434 | } |
@@ -1297,7 +1448,9 @@ discard block |
||
1297 | 1448 | if (($handle = fopen($tmp_dir.'routes.tsv', 'r')) !== FALSE) |
1298 | 1449 | { |
1299 | 1450 | $i = 0; |
1300 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1451 | + if ($globalTransaction) { |
|
1452 | + $Connection->db->beginTransaction(); |
|
1453 | + } |
|
1301 | 1454 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1302 | 1455 | { |
1303 | 1456 | if ($i > 0) { |
@@ -1307,19 +1460,25 @@ discard block |
||
1307 | 1460 | $sth = $Connection->db->prepare($query); |
1308 | 1461 | $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')); |
1309 | 1462 | } catch(PDOException $e) { |
1310 | - if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".implode(',',$data); |
|
1463 | + if ($globalDebug) { |
|
1464 | + echo "error: ".$e->getMessage()." - data: ".implode(',',$data); |
|
1465 | + } |
|
1311 | 1466 | die(); |
1312 | 1467 | } |
1313 | 1468 | } |
1314 | 1469 | if ($globalTransaction && $i % 2000 == 0) { |
1315 | 1470 | $Connection->db->commit(); |
1316 | - if ($globalDebug) echo '.'; |
|
1471 | + if ($globalDebug) { |
|
1472 | + echo '.'; |
|
1473 | + } |
|
1317 | 1474 | $Connection->db->beginTransaction(); |
1318 | 1475 | } |
1319 | 1476 | $i++; |
1320 | 1477 | } |
1321 | 1478 | fclose($handle); |
1322 | - if ($globalTransaction) $Connection->db->commit(); |
|
1479 | + if ($globalTransaction) { |
|
1480 | + $Connection->db->commit(); |
|
1481 | + } |
|
1323 | 1482 | } |
1324 | 1483 | return ''; |
1325 | 1484 | } |
@@ -1338,7 +1497,9 @@ discard block |
||
1338 | 1497 | if (($handle = fopen($tmp_dir.'block.tsv', 'r')) !== FALSE) |
1339 | 1498 | { |
1340 | 1499 | $i = 0; |
1341 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1500 | + if ($globalTransaction) { |
|
1501 | + $Connection->db->beginTransaction(); |
|
1502 | + } |
|
1342 | 1503 | while (($data = fgets($handle, 1000)) !== FALSE) |
1343 | 1504 | { |
1344 | 1505 | $query = 'INSERT INTO aircraft_block (callSign,Source) VALUES (:callSign,:source)'; |
@@ -1346,18 +1507,24 @@ discard block |
||
1346 | 1507 | $sth = $Connection->db->prepare($query); |
1347 | 1508 | $sth->execute(array(':callSign' => trim($data),':source' => 'website_fam')); |
1348 | 1509 | } catch(PDOException $e) { |
1349 | - if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".$data; |
|
1510 | + if ($globalDebug) { |
|
1511 | + echo "error: ".$e->getMessage()." - data: ".$data; |
|
1512 | + } |
|
1350 | 1513 | die(); |
1351 | 1514 | } |
1352 | 1515 | if ($globalTransaction && $i % 2000 == 0) { |
1353 | 1516 | $Connection->db->commit(); |
1354 | - if ($globalDebug) echo '.'; |
|
1517 | + if ($globalDebug) { |
|
1518 | + echo '.'; |
|
1519 | + } |
|
1355 | 1520 | $Connection->db->beginTransaction(); |
1356 | 1521 | } |
1357 | 1522 | $i++; |
1358 | 1523 | } |
1359 | 1524 | fclose($handle); |
1360 | - if ($globalTransaction) $Connection->db->commit(); |
|
1525 | + if ($globalTransaction) { |
|
1526 | + $Connection->db->commit(); |
|
1527 | + } |
|
1361 | 1528 | } |
1362 | 1529 | return ''; |
1363 | 1530 | } |
@@ -1382,7 +1549,9 @@ discard block |
||
1382 | 1549 | $i = 0; |
1383 | 1550 | //$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE); |
1384 | 1551 | //$Connection->db->beginTransaction(); |
1385 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1552 | + if ($globalTransaction) { |
|
1553 | + $Connection->db->beginTransaction(); |
|
1554 | + } |
|
1386 | 1555 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1387 | 1556 | { |
1388 | 1557 | if ($i > 0) { |
@@ -1398,7 +1567,9 @@ discard block |
||
1398 | 1567 | $i++; |
1399 | 1568 | } |
1400 | 1569 | fclose($handle); |
1401 | - if ($globalTransaction) $Connection->db->commit(); |
|
1570 | + if ($globalTransaction) { |
|
1571 | + $Connection->db->commit(); |
|
1572 | + } |
|
1402 | 1573 | } |
1403 | 1574 | return ''; |
1404 | 1575 | } |
@@ -1418,7 +1589,9 @@ discard block |
||
1418 | 1589 | if (($handle = fopen($tmp_dir.'satellite.tsv', 'r')) !== FALSE) |
1419 | 1590 | { |
1420 | 1591 | $i = 0; |
1421 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1592 | + if ($globalTransaction) { |
|
1593 | + $Connection->db->beginTransaction(); |
|
1594 | + } |
|
1422 | 1595 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1423 | 1596 | { |
1424 | 1597 | if ($i > 0) { |
@@ -1435,7 +1608,9 @@ discard block |
||
1435 | 1608 | $i++; |
1436 | 1609 | } |
1437 | 1610 | fclose($handle); |
1438 | - if ($globalTransaction) $Connection->db->commit(); |
|
1611 | + if ($globalTransaction) { |
|
1612 | + $Connection->db->commit(); |
|
1613 | + } |
|
1439 | 1614 | } |
1440 | 1615 | return ''; |
1441 | 1616 | } |
@@ -1454,7 +1629,9 @@ discard block |
||
1454 | 1629 | $Connection = new Connection(); |
1455 | 1630 | if (($handle = fopen($tmp_dir.'ban_eu.csv', 'r')) !== FALSE) |
1456 | 1631 | { |
1457 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1632 | + if ($globalTransaction) { |
|
1633 | + $Connection->db->beginTransaction(); |
|
1634 | + } |
|
1458 | 1635 | while (($data = fgetcsv($handle, 1000)) !== FALSE) |
1459 | 1636 | { |
1460 | 1637 | $query = 'UPDATE airlines SET ban_eu = 1 WHERE icao = :icao AND forsource IS NULL'; |
@@ -1469,7 +1646,9 @@ discard block |
||
1469 | 1646 | } |
1470 | 1647 | } |
1471 | 1648 | fclose($handle); |
1472 | - if ($globalTransaction) $Connection->db->commit(); |
|
1649 | + if ($globalTransaction) { |
|
1650 | + $Connection->db->commit(); |
|
1651 | + } |
|
1473 | 1652 | } |
1474 | 1653 | return ''; |
1475 | 1654 | } |
@@ -1547,9 +1726,14 @@ discard block |
||
1547 | 1726 | if ($i > 0 && $data[0] != '') { |
1548 | 1727 | $sources = trim($data[28].' '.$data[29].' '.$data[30].' '.$data[31].' '.$data[32].' '.$data[33]); |
1549 | 1728 | $period = str_replace(',','',$data[14]); |
1550 | - if (!empty($period) && strpos($period,'days')) $period = str_replace(' days','',$period)*24*60; |
|
1551 | - if ($data[18] != '') $launch_date = date('Y-m-d',strtotime($data[18])); |
|
1552 | - else $launch_date = NULL; |
|
1729 | + if (!empty($period) && strpos($period,'days')) { |
|
1730 | + $period = str_replace(' days','',$period)*24*60; |
|
1731 | + } |
|
1732 | + if ($data[18] != '') { |
|
1733 | + $launch_date = date('Y-m-d',strtotime($data[18])); |
|
1734 | + } else { |
|
1735 | + $launch_date = NULL; |
|
1736 | + } |
|
1553 | 1737 | $data = array_map(function($value) { |
1554 | 1738 | return trim($value) === '' ? null : $value; |
1555 | 1739 | }, $data); |
@@ -1741,10 +1925,14 @@ discard block |
||
1741 | 1925 | $owner_code = trim(substr($data,49,5)); |
1742 | 1926 | |
1743 | 1927 | if (!isset($satcat_sources[$owner_code]) && $satcat_sources[$owner_code] != 'TBD') { |
1744 | - if ($globalDebug) echo $data.'owner_code: '.$owner_code."\n"; |
|
1928 | + if ($globalDebug) { |
|
1929 | + echo $data.'owner_code: '.$owner_code."\n"; |
|
1930 | + } |
|
1745 | 1931 | } |
1746 | 1932 | if (!isset($satcat_launch_site[trim(substr($data,68,5))])) { |
1747 | - if ($globalDebug) echo 'launch_site_code: '.trim(substr($data,68,5))."\n"; |
|
1933 | + if ($globalDebug) { |
|
1934 | + echo 'launch_site_code: '.trim(substr($data,68,5))."\n"; |
|
1935 | + } |
|
1748 | 1936 | } |
1749 | 1937 | |
1750 | 1938 | if ($owner_code != 'TBD' && isset($satcat_sources[$owner_code]) && isset($satcat_launch_site[trim(substr($data,68,5))])) { |
@@ -1911,7 +2099,9 @@ discard block |
||
1911 | 2099 | if (($handle = fopen($filename, 'r')) !== FALSE) |
1912 | 2100 | { |
1913 | 2101 | $i = 0; |
1914 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
2102 | + if ($globalTransaction) { |
|
2103 | + $Connection->db->beginTransaction(); |
|
2104 | + } |
|
1915 | 2105 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1916 | 2106 | { |
1917 | 2107 | $i++; |
@@ -1939,7 +2129,9 @@ discard block |
||
1939 | 2129 | } |
1940 | 2130 | } |
1941 | 2131 | fclose($handle); |
1942 | - if ($globalTransaction) $Connection->db->commit(); |
|
2132 | + if ($globalTransaction) { |
|
2133 | + $Connection->db->commit(); |
|
2134 | + } |
|
1943 | 2135 | } |
1944 | 2136 | return ''; |
1945 | 2137 | } |
@@ -1955,7 +2147,9 @@ discard block |
||
1955 | 2147 | $Source->deleteLocationByType('fires'); |
1956 | 2148 | $i = 0; |
1957 | 2149 | if (($handle = fopen($tmp_dir.'fires.csv','r')) !== false) { |
1958 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
2150 | + if ($globalTransaction) { |
|
2151 | + $Connection->db->beginTransaction(); |
|
2152 | + } |
|
1959 | 2153 | while (($row = fgetcsv($handle,1000)) !== false) { |
1960 | 2154 | if ($i > 0 && $row[0] != '' && $row[8] != 'low') { |
1961 | 2155 | $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]); |
@@ -1970,7 +2164,9 @@ discard block |
||
1970 | 2164 | } |
1971 | 2165 | $i++; |
1972 | 2166 | } |
1973 | - if ($globalTransaction) $Connection->db->commit(); |
|
2167 | + if ($globalTransaction) { |
|
2168 | + $Connection->db->commit(); |
|
2169 | + } |
|
1974 | 2170 | } |
1975 | 2171 | } |
1976 | 2172 | |
@@ -1991,7 +2187,9 @@ discard block |
||
1991 | 2187 | $Connection = new Connection(); |
1992 | 2188 | if (($handle = fopen($filename, 'r')) !== FALSE) |
1993 | 2189 | { |
1994 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
2190 | + if ($globalTransaction) { |
|
2191 | + $Connection->db->beginTransaction(); |
|
2192 | + } |
|
1995 | 2193 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1996 | 2194 | { |
1997 | 2195 | if(count($row) > 1) { |
@@ -2005,7 +2203,9 @@ discard block |
||
2005 | 2203 | } |
2006 | 2204 | } |
2007 | 2205 | fclose($handle); |
2008 | - if ($globalTransaction) $Connection->db->commit(); |
|
2206 | + if ($globalTransaction) { |
|
2207 | + $Connection->db->commit(); |
|
2208 | + } |
|
2009 | 2209 | } |
2010 | 2210 | return ''; |
2011 | 2211 | } |
@@ -2025,8 +2225,9 @@ discard block |
||
2025 | 2225 | } |
2026 | 2226 | |
2027 | 2227 | |
2028 | - if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
2029 | - else { |
|
2228 | + if ($globalDBdriver == 'mysql') { |
|
2229 | + update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
2230 | + } else { |
|
2030 | 2231 | update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
2031 | 2232 | $query = "CREATE EXTENSION postgis"; |
2032 | 2233 | $Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']); |
@@ -2045,7 +2246,9 @@ discard block |
||
2045 | 2246 | global $tmp_dir, $globalDebug; |
2046 | 2247 | include_once('class.create_db.php'); |
2047 | 2248 | require_once(dirname(__FILE__).'/../require/class.NOTAM.php'); |
2048 | - if ($globalDebug) echo "NOTAM from FlightAirMap website : Download..."; |
|
2249 | + if ($globalDebug) { |
|
2250 | + echo "NOTAM from FlightAirMap website : Download..."; |
|
2251 | + } |
|
2049 | 2252 | update_db::download('http://data.flightairmap.com/data/notam.txt.gz.md5',$tmp_dir.'notam.txt.gz.md5'); |
2050 | 2253 | $error = ''; |
2051 | 2254 | if (file_exists($tmp_dir.'notam.txt.gz.md5')) { |
@@ -2055,20 +2258,34 @@ discard block |
||
2055 | 2258 | update_db::download('http://data.flightairmap.com/data/notam.txt.gz',$tmp_dir.'notam.txt.gz'); |
2056 | 2259 | if (file_exists($tmp_dir.'notam.txt.gz')) { |
2057 | 2260 | if (md5_file($tmp_dir.'notam.txt.gz') == $notam_md5) { |
2058 | - if ($globalDebug) echo "Gunzip..."; |
|
2261 | + if ($globalDebug) { |
|
2262 | + echo "Gunzip..."; |
|
2263 | + } |
|
2059 | 2264 | update_db::gunzip($tmp_dir.'notam.txt.gz'); |
2060 | - if ($globalDebug) echo "Add to DB..."; |
|
2265 | + if ($globalDebug) { |
|
2266 | + echo "Add to DB..."; |
|
2267 | + } |
|
2061 | 2268 | //$error = create_db::import_file($tmp_dir.'notam.sql'); |
2062 | 2269 | $NOTAM = new NOTAM(); |
2063 | 2270 | $NOTAM->updateNOTAMfromTextFile($tmp_dir.'notam.txt'); |
2064 | 2271 | update_db::insert_notam_version($notam_md5); |
2065 | - } else $error = "File ".$tmp_dir.'notam.txt.gz'." md5 failed. Download failed."; |
|
2066 | - } else $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed."; |
|
2067 | - } elseif ($globalDebug) echo "No new version."; |
|
2068 | - } else $error = "File ".$tmp_dir.'notam.txt.gz.md5'." doesn't exist. Download failed."; |
|
2272 | + } else { |
|
2273 | + $error = "File ".$tmp_dir.'notam.txt.gz'." md5 failed. Download failed."; |
|
2274 | + } |
|
2275 | + } else { |
|
2276 | + $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed."; |
|
2277 | + } |
|
2278 | + } elseif ($globalDebug) { |
|
2279 | + echo "No new version."; |
|
2280 | + } |
|
2281 | + } else { |
|
2282 | + $error = "File ".$tmp_dir.'notam.txt.gz.md5'." doesn't exist. Download failed."; |
|
2283 | + } |
|
2069 | 2284 | if ($error != '') { |
2070 | 2285 | return $error; |
2071 | - } elseif ($globalDebug) echo "Done\n"; |
|
2286 | + } elseif ($globalDebug) { |
|
2287 | + echo "Done\n"; |
|
2288 | + } |
|
2072 | 2289 | return ''; |
2073 | 2290 | } |
2074 | 2291 | |
@@ -2123,68 +2340,114 @@ discard block |
||
2123 | 2340 | //update_db::download('http://fr.mirror.ivao.aero/software/ivae_feb2013.zip',$tmp_dir.'ivae_feb2013.zip'); |
2124 | 2341 | if (extension_loaded('zip')) { |
2125 | 2342 | if (file_exists($tmp_dir.'ivae_feb2013.zip')) { |
2126 | - if ($globalDebug) echo "Unzip..."; |
|
2343 | + if ($globalDebug) { |
|
2344 | + echo "Unzip..."; |
|
2345 | + } |
|
2127 | 2346 | update_db::unzip($tmp_dir.'ivae_feb2013.zip'); |
2128 | - if ($globalDebug) echo "Add to DB..."; |
|
2347 | + if ($globalDebug) { |
|
2348 | + echo "Add to DB..."; |
|
2349 | + } |
|
2129 | 2350 | update_db::ivao_airlines($tmp_dir.'data/airlines.dat'); |
2130 | - if ($globalDebug) echo "Copy airlines logos to airlines images directory..."; |
|
2351 | + if ($globalDebug) { |
|
2352 | + echo "Copy airlines logos to airlines images directory..."; |
|
2353 | + } |
|
2131 | 2354 | if (is_writable(dirname(__FILE__).'/../images/airlines')) { |
2132 | - if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
2133 | - } else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
|
2134 | - } else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
|
2135 | - } else $error = "ZIP module not loaded but required for IVAO."; |
|
2355 | + if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) { |
|
2356 | + $error = "Failed to copy airlines logo."; |
|
2357 | + } |
|
2358 | + } else { |
|
2359 | + $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
|
2360 | + } |
|
2361 | + } else { |
|
2362 | + $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
|
2363 | + } |
|
2364 | + } else { |
|
2365 | + $error = "ZIP module not loaded but required for IVAO."; |
|
2366 | + } |
|
2136 | 2367 | if ($error != '') { |
2137 | 2368 | return $error; |
2138 | - } elseif ($globalDebug) echo "Done\n"; |
|
2369 | + } elseif ($globalDebug) { |
|
2370 | + echo "Done\n"; |
|
2371 | + } |
|
2139 | 2372 | return ''; |
2140 | 2373 | } |
2141 | 2374 | |
2142 | 2375 | public static function update_routes() { |
2143 | 2376 | global $tmp_dir, $globalDebug; |
2144 | 2377 | $error = ''; |
2145 | - if ($globalDebug) echo "Routes : Download..."; |
|
2378 | + if ($globalDebug) { |
|
2379 | + echo "Routes : Download..."; |
|
2380 | + } |
|
2146 | 2381 | update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz'); |
2147 | 2382 | if (file_exists($tmp_dir.'StandingData.sqb.gz')) { |
2148 | - if ($globalDebug) echo "Gunzip..."; |
|
2383 | + if ($globalDebug) { |
|
2384 | + echo "Gunzip..."; |
|
2385 | + } |
|
2149 | 2386 | update_db::gunzip($tmp_dir.'StandingData.sqb.gz'); |
2150 | - if ($globalDebug) echo "Add to DB..."; |
|
2387 | + if ($globalDebug) { |
|
2388 | + echo "Add to DB..."; |
|
2389 | + } |
|
2151 | 2390 | $error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb'); |
2152 | - } else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed."; |
|
2391 | + } else { |
|
2392 | + $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed."; |
|
2393 | + } |
|
2153 | 2394 | if ($error != '') { |
2154 | 2395 | return $error; |
2155 | - } elseif ($globalDebug) echo "Done\n"; |
|
2396 | + } elseif ($globalDebug) { |
|
2397 | + echo "Done\n"; |
|
2398 | + } |
|
2156 | 2399 | return ''; |
2157 | 2400 | } |
2158 | 2401 | public static function update_oneworld() { |
2159 | 2402 | global $tmp_dir, $globalDebug; |
2160 | 2403 | $error = ''; |
2161 | - if ($globalDebug) echo "Schedules Oneworld : Download..."; |
|
2404 | + if ($globalDebug) { |
|
2405 | + echo "Schedules Oneworld : Download..."; |
|
2406 | + } |
|
2162 | 2407 | update_db::download('http://data.flightairmap.com/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz'); |
2163 | 2408 | if (file_exists($tmp_dir.'oneworld.csv.gz')) { |
2164 | - if ($globalDebug) echo "Gunzip..."; |
|
2409 | + if ($globalDebug) { |
|
2410 | + echo "Gunzip..."; |
|
2411 | + } |
|
2165 | 2412 | update_db::gunzip($tmp_dir.'oneworld.csv.gz'); |
2166 | - if ($globalDebug) echo "Add to DB..."; |
|
2413 | + if ($globalDebug) { |
|
2414 | + echo "Add to DB..."; |
|
2415 | + } |
|
2167 | 2416 | $error = update_db::retrieve_route_oneworld($tmp_dir.'oneworld.csv'); |
2168 | - } else $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed."; |
|
2417 | + } else { |
|
2418 | + $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed."; |
|
2419 | + } |
|
2169 | 2420 | if ($error != '') { |
2170 | 2421 | return $error; |
2171 | - } elseif ($globalDebug) echo "Done\n"; |
|
2422 | + } elseif ($globalDebug) { |
|
2423 | + echo "Done\n"; |
|
2424 | + } |
|
2172 | 2425 | return ''; |
2173 | 2426 | } |
2174 | 2427 | public static function update_skyteam() { |
2175 | 2428 | global $tmp_dir, $globalDebug; |
2176 | 2429 | $error = ''; |
2177 | - if ($globalDebug) echo "Schedules Skyteam : Download..."; |
|
2430 | + if ($globalDebug) { |
|
2431 | + echo "Schedules Skyteam : Download..."; |
|
2432 | + } |
|
2178 | 2433 | update_db::download('http://data.flightairmap.com/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz'); |
2179 | 2434 | if (file_exists($tmp_dir.'skyteam.csv.gz')) { |
2180 | - if ($globalDebug) echo "Gunzip..."; |
|
2435 | + if ($globalDebug) { |
|
2436 | + echo "Gunzip..."; |
|
2437 | + } |
|
2181 | 2438 | update_db::gunzip($tmp_dir.'skyteam.csv.gz'); |
2182 | - if ($globalDebug) echo "Add to DB..."; |
|
2439 | + if ($globalDebug) { |
|
2440 | + echo "Add to DB..."; |
|
2441 | + } |
|
2183 | 2442 | $error = update_db::retrieve_route_skyteam($tmp_dir.'skyteam.csv'); |
2184 | - } else $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed."; |
|
2443 | + } else { |
|
2444 | + $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed."; |
|
2445 | + } |
|
2185 | 2446 | if ($error != '') { |
2186 | 2447 | return $error; |
2187 | - } elseif ($globalDebug) echo "Done\n"; |
|
2448 | + } elseif ($globalDebug) { |
|
2449 | + echo "Done\n"; |
|
2450 | + } |
|
2188 | 2451 | return ''; |
2189 | 2452 | } |
2190 | 2453 | public static function update_ModeS() { |
@@ -2201,340 +2464,590 @@ discard block |
||
2201 | 2464 | exit; |
2202 | 2465 | } elseif ($globalDebug) echo "Done\n"; |
2203 | 2466 | */ |
2204 | - if ($globalDebug) echo "Modes : Download..."; |
|
2205 | -// update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
|
2467 | + if ($globalDebug) { |
|
2468 | + echo "Modes : Download..."; |
|
2469 | + } |
|
2470 | + // update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
|
2206 | 2471 | update_db::download('http://data.flightairmap.com/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz'); |
2207 | 2472 | |
2208 | 2473 | // if (file_exists($tmp_dir.'basestation_latest.zip')) { |
2209 | 2474 | if (file_exists($tmp_dir.'BaseStation.sqb.gz')) { |
2210 | - if ($globalDebug) echo "Unzip..."; |
|
2211 | -// update_db::unzip($tmp_dir.'basestation_latest.zip'); |
|
2475 | + if ($globalDebug) { |
|
2476 | + echo "Unzip..."; |
|
2477 | + } |
|
2478 | + // update_db::unzip($tmp_dir.'basestation_latest.zip'); |
|
2212 | 2479 | update_db::gunzip($tmp_dir.'BaseStation.sqb.gz'); |
2213 | - if ($globalDebug) echo "Add to DB..."; |
|
2480 | + if ($globalDebug) { |
|
2481 | + echo "Add to DB..."; |
|
2482 | + } |
|
2214 | 2483 | $error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb'); |
2215 | 2484 | // $error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'basestation.sqb'); |
2216 | - } else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed."; |
|
2485 | + } else { |
|
2486 | + $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed."; |
|
2487 | + } |
|
2217 | 2488 | if ($error != '') { |
2218 | 2489 | return $error; |
2219 | - } elseif ($globalDebug) echo "Done\n"; |
|
2490 | + } elseif ($globalDebug) { |
|
2491 | + echo "Done\n"; |
|
2492 | + } |
|
2220 | 2493 | return ''; |
2221 | 2494 | } |
2222 | 2495 | |
2223 | 2496 | public static function update_ModeS_faa() { |
2224 | 2497 | global $tmp_dir, $globalDebug; |
2225 | - if ($globalDebug) echo "Modes FAA: Download..."; |
|
2498 | + if ($globalDebug) { |
|
2499 | + echo "Modes FAA: Download..."; |
|
2500 | + } |
|
2226 | 2501 | update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip'); |
2227 | 2502 | if (file_exists($tmp_dir.'ReleasableAircraft.zip')) { |
2228 | - if ($globalDebug) echo "Unzip..."; |
|
2503 | + if ($globalDebug) { |
|
2504 | + echo "Unzip..."; |
|
2505 | + } |
|
2229 | 2506 | update_db::unzip($tmp_dir.'ReleasableAircraft.zip'); |
2230 | - if ($globalDebug) echo "Add to DB..."; |
|
2507 | + if ($globalDebug) { |
|
2508 | + echo "Add to DB..."; |
|
2509 | + } |
|
2231 | 2510 | $error = update_db::modes_faa(); |
2232 | - } else $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed."; |
|
2511 | + } else { |
|
2512 | + $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed."; |
|
2513 | + } |
|
2233 | 2514 | if ($error != '') { |
2234 | 2515 | return $error; |
2235 | - } elseif ($globalDebug) echo "Done\n"; |
|
2516 | + } elseif ($globalDebug) { |
|
2517 | + echo "Done\n"; |
|
2518 | + } |
|
2236 | 2519 | return ''; |
2237 | 2520 | } |
2238 | 2521 | |
2239 | 2522 | public static function update_ModeS_flarm() { |
2240 | 2523 | global $tmp_dir, $globalDebug; |
2241 | - if ($globalDebug) echo "Modes Flarmnet: Download..."; |
|
2524 | + if ($globalDebug) { |
|
2525 | + echo "Modes Flarmnet: Download..."; |
|
2526 | + } |
|
2242 | 2527 | update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln'); |
2243 | 2528 | if (file_exists($tmp_dir.'data.fln')) { |
2244 | - if ($globalDebug) echo "Add to DB..."; |
|
2529 | + if ($globalDebug) { |
|
2530 | + echo "Add to DB..."; |
|
2531 | + } |
|
2245 | 2532 | $error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln'); |
2246 | - } else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed."; |
|
2533 | + } else { |
|
2534 | + $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed."; |
|
2535 | + } |
|
2247 | 2536 | if ($error != '') { |
2248 | 2537 | return $error; |
2249 | - } elseif ($globalDebug) echo "Done\n"; |
|
2538 | + } elseif ($globalDebug) { |
|
2539 | + echo "Done\n"; |
|
2540 | + } |
|
2250 | 2541 | return ''; |
2251 | 2542 | } |
2252 | 2543 | |
2253 | 2544 | public static function update_ModeS_ogn() { |
2254 | 2545 | global $tmp_dir, $globalDebug; |
2255 | - if ($globalDebug) echo "Modes OGN: Download..."; |
|
2546 | + if ($globalDebug) { |
|
2547 | + echo "Modes OGN: Download..."; |
|
2548 | + } |
|
2256 | 2549 | update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv'); |
2257 | 2550 | if (file_exists($tmp_dir.'ogn.csv')) { |
2258 | - if ($globalDebug) echo "Add to DB..."; |
|
2551 | + if ($globalDebug) { |
|
2552 | + echo "Add to DB..."; |
|
2553 | + } |
|
2259 | 2554 | $error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv'); |
2260 | - } else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed."; |
|
2555 | + } else { |
|
2556 | + $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed."; |
|
2557 | + } |
|
2261 | 2558 | if ($error != '') { |
2262 | 2559 | return $error; |
2263 | - } elseif ($globalDebug) echo "Done\n"; |
|
2560 | + } elseif ($globalDebug) { |
|
2561 | + echo "Done\n"; |
|
2562 | + } |
|
2264 | 2563 | return ''; |
2265 | 2564 | } |
2266 | 2565 | |
2267 | 2566 | public static function update_owner() { |
2268 | 2567 | global $tmp_dir, $globalDebug, $globalMasterSource; |
2269 | 2568 | |
2270 | - if ($globalDebug) echo "Owner France: Download..."; |
|
2569 | + if ($globalDebug) { |
|
2570 | + echo "Owner France: Download..."; |
|
2571 | + } |
|
2271 | 2572 | update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv'); |
2272 | 2573 | if (file_exists($tmp_dir.'owner_f.csv')) { |
2273 | - if ($globalDebug) echo "Add to DB..."; |
|
2574 | + if ($globalDebug) { |
|
2575 | + echo "Add to DB..."; |
|
2576 | + } |
|
2274 | 2577 | $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F'); |
2275 | - } else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
|
2578 | + } else { |
|
2579 | + $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
|
2580 | + } |
|
2276 | 2581 | if ($error != '') { |
2277 | 2582 | return $error; |
2278 | - } elseif ($globalDebug) echo "Done\n"; |
|
2583 | + } elseif ($globalDebug) { |
|
2584 | + echo "Done\n"; |
|
2585 | + } |
|
2279 | 2586 | |
2280 | - if ($globalDebug) echo "Owner Ireland: Download..."; |
|
2587 | + if ($globalDebug) { |
|
2588 | + echo "Owner Ireland: Download..."; |
|
2589 | + } |
|
2281 | 2590 | update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv'); |
2282 | 2591 | if (file_exists($tmp_dir.'owner_ei.csv')) { |
2283 | - if ($globalDebug) echo "Add to DB..."; |
|
2592 | + if ($globalDebug) { |
|
2593 | + echo "Add to DB..."; |
|
2594 | + } |
|
2284 | 2595 | $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI'); |
2285 | - } else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
|
2596 | + } else { |
|
2597 | + $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
|
2598 | + } |
|
2286 | 2599 | if ($error != '') { |
2287 | 2600 | return $error; |
2288 | - } elseif ($globalDebug) echo "Done\n"; |
|
2289 | - if ($globalDebug) echo "Owner Switzerland: Download..."; |
|
2601 | + } elseif ($globalDebug) { |
|
2602 | + echo "Done\n"; |
|
2603 | + } |
|
2604 | + if ($globalDebug) { |
|
2605 | + echo "Owner Switzerland: Download..."; |
|
2606 | + } |
|
2290 | 2607 | update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv'); |
2291 | 2608 | if (file_exists($tmp_dir.'owner_hb.csv')) { |
2292 | - if ($globalDebug) echo "Add to DB..."; |
|
2609 | + if ($globalDebug) { |
|
2610 | + echo "Add to DB..."; |
|
2611 | + } |
|
2293 | 2612 | $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB'); |
2294 | - } else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
|
2613 | + } else { |
|
2614 | + $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
|
2615 | + } |
|
2295 | 2616 | if ($error != '') { |
2296 | 2617 | return $error; |
2297 | - } elseif ($globalDebug) echo "Done\n"; |
|
2298 | - if ($globalDebug) echo "Owner Czech Republic: Download..."; |
|
2618 | + } elseif ($globalDebug) { |
|
2619 | + echo "Done\n"; |
|
2620 | + } |
|
2621 | + if ($globalDebug) { |
|
2622 | + echo "Owner Czech Republic: Download..."; |
|
2623 | + } |
|
2299 | 2624 | update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv'); |
2300 | 2625 | if (file_exists($tmp_dir.'owner_ok.csv')) { |
2301 | - if ($globalDebug) echo "Add to DB..."; |
|
2626 | + if ($globalDebug) { |
|
2627 | + echo "Add to DB..."; |
|
2628 | + } |
|
2302 | 2629 | $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK'); |
2303 | - } else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
|
2630 | + } else { |
|
2631 | + $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
|
2632 | + } |
|
2304 | 2633 | if ($error != '') { |
2305 | 2634 | return $error; |
2306 | - } elseif ($globalDebug) echo "Done\n"; |
|
2307 | - if ($globalDebug) echo "Owner Australia: Download..."; |
|
2635 | + } elseif ($globalDebug) { |
|
2636 | + echo "Done\n"; |
|
2637 | + } |
|
2638 | + if ($globalDebug) { |
|
2639 | + echo "Owner Australia: Download..."; |
|
2640 | + } |
|
2308 | 2641 | update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv'); |
2309 | 2642 | if (file_exists($tmp_dir.'owner_vh.csv')) { |
2310 | - if ($globalDebug) echo "Add to DB..."; |
|
2643 | + if ($globalDebug) { |
|
2644 | + echo "Add to DB..."; |
|
2645 | + } |
|
2311 | 2646 | $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH'); |
2312 | - } else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
|
2647 | + } else { |
|
2648 | + $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
|
2649 | + } |
|
2313 | 2650 | if ($error != '') { |
2314 | 2651 | return $error; |
2315 | - } elseif ($globalDebug) echo "Done\n"; |
|
2316 | - if ($globalDebug) echo "Owner Austria: Download..."; |
|
2652 | + } elseif ($globalDebug) { |
|
2653 | + echo "Done\n"; |
|
2654 | + } |
|
2655 | + if ($globalDebug) { |
|
2656 | + echo "Owner Austria: Download..."; |
|
2657 | + } |
|
2317 | 2658 | update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv'); |
2318 | 2659 | if (file_exists($tmp_dir.'owner_oe.csv')) { |
2319 | - if ($globalDebug) echo "Add to DB..."; |
|
2660 | + if ($globalDebug) { |
|
2661 | + echo "Add to DB..."; |
|
2662 | + } |
|
2320 | 2663 | $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE'); |
2321 | - } else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
|
2664 | + } else { |
|
2665 | + $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
|
2666 | + } |
|
2322 | 2667 | if ($error != '') { |
2323 | 2668 | return $error; |
2324 | - } elseif ($globalDebug) echo "Done\n"; |
|
2325 | - if ($globalDebug) echo "Owner Chile: Download..."; |
|
2669 | + } elseif ($globalDebug) { |
|
2670 | + echo "Done\n"; |
|
2671 | + } |
|
2672 | + if ($globalDebug) { |
|
2673 | + echo "Owner Chile: Download..."; |
|
2674 | + } |
|
2326 | 2675 | update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv'); |
2327 | 2676 | if (file_exists($tmp_dir.'owner_cc.csv')) { |
2328 | - if ($globalDebug) echo "Add to DB..."; |
|
2677 | + if ($globalDebug) { |
|
2678 | + echo "Add to DB..."; |
|
2679 | + } |
|
2329 | 2680 | $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC'); |
2330 | - } else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
|
2681 | + } else { |
|
2682 | + $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
|
2683 | + } |
|
2331 | 2684 | if ($error != '') { |
2332 | 2685 | return $error; |
2333 | - } elseif ($globalDebug) echo "Done\n"; |
|
2334 | - if ($globalDebug) echo "Owner Colombia: Download..."; |
|
2686 | + } elseif ($globalDebug) { |
|
2687 | + echo "Done\n"; |
|
2688 | + } |
|
2689 | + if ($globalDebug) { |
|
2690 | + echo "Owner Colombia: Download..."; |
|
2691 | + } |
|
2335 | 2692 | update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv'); |
2336 | 2693 | if (file_exists($tmp_dir.'owner_hj.csv')) { |
2337 | - if ($globalDebug) echo "Add to DB..."; |
|
2694 | + if ($globalDebug) { |
|
2695 | + echo "Add to DB..."; |
|
2696 | + } |
|
2338 | 2697 | $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ'); |
2339 | - } else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
|
2698 | + } else { |
|
2699 | + $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
|
2700 | + } |
|
2340 | 2701 | if ($error != '') { |
2341 | 2702 | return $error; |
2342 | - } elseif ($globalDebug) echo "Done\n"; |
|
2343 | - if ($globalDebug) echo "Owner Bosnia Herzegobina: Download..."; |
|
2703 | + } elseif ($globalDebug) { |
|
2704 | + echo "Done\n"; |
|
2705 | + } |
|
2706 | + if ($globalDebug) { |
|
2707 | + echo "Owner Bosnia Herzegobina: Download..."; |
|
2708 | + } |
|
2344 | 2709 | update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv'); |
2345 | 2710 | if (file_exists($tmp_dir.'owner_e7.csv')) { |
2346 | - if ($globalDebug) echo "Add to DB..."; |
|
2711 | + if ($globalDebug) { |
|
2712 | + echo "Add to DB..."; |
|
2713 | + } |
|
2347 | 2714 | $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7'); |
2348 | - } else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
|
2715 | + } else { |
|
2716 | + $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
|
2717 | + } |
|
2349 | 2718 | if ($error != '') { |
2350 | 2719 | return $error; |
2351 | - } elseif ($globalDebug) echo "Done\n"; |
|
2352 | - if ($globalDebug) echo "Owner Brazil: Download..."; |
|
2720 | + } elseif ($globalDebug) { |
|
2721 | + echo "Done\n"; |
|
2722 | + } |
|
2723 | + if ($globalDebug) { |
|
2724 | + echo "Owner Brazil: Download..."; |
|
2725 | + } |
|
2353 | 2726 | update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv'); |
2354 | 2727 | if (file_exists($tmp_dir.'owner_pp.csv')) { |
2355 | - if ($globalDebug) echo "Add to DB..."; |
|
2728 | + if ($globalDebug) { |
|
2729 | + echo "Add to DB..."; |
|
2730 | + } |
|
2356 | 2731 | $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP'); |
2357 | - } else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
|
2732 | + } else { |
|
2733 | + $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
|
2734 | + } |
|
2358 | 2735 | if ($error != '') { |
2359 | 2736 | return $error; |
2360 | - } elseif ($globalDebug) echo "Done\n"; |
|
2361 | - if ($globalDebug) echo "Owner Cayman Islands: Download..."; |
|
2737 | + } elseif ($globalDebug) { |
|
2738 | + echo "Done\n"; |
|
2739 | + } |
|
2740 | + if ($globalDebug) { |
|
2741 | + echo "Owner Cayman Islands: Download..."; |
|
2742 | + } |
|
2362 | 2743 | update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv'); |
2363 | 2744 | if (file_exists($tmp_dir.'owner_vp.csv')) { |
2364 | - if ($globalDebug) echo "Add to DB..."; |
|
2745 | + if ($globalDebug) { |
|
2746 | + echo "Add to DB..."; |
|
2747 | + } |
|
2365 | 2748 | $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP'); |
2366 | - } else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
|
2749 | + } else { |
|
2750 | + $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
|
2751 | + } |
|
2367 | 2752 | if ($error != '') { |
2368 | 2753 | return $error; |
2369 | - } elseif ($globalDebug) echo "Done\n"; |
|
2370 | - if ($globalDebug) echo "Owner Croatia: Download..."; |
|
2754 | + } elseif ($globalDebug) { |
|
2755 | + echo "Done\n"; |
|
2756 | + } |
|
2757 | + if ($globalDebug) { |
|
2758 | + echo "Owner Croatia: Download..."; |
|
2759 | + } |
|
2371 | 2760 | update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv'); |
2372 | 2761 | if (file_exists($tmp_dir.'owner_9a.csv')) { |
2373 | - if ($globalDebug) echo "Add to DB..."; |
|
2762 | + if ($globalDebug) { |
|
2763 | + echo "Add to DB..."; |
|
2764 | + } |
|
2374 | 2765 | $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A'); |
2375 | - } else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
|
2766 | + } else { |
|
2767 | + $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
|
2768 | + } |
|
2376 | 2769 | if ($error != '') { |
2377 | 2770 | return $error; |
2378 | - } elseif ($globalDebug) echo "Done\n"; |
|
2379 | - if ($globalDebug) echo "Owner Luxembourg: Download..."; |
|
2771 | + } elseif ($globalDebug) { |
|
2772 | + echo "Done\n"; |
|
2773 | + } |
|
2774 | + if ($globalDebug) { |
|
2775 | + echo "Owner Luxembourg: Download..."; |
|
2776 | + } |
|
2380 | 2777 | update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv'); |
2381 | 2778 | if (file_exists($tmp_dir.'owner_lx.csv')) { |
2382 | - if ($globalDebug) echo "Add to DB..."; |
|
2779 | + if ($globalDebug) { |
|
2780 | + echo "Add to DB..."; |
|
2781 | + } |
|
2383 | 2782 | $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX'); |
2384 | - } else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
|
2783 | + } else { |
|
2784 | + $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
|
2785 | + } |
|
2385 | 2786 | if ($error != '') { |
2386 | 2787 | return $error; |
2387 | - } elseif ($globalDebug) echo "Done\n"; |
|
2388 | - if ($globalDebug) echo "Owner Maldives: Download..."; |
|
2788 | + } elseif ($globalDebug) { |
|
2789 | + echo "Done\n"; |
|
2790 | + } |
|
2791 | + if ($globalDebug) { |
|
2792 | + echo "Owner Maldives: Download..."; |
|
2793 | + } |
|
2389 | 2794 | update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv'); |
2390 | 2795 | if (file_exists($tmp_dir.'owner_8q.csv')) { |
2391 | - if ($globalDebug) echo "Add to DB..."; |
|
2796 | + if ($globalDebug) { |
|
2797 | + echo "Add to DB..."; |
|
2798 | + } |
|
2392 | 2799 | $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q'); |
2393 | - } else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
|
2800 | + } else { |
|
2801 | + $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
|
2802 | + } |
|
2394 | 2803 | if ($error != '') { |
2395 | 2804 | return $error; |
2396 | - } elseif ($globalDebug) echo "Done\n"; |
|
2397 | - if ($globalDebug) echo "Owner New Zealand: Download..."; |
|
2805 | + } elseif ($globalDebug) { |
|
2806 | + echo "Done\n"; |
|
2807 | + } |
|
2808 | + if ($globalDebug) { |
|
2809 | + echo "Owner New Zealand: Download..."; |
|
2810 | + } |
|
2398 | 2811 | update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv'); |
2399 | 2812 | if (file_exists($tmp_dir.'owner_zk.csv')) { |
2400 | - if ($globalDebug) echo "Add to DB..."; |
|
2813 | + if ($globalDebug) { |
|
2814 | + echo "Add to DB..."; |
|
2815 | + } |
|
2401 | 2816 | $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK'); |
2402 | - } else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
|
2817 | + } else { |
|
2818 | + $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
|
2819 | + } |
|
2403 | 2820 | if ($error != '') { |
2404 | 2821 | return $error; |
2405 | - } elseif ($globalDebug) echo "Done\n"; |
|
2406 | - if ($globalDebug) echo "Owner Papua New Guinea: Download..."; |
|
2822 | + } elseif ($globalDebug) { |
|
2823 | + echo "Done\n"; |
|
2824 | + } |
|
2825 | + if ($globalDebug) { |
|
2826 | + echo "Owner Papua New Guinea: Download..."; |
|
2827 | + } |
|
2407 | 2828 | update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv'); |
2408 | 2829 | if (file_exists($tmp_dir.'owner_p2.csv')) { |
2409 | - if ($globalDebug) echo "Add to DB..."; |
|
2830 | + if ($globalDebug) { |
|
2831 | + echo "Add to DB..."; |
|
2832 | + } |
|
2410 | 2833 | $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2'); |
2411 | - } else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
|
2834 | + } else { |
|
2835 | + $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
|
2836 | + } |
|
2412 | 2837 | if ($error != '') { |
2413 | 2838 | return $error; |
2414 | - } elseif ($globalDebug) echo "Done\n"; |
|
2415 | - if ($globalDebug) echo "Owner Slovakia: Download..."; |
|
2839 | + } elseif ($globalDebug) { |
|
2840 | + echo "Done\n"; |
|
2841 | + } |
|
2842 | + if ($globalDebug) { |
|
2843 | + echo "Owner Slovakia: Download..."; |
|
2844 | + } |
|
2416 | 2845 | update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv'); |
2417 | 2846 | if (file_exists($tmp_dir.'owner_om.csv')) { |
2418 | - if ($globalDebug) echo "Add to DB..."; |
|
2847 | + if ($globalDebug) { |
|
2848 | + echo "Add to DB..."; |
|
2849 | + } |
|
2419 | 2850 | $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM'); |
2420 | - } else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
|
2851 | + } else { |
|
2852 | + $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
|
2853 | + } |
|
2421 | 2854 | if ($error != '') { |
2422 | 2855 | return $error; |
2423 | - } elseif ($globalDebug) echo "Done\n"; |
|
2424 | - if ($globalDebug) echo "Owner Ecuador: Download..."; |
|
2856 | + } elseif ($globalDebug) { |
|
2857 | + echo "Done\n"; |
|
2858 | + } |
|
2859 | + if ($globalDebug) { |
|
2860 | + echo "Owner Ecuador: Download..."; |
|
2861 | + } |
|
2425 | 2862 | update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv'); |
2426 | 2863 | if (file_exists($tmp_dir.'owner_hc.csv')) { |
2427 | - if ($globalDebug) echo "Add to DB..."; |
|
2864 | + if ($globalDebug) { |
|
2865 | + echo "Add to DB..."; |
|
2866 | + } |
|
2428 | 2867 | $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC'); |
2429 | - } else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
|
2868 | + } else { |
|
2869 | + $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
|
2870 | + } |
|
2430 | 2871 | if ($error != '') { |
2431 | 2872 | return $error; |
2432 | - } elseif ($globalDebug) echo "Done\n"; |
|
2433 | - if ($globalDebug) echo "Owner Iceland: Download..."; |
|
2873 | + } elseif ($globalDebug) { |
|
2874 | + echo "Done\n"; |
|
2875 | + } |
|
2876 | + if ($globalDebug) { |
|
2877 | + echo "Owner Iceland: Download..."; |
|
2878 | + } |
|
2434 | 2879 | update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv'); |
2435 | 2880 | if (file_exists($tmp_dir.'owner_tf.csv')) { |
2436 | - if ($globalDebug) echo "Add to DB..."; |
|
2881 | + if ($globalDebug) { |
|
2882 | + echo "Add to DB..."; |
|
2883 | + } |
|
2437 | 2884 | $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF'); |
2438 | - } else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
|
2885 | + } else { |
|
2886 | + $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
|
2887 | + } |
|
2439 | 2888 | if ($error != '') { |
2440 | 2889 | return $error; |
2441 | - } elseif ($globalDebug) echo "Done\n"; |
|
2442 | - if ($globalDebug) echo "Owner Isle of Man: Download..."; |
|
2890 | + } elseif ($globalDebug) { |
|
2891 | + echo "Done\n"; |
|
2892 | + } |
|
2893 | + if ($globalDebug) { |
|
2894 | + echo "Owner Isle of Man: Download..."; |
|
2895 | + } |
|
2443 | 2896 | update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv'); |
2444 | 2897 | if (file_exists($tmp_dir.'owner_m.csv')) { |
2445 | - if ($globalDebug) echo "Add to DB..."; |
|
2898 | + if ($globalDebug) { |
|
2899 | + echo "Add to DB..."; |
|
2900 | + } |
|
2446 | 2901 | $error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M'); |
2447 | - } else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed."; |
|
2902 | + } else { |
|
2903 | + $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed."; |
|
2904 | + } |
|
2448 | 2905 | if ($error != '') { |
2449 | 2906 | return $error; |
2450 | - } elseif ($globalDebug) echo "Done\n"; |
|
2907 | + } elseif ($globalDebug) { |
|
2908 | + echo "Done\n"; |
|
2909 | + } |
|
2451 | 2910 | if ($globalMasterSource) { |
2452 | - if ($globalDebug) echo "ModeS Netherlands: Download..."; |
|
2911 | + if ($globalDebug) { |
|
2912 | + echo "ModeS Netherlands: Download..."; |
|
2913 | + } |
|
2453 | 2914 | update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv'); |
2454 | 2915 | if (file_exists($tmp_dir.'owner_ph.csv')) { |
2455 | - if ($globalDebug) echo "Add to DB..."; |
|
2916 | + if ($globalDebug) { |
|
2917 | + echo "Add to DB..."; |
|
2918 | + } |
|
2456 | 2919 | $error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH'); |
2457 | - } else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed."; |
|
2920 | + } else { |
|
2921 | + $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed."; |
|
2922 | + } |
|
2458 | 2923 | if ($error != '') { |
2459 | 2924 | return $error; |
2460 | - } elseif ($globalDebug) echo "Done\n"; |
|
2461 | - if ($globalDebug) echo "ModeS Denmark: Download..."; |
|
2925 | + } elseif ($globalDebug) { |
|
2926 | + echo "Done\n"; |
|
2927 | + } |
|
2928 | + if ($globalDebug) { |
|
2929 | + echo "ModeS Denmark: Download..."; |
|
2930 | + } |
|
2462 | 2931 | update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv'); |
2463 | 2932 | if (file_exists($tmp_dir.'owner_oy.csv')) { |
2464 | - if ($globalDebug) echo "Add to DB..."; |
|
2933 | + if ($globalDebug) { |
|
2934 | + echo "Add to DB..."; |
|
2935 | + } |
|
2465 | 2936 | $error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY'); |
2466 | - } else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed."; |
|
2937 | + } else { |
|
2938 | + $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed."; |
|
2939 | + } |
|
2467 | 2940 | if ($error != '') { |
2468 | 2941 | return $error; |
2469 | - } elseif ($globalDebug) echo "Done\n"; |
|
2470 | - } elseif ($globalDebug) echo "Done\n"; |
|
2942 | + } elseif ($globalDebug) { |
|
2943 | + echo "Done\n"; |
|
2944 | + } |
|
2945 | + } elseif ($globalDebug) { |
|
2946 | + echo "Done\n"; |
|
2947 | + } |
|
2471 | 2948 | return ''; |
2472 | 2949 | } |
2473 | 2950 | |
2474 | 2951 | public static function update_translation() { |
2475 | 2952 | global $tmp_dir, $globalDebug; |
2476 | 2953 | $error = ''; |
2477 | - if ($globalDebug) echo "Translation : Download..."; |
|
2954 | + if ($globalDebug) { |
|
2955 | + echo "Translation : Download..."; |
|
2956 | + } |
|
2478 | 2957 | update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip'); |
2479 | 2958 | if (file_exists($tmp_dir.'translation.zip')) { |
2480 | - if ($globalDebug) echo "Unzip..."; |
|
2959 | + if ($globalDebug) { |
|
2960 | + echo "Unzip..."; |
|
2961 | + } |
|
2481 | 2962 | update_db::unzip($tmp_dir.'translation.zip'); |
2482 | - if ($globalDebug) echo "Add to DB..."; |
|
2963 | + if ($globalDebug) { |
|
2964 | + echo "Add to DB..."; |
|
2965 | + } |
|
2483 | 2966 | $error = update_db::translation(); |
2484 | - } else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed."; |
|
2967 | + } else { |
|
2968 | + $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed."; |
|
2969 | + } |
|
2485 | 2970 | if ($error != '') { |
2486 | 2971 | return $error; |
2487 | - } elseif ($globalDebug) echo "Done\n"; |
|
2972 | + } elseif ($globalDebug) { |
|
2973 | + echo "Done\n"; |
|
2974 | + } |
|
2488 | 2975 | return ''; |
2489 | 2976 | } |
2490 | 2977 | |
2491 | 2978 | public static function update_translation_fam() { |
2492 | 2979 | global $tmp_dir, $globalDebug; |
2493 | 2980 | $error = ''; |
2494 | - if ($globalDebug) echo "Translation from FlightAirMap website : Download..."; |
|
2981 | + if ($globalDebug) { |
|
2982 | + echo "Translation from FlightAirMap website : Download..."; |
|
2983 | + } |
|
2495 | 2984 | update_db::download('http://data.flightairmap.com/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz'); |
2496 | 2985 | update_db::download('http://data.flightairmap.com/data/translation.tsv.gz.md5',$tmp_dir.'translation.tsv.gz.md5'); |
2497 | 2986 | if (file_exists($tmp_dir.'translation.tsv.gz') && file_exists($tmp_dir.'translation.tsv.gz')) { |
2498 | 2987 | $translation_md5_file = explode(' ',file_get_contents($tmp_dir.'translation.tsv.gz.md5')); |
2499 | 2988 | $translation_md5 = $translation_md5_file[0]; |
2500 | 2989 | if (md5_file($tmp_dir.'translation.tsv.gz') == $translation_md5) { |
2501 | - if ($globalDebug) echo "Gunzip..."; |
|
2990 | + if ($globalDebug) { |
|
2991 | + echo "Gunzip..."; |
|
2992 | + } |
|
2502 | 2993 | update_db::gunzip($tmp_dir.'translation.tsv.gz'); |
2503 | - if ($globalDebug) echo "Add to DB..."; |
|
2994 | + if ($globalDebug) { |
|
2995 | + echo "Add to DB..."; |
|
2996 | + } |
|
2504 | 2997 | $error = update_db::translation_fam(); |
2505 | - } else $error = "File ".$tmp_dir.'translation.tsv.gz'." md5 failed. Download failed."; |
|
2506 | - } else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed."; |
|
2998 | + } else { |
|
2999 | + $error = "File ".$tmp_dir.'translation.tsv.gz'." md5 failed. Download failed."; |
|
3000 | + } |
|
3001 | + } else { |
|
3002 | + $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed."; |
|
3003 | + } |
|
2507 | 3004 | if ($error != '') { |
2508 | 3005 | return $error; |
2509 | - } elseif ($globalDebug) echo "Done\n"; |
|
3006 | + } elseif ($globalDebug) { |
|
3007 | + echo "Done\n"; |
|
3008 | + } |
|
2510 | 3009 | return ''; |
2511 | 3010 | } |
2512 | 3011 | public static function update_ModeS_fam() { |
2513 | 3012 | global $tmp_dir, $globalDebug; |
2514 | 3013 | $error = ''; |
2515 | - if ($globalDebug) echo "ModeS from FlightAirMap website : Download..."; |
|
3014 | + if ($globalDebug) { |
|
3015 | + echo "ModeS from FlightAirMap website : Download..."; |
|
3016 | + } |
|
2516 | 3017 | update_db::download('http://data.flightairmap.com/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz'); |
2517 | 3018 | update_db::download('http://data.flightairmap.com/data/modes.tsv.gz.md5',$tmp_dir.'modes.tsv.gz.md5'); |
2518 | 3019 | if (file_exists($tmp_dir.'modes.tsv.gz') && file_exists($tmp_dir.'modes.tsv.gz.md5')) { |
2519 | 3020 | $modes_md5_file = explode(' ',file_get_contents($tmp_dir.'modes.tsv.gz.md5')); |
2520 | 3021 | $modes_md5 = $modes_md5_file[0]; |
2521 | 3022 | if (md5_file($tmp_dir.'modes.tsv.gz') == $modes_md5) { |
2522 | - if ($globalDebug) echo "Gunzip..."; |
|
3023 | + if ($globalDebug) { |
|
3024 | + echo "Gunzip..."; |
|
3025 | + } |
|
2523 | 3026 | update_db::gunzip($tmp_dir.'modes.tsv.gz'); |
2524 | - if ($globalDebug) echo "Add to DB..."; |
|
3027 | + if ($globalDebug) { |
|
3028 | + echo "Add to DB..."; |
|
3029 | + } |
|
2525 | 3030 | $error = update_db::modes_fam(); |
2526 | - } else $error = "File ".$tmp_dir.'modes.tsv.gz'." md5 failed. Download failed."; |
|
2527 | - } else $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed."; |
|
3031 | + } else { |
|
3032 | + $error = "File ".$tmp_dir.'modes.tsv.gz'." md5 failed. Download failed."; |
|
3033 | + } |
|
3034 | + } else { |
|
3035 | + $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed."; |
|
3036 | + } |
|
2528 | 3037 | if ($error != '') { |
2529 | 3038 | return $error; |
2530 | - } elseif ($globalDebug) echo "Done\n"; |
|
3039 | + } elseif ($globalDebug) { |
|
3040 | + echo "Done\n"; |
|
3041 | + } |
|
2531 | 3042 | return ''; |
2532 | 3043 | } |
2533 | 3044 | |
2534 | 3045 | public static function update_airlines_fam() { |
2535 | 3046 | global $tmp_dir, $globalDebug; |
2536 | 3047 | $error = ''; |
2537 | - if ($globalDebug) echo "Airlines from FlightAirMap website : Download..."; |
|
3048 | + if ($globalDebug) { |
|
3049 | + echo "Airlines from FlightAirMap website : Download..."; |
|
3050 | + } |
|
2538 | 3051 | update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz.md5',$tmp_dir.'airlines.tsv.gz.md5'); |
2539 | 3052 | if (file_exists($tmp_dir.'airlines.tsv.gz.md5')) { |
2540 | 3053 | $airlines_md5_file = explode(' ',file_get_contents($tmp_dir.'airlines.tsv.gz.md5')); |
@@ -2543,26 +3056,42 @@ discard block |
||
2543 | 3056 | update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz',$tmp_dir.'airlines.tsv.gz'); |
2544 | 3057 | if (file_exists($tmp_dir.'airlines.tsv.gz')) { |
2545 | 3058 | if (md5_file($tmp_dir.'airlines.tsv.gz') == $airlines_md5) { |
2546 | - if ($globalDebug) echo "Gunzip..."; |
|
3059 | + if ($globalDebug) { |
|
3060 | + echo "Gunzip..."; |
|
3061 | + } |
|
2547 | 3062 | update_db::gunzip($tmp_dir.'airlines.tsv.gz'); |
2548 | - if ($globalDebug) echo "Add to DB..."; |
|
3063 | + if ($globalDebug) { |
|
3064 | + echo "Add to DB..."; |
|
3065 | + } |
|
2549 | 3066 | $error = update_db::airlines_fam(); |
2550 | 3067 | update_db::insert_airlines_version($airlines_md5); |
2551 | - } else $error = "File ".$tmp_dir.'airlines.tsv.gz'." md5 failed. Download failed."; |
|
2552 | - } else $error = "File ".$tmp_dir.'airlines.tsv.gz'." doesn't exist. Download failed."; |
|
2553 | - } elseif ($globalDebug) echo "No update."; |
|
2554 | - } else $error = "File ".$tmp_dir.'airlines.tsv.gz.md5'." doesn't exist. Download failed."; |
|
3068 | + } else { |
|
3069 | + $error = "File ".$tmp_dir.'airlines.tsv.gz'." md5 failed. Download failed."; |
|
3070 | + } |
|
3071 | + } else { |
|
3072 | + $error = "File ".$tmp_dir.'airlines.tsv.gz'." doesn't exist. Download failed."; |
|
3073 | + } |
|
3074 | + } elseif ($globalDebug) { |
|
3075 | + echo "No update."; |
|
3076 | + } |
|
3077 | + } else { |
|
3078 | + $error = "File ".$tmp_dir.'airlines.tsv.gz.md5'." doesn't exist. Download failed."; |
|
3079 | + } |
|
2555 | 3080 | if ($error != '') { |
2556 | 3081 | return $error; |
2557 | 3082 | } else { |
2558 | - if ($globalDebug) echo "Done\n"; |
|
3083 | + if ($globalDebug) { |
|
3084 | + echo "Done\n"; |
|
3085 | + } |
|
2559 | 3086 | } |
2560 | 3087 | return ''; |
2561 | 3088 | } |
2562 | 3089 | |
2563 | 3090 | public static function update_owner_fam() { |
2564 | 3091 | global $tmp_dir, $globalDebug, $globalOwner; |
2565 | - if ($globalDebug) echo "owner from FlightAirMap website : Download..."; |
|
3092 | + if ($globalDebug) { |
|
3093 | + echo "owner from FlightAirMap website : Download..."; |
|
3094 | + } |
|
2566 | 3095 | $error = ''; |
2567 | 3096 | if ($globalOwner === TRUE) { |
2568 | 3097 | update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz'); |
@@ -2575,55 +3104,89 @@ discard block |
||
2575 | 3104 | $owners_md5_file = explode(' ',file_get_contents($tmp_dir.'owners.tsv.gz.md5')); |
2576 | 3105 | $owners_md5 = $owners_md5_file[0]; |
2577 | 3106 | if (md5_file($tmp_dir.'owners.tsv.gz') == $owners_md5) { |
2578 | - if ($globalDebug) echo "Gunzip..."; |
|
3107 | + if ($globalDebug) { |
|
3108 | + echo "Gunzip..."; |
|
3109 | + } |
|
2579 | 3110 | update_db::gunzip($tmp_dir.'owners.tsv.gz'); |
2580 | - if ($globalDebug) echo "Add to DB..."; |
|
3111 | + if ($globalDebug) { |
|
3112 | + echo "Add to DB..."; |
|
3113 | + } |
|
2581 | 3114 | $error = update_db::owner_fam(); |
2582 | - } else $error = "File ".$tmp_dir.'owners.tsv.gz'." md5 failed. Download failed."; |
|
2583 | - } else $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed."; |
|
3115 | + } else { |
|
3116 | + $error = "File ".$tmp_dir.'owners.tsv.gz'." md5 failed. Download failed."; |
|
3117 | + } |
|
3118 | + } else { |
|
3119 | + $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed."; |
|
3120 | + } |
|
2584 | 3121 | if ($error != '') { |
2585 | 3122 | return $error; |
2586 | - } elseif ($globalDebug) echo "Done\n"; |
|
3123 | + } elseif ($globalDebug) { |
|
3124 | + echo "Done\n"; |
|
3125 | + } |
|
2587 | 3126 | return ''; |
2588 | 3127 | } |
2589 | 3128 | public static function update_routes_fam() { |
2590 | 3129 | global $tmp_dir, $globalDebug; |
2591 | - if ($globalDebug) echo "Routes from FlightAirMap website : Download..."; |
|
3130 | + if ($globalDebug) { |
|
3131 | + echo "Routes from FlightAirMap website : Download..."; |
|
3132 | + } |
|
2592 | 3133 | update_db::download('http://data.flightairmap.com/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz'); |
2593 | 3134 | update_db::download('http://data.flightairmap.com/data/routes.tsv.gz.md5',$tmp_dir.'routes.tsv.gz.md5'); |
2594 | 3135 | if (file_exists($tmp_dir.'routes.tsv.gz') && file_exists($tmp_dir.'routes.tsv.gz.md5')) { |
2595 | 3136 | $routes_md5_file = explode(' ',file_get_contents($tmp_dir.'routes.tsv.gz.md5')); |
2596 | 3137 | $routes_md5 = $routes_md5_file[0]; |
2597 | 3138 | if (md5_file($tmp_dir.'routes.tsv.gz') == $routes_md5) { |
2598 | - if ($globalDebug) echo "Gunzip..."; |
|
3139 | + if ($globalDebug) { |
|
3140 | + echo "Gunzip..."; |
|
3141 | + } |
|
2599 | 3142 | update_db::gunzip($tmp_dir.'routes.tsv.gz'); |
2600 | - if ($globalDebug) echo "Add to DB..."; |
|
3143 | + if ($globalDebug) { |
|
3144 | + echo "Add to DB..."; |
|
3145 | + } |
|
2601 | 3146 | $error = update_db::routes_fam(); |
2602 | - } else $error = "File ".$tmp_dir.'routes.tsv.gz'." md5 failed. Download failed."; |
|
2603 | - } else $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed."; |
|
3147 | + } else { |
|
3148 | + $error = "File ".$tmp_dir.'routes.tsv.gz'." md5 failed. Download failed."; |
|
3149 | + } |
|
3150 | + } else { |
|
3151 | + $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed."; |
|
3152 | + } |
|
2604 | 3153 | if ($error != '') { |
2605 | 3154 | return $error; |
2606 | - } elseif ($globalDebug) echo "Done\n"; |
|
3155 | + } elseif ($globalDebug) { |
|
3156 | + echo "Done\n"; |
|
3157 | + } |
|
2607 | 3158 | return ''; |
2608 | 3159 | } |
2609 | 3160 | public static function update_block_fam() { |
2610 | 3161 | global $tmp_dir, $globalDebug; |
2611 | - if ($globalDebug) echo "Blocked aircraft from FlightAirMap website : Download..."; |
|
3162 | + if ($globalDebug) { |
|
3163 | + echo "Blocked aircraft from FlightAirMap website : Download..."; |
|
3164 | + } |
|
2612 | 3165 | update_db::download('http://data.flightairmap.com/data/block.tsv.gz',$tmp_dir.'block.tsv.gz'); |
2613 | 3166 | update_db::download('http://data.flightairmap.com/data/block.tsv.gz.md5',$tmp_dir.'block.tsv.gz.md5'); |
2614 | 3167 | if (file_exists($tmp_dir.'block.tsv.gz') && file_exists($tmp_dir.'block.tsv.gz.md5')) { |
2615 | 3168 | $block_md5_file = explode(' ',file_get_contents($tmp_dir.'block.tsv.gz.md5')); |
2616 | 3169 | $block_md5 = $block_md5_file[0]; |
2617 | 3170 | if (md5_file($tmp_dir.'block.tsv.gz') == $block_md5) { |
2618 | - if ($globalDebug) echo "Gunzip..."; |
|
3171 | + if ($globalDebug) { |
|
3172 | + echo "Gunzip..."; |
|
3173 | + } |
|
2619 | 3174 | update_db::gunzip($tmp_dir.'block.tsv.gz'); |
2620 | - if ($globalDebug) echo "Add to DB..."; |
|
3175 | + if ($globalDebug) { |
|
3176 | + echo "Add to DB..."; |
|
3177 | + } |
|
2621 | 3178 | $error = update_db::block_fam(); |
2622 | - } else $error = "File ".$tmp_dir.'block.tsv.gz'." md5 failed. Download failed."; |
|
2623 | - } else $error = "File ".$tmp_dir.'block.tsv.gz'." doesn't exist. Download failed."; |
|
3179 | + } else { |
|
3180 | + $error = "File ".$tmp_dir.'block.tsv.gz'." md5 failed. Download failed."; |
|
3181 | + } |
|
3182 | + } else { |
|
3183 | + $error = "File ".$tmp_dir.'block.tsv.gz'." doesn't exist. Download failed."; |
|
3184 | + } |
|
2624 | 3185 | if ($error != '') { |
2625 | 3186 | return $error; |
2626 | - } elseif ($globalDebug) echo "Done\n"; |
|
3187 | + } elseif ($globalDebug) { |
|
3188 | + echo "Done\n"; |
|
3189 | + } |
|
2627 | 3190 | return ''; |
2628 | 3191 | } |
2629 | 3192 | public static function update_marine_identity_fam() { |
@@ -2633,21 +3196,33 @@ discard block |
||
2633 | 3196 | $marine_identity_md5_file = explode(' ',file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5')); |
2634 | 3197 | $marine_identity_md5 = $marine_identity_md5_file[0]; |
2635 | 3198 | if (!update_db::check_marine_identity_version($marine_identity_md5)) { |
2636 | - if ($globalDebug) echo "Marine identity from FlightAirMap website : Download..."; |
|
3199 | + if ($globalDebug) { |
|
3200 | + echo "Marine identity from FlightAirMap website : Download..."; |
|
3201 | + } |
|
2637 | 3202 | update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz',$tmp_dir.'marine_identity.tsv.gz'); |
2638 | 3203 | if (file_exists($tmp_dir.'marine_identity.tsv.gz')) { |
2639 | 3204 | if (md5_file($tmp_dir.'marine_identity.tsv.gz') == $marine_identity_md5) { |
2640 | - if ($globalDebug) echo "Gunzip..."; |
|
3205 | + if ($globalDebug) { |
|
3206 | + echo "Gunzip..."; |
|
3207 | + } |
|
2641 | 3208 | update_db::gunzip($tmp_dir.'marine_identity.tsv.gz'); |
2642 | - if ($globalDebug) echo "Add to DB..."; |
|
3209 | + if ($globalDebug) { |
|
3210 | + echo "Add to DB..."; |
|
3211 | + } |
|
2643 | 3212 | $error = update_db::marine_identity_fam(); |
2644 | - } else $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." md5 failed. Download failed."; |
|
2645 | - } else $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed."; |
|
3213 | + } else { |
|
3214 | + $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." md5 failed. Download failed."; |
|
3215 | + } |
|
3216 | + } else { |
|
3217 | + $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed."; |
|
3218 | + } |
|
2646 | 3219 | if ($error != '') { |
2647 | 3220 | return $error; |
2648 | 3221 | } else { |
2649 | 3222 | update_db::insert_marine_identity_version($marine_identity_md5); |
2650 | - if ($globalDebug) echo "Done\n"; |
|
3223 | + if ($globalDebug) { |
|
3224 | + echo "Done\n"; |
|
3225 | + } |
|
2651 | 3226 | } |
2652 | 3227 | } |
2653 | 3228 | } |
@@ -2661,21 +3236,33 @@ discard block |
||
2661 | 3236 | $satellite_md5_file = explode(' ',file_get_contents($tmp_dir.'satellite.tsv.gz.md5')); |
2662 | 3237 | $satellite_md5 = $satellite_md5_file[0]; |
2663 | 3238 | if (!update_db::check_satellite_version($satellite_md5)) { |
2664 | - if ($globalDebug) echo "Satellite from FlightAirMap website : Download..."; |
|
3239 | + if ($globalDebug) { |
|
3240 | + echo "Satellite from FlightAirMap website : Download..."; |
|
3241 | + } |
|
2665 | 3242 | update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz',$tmp_dir.'satellite.tsv.gz'); |
2666 | 3243 | if (file_exists($tmp_dir.'satellite.tsv.gz')) { |
2667 | 3244 | if (md5_file($tmp_dir.'satellite.tsv.gz') == $satellite_md5) { |
2668 | - if ($globalDebug) echo "Gunzip..."; |
|
3245 | + if ($globalDebug) { |
|
3246 | + echo "Gunzip..."; |
|
3247 | + } |
|
2669 | 3248 | update_db::gunzip($tmp_dir.'satellite.tsv.gz'); |
2670 | - if ($globalDebug) echo "Add to DB..."; |
|
3249 | + if ($globalDebug) { |
|
3250 | + echo "Add to DB..."; |
|
3251 | + } |
|
2671 | 3252 | $error = update_db::satellite_fam(); |
2672 | - } else $error = "File ".$tmp_dir.'satellite.tsv.gz'." md5 failed. Download failed."; |
|
2673 | - } else $error = "File ".$tmp_dir.'satellite.tsv.gz'." doesn't exist. Download failed."; |
|
3253 | + } else { |
|
3254 | + $error = "File ".$tmp_dir.'satellite.tsv.gz'." md5 failed. Download failed."; |
|
3255 | + } |
|
3256 | + } else { |
|
3257 | + $error = "File ".$tmp_dir.'satellite.tsv.gz'." doesn't exist. Download failed."; |
|
3258 | + } |
|
2674 | 3259 | if ($error != '') { |
2675 | 3260 | return $error; |
2676 | 3261 | } else { |
2677 | 3262 | update_db::insert_satellite_version($satellite_md5); |
2678 | - if ($globalDebug) echo "Done\n"; |
|
3263 | + if ($globalDebug) { |
|
3264 | + echo "Done\n"; |
|
3265 | + } |
|
2679 | 3266 | } |
2680 | 3267 | } |
2681 | 3268 | } |
@@ -2688,19 +3275,29 @@ discard block |
||
2688 | 3275 | $diagrams_md5_file = explode(' ',file_get_contents($tmp_dir.'diagramspdf.md5')); |
2689 | 3276 | $diagrams_md5 = $diagrams_md5_file[0]; |
2690 | 3277 | if (!update_db::check_diagrams_version($diagrams_md5)) { |
2691 | - if ($globalDebug) echo "Airports diagrams from FlightAirMap website : Download..."; |
|
3278 | + if ($globalDebug) { |
|
3279 | + echo "Airports diagrams from FlightAirMap website : Download..."; |
|
3280 | + } |
|
2692 | 3281 | update_db::download('http://data.flightairmap.com/data/diagrams/diagramspdf',$tmp_dir.'diagramspdf'); |
2693 | 3282 | if (file_exists($tmp_dir.'diagramspdf')) { |
2694 | 3283 | if (md5_file($tmp_dir.'diagramspdf') == $diagrams_md5) { |
2695 | - if ($globalDebug) echo "Add to DB..."; |
|
3284 | + if ($globalDebug) { |
|
3285 | + echo "Add to DB..."; |
|
3286 | + } |
|
2696 | 3287 | $error = update_db::diagrams_fam(); |
2697 | - } else $error = "File ".$tmp_dir.'diagramspdf'." md5 failed. Download failed."; |
|
2698 | - } else $error = "File ".$tmp_dir.'diagramspdf'." doesn't exist. Download failed."; |
|
3288 | + } else { |
|
3289 | + $error = "File ".$tmp_dir.'diagramspdf'." md5 failed. Download failed."; |
|
3290 | + } |
|
3291 | + } else { |
|
3292 | + $error = "File ".$tmp_dir.'diagramspdf'." doesn't exist. Download failed."; |
|
3293 | + } |
|
2699 | 3294 | if ($error != '') { |
2700 | 3295 | return $error; |
2701 | 3296 | } else { |
2702 | 3297 | update_db::insert_diagrams_version($diagrams_md5); |
2703 | - if ($globalDebug) echo "Done\n"; |
|
3298 | + if ($globalDebug) { |
|
3299 | + echo "Done\n"; |
|
3300 | + } |
|
2704 | 3301 | } |
2705 | 3302 | } |
2706 | 3303 | } |
@@ -2708,17 +3305,25 @@ discard block |
||
2708 | 3305 | } |
2709 | 3306 | public static function update_banned_fam() { |
2710 | 3307 | global $tmp_dir, $globalDebug; |
2711 | - if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download..."; |
|
3308 | + if ($globalDebug) { |
|
3309 | + echo "Banned airlines in Europe from FlightAirMap website : Download..."; |
|
3310 | + } |
|
2712 | 3311 | update_db::download('http://data.flightairmap.com/data/ban-eu.csv',$tmp_dir.'ban_eu.csv'); |
2713 | 3312 | if (file_exists($tmp_dir.'ban_eu.csv')) { |
2714 | 3313 | //if ($globalDebug) echo "Gunzip..."; |
2715 | 3314 | //update_db::gunzip($tmp_dir.'ban_ue.csv'); |
2716 | - if ($globalDebug) echo "Add to DB..."; |
|
3315 | + if ($globalDebug) { |
|
3316 | + echo "Add to DB..."; |
|
3317 | + } |
|
2717 | 3318 | $error = update_db::banned_fam(); |
2718 | - } else $error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed."; |
|
3319 | + } else { |
|
3320 | + $error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed."; |
|
3321 | + } |
|
2719 | 3322 | if ($error != '') { |
2720 | 3323 | return $error; |
2721 | - } elseif ($globalDebug) echo "Done\n"; |
|
3324 | + } elseif ($globalDebug) { |
|
3325 | + echo "Done\n"; |
|
3326 | + } |
|
2722 | 3327 | return ''; |
2723 | 3328 | } |
2724 | 3329 | |
@@ -2726,7 +3331,9 @@ discard block |
||
2726 | 3331 | global $tmp_dir, $globalDebug, $globalDBdriver; |
2727 | 3332 | include_once('class.create_db.php'); |
2728 | 3333 | $error = ''; |
2729 | - if ($globalDebug) echo "Airspace from FlightAirMap website : Download..."; |
|
3334 | + if ($globalDebug) { |
|
3335 | + echo "Airspace from FlightAirMap website : Download..."; |
|
3336 | + } |
|
2730 | 3337 | if ($globalDBdriver == 'mysql') { |
2731 | 3338 | update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); |
2732 | 3339 | } else { |
@@ -2743,9 +3350,13 @@ discard block |
||
2743 | 3350 | } |
2744 | 3351 | if (file_exists($tmp_dir.'airspace.sql.gz')) { |
2745 | 3352 | if (md5_file($tmp_dir.'airspace.sql.gz') == $airspace_md5) { |
2746 | - if ($globalDebug) echo "Gunzip..."; |
|
3353 | + if ($globalDebug) { |
|
3354 | + echo "Gunzip..."; |
|
3355 | + } |
|
2747 | 3356 | update_db::gunzip($tmp_dir.'airspace.sql.gz'); |
2748 | - if ($globalDebug) echo "Add to DB..."; |
|
3357 | + if ($globalDebug) { |
|
3358 | + echo "Add to DB..."; |
|
3359 | + } |
|
2749 | 3360 | $Connection = new Connection(); |
2750 | 3361 | if ($Connection->tableExists('airspace')) { |
2751 | 3362 | $query = 'DROP TABLE airspace'; |
@@ -2758,20 +3369,30 @@ discard block |
||
2758 | 3369 | } |
2759 | 3370 | $error = create_db::import_file($tmp_dir.'airspace.sql'); |
2760 | 3371 | update_db::insert_airspace_version($airspace_md5); |
2761 | - } else $error = "File ".$tmp_dir.'airspace.sql.gz'." md5 failed. Download failed."; |
|
2762 | - } else $error = "File ".$tmp_dir.'airspace.sql.gz'." doesn't exist. Download failed."; |
|
3372 | + } else { |
|
3373 | + $error = "File ".$tmp_dir.'airspace.sql.gz'." md5 failed. Download failed."; |
|
3374 | + } |
|
3375 | + } else { |
|
3376 | + $error = "File ".$tmp_dir.'airspace.sql.gz'." doesn't exist. Download failed."; |
|
3377 | + } |
|
2763 | 3378 | } |
2764 | - } else $error = "File ".$tmp_dir.'airspace.sql.gz.md5'." doesn't exist. Download failed."; |
|
3379 | + } else { |
|
3380 | + $error = "File ".$tmp_dir.'airspace.sql.gz.md5'." doesn't exist. Download failed."; |
|
3381 | + } |
|
2765 | 3382 | if ($error != '') { |
2766 | 3383 | return $error; |
2767 | - } elseif ($globalDebug) echo "Done\n"; |
|
3384 | + } elseif ($globalDebug) { |
|
3385 | + echo "Done\n"; |
|
3386 | + } |
|
2768 | 3387 | return ''; |
2769 | 3388 | } |
2770 | 3389 | |
2771 | 3390 | public static function update_geoid_fam() { |
2772 | 3391 | global $tmp_dir, $globalDebug, $globalGeoidSource; |
2773 | 3392 | $error = ''; |
2774 | - if ($globalDebug) echo "Geoid from FlightAirMap website : Download..."; |
|
3393 | + if ($globalDebug) { |
|
3394 | + echo "Geoid from FlightAirMap website : Download..."; |
|
3395 | + } |
|
2775 | 3396 | update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5',$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'); |
2776 | 3397 | if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')) { |
2777 | 3398 | $geoid_md5_file = explode(' ',file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')); |
@@ -2780,80 +3401,126 @@ discard block |
||
2780 | 3401 | update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz',$tmp_dir.$globalGeoidSource.'.pgm.gz'); |
2781 | 3402 | if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz')) { |
2782 | 3403 | if (md5_file($tmp_dir.$globalGeoidSource.'.pgm.gz') == $geoid_md5) { |
2783 | - if ($globalDebug) echo "Gunzip..."; |
|
3404 | + if ($globalDebug) { |
|
3405 | + echo "Gunzip..."; |
|
3406 | + } |
|
2784 | 3407 | update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz',dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm'); |
2785 | 3408 | if (file_exists(dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm')) { |
2786 | 3409 | update_db::insert_geoid_version($geoid_md5); |
2787 | - } else $error = "File data/".$globalGeoidSource.'.pgm'." doesn't exist. Gunzip failed."; |
|
2788 | - } else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." md5 failed. Download failed."; |
|
2789 | - } else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed."; |
|
2790 | - } elseif ($globalDebug) echo 'No new version'."\n"; |
|
2791 | - } else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed."; |
|
3410 | + } else { |
|
3411 | + $error = "File data/".$globalGeoidSource.'.pgm'." doesn't exist. Gunzip failed."; |
|
3412 | + } |
|
3413 | + } else { |
|
3414 | + $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." md5 failed. Download failed."; |
|
3415 | + } |
|
3416 | + } else { |
|
3417 | + $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed."; |
|
3418 | + } |
|
3419 | + } elseif ($globalDebug) { |
|
3420 | + echo 'No new version'."\n"; |
|
3421 | + } |
|
3422 | + } else { |
|
3423 | + $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed."; |
|
3424 | + } |
|
2792 | 3425 | if ($error != '') { |
2793 | 3426 | return $error; |
2794 | - } elseif ($globalDebug) echo "Done\n"; |
|
3427 | + } elseif ($globalDebug) { |
|
3428 | + echo "Done\n"; |
|
3429 | + } |
|
2795 | 3430 | return ''; |
2796 | 3431 | } |
2797 | 3432 | |
2798 | 3433 | public static function update_tle() { |
2799 | 3434 | global $tmp_dir, $globalDebug; |
2800 | - if ($globalDebug) echo "Download TLE : Download..."; |
|
3435 | + if ($globalDebug) { |
|
3436 | + echo "Download TLE : Download..."; |
|
3437 | + } |
|
2801 | 3438 | $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', |
2802 | 3439 | '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', |
2803 | 3440 | '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'); |
2804 | 3441 | foreach ($alltle as $filename) { |
2805 | - if ($globalDebug) echo "downloading ".$filename.'...'; |
|
3442 | + if ($globalDebug) { |
|
3443 | + echo "downloading ".$filename.'...'; |
|
3444 | + } |
|
2806 | 3445 | update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename); |
2807 | 3446 | if (file_exists($tmp_dir.$filename)) { |
2808 | - if ($globalDebug) echo "Add to DB ".$filename."..."; |
|
3447 | + if ($globalDebug) { |
|
3448 | + echo "Add to DB ".$filename."..."; |
|
3449 | + } |
|
2809 | 3450 | $error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename)); |
2810 | - } else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
|
3451 | + } else { |
|
3452 | + $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
|
3453 | + } |
|
2811 | 3454 | if ($error != '') { |
2812 | 3455 | echo $error."\n"; |
2813 | - } elseif ($globalDebug) echo "Done\n"; |
|
3456 | + } elseif ($globalDebug) { |
|
3457 | + echo "Done\n"; |
|
3458 | + } |
|
2814 | 3459 | } |
2815 | 3460 | return ''; |
2816 | 3461 | } |
2817 | 3462 | |
2818 | 3463 | public static function update_ucsdb() { |
2819 | 3464 | global $tmp_dir, $globalDebug; |
2820 | - if ($globalDebug) echo "Download UCS DB : Download..."; |
|
3465 | + if ($globalDebug) { |
|
3466 | + echo "Download UCS DB : Download..."; |
|
3467 | + } |
|
2821 | 3468 | update_db::download('https://s3.amazonaws.com/ucs-documents/nuclear-weapons/sat-database/9-1-17-update/UCS_Satellite_Database_officialname_9-1-2017.txt',$tmp_dir.'UCS_Satellite_Database_officialname_9-1-2017.txt'); |
2822 | 3469 | if (file_exists($tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt')) { |
2823 | - if ($globalDebug) echo "Add to DB..."; |
|
3470 | + if ($globalDebug) { |
|
3471 | + echo "Add to DB..."; |
|
3472 | + } |
|
2824 | 3473 | $error = update_db::satellite_ucsdb($tmp_dir.'UCS_Satellite_Database_officialname_9-1-2017.txt'); |
2825 | - } else $error = "File ".$tmp_dir.'UCS_Satellite_Database_officialname_9-1-2017.txt'." doesn't exist. Download failed."; |
|
3474 | + } else { |
|
3475 | + $error = "File ".$tmp_dir.'UCS_Satellite_Database_officialname_9-1-2017.txt'." doesn't exist. Download failed."; |
|
3476 | + } |
|
2826 | 3477 | if ($error != '') { |
2827 | 3478 | echo $error."\n"; |
2828 | - } elseif ($globalDebug) echo "Done\n"; |
|
3479 | + } elseif ($globalDebug) { |
|
3480 | + echo "Done\n"; |
|
3481 | + } |
|
2829 | 3482 | return ''; |
2830 | 3483 | } |
2831 | 3484 | |
2832 | 3485 | public static function update_celestrak() { |
2833 | 3486 | global $tmp_dir, $globalDebug; |
2834 | - if ($globalDebug) echo "Download Celestrak DB : Download..."; |
|
3487 | + if ($globalDebug) { |
|
3488 | + echo "Download Celestrak DB : Download..."; |
|
3489 | + } |
|
2835 | 3490 | update_db::download('http://celestrak.com/pub/satcat.txt',$tmp_dir.'satcat.txt'); |
2836 | 3491 | if (file_exists($tmp_dir.'satcat.txt')) { |
2837 | - if ($globalDebug) echo "Add to DB..."; |
|
3492 | + if ($globalDebug) { |
|
3493 | + echo "Add to DB..."; |
|
3494 | + } |
|
2838 | 3495 | $error = update_db::satellite_celestrak($tmp_dir.'satcat.txt'); |
2839 | - } else $error = "File ".$tmp_dir.'satcat.txt'." doesn't exist. Download failed."; |
|
3496 | + } else { |
|
3497 | + $error = "File ".$tmp_dir.'satcat.txt'." doesn't exist. Download failed."; |
|
3498 | + } |
|
2840 | 3499 | if ($error != '') { |
2841 | 3500 | echo $error."\n"; |
2842 | - } elseif ($globalDebug) echo "Done\n"; |
|
3501 | + } elseif ($globalDebug) { |
|
3502 | + echo "Done\n"; |
|
3503 | + } |
|
2843 | 3504 | return ''; |
2844 | 3505 | } |
2845 | 3506 | |
2846 | 3507 | public static function update_models() { |
2847 | 3508 | global $tmp_dir, $globalDebug; |
2848 | 3509 | $error = ''; |
2849 | - if ($globalDebug) echo "Models from FlightAirMap website : Download..."; |
|
3510 | + if ($globalDebug) { |
|
3511 | + echo "Models from FlightAirMap website : Download..."; |
|
3512 | + } |
|
2850 | 3513 | if (!is_writable(dirname(__FILE__).'/../models')) { |
2851 | - if ($globalDebug) echo dirname(__FILE__).'/../models'.' is not writable !'; |
|
3514 | + if ($globalDebug) { |
|
3515 | + echo dirname(__FILE__).'/../models'.' is not writable !'; |
|
3516 | + } |
|
2852 | 3517 | return ''; |
2853 | 3518 | } |
2854 | 3519 | update_db::download('http://data.flightairmap.com/data/models/models.md5sum',$tmp_dir.'models.md5sum'); |
2855 | 3520 | if (file_exists($tmp_dir.'models.md5sum')) { |
2856 | - if ($globalDebug) echo "Check files...\n"; |
|
3521 | + if ($globalDebug) { |
|
3522 | + echo "Check files...\n"; |
|
3523 | + } |
|
2857 | 3524 | $newmodelsdb = array(); |
2858 | 3525 | if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) { |
2859 | 3526 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2872,18 +3539,28 @@ discard block |
||
2872 | 3539 | } |
2873 | 3540 | $diff = array_diff($newmodelsdb,$modelsdb); |
2874 | 3541 | foreach ($diff as $key => $value) { |
2875 | - if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n"; |
|
3542 | + if ($globalDebug) { |
|
3543 | + echo 'Downloading model '.$key.' ...'."\n"; |
|
3544 | + } |
|
2876 | 3545 | update_db::download('http://data.flightairmap.com/data/models/'.$key,dirname(__FILE__).'/../models/'.$key); |
2877 | 3546 | } |
2878 | 3547 | update_db::download('http://data.flightairmap.com/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum'); |
2879 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
3548 | + } else { |
|
3549 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
3550 | + } |
|
2880 | 3551 | if ($error != '') { |
2881 | 3552 | return $error; |
2882 | - } elseif ($globalDebug) echo "Done\n"; |
|
2883 | - if ($globalDebug) echo "glTF 2.0 Models from FlightAirMap website : Download..."; |
|
3553 | + } elseif ($globalDebug) { |
|
3554 | + echo "Done\n"; |
|
3555 | + } |
|
3556 | + if ($globalDebug) { |
|
3557 | + echo "glTF 2.0 Models from FlightAirMap website : Download..."; |
|
3558 | + } |
|
2884 | 3559 | update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum',$tmp_dir.'modelsgltf2.md5sum'); |
2885 | 3560 | if (file_exists($tmp_dir.'modelsgltf2.md5sum')) { |
2886 | - if ($globalDebug) echo "Check files...\n"; |
|
3561 | + if ($globalDebug) { |
|
3562 | + echo "Check files...\n"; |
|
3563 | + } |
|
2887 | 3564 | $newmodelsdb = array(); |
2888 | 3565 | if (($handle = fopen($tmp_dir.'modelsgltf2.md5sum','r')) !== FALSE) { |
2889 | 3566 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2902,29 +3579,43 @@ discard block |
||
2902 | 3579 | } |
2903 | 3580 | $diff = array_diff($newmodelsdb,$modelsdb); |
2904 | 3581 | foreach ($diff as $key => $value) { |
2905 | - if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n"; |
|
3582 | + if ($globalDebug) { |
|
3583 | + echo 'Downloading model '.$key.' ...'."\n"; |
|
3584 | + } |
|
2906 | 3585 | update_db::download('http://data.flightairmap.com/data/models/gltf2/'.$key,dirname(__FILE__).'/../models/gltf2/'.$key); |
2907 | 3586 | |
2908 | 3587 | } |
2909 | 3588 | update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum',dirname(__FILE__).'/../models/gltf2/models.md5sum'); |
2910 | - } else $error = "File ".$tmp_dir.'modelsgltf2.md5sum'." doesn't exist. Download failed."; |
|
3589 | + } else { |
|
3590 | + $error = "File ".$tmp_dir.'modelsgltf2.md5sum'." doesn't exist. Download failed."; |
|
3591 | + } |
|
2911 | 3592 | if ($error != '') { |
2912 | 3593 | return $error; |
2913 | - } elseif ($globalDebug) echo "Done\n"; |
|
3594 | + } elseif ($globalDebug) { |
|
3595 | + echo "Done\n"; |
|
3596 | + } |
|
2914 | 3597 | return ''; |
2915 | 3598 | } |
2916 | 3599 | public static function update_weather_models() { |
2917 | 3600 | global $tmp_dir, $globalDebug; |
2918 | 3601 | $error = ''; |
2919 | - if ($globalDebug) echo "Models from FlightAirMap website : Download..."; |
|
3602 | + if ($globalDebug) { |
|
3603 | + echo "Models from FlightAirMap website : Download..."; |
|
3604 | + } |
|
2920 | 3605 | if (!is_writable(dirname(__FILE__).'/../models/gltf2/weather')) { |
2921 | - if ($globalDebug) echo dirname(__FILE__).'/../models/gltf2/weather'.' is not writable !'; |
|
3606 | + if ($globalDebug) { |
|
3607 | + echo dirname(__FILE__).'/../models/gltf2/weather'.' is not writable !'; |
|
3608 | + } |
|
2922 | 3609 | return ''; |
2923 | 3610 | } |
2924 | - if ($globalDebug) echo "Weather Models from FlightAirMap website : Download..."; |
|
3611 | + if ($globalDebug) { |
|
3612 | + echo "Weather Models from FlightAirMap website : Download..."; |
|
3613 | + } |
|
2925 | 3614 | update_db::download('http://data.flightairmap.com/data/models/gltf2/weather/models.md5sum',$tmp_dir.'modelsweather.md5sum'); |
2926 | 3615 | if (file_exists($tmp_dir.'modelsweather.md5sum')) { |
2927 | - if ($globalDebug) echo "Check files...\n"; |
|
3616 | + if ($globalDebug) { |
|
3617 | + echo "Check files...\n"; |
|
3618 | + } |
|
2928 | 3619 | $newmodelsdb = array(); |
2929 | 3620 | if (($handle = fopen($tmp_dir.'modelsweather.md5sum','r')) !== FALSE) { |
2930 | 3621 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2943,25 +3634,35 @@ discard block |
||
2943 | 3634 | } |
2944 | 3635 | $diff = array_diff($newmodelsdb,$modelsdb); |
2945 | 3636 | foreach ($diff as $key => $value) { |
2946 | - if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n"; |
|
3637 | + if ($globalDebug) { |
|
3638 | + echo 'Downloading model '.$key.' ...'."\n"; |
|
3639 | + } |
|
2947 | 3640 | update_db::download('http://data.flightairmap.com/data/models/gltf2/weather/'.$key,dirname(__FILE__).'/../models/gltf2/weather/'.$key); |
2948 | 3641 | |
2949 | 3642 | } |
2950 | 3643 | update_db::download('http://data.flightairmap.com/data/models/gltf2/weather/models.md5sum',dirname(__FILE__).'/../models/gltf2/weather/models.md5sum'); |
2951 | - } else $error = "File ".$tmp_dir.'modelsweather.md5sum'." doesn't exist. Download failed."; |
|
3644 | + } else { |
|
3645 | + $error = "File ".$tmp_dir.'modelsweather.md5sum'." doesn't exist. Download failed."; |
|
3646 | + } |
|
2952 | 3647 | if ($error != '') { |
2953 | 3648 | return $error; |
2954 | - } elseif ($globalDebug) echo "Done\n"; |
|
3649 | + } elseif ($globalDebug) { |
|
3650 | + echo "Done\n"; |
|
3651 | + } |
|
2955 | 3652 | return ''; |
2956 | 3653 | } |
2957 | 3654 | |
2958 | 3655 | public static function update_liveries() { |
2959 | 3656 | global $tmp_dir, $globalDebug; |
2960 | 3657 | $error = ''; |
2961 | - if ($globalDebug) echo "Liveries from FlightAirMap website : Download..."; |
|
3658 | + if ($globalDebug) { |
|
3659 | + echo "Liveries from FlightAirMap website : Download..."; |
|
3660 | + } |
|
2962 | 3661 | update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum',$tmp_dir.'liveries.md5sum'); |
2963 | 3662 | if (file_exists($tmp_dir.'liveries.md5sum')) { |
2964 | - if ($globalDebug) echo "Check files...\n"; |
|
3663 | + if ($globalDebug) { |
|
3664 | + echo "Check files...\n"; |
|
3665 | + } |
|
2965 | 3666 | $newmodelsdb = array(); |
2966 | 3667 | if (($handle = fopen($tmp_dir.'liveries.md5sum','r')) !== FALSE) { |
2967 | 3668 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2980,15 +3681,21 @@ discard block |
||
2980 | 3681 | } |
2981 | 3682 | $diff = array_diff($newmodelsdb,$modelsdb); |
2982 | 3683 | foreach ($diff as $key => $value) { |
2983 | - if ($globalDebug) echo 'Downloading liveries '.$key.' ...'."\n"; |
|
3684 | + if ($globalDebug) { |
|
3685 | + echo 'Downloading liveries '.$key.' ...'."\n"; |
|
3686 | + } |
|
2984 | 3687 | update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/'.$key,dirname(__FILE__).'/../models/gltf2/liveries/'.$key); |
2985 | 3688 | |
2986 | 3689 | } |
2987 | 3690 | update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum',dirname(__FILE__).'/../models/gltf2/liveries/liveries.md5sum'); |
2988 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
3691 | + } else { |
|
3692 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
3693 | + } |
|
2989 | 3694 | if ($error != '') { |
2990 | 3695 | return $error; |
2991 | - } elseif ($globalDebug) echo "Done\n"; |
|
3696 | + } elseif ($globalDebug) { |
|
3697 | + echo "Done\n"; |
|
3698 | + } |
|
2992 | 3699 | return ''; |
2993 | 3700 | } |
2994 | 3701 | |
@@ -2996,13 +3703,19 @@ discard block |
||
2996 | 3703 | global $tmp_dir, $globalDebug; |
2997 | 3704 | $error = ''; |
2998 | 3705 | if (!is_writable(dirname(__FILE__).'/../models')) { |
2999 | - if ($globalDebug) echo dirname(__FILE__).'/../models'.' is not writable !'; |
|
3706 | + if ($globalDebug) { |
|
3707 | + echo dirname(__FILE__).'/../models'.' is not writable !'; |
|
3708 | + } |
|
3000 | 3709 | return ''; |
3001 | 3710 | } |
3002 | - if ($globalDebug) echo "Space models from FlightAirMap website : Download..."; |
|
3711 | + if ($globalDebug) { |
|
3712 | + echo "Space models from FlightAirMap website : Download..."; |
|
3713 | + } |
|
3003 | 3714 | update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum'); |
3004 | 3715 | if (file_exists($tmp_dir.'space_models.md5sum')) { |
3005 | - if ($globalDebug) echo "Check files...\n"; |
|
3716 | + if ($globalDebug) { |
|
3717 | + echo "Check files...\n"; |
|
3718 | + } |
|
3006 | 3719 | $newmodelsdb = array(); |
3007 | 3720 | if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) { |
3008 | 3721 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -3021,15 +3734,21 @@ discard block |
||
3021 | 3734 | } |
3022 | 3735 | $diff = array_diff($newmodelsdb,$modelsdb); |
3023 | 3736 | foreach ($diff as $key => $value) { |
3024 | - if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n"; |
|
3737 | + if ($globalDebug) { |
|
3738 | + echo 'Downloading space model '.$key.' ...'."\n"; |
|
3739 | + } |
|
3025 | 3740 | update_db::download('http://data.flightairmap.com/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key); |
3026 | 3741 | |
3027 | 3742 | } |
3028 | 3743 | update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum'); |
3029 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
3744 | + } else { |
|
3745 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
3746 | + } |
|
3030 | 3747 | if ($error != '') { |
3031 | 3748 | return $error; |
3032 | - } elseif ($globalDebug) echo "Done\n"; |
|
3749 | + } elseif ($globalDebug) { |
|
3750 | + echo "Done\n"; |
|
3751 | + } |
|
3033 | 3752 | return ''; |
3034 | 3753 | } |
3035 | 3754 | |
@@ -3037,13 +3756,19 @@ discard block |
||
3037 | 3756 | global $tmp_dir, $globalDebug; |
3038 | 3757 | $error = ''; |
3039 | 3758 | if (!is_writable(dirname(__FILE__).'/../models/vehicules')) { |
3040 | - if ($globalDebug) echo dirname(__FILE__).'/../models/vehicules'.' is not writable !'; |
|
3759 | + if ($globalDebug) { |
|
3760 | + echo dirname(__FILE__).'/../models/vehicules'.' is not writable !'; |
|
3761 | + } |
|
3041 | 3762 | return ''; |
3042 | 3763 | } |
3043 | - if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download..."; |
|
3764 | + if ($globalDebug) { |
|
3765 | + echo "Vehicules models from FlightAirMap website : Download..."; |
|
3766 | + } |
|
3044 | 3767 | update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum'); |
3045 | 3768 | if (file_exists($tmp_dir.'vehicules_models.md5sum')) { |
3046 | - if ($globalDebug) echo "Check files...\n"; |
|
3769 | + if ($globalDebug) { |
|
3770 | + echo "Check files...\n"; |
|
3771 | + } |
|
3047 | 3772 | $newmodelsdb = array(); |
3048 | 3773 | if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) { |
3049 | 3774 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -3062,15 +3787,21 @@ discard block |
||
3062 | 3787 | } |
3063 | 3788 | $diff = array_diff($newmodelsdb,$modelsdb); |
3064 | 3789 | foreach ($diff as $key => $value) { |
3065 | - if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n"; |
|
3790 | + if ($globalDebug) { |
|
3791 | + echo 'Downloading vehicules model '.$key.' ...'."\n"; |
|
3792 | + } |
|
3066 | 3793 | update_db::download('http://data.flightairmap.com/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key); |
3067 | 3794 | |
3068 | 3795 | } |
3069 | 3796 | update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum'); |
3070 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
3797 | + } else { |
|
3798 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
3799 | + } |
|
3071 | 3800 | if ($error != '') { |
3072 | 3801 | return $error; |
3073 | - } elseif ($globalDebug) echo "Done\n"; |
|
3802 | + } elseif ($globalDebug) { |
|
3803 | + echo "Done\n"; |
|
3804 | + } |
|
3074 | 3805 | return ''; |
3075 | 3806 | } |
3076 | 3807 | |
@@ -3143,7 +3874,9 @@ discard block |
||
3143 | 3874 | } |
3144 | 3875 | |
3145 | 3876 | $error = ''; |
3146 | - if ($globalDebug) echo "Notam : Download..."; |
|
3877 | + if ($globalDebug) { |
|
3878 | + echo "Notam : Download..."; |
|
3879 | + } |
|
3147 | 3880 | update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss'); |
3148 | 3881 | if (file_exists($tmp_dir.'notam.rss')) { |
3149 | 3882 | $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true); |
@@ -3158,14 +3891,30 @@ discard block |
||
3158 | 3891 | $data['fir'] = $q[0]; |
3159 | 3892 | $data['code'] = $q[1]; |
3160 | 3893 | $ifrvfr = $q[2]; |
3161 | - if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR'; |
|
3162 | - if ($ifrvfr == 'I') $data['rules'] = 'IFR'; |
|
3163 | - if ($ifrvfr == 'V') $data['rules'] = 'VFR'; |
|
3164 | - if ($q[4] == 'A') $data['scope'] = 'Airport warning'; |
|
3165 | - if ($q[4] == 'E') $data['scope'] = 'Enroute warning'; |
|
3166 | - if ($q[4] == 'W') $data['scope'] = 'Navigation warning'; |
|
3167 | - if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning'; |
|
3168 | - if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning'; |
|
3894 | + if ($ifrvfr == 'IV') { |
|
3895 | + $data['rules'] = 'IFR/VFR'; |
|
3896 | + } |
|
3897 | + if ($ifrvfr == 'I') { |
|
3898 | + $data['rules'] = 'IFR'; |
|
3899 | + } |
|
3900 | + if ($ifrvfr == 'V') { |
|
3901 | + $data['rules'] = 'VFR'; |
|
3902 | + } |
|
3903 | + if ($q[4] == 'A') { |
|
3904 | + $data['scope'] = 'Airport warning'; |
|
3905 | + } |
|
3906 | + if ($q[4] == 'E') { |
|
3907 | + $data['scope'] = 'Enroute warning'; |
|
3908 | + } |
|
3909 | + if ($q[4] == 'W') { |
|
3910 | + $data['scope'] = 'Navigation warning'; |
|
3911 | + } |
|
3912 | + if ($q[4] == 'AE') { |
|
3913 | + $data['scope'] = 'Airport/Enroute warning'; |
|
3914 | + } |
|
3915 | + if ($q[4] == 'AW') { |
|
3916 | + $data['scope'] = 'Airport/Navigation warning'; |
|
3917 | + } |
|
3169 | 3918 | //$data['scope'] = $q[4]; |
3170 | 3919 | $data['lower_limit'] = $q[5]; |
3171 | 3920 | $data['upper_limit'] = $q[6]; |
@@ -3173,8 +3922,12 @@ discard block |
||
3173 | 3922 | sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius); |
3174 | 3923 | $latitude = $Common->convertDec($las,'latitude'); |
3175 | 3924 | $longitude = $Common->convertDec($lns,'longitude'); |
3176 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
3177 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
3925 | + if ($lac == 'S') { |
|
3926 | + $latitude = '-'.$latitude; |
|
3927 | + } |
|
3928 | + if ($lnc == 'W') { |
|
3929 | + $longitude = '-'.$longitude; |
|
3930 | + } |
|
3178 | 3931 | $data['center_latitude'] = $latitude; |
3179 | 3932 | $data['center_longitude'] = $longitude; |
3180 | 3933 | $data['radius'] = intval($radius); |
@@ -3204,10 +3957,14 @@ discard block |
||
3204 | 3957 | $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']); |
3205 | 3958 | unset($data); |
3206 | 3959 | } |
3207 | - } else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
|
3960 | + } else { |
|
3961 | + $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
|
3962 | + } |
|
3208 | 3963 | if ($error != '') { |
3209 | 3964 | return $error; |
3210 | - } elseif ($globalDebug) echo "Done\n"; |
|
3965 | + } elseif ($globalDebug) { |
|
3966 | + echo "Done\n"; |
|
3967 | + } |
|
3211 | 3968 | return ''; |
3212 | 3969 | } |
3213 | 3970 | |
@@ -3232,7 +3989,9 @@ discard block |
||
3232 | 3989 | $airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json'); |
3233 | 3990 | $airspace_json = json_decode($airspace_lst,true); |
3234 | 3991 | foreach ($airspace_json['records'] as $airspace) { |
3235 | - if ($globalDebug) echo $airspace['name']."...\n"; |
|
3992 | + if ($globalDebug) { |
|
3993 | + echo $airspace['name']."...\n"; |
|
3994 | + } |
|
3236 | 3995 | update_db::download($airspace['uri'],$tmp_dir.$airspace['name']); |
3237 | 3996 | if (file_exists($tmp_dir.$airspace['name'])) { |
3238 | 3997 | file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name']))); |
@@ -3276,8 +4035,11 @@ discard block |
||
3276 | 4035 | return "error : ".$e->getMessage(); |
3277 | 4036 | } |
3278 | 4037 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3279 | - if ($row['nb'] > 0) return false; |
|
3280 | - else return true; |
|
4038 | + if ($row['nb'] > 0) { |
|
4039 | + return false; |
|
4040 | + } else { |
|
4041 | + return true; |
|
4042 | + } |
|
3281 | 4043 | } |
3282 | 4044 | |
3283 | 4045 | public static function insert_last_update() { |
@@ -3302,8 +4064,11 @@ discard block |
||
3302 | 4064 | return "error : ".$e->getMessage(); |
3303 | 4065 | } |
3304 | 4066 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3305 | - if ($row['nb'] > 0) return true; |
|
3306 | - else return false; |
|
4067 | + if ($row['nb'] > 0) { |
|
4068 | + return true; |
|
4069 | + } else { |
|
4070 | + return false; |
|
4071 | + } |
|
3307 | 4072 | } |
3308 | 4073 | |
3309 | 4074 | public static function check_geoid_version($version) { |
@@ -3316,8 +4081,11 @@ discard block |
||
3316 | 4081 | return "error : ".$e->getMessage(); |
3317 | 4082 | } |
3318 | 4083 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3319 | - if ($row['nb'] > 0) return true; |
|
3320 | - else return false; |
|
4084 | + if ($row['nb'] > 0) { |
|
4085 | + return true; |
|
4086 | + } else { |
|
4087 | + return false; |
|
4088 | + } |
|
3321 | 4089 | } |
3322 | 4090 | |
3323 | 4091 | public static function check_marine_identity_version($version) { |
@@ -3330,8 +4098,11 @@ discard block |
||
3330 | 4098 | return "error : ".$e->getMessage(); |
3331 | 4099 | } |
3332 | 4100 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3333 | - if ($row['nb'] > 0) return true; |
|
3334 | - else return false; |
|
4101 | + if ($row['nb'] > 0) { |
|
4102 | + return true; |
|
4103 | + } else { |
|
4104 | + return false; |
|
4105 | + } |
|
3335 | 4106 | } |
3336 | 4107 | |
3337 | 4108 | public static function check_satellite_version($version) { |
@@ -3344,8 +4115,11 @@ discard block |
||
3344 | 4115 | return "error : ".$e->getMessage(); |
3345 | 4116 | } |
3346 | 4117 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3347 | - if ($row['nb'] > 0) return true; |
|
3348 | - else return false; |
|
4118 | + if ($row['nb'] > 0) { |
|
4119 | + return true; |
|
4120 | + } else { |
|
4121 | + return false; |
|
4122 | + } |
|
3349 | 4123 | } |
3350 | 4124 | public static function check_diagrams_version($version) { |
3351 | 4125 | $query = "SELECT COUNT(*) as nb FROM config WHERE name = 'diagrams_version' AND value = :version"; |
@@ -3357,8 +4131,11 @@ discard block |
||
3357 | 4131 | return "error : ".$e->getMessage(); |
3358 | 4132 | } |
3359 | 4133 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3360 | - if ($row['nb'] > 0) return true; |
|
3361 | - else return false; |
|
4134 | + if ($row['nb'] > 0) { |
|
4135 | + return true; |
|
4136 | + } else { |
|
4137 | + return false; |
|
4138 | + } |
|
3362 | 4139 | } |
3363 | 4140 | |
3364 | 4141 | public static function check_airlines_version($version) { |
@@ -3371,8 +4148,11 @@ discard block |
||
3371 | 4148 | return "error : ".$e->getMessage(); |
3372 | 4149 | } |
3373 | 4150 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3374 | - if ($row['nb'] > 0) return true; |
|
3375 | - else return false; |
|
4151 | + if ($row['nb'] > 0) { |
|
4152 | + return true; |
|
4153 | + } else { |
|
4154 | + return false; |
|
4155 | + } |
|
3376 | 4156 | } |
3377 | 4157 | |
3378 | 4158 | public static function check_notam_version($version) { |
@@ -3385,8 +4165,11 @@ discard block |
||
3385 | 4165 | return "error : ".$e->getMessage(); |
3386 | 4166 | } |
3387 | 4167 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3388 | - if ($row['nb'] > 0) return true; |
|
3389 | - else return false; |
|
4168 | + if ($row['nb'] > 0) { |
|
4169 | + return true; |
|
4170 | + } else { |
|
4171 | + return false; |
|
4172 | + } |
|
3390 | 4173 | } |
3391 | 4174 | |
3392 | 4175 | public static function insert_airlines_version($version) { |
@@ -3487,8 +4270,11 @@ discard block |
||
3487 | 4270 | return "error : ".$e->getMessage(); |
3488 | 4271 | } |
3489 | 4272 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3490 | - if ($row['nb'] > 0) return false; |
|
3491 | - else return true; |
|
4273 | + if ($row['nb'] > 0) { |
|
4274 | + return false; |
|
4275 | + } else { |
|
4276 | + return true; |
|
4277 | + } |
|
3492 | 4278 | } |
3493 | 4279 | |
3494 | 4280 | public static function insert_last_notam_update() { |
@@ -3518,8 +4304,11 @@ discard block |
||
3518 | 4304 | return "error : ".$e->getMessage(); |
3519 | 4305 | } |
3520 | 4306 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3521 | - if ($row['nb'] > 0) return false; |
|
3522 | - else return true; |
|
4307 | + if ($row['nb'] > 0) { |
|
4308 | + return false; |
|
4309 | + } else { |
|
4310 | + return true; |
|
4311 | + } |
|
3523 | 4312 | } |
3524 | 4313 | |
3525 | 4314 | public static function insert_last_airspace_update() { |
@@ -3549,8 +4338,11 @@ discard block |
||
3549 | 4338 | return "error : ".$e->getMessage(); |
3550 | 4339 | } |
3551 | 4340 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3552 | - if ($row['nb'] > 0) return false; |
|
3553 | - else return true; |
|
4341 | + if ($row['nb'] > 0) { |
|
4342 | + return false; |
|
4343 | + } else { |
|
4344 | + return true; |
|
4345 | + } |
|
3554 | 4346 | } |
3555 | 4347 | |
3556 | 4348 | public static function insert_last_geoid_update() { |
@@ -3580,8 +4372,11 @@ discard block |
||
3580 | 4372 | return "error : ".$e->getMessage(); |
3581 | 4373 | } |
3582 | 4374 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3583 | - if ($row['nb'] > 0) return false; |
|
3584 | - else return true; |
|
4375 | + if ($row['nb'] > 0) { |
|
4376 | + return false; |
|
4377 | + } else { |
|
4378 | + return true; |
|
4379 | + } |
|
3585 | 4380 | } |
3586 | 4381 | |
3587 | 4382 | public static function insert_last_owner_update() { |
@@ -3611,8 +4406,11 @@ discard block |
||
3611 | 4406 | return "error : ".$e->getMessage(); |
3612 | 4407 | } |
3613 | 4408 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3614 | - if ($row['nb'] > 0) return false; |
|
3615 | - else return true; |
|
4409 | + if ($row['nb'] > 0) { |
|
4410 | + return false; |
|
4411 | + } else { |
|
4412 | + return true; |
|
4413 | + } |
|
3616 | 4414 | } |
3617 | 4415 | |
3618 | 4416 | public static function insert_last_fires_update() { |
@@ -3642,8 +4440,11 @@ discard block |
||
3642 | 4440 | return "error : ".$e->getMessage(); |
3643 | 4441 | } |
3644 | 4442 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3645 | - if ($row['nb'] > 0) return false; |
|
3646 | - else return true; |
|
4443 | + if ($row['nb'] > 0) { |
|
4444 | + return false; |
|
4445 | + } else { |
|
4446 | + return true; |
|
4447 | + } |
|
3647 | 4448 | } |
3648 | 4449 | |
3649 | 4450 | public static function insert_last_airlines_update() { |
@@ -3673,8 +4474,11 @@ discard block |
||
3673 | 4474 | return "error : ".$e->getMessage(); |
3674 | 4475 | } |
3675 | 4476 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3676 | - if ($row['nb'] > 0) return false; |
|
3677 | - else return true; |
|
4477 | + if ($row['nb'] > 0) { |
|
4478 | + return false; |
|
4479 | + } else { |
|
4480 | + return true; |
|
4481 | + } |
|
3678 | 4482 | } |
3679 | 4483 | |
3680 | 4484 | public static function insert_last_schedules_update() { |
@@ -3704,8 +4508,11 @@ discard block |
||
3704 | 4508 | return "error : ".$e->getMessage(); |
3705 | 4509 | } |
3706 | 4510 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3707 | - if ($row['nb'] > 0) return false; |
|
3708 | - else return true; |
|
4511 | + if ($row['nb'] > 0) { |
|
4512 | + return false; |
|
4513 | + } else { |
|
4514 | + return true; |
|
4515 | + } |
|
3709 | 4516 | } |
3710 | 4517 | |
3711 | 4518 | public static function insert_last_tle_update() { |
@@ -3735,8 +4542,11 @@ discard block |
||
3735 | 4542 | return "error : ".$e->getMessage(); |
3736 | 4543 | } |
3737 | 4544 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3738 | - if ($row['nb'] > 0) return false; |
|
3739 | - else return true; |
|
4545 | + if ($row['nb'] > 0) { |
|
4546 | + return false; |
|
4547 | + } else { |
|
4548 | + return true; |
|
4549 | + } |
|
3740 | 4550 | } |
3741 | 4551 | |
3742 | 4552 | public static function insert_last_ucsdb_update() { |
@@ -3766,8 +4576,11 @@ discard block |
||
3766 | 4576 | return "error : ".$e->getMessage(); |
3767 | 4577 | } |
3768 | 4578 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3769 | - if ($row['nb'] > 0) return false; |
|
3770 | - else return true; |
|
4579 | + if ($row['nb'] > 0) { |
|
4580 | + return false; |
|
4581 | + } else { |
|
4582 | + return true; |
|
4583 | + } |
|
3771 | 4584 | } |
3772 | 4585 | |
3773 | 4586 | public static function insert_last_celestrak_update() { |
@@ -3797,8 +4610,11 @@ discard block |
||
3797 | 4610 | return "error : ".$e->getMessage(); |
3798 | 4611 | } |
3799 | 4612 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3800 | - if ($row['nb'] > 0) return false; |
|
3801 | - else return true; |
|
4613 | + if ($row['nb'] > 0) { |
|
4614 | + return false; |
|
4615 | + } else { |
|
4616 | + return true; |
|
4617 | + } |
|
3802 | 4618 | } |
3803 | 4619 | |
3804 | 4620 | public static function check_last_satellite_update() { |
@@ -3816,8 +4632,11 @@ discard block |
||
3816 | 4632 | return "error : ".$e->getMessage(); |
3817 | 4633 | } |
3818 | 4634 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3819 | - if ($row['nb'] > 0) return false; |
|
3820 | - else return true; |
|
4635 | + if ($row['nb'] > 0) { |
|
4636 | + return false; |
|
4637 | + } else { |
|
4638 | + return true; |
|
4639 | + } |
|
3821 | 4640 | } |
3822 | 4641 | |
3823 | 4642 | public static function insert_last_marine_identity_update() { |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | $limit_start = 0; |
16 | 16 | $limit_end = 25; |
17 | 17 | $absolute_difference = 25; |
18 | - } else { |
|
18 | + } else { |
|
19 | 19 | $limit_explode = explode(",", $_GET['limit']); |
20 | 20 | $limit_start = $limit_explode[0]; |
21 | 21 | $limit_end = $limit_explode[1]; |
@@ -46,7 +46,9 @@ discard block |
||
46 | 46 | $METAR = new METAR(); |
47 | 47 | $metar_info = $METAR->getMETAR($airport_icao); |
48 | 48 | //print_r($metar_info); |
49 | - if (isset($metar_info[0]['metar'])) $metar_parse = $METAR->parse($metar_info[0]['metar']); |
|
49 | + if (isset($metar_info[0]['metar'])) { |
|
50 | + $metar_parse = $METAR->parse($metar_info[0]['metar']); |
|
51 | + } |
|
50 | 52 | //print_r($metar_parse); |
51 | 53 | } |
52 | 54 | |
@@ -60,7 +62,9 @@ discard block |
||
60 | 62 | print '<option></option>'; |
61 | 63 | $Stats = new Stats(); |
62 | 64 | $airport_names = $Stats->getAllAirportNames(); |
63 | - if (empty($airport_names)) $airport_names = $Spotter->getAllAirportNames(); |
|
65 | + if (empty($airport_names)) { |
|
66 | + $airport_names = $Spotter->getAllAirportNames(); |
|
67 | + } |
|
64 | 68 | ksort($airport_names); |
65 | 69 | foreach($airport_names as $airport_name) |
66 | 70 | { |
@@ -95,9 +99,15 @@ discard block |
||
95 | 99 | print '</div>'; |
96 | 100 | print '<div><span class="label">'._("Coordinates").'</span><a href="http://maps.google.com/maps?z=10&t=k&q='.$airport_array[0]['latitude'].','.$airport_array[0]['longitude'].'" target="_blank">Google Map<i class="fa fa-angle-double-right"></i></a></div>'; |
97 | 101 | print '<div><span class="label">'._("Live Air Traffic").'</span><a href="http://www.liveatc.net/search/?icao='.$airport_array[0]['icao'].'" target="_blank">LiveATC.net<i class="fa fa-angle-double-right"></i></a></div>'; |
98 | - if (isset($airport_array[0]['home_link']) && $airport_array[0]['home_link'] != '') print '<div><a href="'.$airport_array[0]['home_link'].'"><i class="fa fa-home"></i></a></div>'; |
|
99 | - if (isset($airport_array[0]['wikipedia_link']) && $airport_array[0]['wikipedia_link'] != '') print '<div><a href="'.$airport_array[0]['wikipedia_link'].'"><i class="fa fa-wikipedia-w"></i></a></div>'; |
|
100 | - if (isset($airport_array[0]['diagram_pdf']) && $airport_array[0]['diagram_pdf'] != '') print '<div><span class="label">'._("Diagram").'</span><a href="'.$airport_array[0]['diagram_pdf'].'" target="_blank">'.$airport_array[0]['icao'].'<i class="fa fa-angle-double-right"></i></a></div>'; |
|
102 | + if (isset($airport_array[0]['home_link']) && $airport_array[0]['home_link'] != '') { |
|
103 | + print '<div><a href="'.$airport_array[0]['home_link'].'"><i class="fa fa-home"></i></a></div>'; |
|
104 | + } |
|
105 | + if (isset($airport_array[0]['wikipedia_link']) && $airport_array[0]['wikipedia_link'] != '') { |
|
106 | + print '<div><a href="'.$airport_array[0]['wikipedia_link'].'"><i class="fa fa-wikipedia-w"></i></a></div>'; |
|
107 | + } |
|
108 | + if (isset($airport_array[0]['diagram_pdf']) && $airport_array[0]['diagram_pdf'] != '') { |
|
109 | + print '<div><span class="label">'._("Diagram").'</span><a href="'.$airport_array[0]['diagram_pdf'].'" target="_blank">'.$airport_array[0]['icao'].'<i class="fa fa-angle-double-right"></i></a></div>'; |
|
110 | + } |
|
101 | 111 | print '</div>'; |
102 | 112 | |
103 | 113 | $Stats = new Stats(); |
@@ -105,7 +115,9 @@ discard block |
||
105 | 115 | // Use spotter also |
106 | 116 | if (isset($globalTimezone)) { |
107 | 117 | date_default_timezone_set($globalTimezone); |
108 | - } else date_default_timezone_set('UTC'); |
|
118 | + } else { |
|
119 | + date_default_timezone_set('UTC'); |
|
120 | + } |
|
109 | 121 | if (count($all_data) > 0) { |
110 | 122 | print '<link href="'.$globalURL.'/css/c3.min.css" rel="stylesheet" type="text/css">'; |
111 | 123 | print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>'; |
@@ -211,7 +223,9 @@ discard block |
||
211 | 223 | print '</div>'; |
212 | 224 | print '</div>'; |
213 | 225 | } else { |
214 | - if (isset($airport_array[0]['image']) && $airport_array[0]['image'] != '') print '<center><img src="'.$airport_array[0]['image'].'" /></center>'; |
|
226 | + if (isset($airport_array[0]['image']) && $airport_array[0]['image'] != '') { |
|
227 | + print '<center><img src="'.$airport_array[0]['image'].'" /></center>'; |
|
228 | + } |
|
215 | 229 | print '<p>'._("Sorry, no flights used the airport in this database.").'</p>'; |
216 | 230 | } |
217 | 231 | } else { |