@@ -17,7 +17,9 @@ discard block |
||
| 17 | 17 | curl_setopt($ch, CURLOPT_URL, $url); |
| 18 | 18 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
| 19 | 19 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
| 20 | - if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
| 20 | + if ($referer != '') { |
|
| 21 | + curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
| 22 | + } |
|
| 21 | 23 | 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'); |
| 22 | 24 | curl_setopt($ch, CURLOPT_FILE, $fp); |
| 23 | 25 | curl_exec($ch); |
@@ -28,12 +30,16 @@ discard block |
||
| 28 | 30 | public static function gunzip($in_file,$out_file_name = '') { |
| 29 | 31 | //echo $in_file.' -> '.$out_file_name."\n"; |
| 30 | 32 | $buffer_size = 4096; // read 4kb at a time |
| 31 | - if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); |
|
| 33 | + if ($out_file_name == '') { |
|
| 34 | + $out_file_name = str_replace('.gz', '', $in_file); |
|
| 35 | + } |
|
| 32 | 36 | if ($in_file != '' && file_exists($in_file)) { |
| 33 | 37 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
| 34 | - if (function_exists('gzopen')) $file = gzopen($in_file,'rb'); |
|
| 35 | - elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb'); |
|
| 36 | - else { |
|
| 38 | + if (function_exists('gzopen')) { |
|
| 39 | + $file = gzopen($in_file,'rb'); |
|
| 40 | + } elseif (function_exists('gzopen64')) { |
|
| 41 | + $file = gzopen64($in_file,'rb'); |
|
| 42 | + } else { |
|
| 37 | 43 | echo 'gzopen not available'; |
| 38 | 44 | die; |
| 39 | 45 | } |
@@ -54,8 +60,12 @@ discard block |
||
| 54 | 60 | if ($res === TRUE) { |
| 55 | 61 | $zip->extractTo($path); |
| 56 | 62 | $zip->close(); |
| 57 | - } else return false; |
|
| 58 | - } else return false; |
|
| 63 | + } else { |
|
| 64 | + return false; |
|
| 65 | + } |
|
| 66 | + } else { |
|
| 67 | + return false; |
|
| 68 | + } |
|
| 59 | 69 | } |
| 60 | 70 | |
| 61 | 71 | public static function connect_sqlite($database) { |
@@ -70,7 +80,9 @@ discard block |
||
| 70 | 80 | public static function retrieve_route_sqlite_to_dest($database_file) { |
| 71 | 81 | global $globalDebug, $globalTransaction; |
| 72 | 82 | //$query = 'TRUNCATE TABLE routes'; |
| 73 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
| 83 | + if ($globalDebug) { |
|
| 84 | + echo " - Delete previous routes from DB -"; |
|
| 85 | + } |
|
| 74 | 86 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
| 75 | 87 | $Connection = new Connection(); |
| 76 | 88 | try { |
@@ -81,7 +93,9 @@ discard block |
||
| 81 | 93 | return "error : ".$e->getMessage(); |
| 82 | 94 | } |
| 83 | 95 | |
| 84 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
| 96 | + if ($globalDebug) { |
|
| 97 | + echo " - Add routes to DB -"; |
|
| 98 | + } |
|
| 85 | 99 | update_db::connect_sqlite($database_file); |
| 86 | 100 | //$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'; |
| 87 | 101 | $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"; |
@@ -96,15 +110,21 @@ discard block |
||
| 96 | 110 | $Connection = new Connection(); |
| 97 | 111 | $sth_dest = $Connection->db->prepare($query_dest); |
| 98 | 112 | try { |
| 99 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 113 | + if ($globalTransaction) { |
|
| 114 | + $Connection->db->beginTransaction(); |
|
| 115 | + } |
|
| 100 | 116 | while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
| 101 | 117 | //$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); |
| 102 | 118 | $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); |
| 103 | 119 | $sth_dest->execute($query_dest_values); |
| 104 | 120 | } |
| 105 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 121 | + if ($globalTransaction) { |
|
| 122 | + $Connection->db->commit(); |
|
| 123 | + } |
|
| 106 | 124 | } catch(PDOException $e) { |
| 107 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
| 125 | + if ($globalTransaction) { |
|
| 126 | + $Connection->db->rollBack(); |
|
| 127 | + } |
|
| 108 | 128 | return "error : ".$e->getMessage(); |
| 109 | 129 | } |
| 110 | 130 | return ''; |
@@ -112,7 +132,9 @@ discard block |
||
| 112 | 132 | public static function retrieve_route_oneworld($database_file) { |
| 113 | 133 | global $globalDebug, $globalTransaction; |
| 114 | 134 | //$query = 'TRUNCATE TABLE routes'; |
| 115 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
| 135 | + if ($globalDebug) { |
|
| 136 | + echo " - Delete previous routes from DB -"; |
|
| 137 | + } |
|
| 116 | 138 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
| 117 | 139 | $Connection = new Connection(); |
| 118 | 140 | try { |
@@ -123,14 +145,18 @@ discard block |
||
| 123 | 145 | return "error : ".$e->getMessage(); |
| 124 | 146 | } |
| 125 | 147 | |
| 126 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
| 148 | + if ($globalDebug) { |
|
| 149 | + echo " - Add routes to DB -"; |
|
| 150 | + } |
|
| 127 | 151 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 128 | 152 | $Spotter = new Spotter(); |
| 129 | 153 | if ($fh = fopen($database_file,"r")) { |
| 130 | 154 | $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)'; |
| 131 | 155 | $Connection = new Connection(); |
| 132 | 156 | $sth_dest = $Connection->db->prepare($query_dest); |
| 133 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 157 | + if ($globalTransaction) { |
|
| 158 | + $Connection->db->beginTransaction(); |
|
| 159 | + } |
|
| 134 | 160 | while (!feof($fh)) { |
| 135 | 161 | $line = fgetcsv($fh,9999,','); |
| 136 | 162 | if ($line[0] != '') { |
@@ -139,13 +165,17 @@ discard block |
||
| 139 | 165 | $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'); |
| 140 | 166 | $sth_dest->execute($query_dest_values); |
| 141 | 167 | } catch(PDOException $e) { |
| 142 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
| 168 | + if ($globalTransaction) { |
|
| 169 | + $Connection->db->rollBack(); |
|
| 170 | + } |
|
| 143 | 171 | return "error : ".$e->getMessage(); |
| 144 | 172 | } |
| 145 | 173 | } |
| 146 | 174 | } |
| 147 | 175 | } |
| 148 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 176 | + if ($globalTransaction) { |
|
| 177 | + $Connection->db->commit(); |
|
| 178 | + } |
|
| 149 | 179 | } |
| 150 | 180 | return ''; |
| 151 | 181 | } |
@@ -153,7 +183,9 @@ discard block |
||
| 153 | 183 | public static function retrieve_route_skyteam($database_file) { |
| 154 | 184 | global $globalDebug, $globalTransaction; |
| 155 | 185 | //$query = 'TRUNCATE TABLE routes'; |
| 156 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
| 186 | + if ($globalDebug) { |
|
| 187 | + echo " - Delete previous routes from DB -"; |
|
| 188 | + } |
|
| 157 | 189 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
| 158 | 190 | $Connection = new Connection(); |
| 159 | 191 | try { |
@@ -164,7 +196,9 @@ discard block |
||
| 164 | 196 | return "error : ".$e->getMessage(); |
| 165 | 197 | } |
| 166 | 198 | |
| 167 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
| 199 | + if ($globalDebug) { |
|
| 200 | + echo " - Add routes to DB -"; |
|
| 201 | + } |
|
| 168 | 202 | |
| 169 | 203 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 170 | 204 | $Spotter = new Spotter(); |
@@ -173,7 +207,9 @@ discard block |
||
| 173 | 207 | $Connection = new Connection(); |
| 174 | 208 | $sth_dest = $Connection->db->prepare($query_dest); |
| 175 | 209 | try { |
| 176 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 210 | + if ($globalTransaction) { |
|
| 211 | + $Connection->db->beginTransaction(); |
|
| 212 | + } |
|
| 177 | 213 | while (!feof($fh)) { |
| 178 | 214 | $line = fgetcsv($fh,9999,','); |
| 179 | 215 | if ($line[0] != '') { |
@@ -184,9 +220,13 @@ discard block |
||
| 184 | 220 | } |
| 185 | 221 | } |
| 186 | 222 | } |
| 187 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 223 | + if ($globalTransaction) { |
|
| 224 | + $Connection->db->commit(); |
|
| 225 | + } |
|
| 188 | 226 | } catch(PDOException $e) { |
| 189 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
| 227 | + if ($globalTransaction) { |
|
| 228 | + $Connection->db->rollBack(); |
|
| 229 | + } |
|
| 190 | 230 | return "error : ".$e->getMessage(); |
| 191 | 231 | } |
| 192 | 232 | } |
@@ -229,11 +269,16 @@ discard block |
||
| 229 | 269 | $sth_dest = $Connection->db->prepare($query_dest); |
| 230 | 270 | $sth_dest_owner = $Connection->db->prepare($query_dest_owner); |
| 231 | 271 | try { |
| 232 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 272 | + if ($globalTransaction) { |
|
| 273 | + $Connection->db->beginTransaction(); |
|
| 274 | + } |
|
| 233 | 275 | while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
| 234 | 276 | //$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']); |
| 235 | - if ($values['UserString4'] == 'M') $type = 'military'; |
|
| 236 | - else $type = null; |
|
| 277 | + if ($values['UserString4'] == 'M') { |
|
| 278 | + $type = 'military'; |
|
| 279 | + } else { |
|
| 280 | + $type = null; |
|
| 281 | + } |
|
| 237 | 282 | $query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type); |
| 238 | 283 | $sth_dest->execute($query_dest_values); |
| 239 | 284 | if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') { |
@@ -241,7 +286,9 @@ discard block |
||
| 241 | 286 | $sth_dest_owner->execute($query_dest_owner_values); |
| 242 | 287 | } |
| 243 | 288 | } |
| 244 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 289 | + if ($globalTransaction) { |
|
| 290 | + $Connection->db->commit(); |
|
| 291 | + } |
|
| 245 | 292 | } catch(PDOException $e) { |
| 246 | 293 | return "error : ".$e->getMessage(); |
| 247 | 294 | } |
@@ -278,7 +325,9 @@ discard block |
||
| 278 | 325 | $Connection = new Connection(); |
| 279 | 326 | $sth_dest = $Connection->db->prepare($query_dest); |
| 280 | 327 | try { |
| 281 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 328 | + if ($globalTransaction) { |
|
| 329 | + $Connection->db->beginTransaction(); |
|
| 330 | + } |
|
| 282 | 331 | while (!feof($fh)) { |
| 283 | 332 | $values = array(); |
| 284 | 333 | $line = $Common->hex2str(fgets($fh,9999)); |
@@ -289,7 +338,9 @@ discard block |
||
| 289 | 338 | // Check if we can find ICAO, else set it to GLID |
| 290 | 339 | $aircraft_name_split = explode(' ',$aircraft_name); |
| 291 | 340 | $search_more = ''; |
| 292 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 341 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) { |
|
| 342 | + $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 343 | + } |
|
| 293 | 344 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
| 294 | 345 | $sth_search = $Connection->db->prepare($query_search); |
| 295 | 346 | try { |
@@ -302,7 +353,9 @@ discard block |
||
| 302 | 353 | } catch(PDOException $e) { |
| 303 | 354 | return "error : ".$e->getMessage(); |
| 304 | 355 | } |
| 305 | - if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID'; |
|
| 356 | + if (!isset($values['ICAOTypeCode'])) { |
|
| 357 | + $values['ICAOTypeCode'] = 'GLID'; |
|
| 358 | + } |
|
| 306 | 359 | // Add data to db |
| 307 | 360 | if ($values['Registration'] != '' && $values['Registration'] != '0000') { |
| 308 | 361 | //$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']); |
@@ -311,7 +364,9 @@ discard block |
||
| 311 | 364 | $sth_dest->execute($query_dest_values); |
| 312 | 365 | } |
| 313 | 366 | } |
| 314 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 367 | + if ($globalTransaction) { |
|
| 368 | + $Connection->db->commit(); |
|
| 369 | + } |
|
| 315 | 370 | } catch(PDOException $e) { |
| 316 | 371 | return "error : ".$e->getMessage(); |
| 317 | 372 | } |
@@ -347,7 +402,9 @@ discard block |
||
| 347 | 402 | $Connection = new Connection(); |
| 348 | 403 | $sth_dest = $Connection->db->prepare($query_dest); |
| 349 | 404 | try { |
| 350 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 405 | + if ($globalTransaction) { |
|
| 406 | + $Connection->db->beginTransaction(); |
|
| 407 | + } |
|
| 351 | 408 | $tmp = fgetcsv($fh,9999,',',"'"); |
| 352 | 409 | while (!feof($fh)) { |
| 353 | 410 | $line = fgetcsv($fh,9999,',',"'"); |
@@ -361,13 +418,17 @@ discard block |
||
| 361 | 418 | // Check if we can find ICAO, else set it to GLID |
| 362 | 419 | $aircraft_name_split = explode(' ',$aircraft_name); |
| 363 | 420 | $search_more = ''; |
| 364 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 421 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) { |
|
| 422 | + $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 423 | + } |
|
| 365 | 424 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
| 366 | 425 | $sth_search = $Connection->db->prepare($query_search); |
| 367 | 426 | try { |
| 368 | 427 | $sth_search->execute(); |
| 369 | 428 | $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
| 370 | - if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
|
| 429 | + if (isset($result['icao']) && $result['icao'] != '') { |
|
| 430 | + $values['ICAOTypeCode'] = $result['icao']; |
|
| 431 | + } |
|
| 371 | 432 | } catch(PDOException $e) { |
| 372 | 433 | return "error : ".$e->getMessage(); |
| 373 | 434 | } |
@@ -380,7 +441,9 @@ discard block |
||
| 380 | 441 | $sth_dest->execute($query_dest_values); |
| 381 | 442 | } |
| 382 | 443 | } |
| 383 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 444 | + if ($globalTransaction) { |
|
| 445 | + $Connection->db->commit(); |
|
| 446 | + } |
|
| 384 | 447 | } catch(PDOException $e) { |
| 385 | 448 | return "error : ".$e->getMessage(); |
| 386 | 449 | } |
@@ -419,7 +482,9 @@ discard block |
||
| 419 | 482 | $sth_dest = $Connection->db->prepare($query_dest); |
| 420 | 483 | $sth_modes = $Connection->db->prepare($query_modes); |
| 421 | 484 | try { |
| 422 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 485 | + if ($globalTransaction) { |
|
| 486 | + $Connection->db->beginTransaction(); |
|
| 487 | + } |
|
| 423 | 488 | $tmp = fgetcsv($fh,9999,',','"'); |
| 424 | 489 | while (!feof($fh)) { |
| 425 | 490 | $line = fgetcsv($fh,9999,',','"'); |
@@ -429,16 +494,22 @@ discard block |
||
| 429 | 494 | $values['registration'] = $line[0]; |
| 430 | 495 | $values['base'] = $line[4]; |
| 431 | 496 | $values['owner'] = $line[5]; |
| 432 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
| 433 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 497 | + if ($line[6] == '') { |
|
| 498 | + $values['date_first_reg'] = null; |
|
| 499 | + } else { |
|
| 500 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 501 | + } |
|
| 434 | 502 | $values['cancel'] = $line[7]; |
| 435 | 503 | } elseif ($country == 'EI') { |
| 436 | 504 | // TODO : add modeS & reg to aircraft_modes |
| 437 | 505 | $values['registration'] = $line[0]; |
| 438 | 506 | $values['base'] = $line[3]; |
| 439 | 507 | $values['owner'] = $line[2]; |
| 440 | - if ($line[1] == '') $values['date_first_reg'] = null; |
|
| 441 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
| 508 | + if ($line[1] == '') { |
|
| 509 | + $values['date_first_reg'] = null; |
|
| 510 | + } else { |
|
| 511 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
| 512 | + } |
|
| 442 | 513 | $values['cancel'] = ''; |
| 443 | 514 | $values['modes'] = $line[7]; |
| 444 | 515 | $values['icao'] = $line[8]; |
@@ -457,16 +528,22 @@ discard block |
||
| 457 | 528 | $values['registration'] = $line[3]; |
| 458 | 529 | $values['base'] = null; |
| 459 | 530 | $values['owner'] = $line[5]; |
| 460 | - if ($line[18] == '') $values['date_first_reg'] = null; |
|
| 461 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
| 531 | + if ($line[18] == '') { |
|
| 532 | + $values['date_first_reg'] = null; |
|
| 533 | + } else { |
|
| 534 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
| 535 | + } |
|
| 462 | 536 | $values['cancel'] = ''; |
| 463 | 537 | } elseif ($country == 'VH') { |
| 464 | 538 | // TODO : add modeS & reg to aircraft_modes |
| 465 | 539 | $values['registration'] = $line[0]; |
| 466 | 540 | $values['base'] = null; |
| 467 | 541 | $values['owner'] = $line[12]; |
| 468 | - if ($line[28] == '') $values['date_first_reg'] = null; |
|
| 469 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
| 542 | + if ($line[28] == '') { |
|
| 543 | + $values['date_first_reg'] = null; |
|
| 544 | + } else { |
|
| 545 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
| 546 | + } |
|
| 470 | 547 | |
| 471 | 548 | $values['cancel'] = $line[39]; |
| 472 | 549 | } elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { |
@@ -485,29 +562,41 @@ discard block |
||
| 485 | 562 | $values['registration'] = $line[0]; |
| 486 | 563 | $values['base'] = null; |
| 487 | 564 | $values['owner'] = $line[8]; |
| 488 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
| 489 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 565 | + if ($line[7] == '') { |
|
| 566 | + $values['date_first_reg'] = null; |
|
| 567 | + } else { |
|
| 568 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 569 | + } |
|
| 490 | 570 | $values['cancel'] = ''; |
| 491 | 571 | } elseif ($country == 'PP') { |
| 492 | 572 | $values['registration'] = $line[0]; |
| 493 | 573 | $values['base'] = null; |
| 494 | 574 | $values['owner'] = $line[4]; |
| 495 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
| 496 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 575 | + if ($line[6] == '') { |
|
| 576 | + $values['date_first_reg'] = null; |
|
| 577 | + } else { |
|
| 578 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 579 | + } |
|
| 497 | 580 | $values['cancel'] = $line[7]; |
| 498 | 581 | } elseif ($country == 'E7') { |
| 499 | 582 | $values['registration'] = $line[0]; |
| 500 | 583 | $values['base'] = null; |
| 501 | 584 | $values['owner'] = $line[4]; |
| 502 | - if ($line[5] == '') $values['date_first_reg'] = null; |
|
| 503 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
| 585 | + if ($line[5] == '') { |
|
| 586 | + $values['date_first_reg'] = null; |
|
| 587 | + } else { |
|
| 588 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
| 589 | + } |
|
| 504 | 590 | $values['cancel'] = ''; |
| 505 | 591 | } elseif ($country == '8Q') { |
| 506 | 592 | $values['registration'] = $line[0]; |
| 507 | 593 | $values['base'] = null; |
| 508 | 594 | $values['owner'] = $line[3]; |
| 509 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
| 510 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 595 | + if ($line[7] == '') { |
|
| 596 | + $values['date_first_reg'] = null; |
|
| 597 | + } else { |
|
| 598 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 599 | + } |
|
| 511 | 600 | $values['cancel'] = ''; |
| 512 | 601 | } elseif ($country == 'ZK') { |
| 513 | 602 | $values['registration'] = $line[0]; |
@@ -552,7 +641,9 @@ discard block |
||
| 552 | 641 | $sth_modes->execute($query_modes_values); |
| 553 | 642 | } |
| 554 | 643 | } |
| 555 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 644 | + if ($globalTransaction) { |
|
| 645 | + $Connection->db->commit(); |
|
| 646 | + } |
|
| 556 | 647 | } catch(PDOException $e) { |
| 557 | 648 | return "error : ".$e->getMessage(); |
| 558 | 649 | } |
@@ -688,25 +779,45 @@ discard block |
||
| 688 | 779 | VALUES (:name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)"; |
| 689 | 780 | $Connection = new Connection(); |
| 690 | 781 | $sth_dest = $Connection->db->prepare($query_dest); |
| 691 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 782 | + if ($globalTransaction) { |
|
| 783 | + $Connection->db->beginTransaction(); |
|
| 784 | + } |
|
| 692 | 785 | |
| 693 | 786 | $i = 0; |
| 694 | 787 | while($row = sparql_fetch_array($result)) |
| 695 | 788 | { |
| 696 | 789 | if ($i >= 1) { |
| 697 | 790 | //print_r($row); |
| 698 | - if (!isset($row['iata'])) $row['iata'] = ''; |
|
| 699 | - if (!isset($row['icao'])) $row['icao'] = ''; |
|
| 700 | - if (!isset($row['type'])) $row['type'] = ''; |
|
| 701 | - if (!isset($row['altitude'])) $row['altitude'] = ''; |
|
| 791 | + if (!isset($row['iata'])) { |
|
| 792 | + $row['iata'] = ''; |
|
| 793 | + } |
|
| 794 | + if (!isset($row['icao'])) { |
|
| 795 | + $row['icao'] = ''; |
|
| 796 | + } |
|
| 797 | + if (!isset($row['type'])) { |
|
| 798 | + $row['type'] = ''; |
|
| 799 | + } |
|
| 800 | + if (!isset($row['altitude'])) { |
|
| 801 | + $row['altitude'] = ''; |
|
| 802 | + } |
|
| 702 | 803 | if (isset($row['city_bis'])) { |
| 703 | 804 | $row['city'] = $row['city_bis']; |
| 704 | 805 | } |
| 705 | - if (!isset($row['city'])) $row['city'] = ''; |
|
| 706 | - if (!isset($row['country'])) $row['country'] = ''; |
|
| 707 | - if (!isset($row['homepage'])) $row['homepage'] = ''; |
|
| 708 | - if (!isset($row['wikipedia_page'])) $row['wikipedia_page'] = ''; |
|
| 709 | - if (!isset($row['name'])) continue; |
|
| 806 | + if (!isset($row['city'])) { |
|
| 807 | + $row['city'] = ''; |
|
| 808 | + } |
|
| 809 | + if (!isset($row['country'])) { |
|
| 810 | + $row['country'] = ''; |
|
| 811 | + } |
|
| 812 | + if (!isset($row['homepage'])) { |
|
| 813 | + $row['homepage'] = ''; |
|
| 814 | + } |
|
| 815 | + if (!isset($row['wikipedia_page'])) { |
|
| 816 | + $row['wikipedia_page'] = ''; |
|
| 817 | + } |
|
| 818 | + if (!isset($row['name'])) { |
|
| 819 | + continue; |
|
| 820 | + } |
|
| 710 | 821 | if (!isset($row['image'])) { |
| 711 | 822 | $row['image'] = ''; |
| 712 | 823 | $row['image_thumb'] = ''; |
@@ -762,7 +873,9 @@ discard block |
||
| 762 | 873 | |
| 763 | 874 | $i++; |
| 764 | 875 | } |
| 765 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 876 | + if ($globalTransaction) { |
|
| 877 | + $Connection->db->commit(); |
|
| 878 | + } |
|
| 766 | 879 | /* |
| 767 | 880 | echo "Delete duplicate rows...\n"; |
| 768 | 881 | $query = 'ALTER IGNORE TABLE airport ADD UNIQUE INDEX icaoidx (icao)'; |
@@ -805,7 +918,9 @@ discard block |
||
| 805 | 918 | $delimiter = ','; |
| 806 | 919 | $out_file = $tmp_dir.'airports.csv'; |
| 807 | 920 | update_db::download('http://ourairports.com/data/airports.csv',$out_file); |
| 808 | - if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
|
| 921 | + if (!file_exists($out_file) || !is_readable($out_file)) { |
|
| 922 | + return FALSE; |
|
| 923 | + } |
|
| 809 | 924 | echo "Add data from ourairports.com...\n"; |
| 810 | 925 | |
| 811 | 926 | $header = NULL; |
@@ -815,8 +930,9 @@ discard block |
||
| 815 | 930 | //$Connection->db->beginTransaction(); |
| 816 | 931 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 817 | 932 | { |
| 818 | - if(!$header) $header = $row; |
|
| 819 | - else { |
|
| 933 | + if(!$header) { |
|
| 934 | + $header = $row; |
|
| 935 | + } else { |
|
| 820 | 936 | $data = array(); |
| 821 | 937 | $data = array_combine($header, $row); |
| 822 | 938 | try { |
@@ -857,7 +973,9 @@ discard block |
||
| 857 | 973 | echo "Download data from another free database...\n"; |
| 858 | 974 | $out_file = $tmp_dir.'GlobalAirportDatabase.zip'; |
| 859 | 975 | update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file); |
| 860 | - if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
|
| 976 | + if (!file_exists($out_file) || !is_readable($out_file)) { |
|
| 977 | + return FALSE; |
|
| 978 | + } |
|
| 861 | 979 | update_db::unzip($out_file); |
| 862 | 980 | $header = NULL; |
| 863 | 981 | echo "Add data from another free database...\n"; |
@@ -868,8 +986,9 @@ discard block |
||
| 868 | 986 | //$Connection->db->beginTransaction(); |
| 869 | 987 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 870 | 988 | { |
| 871 | - if(!$header) $header = $row; |
|
| 872 | - else { |
|
| 989 | + if(!$header) { |
|
| 990 | + $header = $row; |
|
| 991 | + } else { |
|
| 873 | 992 | $data = $row; |
| 874 | 993 | |
| 875 | 994 | $query = 'UPDATE airport SET city = :city, country = :country WHERE icao = :icao'; |
@@ -1042,7 +1161,9 @@ discard block |
||
| 1042 | 1161 | if (($handle = fopen($tmp_dir.'MASTER.txt', 'r')) !== FALSE) |
| 1043 | 1162 | { |
| 1044 | 1163 | $i = 0; |
| 1045 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1164 | + if ($globalTransaction) { |
|
| 1165 | + $Connection->db->beginTransaction(); |
|
| 1166 | + } |
|
| 1046 | 1167 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1047 | 1168 | { |
| 1048 | 1169 | if ($i > 0) { |
@@ -1055,7 +1176,9 @@ discard block |
||
| 1055 | 1176 | } |
| 1056 | 1177 | $result_search = $sths->fetchAll(PDO::FETCH_ASSOC); |
| 1057 | 1178 | if (!empty($result_search)) { |
| 1058 | - if ($globalDebug) echo '.'; |
|
| 1179 | + if ($globalDebug) { |
|
| 1180 | + echo '.'; |
|
| 1181 | + } |
|
| 1059 | 1182 | //if ($globalDBdriver == 'mysql') { |
| 1060 | 1183 | // $queryi = 'INSERT INTO faamfr (mfr,icao) VALUES (:mfr,:icao) ON DUPLICATE KEY UPDATE icao = :icao'; |
| 1061 | 1184 | //} else { |
@@ -1077,8 +1200,12 @@ discard block |
||
| 1077 | 1200 | } |
| 1078 | 1201 | $result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC); |
| 1079 | 1202 | if (!empty($result_search_mfr)) { |
| 1080 | - if (trim($data[16]) == '' && trim($data[23]) != '') $data[16] = $data[23]; |
|
| 1081 | - if (trim($data[16]) == '' && trim($data[15]) != '') $data[16] = $data[15]; |
|
| 1203 | + if (trim($data[16]) == '' && trim($data[23]) != '') { |
|
| 1204 | + $data[16] = $data[23]; |
|
| 1205 | + } |
|
| 1206 | + if (trim($data[16]) == '' && trim($data[15]) != '') { |
|
| 1207 | + $data[16] = $data[15]; |
|
| 1208 | + } |
|
| 1082 | 1209 | $queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)'; |
| 1083 | 1210 | try { |
| 1084 | 1211 | $sthf = $Connection->db->prepare($queryf); |
@@ -1089,7 +1216,9 @@ discard block |
||
| 1089 | 1216 | } |
| 1090 | 1217 | } |
| 1091 | 1218 | if (strtotime($data[29]) > time()) { |
| 1092 | - if ($globalDebug) echo 'i'; |
|
| 1219 | + if ($globalDebug) { |
|
| 1220 | + echo 'i'; |
|
| 1221 | + } |
|
| 1093 | 1222 | $query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)'; |
| 1094 | 1223 | try { |
| 1095 | 1224 | $sth = $Connection->db->prepare($query); |
@@ -1100,13 +1229,19 @@ discard block |
||
| 1100 | 1229 | } |
| 1101 | 1230 | } |
| 1102 | 1231 | if ($i % 90 == 0) { |
| 1103 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1104 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1232 | + if ($globalTransaction) { |
|
| 1233 | + $Connection->db->commit(); |
|
| 1234 | + } |
|
| 1235 | + if ($globalTransaction) { |
|
| 1236 | + $Connection->db->beginTransaction(); |
|
| 1237 | + } |
|
| 1105 | 1238 | } |
| 1106 | 1239 | $i++; |
| 1107 | 1240 | } |
| 1108 | 1241 | fclose($handle); |
| 1109 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1242 | + if ($globalTransaction) { |
|
| 1243 | + $Connection->db->commit(); |
|
| 1244 | + } |
|
| 1110 | 1245 | } |
| 1111 | 1246 | print_r($mfr); |
| 1112 | 1247 | return ''; |
@@ -1131,11 +1266,15 @@ discard block |
||
| 1131 | 1266 | $i = 0; |
| 1132 | 1267 | //$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE); |
| 1133 | 1268 | //$Connection->db->beginTransaction(); |
| 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 | } |
@@ -1168,7 +1309,9 @@ discard block |
||
| 1168 | 1309 | if (($handle = fopen($tmp_dir.'owners.tsv', 'r')) !== FALSE) |
| 1169 | 1310 | { |
| 1170 | 1311 | $i = 0; |
| 1171 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1312 | + if ($globalTransaction) { |
|
| 1313 | + $Connection->db->beginTransaction(); |
|
| 1314 | + } |
|
| 1172 | 1315 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1173 | 1316 | { |
| 1174 | 1317 | if ($i > 0) { |
@@ -1184,7 +1327,9 @@ discard block |
||
| 1184 | 1327 | $i++; |
| 1185 | 1328 | } |
| 1186 | 1329 | fclose($handle); |
| 1187 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1330 | + if ($globalTransaction) { |
|
| 1331 | + $Connection->db->commit(); |
|
| 1332 | + } |
|
| 1188 | 1333 | } |
| 1189 | 1334 | return ''; |
| 1190 | 1335 | } |
@@ -1209,7 +1354,9 @@ discard block |
||
| 1209 | 1354 | $i = 0; |
| 1210 | 1355 | //$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE); |
| 1211 | 1356 | //$Connection->db->beginTransaction(); |
| 1212 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1357 | + if ($globalTransaction) { |
|
| 1358 | + $Connection->db->beginTransaction(); |
|
| 1359 | + } |
|
| 1213 | 1360 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1214 | 1361 | { |
| 1215 | 1362 | if ($i > 0) { |
@@ -1224,7 +1371,9 @@ discard block |
||
| 1224 | 1371 | $i++; |
| 1225 | 1372 | } |
| 1226 | 1373 | fclose($handle); |
| 1227 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1374 | + if ($globalTransaction) { |
|
| 1375 | + $Connection->db->commit(); |
|
| 1376 | + } |
|
| 1228 | 1377 | } |
| 1229 | 1378 | return ''; |
| 1230 | 1379 | } |
@@ -1249,7 +1398,9 @@ discard block |
||
| 1249 | 1398 | $i = 0; |
| 1250 | 1399 | //$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE); |
| 1251 | 1400 | //$Connection->db->beginTransaction(); |
| 1252 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1401 | + if ($globalTransaction) { |
|
| 1402 | + $Connection->db->beginTransaction(); |
|
| 1403 | + } |
|
| 1253 | 1404 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1254 | 1405 | { |
| 1255 | 1406 | if ($i > 0) { |
@@ -1265,7 +1416,9 @@ discard block |
||
| 1265 | 1416 | $i++; |
| 1266 | 1417 | } |
| 1267 | 1418 | fclose($handle); |
| 1268 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1419 | + if ($globalTransaction) { |
|
| 1420 | + $Connection->db->commit(); |
|
| 1421 | + } |
|
| 1269 | 1422 | } |
| 1270 | 1423 | return ''; |
| 1271 | 1424 | } |
@@ -1284,7 +1437,9 @@ discard block |
||
| 1284 | 1437 | $Connection = new Connection(); |
| 1285 | 1438 | if (($handle = fopen($tmp_dir.'ban_eu.csv', 'r')) !== FALSE) |
| 1286 | 1439 | { |
| 1287 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1440 | + if ($globalTransaction) { |
|
| 1441 | + $Connection->db->beginTransaction(); |
|
| 1442 | + } |
|
| 1288 | 1443 | while (($data = fgetcsv($handle, 1000)) !== FALSE) |
| 1289 | 1444 | { |
| 1290 | 1445 | $query = 'UPDATE airlines SET ban_eu = 1 WHERE icao = :icao AND forsource IS NULL'; |
@@ -1299,7 +1454,9 @@ discard block |
||
| 1299 | 1454 | } |
| 1300 | 1455 | } |
| 1301 | 1456 | fclose($handle); |
| 1302 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1457 | + if ($globalTransaction) { |
|
| 1458 | + $Connection->db->commit(); |
|
| 1459 | + } |
|
| 1303 | 1460 | } |
| 1304 | 1461 | return ''; |
| 1305 | 1462 | } |
@@ -1450,7 +1607,9 @@ discard block |
||
| 1450 | 1607 | if (($handle = fopen($filename, 'r')) !== FALSE) |
| 1451 | 1608 | { |
| 1452 | 1609 | $i = 0; |
| 1453 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1610 | + if ($globalTransaction) { |
|
| 1611 | + $Connection->db->beginTransaction(); |
|
| 1612 | + } |
|
| 1454 | 1613 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1455 | 1614 | { |
| 1456 | 1615 | $i++; |
@@ -1478,7 +1637,9 @@ discard block |
||
| 1478 | 1637 | } |
| 1479 | 1638 | } |
| 1480 | 1639 | fclose($handle); |
| 1481 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1640 | + if ($globalTransaction) { |
|
| 1641 | + $Connection->db->commit(); |
|
| 1642 | + } |
|
| 1482 | 1643 | } |
| 1483 | 1644 | return ''; |
| 1484 | 1645 | } |
@@ -1501,7 +1662,9 @@ discard block |
||
| 1501 | 1662 | $Connection = new Connection(); |
| 1502 | 1663 | if (($handle = fopen($filename, 'r')) !== FALSE) |
| 1503 | 1664 | { |
| 1504 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1665 | + if ($globalTransaction) { |
|
| 1666 | + $Connection->db->beginTransaction(); |
|
| 1667 | + } |
|
| 1505 | 1668 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1506 | 1669 | { |
| 1507 | 1670 | if(count($row) > 1) { |
@@ -1515,7 +1678,9 @@ discard block |
||
| 1515 | 1678 | } |
| 1516 | 1679 | } |
| 1517 | 1680 | fclose($handle); |
| 1518 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1681 | + if ($globalTransaction) { |
|
| 1682 | + $Connection->db->commit(); |
|
| 1683 | + } |
|
| 1519 | 1684 | } |
| 1520 | 1685 | return ''; |
| 1521 | 1686 | } |
@@ -1535,8 +1700,9 @@ discard block |
||
| 1535 | 1700 | } |
| 1536 | 1701 | |
| 1537 | 1702 | |
| 1538 | - if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
| 1539 | - else { |
|
| 1703 | + if ($globalDBdriver == 'mysql') { |
|
| 1704 | + update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
| 1705 | + } else { |
|
| 1540 | 1706 | update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
| 1541 | 1707 | $query = "CREATE EXTENSION postgis"; |
| 1542 | 1708 | $Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']); |
@@ -1555,20 +1721,30 @@ discard block |
||
| 1555 | 1721 | global $tmp_dir, $globalDebug; |
| 1556 | 1722 | include_once('class.create_db.php'); |
| 1557 | 1723 | require_once(dirname(__FILE__).'/../require/class.NOTAM.php'); |
| 1558 | - if ($globalDebug) echo "NOTAM from FlightAirMap website : Download..."; |
|
| 1724 | + if ($globalDebug) { |
|
| 1725 | + echo "NOTAM from FlightAirMap website : Download..."; |
|
| 1726 | + } |
|
| 1559 | 1727 | update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz'); |
| 1560 | 1728 | $error = ''; |
| 1561 | 1729 | if (file_exists($tmp_dir.'notam.txt.gz')) { |
| 1562 | - if ($globalDebug) echo "Gunzip..."; |
|
| 1730 | + if ($globalDebug) { |
|
| 1731 | + echo "Gunzip..."; |
|
| 1732 | + } |
|
| 1563 | 1733 | update_db::gunzip($tmp_dir.'notam.txt.gz'); |
| 1564 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1734 | + if ($globalDebug) { |
|
| 1735 | + echo "Add to DB..."; |
|
| 1736 | + } |
|
| 1565 | 1737 | //$error = create_db::import_file($tmp_dir.'notam.sql'); |
| 1566 | 1738 | $NOTAM = new NOTAM(); |
| 1567 | 1739 | $NOTAM->updateNOTAMfromTextFile($tmp_dir.'notam.txt'); |
| 1568 | - } else $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed."; |
|
| 1740 | + } else { |
|
| 1741 | + $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed."; |
|
| 1742 | + } |
|
| 1569 | 1743 | if ($error != '') { |
| 1570 | 1744 | return $error; |
| 1571 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1745 | + } elseif ($globalDebug) { |
|
| 1746 | + echo "Done\n"; |
|
| 1747 | + } |
|
| 1572 | 1748 | return ''; |
| 1573 | 1749 | } |
| 1574 | 1750 | |
@@ -1622,67 +1798,111 @@ discard block |
||
| 1622 | 1798 | //if ($globalDebug) echo "IVAO : Download..."; |
| 1623 | 1799 | //update_db::download('http://fr.mirror.ivao.aero/software/ivae_feb2013.zip',$tmp_dir.'ivae_feb2013.zip'); |
| 1624 | 1800 | if (file_exists($tmp_dir.'ivae_feb2013.zip')) { |
| 1625 | - if ($globalDebug) echo "Unzip..."; |
|
| 1801 | + if ($globalDebug) { |
|
| 1802 | + echo "Unzip..."; |
|
| 1803 | + } |
|
| 1626 | 1804 | update_db::unzip($tmp_dir.'ivae_feb2013.zip'); |
| 1627 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1805 | + if ($globalDebug) { |
|
| 1806 | + echo "Add to DB..."; |
|
| 1807 | + } |
|
| 1628 | 1808 | update_db::ivao_airlines($tmp_dir.'data/airlines.dat'); |
| 1629 | - if ($globalDebug) echo "Copy airlines logos to airlines images directory..."; |
|
| 1809 | + if ($globalDebug) { |
|
| 1810 | + echo "Copy airlines logos to airlines images directory..."; |
|
| 1811 | + } |
|
| 1630 | 1812 | if (is_writable(dirname(__FILE__).'/../images/airlines')) { |
| 1631 | - if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
| 1632 | - } else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
|
| 1633 | - } else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
|
| 1813 | + if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) { |
|
| 1814 | + $error = "Failed to copy airlines logo."; |
|
| 1815 | + } |
|
| 1816 | + } else { |
|
| 1817 | + $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
|
| 1818 | + } |
|
| 1819 | + } else { |
|
| 1820 | + $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
|
| 1821 | + } |
|
| 1634 | 1822 | if ($error != '') { |
| 1635 | 1823 | return $error; |
| 1636 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1824 | + } elseif ($globalDebug) { |
|
| 1825 | + echo "Done\n"; |
|
| 1826 | + } |
|
| 1637 | 1827 | return ''; |
| 1638 | 1828 | } |
| 1639 | 1829 | |
| 1640 | 1830 | public static function update_routes() { |
| 1641 | 1831 | global $tmp_dir, $globalDebug; |
| 1642 | 1832 | $error = ''; |
| 1643 | - if ($globalDebug) echo "Routes : Download..."; |
|
| 1833 | + if ($globalDebug) { |
|
| 1834 | + echo "Routes : Download..."; |
|
| 1835 | + } |
|
| 1644 | 1836 | update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz'); |
| 1645 | 1837 | if (file_exists($tmp_dir.'StandingData.sqb.gz')) { |
| 1646 | - if ($globalDebug) echo "Gunzip..."; |
|
| 1838 | + if ($globalDebug) { |
|
| 1839 | + echo "Gunzip..."; |
|
| 1840 | + } |
|
| 1647 | 1841 | update_db::gunzip($tmp_dir.'StandingData.sqb.gz'); |
| 1648 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1842 | + if ($globalDebug) { |
|
| 1843 | + echo "Add to DB..."; |
|
| 1844 | + } |
|
| 1649 | 1845 | $error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb'); |
| 1650 | - } else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed."; |
|
| 1846 | + } else { |
|
| 1847 | + $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed."; |
|
| 1848 | + } |
|
| 1651 | 1849 | if ($error != '') { |
| 1652 | 1850 | return $error; |
| 1653 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1851 | + } elseif ($globalDebug) { |
|
| 1852 | + echo "Done\n"; |
|
| 1853 | + } |
|
| 1654 | 1854 | return ''; |
| 1655 | 1855 | } |
| 1656 | 1856 | public static function update_oneworld() { |
| 1657 | 1857 | global $tmp_dir, $globalDebug; |
| 1658 | 1858 | $error = ''; |
| 1659 | - if ($globalDebug) echo "Schedules Oneworld : Download..."; |
|
| 1859 | + if ($globalDebug) { |
|
| 1860 | + echo "Schedules Oneworld : Download..."; |
|
| 1861 | + } |
|
| 1660 | 1862 | update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz'); |
| 1661 | 1863 | if (file_exists($tmp_dir.'oneworld.csv.gz')) { |
| 1662 | - if ($globalDebug) echo "Gunzip..."; |
|
| 1864 | + if ($globalDebug) { |
|
| 1865 | + echo "Gunzip..."; |
|
| 1866 | + } |
|
| 1663 | 1867 | update_db::gunzip($tmp_dir.'oneworld.csv.gz'); |
| 1664 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1868 | + if ($globalDebug) { |
|
| 1869 | + echo "Add to DB..."; |
|
| 1870 | + } |
|
| 1665 | 1871 | $error = update_db::retrieve_route_oneworld($tmp_dir.'oneworld.csv'); |
| 1666 | - } else $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed."; |
|
| 1872 | + } else { |
|
| 1873 | + $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed."; |
|
| 1874 | + } |
|
| 1667 | 1875 | if ($error != '') { |
| 1668 | 1876 | return $error; |
| 1669 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1877 | + } elseif ($globalDebug) { |
|
| 1878 | + echo "Done\n"; |
|
| 1879 | + } |
|
| 1670 | 1880 | return ''; |
| 1671 | 1881 | } |
| 1672 | 1882 | public static function update_skyteam() { |
| 1673 | 1883 | global $tmp_dir, $globalDebug; |
| 1674 | 1884 | $error = ''; |
| 1675 | - if ($globalDebug) echo "Schedules Skyteam : Download..."; |
|
| 1885 | + if ($globalDebug) { |
|
| 1886 | + echo "Schedules Skyteam : Download..."; |
|
| 1887 | + } |
|
| 1676 | 1888 | update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz'); |
| 1677 | 1889 | if (file_exists($tmp_dir.'skyteam.csv.gz')) { |
| 1678 | - if ($globalDebug) echo "Gunzip..."; |
|
| 1890 | + if ($globalDebug) { |
|
| 1891 | + echo "Gunzip..."; |
|
| 1892 | + } |
|
| 1679 | 1893 | update_db::gunzip($tmp_dir.'skyteam.csv.gz'); |
| 1680 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1894 | + if ($globalDebug) { |
|
| 1895 | + echo "Add to DB..."; |
|
| 1896 | + } |
|
| 1681 | 1897 | $error = update_db::retrieve_route_skyteam($tmp_dir.'skyteam.csv'); |
| 1682 | - } else $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed."; |
|
| 1898 | + } else { |
|
| 1899 | + $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed."; |
|
| 1900 | + } |
|
| 1683 | 1901 | if ($error != '') { |
| 1684 | 1902 | return $error; |
| 1685 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1903 | + } elseif ($globalDebug) { |
|
| 1904 | + echo "Done\n"; |
|
| 1905 | + } |
|
| 1686 | 1906 | return ''; |
| 1687 | 1907 | } |
| 1688 | 1908 | public static function update_ModeS() { |
@@ -1699,355 +1919,619 @@ discard block |
||
| 1699 | 1919 | exit; |
| 1700 | 1920 | } elseif ($globalDebug) echo "Done\n"; |
| 1701 | 1921 | */ |
| 1702 | - if ($globalDebug) echo "Modes : Download..."; |
|
| 1703 | -// update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
|
| 1922 | + if ($globalDebug) { |
|
| 1923 | + echo "Modes : Download..."; |
|
| 1924 | + } |
|
| 1925 | + // update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
|
| 1704 | 1926 | update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz'); |
| 1705 | 1927 | |
| 1706 | 1928 | // if (file_exists($tmp_dir.'basestation_latest.zip')) { |
| 1707 | 1929 | if (file_exists($tmp_dir.'BaseStation.sqb.gz')) { |
| 1708 | - if ($globalDebug) echo "Unzip..."; |
|
| 1709 | -// update_db::unzip($tmp_dir.'basestation_latest.zip'); |
|
| 1930 | + if ($globalDebug) { |
|
| 1931 | + echo "Unzip..."; |
|
| 1932 | + } |
|
| 1933 | + // update_db::unzip($tmp_dir.'basestation_latest.zip'); |
|
| 1710 | 1934 | update_db::gunzip($tmp_dir.'BaseStation.sqb.gz'); |
| 1711 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1935 | + if ($globalDebug) { |
|
| 1936 | + echo "Add to DB..."; |
|
| 1937 | + } |
|
| 1712 | 1938 | $error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb'); |
| 1713 | 1939 | // $error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'basestation.sqb'); |
| 1714 | - } else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed."; |
|
| 1940 | + } else { |
|
| 1941 | + $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed."; |
|
| 1942 | + } |
|
| 1715 | 1943 | if ($error != '') { |
| 1716 | 1944 | return $error; |
| 1717 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1945 | + } elseif ($globalDebug) { |
|
| 1946 | + echo "Done\n"; |
|
| 1947 | + } |
|
| 1718 | 1948 | return ''; |
| 1719 | 1949 | } |
| 1720 | 1950 | |
| 1721 | 1951 | public static function update_ModeS_faa() { |
| 1722 | 1952 | global $tmp_dir, $globalDebug; |
| 1723 | - if ($globalDebug) echo "Modes FAA: Download..."; |
|
| 1953 | + if ($globalDebug) { |
|
| 1954 | + echo "Modes FAA: Download..."; |
|
| 1955 | + } |
|
| 1724 | 1956 | update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip'); |
| 1725 | 1957 | if (file_exists($tmp_dir.'ReleasableAircraft.zip')) { |
| 1726 | - if ($globalDebug) echo "Unzip..."; |
|
| 1958 | + if ($globalDebug) { |
|
| 1959 | + echo "Unzip..."; |
|
| 1960 | + } |
|
| 1727 | 1961 | update_db::unzip($tmp_dir.'ReleasableAircraft.zip'); |
| 1728 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1962 | + if ($globalDebug) { |
|
| 1963 | + echo "Add to DB..."; |
|
| 1964 | + } |
|
| 1729 | 1965 | $error = update_db::modes_faa(); |
| 1730 | - } else $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed."; |
|
| 1966 | + } else { |
|
| 1967 | + $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed."; |
|
| 1968 | + } |
|
| 1731 | 1969 | if ($error != '') { |
| 1732 | 1970 | return $error; |
| 1733 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1971 | + } elseif ($globalDebug) { |
|
| 1972 | + echo "Done\n"; |
|
| 1973 | + } |
|
| 1734 | 1974 | return ''; |
| 1735 | 1975 | } |
| 1736 | 1976 | |
| 1737 | 1977 | public static function update_ModeS_flarm() { |
| 1738 | 1978 | global $tmp_dir, $globalDebug; |
| 1739 | - if ($globalDebug) echo "Modes Flarmnet: Download..."; |
|
| 1979 | + if ($globalDebug) { |
|
| 1980 | + echo "Modes Flarmnet: Download..."; |
|
| 1981 | + } |
|
| 1740 | 1982 | update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln'); |
| 1741 | 1983 | if (file_exists($tmp_dir.'data.fln')) { |
| 1742 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1984 | + if ($globalDebug) { |
|
| 1985 | + echo "Add to DB..."; |
|
| 1986 | + } |
|
| 1743 | 1987 | $error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln'); |
| 1744 | - } else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed."; |
|
| 1988 | + } else { |
|
| 1989 | + $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed."; |
|
| 1990 | + } |
|
| 1745 | 1991 | if ($error != '') { |
| 1746 | 1992 | return $error; |
| 1747 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1993 | + } elseif ($globalDebug) { |
|
| 1994 | + echo "Done\n"; |
|
| 1995 | + } |
|
| 1748 | 1996 | return ''; |
| 1749 | 1997 | } |
| 1750 | 1998 | |
| 1751 | 1999 | public static function update_ModeS_ogn() { |
| 1752 | 2000 | global $tmp_dir, $globalDebug; |
| 1753 | - if ($globalDebug) echo "Modes OGN: Download..."; |
|
| 2001 | + if ($globalDebug) { |
|
| 2002 | + echo "Modes OGN: Download..."; |
|
| 2003 | + } |
|
| 1754 | 2004 | update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv'); |
| 1755 | 2005 | if (file_exists($tmp_dir.'ogn.csv')) { |
| 1756 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2006 | + if ($globalDebug) { |
|
| 2007 | + echo "Add to DB..."; |
|
| 2008 | + } |
|
| 1757 | 2009 | $error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv'); |
| 1758 | - } else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed."; |
|
| 2010 | + } else { |
|
| 2011 | + $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed."; |
|
| 2012 | + } |
|
| 1759 | 2013 | if ($error != '') { |
| 1760 | 2014 | return $error; |
| 1761 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2015 | + } elseif ($globalDebug) { |
|
| 2016 | + echo "Done\n"; |
|
| 2017 | + } |
|
| 1762 | 2018 | return ''; |
| 1763 | 2019 | } |
| 1764 | 2020 | |
| 1765 | 2021 | public static function update_owner() { |
| 1766 | 2022 | global $tmp_dir, $globalDebug, $globalMasterSource; |
| 1767 | 2023 | |
| 1768 | - if ($globalDebug) echo "Owner France: Download..."; |
|
| 2024 | + if ($globalDebug) { |
|
| 2025 | + echo "Owner France: Download..."; |
|
| 2026 | + } |
|
| 1769 | 2027 | update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv'); |
| 1770 | 2028 | if (file_exists($tmp_dir.'owner_f.csv')) { |
| 1771 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2029 | + if ($globalDebug) { |
|
| 2030 | + echo "Add to DB..."; |
|
| 2031 | + } |
|
| 1772 | 2032 | $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F'); |
| 1773 | - } else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
|
| 2033 | + } else { |
|
| 2034 | + $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
|
| 2035 | + } |
|
| 1774 | 2036 | if ($error != '') { |
| 1775 | 2037 | return $error; |
| 1776 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2038 | + } elseif ($globalDebug) { |
|
| 2039 | + echo "Done\n"; |
|
| 2040 | + } |
|
| 1777 | 2041 | |
| 1778 | - if ($globalDebug) echo "Owner Ireland: Download..."; |
|
| 2042 | + if ($globalDebug) { |
|
| 2043 | + echo "Owner Ireland: Download..."; |
|
| 2044 | + } |
|
| 1779 | 2045 | update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv'); |
| 1780 | 2046 | if (file_exists($tmp_dir.'owner_ei.csv')) { |
| 1781 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2047 | + if ($globalDebug) { |
|
| 2048 | + echo "Add to DB..."; |
|
| 2049 | + } |
|
| 1782 | 2050 | $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI'); |
| 1783 | - } else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
|
| 2051 | + } else { |
|
| 2052 | + $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
|
| 2053 | + } |
|
| 1784 | 2054 | if ($error != '') { |
| 1785 | 2055 | return $error; |
| 1786 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1787 | - if ($globalDebug) echo "Owner Switzerland: Download..."; |
|
| 2056 | + } elseif ($globalDebug) { |
|
| 2057 | + echo "Done\n"; |
|
| 2058 | + } |
|
| 2059 | + if ($globalDebug) { |
|
| 2060 | + echo "Owner Switzerland: Download..."; |
|
| 2061 | + } |
|
| 1788 | 2062 | update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv'); |
| 1789 | 2063 | if (file_exists($tmp_dir.'owner_hb.csv')) { |
| 1790 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2064 | + if ($globalDebug) { |
|
| 2065 | + echo "Add to DB..."; |
|
| 2066 | + } |
|
| 1791 | 2067 | $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB'); |
| 1792 | - } else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
|
| 2068 | + } else { |
|
| 2069 | + $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
|
| 2070 | + } |
|
| 1793 | 2071 | if ($error != '') { |
| 1794 | 2072 | return $error; |
| 1795 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1796 | - if ($globalDebug) echo "Owner Czech Republic: Download..."; |
|
| 2073 | + } elseif ($globalDebug) { |
|
| 2074 | + echo "Done\n"; |
|
| 2075 | + } |
|
| 2076 | + if ($globalDebug) { |
|
| 2077 | + echo "Owner Czech Republic: Download..."; |
|
| 2078 | + } |
|
| 1797 | 2079 | update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv'); |
| 1798 | 2080 | if (file_exists($tmp_dir.'owner_ok.csv')) { |
| 1799 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2081 | + if ($globalDebug) { |
|
| 2082 | + echo "Add to DB..."; |
|
| 2083 | + } |
|
| 1800 | 2084 | $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK'); |
| 1801 | - } else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
|
| 2085 | + } else { |
|
| 2086 | + $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
|
| 2087 | + } |
|
| 1802 | 2088 | if ($error != '') { |
| 1803 | 2089 | return $error; |
| 1804 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1805 | - if ($globalDebug) echo "Owner Australia: Download..."; |
|
| 2090 | + } elseif ($globalDebug) { |
|
| 2091 | + echo "Done\n"; |
|
| 2092 | + } |
|
| 2093 | + if ($globalDebug) { |
|
| 2094 | + echo "Owner Australia: Download..."; |
|
| 2095 | + } |
|
| 1806 | 2096 | update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv'); |
| 1807 | 2097 | if (file_exists($tmp_dir.'owner_vh.csv')) { |
| 1808 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2098 | + if ($globalDebug) { |
|
| 2099 | + echo "Add to DB..."; |
|
| 2100 | + } |
|
| 1809 | 2101 | $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH'); |
| 1810 | - } else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
|
| 2102 | + } else { |
|
| 2103 | + $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
|
| 2104 | + } |
|
| 1811 | 2105 | if ($error != '') { |
| 1812 | 2106 | return $error; |
| 1813 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1814 | - if ($globalDebug) echo "Owner Austria: Download..."; |
|
| 2107 | + } elseif ($globalDebug) { |
|
| 2108 | + echo "Done\n"; |
|
| 2109 | + } |
|
| 2110 | + if ($globalDebug) { |
|
| 2111 | + echo "Owner Austria: Download..."; |
|
| 2112 | + } |
|
| 1815 | 2113 | update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv'); |
| 1816 | 2114 | if (file_exists($tmp_dir.'owner_oe.csv')) { |
| 1817 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2115 | + if ($globalDebug) { |
|
| 2116 | + echo "Add to DB..."; |
|
| 2117 | + } |
|
| 1818 | 2118 | $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE'); |
| 1819 | - } else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
|
| 2119 | + } else { |
|
| 2120 | + $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
|
| 2121 | + } |
|
| 1820 | 2122 | if ($error != '') { |
| 1821 | 2123 | return $error; |
| 1822 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1823 | - if ($globalDebug) echo "Owner Chile: Download..."; |
|
| 2124 | + } elseif ($globalDebug) { |
|
| 2125 | + echo "Done\n"; |
|
| 2126 | + } |
|
| 2127 | + if ($globalDebug) { |
|
| 2128 | + echo "Owner Chile: Download..."; |
|
| 2129 | + } |
|
| 1824 | 2130 | update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv'); |
| 1825 | 2131 | if (file_exists($tmp_dir.'owner_cc.csv')) { |
| 1826 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2132 | + if ($globalDebug) { |
|
| 2133 | + echo "Add to DB..."; |
|
| 2134 | + } |
|
| 1827 | 2135 | $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC'); |
| 1828 | - } else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
|
| 2136 | + } else { |
|
| 2137 | + $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
|
| 2138 | + } |
|
| 1829 | 2139 | if ($error != '') { |
| 1830 | 2140 | return $error; |
| 1831 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1832 | - if ($globalDebug) echo "Owner Colombia: Download..."; |
|
| 2141 | + } elseif ($globalDebug) { |
|
| 2142 | + echo "Done\n"; |
|
| 2143 | + } |
|
| 2144 | + if ($globalDebug) { |
|
| 2145 | + echo "Owner Colombia: Download..."; |
|
| 2146 | + } |
|
| 1833 | 2147 | update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv'); |
| 1834 | 2148 | if (file_exists($tmp_dir.'owner_hj.csv')) { |
| 1835 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2149 | + if ($globalDebug) { |
|
| 2150 | + echo "Add to DB..."; |
|
| 2151 | + } |
|
| 1836 | 2152 | $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ'); |
| 1837 | - } else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
|
| 2153 | + } else { |
|
| 2154 | + $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
|
| 2155 | + } |
|
| 1838 | 2156 | if ($error != '') { |
| 1839 | 2157 | return $error; |
| 1840 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1841 | - if ($globalDebug) echo "Owner Bosnia Herzegobina: Download..."; |
|
| 2158 | + } elseif ($globalDebug) { |
|
| 2159 | + echo "Done\n"; |
|
| 2160 | + } |
|
| 2161 | + if ($globalDebug) { |
|
| 2162 | + echo "Owner Bosnia Herzegobina: Download..."; |
|
| 2163 | + } |
|
| 1842 | 2164 | update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv'); |
| 1843 | 2165 | if (file_exists($tmp_dir.'owner_e7.csv')) { |
| 1844 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2166 | + if ($globalDebug) { |
|
| 2167 | + echo "Add to DB..."; |
|
| 2168 | + } |
|
| 1845 | 2169 | $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7'); |
| 1846 | - } else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
|
| 2170 | + } else { |
|
| 2171 | + $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
|
| 2172 | + } |
|
| 1847 | 2173 | if ($error != '') { |
| 1848 | 2174 | return $error; |
| 1849 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1850 | - if ($globalDebug) echo "Owner Brazil: Download..."; |
|
| 2175 | + } elseif ($globalDebug) { |
|
| 2176 | + echo "Done\n"; |
|
| 2177 | + } |
|
| 2178 | + if ($globalDebug) { |
|
| 2179 | + echo "Owner Brazil: Download..."; |
|
| 2180 | + } |
|
| 1851 | 2181 | update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv'); |
| 1852 | 2182 | if (file_exists($tmp_dir.'owner_pp.csv')) { |
| 1853 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2183 | + if ($globalDebug) { |
|
| 2184 | + echo "Add to DB..."; |
|
| 2185 | + } |
|
| 1854 | 2186 | $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP'); |
| 1855 | - } else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
|
| 2187 | + } else { |
|
| 2188 | + $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
|
| 2189 | + } |
|
| 1856 | 2190 | if ($error != '') { |
| 1857 | 2191 | return $error; |
| 1858 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1859 | - if ($globalDebug) echo "Owner Cayman Islands: Download..."; |
|
| 2192 | + } elseif ($globalDebug) { |
|
| 2193 | + echo "Done\n"; |
|
| 2194 | + } |
|
| 2195 | + if ($globalDebug) { |
|
| 2196 | + echo "Owner Cayman Islands: Download..."; |
|
| 2197 | + } |
|
| 1860 | 2198 | update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv'); |
| 1861 | 2199 | if (file_exists($tmp_dir.'owner_vp.csv')) { |
| 1862 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2200 | + if ($globalDebug) { |
|
| 2201 | + echo "Add to DB..."; |
|
| 2202 | + } |
|
| 1863 | 2203 | $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP'); |
| 1864 | - } else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
|
| 2204 | + } else { |
|
| 2205 | + $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
|
| 2206 | + } |
|
| 1865 | 2207 | if ($error != '') { |
| 1866 | 2208 | return $error; |
| 1867 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1868 | - if ($globalDebug) echo "Owner Croatia: Download..."; |
|
| 2209 | + } elseif ($globalDebug) { |
|
| 2210 | + echo "Done\n"; |
|
| 2211 | + } |
|
| 2212 | + if ($globalDebug) { |
|
| 2213 | + echo "Owner Croatia: Download..."; |
|
| 2214 | + } |
|
| 1869 | 2215 | update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv'); |
| 1870 | 2216 | if (file_exists($tmp_dir.'owner_9a.csv')) { |
| 1871 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2217 | + if ($globalDebug) { |
|
| 2218 | + echo "Add to DB..."; |
|
| 2219 | + } |
|
| 1872 | 2220 | $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A'); |
| 1873 | - } else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
|
| 2221 | + } else { |
|
| 2222 | + $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
|
| 2223 | + } |
|
| 1874 | 2224 | if ($error != '') { |
| 1875 | 2225 | return $error; |
| 1876 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1877 | - if ($globalDebug) echo "Owner Luxembourg: Download..."; |
|
| 2226 | + } elseif ($globalDebug) { |
|
| 2227 | + echo "Done\n"; |
|
| 2228 | + } |
|
| 2229 | + if ($globalDebug) { |
|
| 2230 | + echo "Owner Luxembourg: Download..."; |
|
| 2231 | + } |
|
| 1878 | 2232 | update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv'); |
| 1879 | 2233 | if (file_exists($tmp_dir.'owner_lx.csv')) { |
| 1880 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2234 | + if ($globalDebug) { |
|
| 2235 | + echo "Add to DB..."; |
|
| 2236 | + } |
|
| 1881 | 2237 | $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX'); |
| 1882 | - } else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
|
| 2238 | + } else { |
|
| 2239 | + $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
|
| 2240 | + } |
|
| 1883 | 2241 | if ($error != '') { |
| 1884 | 2242 | return $error; |
| 1885 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1886 | - if ($globalDebug) echo "Owner Maldives: Download..."; |
|
| 2243 | + } elseif ($globalDebug) { |
|
| 2244 | + echo "Done\n"; |
|
| 2245 | + } |
|
| 2246 | + if ($globalDebug) { |
|
| 2247 | + echo "Owner Maldives: Download..."; |
|
| 2248 | + } |
|
| 1887 | 2249 | update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv'); |
| 1888 | 2250 | if (file_exists($tmp_dir.'owner_8q.csv')) { |
| 1889 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2251 | + if ($globalDebug) { |
|
| 2252 | + echo "Add to DB..."; |
|
| 2253 | + } |
|
| 1890 | 2254 | $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q'); |
| 1891 | - } else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
|
| 2255 | + } else { |
|
| 2256 | + $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
|
| 2257 | + } |
|
| 1892 | 2258 | if ($error != '') { |
| 1893 | 2259 | return $error; |
| 1894 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1895 | - if ($globalDebug) echo "Owner New Zealand: Download..."; |
|
| 2260 | + } elseif ($globalDebug) { |
|
| 2261 | + echo "Done\n"; |
|
| 2262 | + } |
|
| 2263 | + if ($globalDebug) { |
|
| 2264 | + echo "Owner New Zealand: Download..."; |
|
| 2265 | + } |
|
| 1896 | 2266 | update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv'); |
| 1897 | 2267 | if (file_exists($tmp_dir.'owner_zk.csv')) { |
| 1898 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2268 | + if ($globalDebug) { |
|
| 2269 | + echo "Add to DB..."; |
|
| 2270 | + } |
|
| 1899 | 2271 | $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK'); |
| 1900 | - } else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
|
| 2272 | + } else { |
|
| 2273 | + $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
|
| 2274 | + } |
|
| 1901 | 2275 | if ($error != '') { |
| 1902 | 2276 | return $error; |
| 1903 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1904 | - if ($globalDebug) echo "Owner Papua New Guinea: Download..."; |
|
| 2277 | + } elseif ($globalDebug) { |
|
| 2278 | + echo "Done\n"; |
|
| 2279 | + } |
|
| 2280 | + if ($globalDebug) { |
|
| 2281 | + echo "Owner Papua New Guinea: Download..."; |
|
| 2282 | + } |
|
| 1905 | 2283 | update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv'); |
| 1906 | 2284 | if (file_exists($tmp_dir.'owner_p2.csv')) { |
| 1907 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2285 | + if ($globalDebug) { |
|
| 2286 | + echo "Add to DB..."; |
|
| 2287 | + } |
|
| 1908 | 2288 | $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2'); |
| 1909 | - } else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
|
| 2289 | + } else { |
|
| 2290 | + $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
|
| 2291 | + } |
|
| 1910 | 2292 | if ($error != '') { |
| 1911 | 2293 | return $error; |
| 1912 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1913 | - if ($globalDebug) echo "Owner Slovakia: Download..."; |
|
| 2294 | + } elseif ($globalDebug) { |
|
| 2295 | + echo "Done\n"; |
|
| 2296 | + } |
|
| 2297 | + if ($globalDebug) { |
|
| 2298 | + echo "Owner Slovakia: Download..."; |
|
| 2299 | + } |
|
| 1914 | 2300 | update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv'); |
| 1915 | 2301 | if (file_exists($tmp_dir.'owner_om.csv')) { |
| 1916 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2302 | + if ($globalDebug) { |
|
| 2303 | + echo "Add to DB..."; |
|
| 2304 | + } |
|
| 1917 | 2305 | $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM'); |
| 1918 | - } else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
|
| 2306 | + } else { |
|
| 2307 | + $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
|
| 2308 | + } |
|
| 1919 | 2309 | if ($error != '') { |
| 1920 | 2310 | return $error; |
| 1921 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1922 | - if ($globalDebug) echo "Owner Ecuador: Download..."; |
|
| 2311 | + } elseif ($globalDebug) { |
|
| 2312 | + echo "Done\n"; |
|
| 2313 | + } |
|
| 2314 | + if ($globalDebug) { |
|
| 2315 | + echo "Owner Ecuador: Download..."; |
|
| 2316 | + } |
|
| 1923 | 2317 | update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv'); |
| 1924 | 2318 | if (file_exists($tmp_dir.'owner_hc.csv')) { |
| 1925 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2319 | + if ($globalDebug) { |
|
| 2320 | + echo "Add to DB..."; |
|
| 2321 | + } |
|
| 1926 | 2322 | $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC'); |
| 1927 | - } else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
|
| 2323 | + } else { |
|
| 2324 | + $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
|
| 2325 | + } |
|
| 1928 | 2326 | if ($error != '') { |
| 1929 | 2327 | return $error; |
| 1930 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1931 | - if ($globalDebug) echo "Owner Iceland: Download..."; |
|
| 2328 | + } elseif ($globalDebug) { |
|
| 2329 | + echo "Done\n"; |
|
| 2330 | + } |
|
| 2331 | + if ($globalDebug) { |
|
| 2332 | + echo "Owner Iceland: Download..."; |
|
| 2333 | + } |
|
| 1932 | 2334 | update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv'); |
| 1933 | 2335 | if (file_exists($tmp_dir.'owner_tf.csv')) { |
| 1934 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2336 | + if ($globalDebug) { |
|
| 2337 | + echo "Add to DB..."; |
|
| 2338 | + } |
|
| 1935 | 2339 | $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF'); |
| 1936 | - } else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
|
| 2340 | + } else { |
|
| 2341 | + $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
|
| 2342 | + } |
|
| 1937 | 2343 | if ($error != '') { |
| 1938 | 2344 | return $error; |
| 1939 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1940 | - if ($globalDebug) echo "Owner Isle of Man: Download..."; |
|
| 2345 | + } elseif ($globalDebug) { |
|
| 2346 | + echo "Done\n"; |
|
| 2347 | + } |
|
| 2348 | + if ($globalDebug) { |
|
| 2349 | + echo "Owner Isle of Man: Download..."; |
|
| 2350 | + } |
|
| 1941 | 2351 | update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv'); |
| 1942 | 2352 | if (file_exists($tmp_dir.'owner_m.csv')) { |
| 1943 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2353 | + if ($globalDebug) { |
|
| 2354 | + echo "Add to DB..."; |
|
| 2355 | + } |
|
| 1944 | 2356 | $error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M'); |
| 1945 | - } else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed."; |
|
| 2357 | + } else { |
|
| 2358 | + $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed."; |
|
| 2359 | + } |
|
| 1946 | 2360 | if ($error != '') { |
| 1947 | 2361 | return $error; |
| 1948 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2362 | + } elseif ($globalDebug) { |
|
| 2363 | + echo "Done\n"; |
|
| 2364 | + } |
|
| 1949 | 2365 | if ($globalMasterSource) { |
| 1950 | - if ($globalDebug) echo "ModeS Netherlands: Download..."; |
|
| 2366 | + if ($globalDebug) { |
|
| 2367 | + echo "ModeS Netherlands: Download..."; |
|
| 2368 | + } |
|
| 1951 | 2369 | update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv'); |
| 1952 | 2370 | if (file_exists($tmp_dir.'owner_ph.csv')) { |
| 1953 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2371 | + if ($globalDebug) { |
|
| 2372 | + echo "Add to DB..."; |
|
| 2373 | + } |
|
| 1954 | 2374 | $error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH'); |
| 1955 | - } else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed."; |
|
| 2375 | + } else { |
|
| 2376 | + $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed."; |
|
| 2377 | + } |
|
| 1956 | 2378 | if ($error != '') { |
| 1957 | 2379 | return $error; |
| 1958 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1959 | - if ($globalDebug) echo "ModeS Denmark: Download..."; |
|
| 2380 | + } elseif ($globalDebug) { |
|
| 2381 | + echo "Done\n"; |
|
| 2382 | + } |
|
| 2383 | + if ($globalDebug) { |
|
| 2384 | + echo "ModeS Denmark: Download..."; |
|
| 2385 | + } |
|
| 1960 | 2386 | update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv'); |
| 1961 | 2387 | if (file_exists($tmp_dir.'owner_oy.csv')) { |
| 1962 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2388 | + if ($globalDebug) { |
|
| 2389 | + echo "Add to DB..."; |
|
| 2390 | + } |
|
| 1963 | 2391 | $error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY'); |
| 1964 | - } else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed."; |
|
| 2392 | + } else { |
|
| 2393 | + $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed."; |
|
| 2394 | + } |
|
| 1965 | 2395 | if ($error != '') { |
| 1966 | 2396 | return $error; |
| 1967 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1968 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2397 | + } elseif ($globalDebug) { |
|
| 2398 | + echo "Done\n"; |
|
| 2399 | + } |
|
| 2400 | + } elseif ($globalDebug) { |
|
| 2401 | + echo "Done\n"; |
|
| 2402 | + } |
|
| 1969 | 2403 | return ''; |
| 1970 | 2404 | } |
| 1971 | 2405 | |
| 1972 | 2406 | public static function update_translation() { |
| 1973 | 2407 | global $tmp_dir, $globalDebug; |
| 1974 | 2408 | $error = ''; |
| 1975 | - if ($globalDebug) echo "Translation : Download..."; |
|
| 2409 | + if ($globalDebug) { |
|
| 2410 | + echo "Translation : Download..."; |
|
| 2411 | + } |
|
| 1976 | 2412 | update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip'); |
| 1977 | 2413 | if (file_exists($tmp_dir.'translation.zip')) { |
| 1978 | - if ($globalDebug) echo "Unzip..."; |
|
| 2414 | + if ($globalDebug) { |
|
| 2415 | + echo "Unzip..."; |
|
| 2416 | + } |
|
| 1979 | 2417 | update_db::unzip($tmp_dir.'translation.zip'); |
| 1980 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2418 | + if ($globalDebug) { |
|
| 2419 | + echo "Add to DB..."; |
|
| 2420 | + } |
|
| 1981 | 2421 | $error = update_db::translation(); |
| 1982 | - } else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed."; |
|
| 2422 | + } else { |
|
| 2423 | + $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed."; |
|
| 2424 | + } |
|
| 1983 | 2425 | if ($error != '') { |
| 1984 | 2426 | return $error; |
| 1985 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2427 | + } elseif ($globalDebug) { |
|
| 2428 | + echo "Done\n"; |
|
| 2429 | + } |
|
| 1986 | 2430 | return ''; |
| 1987 | 2431 | } |
| 1988 | 2432 | |
| 1989 | 2433 | public static function update_translation_fam() { |
| 1990 | 2434 | global $tmp_dir, $globalDebug; |
| 1991 | - if ($globalDebug) echo "Translation from FlightAirMap website : Download..."; |
|
| 2435 | + if ($globalDebug) { |
|
| 2436 | + echo "Translation from FlightAirMap website : Download..."; |
|
| 2437 | + } |
|
| 1992 | 2438 | update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz'); |
| 1993 | 2439 | if (file_exists($tmp_dir.'translation.tsv.gz')) { |
| 1994 | - if ($globalDebug) echo "Gunzip..."; |
|
| 2440 | + if ($globalDebug) { |
|
| 2441 | + echo "Gunzip..."; |
|
| 2442 | + } |
|
| 1995 | 2443 | update_db::gunzip($tmp_dir.'translation.tsv.gz'); |
| 1996 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2444 | + if ($globalDebug) { |
|
| 2445 | + echo "Add to DB..."; |
|
| 2446 | + } |
|
| 1997 | 2447 | $error = update_db::translation_fam(); |
| 1998 | - } else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed."; |
|
| 2448 | + } else { |
|
| 2449 | + $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed."; |
|
| 2450 | + } |
|
| 1999 | 2451 | if ($error != '') { |
| 2000 | 2452 | return $error; |
| 2001 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2453 | + } elseif ($globalDebug) { |
|
| 2454 | + echo "Done\n"; |
|
| 2455 | + } |
|
| 2002 | 2456 | return ''; |
| 2003 | 2457 | } |
| 2004 | 2458 | public static function update_ModeS_fam() { |
| 2005 | 2459 | global $tmp_dir, $globalDebug; |
| 2006 | - if ($globalDebug) echo "ModeS from FlightAirMap website : Download..."; |
|
| 2460 | + if ($globalDebug) { |
|
| 2461 | + echo "ModeS from FlightAirMap website : Download..."; |
|
| 2462 | + } |
|
| 2007 | 2463 | update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz'); |
| 2008 | 2464 | if (file_exists($tmp_dir.'modes.tsv.gz')) { |
| 2009 | - if ($globalDebug) echo "Gunzip..."; |
|
| 2465 | + if ($globalDebug) { |
|
| 2466 | + echo "Gunzip..."; |
|
| 2467 | + } |
|
| 2010 | 2468 | update_db::gunzip($tmp_dir.'modes.tsv.gz'); |
| 2011 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2469 | + if ($globalDebug) { |
|
| 2470 | + echo "Add to DB..."; |
|
| 2471 | + } |
|
| 2012 | 2472 | $error = update_db::modes_fam(); |
| 2013 | - } else $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed."; |
|
| 2473 | + } else { |
|
| 2474 | + $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed."; |
|
| 2475 | + } |
|
| 2014 | 2476 | if ($error != '') { |
| 2015 | 2477 | return $error; |
| 2016 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2478 | + } elseif ($globalDebug) { |
|
| 2479 | + echo "Done\n"; |
|
| 2480 | + } |
|
| 2017 | 2481 | return ''; |
| 2018 | 2482 | } |
| 2019 | 2483 | public static function update_owner_fam() { |
| 2020 | 2484 | global $tmp_dir, $globalDebug, $globalOwner; |
| 2021 | - if ($globalDebug) echo "owner from FlightAirMap website : Download..."; |
|
| 2485 | + if ($globalDebug) { |
|
| 2486 | + echo "owner from FlightAirMap website : Download..."; |
|
| 2487 | + } |
|
| 2022 | 2488 | if ($globalOwner === TRUE) { |
| 2023 | 2489 | update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz'); |
| 2024 | 2490 | } else { |
| 2025 | 2491 | update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz',$tmp_dir.'owners.tsv.gz'); |
| 2026 | 2492 | } |
| 2027 | 2493 | if (file_exists($tmp_dir.'owners.tsv.gz')) { |
| 2028 | - if ($globalDebug) echo "Gunzip..."; |
|
| 2494 | + if ($globalDebug) { |
|
| 2495 | + echo "Gunzip..."; |
|
| 2496 | + } |
|
| 2029 | 2497 | update_db::gunzip($tmp_dir.'owners.tsv.gz'); |
| 2030 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2498 | + if ($globalDebug) { |
|
| 2499 | + echo "Add to DB..."; |
|
| 2500 | + } |
|
| 2031 | 2501 | $error = update_db::owner_fam(); |
| 2032 | - } else $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed."; |
|
| 2502 | + } else { |
|
| 2503 | + $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed."; |
|
| 2504 | + } |
|
| 2033 | 2505 | if ($error != '') { |
| 2034 | 2506 | return $error; |
| 2035 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2507 | + } elseif ($globalDebug) { |
|
| 2508 | + echo "Done\n"; |
|
| 2509 | + } |
|
| 2036 | 2510 | return ''; |
| 2037 | 2511 | } |
| 2038 | 2512 | public static function update_routes_fam() { |
| 2039 | 2513 | global $tmp_dir, $globalDebug; |
| 2040 | - if ($globalDebug) echo "Routes from FlightAirMap website : Download..."; |
|
| 2514 | + if ($globalDebug) { |
|
| 2515 | + echo "Routes from FlightAirMap website : Download..."; |
|
| 2516 | + } |
|
| 2041 | 2517 | update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz'); |
| 2042 | 2518 | if (file_exists($tmp_dir.'routes.tsv.gz')) { |
| 2043 | - if ($globalDebug) echo "Gunzip..."; |
|
| 2519 | + if ($globalDebug) { |
|
| 2520 | + echo "Gunzip..."; |
|
| 2521 | + } |
|
| 2044 | 2522 | update_db::gunzip($tmp_dir.'routes.tsv.gz'); |
| 2045 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2523 | + if ($globalDebug) { |
|
| 2524 | + echo "Add to DB..."; |
|
| 2525 | + } |
|
| 2046 | 2526 | $error = update_db::routes_fam(); |
| 2047 | - } else $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed."; |
|
| 2527 | + } else { |
|
| 2528 | + $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed."; |
|
| 2529 | + } |
|
| 2048 | 2530 | if ($error != '') { |
| 2049 | 2531 | return $error; |
| 2050 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2532 | + } elseif ($globalDebug) { |
|
| 2533 | + echo "Done\n"; |
|
| 2534 | + } |
|
| 2051 | 2535 | return ''; |
| 2052 | 2536 | } |
| 2053 | 2537 | public static function update_marine_identity_fam() { |
@@ -2057,14 +2541,22 @@ discard block |
||
| 2057 | 2541 | $marine_identity_md5_file = explode(' ',file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5')); |
| 2058 | 2542 | $marine_identity_md5 = $marine_identity_md5_file[0]; |
| 2059 | 2543 | if (!update_db::check_marine_identity_version($marine_identity_md5)) { |
| 2060 | - if ($globalDebug) echo "Marine identity from FlightAirMap website : Download..."; |
|
| 2544 | + if ($globalDebug) { |
|
| 2545 | + echo "Marine identity from FlightAirMap website : Download..."; |
|
| 2546 | + } |
|
| 2061 | 2547 | update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz',$tmp_dir.'marine_identity.tsv.gz'); |
| 2062 | 2548 | if (file_exists($tmp_dir.'marine_identity.tsv.gz')) { |
| 2063 | - if ($globalDebug) echo "Gunzip..."; |
|
| 2549 | + if ($globalDebug) { |
|
| 2550 | + echo "Gunzip..."; |
|
| 2551 | + } |
|
| 2064 | 2552 | update_db::gunzip($tmp_dir.'marine_identity.tsv.gz'); |
| 2065 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2553 | + if ($globalDebug) { |
|
| 2554 | + echo "Add to DB..."; |
|
| 2555 | + } |
|
| 2066 | 2556 | $error = update_db::marine_identity_fam(); |
| 2067 | - } else $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed."; |
|
| 2557 | + } else { |
|
| 2558 | + $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed."; |
|
| 2559 | + } |
|
| 2068 | 2560 | if ($error != '') { |
| 2069 | 2561 | return $error; |
| 2070 | 2562 | } elseif ($globalDebug) { |
@@ -2077,17 +2569,25 @@ discard block |
||
| 2077 | 2569 | } |
| 2078 | 2570 | public static function update_banned_fam() { |
| 2079 | 2571 | global $tmp_dir, $globalDebug; |
| 2080 | - if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download..."; |
|
| 2572 | + if ($globalDebug) { |
|
| 2573 | + echo "Banned airlines in Europe from FlightAirMap website : Download..."; |
|
| 2574 | + } |
|
| 2081 | 2575 | update_db::download('http://data.flightairmap.fr/data/ban-eu.csv',$tmp_dir.'ban_eu.csv'); |
| 2082 | 2576 | if (file_exists($tmp_dir.'ban_eu.csv')) { |
| 2083 | 2577 | //if ($globalDebug) echo "Gunzip..."; |
| 2084 | 2578 | //update_db::gunzip($tmp_dir.'ban_ue.csv'); |
| 2085 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2579 | + if ($globalDebug) { |
|
| 2580 | + echo "Add to DB..."; |
|
| 2581 | + } |
|
| 2086 | 2582 | $error = update_db::banned_fam(); |
| 2087 | - } else $error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed."; |
|
| 2583 | + } else { |
|
| 2584 | + $error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed."; |
|
| 2585 | + } |
|
| 2088 | 2586 | if ($error != '') { |
| 2089 | 2587 | return $error; |
| 2090 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2588 | + } elseif ($globalDebug) { |
|
| 2589 | + echo "Done\n"; |
|
| 2590 | + } |
|
| 2091 | 2591 | return ''; |
| 2092 | 2592 | } |
| 2093 | 2593 | |
@@ -2095,7 +2595,9 @@ discard block |
||
| 2095 | 2595 | global $tmp_dir, $globalDebug, $globalDBdriver; |
| 2096 | 2596 | include_once('class.create_db.php'); |
| 2097 | 2597 | $error = ''; |
| 2098 | - if ($globalDebug) echo "Airspace from FlightAirMap website : Download..."; |
|
| 2598 | + if ($globalDebug) { |
|
| 2599 | + echo "Airspace from FlightAirMap website : Download..."; |
|
| 2600 | + } |
|
| 2099 | 2601 | if ($globalDBdriver == 'mysql') { |
| 2100 | 2602 | update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); |
| 2101 | 2603 | } else { |
@@ -2111,9 +2613,13 @@ discard block |
||
| 2111 | 2613 | update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz'); |
| 2112 | 2614 | } |
| 2113 | 2615 | if (file_exists($tmp_dir.'airspace.sql.gz')) { |
| 2114 | - if ($globalDebug) echo "Gunzip..."; |
|
| 2616 | + if ($globalDebug) { |
|
| 2617 | + echo "Gunzip..."; |
|
| 2618 | + } |
|
| 2115 | 2619 | update_db::gunzip($tmp_dir.'airspace.sql.gz'); |
| 2116 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2620 | + if ($globalDebug) { |
|
| 2621 | + echo "Add to DB..."; |
|
| 2622 | + } |
|
| 2117 | 2623 | $Connection = new Connection(); |
| 2118 | 2624 | if ($Connection->tableExists('airspace')) { |
| 2119 | 2625 | $query = 'DROP TABLE airspace'; |
@@ -2126,19 +2632,27 @@ discard block |
||
| 2126 | 2632 | } |
| 2127 | 2633 | $error = create_db::import_file($tmp_dir.'airspace.sql'); |
| 2128 | 2634 | update_db::insert_airspace_version($airspace_md5); |
| 2129 | - } else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed."; |
|
| 2635 | + } else { |
|
| 2636 | + $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed."; |
|
| 2637 | + } |
|
| 2130 | 2638 | } |
| 2131 | - } else $error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed."; |
|
| 2639 | + } else { |
|
| 2640 | + $error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed."; |
|
| 2641 | + } |
|
| 2132 | 2642 | if ($error != '') { |
| 2133 | 2643 | return $error; |
| 2134 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2644 | + } elseif ($globalDebug) { |
|
| 2645 | + echo "Done\n"; |
|
| 2646 | + } |
|
| 2135 | 2647 | return ''; |
| 2136 | 2648 | } |
| 2137 | 2649 | |
| 2138 | 2650 | public static function update_geoid_fam() { |
| 2139 | 2651 | global $tmp_dir, $globalDebug, $globalGeoidSource; |
| 2140 | 2652 | $error = ''; |
| 2141 | - if ($globalDebug) echo "Geoid from FlightAirMap website : Download..."; |
|
| 2653 | + if ($globalDebug) { |
|
| 2654 | + echo "Geoid from FlightAirMap website : Download..."; |
|
| 2655 | + } |
|
| 2142 | 2656 | update_db::download('http://data.flightairmap.fr/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5',$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'); |
| 2143 | 2657 | if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')) { |
| 2144 | 2658 | $geoid_md5_file = explode(' ',file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')); |
@@ -2146,36 +2660,54 @@ discard block |
||
| 2146 | 2660 | if (!update_db::check_geoid_version($geoid_md5)) { |
| 2147 | 2661 | update_db::download('http://data.flightairmap.fr/data/geoid/'.$globalGeoidSource.'.pgm.gz',$tmp_dir.$globalGeoidSource.'.pgm.gz'); |
| 2148 | 2662 | if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz')) { |
| 2149 | - if ($globalDebug) echo "Gunzip..."; |
|
| 2663 | + if ($globalDebug) { |
|
| 2664 | + echo "Gunzip..."; |
|
| 2665 | + } |
|
| 2150 | 2666 | update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz',dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm'); |
| 2151 | 2667 | if (file_exists(dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm')) { |
| 2152 | 2668 | update_db::insert_geoid_version($geoid_md5); |
| 2153 | 2669 | } |
| 2154 | - } else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed."; |
|
| 2670 | + } else { |
|
| 2671 | + $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed."; |
|
| 2672 | + } |
|
| 2155 | 2673 | } |
| 2156 | - } else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed."; |
|
| 2674 | + } else { |
|
| 2675 | + $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed."; |
|
| 2676 | + } |
|
| 2157 | 2677 | if ($error != '') { |
| 2158 | 2678 | return $error; |
| 2159 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2679 | + } elseif ($globalDebug) { |
|
| 2680 | + echo "Done\n"; |
|
| 2681 | + } |
|
| 2160 | 2682 | return ''; |
| 2161 | 2683 | } |
| 2162 | 2684 | |
| 2163 | 2685 | public static function update_tle() { |
| 2164 | 2686 | global $tmp_dir, $globalDebug; |
| 2165 | - if ($globalDebug) echo "Download TLE : Download..."; |
|
| 2687 | + if ($globalDebug) { |
|
| 2688 | + echo "Download TLE : Download..."; |
|
| 2689 | + } |
|
| 2166 | 2690 | $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', |
| 2167 | 2691 | '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', |
| 2168 | 2692 | 'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt'); |
| 2169 | 2693 | foreach ($alltle as $filename) { |
| 2170 | - if ($globalDebug) echo "downloading ".$filename.'...'; |
|
| 2694 | + if ($globalDebug) { |
|
| 2695 | + echo "downloading ".$filename.'...'; |
|
| 2696 | + } |
|
| 2171 | 2697 | update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename); |
| 2172 | 2698 | if (file_exists($tmp_dir.$filename)) { |
| 2173 | - if ($globalDebug) echo "Add to DB ".$filename."..."; |
|
| 2699 | + if ($globalDebug) { |
|
| 2700 | + echo "Add to DB ".$filename."..."; |
|
| 2701 | + } |
|
| 2174 | 2702 | $error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename)); |
| 2175 | - } else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
|
| 2703 | + } else { |
|
| 2704 | + $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
|
| 2705 | + } |
|
| 2176 | 2706 | if ($error != '') { |
| 2177 | 2707 | echo $error."\n"; |
| 2178 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2708 | + } elseif ($globalDebug) { |
|
| 2709 | + echo "Done\n"; |
|
| 2710 | + } |
|
| 2179 | 2711 | } |
| 2180 | 2712 | return ''; |
| 2181 | 2713 | } |
@@ -2183,10 +2715,14 @@ discard block |
||
| 2183 | 2715 | public static function update_models() { |
| 2184 | 2716 | global $tmp_dir, $globalDebug; |
| 2185 | 2717 | $error = ''; |
| 2186 | - if ($globalDebug) echo "Models from FlightAirMap website : Download..."; |
|
| 2718 | + if ($globalDebug) { |
|
| 2719 | + echo "Models from FlightAirMap website : Download..."; |
|
| 2720 | + } |
|
| 2187 | 2721 | update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum'); |
| 2188 | 2722 | if (file_exists($tmp_dir.'models.md5sum')) { |
| 2189 | - if ($globalDebug) echo "Check files...\n"; |
|
| 2723 | + if ($globalDebug) { |
|
| 2724 | + echo "Check files...\n"; |
|
| 2725 | + } |
|
| 2190 | 2726 | $newmodelsdb = array(); |
| 2191 | 2727 | if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) { |
| 2192 | 2728 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2205,25 +2741,35 @@ discard block |
||
| 2205 | 2741 | } |
| 2206 | 2742 | $diff = array_diff($newmodelsdb,$modelsdb); |
| 2207 | 2743 | foreach ($diff as $key => $value) { |
| 2208 | - if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n"; |
|
| 2744 | + if ($globalDebug) { |
|
| 2745 | + echo 'Downloading model '.$key.' ...'."\n"; |
|
| 2746 | + } |
|
| 2209 | 2747 | update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key); |
| 2210 | 2748 | |
| 2211 | 2749 | } |
| 2212 | 2750 | update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum'); |
| 2213 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 2751 | + } else { |
|
| 2752 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 2753 | + } |
|
| 2214 | 2754 | if ($error != '') { |
| 2215 | 2755 | return $error; |
| 2216 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2756 | + } elseif ($globalDebug) { |
|
| 2757 | + echo "Done\n"; |
|
| 2758 | + } |
|
| 2217 | 2759 | return ''; |
| 2218 | 2760 | } |
| 2219 | 2761 | |
| 2220 | 2762 | public static function update_space_models() { |
| 2221 | 2763 | global $tmp_dir, $globalDebug; |
| 2222 | 2764 | $error = ''; |
| 2223 | - if ($globalDebug) echo "Space models from FlightAirMap website : Download..."; |
|
| 2765 | + if ($globalDebug) { |
|
| 2766 | + echo "Space models from FlightAirMap website : Download..."; |
|
| 2767 | + } |
|
| 2224 | 2768 | update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum'); |
| 2225 | 2769 | if (file_exists($tmp_dir.'space_models.md5sum')) { |
| 2226 | - if ($globalDebug) echo "Check files...\n"; |
|
| 2770 | + if ($globalDebug) { |
|
| 2771 | + echo "Check files...\n"; |
|
| 2772 | + } |
|
| 2227 | 2773 | $newmodelsdb = array(); |
| 2228 | 2774 | if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) { |
| 2229 | 2775 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2242,25 +2788,35 @@ discard block |
||
| 2242 | 2788 | } |
| 2243 | 2789 | $diff = array_diff($newmodelsdb,$modelsdb); |
| 2244 | 2790 | foreach ($diff as $key => $value) { |
| 2245 | - if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n"; |
|
| 2791 | + if ($globalDebug) { |
|
| 2792 | + echo 'Downloading space model '.$key.' ...'."\n"; |
|
| 2793 | + } |
|
| 2246 | 2794 | update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key); |
| 2247 | 2795 | |
| 2248 | 2796 | } |
| 2249 | 2797 | update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum'); |
| 2250 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 2798 | + } else { |
|
| 2799 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 2800 | + } |
|
| 2251 | 2801 | if ($error != '') { |
| 2252 | 2802 | return $error; |
| 2253 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2803 | + } elseif ($globalDebug) { |
|
| 2804 | + echo "Done\n"; |
|
| 2805 | + } |
|
| 2254 | 2806 | return ''; |
| 2255 | 2807 | } |
| 2256 | 2808 | |
| 2257 | 2809 | public static function update_vehicules_models() { |
| 2258 | 2810 | global $tmp_dir, $globalDebug; |
| 2259 | 2811 | $error = ''; |
| 2260 | - if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download..."; |
|
| 2812 | + if ($globalDebug) { |
|
| 2813 | + echo "Vehicules models from FlightAirMap website : Download..."; |
|
| 2814 | + } |
|
| 2261 | 2815 | update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum'); |
| 2262 | 2816 | if (file_exists($tmp_dir.'vehicules_models.md5sum')) { |
| 2263 | - if ($globalDebug) echo "Check files...\n"; |
|
| 2817 | + if ($globalDebug) { |
|
| 2818 | + echo "Check files...\n"; |
|
| 2819 | + } |
|
| 2264 | 2820 | $newmodelsdb = array(); |
| 2265 | 2821 | if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) { |
| 2266 | 2822 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2279,15 +2835,21 @@ discard block |
||
| 2279 | 2835 | } |
| 2280 | 2836 | $diff = array_diff($newmodelsdb,$modelsdb); |
| 2281 | 2837 | foreach ($diff as $key => $value) { |
| 2282 | - if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n"; |
|
| 2838 | + if ($globalDebug) { |
|
| 2839 | + echo 'Downloading vehicules model '.$key.' ...'."\n"; |
|
| 2840 | + } |
|
| 2283 | 2841 | update_db::download('http://data.flightairmap.fr/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key); |
| 2284 | 2842 | |
| 2285 | 2843 | } |
| 2286 | 2844 | update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum'); |
| 2287 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 2845 | + } else { |
|
| 2846 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 2847 | + } |
|
| 2288 | 2848 | if ($error != '') { |
| 2289 | 2849 | return $error; |
| 2290 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2850 | + } elseif ($globalDebug) { |
|
| 2851 | + echo "Done\n"; |
|
| 2852 | + } |
|
| 2291 | 2853 | return ''; |
| 2292 | 2854 | } |
| 2293 | 2855 | |
@@ -2330,7 +2892,9 @@ discard block |
||
| 2330 | 2892 | } |
| 2331 | 2893 | |
| 2332 | 2894 | $error = ''; |
| 2333 | - if ($globalDebug) echo "Notam : Download..."; |
|
| 2895 | + if ($globalDebug) { |
|
| 2896 | + echo "Notam : Download..."; |
|
| 2897 | + } |
|
| 2334 | 2898 | update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss'); |
| 2335 | 2899 | if (file_exists($tmp_dir.'notam.rss')) { |
| 2336 | 2900 | $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true); |
@@ -2345,14 +2909,30 @@ discard block |
||
| 2345 | 2909 | $data['fir'] = $q[0]; |
| 2346 | 2910 | $data['code'] = $q[1]; |
| 2347 | 2911 | $ifrvfr = $q[2]; |
| 2348 | - if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR'; |
|
| 2349 | - if ($ifrvfr == 'I') $data['rules'] = 'IFR'; |
|
| 2350 | - if ($ifrvfr == 'V') $data['rules'] = 'VFR'; |
|
| 2351 | - if ($q[4] == 'A') $data['scope'] = 'Airport warning'; |
|
| 2352 | - if ($q[4] == 'E') $data['scope'] = 'Enroute warning'; |
|
| 2353 | - if ($q[4] == 'W') $data['scope'] = 'Navigation warning'; |
|
| 2354 | - if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning'; |
|
| 2355 | - if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning'; |
|
| 2912 | + if ($ifrvfr == 'IV') { |
|
| 2913 | + $data['rules'] = 'IFR/VFR'; |
|
| 2914 | + } |
|
| 2915 | + if ($ifrvfr == 'I') { |
|
| 2916 | + $data['rules'] = 'IFR'; |
|
| 2917 | + } |
|
| 2918 | + if ($ifrvfr == 'V') { |
|
| 2919 | + $data['rules'] = 'VFR'; |
|
| 2920 | + } |
|
| 2921 | + if ($q[4] == 'A') { |
|
| 2922 | + $data['scope'] = 'Airport warning'; |
|
| 2923 | + } |
|
| 2924 | + if ($q[4] == 'E') { |
|
| 2925 | + $data['scope'] = 'Enroute warning'; |
|
| 2926 | + } |
|
| 2927 | + if ($q[4] == 'W') { |
|
| 2928 | + $data['scope'] = 'Navigation warning'; |
|
| 2929 | + } |
|
| 2930 | + if ($q[4] == 'AE') { |
|
| 2931 | + $data['scope'] = 'Airport/Enroute warning'; |
|
| 2932 | + } |
|
| 2933 | + if ($q[4] == 'AW') { |
|
| 2934 | + $data['scope'] = 'Airport/Navigation warning'; |
|
| 2935 | + } |
|
| 2356 | 2936 | //$data['scope'] = $q[4]; |
| 2357 | 2937 | $data['lower_limit'] = $q[5]; |
| 2358 | 2938 | $data['upper_limit'] = $q[6]; |
@@ -2360,8 +2940,12 @@ discard block |
||
| 2360 | 2940 | sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius); |
| 2361 | 2941 | $latitude = $Common->convertDec($las,'latitude'); |
| 2362 | 2942 | $longitude = $Common->convertDec($lns,'longitude'); |
| 2363 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
| 2364 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
| 2943 | + if ($lac == 'S') { |
|
| 2944 | + $latitude = '-'.$latitude; |
|
| 2945 | + } |
|
| 2946 | + if ($lnc == 'W') { |
|
| 2947 | + $longitude = '-'.$longitude; |
|
| 2948 | + } |
|
| 2365 | 2949 | $data['center_latitude'] = $latitude; |
| 2366 | 2950 | $data['center_longitude'] = $longitude; |
| 2367 | 2951 | $data['radius'] = intval($radius); |
@@ -2391,10 +2975,14 @@ discard block |
||
| 2391 | 2975 | $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']); |
| 2392 | 2976 | unset($data); |
| 2393 | 2977 | } |
| 2394 | - } else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
|
| 2978 | + } else { |
|
| 2979 | + $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
|
| 2980 | + } |
|
| 2395 | 2981 | if ($error != '') { |
| 2396 | 2982 | return $error; |
| 2397 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2983 | + } elseif ($globalDebug) { |
|
| 2984 | + echo "Done\n"; |
|
| 2985 | + } |
|
| 2398 | 2986 | return ''; |
| 2399 | 2987 | } |
| 2400 | 2988 | |
@@ -2419,7 +3007,9 @@ discard block |
||
| 2419 | 3007 | $airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json'); |
| 2420 | 3008 | $airspace_json = json_decode($airspace_lst,true); |
| 2421 | 3009 | foreach ($airspace_json['records'] as $airspace) { |
| 2422 | - if ($globalDebug) echo $airspace['name']."...\n"; |
|
| 3010 | + if ($globalDebug) { |
|
| 3011 | + echo $airspace['name']."...\n"; |
|
| 3012 | + } |
|
| 2423 | 3013 | update_db::download($airspace['uri'],$tmp_dir.$airspace['name']); |
| 2424 | 3014 | if (file_exists($tmp_dir.$airspace['name'])) { |
| 2425 | 3015 | file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name']))); |
@@ -2463,8 +3053,11 @@ discard block |
||
| 2463 | 3053 | return "error : ".$e->getMessage(); |
| 2464 | 3054 | } |
| 2465 | 3055 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 2466 | - if ($row['nb'] > 0) return false; |
|
| 2467 | - else return true; |
|
| 3056 | + if ($row['nb'] > 0) { |
|
| 3057 | + return false; |
|
| 3058 | + } else { |
|
| 3059 | + return true; |
|
| 3060 | + } |
|
| 2468 | 3061 | } |
| 2469 | 3062 | |
| 2470 | 3063 | public static function insert_last_update() { |
@@ -2489,8 +3082,11 @@ discard block |
||
| 2489 | 3082 | return "error : ".$e->getMessage(); |
| 2490 | 3083 | } |
| 2491 | 3084 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 2492 | - if ($row['nb'] > 0) return true; |
|
| 2493 | - else return false; |
|
| 3085 | + if ($row['nb'] > 0) { |
|
| 3086 | + return true; |
|
| 3087 | + } else { |
|
| 3088 | + return false; |
|
| 3089 | + } |
|
| 2494 | 3090 | } |
| 2495 | 3091 | |
| 2496 | 3092 | public static function check_geoid_version($version) { |
@@ -2503,8 +3099,11 @@ discard block |
||
| 2503 | 3099 | return "error : ".$e->getMessage(); |
| 2504 | 3100 | } |
| 2505 | 3101 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 2506 | - if ($row['nb'] > 0) return true; |
|
| 2507 | - else return false; |
|
| 3102 | + if ($row['nb'] > 0) { |
|
| 3103 | + return true; |
|
| 3104 | + } else { |
|
| 3105 | + return false; |
|
| 3106 | + } |
|
| 2508 | 3107 | } |
| 2509 | 3108 | |
| 2510 | 3109 | public static function check_marine_identity_version($version) { |
@@ -2517,8 +3116,11 @@ discard block |
||
| 2517 | 3116 | return "error : ".$e->getMessage(); |
| 2518 | 3117 | } |
| 2519 | 3118 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 2520 | - if ($row['nb'] > 0) return true; |
|
| 2521 | - else return false; |
|
| 3119 | + if ($row['nb'] > 0) { |
|
| 3120 | + return true; |
|
| 3121 | + } else { |
|
| 3122 | + return false; |
|
| 3123 | + } |
|
| 2522 | 3124 | } |
| 2523 | 3125 | |
| 2524 | 3126 | |
@@ -2573,8 +3175,11 @@ discard block |
||
| 2573 | 3175 | return "error : ".$e->getMessage(); |
| 2574 | 3176 | } |
| 2575 | 3177 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 2576 | - if ($row['nb'] > 0) return false; |
|
| 2577 | - else return true; |
|
| 3178 | + if ($row['nb'] > 0) { |
|
| 3179 | + return false; |
|
| 3180 | + } else { |
|
| 3181 | + return true; |
|
| 3182 | + } |
|
| 2578 | 3183 | } |
| 2579 | 3184 | |
| 2580 | 3185 | public static function insert_last_notam_update() { |
@@ -2604,8 +3209,11 @@ discard block |
||
| 2604 | 3209 | return "error : ".$e->getMessage(); |
| 2605 | 3210 | } |
| 2606 | 3211 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 2607 | - if ($row['nb'] > 0) return false; |
|
| 2608 | - else return true; |
|
| 3212 | + if ($row['nb'] > 0) { |
|
| 3213 | + return false; |
|
| 3214 | + } else { |
|
| 3215 | + return true; |
|
| 3216 | + } |
|
| 2609 | 3217 | } |
| 2610 | 3218 | |
| 2611 | 3219 | public static function insert_last_airspace_update() { |
@@ -2635,8 +3243,11 @@ discard block |
||
| 2635 | 3243 | return "error : ".$e->getMessage(); |
| 2636 | 3244 | } |
| 2637 | 3245 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 2638 | - if ($row['nb'] > 0) return false; |
|
| 2639 | - else return true; |
|
| 3246 | + if ($row['nb'] > 0) { |
|
| 3247 | + return false; |
|
| 3248 | + } else { |
|
| 3249 | + return true; |
|
| 3250 | + } |
|
| 2640 | 3251 | } |
| 2641 | 3252 | |
| 2642 | 3253 | public static function insert_last_geoid_update() { |
@@ -2666,8 +3277,11 @@ discard block |
||
| 2666 | 3277 | return "error : ".$e->getMessage(); |
| 2667 | 3278 | } |
| 2668 | 3279 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 2669 | - if ($row['nb'] > 0) return false; |
|
| 2670 | - else return true; |
|
| 3280 | + if ($row['nb'] > 0) { |
|
| 3281 | + return false; |
|
| 3282 | + } else { |
|
| 3283 | + return true; |
|
| 3284 | + } |
|
| 2671 | 3285 | } |
| 2672 | 3286 | |
| 2673 | 3287 | public static function insert_last_owner_update() { |
@@ -2696,8 +3310,11 @@ discard block |
||
| 2696 | 3310 | return "error : ".$e->getMessage(); |
| 2697 | 3311 | } |
| 2698 | 3312 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 2699 | - if ($row['nb'] > 0) return false; |
|
| 2700 | - else return true; |
|
| 3313 | + if ($row['nb'] > 0) { |
|
| 3314 | + return false; |
|
| 3315 | + } else { |
|
| 3316 | + return true; |
|
| 3317 | + } |
|
| 2701 | 3318 | } |
| 2702 | 3319 | |
| 2703 | 3320 | public static function insert_last_schedules_update() { |
@@ -2726,8 +3343,11 @@ discard block |
||
| 2726 | 3343 | return "error : ".$e->getMessage(); |
| 2727 | 3344 | } |
| 2728 | 3345 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 2729 | - if ($row['nb'] > 0) return false; |
|
| 2730 | - else return true; |
|
| 3346 | + if ($row['nb'] > 0) { |
|
| 3347 | + return false; |
|
| 3348 | + } else { |
|
| 3349 | + return true; |
|
| 3350 | + } |
|
| 2731 | 3351 | } |
| 2732 | 3352 | |
| 2733 | 3353 | public static function insert_last_tle_update() { |
@@ -2756,8 +3376,11 @@ discard block |
||
| 2756 | 3376 | return "error : ".$e->getMessage(); |
| 2757 | 3377 | } |
| 2758 | 3378 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 2759 | - if ($row['nb'] > 0) return false; |
|
| 2760 | - else return true; |
|
| 3379 | + if ($row['nb'] > 0) { |
|
| 3380 | + return false; |
|
| 3381 | + } else { |
|
| 3382 | + return true; |
|
| 3383 | + } |
|
| 2761 | 3384 | } |
| 2762 | 3385 | |
| 2763 | 3386 | public static function insert_last_marine_identity_update() { |
@@ -9,7 +9,9 @@ discard block |
||
| 9 | 9 | if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') { |
| 10 | 10 | exec("ps ux", $output, $result); |
| 11 | 11 | $j = 0; |
| 12 | - foreach ($output as $line) if(strpos($line, "update_db.php") && !strpos($line, "sh ")) $j++; |
|
| 12 | + foreach ($output as $line) { |
|
| 13 | + if(strpos($line, "update_db.php") && !strpos($line, "sh ")) $j++; |
|
| 14 | + } |
|
| 13 | 15 | if ($j > 1) { |
| 14 | 16 | echo "Script is already runnning..."; |
| 15 | 17 | die(); |
@@ -29,14 +31,18 @@ discard block |
||
| 29 | 31 | $update_db->update_notam(); |
| 30 | 32 | } |
| 31 | 33 | $update_db->insert_last_notam_update(); |
| 32 | - } elseif (isset($globalDebug) && $globalDebug && isset($globalNOTAM) && $globalNOTAM) echo "NOTAM are only updated once a day.\n"; |
|
| 34 | + } elseif (isset($globalDebug) && $globalDebug && isset($globalNOTAM) && $globalNOTAM) { |
|
| 35 | + echo "NOTAM are only updated once a day.\n"; |
|
| 36 | + } |
|
| 33 | 37 | if ($update_db->check_last_update() && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) { |
| 34 | 38 | $update_db->update_all(); |
| 35 | 39 | // require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 36 | 40 | // $Spotter = new Spotter(); |
| 37 | 41 | // $Spotter->updateFieldsFromOtherTables(); |
| 38 | 42 | $update_db->insert_last_update(); |
| 39 | - } elseif (isset($globalDebug) && $globalDebug && (!isset($globalVA) || !$globalVA) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM)) echo "DB are populated with external data only every 15 days ! Files are not updated more often.\n"; |
|
| 43 | + } elseif (isset($globalDebug) && $globalDebug && (!isset($globalVA) || !$globalVA) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM)) { |
|
| 44 | + echo "DB are populated with external data only every 15 days ! Files are not updated more often.\n"; |
|
| 45 | + } |
|
| 40 | 46 | if (isset($globalWaypoints) && $globalWaypoints && $update_db->check_last_airspace_update()) { |
| 41 | 47 | echo "Check if new airspace version exist..."; |
| 42 | 48 | echo $update_db->update_airspace_fam(); |
@@ -45,8 +51,11 @@ discard block |
||
| 45 | 51 | if (isset($globalGeoid) && $globalGeoid && $update_db->check_last_geoid_update()) { |
| 46 | 52 | echo "Check if new geoid version exist..."; |
| 47 | 53 | $error = $update_db->update_geoid_fam(); |
| 48 | - if ($error == '') $update_db->insert_last_geoid_update(); |
|
| 49 | - else echo $error; |
|
| 54 | + if ($error == '') { |
|
| 55 | + $update_db->insert_last_geoid_update(); |
|
| 56 | + } else { |
|
| 57 | + echo $error; |
|
| 58 | + } |
|
| 50 | 59 | } |
| 51 | 60 | if (isset($globalMarine) && $globalMarine && $update_db->check_last_marine_identity_update()) { |
| 52 | 61 | echo "Check if new marine identity version exist..."; |
@@ -62,7 +71,9 @@ discard block |
||
| 62 | 71 | $update_db->delete_duplicateowner(); |
| 63 | 72 | } |
| 64 | 73 | $update_db->insert_last_owner_update(); |
| 65 | - } elseif (isset($globalDebug) && $globalDebug && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) echo "Owner are only updated every 15 days.\n"; |
|
| 74 | + } elseif (isset($globalDebug) && $globalDebug && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) { |
|
| 75 | + echo "Owner are only updated every 15 days.\n"; |
|
| 76 | + } |
|
| 66 | 77 | |
| 67 | 78 | if (isset($globalAccidents) && $globalAccidents && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) { |
| 68 | 79 | require_once(dirname(__FILE__).'/../require/class.Accident.php'); |
@@ -71,7 +82,9 @@ discard block |
||
| 71 | 82 | if ($Accident->check_last_accidents_update()) { |
| 72 | 83 | $Accident->download_update(); |
| 73 | 84 | $Accident->insert_last_accidents_update(); |
| 74 | - } else echo "Accidents are updated once a day.\n"; |
|
| 85 | + } else { |
|
| 86 | + echo "Accidents are updated once a day.\n"; |
|
| 87 | + } |
|
| 75 | 88 | } |
| 76 | 89 | |
| 77 | 90 | } |
@@ -84,15 +97,19 @@ discard block |
||
| 84 | 97 | if ($METAR->check_last_update()) { |
| 85 | 98 | $METAR->addMETARCycle(); |
| 86 | 99 | $METAR->insert_last_update(); |
| 87 | - } else echo "METAR are only updated every 30 minutes.\n"; |
|
| 88 | -} |
|
| 100 | + } else { |
|
| 101 | + echo "METAR are only updated every 30 minutes.\n"; |
|
| 102 | + } |
|
| 103 | + } |
|
| 89 | 104 | |
| 90 | 105 | if (isset($globalSchedules) && $globalSchedules && $update_db->check_last_schedules_update() && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) { |
| 91 | 106 | echo "Updating schedules..."; |
| 92 | 107 | //$update_db->update_oneworld(); |
| 93 | 108 | $update_db->update_skyteam(); |
| 94 | 109 | $update_db->insert_last_schedules_update(); |
| 95 | -} elseif (isset($globalDebug) && $globalDebug && isset($globalOwner) && $globalOwner && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) echo "Schedules are only updated every 15 days.\n"; |
|
| 110 | +} elseif (isset($globalDebug) && $globalDebug && isset($globalOwner) && $globalOwner && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) { |
|
| 111 | + echo "Schedules are only updated every 15 days.\n"; |
|
| 112 | +} |
|
| 96 | 113 | |
| 97 | 114 | if (isset($globalArchiveMonths) && $globalArchiveMonths > 0) { |
| 98 | 115 | echo "Updating statistics and archive old data..."; |