@@ -26,7 +26,9 @@ discard block |
||
26 | 26 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
27 | 27 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
28 | 28 | curl_setopt($ch, CURLOPT_TIMEOUT, 200); |
29 | - if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
29 | + if ($referer != '') { |
|
30 | + curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
31 | + } |
|
30 | 32 | 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'); |
31 | 33 | curl_setopt($ch, CURLOPT_FILE, $fp); |
32 | 34 | curl_exec($ch); |
@@ -37,12 +39,16 @@ discard block |
||
37 | 39 | public static function gunzip($in_file,$out_file_name = '') { |
38 | 40 | //echo $in_file.' -> '.$out_file_name."\n"; |
39 | 41 | $buffer_size = 4096; // read 4kb at a time |
40 | - if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); |
|
42 | + if ($out_file_name == '') { |
|
43 | + $out_file_name = str_replace('.gz', '', $in_file); |
|
44 | + } |
|
41 | 45 | if ($in_file != '' && file_exists($in_file)) { |
42 | 46 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
43 | - if (function_exists('gzopen')) $file = gzopen($in_file,'rb'); |
|
44 | - elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb'); |
|
45 | - else { |
|
47 | + if (function_exists('gzopen')) { |
|
48 | + $file = gzopen($in_file,'rb'); |
|
49 | + } elseif (function_exists('gzopen64')) { |
|
50 | + $file = gzopen64($in_file,'rb'); |
|
51 | + } else { |
|
46 | 52 | echo 'gzopen not available'; |
47 | 53 | die; |
48 | 54 | } |
@@ -63,8 +69,12 @@ discard block |
||
63 | 69 | if ($res === TRUE) { |
64 | 70 | $zip->extractTo($path); |
65 | 71 | $zip->close(); |
66 | - } else return false; |
|
67 | - } else return false; |
|
72 | + } else { |
|
73 | + return false; |
|
74 | + } |
|
75 | + } else { |
|
76 | + return false; |
|
77 | + } |
|
68 | 78 | } |
69 | 79 | |
70 | 80 | public static function connect_sqlite($database) { |
@@ -79,7 +89,9 @@ discard block |
||
79 | 89 | public static function retrieve_route_sqlite_to_dest($database_file) { |
80 | 90 | global $globalDebug, $globalTransaction; |
81 | 91 | //$query = 'TRUNCATE TABLE routes'; |
82 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
92 | + if ($globalDebug) { |
|
93 | + echo " - Delete previous routes from DB -"; |
|
94 | + } |
|
83 | 95 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
84 | 96 | $Connection = new Connection(); |
85 | 97 | try { |
@@ -90,7 +102,9 @@ discard block |
||
90 | 102 | return "error : ".$e->getMessage(); |
91 | 103 | } |
92 | 104 | |
93 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
105 | + if ($globalDebug) { |
|
106 | + echo " - Add routes to DB -"; |
|
107 | + } |
|
94 | 108 | update_db::connect_sqlite($database_file); |
95 | 109 | //$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'; |
96 | 110 | $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"; |
@@ -105,15 +119,21 @@ discard block |
||
105 | 119 | $Connection = new Connection(); |
106 | 120 | $sth_dest = $Connection->db->prepare($query_dest); |
107 | 121 | try { |
108 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
122 | + if ($globalTransaction) { |
|
123 | + $Connection->db->beginTransaction(); |
|
124 | + } |
|
109 | 125 | while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
110 | 126 | //$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); |
111 | 127 | $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); |
112 | 128 | $sth_dest->execute($query_dest_values); |
113 | 129 | } |
114 | - if ($globalTransaction) $Connection->db->commit(); |
|
130 | + if ($globalTransaction) { |
|
131 | + $Connection->db->commit(); |
|
132 | + } |
|
115 | 133 | } catch(PDOException $e) { |
116 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
134 | + if ($globalTransaction) { |
|
135 | + $Connection->db->rollBack(); |
|
136 | + } |
|
117 | 137 | return "error : ".$e->getMessage(); |
118 | 138 | } |
119 | 139 | return ''; |
@@ -121,7 +141,9 @@ discard block |
||
121 | 141 | public static function retrieve_route_oneworld($database_file) { |
122 | 142 | global $globalDebug, $globalTransaction; |
123 | 143 | //$query = 'TRUNCATE TABLE routes'; |
124 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
144 | + if ($globalDebug) { |
|
145 | + echo " - Delete previous routes from DB -"; |
|
146 | + } |
|
125 | 147 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
126 | 148 | $Connection = new Connection(); |
127 | 149 | try { |
@@ -132,14 +154,18 @@ discard block |
||
132 | 154 | return "error : ".$e->getMessage(); |
133 | 155 | } |
134 | 156 | |
135 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
157 | + if ($globalDebug) { |
|
158 | + echo " - Add routes to DB -"; |
|
159 | + } |
|
136 | 160 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
137 | 161 | $Spotter = new Spotter(); |
138 | 162 | if ($fh = fopen($database_file,"r")) { |
139 | 163 | $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)'; |
140 | 164 | $Connection = new Connection(); |
141 | 165 | $sth_dest = $Connection->db->prepare($query_dest); |
142 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
166 | + if ($globalTransaction) { |
|
167 | + $Connection->db->beginTransaction(); |
|
168 | + } |
|
143 | 169 | while (!feof($fh)) { |
144 | 170 | $line = fgetcsv($fh,9999,','); |
145 | 171 | if ($line[0] != '') { |
@@ -148,13 +174,17 @@ discard block |
||
148 | 174 | $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'); |
149 | 175 | $sth_dest->execute($query_dest_values); |
150 | 176 | } catch(PDOException $e) { |
151 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
177 | + if ($globalTransaction) { |
|
178 | + $Connection->db->rollBack(); |
|
179 | + } |
|
152 | 180 | return "error : ".$e->getMessage(); |
153 | 181 | } |
154 | 182 | } |
155 | 183 | } |
156 | 184 | } |
157 | - if ($globalTransaction) $Connection->db->commit(); |
|
185 | + if ($globalTransaction) { |
|
186 | + $Connection->db->commit(); |
|
187 | + } |
|
158 | 188 | } |
159 | 189 | return ''; |
160 | 190 | } |
@@ -162,7 +192,9 @@ discard block |
||
162 | 192 | public static function retrieve_route_skyteam($database_file) { |
163 | 193 | global $globalDebug, $globalTransaction; |
164 | 194 | //$query = 'TRUNCATE TABLE routes'; |
165 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
195 | + if ($globalDebug) { |
|
196 | + echo " - Delete previous routes from DB -"; |
|
197 | + } |
|
166 | 198 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
167 | 199 | $Connection = new Connection(); |
168 | 200 | try { |
@@ -173,7 +205,9 @@ discard block |
||
173 | 205 | return "error : ".$e->getMessage(); |
174 | 206 | } |
175 | 207 | |
176 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
208 | + if ($globalDebug) { |
|
209 | + echo " - Add routes to DB -"; |
|
210 | + } |
|
177 | 211 | |
178 | 212 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
179 | 213 | $Spotter = new Spotter(); |
@@ -182,7 +216,9 @@ discard block |
||
182 | 216 | $Connection = new Connection(); |
183 | 217 | $sth_dest = $Connection->db->prepare($query_dest); |
184 | 218 | try { |
185 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
219 | + if ($globalTransaction) { |
|
220 | + $Connection->db->beginTransaction(); |
|
221 | + } |
|
186 | 222 | while (!feof($fh)) { |
187 | 223 | $line = fgetcsv($fh,9999,','); |
188 | 224 | if ($line[0] != '') { |
@@ -193,9 +229,13 @@ discard block |
||
193 | 229 | } |
194 | 230 | } |
195 | 231 | } |
196 | - if ($globalTransaction) $Connection->db->commit(); |
|
232 | + if ($globalTransaction) { |
|
233 | + $Connection->db->commit(); |
|
234 | + } |
|
197 | 235 | } catch(PDOException $e) { |
198 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
236 | + if ($globalTransaction) { |
|
237 | + $Connection->db->rollBack(); |
|
238 | + } |
|
199 | 239 | return "error : ".$e->getMessage(); |
200 | 240 | } |
201 | 241 | } |
@@ -238,11 +278,16 @@ discard block |
||
238 | 278 | $sth_dest = $Connection->db->prepare($query_dest); |
239 | 279 | $sth_dest_owner = $Connection->db->prepare($query_dest_owner); |
240 | 280 | try { |
241 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
281 | + if ($globalTransaction) { |
|
282 | + $Connection->db->beginTransaction(); |
|
283 | + } |
|
242 | 284 | while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
243 | 285 | //$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']); |
244 | - if ($values['UserString4'] == 'M') $type = 'military'; |
|
245 | - else $type = null; |
|
286 | + if ($values['UserString4'] == 'M') { |
|
287 | + $type = 'military'; |
|
288 | + } else { |
|
289 | + $type = null; |
|
290 | + } |
|
246 | 291 | $query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type); |
247 | 292 | $sth_dest->execute($query_dest_values); |
248 | 293 | if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') { |
@@ -250,7 +295,9 @@ discard block |
||
250 | 295 | $sth_dest_owner->execute($query_dest_owner_values); |
251 | 296 | } |
252 | 297 | } |
253 | - if ($globalTransaction) $Connection->db->commit(); |
|
298 | + if ($globalTransaction) { |
|
299 | + $Connection->db->commit(); |
|
300 | + } |
|
254 | 301 | } catch(PDOException $e) { |
255 | 302 | return "error : ".$e->getMessage(); |
256 | 303 | } |
@@ -287,7 +334,9 @@ discard block |
||
287 | 334 | $Connection = new Connection(); |
288 | 335 | $sth_dest = $Connection->db->prepare($query_dest); |
289 | 336 | try { |
290 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
337 | + if ($globalTransaction) { |
|
338 | + $Connection->db->beginTransaction(); |
|
339 | + } |
|
291 | 340 | while (!feof($fh)) { |
292 | 341 | $values = array(); |
293 | 342 | $line = $Common->hex2str(fgets($fh,9999)); |
@@ -298,7 +347,9 @@ discard block |
||
298 | 347 | // Check if we can find ICAO, else set it to GLID |
299 | 348 | $aircraft_name_split = explode(' ',$aircraft_name); |
300 | 349 | $search_more = ''; |
301 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
350 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) { |
|
351 | + $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
352 | + } |
|
302 | 353 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
303 | 354 | $sth_search = $Connection->db->prepare($query_search); |
304 | 355 | try { |
@@ -311,7 +362,9 @@ discard block |
||
311 | 362 | } catch(PDOException $e) { |
312 | 363 | return "error : ".$e->getMessage(); |
313 | 364 | } |
314 | - if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID'; |
|
365 | + if (!isset($values['ICAOTypeCode'])) { |
|
366 | + $values['ICAOTypeCode'] = 'GLID'; |
|
367 | + } |
|
315 | 368 | // Add data to db |
316 | 369 | if ($values['Registration'] != '' && $values['Registration'] != '0000') { |
317 | 370 | //$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']); |
@@ -320,7 +373,9 @@ discard block |
||
320 | 373 | $sth_dest->execute($query_dest_values); |
321 | 374 | } |
322 | 375 | } |
323 | - if ($globalTransaction) $Connection->db->commit(); |
|
376 | + if ($globalTransaction) { |
|
377 | + $Connection->db->commit(); |
|
378 | + } |
|
324 | 379 | } catch(PDOException $e) { |
325 | 380 | return "error : ".$e->getMessage(); |
326 | 381 | } |
@@ -356,7 +411,9 @@ discard block |
||
356 | 411 | $Connection = new Connection(); |
357 | 412 | $sth_dest = $Connection->db->prepare($query_dest); |
358 | 413 | try { |
359 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
414 | + if ($globalTransaction) { |
|
415 | + $Connection->db->beginTransaction(); |
|
416 | + } |
|
360 | 417 | $tmp = fgetcsv($fh,9999,',',"'"); |
361 | 418 | while (!feof($fh)) { |
362 | 419 | $line = fgetcsv($fh,9999,',',"'"); |
@@ -370,13 +427,17 @@ discard block |
||
370 | 427 | // Check if we can find ICAO, else set it to GLID |
371 | 428 | $aircraft_name_split = explode(' ',$aircraft_name); |
372 | 429 | $search_more = ''; |
373 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
430 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) { |
|
431 | + $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
432 | + } |
|
374 | 433 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
375 | 434 | $sth_search = $Connection->db->prepare($query_search); |
376 | 435 | try { |
377 | 436 | $sth_search->execute(); |
378 | 437 | $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
379 | - if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
|
438 | + if (isset($result['icao']) && $result['icao'] != '') { |
|
439 | + $values['ICAOTypeCode'] = $result['icao']; |
|
440 | + } |
|
380 | 441 | } catch(PDOException $e) { |
381 | 442 | return "error : ".$e->getMessage(); |
382 | 443 | } |
@@ -389,7 +450,9 @@ discard block |
||
389 | 450 | $sth_dest->execute($query_dest_values); |
390 | 451 | } |
391 | 452 | } |
392 | - if ($globalTransaction) $Connection->db->commit(); |
|
453 | + if ($globalTransaction) { |
|
454 | + $Connection->db->commit(); |
|
455 | + } |
|
393 | 456 | } catch(PDOException $e) { |
394 | 457 | return "error : ".$e->getMessage(); |
395 | 458 | } |
@@ -428,7 +491,9 @@ discard block |
||
428 | 491 | $sth_dest = $Connection->db->prepare($query_dest); |
429 | 492 | $sth_modes = $Connection->db->prepare($query_modes); |
430 | 493 | try { |
431 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
494 | + if ($globalTransaction) { |
|
495 | + $Connection->db->beginTransaction(); |
|
496 | + } |
|
432 | 497 | $tmp = fgetcsv($fh,9999,',','"'); |
433 | 498 | while (!feof($fh)) { |
434 | 499 | $line = fgetcsv($fh,9999,',','"'); |
@@ -438,16 +503,22 @@ discard block |
||
438 | 503 | $values['registration'] = $line[0]; |
439 | 504 | $values['base'] = $line[4]; |
440 | 505 | $values['owner'] = $line[5]; |
441 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
442 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
506 | + if ($line[6] == '') { |
|
507 | + $values['date_first_reg'] = null; |
|
508 | + } else { |
|
509 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
510 | + } |
|
443 | 511 | $values['cancel'] = $line[7]; |
444 | 512 | } elseif ($country == 'EI') { |
445 | 513 | // TODO : add modeS & reg to aircraft_modes |
446 | 514 | $values['registration'] = $line[0]; |
447 | 515 | $values['base'] = $line[3]; |
448 | 516 | $values['owner'] = $line[2]; |
449 | - if ($line[1] == '') $values['date_first_reg'] = null; |
|
450 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
517 | + if ($line[1] == '') { |
|
518 | + $values['date_first_reg'] = null; |
|
519 | + } else { |
|
520 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
521 | + } |
|
451 | 522 | $values['cancel'] = ''; |
452 | 523 | $values['modes'] = $line[7]; |
453 | 524 | $values['icao'] = $line[8]; |
@@ -466,16 +537,22 @@ discard block |
||
466 | 537 | $values['registration'] = $line[3]; |
467 | 538 | $values['base'] = null; |
468 | 539 | $values['owner'] = $line[5]; |
469 | - if ($line[18] == '') $values['date_first_reg'] = null; |
|
470 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
540 | + if ($line[18] == '') { |
|
541 | + $values['date_first_reg'] = null; |
|
542 | + } else { |
|
543 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
544 | + } |
|
471 | 545 | $values['cancel'] = ''; |
472 | 546 | } elseif ($country == 'VH') { |
473 | 547 | // TODO : add modeS & reg to aircraft_modes |
474 | 548 | $values['registration'] = $line[0]; |
475 | 549 | $values['base'] = null; |
476 | 550 | $values['owner'] = $line[12]; |
477 | - if ($line[28] == '') $values['date_first_reg'] = null; |
|
478 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
551 | + if ($line[28] == '') { |
|
552 | + $values['date_first_reg'] = null; |
|
553 | + } else { |
|
554 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
555 | + } |
|
479 | 556 | |
480 | 557 | $values['cancel'] = $line[39]; |
481 | 558 | } elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { |
@@ -494,29 +571,41 @@ discard block |
||
494 | 571 | $values['registration'] = $line[0]; |
495 | 572 | $values['base'] = null; |
496 | 573 | $values['owner'] = $line[8]; |
497 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
498 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
574 | + if ($line[7] == '') { |
|
575 | + $values['date_first_reg'] = null; |
|
576 | + } else { |
|
577 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
578 | + } |
|
499 | 579 | $values['cancel'] = ''; |
500 | 580 | } elseif ($country == 'PP') { |
501 | 581 | $values['registration'] = $line[0]; |
502 | 582 | $values['base'] = null; |
503 | 583 | $values['owner'] = $line[4]; |
504 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
505 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
584 | + if ($line[6] == '') { |
|
585 | + $values['date_first_reg'] = null; |
|
586 | + } else { |
|
587 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
588 | + } |
|
506 | 589 | $values['cancel'] = $line[7]; |
507 | 590 | } elseif ($country == 'E7') { |
508 | 591 | $values['registration'] = $line[0]; |
509 | 592 | $values['base'] = null; |
510 | 593 | $values['owner'] = $line[4]; |
511 | - if ($line[5] == '') $values['date_first_reg'] = null; |
|
512 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
594 | + if ($line[5] == '') { |
|
595 | + $values['date_first_reg'] = null; |
|
596 | + } else { |
|
597 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
598 | + } |
|
513 | 599 | $values['cancel'] = ''; |
514 | 600 | } elseif ($country == '8Q') { |
515 | 601 | $values['registration'] = $line[0]; |
516 | 602 | $values['base'] = null; |
517 | 603 | $values['owner'] = $line[3]; |
518 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
519 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
604 | + if ($line[7] == '') { |
|
605 | + $values['date_first_reg'] = null; |
|
606 | + } else { |
|
607 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
608 | + } |
|
520 | 609 | $values['cancel'] = ''; |
521 | 610 | } elseif ($country == 'ZK') { |
522 | 611 | $values['registration'] = $line[0]; |
@@ -561,7 +650,9 @@ discard block |
||
561 | 650 | $sth_modes->execute($query_modes_values); |
562 | 651 | } |
563 | 652 | } |
564 | - if ($globalTransaction) $Connection->db->commit(); |
|
653 | + if ($globalTransaction) { |
|
654 | + $Connection->db->commit(); |
|
655 | + } |
|
565 | 656 | } catch(PDOException $e) { |
566 | 657 | return "error : ".$e->getMessage(); |
567 | 658 | } |
@@ -697,25 +788,45 @@ discard block |
||
697 | 788 | VALUES (:name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)"; |
698 | 789 | $Connection = new Connection(); |
699 | 790 | $sth_dest = $Connection->db->prepare($query_dest); |
700 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
791 | + if ($globalTransaction) { |
|
792 | + $Connection->db->beginTransaction(); |
|
793 | + } |
|
701 | 794 | |
702 | 795 | $i = 0; |
703 | 796 | while($row = sparql_fetch_array($result)) |
704 | 797 | { |
705 | 798 | if ($i >= 1) { |
706 | 799 | //print_r($row); |
707 | - if (!isset($row['iata'])) $row['iata'] = ''; |
|
708 | - if (!isset($row['icao'])) $row['icao'] = ''; |
|
709 | - if (!isset($row['type'])) $row['type'] = ''; |
|
710 | - if (!isset($row['altitude'])) $row['altitude'] = ''; |
|
800 | + if (!isset($row['iata'])) { |
|
801 | + $row['iata'] = ''; |
|
802 | + } |
|
803 | + if (!isset($row['icao'])) { |
|
804 | + $row['icao'] = ''; |
|
805 | + } |
|
806 | + if (!isset($row['type'])) { |
|
807 | + $row['type'] = ''; |
|
808 | + } |
|
809 | + if (!isset($row['altitude'])) { |
|
810 | + $row['altitude'] = ''; |
|
811 | + } |
|
711 | 812 | if (isset($row['city_bis'])) { |
712 | 813 | $row['city'] = $row['city_bis']; |
713 | 814 | } |
714 | - if (!isset($row['city'])) $row['city'] = ''; |
|
715 | - if (!isset($row['country'])) $row['country'] = ''; |
|
716 | - if (!isset($row['homepage'])) $row['homepage'] = ''; |
|
717 | - if (!isset($row['wikipedia_page'])) $row['wikipedia_page'] = ''; |
|
718 | - if (!isset($row['name'])) continue; |
|
815 | + if (!isset($row['city'])) { |
|
816 | + $row['city'] = ''; |
|
817 | + } |
|
818 | + if (!isset($row['country'])) { |
|
819 | + $row['country'] = ''; |
|
820 | + } |
|
821 | + if (!isset($row['homepage'])) { |
|
822 | + $row['homepage'] = ''; |
|
823 | + } |
|
824 | + if (!isset($row['wikipedia_page'])) { |
|
825 | + $row['wikipedia_page'] = ''; |
|
826 | + } |
|
827 | + if (!isset($row['name'])) { |
|
828 | + continue; |
|
829 | + } |
|
719 | 830 | if (!isset($row['image'])) { |
720 | 831 | $row['image'] = ''; |
721 | 832 | $row['image_thumb'] = ''; |
@@ -771,7 +882,9 @@ discard block |
||
771 | 882 | |
772 | 883 | $i++; |
773 | 884 | } |
774 | - if ($globalTransaction) $Connection->db->commit(); |
|
885 | + if ($globalTransaction) { |
|
886 | + $Connection->db->commit(); |
|
887 | + } |
|
775 | 888 | /* |
776 | 889 | echo "Delete duplicate rows...\n"; |
777 | 890 | $query = 'ALTER IGNORE TABLE airport ADD UNIQUE INDEX icaoidx (icao)'; |
@@ -814,7 +927,9 @@ discard block |
||
814 | 927 | $delimiter = ','; |
815 | 928 | $out_file = $tmp_dir.'airports.csv'; |
816 | 929 | update_db::download('http://ourairports.com/data/airports.csv',$out_file); |
817 | - if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
|
930 | + if (!file_exists($out_file) || !is_readable($out_file)) { |
|
931 | + return FALSE; |
|
932 | + } |
|
818 | 933 | echo "Add data from ourairports.com...\n"; |
819 | 934 | |
820 | 935 | $header = NULL; |
@@ -824,8 +939,9 @@ discard block |
||
824 | 939 | //$Connection->db->beginTransaction(); |
825 | 940 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
826 | 941 | { |
827 | - if(!$header) $header = $row; |
|
828 | - else { |
|
942 | + if(!$header) { |
|
943 | + $header = $row; |
|
944 | + } else { |
|
829 | 945 | $data = array(); |
830 | 946 | $data = array_combine($header, $row); |
831 | 947 | try { |
@@ -866,7 +982,9 @@ discard block |
||
866 | 982 | echo "Download data from another free database...\n"; |
867 | 983 | $out_file = $tmp_dir.'GlobalAirportDatabase.zip'; |
868 | 984 | update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file); |
869 | - if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
|
985 | + if (!file_exists($out_file) || !is_readable($out_file)) { |
|
986 | + return FALSE; |
|
987 | + } |
|
870 | 988 | update_db::unzip($out_file); |
871 | 989 | $header = NULL; |
872 | 990 | echo "Add data from another free database...\n"; |
@@ -877,8 +995,9 @@ discard block |
||
877 | 995 | //$Connection->db->beginTransaction(); |
878 | 996 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
879 | 997 | { |
880 | - if(!$header) $header = $row; |
|
881 | - else { |
|
998 | + if(!$header) { |
|
999 | + $header = $row; |
|
1000 | + } else { |
|
882 | 1001 | $data = $row; |
883 | 1002 | |
884 | 1003 | $query = 'UPDATE airport SET city = :city, country = :country WHERE icao = :icao'; |
@@ -1047,7 +1166,9 @@ discard block |
||
1047 | 1166 | if (($handle = fopen($tmp_dir.'MASTER.txt', 'r')) !== FALSE) |
1048 | 1167 | { |
1049 | 1168 | $i = 0; |
1050 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1169 | + if ($globalTransaction) { |
|
1170 | + $Connection->db->beginTransaction(); |
|
1171 | + } |
|
1051 | 1172 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1052 | 1173 | { |
1053 | 1174 | if ($i > 0) { |
@@ -1060,7 +1181,9 @@ discard block |
||
1060 | 1181 | } |
1061 | 1182 | $result_search = $sths->fetchAll(PDO::FETCH_ASSOC); |
1062 | 1183 | if (!empty($result_search)) { |
1063 | - if ($globalDebug) echo '.'; |
|
1184 | + if ($globalDebug) { |
|
1185 | + echo '.'; |
|
1186 | + } |
|
1064 | 1187 | //if ($globalDBdriver == 'mysql') { |
1065 | 1188 | // $queryi = 'INSERT INTO faamfr (mfr,icao) VALUES (:mfr,:icao) ON DUPLICATE KEY UPDATE icao = :icao'; |
1066 | 1189 | //} else { |
@@ -1082,8 +1205,12 @@ discard block |
||
1082 | 1205 | } |
1083 | 1206 | $result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC); |
1084 | 1207 | if (!empty($result_search_mfr)) { |
1085 | - if (trim($data[16]) == '' && trim($data[23]) != '') $data[16] = $data[23]; |
|
1086 | - if (trim($data[16]) == '' && trim($data[15]) != '') $data[16] = $data[15]; |
|
1208 | + if (trim($data[16]) == '' && trim($data[23]) != '') { |
|
1209 | + $data[16] = $data[23]; |
|
1210 | + } |
|
1211 | + if (trim($data[16]) == '' && trim($data[15]) != '') { |
|
1212 | + $data[16] = $data[15]; |
|
1213 | + } |
|
1087 | 1214 | $queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)'; |
1088 | 1215 | try { |
1089 | 1216 | $sthf = $Connection->db->prepare($queryf); |
@@ -1094,7 +1221,9 @@ discard block |
||
1094 | 1221 | } |
1095 | 1222 | } |
1096 | 1223 | if (strtotime($data[29]) > time()) { |
1097 | - if ($globalDebug) echo 'i'; |
|
1224 | + if ($globalDebug) { |
|
1225 | + echo 'i'; |
|
1226 | + } |
|
1098 | 1227 | $query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)'; |
1099 | 1228 | try { |
1100 | 1229 | $sth = $Connection->db->prepare($query); |
@@ -1105,13 +1234,19 @@ discard block |
||
1105 | 1234 | } |
1106 | 1235 | } |
1107 | 1236 | if ($i % 90 == 0) { |
1108 | - if ($globalTransaction) $Connection->db->commit(); |
|
1109 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1237 | + if ($globalTransaction) { |
|
1238 | + $Connection->db->commit(); |
|
1239 | + } |
|
1240 | + if ($globalTransaction) { |
|
1241 | + $Connection->db->beginTransaction(); |
|
1242 | + } |
|
1110 | 1243 | } |
1111 | 1244 | $i++; |
1112 | 1245 | } |
1113 | 1246 | fclose($handle); |
1114 | - if ($globalTransaction) $Connection->db->commit(); |
|
1247 | + if ($globalTransaction) { |
|
1248 | + $Connection->db->commit(); |
|
1249 | + } |
|
1115 | 1250 | } |
1116 | 1251 | return ''; |
1117 | 1252 | } |
@@ -1131,11 +1266,15 @@ discard block |
||
1131 | 1266 | if (($handle = fopen($tmp_dir.'modes.tsv', 'r')) !== FALSE) |
1132 | 1267 | { |
1133 | 1268 | $i = 0; |
1134 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1269 | + if ($globalTransaction) { |
|
1270 | + $Connection->db->beginTransaction(); |
|
1271 | + } |
|
1135 | 1272 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1136 | 1273 | { |
1137 | 1274 | if ($i > 0) { |
1138 | - if ($data[1] == 'NULL') $data[1] = $data[0]; |
|
1275 | + if ($data[1] == 'NULL') { |
|
1276 | + $data[1] = $data[0]; |
|
1277 | + } |
|
1139 | 1278 | $query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)'; |
1140 | 1279 | try { |
1141 | 1280 | $sth = $Connection->db->prepare($query); |
@@ -1147,7 +1286,9 @@ discard block |
||
1147 | 1286 | $i++; |
1148 | 1287 | } |
1149 | 1288 | fclose($handle); |
1150 | - if ($globalTransaction) $Connection->db->commit(); |
|
1289 | + if ($globalTransaction) { |
|
1290 | + $Connection->db->commit(); |
|
1291 | + } |
|
1151 | 1292 | } |
1152 | 1293 | return ''; |
1153 | 1294 | } |
@@ -1179,11 +1320,15 @@ discard block |
||
1179 | 1320 | if (($handle = fopen($tmp_dir.'airlines.tsv', 'r')) !== FALSE) |
1180 | 1321 | { |
1181 | 1322 | $i = 0; |
1182 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1323 | + if ($globalTransaction) { |
|
1324 | + $Connection->db->beginTransaction(); |
|
1325 | + } |
|
1183 | 1326 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1184 | 1327 | { |
1185 | 1328 | if ($i > 0) { |
1186 | - if ($data[1] == 'NULL') $data[1] = $data[0]; |
|
1329 | + if ($data[1] == 'NULL') { |
|
1330 | + $data[1] = $data[0]; |
|
1331 | + } |
|
1187 | 1332 | $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)'; |
1188 | 1333 | try { |
1189 | 1334 | $sth = $Connection->db->prepare($query); |
@@ -1195,7 +1340,9 @@ discard block |
||
1195 | 1340 | $i++; |
1196 | 1341 | } |
1197 | 1342 | fclose($handle); |
1198 | - if ($globalTransaction) $Connection->db->commit(); |
|
1343 | + if ($globalTransaction) { |
|
1344 | + $Connection->db->commit(); |
|
1345 | + } |
|
1199 | 1346 | } |
1200 | 1347 | /* |
1201 | 1348 | $query = "UNLOCK TABLES"; |
@@ -1225,7 +1372,9 @@ discard block |
||
1225 | 1372 | if (($handle = fopen($tmp_dir.'owners.tsv', 'r')) !== FALSE) |
1226 | 1373 | { |
1227 | 1374 | $i = 0; |
1228 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1375 | + if ($globalTransaction) { |
|
1376 | + $Connection->db->beginTransaction(); |
|
1377 | + } |
|
1229 | 1378 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1230 | 1379 | { |
1231 | 1380 | if ($i > 0) { |
@@ -1241,7 +1390,9 @@ discard block |
||
1241 | 1390 | $i++; |
1242 | 1391 | } |
1243 | 1392 | fclose($handle); |
1244 | - if ($globalTransaction) $Connection->db->commit(); |
|
1393 | + if ($globalTransaction) { |
|
1394 | + $Connection->db->commit(); |
|
1395 | + } |
|
1245 | 1396 | } |
1246 | 1397 | return ''; |
1247 | 1398 | } |
@@ -1261,7 +1412,9 @@ discard block |
||
1261 | 1412 | if (($handle = fopen($tmp_dir.'routes.tsv', 'r')) !== FALSE) |
1262 | 1413 | { |
1263 | 1414 | $i = 0; |
1264 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1415 | + if ($globalTransaction) { |
|
1416 | + $Connection->db->beginTransaction(); |
|
1417 | + } |
|
1265 | 1418 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1266 | 1419 | { |
1267 | 1420 | if ($i > 0) { |
@@ -1271,19 +1424,25 @@ discard block |
||
1271 | 1424 | $sth = $Connection->db->prepare($query); |
1272 | 1425 | $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')); |
1273 | 1426 | } catch(PDOException $e) { |
1274 | - if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".implode(',',$data); |
|
1427 | + if ($globalDebug) { |
|
1428 | + echo "error: ".$e->getMessage()." - data: ".implode(',',$data); |
|
1429 | + } |
|
1275 | 1430 | die(); |
1276 | 1431 | } |
1277 | 1432 | } |
1278 | 1433 | if ($globalTransaction && $i % 2000 == 0) { |
1279 | 1434 | $Connection->db->commit(); |
1280 | - if ($globalDebug) echo '.'; |
|
1435 | + if ($globalDebug) { |
|
1436 | + echo '.'; |
|
1437 | + } |
|
1281 | 1438 | $Connection->db->beginTransaction(); |
1282 | 1439 | } |
1283 | 1440 | $i++; |
1284 | 1441 | } |
1285 | 1442 | fclose($handle); |
1286 | - if ($globalTransaction) $Connection->db->commit(); |
|
1443 | + if ($globalTransaction) { |
|
1444 | + $Connection->db->commit(); |
|
1445 | + } |
|
1287 | 1446 | } |
1288 | 1447 | return ''; |
1289 | 1448 | } |
@@ -1308,7 +1467,9 @@ discard block |
||
1308 | 1467 | $i = 0; |
1309 | 1468 | //$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE); |
1310 | 1469 | //$Connection->db->beginTransaction(); |
1311 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1470 | + if ($globalTransaction) { |
|
1471 | + $Connection->db->beginTransaction(); |
|
1472 | + } |
|
1312 | 1473 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1313 | 1474 | { |
1314 | 1475 | if ($i > 0) { |
@@ -1324,7 +1485,9 @@ discard block |
||
1324 | 1485 | $i++; |
1325 | 1486 | } |
1326 | 1487 | fclose($handle); |
1327 | - if ($globalTransaction) $Connection->db->commit(); |
|
1488 | + if ($globalTransaction) { |
|
1489 | + $Connection->db->commit(); |
|
1490 | + } |
|
1328 | 1491 | } |
1329 | 1492 | return ''; |
1330 | 1493 | } |
@@ -1344,7 +1507,9 @@ discard block |
||
1344 | 1507 | if (($handle = fopen($tmp_dir.'satellite.tsv', 'r')) !== FALSE) |
1345 | 1508 | { |
1346 | 1509 | $i = 0; |
1347 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1510 | + if ($globalTransaction) { |
|
1511 | + $Connection->db->beginTransaction(); |
|
1512 | + } |
|
1348 | 1513 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1349 | 1514 | { |
1350 | 1515 | if ($i > 0) { |
@@ -1361,7 +1526,9 @@ discard block |
||
1361 | 1526 | $i++; |
1362 | 1527 | } |
1363 | 1528 | fclose($handle); |
1364 | - if ($globalTransaction) $Connection->db->commit(); |
|
1529 | + if ($globalTransaction) { |
|
1530 | + $Connection->db->commit(); |
|
1531 | + } |
|
1365 | 1532 | } |
1366 | 1533 | return ''; |
1367 | 1534 | } |
@@ -1380,7 +1547,9 @@ discard block |
||
1380 | 1547 | $Connection = new Connection(); |
1381 | 1548 | if (($handle = fopen($tmp_dir.'ban_eu.csv', 'r')) !== FALSE) |
1382 | 1549 | { |
1383 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1550 | + if ($globalTransaction) { |
|
1551 | + $Connection->db->beginTransaction(); |
|
1552 | + } |
|
1384 | 1553 | while (($data = fgetcsv($handle, 1000)) !== FALSE) |
1385 | 1554 | { |
1386 | 1555 | $query = 'UPDATE airlines SET ban_eu = 1 WHERE icao = :icao AND forsource IS NULL'; |
@@ -1395,7 +1564,9 @@ discard block |
||
1395 | 1564 | } |
1396 | 1565 | } |
1397 | 1566 | fclose($handle); |
1398 | - if ($globalTransaction) $Connection->db->commit(); |
|
1567 | + if ($globalTransaction) { |
|
1568 | + $Connection->db->commit(); |
|
1569 | + } |
|
1399 | 1570 | } |
1400 | 1571 | return ''; |
1401 | 1572 | } |
@@ -1471,9 +1642,14 @@ discard block |
||
1471 | 1642 | if ($i > 0 && $data[0] != '') { |
1472 | 1643 | $sources = trim($data[28].' '.$data[29].' '.$data[30].' '.$data[31].' '.$data[32].' '.$data[33]); |
1473 | 1644 | $period = str_replace(',','',$data[14]); |
1474 | - if (!empty($period) && strpos($period,'days')) $period = str_replace(' days','',$period)*24*60; |
|
1475 | - if ($data[18] != '') $launch_date = date('Y-m-d',strtotime($data[18])); |
|
1476 | - else $launch_date = NULL; |
|
1645 | + if (!empty($period) && strpos($period,'days')) { |
|
1646 | + $period = str_replace(' days','',$period)*24*60; |
|
1647 | + } |
|
1648 | + if ($data[18] != '') { |
|
1649 | + $launch_date = date('Y-m-d',strtotime($data[18])); |
|
1650 | + } else { |
|
1651 | + $launch_date = NULL; |
|
1652 | + } |
|
1477 | 1653 | $data = array_map(function($value) { |
1478 | 1654 | return trim($value) === '' ? null : $value; |
1479 | 1655 | }, $data); |
@@ -1836,7 +2012,9 @@ discard block |
||
1836 | 2012 | if (($handle = fopen($filename, 'r')) !== FALSE) |
1837 | 2013 | { |
1838 | 2014 | $i = 0; |
1839 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
2015 | + if ($globalTransaction) { |
|
2016 | + $Connection->db->beginTransaction(); |
|
2017 | + } |
|
1840 | 2018 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1841 | 2019 | { |
1842 | 2020 | $i++; |
@@ -1864,7 +2042,9 @@ discard block |
||
1864 | 2042 | } |
1865 | 2043 | } |
1866 | 2044 | fclose($handle); |
1867 | - if ($globalTransaction) $Connection->db->commit(); |
|
2045 | + if ($globalTransaction) { |
|
2046 | + $Connection->db->commit(); |
|
2047 | + } |
|
1868 | 2048 | } |
1869 | 2049 | return ''; |
1870 | 2050 | } |
@@ -1907,7 +2087,9 @@ discard block |
||
1907 | 2087 | $Connection = new Connection(); |
1908 | 2088 | if (($handle = fopen($filename, 'r')) !== FALSE) |
1909 | 2089 | { |
1910 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
2090 | + if ($globalTransaction) { |
|
2091 | + $Connection->db->beginTransaction(); |
|
2092 | + } |
|
1911 | 2093 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1912 | 2094 | { |
1913 | 2095 | if(count($row) > 1) { |
@@ -1921,7 +2103,9 @@ discard block |
||
1921 | 2103 | } |
1922 | 2104 | } |
1923 | 2105 | fclose($handle); |
1924 | - if ($globalTransaction) $Connection->db->commit(); |
|
2106 | + if ($globalTransaction) { |
|
2107 | + $Connection->db->commit(); |
|
2108 | + } |
|
1925 | 2109 | } |
1926 | 2110 | return ''; |
1927 | 2111 | } |
@@ -1941,8 +2125,9 @@ discard block |
||
1941 | 2125 | } |
1942 | 2126 | |
1943 | 2127 | |
1944 | - if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
1945 | - else { |
|
2128 | + if ($globalDBdriver == 'mysql') { |
|
2129 | + update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
2130 | + } else { |
|
1946 | 2131 | update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
1947 | 2132 | $query = "CREATE EXTENSION postgis"; |
1948 | 2133 | $Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']); |
@@ -1961,7 +2146,9 @@ discard block |
||
1961 | 2146 | global $tmp_dir, $globalDebug; |
1962 | 2147 | include_once('class.create_db.php'); |
1963 | 2148 | require_once(dirname(__FILE__).'/../require/class.NOTAM.php'); |
1964 | - if ($globalDebug) echo "NOTAM from FlightAirMap website : Download..."; |
|
2149 | + if ($globalDebug) { |
|
2150 | + echo "NOTAM from FlightAirMap website : Download..."; |
|
2151 | + } |
|
1965 | 2152 | update_db::download('http://data.flightairmap.com/data/notam.txt.gz.md5',$tmp_dir.'notam.txt.gz.md5'); |
1966 | 2153 | $error = ''; |
1967 | 2154 | if (file_exists($tmp_dir.'notam.txt.gz.md5')) { |
@@ -1971,20 +2158,34 @@ discard block |
||
1971 | 2158 | update_db::download('http://data.flightairmap.com/data/notam.txt.gz',$tmp_dir.'notam.txt.gz'); |
1972 | 2159 | if (file_exists($tmp_dir.'notam.txt.gz')) { |
1973 | 2160 | if (md5_file($tmp_dir.'notam.txt.gz') == $notam_md5) { |
1974 | - if ($globalDebug) echo "Gunzip..."; |
|
2161 | + if ($globalDebug) { |
|
2162 | + echo "Gunzip..."; |
|
2163 | + } |
|
1975 | 2164 | update_db::gunzip($tmp_dir.'notam.txt.gz'); |
1976 | - if ($globalDebug) echo "Add to DB..."; |
|
2165 | + if ($globalDebug) { |
|
2166 | + echo "Add to DB..."; |
|
2167 | + } |
|
1977 | 2168 | //$error = create_db::import_file($tmp_dir.'notam.sql'); |
1978 | 2169 | $NOTAM = new NOTAM(); |
1979 | 2170 | $NOTAM->updateNOTAMfromTextFile($tmp_dir.'notam.txt'); |
1980 | 2171 | update_db::insert_notam_version($notam_md5); |
1981 | - } else $error = "File ".$tmp_dir.'notam.txt.gz'." md5 failed. Download failed."; |
|
1982 | - } else $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed."; |
|
1983 | - } elseif ($globalDebug) echo "No new version."; |
|
1984 | - } else $error = "File ".$tmp_dir.'notam.txt.gz.md5'." doesn't exist. Download failed."; |
|
2172 | + } else { |
|
2173 | + $error = "File ".$tmp_dir.'notam.txt.gz'." md5 failed. Download failed."; |
|
2174 | + } |
|
2175 | + } else { |
|
2176 | + $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed."; |
|
2177 | + } |
|
2178 | + } elseif ($globalDebug) { |
|
2179 | + echo "No new version."; |
|
2180 | + } |
|
2181 | + } else { |
|
2182 | + $error = "File ".$tmp_dir.'notam.txt.gz.md5'." doesn't exist. Download failed."; |
|
2183 | + } |
|
1985 | 2184 | if ($error != '') { |
1986 | 2185 | return $error; |
1987 | - } elseif ($globalDebug) echo "Done\n"; |
|
2186 | + } elseif ($globalDebug) { |
|
2187 | + echo "Done\n"; |
|
2188 | + } |
|
1988 | 2189 | return ''; |
1989 | 2190 | } |
1990 | 2191 | |
@@ -2039,68 +2240,114 @@ discard block |
||
2039 | 2240 | //update_db::download('http://fr.mirror.ivao.aero/software/ivae_feb2013.zip',$tmp_dir.'ivae_feb2013.zip'); |
2040 | 2241 | if (extension_loaded('zip')) { |
2041 | 2242 | if (file_exists($tmp_dir.'ivae_feb2013.zip')) { |
2042 | - if ($globalDebug) echo "Unzip..."; |
|
2243 | + if ($globalDebug) { |
|
2244 | + echo "Unzip..."; |
|
2245 | + } |
|
2043 | 2246 | update_db::unzip($tmp_dir.'ivae_feb2013.zip'); |
2044 | - if ($globalDebug) echo "Add to DB..."; |
|
2247 | + if ($globalDebug) { |
|
2248 | + echo "Add to DB..."; |
|
2249 | + } |
|
2045 | 2250 | update_db::ivao_airlines($tmp_dir.'data/airlines.dat'); |
2046 | - if ($globalDebug) echo "Copy airlines logos to airlines images directory..."; |
|
2251 | + if ($globalDebug) { |
|
2252 | + echo "Copy airlines logos to airlines images directory..."; |
|
2253 | + } |
|
2047 | 2254 | if (is_writable(dirname(__FILE__).'/../images/airlines')) { |
2048 | - if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
2049 | - } else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
|
2050 | - } else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
|
2051 | - } else $error = "ZIP module not loaded but required for IVAO."; |
|
2255 | + if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) { |
|
2256 | + $error = "Failed to copy airlines logo."; |
|
2257 | + } |
|
2258 | + } else { |
|
2259 | + $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
|
2260 | + } |
|
2261 | + } else { |
|
2262 | + $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
|
2263 | + } |
|
2264 | + } else { |
|
2265 | + $error = "ZIP module not loaded but required for IVAO."; |
|
2266 | + } |
|
2052 | 2267 | if ($error != '') { |
2053 | 2268 | return $error; |
2054 | - } elseif ($globalDebug) echo "Done\n"; |
|
2269 | + } elseif ($globalDebug) { |
|
2270 | + echo "Done\n"; |
|
2271 | + } |
|
2055 | 2272 | return ''; |
2056 | 2273 | } |
2057 | 2274 | |
2058 | 2275 | public static function update_routes() { |
2059 | 2276 | global $tmp_dir, $globalDebug; |
2060 | 2277 | $error = ''; |
2061 | - if ($globalDebug) echo "Routes : Download..."; |
|
2278 | + if ($globalDebug) { |
|
2279 | + echo "Routes : Download..."; |
|
2280 | + } |
|
2062 | 2281 | update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz'); |
2063 | 2282 | if (file_exists($tmp_dir.'StandingData.sqb.gz')) { |
2064 | - if ($globalDebug) echo "Gunzip..."; |
|
2283 | + if ($globalDebug) { |
|
2284 | + echo "Gunzip..."; |
|
2285 | + } |
|
2065 | 2286 | update_db::gunzip($tmp_dir.'StandingData.sqb.gz'); |
2066 | - if ($globalDebug) echo "Add to DB..."; |
|
2287 | + if ($globalDebug) { |
|
2288 | + echo "Add to DB..."; |
|
2289 | + } |
|
2067 | 2290 | $error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb'); |
2068 | - } else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed."; |
|
2291 | + } else { |
|
2292 | + $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed."; |
|
2293 | + } |
|
2069 | 2294 | if ($error != '') { |
2070 | 2295 | return $error; |
2071 | - } elseif ($globalDebug) echo "Done\n"; |
|
2296 | + } elseif ($globalDebug) { |
|
2297 | + echo "Done\n"; |
|
2298 | + } |
|
2072 | 2299 | return ''; |
2073 | 2300 | } |
2074 | 2301 | public static function update_oneworld() { |
2075 | 2302 | global $tmp_dir, $globalDebug; |
2076 | 2303 | $error = ''; |
2077 | - if ($globalDebug) echo "Schedules Oneworld : Download..."; |
|
2304 | + if ($globalDebug) { |
|
2305 | + echo "Schedules Oneworld : Download..."; |
|
2306 | + } |
|
2078 | 2307 | update_db::download('http://data.flightairmap.com/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz'); |
2079 | 2308 | if (file_exists($tmp_dir.'oneworld.csv.gz')) { |
2080 | - if ($globalDebug) echo "Gunzip..."; |
|
2309 | + if ($globalDebug) { |
|
2310 | + echo "Gunzip..."; |
|
2311 | + } |
|
2081 | 2312 | update_db::gunzip($tmp_dir.'oneworld.csv.gz'); |
2082 | - if ($globalDebug) echo "Add to DB..."; |
|
2313 | + if ($globalDebug) { |
|
2314 | + echo "Add to DB..."; |
|
2315 | + } |
|
2083 | 2316 | $error = update_db::retrieve_route_oneworld($tmp_dir.'oneworld.csv'); |
2084 | - } else $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed."; |
|
2317 | + } else { |
|
2318 | + $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed."; |
|
2319 | + } |
|
2085 | 2320 | if ($error != '') { |
2086 | 2321 | return $error; |
2087 | - } elseif ($globalDebug) echo "Done\n"; |
|
2322 | + } elseif ($globalDebug) { |
|
2323 | + echo "Done\n"; |
|
2324 | + } |
|
2088 | 2325 | return ''; |
2089 | 2326 | } |
2090 | 2327 | public static function update_skyteam() { |
2091 | 2328 | global $tmp_dir, $globalDebug; |
2092 | 2329 | $error = ''; |
2093 | - if ($globalDebug) echo "Schedules Skyteam : Download..."; |
|
2330 | + if ($globalDebug) { |
|
2331 | + echo "Schedules Skyteam : Download..."; |
|
2332 | + } |
|
2094 | 2333 | update_db::download('http://data.flightairmap.com/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz'); |
2095 | 2334 | if (file_exists($tmp_dir.'skyteam.csv.gz')) { |
2096 | - if ($globalDebug) echo "Gunzip..."; |
|
2335 | + if ($globalDebug) { |
|
2336 | + echo "Gunzip..."; |
|
2337 | + } |
|
2097 | 2338 | update_db::gunzip($tmp_dir.'skyteam.csv.gz'); |
2098 | - if ($globalDebug) echo "Add to DB..."; |
|
2339 | + if ($globalDebug) { |
|
2340 | + echo "Add to DB..."; |
|
2341 | + } |
|
2099 | 2342 | $error = update_db::retrieve_route_skyteam($tmp_dir.'skyteam.csv'); |
2100 | - } else $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed."; |
|
2343 | + } else { |
|
2344 | + $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed."; |
|
2345 | + } |
|
2101 | 2346 | if ($error != '') { |
2102 | 2347 | return $error; |
2103 | - } elseif ($globalDebug) echo "Done\n"; |
|
2348 | + } elseif ($globalDebug) { |
|
2349 | + echo "Done\n"; |
|
2350 | + } |
|
2104 | 2351 | return ''; |
2105 | 2352 | } |
2106 | 2353 | public static function update_ModeS() { |
@@ -2117,340 +2364,590 @@ discard block |
||
2117 | 2364 | exit; |
2118 | 2365 | } elseif ($globalDebug) echo "Done\n"; |
2119 | 2366 | */ |
2120 | - if ($globalDebug) echo "Modes : Download..."; |
|
2121 | -// update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
|
2367 | + if ($globalDebug) { |
|
2368 | + echo "Modes : Download..."; |
|
2369 | + } |
|
2370 | + // update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
|
2122 | 2371 | update_db::download('http://data.flightairmap.com/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz'); |
2123 | 2372 | |
2124 | 2373 | // if (file_exists($tmp_dir.'basestation_latest.zip')) { |
2125 | 2374 | if (file_exists($tmp_dir.'BaseStation.sqb.gz')) { |
2126 | - if ($globalDebug) echo "Unzip..."; |
|
2127 | -// update_db::unzip($tmp_dir.'basestation_latest.zip'); |
|
2375 | + if ($globalDebug) { |
|
2376 | + echo "Unzip..."; |
|
2377 | + } |
|
2378 | + // update_db::unzip($tmp_dir.'basestation_latest.zip'); |
|
2128 | 2379 | update_db::gunzip($tmp_dir.'BaseStation.sqb.gz'); |
2129 | - if ($globalDebug) echo "Add to DB..."; |
|
2380 | + if ($globalDebug) { |
|
2381 | + echo "Add to DB..."; |
|
2382 | + } |
|
2130 | 2383 | $error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb'); |
2131 | 2384 | // $error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'basestation.sqb'); |
2132 | - } else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed."; |
|
2385 | + } else { |
|
2386 | + $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed."; |
|
2387 | + } |
|
2133 | 2388 | if ($error != '') { |
2134 | 2389 | return $error; |
2135 | - } elseif ($globalDebug) echo "Done\n"; |
|
2390 | + } elseif ($globalDebug) { |
|
2391 | + echo "Done\n"; |
|
2392 | + } |
|
2136 | 2393 | return ''; |
2137 | 2394 | } |
2138 | 2395 | |
2139 | 2396 | public static function update_ModeS_faa() { |
2140 | 2397 | global $tmp_dir, $globalDebug; |
2141 | - if ($globalDebug) echo "Modes FAA: Download..."; |
|
2398 | + if ($globalDebug) { |
|
2399 | + echo "Modes FAA: Download..."; |
|
2400 | + } |
|
2142 | 2401 | update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip'); |
2143 | 2402 | if (file_exists($tmp_dir.'ReleasableAircraft.zip')) { |
2144 | - if ($globalDebug) echo "Unzip..."; |
|
2403 | + if ($globalDebug) { |
|
2404 | + echo "Unzip..."; |
|
2405 | + } |
|
2145 | 2406 | update_db::unzip($tmp_dir.'ReleasableAircraft.zip'); |
2146 | - if ($globalDebug) echo "Add to DB..."; |
|
2407 | + if ($globalDebug) { |
|
2408 | + echo "Add to DB..."; |
|
2409 | + } |
|
2147 | 2410 | $error = update_db::modes_faa(); |
2148 | - } else $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed."; |
|
2411 | + } else { |
|
2412 | + $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed."; |
|
2413 | + } |
|
2149 | 2414 | if ($error != '') { |
2150 | 2415 | return $error; |
2151 | - } elseif ($globalDebug) echo "Done\n"; |
|
2416 | + } elseif ($globalDebug) { |
|
2417 | + echo "Done\n"; |
|
2418 | + } |
|
2152 | 2419 | return ''; |
2153 | 2420 | } |
2154 | 2421 | |
2155 | 2422 | public static function update_ModeS_flarm() { |
2156 | 2423 | global $tmp_dir, $globalDebug; |
2157 | - if ($globalDebug) echo "Modes Flarmnet: Download..."; |
|
2424 | + if ($globalDebug) { |
|
2425 | + echo "Modes Flarmnet: Download..."; |
|
2426 | + } |
|
2158 | 2427 | update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln'); |
2159 | 2428 | if (file_exists($tmp_dir.'data.fln')) { |
2160 | - if ($globalDebug) echo "Add to DB..."; |
|
2429 | + if ($globalDebug) { |
|
2430 | + echo "Add to DB..."; |
|
2431 | + } |
|
2161 | 2432 | $error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln'); |
2162 | - } else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed."; |
|
2433 | + } else { |
|
2434 | + $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed."; |
|
2435 | + } |
|
2163 | 2436 | if ($error != '') { |
2164 | 2437 | return $error; |
2165 | - } elseif ($globalDebug) echo "Done\n"; |
|
2438 | + } elseif ($globalDebug) { |
|
2439 | + echo "Done\n"; |
|
2440 | + } |
|
2166 | 2441 | return ''; |
2167 | 2442 | } |
2168 | 2443 | |
2169 | 2444 | public static function update_ModeS_ogn() { |
2170 | 2445 | global $tmp_dir, $globalDebug; |
2171 | - if ($globalDebug) echo "Modes OGN: Download..."; |
|
2446 | + if ($globalDebug) { |
|
2447 | + echo "Modes OGN: Download..."; |
|
2448 | + } |
|
2172 | 2449 | update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv'); |
2173 | 2450 | if (file_exists($tmp_dir.'ogn.csv')) { |
2174 | - if ($globalDebug) echo "Add to DB..."; |
|
2451 | + if ($globalDebug) { |
|
2452 | + echo "Add to DB..."; |
|
2453 | + } |
|
2175 | 2454 | $error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv'); |
2176 | - } else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed."; |
|
2455 | + } else { |
|
2456 | + $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed."; |
|
2457 | + } |
|
2177 | 2458 | if ($error != '') { |
2178 | 2459 | return $error; |
2179 | - } elseif ($globalDebug) echo "Done\n"; |
|
2460 | + } elseif ($globalDebug) { |
|
2461 | + echo "Done\n"; |
|
2462 | + } |
|
2180 | 2463 | return ''; |
2181 | 2464 | } |
2182 | 2465 | |
2183 | 2466 | public static function update_owner() { |
2184 | 2467 | global $tmp_dir, $globalDebug, $globalMasterSource; |
2185 | 2468 | |
2186 | - if ($globalDebug) echo "Owner France: Download..."; |
|
2469 | + if ($globalDebug) { |
|
2470 | + echo "Owner France: Download..."; |
|
2471 | + } |
|
2187 | 2472 | update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv'); |
2188 | 2473 | if (file_exists($tmp_dir.'owner_f.csv')) { |
2189 | - if ($globalDebug) echo "Add to DB..."; |
|
2474 | + if ($globalDebug) { |
|
2475 | + echo "Add to DB..."; |
|
2476 | + } |
|
2190 | 2477 | $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F'); |
2191 | - } else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
|
2478 | + } else { |
|
2479 | + $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
|
2480 | + } |
|
2192 | 2481 | if ($error != '') { |
2193 | 2482 | return $error; |
2194 | - } elseif ($globalDebug) echo "Done\n"; |
|
2483 | + } elseif ($globalDebug) { |
|
2484 | + echo "Done\n"; |
|
2485 | + } |
|
2195 | 2486 | |
2196 | - if ($globalDebug) echo "Owner Ireland: Download..."; |
|
2487 | + if ($globalDebug) { |
|
2488 | + echo "Owner Ireland: Download..."; |
|
2489 | + } |
|
2197 | 2490 | update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv'); |
2198 | 2491 | if (file_exists($tmp_dir.'owner_ei.csv')) { |
2199 | - if ($globalDebug) echo "Add to DB..."; |
|
2492 | + if ($globalDebug) { |
|
2493 | + echo "Add to DB..."; |
|
2494 | + } |
|
2200 | 2495 | $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI'); |
2201 | - } else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
|
2496 | + } else { |
|
2497 | + $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
|
2498 | + } |
|
2202 | 2499 | if ($error != '') { |
2203 | 2500 | return $error; |
2204 | - } elseif ($globalDebug) echo "Done\n"; |
|
2205 | - if ($globalDebug) echo "Owner Switzerland: Download..."; |
|
2501 | + } elseif ($globalDebug) { |
|
2502 | + echo "Done\n"; |
|
2503 | + } |
|
2504 | + if ($globalDebug) { |
|
2505 | + echo "Owner Switzerland: Download..."; |
|
2506 | + } |
|
2206 | 2507 | update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv'); |
2207 | 2508 | if (file_exists($tmp_dir.'owner_hb.csv')) { |
2208 | - if ($globalDebug) echo "Add to DB..."; |
|
2509 | + if ($globalDebug) { |
|
2510 | + echo "Add to DB..."; |
|
2511 | + } |
|
2209 | 2512 | $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB'); |
2210 | - } else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
|
2513 | + } else { |
|
2514 | + $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
|
2515 | + } |
|
2211 | 2516 | if ($error != '') { |
2212 | 2517 | return $error; |
2213 | - } elseif ($globalDebug) echo "Done\n"; |
|
2214 | - if ($globalDebug) echo "Owner Czech Republic: Download..."; |
|
2518 | + } elseif ($globalDebug) { |
|
2519 | + echo "Done\n"; |
|
2520 | + } |
|
2521 | + if ($globalDebug) { |
|
2522 | + echo "Owner Czech Republic: Download..."; |
|
2523 | + } |
|
2215 | 2524 | update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv'); |
2216 | 2525 | if (file_exists($tmp_dir.'owner_ok.csv')) { |
2217 | - if ($globalDebug) echo "Add to DB..."; |
|
2526 | + if ($globalDebug) { |
|
2527 | + echo "Add to DB..."; |
|
2528 | + } |
|
2218 | 2529 | $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK'); |
2219 | - } else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
|
2530 | + } else { |
|
2531 | + $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
|
2532 | + } |
|
2220 | 2533 | if ($error != '') { |
2221 | 2534 | return $error; |
2222 | - } elseif ($globalDebug) echo "Done\n"; |
|
2223 | - if ($globalDebug) echo "Owner Australia: Download..."; |
|
2535 | + } elseif ($globalDebug) { |
|
2536 | + echo "Done\n"; |
|
2537 | + } |
|
2538 | + if ($globalDebug) { |
|
2539 | + echo "Owner Australia: Download..."; |
|
2540 | + } |
|
2224 | 2541 | update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv'); |
2225 | 2542 | if (file_exists($tmp_dir.'owner_vh.csv')) { |
2226 | - if ($globalDebug) echo "Add to DB..."; |
|
2543 | + if ($globalDebug) { |
|
2544 | + echo "Add to DB..."; |
|
2545 | + } |
|
2227 | 2546 | $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH'); |
2228 | - } else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
|
2547 | + } else { |
|
2548 | + $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
|
2549 | + } |
|
2229 | 2550 | if ($error != '') { |
2230 | 2551 | return $error; |
2231 | - } elseif ($globalDebug) echo "Done\n"; |
|
2232 | - if ($globalDebug) echo "Owner Austria: Download..."; |
|
2552 | + } elseif ($globalDebug) { |
|
2553 | + echo "Done\n"; |
|
2554 | + } |
|
2555 | + if ($globalDebug) { |
|
2556 | + echo "Owner Austria: Download..."; |
|
2557 | + } |
|
2233 | 2558 | update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv'); |
2234 | 2559 | if (file_exists($tmp_dir.'owner_oe.csv')) { |
2235 | - if ($globalDebug) echo "Add to DB..."; |
|
2560 | + if ($globalDebug) { |
|
2561 | + echo "Add to DB..."; |
|
2562 | + } |
|
2236 | 2563 | $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE'); |
2237 | - } else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
|
2564 | + } else { |
|
2565 | + $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
|
2566 | + } |
|
2238 | 2567 | if ($error != '') { |
2239 | 2568 | return $error; |
2240 | - } elseif ($globalDebug) echo "Done\n"; |
|
2241 | - if ($globalDebug) echo "Owner Chile: Download..."; |
|
2569 | + } elseif ($globalDebug) { |
|
2570 | + echo "Done\n"; |
|
2571 | + } |
|
2572 | + if ($globalDebug) { |
|
2573 | + echo "Owner Chile: Download..."; |
|
2574 | + } |
|
2242 | 2575 | update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv'); |
2243 | 2576 | if (file_exists($tmp_dir.'owner_cc.csv')) { |
2244 | - if ($globalDebug) echo "Add to DB..."; |
|
2577 | + if ($globalDebug) { |
|
2578 | + echo "Add to DB..."; |
|
2579 | + } |
|
2245 | 2580 | $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC'); |
2246 | - } else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
|
2581 | + } else { |
|
2582 | + $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
|
2583 | + } |
|
2247 | 2584 | if ($error != '') { |
2248 | 2585 | return $error; |
2249 | - } elseif ($globalDebug) echo "Done\n"; |
|
2250 | - if ($globalDebug) echo "Owner Colombia: Download..."; |
|
2586 | + } elseif ($globalDebug) { |
|
2587 | + echo "Done\n"; |
|
2588 | + } |
|
2589 | + if ($globalDebug) { |
|
2590 | + echo "Owner Colombia: Download..."; |
|
2591 | + } |
|
2251 | 2592 | update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv'); |
2252 | 2593 | if (file_exists($tmp_dir.'owner_hj.csv')) { |
2253 | - if ($globalDebug) echo "Add to DB..."; |
|
2594 | + if ($globalDebug) { |
|
2595 | + echo "Add to DB..."; |
|
2596 | + } |
|
2254 | 2597 | $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ'); |
2255 | - } else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
|
2598 | + } else { |
|
2599 | + $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
|
2600 | + } |
|
2256 | 2601 | if ($error != '') { |
2257 | 2602 | return $error; |
2258 | - } elseif ($globalDebug) echo "Done\n"; |
|
2259 | - if ($globalDebug) echo "Owner Bosnia Herzegobina: Download..."; |
|
2603 | + } elseif ($globalDebug) { |
|
2604 | + echo "Done\n"; |
|
2605 | + } |
|
2606 | + if ($globalDebug) { |
|
2607 | + echo "Owner Bosnia Herzegobina: Download..."; |
|
2608 | + } |
|
2260 | 2609 | update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv'); |
2261 | 2610 | if (file_exists($tmp_dir.'owner_e7.csv')) { |
2262 | - if ($globalDebug) echo "Add to DB..."; |
|
2611 | + if ($globalDebug) { |
|
2612 | + echo "Add to DB..."; |
|
2613 | + } |
|
2263 | 2614 | $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7'); |
2264 | - } else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
|
2615 | + } else { |
|
2616 | + $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
|
2617 | + } |
|
2265 | 2618 | if ($error != '') { |
2266 | 2619 | return $error; |
2267 | - } elseif ($globalDebug) echo "Done\n"; |
|
2268 | - if ($globalDebug) echo "Owner Brazil: Download..."; |
|
2620 | + } elseif ($globalDebug) { |
|
2621 | + echo "Done\n"; |
|
2622 | + } |
|
2623 | + if ($globalDebug) { |
|
2624 | + echo "Owner Brazil: Download..."; |
|
2625 | + } |
|
2269 | 2626 | update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv'); |
2270 | 2627 | if (file_exists($tmp_dir.'owner_pp.csv')) { |
2271 | - if ($globalDebug) echo "Add to DB..."; |
|
2628 | + if ($globalDebug) { |
|
2629 | + echo "Add to DB..."; |
|
2630 | + } |
|
2272 | 2631 | $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP'); |
2273 | - } else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
|
2632 | + } else { |
|
2633 | + $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
|
2634 | + } |
|
2274 | 2635 | if ($error != '') { |
2275 | 2636 | return $error; |
2276 | - } elseif ($globalDebug) echo "Done\n"; |
|
2277 | - if ($globalDebug) echo "Owner Cayman Islands: Download..."; |
|
2637 | + } elseif ($globalDebug) { |
|
2638 | + echo "Done\n"; |
|
2639 | + } |
|
2640 | + if ($globalDebug) { |
|
2641 | + echo "Owner Cayman Islands: Download..."; |
|
2642 | + } |
|
2278 | 2643 | update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv'); |
2279 | 2644 | if (file_exists($tmp_dir.'owner_vp.csv')) { |
2280 | - if ($globalDebug) echo "Add to DB..."; |
|
2645 | + if ($globalDebug) { |
|
2646 | + echo "Add to DB..."; |
|
2647 | + } |
|
2281 | 2648 | $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP'); |
2282 | - } else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
|
2649 | + } else { |
|
2650 | + $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
|
2651 | + } |
|
2283 | 2652 | if ($error != '') { |
2284 | 2653 | return $error; |
2285 | - } elseif ($globalDebug) echo "Done\n"; |
|
2286 | - if ($globalDebug) echo "Owner Croatia: Download..."; |
|
2654 | + } elseif ($globalDebug) { |
|
2655 | + echo "Done\n"; |
|
2656 | + } |
|
2657 | + if ($globalDebug) { |
|
2658 | + echo "Owner Croatia: Download..."; |
|
2659 | + } |
|
2287 | 2660 | update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv'); |
2288 | 2661 | if (file_exists($tmp_dir.'owner_9a.csv')) { |
2289 | - if ($globalDebug) echo "Add to DB..."; |
|
2662 | + if ($globalDebug) { |
|
2663 | + echo "Add to DB..."; |
|
2664 | + } |
|
2290 | 2665 | $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A'); |
2291 | - } else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
|
2666 | + } else { |
|
2667 | + $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
|
2668 | + } |
|
2292 | 2669 | if ($error != '') { |
2293 | 2670 | return $error; |
2294 | - } elseif ($globalDebug) echo "Done\n"; |
|
2295 | - if ($globalDebug) echo "Owner Luxembourg: Download..."; |
|
2671 | + } elseif ($globalDebug) { |
|
2672 | + echo "Done\n"; |
|
2673 | + } |
|
2674 | + if ($globalDebug) { |
|
2675 | + echo "Owner Luxembourg: Download..."; |
|
2676 | + } |
|
2296 | 2677 | update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv'); |
2297 | 2678 | if (file_exists($tmp_dir.'owner_lx.csv')) { |
2298 | - if ($globalDebug) echo "Add to DB..."; |
|
2679 | + if ($globalDebug) { |
|
2680 | + echo "Add to DB..."; |
|
2681 | + } |
|
2299 | 2682 | $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX'); |
2300 | - } else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
|
2683 | + } else { |
|
2684 | + $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
|
2685 | + } |
|
2301 | 2686 | if ($error != '') { |
2302 | 2687 | return $error; |
2303 | - } elseif ($globalDebug) echo "Done\n"; |
|
2304 | - if ($globalDebug) echo "Owner Maldives: Download..."; |
|
2688 | + } elseif ($globalDebug) { |
|
2689 | + echo "Done\n"; |
|
2690 | + } |
|
2691 | + if ($globalDebug) { |
|
2692 | + echo "Owner Maldives: Download..."; |
|
2693 | + } |
|
2305 | 2694 | update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv'); |
2306 | 2695 | if (file_exists($tmp_dir.'owner_8q.csv')) { |
2307 | - if ($globalDebug) echo "Add to DB..."; |
|
2696 | + if ($globalDebug) { |
|
2697 | + echo "Add to DB..."; |
|
2698 | + } |
|
2308 | 2699 | $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q'); |
2309 | - } else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
|
2700 | + } else { |
|
2701 | + $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
|
2702 | + } |
|
2310 | 2703 | if ($error != '') { |
2311 | 2704 | return $error; |
2312 | - } elseif ($globalDebug) echo "Done\n"; |
|
2313 | - if ($globalDebug) echo "Owner New Zealand: Download..."; |
|
2705 | + } elseif ($globalDebug) { |
|
2706 | + echo "Done\n"; |
|
2707 | + } |
|
2708 | + if ($globalDebug) { |
|
2709 | + echo "Owner New Zealand: Download..."; |
|
2710 | + } |
|
2314 | 2711 | update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv'); |
2315 | 2712 | if (file_exists($tmp_dir.'owner_zk.csv')) { |
2316 | - if ($globalDebug) echo "Add to DB..."; |
|
2713 | + if ($globalDebug) { |
|
2714 | + echo "Add to DB..."; |
|
2715 | + } |
|
2317 | 2716 | $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK'); |
2318 | - } else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
|
2717 | + } else { |
|
2718 | + $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
|
2719 | + } |
|
2319 | 2720 | if ($error != '') { |
2320 | 2721 | return $error; |
2321 | - } elseif ($globalDebug) echo "Done\n"; |
|
2322 | - if ($globalDebug) echo "Owner Papua New Guinea: Download..."; |
|
2722 | + } elseif ($globalDebug) { |
|
2723 | + echo "Done\n"; |
|
2724 | + } |
|
2725 | + if ($globalDebug) { |
|
2726 | + echo "Owner Papua New Guinea: Download..."; |
|
2727 | + } |
|
2323 | 2728 | update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv'); |
2324 | 2729 | if (file_exists($tmp_dir.'owner_p2.csv')) { |
2325 | - if ($globalDebug) echo "Add to DB..."; |
|
2730 | + if ($globalDebug) { |
|
2731 | + echo "Add to DB..."; |
|
2732 | + } |
|
2326 | 2733 | $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2'); |
2327 | - } else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
|
2734 | + } else { |
|
2735 | + $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
|
2736 | + } |
|
2328 | 2737 | if ($error != '') { |
2329 | 2738 | return $error; |
2330 | - } elseif ($globalDebug) echo "Done\n"; |
|
2331 | - if ($globalDebug) echo "Owner Slovakia: Download..."; |
|
2739 | + } elseif ($globalDebug) { |
|
2740 | + echo "Done\n"; |
|
2741 | + } |
|
2742 | + if ($globalDebug) { |
|
2743 | + echo "Owner Slovakia: Download..."; |
|
2744 | + } |
|
2332 | 2745 | update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv'); |
2333 | 2746 | if (file_exists($tmp_dir.'owner_om.csv')) { |
2334 | - if ($globalDebug) echo "Add to DB..."; |
|
2747 | + if ($globalDebug) { |
|
2748 | + echo "Add to DB..."; |
|
2749 | + } |
|
2335 | 2750 | $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM'); |
2336 | - } else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
|
2751 | + } else { |
|
2752 | + $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
|
2753 | + } |
|
2337 | 2754 | if ($error != '') { |
2338 | 2755 | return $error; |
2339 | - } elseif ($globalDebug) echo "Done\n"; |
|
2340 | - if ($globalDebug) echo "Owner Ecuador: Download..."; |
|
2756 | + } elseif ($globalDebug) { |
|
2757 | + echo "Done\n"; |
|
2758 | + } |
|
2759 | + if ($globalDebug) { |
|
2760 | + echo "Owner Ecuador: Download..."; |
|
2761 | + } |
|
2341 | 2762 | update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv'); |
2342 | 2763 | if (file_exists($tmp_dir.'owner_hc.csv')) { |
2343 | - if ($globalDebug) echo "Add to DB..."; |
|
2764 | + if ($globalDebug) { |
|
2765 | + echo "Add to DB..."; |
|
2766 | + } |
|
2344 | 2767 | $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC'); |
2345 | - } else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
|
2768 | + } else { |
|
2769 | + $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
|
2770 | + } |
|
2346 | 2771 | if ($error != '') { |
2347 | 2772 | return $error; |
2348 | - } elseif ($globalDebug) echo "Done\n"; |
|
2349 | - if ($globalDebug) echo "Owner Iceland: Download..."; |
|
2773 | + } elseif ($globalDebug) { |
|
2774 | + echo "Done\n"; |
|
2775 | + } |
|
2776 | + if ($globalDebug) { |
|
2777 | + echo "Owner Iceland: Download..."; |
|
2778 | + } |
|
2350 | 2779 | update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv'); |
2351 | 2780 | if (file_exists($tmp_dir.'owner_tf.csv')) { |
2352 | - if ($globalDebug) echo "Add to DB..."; |
|
2781 | + if ($globalDebug) { |
|
2782 | + echo "Add to DB..."; |
|
2783 | + } |
|
2353 | 2784 | $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF'); |
2354 | - } else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
|
2785 | + } else { |
|
2786 | + $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
|
2787 | + } |
|
2355 | 2788 | if ($error != '') { |
2356 | 2789 | return $error; |
2357 | - } elseif ($globalDebug) echo "Done\n"; |
|
2358 | - if ($globalDebug) echo "Owner Isle of Man: Download..."; |
|
2790 | + } elseif ($globalDebug) { |
|
2791 | + echo "Done\n"; |
|
2792 | + } |
|
2793 | + if ($globalDebug) { |
|
2794 | + echo "Owner Isle of Man: Download..."; |
|
2795 | + } |
|
2359 | 2796 | update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv'); |
2360 | 2797 | if (file_exists($tmp_dir.'owner_m.csv')) { |
2361 | - if ($globalDebug) echo "Add to DB..."; |
|
2798 | + if ($globalDebug) { |
|
2799 | + echo "Add to DB..."; |
|
2800 | + } |
|
2362 | 2801 | $error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M'); |
2363 | - } else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed."; |
|
2802 | + } else { |
|
2803 | + $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed."; |
|
2804 | + } |
|
2364 | 2805 | if ($error != '') { |
2365 | 2806 | return $error; |
2366 | - } elseif ($globalDebug) echo "Done\n"; |
|
2807 | + } elseif ($globalDebug) { |
|
2808 | + echo "Done\n"; |
|
2809 | + } |
|
2367 | 2810 | if ($globalMasterSource) { |
2368 | - if ($globalDebug) echo "ModeS Netherlands: Download..."; |
|
2811 | + if ($globalDebug) { |
|
2812 | + echo "ModeS Netherlands: Download..."; |
|
2813 | + } |
|
2369 | 2814 | update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv'); |
2370 | 2815 | if (file_exists($tmp_dir.'owner_ph.csv')) { |
2371 | - if ($globalDebug) echo "Add to DB..."; |
|
2816 | + if ($globalDebug) { |
|
2817 | + echo "Add to DB..."; |
|
2818 | + } |
|
2372 | 2819 | $error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH'); |
2373 | - } else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed."; |
|
2820 | + } else { |
|
2821 | + $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed."; |
|
2822 | + } |
|
2374 | 2823 | if ($error != '') { |
2375 | 2824 | return $error; |
2376 | - } elseif ($globalDebug) echo "Done\n"; |
|
2377 | - if ($globalDebug) echo "ModeS Denmark: Download..."; |
|
2825 | + } elseif ($globalDebug) { |
|
2826 | + echo "Done\n"; |
|
2827 | + } |
|
2828 | + if ($globalDebug) { |
|
2829 | + echo "ModeS Denmark: Download..."; |
|
2830 | + } |
|
2378 | 2831 | update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv'); |
2379 | 2832 | if (file_exists($tmp_dir.'owner_oy.csv')) { |
2380 | - if ($globalDebug) echo "Add to DB..."; |
|
2833 | + if ($globalDebug) { |
|
2834 | + echo "Add to DB..."; |
|
2835 | + } |
|
2381 | 2836 | $error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY'); |
2382 | - } else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed."; |
|
2837 | + } else { |
|
2838 | + $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed."; |
|
2839 | + } |
|
2383 | 2840 | if ($error != '') { |
2384 | 2841 | return $error; |
2385 | - } elseif ($globalDebug) echo "Done\n"; |
|
2386 | - } elseif ($globalDebug) echo "Done\n"; |
|
2842 | + } elseif ($globalDebug) { |
|
2843 | + echo "Done\n"; |
|
2844 | + } |
|
2845 | + } elseif ($globalDebug) { |
|
2846 | + echo "Done\n"; |
|
2847 | + } |
|
2387 | 2848 | return ''; |
2388 | 2849 | } |
2389 | 2850 | |
2390 | 2851 | public static function update_translation() { |
2391 | 2852 | global $tmp_dir, $globalDebug; |
2392 | 2853 | $error = ''; |
2393 | - if ($globalDebug) echo "Translation : Download..."; |
|
2854 | + if ($globalDebug) { |
|
2855 | + echo "Translation : Download..."; |
|
2856 | + } |
|
2394 | 2857 | update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip'); |
2395 | 2858 | if (file_exists($tmp_dir.'translation.zip')) { |
2396 | - if ($globalDebug) echo "Unzip..."; |
|
2859 | + if ($globalDebug) { |
|
2860 | + echo "Unzip..."; |
|
2861 | + } |
|
2397 | 2862 | update_db::unzip($tmp_dir.'translation.zip'); |
2398 | - if ($globalDebug) echo "Add to DB..."; |
|
2863 | + if ($globalDebug) { |
|
2864 | + echo "Add to DB..."; |
|
2865 | + } |
|
2399 | 2866 | $error = update_db::translation(); |
2400 | - } else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed."; |
|
2867 | + } else { |
|
2868 | + $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed."; |
|
2869 | + } |
|
2401 | 2870 | if ($error != '') { |
2402 | 2871 | return $error; |
2403 | - } elseif ($globalDebug) echo "Done\n"; |
|
2872 | + } elseif ($globalDebug) { |
|
2873 | + echo "Done\n"; |
|
2874 | + } |
|
2404 | 2875 | return ''; |
2405 | 2876 | } |
2406 | 2877 | |
2407 | 2878 | public static function update_translation_fam() { |
2408 | 2879 | global $tmp_dir, $globalDebug; |
2409 | 2880 | $error = ''; |
2410 | - if ($globalDebug) echo "Translation from FlightAirMap website : Download..."; |
|
2881 | + if ($globalDebug) { |
|
2882 | + echo "Translation from FlightAirMap website : Download..."; |
|
2883 | + } |
|
2411 | 2884 | update_db::download('http://data.flightairmap.com/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz'); |
2412 | 2885 | update_db::download('http://data.flightairmap.com/data/translation.tsv.gz.md5',$tmp_dir.'translation.tsv.gz.md5'); |
2413 | 2886 | if (file_exists($tmp_dir.'translation.tsv.gz') && file_exists($tmp_dir.'translation.tsv.gz')) { |
2414 | 2887 | $translation_md5_file = explode(' ',file_get_contents($tmp_dir.'translation.tsv.gz.md5')); |
2415 | 2888 | $translation_md5 = $translation_md5_file[0]; |
2416 | 2889 | if (md5_file($tmp_dir.'translation.tsv.gz') == $translation_md5) { |
2417 | - if ($globalDebug) echo "Gunzip..."; |
|
2890 | + if ($globalDebug) { |
|
2891 | + echo "Gunzip..."; |
|
2892 | + } |
|
2418 | 2893 | update_db::gunzip($tmp_dir.'translation.tsv.gz'); |
2419 | - if ($globalDebug) echo "Add to DB..."; |
|
2894 | + if ($globalDebug) { |
|
2895 | + echo "Add to DB..."; |
|
2896 | + } |
|
2420 | 2897 | $error = update_db::translation_fam(); |
2421 | - } else $error = "File ".$tmp_dir.'translation.tsv.gz'." md5 failed. Download failed."; |
|
2422 | - } else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed."; |
|
2898 | + } else { |
|
2899 | + $error = "File ".$tmp_dir.'translation.tsv.gz'." md5 failed. Download failed."; |
|
2900 | + } |
|
2901 | + } else { |
|
2902 | + $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed."; |
|
2903 | + } |
|
2423 | 2904 | if ($error != '') { |
2424 | 2905 | return $error; |
2425 | - } elseif ($globalDebug) echo "Done\n"; |
|
2906 | + } elseif ($globalDebug) { |
|
2907 | + echo "Done\n"; |
|
2908 | + } |
|
2426 | 2909 | return ''; |
2427 | 2910 | } |
2428 | 2911 | public static function update_ModeS_fam() { |
2429 | 2912 | global $tmp_dir, $globalDebug; |
2430 | 2913 | $error = ''; |
2431 | - if ($globalDebug) echo "ModeS from FlightAirMap website : Download..."; |
|
2914 | + if ($globalDebug) { |
|
2915 | + echo "ModeS from FlightAirMap website : Download..."; |
|
2916 | + } |
|
2432 | 2917 | update_db::download('http://data.flightairmap.com/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz'); |
2433 | 2918 | update_db::download('http://data.flightairmap.com/data/modes.tsv.gz.md5',$tmp_dir.'modes.tsv.gz.md5'); |
2434 | 2919 | if (file_exists($tmp_dir.'modes.tsv.gz') && file_exists($tmp_dir.'modes.tsv.gz.md5')) { |
2435 | 2920 | $modes_md5_file = explode(' ',file_get_contents($tmp_dir.'modes.tsv.gz.md5')); |
2436 | 2921 | $modes_md5 = $modes_md5_file[0]; |
2437 | 2922 | if (md5_file($tmp_dir.'modes.tsv.gz') == $modes_md5) { |
2438 | - if ($globalDebug) echo "Gunzip..."; |
|
2923 | + if ($globalDebug) { |
|
2924 | + echo "Gunzip..."; |
|
2925 | + } |
|
2439 | 2926 | update_db::gunzip($tmp_dir.'modes.tsv.gz'); |
2440 | - if ($globalDebug) echo "Add to DB..."; |
|
2927 | + if ($globalDebug) { |
|
2928 | + echo "Add to DB..."; |
|
2929 | + } |
|
2441 | 2930 | $error = update_db::modes_fam(); |
2442 | - } else $error = "File ".$tmp_dir.'modes.tsv.gz'." md5 failed. Download failed."; |
|
2443 | - } else $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed."; |
|
2931 | + } else { |
|
2932 | + $error = "File ".$tmp_dir.'modes.tsv.gz'." md5 failed. Download failed."; |
|
2933 | + } |
|
2934 | + } else { |
|
2935 | + $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed."; |
|
2936 | + } |
|
2444 | 2937 | if ($error != '') { |
2445 | 2938 | return $error; |
2446 | - } elseif ($globalDebug) echo "Done\n"; |
|
2939 | + } elseif ($globalDebug) { |
|
2940 | + echo "Done\n"; |
|
2941 | + } |
|
2447 | 2942 | return ''; |
2448 | 2943 | } |
2449 | 2944 | |
2450 | 2945 | public static function update_airlines_fam() { |
2451 | 2946 | global $tmp_dir, $globalDebug; |
2452 | 2947 | $error = ''; |
2453 | - if ($globalDebug) echo "Airlines from FlightAirMap website : Download..."; |
|
2948 | + if ($globalDebug) { |
|
2949 | + echo "Airlines from FlightAirMap website : Download..."; |
|
2950 | + } |
|
2454 | 2951 | update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz.md5',$tmp_dir.'airlines.tsv.gz.md5'); |
2455 | 2952 | if (file_exists($tmp_dir.'airlines.tsv.gz.md5')) { |
2456 | 2953 | $airlines_md5_file = explode(' ',file_get_contents($tmp_dir.'airlines.tsv.gz.md5')); |
@@ -2459,26 +2956,42 @@ discard block |
||
2459 | 2956 | update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz',$tmp_dir.'airlines.tsv.gz'); |
2460 | 2957 | if (file_exists($tmp_dir.'airlines.tsv.gz')) { |
2461 | 2958 | if (md5_file($tmp_dir.'airlines.tsv.gz') == $airlines_md5) { |
2462 | - if ($globalDebug) echo "Gunzip..."; |
|
2959 | + if ($globalDebug) { |
|
2960 | + echo "Gunzip..."; |
|
2961 | + } |
|
2463 | 2962 | update_db::gunzip($tmp_dir.'airlines.tsv.gz'); |
2464 | - if ($globalDebug) echo "Add to DB..."; |
|
2963 | + if ($globalDebug) { |
|
2964 | + echo "Add to DB..."; |
|
2965 | + } |
|
2465 | 2966 | $error = update_db::airlines_fam(); |
2466 | 2967 | update_db::insert_airlines_version($airlines_md5); |
2467 | - } else $error = "File ".$tmp_dir.'airlines.tsv.gz'." md5 failed. Download failed."; |
|
2468 | - } else $error = "File ".$tmp_dir.'airlines.tsv.gz'." doesn't exist. Download failed."; |
|
2469 | - } elseif ($globalDebug) echo "No update."; |
|
2470 | - } else $error = "File ".$tmp_dir.'airlines.tsv.gz.md5'." doesn't exist. Download failed."; |
|
2968 | + } else { |
|
2969 | + $error = "File ".$tmp_dir.'airlines.tsv.gz'." md5 failed. Download failed."; |
|
2970 | + } |
|
2971 | + } else { |
|
2972 | + $error = "File ".$tmp_dir.'airlines.tsv.gz'." doesn't exist. Download failed."; |
|
2973 | + } |
|
2974 | + } elseif ($globalDebug) { |
|
2975 | + echo "No update."; |
|
2976 | + } |
|
2977 | + } else { |
|
2978 | + $error = "File ".$tmp_dir.'airlines.tsv.gz.md5'." doesn't exist. Download failed."; |
|
2979 | + } |
|
2471 | 2980 | if ($error != '') { |
2472 | 2981 | return $error; |
2473 | 2982 | } else { |
2474 | - if ($globalDebug) echo "Done\n"; |
|
2983 | + if ($globalDebug) { |
|
2984 | + echo "Done\n"; |
|
2985 | + } |
|
2475 | 2986 | } |
2476 | 2987 | return ''; |
2477 | 2988 | } |
2478 | 2989 | |
2479 | 2990 | public static function update_owner_fam() { |
2480 | 2991 | global $tmp_dir, $globalDebug, $globalOwner; |
2481 | - if ($globalDebug) echo "owner from FlightAirMap website : Download..."; |
|
2992 | + if ($globalDebug) { |
|
2993 | + echo "owner from FlightAirMap website : Download..."; |
|
2994 | + } |
|
2482 | 2995 | $error = ''; |
2483 | 2996 | if ($globalOwner === TRUE) { |
2484 | 2997 | update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz'); |
@@ -2491,35 +3004,57 @@ discard block |
||
2491 | 3004 | $owners_md5_file = explode(' ',file_get_contents($tmp_dir.'owners.tsv.gz.md5')); |
2492 | 3005 | $owners_md5 = $owners_md5_file[0]; |
2493 | 3006 | if (md5_file($tmp_dir.'owners.tsv.gz') == $owners_md5) { |
2494 | - if ($globalDebug) echo "Gunzip..."; |
|
3007 | + if ($globalDebug) { |
|
3008 | + echo "Gunzip..."; |
|
3009 | + } |
|
2495 | 3010 | update_db::gunzip($tmp_dir.'owners.tsv.gz'); |
2496 | - if ($globalDebug) echo "Add to DB..."; |
|
3011 | + if ($globalDebug) { |
|
3012 | + echo "Add to DB..."; |
|
3013 | + } |
|
2497 | 3014 | $error = update_db::owner_fam(); |
2498 | - } else $error = "File ".$tmp_dir.'owners.tsv.gz'." md5 failed. Download failed."; |
|
2499 | - } else $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed."; |
|
3015 | + } else { |
|
3016 | + $error = "File ".$tmp_dir.'owners.tsv.gz'." md5 failed. Download failed."; |
|
3017 | + } |
|
3018 | + } else { |
|
3019 | + $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed."; |
|
3020 | + } |
|
2500 | 3021 | if ($error != '') { |
2501 | 3022 | return $error; |
2502 | - } elseif ($globalDebug) echo "Done\n"; |
|
3023 | + } elseif ($globalDebug) { |
|
3024 | + echo "Done\n"; |
|
3025 | + } |
|
2503 | 3026 | return ''; |
2504 | 3027 | } |
2505 | 3028 | public static function update_routes_fam() { |
2506 | 3029 | global $tmp_dir, $globalDebug; |
2507 | - if ($globalDebug) echo "Routes from FlightAirMap website : Download..."; |
|
3030 | + if ($globalDebug) { |
|
3031 | + echo "Routes from FlightAirMap website : Download..."; |
|
3032 | + } |
|
2508 | 3033 | update_db::download('http://data.flightairmap.com/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz'); |
2509 | 3034 | update_db::download('http://data.flightairmap.com/data/routes.tsv.gz.md5',$tmp_dir.'routes.tsv.gz.md5'); |
2510 | 3035 | if (file_exists($tmp_dir.'routes.tsv.gz') && file_exists($tmp_dir.'routes.tsv.gz.md5')) { |
2511 | 3036 | $routes_md5_file = explode(' ',file_get_contents($tmp_dir.'routes.tsv.gz.md5')); |
2512 | 3037 | $routes_md5 = $routes_md5_file[0]; |
2513 | 3038 | if (md5_file($tmp_dir.'routes.tsv.gz') == $routes_md5) { |
2514 | - if ($globalDebug) echo "Gunzip..."; |
|
3039 | + if ($globalDebug) { |
|
3040 | + echo "Gunzip..."; |
|
3041 | + } |
|
2515 | 3042 | update_db::gunzip($tmp_dir.'routes.tsv.gz'); |
2516 | - if ($globalDebug) echo "Add to DB..."; |
|
3043 | + if ($globalDebug) { |
|
3044 | + echo "Add to DB..."; |
|
3045 | + } |
|
2517 | 3046 | $error = update_db::routes_fam(); |
2518 | - } else $error = "File ".$tmp_dir.'routes.tsv.gz'." md5 failed. Download failed."; |
|
2519 | - } else $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed."; |
|
3047 | + } else { |
|
3048 | + $error = "File ".$tmp_dir.'routes.tsv.gz'." md5 failed. Download failed."; |
|
3049 | + } |
|
3050 | + } else { |
|
3051 | + $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed."; |
|
3052 | + } |
|
2520 | 3053 | if ($error != '') { |
2521 | 3054 | return $error; |
2522 | - } elseif ($globalDebug) echo "Done\n"; |
|
3055 | + } elseif ($globalDebug) { |
|
3056 | + echo "Done\n"; |
|
3057 | + } |
|
2523 | 3058 | return ''; |
2524 | 3059 | } |
2525 | 3060 | public static function update_marine_identity_fam() { |
@@ -2529,21 +3064,33 @@ discard block |
||
2529 | 3064 | $marine_identity_md5_file = explode(' ',file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5')); |
2530 | 3065 | $marine_identity_md5 = $marine_identity_md5_file[0]; |
2531 | 3066 | if (!update_db::check_marine_identity_version($marine_identity_md5)) { |
2532 | - if ($globalDebug) echo "Marine identity from FlightAirMap website : Download..."; |
|
3067 | + if ($globalDebug) { |
|
3068 | + echo "Marine identity from FlightAirMap website : Download..."; |
|
3069 | + } |
|
2533 | 3070 | update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz',$tmp_dir.'marine_identity.tsv.gz'); |
2534 | 3071 | if (file_exists($tmp_dir.'marine_identity.tsv.gz')) { |
2535 | 3072 | if (md5_file($tmp_dir.'marine_identity.tsv.gz') == $marine_identity_md5) { |
2536 | - if ($globalDebug) echo "Gunzip..."; |
|
3073 | + if ($globalDebug) { |
|
3074 | + echo "Gunzip..."; |
|
3075 | + } |
|
2537 | 3076 | update_db::gunzip($tmp_dir.'marine_identity.tsv.gz'); |
2538 | - if ($globalDebug) echo "Add to DB..."; |
|
3077 | + if ($globalDebug) { |
|
3078 | + echo "Add to DB..."; |
|
3079 | + } |
|
2539 | 3080 | $error = update_db::marine_identity_fam(); |
2540 | - } else $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." md5 failed. Download failed."; |
|
2541 | - } else $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed."; |
|
3081 | + } else { |
|
3082 | + $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." md5 failed. Download failed."; |
|
3083 | + } |
|
3084 | + } else { |
|
3085 | + $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed."; |
|
3086 | + } |
|
2542 | 3087 | if ($error != '') { |
2543 | 3088 | return $error; |
2544 | 3089 | } else { |
2545 | 3090 | update_db::insert_marine_identity_version($marine_identity_md5); |
2546 | - if ($globalDebug) echo "Done\n"; |
|
3091 | + if ($globalDebug) { |
|
3092 | + echo "Done\n"; |
|
3093 | + } |
|
2547 | 3094 | } |
2548 | 3095 | } |
2549 | 3096 | } |
@@ -2557,21 +3104,33 @@ discard block |
||
2557 | 3104 | $satellite_md5_file = explode(' ',file_get_contents($tmp_dir.'satellite.tsv.gz.md5')); |
2558 | 3105 | $satellite_md5 = $satellite_md5_file[0]; |
2559 | 3106 | if (!update_db::check_satellite_version($satellite_md5)) { |
2560 | - if ($globalDebug) echo "Satellite from FlightAirMap website : Download..."; |
|
3107 | + if ($globalDebug) { |
|
3108 | + echo "Satellite from FlightAirMap website : Download..."; |
|
3109 | + } |
|
2561 | 3110 | update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz',$tmp_dir.'satellite.tsv.gz'); |
2562 | 3111 | if (file_exists($tmp_dir.'satellite.tsv.gz')) { |
2563 | 3112 | if (md5_file($tmp_dir.'satellite.tsv.gz') == $satellite_md5) { |
2564 | - if ($globalDebug) echo "Gunzip..."; |
|
3113 | + if ($globalDebug) { |
|
3114 | + echo "Gunzip..."; |
|
3115 | + } |
|
2565 | 3116 | update_db::gunzip($tmp_dir.'satellite.tsv.gz'); |
2566 | - if ($globalDebug) echo "Add to DB..."; |
|
3117 | + if ($globalDebug) { |
|
3118 | + echo "Add to DB..."; |
|
3119 | + } |
|
2567 | 3120 | $error = update_db::satellite_fam(); |
2568 | - } else $error = "File ".$tmp_dir.'satellite.tsv.gz'." md5 failed. Download failed."; |
|
2569 | - } else $error = "File ".$tmp_dir.'satellite.tsv.gz'." doesn't exist. Download failed."; |
|
3121 | + } else { |
|
3122 | + $error = "File ".$tmp_dir.'satellite.tsv.gz'." md5 failed. Download failed."; |
|
3123 | + } |
|
3124 | + } else { |
|
3125 | + $error = "File ".$tmp_dir.'satellite.tsv.gz'." doesn't exist. Download failed."; |
|
3126 | + } |
|
2570 | 3127 | if ($error != '') { |
2571 | 3128 | return $error; |
2572 | 3129 | } else { |
2573 | 3130 | update_db::insert_satellite_version($satellite_md5); |
2574 | - if ($globalDebug) echo "Done\n"; |
|
3131 | + if ($globalDebug) { |
|
3132 | + echo "Done\n"; |
|
3133 | + } |
|
2575 | 3134 | } |
2576 | 3135 | } |
2577 | 3136 | } |
@@ -2579,17 +3138,25 @@ discard block |
||
2579 | 3138 | } |
2580 | 3139 | public static function update_banned_fam() { |
2581 | 3140 | global $tmp_dir, $globalDebug; |
2582 | - if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download..."; |
|
3141 | + if ($globalDebug) { |
|
3142 | + echo "Banned airlines in Europe from FlightAirMap website : Download..."; |
|
3143 | + } |
|
2583 | 3144 | update_db::download('http://data.flightairmap.com/data/ban-eu.csv',$tmp_dir.'ban_eu.csv'); |
2584 | 3145 | if (file_exists($tmp_dir.'ban_eu.csv')) { |
2585 | 3146 | //if ($globalDebug) echo "Gunzip..."; |
2586 | 3147 | //update_db::gunzip($tmp_dir.'ban_ue.csv'); |
2587 | - if ($globalDebug) echo "Add to DB..."; |
|
3148 | + if ($globalDebug) { |
|
3149 | + echo "Add to DB..."; |
|
3150 | + } |
|
2588 | 3151 | $error = update_db::banned_fam(); |
2589 | - } else $error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed."; |
|
3152 | + } else { |
|
3153 | + $error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed."; |
|
3154 | + } |
|
2590 | 3155 | if ($error != '') { |
2591 | 3156 | return $error; |
2592 | - } elseif ($globalDebug) echo "Done\n"; |
|
3157 | + } elseif ($globalDebug) { |
|
3158 | + echo "Done\n"; |
|
3159 | + } |
|
2593 | 3160 | return ''; |
2594 | 3161 | } |
2595 | 3162 | |
@@ -2597,7 +3164,9 @@ discard block |
||
2597 | 3164 | global $tmp_dir, $globalDebug, $globalDBdriver; |
2598 | 3165 | include_once('class.create_db.php'); |
2599 | 3166 | $error = ''; |
2600 | - if ($globalDebug) echo "Airspace from FlightAirMap website : Download..."; |
|
3167 | + if ($globalDebug) { |
|
3168 | + echo "Airspace from FlightAirMap website : Download..."; |
|
3169 | + } |
|
2601 | 3170 | if ($globalDBdriver == 'mysql') { |
2602 | 3171 | update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); |
2603 | 3172 | } else { |
@@ -2614,9 +3183,13 @@ discard block |
||
2614 | 3183 | } |
2615 | 3184 | if (file_exists($tmp_dir.'airspace.sql.gz')) { |
2616 | 3185 | if (md5_file($tmp_dir.'airspace.sql.gz') == $airspace_md5) { |
2617 | - if ($globalDebug) echo "Gunzip..."; |
|
3186 | + if ($globalDebug) { |
|
3187 | + echo "Gunzip..."; |
|
3188 | + } |
|
2618 | 3189 | update_db::gunzip($tmp_dir.'airspace.sql.gz'); |
2619 | - if ($globalDebug) echo "Add to DB..."; |
|
3190 | + if ($globalDebug) { |
|
3191 | + echo "Add to DB..."; |
|
3192 | + } |
|
2620 | 3193 | $Connection = new Connection(); |
2621 | 3194 | if ($Connection->tableExists('airspace')) { |
2622 | 3195 | $query = 'DROP TABLE airspace'; |
@@ -2629,20 +3202,30 @@ discard block |
||
2629 | 3202 | } |
2630 | 3203 | $error = create_db::import_file($tmp_dir.'airspace.sql'); |
2631 | 3204 | update_db::insert_airspace_version($airspace_md5); |
2632 | - } else $error = "File ".$tmp_dir.'airspace.sql.gz'." md5 failed. Download failed."; |
|
2633 | - } else $error = "File ".$tmp_dir.'airspace.sql.gz'." doesn't exist. Download failed."; |
|
3205 | + } else { |
|
3206 | + $error = "File ".$tmp_dir.'airspace.sql.gz'." md5 failed. Download failed."; |
|
3207 | + } |
|
3208 | + } else { |
|
3209 | + $error = "File ".$tmp_dir.'airspace.sql.gz'." doesn't exist. Download failed."; |
|
3210 | + } |
|
2634 | 3211 | } |
2635 | - } else $error = "File ".$tmp_dir.'airspace.sql.gz.md5'." doesn't exist. Download failed."; |
|
3212 | + } else { |
|
3213 | + $error = "File ".$tmp_dir.'airspace.sql.gz.md5'." doesn't exist. Download failed."; |
|
3214 | + } |
|
2636 | 3215 | if ($error != '') { |
2637 | 3216 | return $error; |
2638 | - } elseif ($globalDebug) echo "Done\n"; |
|
3217 | + } elseif ($globalDebug) { |
|
3218 | + echo "Done\n"; |
|
3219 | + } |
|
2639 | 3220 | return ''; |
2640 | 3221 | } |
2641 | 3222 | |
2642 | 3223 | public static function update_geoid_fam() { |
2643 | 3224 | global $tmp_dir, $globalDebug, $globalGeoidSource; |
2644 | 3225 | $error = ''; |
2645 | - if ($globalDebug) echo "Geoid from FlightAirMap website : Download..."; |
|
3226 | + if ($globalDebug) { |
|
3227 | + echo "Geoid from FlightAirMap website : Download..."; |
|
3228 | + } |
|
2646 | 3229 | update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5',$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'); |
2647 | 3230 | if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')) { |
2648 | 3231 | $geoid_md5_file = explode(' ',file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')); |
@@ -2651,76 +3234,120 @@ discard block |
||
2651 | 3234 | update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz',$tmp_dir.$globalGeoidSource.'.pgm.gz'); |
2652 | 3235 | if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz')) { |
2653 | 3236 | if (md5_file($tmp_dir.$globalGeoidSource.'.pgm.gz') == $geoid_md5) { |
2654 | - if ($globalDebug) echo "Gunzip..."; |
|
3237 | + if ($globalDebug) { |
|
3238 | + echo "Gunzip..."; |
|
3239 | + } |
|
2655 | 3240 | update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz',dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm'); |
2656 | 3241 | if (file_exists(dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm')) { |
2657 | 3242 | update_db::insert_geoid_version($geoid_md5); |
2658 | - } else $error = "File data/".$globalGeoidSource.'.pgm'." doesn't exist. Gunzip failed."; |
|
2659 | - } else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." md5 failed. Download failed."; |
|
2660 | - } else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed."; |
|
2661 | - } elseif ($globalDebug) echo 'No new version'."\n"; |
|
2662 | - } else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed."; |
|
3243 | + } else { |
|
3244 | + $error = "File data/".$globalGeoidSource.'.pgm'." doesn't exist. Gunzip failed."; |
|
3245 | + } |
|
3246 | + } else { |
|
3247 | + $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." md5 failed. Download failed."; |
|
3248 | + } |
|
3249 | + } else { |
|
3250 | + $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed."; |
|
3251 | + } |
|
3252 | + } elseif ($globalDebug) { |
|
3253 | + echo 'No new version'."\n"; |
|
3254 | + } |
|
3255 | + } else { |
|
3256 | + $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed."; |
|
3257 | + } |
|
2663 | 3258 | if ($error != '') { |
2664 | 3259 | return $error; |
2665 | - } elseif ($globalDebug) echo "Done\n"; |
|
3260 | + } elseif ($globalDebug) { |
|
3261 | + echo "Done\n"; |
|
3262 | + } |
|
2666 | 3263 | return ''; |
2667 | 3264 | } |
2668 | 3265 | |
2669 | 3266 | public static function update_tle() { |
2670 | 3267 | global $tmp_dir, $globalDebug; |
2671 | - if ($globalDebug) echo "Download TLE : Download..."; |
|
3268 | + if ($globalDebug) { |
|
3269 | + echo "Download TLE : Download..."; |
|
3270 | + } |
|
2672 | 3271 | $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', |
2673 | 3272 | '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', |
2674 | 3273 | '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'); |
2675 | 3274 | foreach ($alltle as $filename) { |
2676 | - if ($globalDebug) echo "downloading ".$filename.'...'; |
|
3275 | + if ($globalDebug) { |
|
3276 | + echo "downloading ".$filename.'...'; |
|
3277 | + } |
|
2677 | 3278 | update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename); |
2678 | 3279 | if (file_exists($tmp_dir.$filename)) { |
2679 | - if ($globalDebug) echo "Add to DB ".$filename."..."; |
|
3280 | + if ($globalDebug) { |
|
3281 | + echo "Add to DB ".$filename."..."; |
|
3282 | + } |
|
2680 | 3283 | $error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename)); |
2681 | - } else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
|
3284 | + } else { |
|
3285 | + $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
|
3286 | + } |
|
2682 | 3287 | if ($error != '') { |
2683 | 3288 | echo $error."\n"; |
2684 | - } elseif ($globalDebug) echo "Done\n"; |
|
3289 | + } elseif ($globalDebug) { |
|
3290 | + echo "Done\n"; |
|
3291 | + } |
|
2685 | 3292 | } |
2686 | 3293 | return ''; |
2687 | 3294 | } |
2688 | 3295 | |
2689 | 3296 | public static function update_ucsdb() { |
2690 | 3297 | global $tmp_dir, $globalDebug; |
2691 | - if ($globalDebug) echo "Download UCS DB : Download..."; |
|
3298 | + if ($globalDebug) { |
|
3299 | + echo "Download UCS DB : Download..."; |
|
3300 | + } |
|
2692 | 3301 | update_db::download('https://s3.amazonaws.com/ucs-documents/nuclear-weapons/sat-database/4-11-17-update/UCS_Satellite_Database_officialname_1-1-17.txt',$tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt'); |
2693 | 3302 | if (file_exists($tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt')) { |
2694 | - if ($globalDebug) echo "Add to DB..."; |
|
3303 | + if ($globalDebug) { |
|
3304 | + echo "Add to DB..."; |
|
3305 | + } |
|
2695 | 3306 | $error = update_db::satellite_ucsdb($tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt'); |
2696 | - } else $error = "File ".$tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt'." doesn't exist. Download failed."; |
|
3307 | + } else { |
|
3308 | + $error = "File ".$tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt'." doesn't exist. Download failed."; |
|
3309 | + } |
|
2697 | 3310 | if ($error != '') { |
2698 | 3311 | echo $error."\n"; |
2699 | - } elseif ($globalDebug) echo "Done\n"; |
|
3312 | + } elseif ($globalDebug) { |
|
3313 | + echo "Done\n"; |
|
3314 | + } |
|
2700 | 3315 | return ''; |
2701 | 3316 | } |
2702 | 3317 | |
2703 | 3318 | public static function update_celestrak() { |
2704 | 3319 | global $tmp_dir, $globalDebug; |
2705 | - if ($globalDebug) echo "Download Celestrak DB : Download..."; |
|
3320 | + if ($globalDebug) { |
|
3321 | + echo "Download Celestrak DB : Download..."; |
|
3322 | + } |
|
2706 | 3323 | update_db::download('http://celestrak.com/pub/satcat.txt',$tmp_dir.'satcat.txt'); |
2707 | 3324 | if (file_exists($tmp_dir.'satcat.txt')) { |
2708 | - if ($globalDebug) echo "Add to DB..."; |
|
3325 | + if ($globalDebug) { |
|
3326 | + echo "Add to DB..."; |
|
3327 | + } |
|
2709 | 3328 | $error = update_db::satellite_celestrak($tmp_dir.'satcat.txt'); |
2710 | - } else $error = "File ".$tmp_dir.'satcat.txt'." doesn't exist. Download failed."; |
|
3329 | + } else { |
|
3330 | + $error = "File ".$tmp_dir.'satcat.txt'." doesn't exist. Download failed."; |
|
3331 | + } |
|
2711 | 3332 | if ($error != '') { |
2712 | 3333 | echo $error."\n"; |
2713 | - } elseif ($globalDebug) echo "Done\n"; |
|
3334 | + } elseif ($globalDebug) { |
|
3335 | + echo "Done\n"; |
|
3336 | + } |
|
2714 | 3337 | return ''; |
2715 | 3338 | } |
2716 | 3339 | |
2717 | 3340 | public static function update_models() { |
2718 | 3341 | global $tmp_dir, $globalDebug; |
2719 | 3342 | $error = ''; |
2720 | - if ($globalDebug) echo "Models from FlightAirMap website : Download..."; |
|
3343 | + if ($globalDebug) { |
|
3344 | + echo "Models from FlightAirMap website : Download..."; |
|
3345 | + } |
|
2721 | 3346 | update_db::download('http://data.flightairmap.com/data/models/models.md5sum',$tmp_dir.'models.md5sum'); |
2722 | 3347 | if (file_exists($tmp_dir.'models.md5sum')) { |
2723 | - if ($globalDebug) echo "Check files...\n"; |
|
3348 | + if ($globalDebug) { |
|
3349 | + echo "Check files...\n"; |
|
3350 | + } |
|
2724 | 3351 | $newmodelsdb = array(); |
2725 | 3352 | if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) { |
2726 | 3353 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2739,19 +3366,29 @@ discard block |
||
2739 | 3366 | } |
2740 | 3367 | $diff = array_diff($newmodelsdb,$modelsdb); |
2741 | 3368 | foreach ($diff as $key => $value) { |
2742 | - if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n"; |
|
3369 | + if ($globalDebug) { |
|
3370 | + echo 'Downloading model '.$key.' ...'."\n"; |
|
3371 | + } |
|
2743 | 3372 | update_db::download('http://data.flightairmap.com/data/models/'.$key,dirname(__FILE__).'/../models/'.$key); |
2744 | 3373 | |
2745 | 3374 | } |
2746 | 3375 | update_db::download('http://data.flightairmap.com/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum'); |
2747 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
3376 | + } else { |
|
3377 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
3378 | + } |
|
2748 | 3379 | if ($error != '') { |
2749 | 3380 | return $error; |
2750 | - } elseif ($globalDebug) echo "Done\n"; |
|
2751 | - if ($globalDebug) echo "glTF 2.0 Models from FlightAirMap website : Download..."; |
|
3381 | + } elseif ($globalDebug) { |
|
3382 | + echo "Done\n"; |
|
3383 | + } |
|
3384 | + if ($globalDebug) { |
|
3385 | + echo "glTF 2.0 Models from FlightAirMap website : Download..."; |
|
3386 | + } |
|
2752 | 3387 | update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum',$tmp_dir.'modelsgltf2.md5sum'); |
2753 | 3388 | if (file_exists($tmp_dir.'modelsgltf2.md5sum')) { |
2754 | - if ($globalDebug) echo "Check files...\n"; |
|
3389 | + if ($globalDebug) { |
|
3390 | + echo "Check files...\n"; |
|
3391 | + } |
|
2755 | 3392 | $newmodelsdb = array(); |
2756 | 3393 | if (($handle = fopen($tmp_dir.'modelsgltf2.md5sum','r')) !== FALSE) { |
2757 | 3394 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2770,25 +3407,35 @@ discard block |
||
2770 | 3407 | } |
2771 | 3408 | $diff = array_diff($newmodelsdb,$modelsdb); |
2772 | 3409 | foreach ($diff as $key => $value) { |
2773 | - if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n"; |
|
3410 | + if ($globalDebug) { |
|
3411 | + echo 'Downloading model '.$key.' ...'."\n"; |
|
3412 | + } |
|
2774 | 3413 | update_db::download('http://data.flightairmap.com/data/models/gltf2/'.$key,dirname(__FILE__).'/../models/gltf2/'.$key); |
2775 | 3414 | |
2776 | 3415 | } |
2777 | 3416 | update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum',dirname(__FILE__).'/../models/gltf2/models.md5sum'); |
2778 | - } else $error = "File ".$tmp_dir.'modelsgltf2.md5sum'." doesn't exist. Download failed."; |
|
3417 | + } else { |
|
3418 | + $error = "File ".$tmp_dir.'modelsgltf2.md5sum'." doesn't exist. Download failed."; |
|
3419 | + } |
|
2779 | 3420 | if ($error != '') { |
2780 | 3421 | return $error; |
2781 | - } elseif ($globalDebug) echo "Done\n"; |
|
3422 | + } elseif ($globalDebug) { |
|
3423 | + echo "Done\n"; |
|
3424 | + } |
|
2782 | 3425 | return ''; |
2783 | 3426 | } |
2784 | 3427 | |
2785 | 3428 | public static function update_liveries() { |
2786 | 3429 | global $tmp_dir, $globalDebug; |
2787 | 3430 | $error = ''; |
2788 | - if ($globalDebug) echo "Liveries from FlightAirMap website : Download..."; |
|
3431 | + if ($globalDebug) { |
|
3432 | + echo "Liveries from FlightAirMap website : Download..."; |
|
3433 | + } |
|
2789 | 3434 | update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum',$tmp_dir.'liveries.md5sum'); |
2790 | 3435 | if (file_exists($tmp_dir.'liveries.md5sum')) { |
2791 | - if ($globalDebug) echo "Check files...\n"; |
|
3436 | + if ($globalDebug) { |
|
3437 | + echo "Check files...\n"; |
|
3438 | + } |
|
2792 | 3439 | $newmodelsdb = array(); |
2793 | 3440 | if (($handle = fopen($tmp_dir.'liveries.md5sum','r')) !== FALSE) { |
2794 | 3441 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2807,25 +3454,35 @@ discard block |
||
2807 | 3454 | } |
2808 | 3455 | $diff = array_diff($newmodelsdb,$modelsdb); |
2809 | 3456 | foreach ($diff as $key => $value) { |
2810 | - if ($globalDebug) echo 'Downloading liveries '.$key.' ...'."\n"; |
|
3457 | + if ($globalDebug) { |
|
3458 | + echo 'Downloading liveries '.$key.' ...'."\n"; |
|
3459 | + } |
|
2811 | 3460 | update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/'.$key,dirname(__FILE__).'/../models/gltf2/liveries/'.$key); |
2812 | 3461 | |
2813 | 3462 | } |
2814 | 3463 | update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum',dirname(__FILE__).'/../models/gltf2/liveries/liveries.md5sum'); |
2815 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
3464 | + } else { |
|
3465 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
3466 | + } |
|
2816 | 3467 | if ($error != '') { |
2817 | 3468 | return $error; |
2818 | - } elseif ($globalDebug) echo "Done\n"; |
|
3469 | + } elseif ($globalDebug) { |
|
3470 | + echo "Done\n"; |
|
3471 | + } |
|
2819 | 3472 | return ''; |
2820 | 3473 | } |
2821 | 3474 | |
2822 | 3475 | public static function update_space_models() { |
2823 | 3476 | global $tmp_dir, $globalDebug; |
2824 | 3477 | $error = ''; |
2825 | - if ($globalDebug) echo "Space models from FlightAirMap website : Download..."; |
|
3478 | + if ($globalDebug) { |
|
3479 | + echo "Space models from FlightAirMap website : Download..."; |
|
3480 | + } |
|
2826 | 3481 | update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum'); |
2827 | 3482 | if (file_exists($tmp_dir.'space_models.md5sum')) { |
2828 | - if ($globalDebug) echo "Check files...\n"; |
|
3483 | + if ($globalDebug) { |
|
3484 | + echo "Check files...\n"; |
|
3485 | + } |
|
2829 | 3486 | $newmodelsdb = array(); |
2830 | 3487 | if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) { |
2831 | 3488 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2844,25 +3501,35 @@ discard block |
||
2844 | 3501 | } |
2845 | 3502 | $diff = array_diff($newmodelsdb,$modelsdb); |
2846 | 3503 | foreach ($diff as $key => $value) { |
2847 | - if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n"; |
|
3504 | + if ($globalDebug) { |
|
3505 | + echo 'Downloading space model '.$key.' ...'."\n"; |
|
3506 | + } |
|
2848 | 3507 | update_db::download('http://data.flightairmap.com/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key); |
2849 | 3508 | |
2850 | 3509 | } |
2851 | 3510 | update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum'); |
2852 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
3511 | + } else { |
|
3512 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
3513 | + } |
|
2853 | 3514 | if ($error != '') { |
2854 | 3515 | return $error; |
2855 | - } elseif ($globalDebug) echo "Done\n"; |
|
3516 | + } elseif ($globalDebug) { |
|
3517 | + echo "Done\n"; |
|
3518 | + } |
|
2856 | 3519 | return ''; |
2857 | 3520 | } |
2858 | 3521 | |
2859 | 3522 | public static function update_vehicules_models() { |
2860 | 3523 | global $tmp_dir, $globalDebug; |
2861 | 3524 | $error = ''; |
2862 | - if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download..."; |
|
3525 | + if ($globalDebug) { |
|
3526 | + echo "Vehicules models from FlightAirMap website : Download..."; |
|
3527 | + } |
|
2863 | 3528 | update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum'); |
2864 | 3529 | if (file_exists($tmp_dir.'vehicules_models.md5sum')) { |
2865 | - if ($globalDebug) echo "Check files...\n"; |
|
3530 | + if ($globalDebug) { |
|
3531 | + echo "Check files...\n"; |
|
3532 | + } |
|
2866 | 3533 | $newmodelsdb = array(); |
2867 | 3534 | if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) { |
2868 | 3535 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2881,15 +3548,21 @@ discard block |
||
2881 | 3548 | } |
2882 | 3549 | $diff = array_diff($newmodelsdb,$modelsdb); |
2883 | 3550 | foreach ($diff as $key => $value) { |
2884 | - if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n"; |
|
3551 | + if ($globalDebug) { |
|
3552 | + echo 'Downloading vehicules model '.$key.' ...'."\n"; |
|
3553 | + } |
|
2885 | 3554 | update_db::download('http://data.flightairmap.com/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key); |
2886 | 3555 | |
2887 | 3556 | } |
2888 | 3557 | update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum'); |
2889 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
3558 | + } else { |
|
3559 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
3560 | + } |
|
2890 | 3561 | if ($error != '') { |
2891 | 3562 | return $error; |
2892 | - } elseif ($globalDebug) echo "Done\n"; |
|
3563 | + } elseif ($globalDebug) { |
|
3564 | + echo "Done\n"; |
|
3565 | + } |
|
2893 | 3566 | return ''; |
2894 | 3567 | } |
2895 | 3568 | |
@@ -2962,7 +3635,9 @@ discard block |
||
2962 | 3635 | } |
2963 | 3636 | |
2964 | 3637 | $error = ''; |
2965 | - if ($globalDebug) echo "Notam : Download..."; |
|
3638 | + if ($globalDebug) { |
|
3639 | + echo "Notam : Download..."; |
|
3640 | + } |
|
2966 | 3641 | update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss'); |
2967 | 3642 | if (file_exists($tmp_dir.'notam.rss')) { |
2968 | 3643 | $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true); |
@@ -2977,14 +3652,30 @@ discard block |
||
2977 | 3652 | $data['fir'] = $q[0]; |
2978 | 3653 | $data['code'] = $q[1]; |
2979 | 3654 | $ifrvfr = $q[2]; |
2980 | - if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR'; |
|
2981 | - if ($ifrvfr == 'I') $data['rules'] = 'IFR'; |
|
2982 | - if ($ifrvfr == 'V') $data['rules'] = 'VFR'; |
|
2983 | - if ($q[4] == 'A') $data['scope'] = 'Airport warning'; |
|
2984 | - if ($q[4] == 'E') $data['scope'] = 'Enroute warning'; |
|
2985 | - if ($q[4] == 'W') $data['scope'] = 'Navigation warning'; |
|
2986 | - if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning'; |
|
2987 | - if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning'; |
|
3655 | + if ($ifrvfr == 'IV') { |
|
3656 | + $data['rules'] = 'IFR/VFR'; |
|
3657 | + } |
|
3658 | + if ($ifrvfr == 'I') { |
|
3659 | + $data['rules'] = 'IFR'; |
|
3660 | + } |
|
3661 | + if ($ifrvfr == 'V') { |
|
3662 | + $data['rules'] = 'VFR'; |
|
3663 | + } |
|
3664 | + if ($q[4] == 'A') { |
|
3665 | + $data['scope'] = 'Airport warning'; |
|
3666 | + } |
|
3667 | + if ($q[4] == 'E') { |
|
3668 | + $data['scope'] = 'Enroute warning'; |
|
3669 | + } |
|
3670 | + if ($q[4] == 'W') { |
|
3671 | + $data['scope'] = 'Navigation warning'; |
|
3672 | + } |
|
3673 | + if ($q[4] == 'AE') { |
|
3674 | + $data['scope'] = 'Airport/Enroute warning'; |
|
3675 | + } |
|
3676 | + if ($q[4] == 'AW') { |
|
3677 | + $data['scope'] = 'Airport/Navigation warning'; |
|
3678 | + } |
|
2988 | 3679 | //$data['scope'] = $q[4]; |
2989 | 3680 | $data['lower_limit'] = $q[5]; |
2990 | 3681 | $data['upper_limit'] = $q[6]; |
@@ -2992,8 +3683,12 @@ discard block |
||
2992 | 3683 | sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius); |
2993 | 3684 | $latitude = $Common->convertDec($las,'latitude'); |
2994 | 3685 | $longitude = $Common->convertDec($lns,'longitude'); |
2995 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
2996 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
3686 | + if ($lac == 'S') { |
|
3687 | + $latitude = '-'.$latitude; |
|
3688 | + } |
|
3689 | + if ($lnc == 'W') { |
|
3690 | + $longitude = '-'.$longitude; |
|
3691 | + } |
|
2997 | 3692 | $data['center_latitude'] = $latitude; |
2998 | 3693 | $data['center_longitude'] = $longitude; |
2999 | 3694 | $data['radius'] = intval($radius); |
@@ -3023,10 +3718,14 @@ discard block |
||
3023 | 3718 | $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']); |
3024 | 3719 | unset($data); |
3025 | 3720 | } |
3026 | - } else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
|
3721 | + } else { |
|
3722 | + $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
|
3723 | + } |
|
3027 | 3724 | if ($error != '') { |
3028 | 3725 | return $error; |
3029 | - } elseif ($globalDebug) echo "Done\n"; |
|
3726 | + } elseif ($globalDebug) { |
|
3727 | + echo "Done\n"; |
|
3728 | + } |
|
3030 | 3729 | return ''; |
3031 | 3730 | } |
3032 | 3731 | |
@@ -3051,7 +3750,9 @@ discard block |
||
3051 | 3750 | $airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json'); |
3052 | 3751 | $airspace_json = json_decode($airspace_lst,true); |
3053 | 3752 | foreach ($airspace_json['records'] as $airspace) { |
3054 | - if ($globalDebug) echo $airspace['name']."...\n"; |
|
3753 | + if ($globalDebug) { |
|
3754 | + echo $airspace['name']."...\n"; |
|
3755 | + } |
|
3055 | 3756 | update_db::download($airspace['uri'],$tmp_dir.$airspace['name']); |
3056 | 3757 | if (file_exists($tmp_dir.$airspace['name'])) { |
3057 | 3758 | file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name']))); |
@@ -3095,8 +3796,11 @@ discard block |
||
3095 | 3796 | return "error : ".$e->getMessage(); |
3096 | 3797 | } |
3097 | 3798 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3098 | - if ($row['nb'] > 0) return false; |
|
3099 | - else return true; |
|
3799 | + if ($row['nb'] > 0) { |
|
3800 | + return false; |
|
3801 | + } else { |
|
3802 | + return true; |
|
3803 | + } |
|
3100 | 3804 | } |
3101 | 3805 | |
3102 | 3806 | public static function insert_last_update() { |
@@ -3121,8 +3825,11 @@ discard block |
||
3121 | 3825 | return "error : ".$e->getMessage(); |
3122 | 3826 | } |
3123 | 3827 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3124 | - if ($row['nb'] > 0) return true; |
|
3125 | - else return false; |
|
3828 | + if ($row['nb'] > 0) { |
|
3829 | + return true; |
|
3830 | + } else { |
|
3831 | + return false; |
|
3832 | + } |
|
3126 | 3833 | } |
3127 | 3834 | |
3128 | 3835 | public static function check_geoid_version($version) { |
@@ -3135,8 +3842,11 @@ discard block |
||
3135 | 3842 | return "error : ".$e->getMessage(); |
3136 | 3843 | } |
3137 | 3844 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3138 | - if ($row['nb'] > 0) return true; |
|
3139 | - else return false; |
|
3845 | + if ($row['nb'] > 0) { |
|
3846 | + return true; |
|
3847 | + } else { |
|
3848 | + return false; |
|
3849 | + } |
|
3140 | 3850 | } |
3141 | 3851 | |
3142 | 3852 | public static function check_marine_identity_version($version) { |
@@ -3149,8 +3859,11 @@ discard block |
||
3149 | 3859 | return "error : ".$e->getMessage(); |
3150 | 3860 | } |
3151 | 3861 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3152 | - if ($row['nb'] > 0) return true; |
|
3153 | - else return false; |
|
3862 | + if ($row['nb'] > 0) { |
|
3863 | + return true; |
|
3864 | + } else { |
|
3865 | + return false; |
|
3866 | + } |
|
3154 | 3867 | } |
3155 | 3868 | |
3156 | 3869 | public static function check_satellite_version($version) { |
@@ -3163,8 +3876,11 @@ discard block |
||
3163 | 3876 | return "error : ".$e->getMessage(); |
3164 | 3877 | } |
3165 | 3878 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3166 | - if ($row['nb'] > 0) return true; |
|
3167 | - else return false; |
|
3879 | + if ($row['nb'] > 0) { |
|
3880 | + return true; |
|
3881 | + } else { |
|
3882 | + return false; |
|
3883 | + } |
|
3168 | 3884 | } |
3169 | 3885 | |
3170 | 3886 | public static function check_airlines_version($version) { |
@@ -3177,8 +3893,11 @@ discard block |
||
3177 | 3893 | return "error : ".$e->getMessage(); |
3178 | 3894 | } |
3179 | 3895 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3180 | - if ($row['nb'] > 0) return true; |
|
3181 | - else return false; |
|
3896 | + if ($row['nb'] > 0) { |
|
3897 | + return true; |
|
3898 | + } else { |
|
3899 | + return false; |
|
3900 | + } |
|
3182 | 3901 | } |
3183 | 3902 | |
3184 | 3903 | public static function check_notam_version($version) { |
@@ -3191,8 +3910,11 @@ discard block |
||
3191 | 3910 | return "error : ".$e->getMessage(); |
3192 | 3911 | } |
3193 | 3912 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3194 | - if ($row['nb'] > 0) return true; |
|
3195 | - else return false; |
|
3913 | + if ($row['nb'] > 0) { |
|
3914 | + return true; |
|
3915 | + } else { |
|
3916 | + return false; |
|
3917 | + } |
|
3196 | 3918 | } |
3197 | 3919 | |
3198 | 3920 | public static function insert_airlines_version($version) { |
@@ -3282,8 +4004,11 @@ discard block |
||
3282 | 4004 | return "error : ".$e->getMessage(); |
3283 | 4005 | } |
3284 | 4006 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3285 | - if ($row['nb'] > 0) return false; |
|
3286 | - else return true; |
|
4007 | + if ($row['nb'] > 0) { |
|
4008 | + return false; |
|
4009 | + } else { |
|
4010 | + return true; |
|
4011 | + } |
|
3287 | 4012 | } |
3288 | 4013 | |
3289 | 4014 | public static function insert_last_notam_update() { |
@@ -3313,8 +4038,11 @@ discard block |
||
3313 | 4038 | return "error : ".$e->getMessage(); |
3314 | 4039 | } |
3315 | 4040 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3316 | - if ($row['nb'] > 0) return false; |
|
3317 | - else return true; |
|
4041 | + if ($row['nb'] > 0) { |
|
4042 | + return false; |
|
4043 | + } else { |
|
4044 | + return true; |
|
4045 | + } |
|
3318 | 4046 | } |
3319 | 4047 | |
3320 | 4048 | public static function insert_last_airspace_update() { |
@@ -3344,8 +4072,11 @@ discard block |
||
3344 | 4072 | return "error : ".$e->getMessage(); |
3345 | 4073 | } |
3346 | 4074 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3347 | - if ($row['nb'] > 0) return false; |
|
3348 | - else return true; |
|
4075 | + if ($row['nb'] > 0) { |
|
4076 | + return false; |
|
4077 | + } else { |
|
4078 | + return true; |
|
4079 | + } |
|
3349 | 4080 | } |
3350 | 4081 | |
3351 | 4082 | public static function insert_last_geoid_update() { |
@@ -3375,8 +4106,11 @@ discard block |
||
3375 | 4106 | return "error : ".$e->getMessage(); |
3376 | 4107 | } |
3377 | 4108 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3378 | - if ($row['nb'] > 0) return false; |
|
3379 | - else return true; |
|
4109 | + if ($row['nb'] > 0) { |
|
4110 | + return false; |
|
4111 | + } else { |
|
4112 | + return true; |
|
4113 | + } |
|
3380 | 4114 | } |
3381 | 4115 | |
3382 | 4116 | public static function insert_last_owner_update() { |
@@ -3406,8 +4140,11 @@ discard block |
||
3406 | 4140 | return "error : ".$e->getMessage(); |
3407 | 4141 | } |
3408 | 4142 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3409 | - if ($row['nb'] > 0) return false; |
|
3410 | - else return true; |
|
4143 | + if ($row['nb'] > 0) { |
|
4144 | + return false; |
|
4145 | + } else { |
|
4146 | + return true; |
|
4147 | + } |
|
3411 | 4148 | } |
3412 | 4149 | |
3413 | 4150 | public static function insert_last_fires_update() { |
@@ -3437,8 +4174,11 @@ discard block |
||
3437 | 4174 | return "error : ".$e->getMessage(); |
3438 | 4175 | } |
3439 | 4176 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3440 | - if ($row['nb'] > 0) return false; |
|
3441 | - else return true; |
|
4177 | + if ($row['nb'] > 0) { |
|
4178 | + return false; |
|
4179 | + } else { |
|
4180 | + return true; |
|
4181 | + } |
|
3442 | 4182 | } |
3443 | 4183 | |
3444 | 4184 | public static function insert_last_airlines_update() { |
@@ -3468,8 +4208,11 @@ discard block |
||
3468 | 4208 | return "error : ".$e->getMessage(); |
3469 | 4209 | } |
3470 | 4210 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3471 | - if ($row['nb'] > 0) return false; |
|
3472 | - else return true; |
|
4211 | + if ($row['nb'] > 0) { |
|
4212 | + return false; |
|
4213 | + } else { |
|
4214 | + return true; |
|
4215 | + } |
|
3473 | 4216 | } |
3474 | 4217 | |
3475 | 4218 | public static function insert_last_schedules_update() { |
@@ -3499,8 +4242,11 @@ discard block |
||
3499 | 4242 | return "error : ".$e->getMessage(); |
3500 | 4243 | } |
3501 | 4244 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3502 | - if ($row['nb'] > 0) return false; |
|
3503 | - else return true; |
|
4245 | + if ($row['nb'] > 0) { |
|
4246 | + return false; |
|
4247 | + } else { |
|
4248 | + return true; |
|
4249 | + } |
|
3504 | 4250 | } |
3505 | 4251 | |
3506 | 4252 | public static function insert_last_tle_update() { |
@@ -3530,8 +4276,11 @@ discard block |
||
3530 | 4276 | return "error : ".$e->getMessage(); |
3531 | 4277 | } |
3532 | 4278 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3533 | - if ($row['nb'] > 0) return false; |
|
3534 | - else return true; |
|
4279 | + if ($row['nb'] > 0) { |
|
4280 | + return false; |
|
4281 | + } else { |
|
4282 | + return true; |
|
4283 | + } |
|
3535 | 4284 | } |
3536 | 4285 | |
3537 | 4286 | public static function insert_last_ucsdb_update() { |
@@ -3561,8 +4310,11 @@ discard block |
||
3561 | 4310 | return "error : ".$e->getMessage(); |
3562 | 4311 | } |
3563 | 4312 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3564 | - if ($row['nb'] > 0) return false; |
|
3565 | - else return true; |
|
4313 | + if ($row['nb'] > 0) { |
|
4314 | + return false; |
|
4315 | + } else { |
|
4316 | + return true; |
|
4317 | + } |
|
3566 | 4318 | } |
3567 | 4319 | |
3568 | 4320 | public static function insert_last_celestrak_update() { |
@@ -3592,8 +4344,11 @@ discard block |
||
3592 | 4344 | return "error : ".$e->getMessage(); |
3593 | 4345 | } |
3594 | 4346 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3595 | - if ($row['nb'] > 0) return false; |
|
3596 | - else return true; |
|
4347 | + if ($row['nb'] > 0) { |
|
4348 | + return false; |
|
4349 | + } else { |
|
4350 | + return true; |
|
4351 | + } |
|
3597 | 4352 | } |
3598 | 4353 | |
3599 | 4354 | public static function check_last_satellite_update() { |
@@ -3611,8 +4366,11 @@ discard block |
||
3611 | 4366 | return "error : ".$e->getMessage(); |
3612 | 4367 | } |
3613 | 4368 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3614 | - if ($row['nb'] > 0) return false; |
|
3615 | - else return true; |
|
4369 | + if ($row['nb'] > 0) { |
|
4370 | + return false; |
|
4371 | + } else { |
|
4372 | + return true; |
|
4373 | + } |
|
3616 | 4374 | } |
3617 | 4375 | |
3618 | 4376 | public static function insert_last_marine_identity_update() { |