@@ -24,20 +24,20 @@ discard block |
||
| 24 | 24 | fclose($fp); |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - public static function gunzip($in_file,$out_file_name = '') { |
|
| 27 | + public static function gunzip($in_file, $out_file_name = '') { |
|
| 28 | 28 | //echo $in_file.' -> '.$out_file_name."\n"; |
| 29 | 29 | $buffer_size = 4096; // read 4kb at a time |
| 30 | 30 | if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); |
| 31 | 31 | if ($in_file != '' && file_exists($in_file)) { |
| 32 | 32 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
| 33 | - if (function_exists('gzopen')) $file = gzopen($in_file,'rb'); |
|
| 34 | - elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb'); |
|
| 33 | + if (function_exists('gzopen')) $file = gzopen($in_file, 'rb'); |
|
| 34 | + elseif (function_exists('gzopen64')) $file = gzopen64($in_file, 'rb'); |
|
| 35 | 35 | else { |
| 36 | 36 | echo 'gzopen not available'; |
| 37 | 37 | die; |
| 38 | 38 | } |
| 39 | 39 | $out_file = fopen($out_file_name, 'wb'); |
| 40 | - while(!gzeof($file)) { |
|
| 40 | + while (!gzeof($file)) { |
|
| 41 | 41 | fwrite($out_file, gzread($file, $buffer_size)); |
| 42 | 42 | } |
| 43 | 43 | fclose($out_file); |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | try { |
| 62 | 62 | self::$db_sqlite = new PDO('sqlite:'.$database); |
| 63 | 63 | self::$db_sqlite->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
| 64 | - } catch(PDOException $e) { |
|
| 64 | + } catch (PDOException $e) { |
|
| 65 | 65 | return "error : ".$e->getMessage(); |
| 66 | 66 | } |
| 67 | 67 | } |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | //$Connection = new Connection(); |
| 77 | 77 | $sth = $Connection->db->prepare($query); |
| 78 | 78 | $sth->execute(array(':source' => $database_file)); |
| 79 | - } catch(PDOException $e) { |
|
| 79 | + } catch (PDOException $e) { |
|
| 80 | 80 | return "error : ".$e->getMessage(); |
| 81 | 81 | } |
| 82 | 82 | |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | try { |
| 88 | 88 | $sth = update_db::$db_sqlite->prepare($query); |
| 89 | 89 | $sth->execute(); |
| 90 | - } catch(PDOException $e) { |
|
| 90 | + } catch (PDOException $e) { |
|
| 91 | 91 | return "error : ".$e->getMessage(); |
| 92 | 92 | } |
| 93 | 93 | //$query_dest = 'INSERT INTO routes (`RouteID`,`CallSign`,`Operator_ICAO`,`FromAirport_ICAO`,`ToAirport_ICAO`,`RouteStop`,`Source`) VALUES (:RouteID, :CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)'; |
@@ -98,11 +98,11 @@ discard block |
||
| 98 | 98 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 99 | 99 | while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
| 100 | 100 | //$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
| 101 | - $query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
|
| 101 | + $query_dest_values = array(':CallSign' => $values['Callsign'], ':Operator_ICAO' => $values['operator_icao'], ':FromAirport_ICAO' => $values['FromAirportIcao'], ':ToAirport_ICAO' => $values['ToAirportIcao'], ':routestop' => $values['AllStop'], ':source' => $database_file); |
|
| 102 | 102 | $sth_dest->execute($query_dest_values); |
| 103 | 103 | } |
| 104 | 104 | if ($globalTransaction) $Connection->db->commit(); |
| 105 | - } catch(PDOException $e) { |
|
| 105 | + } catch (PDOException $e) { |
|
| 106 | 106 | if ($globalTransaction) $Connection->db->rollBack(); |
| 107 | 107 | return "error : ".$e->getMessage(); |
| 108 | 108 | } |
@@ -118,26 +118,26 @@ discard block |
||
| 118 | 118 | //$Connection = new Connection(); |
| 119 | 119 | $sth = $Connection->db->prepare($query); |
| 120 | 120 | $sth->execute(array(':source' => 'oneworld')); |
| 121 | - } catch(PDOException $e) { |
|
| 121 | + } catch (PDOException $e) { |
|
| 122 | 122 | return "error : ".$e->getMessage(); |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | if ($globalDebug) echo " - Add routes to DB -"; |
| 126 | 126 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 127 | 127 | $Spotter = new Spotter(); |
| 128 | - if ($fh = fopen($database_file,"r")) { |
|
| 128 | + if ($fh = fopen($database_file, "r")) { |
|
| 129 | 129 | $query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)'; |
| 130 | 130 | $Connection = new Connection(); |
| 131 | 131 | $sth_dest = $Connection->db->prepare($query_dest); |
| 132 | 132 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 133 | 133 | while (!feof($fh)) { |
| 134 | - $line = fgetcsv($fh,9999,','); |
|
| 134 | + $line = fgetcsv($fh, 9999, ','); |
|
| 135 | 135 | if ($line[0] != '') { |
| 136 | 136 | if (($line[2] == '-' || ($line[2] != '-' && (strtotime($line[2]) > time()))) && ($line[3] == '-' || ($line[3] != '-' && (strtotime($line[3]) < time())))) { |
| 137 | 137 | try { |
| 138 | - $query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld'); |
|
| 138 | + $query_dest_values = array(':CallSign' => str_replace('*', '', $line[7]), ':Operator_ICAO' => '', ':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]), ':FromAirport_Time' => $line[5], ':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]), ':ToAirport_Time' => $line[6], ':routestop' => '', ':source' => 'oneworld'); |
|
| 139 | 139 | $sth_dest->execute($query_dest_values); |
| 140 | - } catch(PDOException $e) { |
|
| 140 | + } catch (PDOException $e) { |
|
| 141 | 141 | if ($globalTransaction) $Connection->db->rollBack(); |
| 142 | 142 | return "error : ".$e->getMessage(); |
| 143 | 143 | } |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | //$Connection = new Connection(); |
| 160 | 160 | $sth = $Connection->db->prepare($query); |
| 161 | 161 | $sth->execute(array(':source' => 'skyteam')); |
| 162 | - } catch(PDOException $e) { |
|
| 162 | + } catch (PDOException $e) { |
|
| 163 | 163 | return "error : ".$e->getMessage(); |
| 164 | 164 | } |
| 165 | 165 | |
@@ -167,24 +167,24 @@ discard block |
||
| 167 | 167 | |
| 168 | 168 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 169 | 169 | $Spotter = new Spotter(); |
| 170 | - if ($fh = fopen($database_file,"r")) { |
|
| 170 | + if ($fh = fopen($database_file, "r")) { |
|
| 171 | 171 | $query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)'; |
| 172 | 172 | $Connection = new Connection(); |
| 173 | 173 | $sth_dest = $Connection->db->prepare($query_dest); |
| 174 | 174 | try { |
| 175 | 175 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 176 | 176 | while (!feof($fh)) { |
| 177 | - $line = fgetcsv($fh,9999,','); |
|
| 177 | + $line = fgetcsv($fh, 9999, ','); |
|
| 178 | 178 | if ($line[0] != '') { |
| 179 | - $datebe = explode(' - ',$line[2]); |
|
| 179 | + $datebe = explode(' - ', $line[2]); |
|
| 180 | 180 | if (strtotime($datebe[0]) > time() && strtotime($datebe[1]) < time()) { |
| 181 | - $query_dest_values = array(':CallSign' => str_replace('*','',$line[6]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[4],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[5],':routestop' => '',':source' => 'skyteam'); |
|
| 181 | + $query_dest_values = array(':CallSign' => str_replace('*', '', $line[6]), ':Operator_ICAO' => '', ':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]), ':FromAirport_Time' => $line[4], ':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]), ':ToAirport_Time' => $line[5], ':routestop' => '', ':source' => 'skyteam'); |
|
| 182 | 182 | $sth_dest->execute($query_dest_values); |
| 183 | 183 | } |
| 184 | 184 | } |
| 185 | 185 | } |
| 186 | 186 | if ($globalTransaction) $Connection->db->commit(); |
| 187 | - } catch(PDOException $e) { |
|
| 187 | + } catch (PDOException $e) { |
|
| 188 | 188 | if ($globalTransaction) $Connection->db->rollBack(); |
| 189 | 189 | return "error : ".$e->getMessage(); |
| 190 | 190 | } |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | $Connection = new Connection(); |
| 200 | 200 | $sth = $Connection->db->prepare($query); |
| 201 | 201 | $sth->execute(array(':source' => $database_file)); |
| 202 | - } catch(PDOException $e) { |
|
| 202 | + } catch (PDOException $e) { |
|
| 203 | 203 | return "error : ".$e->getMessage(); |
| 204 | 204 | } |
| 205 | 205 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source"; |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | $Connection = new Connection(); |
| 208 | 208 | $sth = $Connection->db->prepare($query); |
| 209 | 209 | $sth->execute(array(':source' => $database_file)); |
| 210 | - } catch(PDOException $e) { |
|
| 210 | + } catch (PDOException $e) { |
|
| 211 | 211 | return "error : ".$e->getMessage(); |
| 212 | 212 | } |
| 213 | 213 | |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | try { |
| 217 | 217 | $sth = update_db::$db_sqlite->prepare($query); |
| 218 | 218 | $sth->execute(); |
| 219 | - } catch(PDOException $e) { |
|
| 219 | + } catch (PDOException $e) { |
|
| 220 | 220 | return "error : ".$e->getMessage(); |
| 221 | 221 | } |
| 222 | 222 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
@@ -233,15 +233,15 @@ discard block |
||
| 233 | 233 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
| 234 | 234 | if ($values['UserString4'] == 'M') $type = 'military'; |
| 235 | 235 | else $type = null; |
| 236 | - $query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type); |
|
| 236 | + $query_dest_values = array(':LastModified' => $values['LastModified'], ':ModeS' => $values['ModeS'], ':ModeSCountry' => $values['ModeSCountry'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':type' => $type); |
|
| 237 | 237 | $sth_dest->execute($query_dest_values); |
| 238 | 238 | if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') { |
| 239 | - $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']); |
|
| 239 | + $query_dest_owner_values = array(':registration' => $values['Registration'], ':source' => $database_file, ':owner' => $values['RegisteredOwners']); |
|
| 240 | 240 | $sth_dest_owner->execute($query_dest_owner_values); |
| 241 | 241 | } |
| 242 | 242 | } |
| 243 | 243 | if ($globalTransaction) $Connection->db->commit(); |
| 244 | - } catch(PDOException $e) { |
|
| 244 | + } catch (PDOException $e) { |
|
| 245 | 245 | return "error : ".$e->getMessage(); |
| 246 | 246 | } |
| 247 | 247 | |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | $Connection = new Connection(); |
| 251 | 251 | $sth = $Connection->db->prepare($query); |
| 252 | 252 | $sth->execute(array(':source' => $database_file)); |
| 253 | - } catch(PDOException $e) { |
|
| 253 | + } catch (PDOException $e) { |
|
| 254 | 254 | return "error : ".$e->getMessage(); |
| 255 | 255 | } |
| 256 | 256 | return ''; |
@@ -265,11 +265,11 @@ discard block |
||
| 265 | 265 | $Connection = new Connection(); |
| 266 | 266 | $sth = $Connection->db->prepare($query); |
| 267 | 267 | $sth->execute(array(':source' => $database_file)); |
| 268 | - } catch(PDOException $e) { |
|
| 268 | + } catch (PDOException $e) { |
|
| 269 | 269 | return "error : ".$e->getMessage(); |
| 270 | 270 | } |
| 271 | 271 | |
| 272 | - if ($fh = fopen($database_file,"r")) { |
|
| 272 | + if ($fh = fopen($database_file, "r")) { |
|
| 273 | 273 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
| 274 | 274 | $query_dest = 'INSERT INTO aircraft_modes (ModeS,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:Registration,:ICAOTypeCode,:source)'; |
| 275 | 275 | |
@@ -279,13 +279,13 @@ discard block |
||
| 279 | 279 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 280 | 280 | while (!feof($fh)) { |
| 281 | 281 | $values = array(); |
| 282 | - $line = $Common->hex2str(fgets($fh,9999)); |
|
| 282 | + $line = $Common->hex2str(fgets($fh, 9999)); |
|
| 283 | 283 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
| 284 | - $values['ModeS'] = substr($line,0,6); |
|
| 285 | - $values['Registration'] = trim(substr($line,69,6)); |
|
| 286 | - $aircraft_name = trim(substr($line,48,6)); |
|
| 284 | + $values['ModeS'] = substr($line, 0, 6); |
|
| 285 | + $values['Registration'] = trim(substr($line, 69, 6)); |
|
| 286 | + $aircraft_name = trim(substr($line, 48, 6)); |
|
| 287 | 287 | // Check if we can find ICAO, else set it to GLID |
| 288 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
| 288 | + $aircraft_name_split = explode(' ', $aircraft_name); |
|
| 289 | 289 | $search_more = ''; |
| 290 | 290 | if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
| 291 | 291 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
@@ -297,20 +297,20 @@ discard block |
||
| 297 | 297 | if (isset($result['icao']) && $result['icao'] != '') { |
| 298 | 298 | $values['ICAOTypeCode'] = $result['icao']; |
| 299 | 299 | } |
| 300 | - } catch(PDOException $e) { |
|
| 300 | + } catch (PDOException $e) { |
|
| 301 | 301 | return "error : ".$e->getMessage(); |
| 302 | 302 | } |
| 303 | 303 | if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID'; |
| 304 | 304 | // Add data to db |
| 305 | 305 | if ($values['ModeS'] != '' && $values['Registration'] != '' && $values['Registration'] != '0000') { |
| 306 | 306 | //$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']); |
| 307 | - $query_dest_values = array(':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file); |
|
| 307 | + $query_dest_values = array(':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file); |
|
| 308 | 308 | //print_r($query_dest_values); |
| 309 | 309 | $sth_dest->execute($query_dest_values); |
| 310 | 310 | } |
| 311 | 311 | } |
| 312 | 312 | if ($globalTransaction) $Connection->db->commit(); |
| 313 | - } catch(PDOException $e) { |
|
| 313 | + } catch (PDOException $e) { |
|
| 314 | 314 | return "error : ".$e->getMessage(); |
| 315 | 315 | } |
| 316 | 316 | } |
@@ -320,7 +320,7 @@ discard block |
||
| 320 | 320 | $Connection = new Connection(); |
| 321 | 321 | $sth = $Connection->db->prepare($query); |
| 322 | 322 | $sth->execute(array(':source' => $database_file)); |
| 323 | - } catch(PDOException $e) { |
|
| 323 | + } catch (PDOException $e) { |
|
| 324 | 324 | return "error : ".$e->getMessage(); |
| 325 | 325 | } |
| 326 | 326 | return ''; |
@@ -334,11 +334,11 @@ discard block |
||
| 334 | 334 | $Connection = new Connection(); |
| 335 | 335 | $sth = $Connection->db->prepare($query); |
| 336 | 336 | $sth->execute(array(':source' => $database_file)); |
| 337 | - } catch(PDOException $e) { |
|
| 337 | + } catch (PDOException $e) { |
|
| 338 | 338 | return "error : ".$e->getMessage(); |
| 339 | 339 | } |
| 340 | 340 | |
| 341 | - if ($fh = fopen($database_file,"r")) { |
|
| 341 | + if ($fh = fopen($database_file, "r")) { |
|
| 342 | 342 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
| 343 | 343 | $query_dest = 'INSERT INTO aircraft_modes (ModeS,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:Registration,:ICAOTypeCode,:source)'; |
| 344 | 344 | |
@@ -346,9 +346,9 @@ discard block |
||
| 346 | 346 | $sth_dest = $Connection->db->prepare($query_dest); |
| 347 | 347 | try { |
| 348 | 348 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 349 | - $tmp = fgetcsv($fh,9999,',',"'"); |
|
| 349 | + $tmp = fgetcsv($fh, 9999, ',', "'"); |
|
| 350 | 350 | while (!feof($fh)) { |
| 351 | - $line = fgetcsv($fh,9999,',',"'"); |
|
| 351 | + $line = fgetcsv($fh, 9999, ',', "'"); |
|
| 352 | 352 | |
| 353 | 353 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
| 354 | 354 | //print_r($line); |
@@ -356,7 +356,7 @@ discard block |
||
| 356 | 356 | $values['Registration'] = $line[3]; |
| 357 | 357 | $aircraft_name = $line[2]; |
| 358 | 358 | // Check if we can find ICAO, else set it to GLID |
| 359 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
| 359 | + $aircraft_name_split = explode(' ', $aircraft_name); |
|
| 360 | 360 | $search_more = ''; |
| 361 | 361 | if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
| 362 | 362 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
@@ -365,20 +365,20 @@ discard block |
||
| 365 | 365 | $sth_search->execute(); |
| 366 | 366 | $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
| 367 | 367 | if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
| 368 | - } catch(PDOException $e) { |
|
| 368 | + } catch (PDOException $e) { |
|
| 369 | 369 | return "error : ".$e->getMessage(); |
| 370 | 370 | } |
| 371 | 371 | //if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID'; |
| 372 | 372 | // Add data to db |
| 373 | 373 | if ($values['ModeS'] != '' && $values['Registration'] != '' && $values['Registration'] != '0000' && $values['ICAOTypeCode'] != '') { |
| 374 | 374 | //$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']); |
| 375 | - $query_dest_values = array(':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file); |
|
| 375 | + $query_dest_values = array(':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file); |
|
| 376 | 376 | //print_r($query_dest_values); |
| 377 | 377 | $sth_dest->execute($query_dest_values); |
| 378 | 378 | } |
| 379 | 379 | } |
| 380 | 380 | if ($globalTransaction) $Connection->db->commit(); |
| 381 | - } catch(PDOException $e) { |
|
| 381 | + } catch (PDOException $e) { |
|
| 382 | 382 | return "error : ".$e->getMessage(); |
| 383 | 383 | } |
| 384 | 384 | } |
@@ -388,13 +388,13 @@ discard block |
||
| 388 | 388 | $Connection = new Connection(); |
| 389 | 389 | $sth = $Connection->db->prepare($query); |
| 390 | 390 | $sth->execute(array(':source' => $database_file)); |
| 391 | - } catch(PDOException $e) { |
|
| 391 | + } catch (PDOException $e) { |
|
| 392 | 392 | return "error : ".$e->getMessage(); |
| 393 | 393 | } |
| 394 | 394 | return ''; |
| 395 | 395 | } |
| 396 | 396 | |
| 397 | - public static function retrieve_owner($database_file,$country = 'F') { |
|
| 397 | + public static function retrieve_owner($database_file, $country = 'F') { |
|
| 398 | 398 | global $globalTransaction; |
| 399 | 399 | //$query = 'TRUNCATE TABLE aircraft_modes'; |
| 400 | 400 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source"; |
@@ -402,11 +402,11 @@ discard block |
||
| 402 | 402 | $Connection = new Connection(); |
| 403 | 403 | $sth = $Connection->db->prepare($query); |
| 404 | 404 | $sth->execute(array(':source' => $database_file)); |
| 405 | - } catch(PDOException $e) { |
|
| 405 | + } catch (PDOException $e) { |
|
| 406 | 406 | return "error : ".$e->getMessage(); |
| 407 | 407 | } |
| 408 | 408 | |
| 409 | - if ($fh = fopen($database_file,"r")) { |
|
| 409 | + if ($fh = fopen($database_file, "r")) { |
|
| 410 | 410 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
| 411 | 411 | $query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)'; |
| 412 | 412 | |
@@ -414,9 +414,9 @@ discard block |
||
| 414 | 414 | $sth_dest = $Connection->db->prepare($query_dest); |
| 415 | 415 | try { |
| 416 | 416 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 417 | - $tmp = fgetcsv($fh,9999,',','"'); |
|
| 417 | + $tmp = fgetcsv($fh, 9999, ',', '"'); |
|
| 418 | 418 | while (!feof($fh)) { |
| 419 | - $line = fgetcsv($fh,9999,',','"'); |
|
| 419 | + $line = fgetcsv($fh, 9999, ',', '"'); |
|
| 420 | 420 | $values = array(); |
| 421 | 421 | //print_r($line); |
| 422 | 422 | if ($country == 'F') { |
@@ -424,7 +424,7 @@ discard block |
||
| 424 | 424 | $values['base'] = $line[4]; |
| 425 | 425 | $values['owner'] = $line[5]; |
| 426 | 426 | if ($line[6] == '') $values['date_first_reg'] = null; |
| 427 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 427 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6])); |
|
| 428 | 428 | $values['cancel'] = $line[7]; |
| 429 | 429 | } elseif ($country == 'EI') { |
| 430 | 430 | // TODO : add modeS & reg to aircraft_modes |
@@ -432,7 +432,7 @@ discard block |
||
| 432 | 432 | $values['base'] = $line[3]; |
| 433 | 433 | $values['owner'] = $line[2]; |
| 434 | 434 | if ($line[1] == '') $values['date_first_reg'] = null; |
| 435 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
| 435 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[1])); |
|
| 436 | 436 | $values['cancel'] = ''; |
| 437 | 437 | } elseif ($country == 'HB') { |
| 438 | 438 | // TODO : add modeS & reg to aircraft_modes |
@@ -447,7 +447,7 @@ discard block |
||
| 447 | 447 | $values['base'] = null; |
| 448 | 448 | $values['owner'] = $line[5]; |
| 449 | 449 | if ($line[18] == '') $values['date_first_reg'] = null; |
| 450 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
| 450 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[18])); |
|
| 451 | 451 | $values['cancel'] = ''; |
| 452 | 452 | } elseif ($country == 'VH') { |
| 453 | 453 | // TODO : add modeS & reg to aircraft_modes |
@@ -455,7 +455,7 @@ discard block |
||
| 455 | 455 | $values['base'] = null; |
| 456 | 456 | $values['owner'] = $line[12]; |
| 457 | 457 | if ($line[28] == '') $values['date_first_reg'] = null; |
| 458 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
| 458 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[28])); |
|
| 459 | 459 | |
| 460 | 460 | $values['cancel'] = $line[39]; |
| 461 | 461 | } elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { |
@@ -475,28 +475,28 @@ discard block |
||
| 475 | 475 | $values['base'] = null; |
| 476 | 476 | $values['owner'] = $line[8]; |
| 477 | 477 | if ($line[7] == '') $values['date_first_reg'] = null; |
| 478 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 478 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7])); |
|
| 479 | 479 | $values['cancel'] = ''; |
| 480 | 480 | } elseif ($country == 'PP') { |
| 481 | 481 | $values['registration'] = $line[0]; |
| 482 | 482 | $values['base'] = null; |
| 483 | 483 | $values['owner'] = $line[4]; |
| 484 | 484 | if ($line[6] == '') $values['date_first_reg'] = null; |
| 485 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 485 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6])); |
|
| 486 | 486 | $values['cancel'] = $line[7]; |
| 487 | 487 | } elseif ($country == 'E7') { |
| 488 | 488 | $values['registration'] = $line[0]; |
| 489 | 489 | $values['base'] = null; |
| 490 | 490 | $values['owner'] = $line[4]; |
| 491 | 491 | if ($line[5] == '') $values['date_first_reg'] = null; |
| 492 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
| 492 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[5])); |
|
| 493 | 493 | $values['cancel'] = ''; |
| 494 | 494 | } elseif ($country == '8Q') { |
| 495 | 495 | $values['registration'] = $line[0]; |
| 496 | 496 | $values['base'] = null; |
| 497 | 497 | $values['owner'] = $line[3]; |
| 498 | 498 | if ($line[7] == '') $values['date_first_reg'] = null; |
| 499 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 499 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7])); |
|
| 500 | 500 | $values['cancel'] = ''; |
| 501 | 501 | } elseif ($country == 'ZK' || $country == 'OM' || $country == 'TF') { |
| 502 | 502 | $values['registration'] = $line[0]; |
@@ -506,12 +506,12 @@ discard block |
||
| 506 | 506 | $values['cancel'] = ''; |
| 507 | 507 | } |
| 508 | 508 | if ($values['cancel'] == '' && $values['registration'] != null) { |
| 509 | - $query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file); |
|
| 509 | + $query_dest_values = array(':registration' => $values['registration'], ':base' => $values['base'], ':date_first_reg' => $values['date_first_reg'], ':owner' => $values['owner'], ':source' => $database_file); |
|
| 510 | 510 | $sth_dest->execute($query_dest_values); |
| 511 | 511 | } |
| 512 | 512 | } |
| 513 | 513 | if ($globalTransaction) $Connection->db->commit(); |
| 514 | - } catch(PDOException $e) { |
|
| 514 | + } catch (PDOException $e) { |
|
| 515 | 515 | return "error : ".$e->getMessage(); |
| 516 | 516 | } |
| 517 | 517 | } |
@@ -626,7 +626,7 @@ discard block |
||
| 626 | 626 | $Connection = new Connection(); |
| 627 | 627 | $sth = $Connection->db->prepare($query); |
| 628 | 628 | $sth->execute(); |
| 629 | - } catch(PDOException $e) { |
|
| 629 | + } catch (PDOException $e) { |
|
| 630 | 630 | return "error : ".$e->getMessage(); |
| 631 | 631 | } |
| 632 | 632 | |
@@ -636,7 +636,7 @@ discard block |
||
| 636 | 636 | $Connection = new Connection(); |
| 637 | 637 | $sth = $Connection->db->prepare($query); |
| 638 | 638 | $sth->execute(); |
| 639 | - } catch(PDOException $e) { |
|
| 639 | + } catch (PDOException $e) { |
|
| 640 | 640 | return "error : ".$e->getMessage(); |
| 641 | 641 | } |
| 642 | 642 | |
@@ -647,7 +647,7 @@ discard block |
||
| 647 | 647 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 648 | 648 | |
| 649 | 649 | $i = 0; |
| 650 | - while($row = sparql_fetch_array($result)) |
|
| 650 | + while ($row = sparql_fetch_array($result)) |
|
| 651 | 651 | { |
| 652 | 652 | if ($i >= 1) { |
| 653 | 653 | //print_r($row); |
@@ -667,31 +667,31 @@ discard block |
||
| 667 | 667 | $row['image'] = ''; |
| 668 | 668 | $row['image_thumb'] = ''; |
| 669 | 669 | } else { |
| 670 | - $image = str_replace(' ','_',$row['image']); |
|
| 670 | + $image = str_replace(' ', '_', $row['image']); |
|
| 671 | 671 | $digest = md5($image); |
| 672 | - $folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image . '/220px-' . $image; |
|
| 673 | - $row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/' . $folder; |
|
| 674 | - $folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image; |
|
| 675 | - $row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/' . $folder; |
|
| 672 | + $folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image.'/220px-'.$image; |
|
| 673 | + $row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/'.$folder; |
|
| 674 | + $folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image; |
|
| 675 | + $row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/'.$folder; |
|
| 676 | 676 | } |
| 677 | 677 | |
| 678 | - $country = explode('-',$row['country']); |
|
| 678 | + $country = explode('-', $row['country']); |
|
| 679 | 679 | $row['country'] = $country[0]; |
| 680 | 680 | |
| 681 | 681 | $row['type'] = trim($row['type']); |
| 682 | - if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i',$row['name'])) { |
|
| 682 | + if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i', $row['name'])) { |
|
| 683 | 683 | $row['type'] = 'Military'; |
| 684 | 684 | } elseif ($row['type'] == 'http://dbpedia.org/resource/Airport' || $row['type'] == 'Civil' || $row['type'] == 'Public use' || $row['type'] == 'Public' || $row['type'] == 'http://dbpedia.org/resource/Civilian' || $row['type'] == 'Public, Civilian' || $row['type'] == 'Public / Military' || $row['type'] == 'Private & Civilian' || $row['type'] == 'Civilian and Military' || $row['type'] == 'Public/military' || $row['type'] == 'Active With Few Facilities' || $row['type'] == '?ivilian' || $row['type'] == 'Civil/Military' || $row['type'] == 'NA' || $row['type'] == 'Public/Military') { |
| 685 | 685 | $row['type'] = 'small_airport'; |
| 686 | 686 | } |
| 687 | 687 | |
| 688 | - $row['city'] = urldecode(str_replace('_',' ',str_replace('http://dbpedia.org/resource/','',$row['city']))); |
|
| 689 | - $query_dest_values = array(':airport_id' => $i, ':name' => $row['name'],':iata' => $row['iata'],':icao' => $row['icao'],':latitude' => $row['latitude'],':longitude' => $row['longitude'],':altitude' => $row['altitude'],':type' => $row['type'],':city' => $row['city'],':country' => $row['country'],':home_link' => $row['homepage'],':wikipedia_link' => $row['wikipedia_page'],':image' => $row['image'],':image_thumb' => $row['image_thumb']); |
|
| 688 | + $row['city'] = urldecode(str_replace('_', ' ', str_replace('http://dbpedia.org/resource/', '', $row['city']))); |
|
| 689 | + $query_dest_values = array(':airport_id' => $i, ':name' => $row['name'], ':iata' => $row['iata'], ':icao' => $row['icao'], ':latitude' => $row['latitude'], ':longitude' => $row['longitude'], ':altitude' => $row['altitude'], ':type' => $row['type'], ':city' => $row['city'], ':country' => $row['country'], ':home_link' => $row['homepage'], ':wikipedia_link' => $row['wikipedia_page'], ':image' => $row['image'], ':image_thumb' => $row['image_thumb']); |
|
| 690 | 690 | //print_r($query_dest_values); |
| 691 | 691 | |
| 692 | 692 | try { |
| 693 | 693 | $sth_dest->execute($query_dest_values); |
| 694 | - } catch(PDOException $e) { |
|
| 694 | + } catch (PDOException $e) { |
|
| 695 | 695 | return "error : ".$e->getMessage(); |
| 696 | 696 | } |
| 697 | 697 | } |
@@ -705,7 +705,7 @@ discard block |
||
| 705 | 705 | $Connection = new Connection(); |
| 706 | 706 | $sth = $Connection->db->prepare($query); |
| 707 | 707 | $sth->execute(); |
| 708 | - } catch(PDOException $e) { |
|
| 708 | + } catch (PDOException $e) { |
|
| 709 | 709 | return "error : ".$e->getMessage(); |
| 710 | 710 | } |
| 711 | 711 | |
@@ -713,12 +713,12 @@ discard block |
||
| 713 | 713 | if ($globalDebug) echo "Insert Not available Airport...\n"; |
| 714 | 714 | $query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image`,`image_thumb`) |
| 715 | 715 | VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image, :image_thumb)"; |
| 716 | - $query_values = array(':airport_id' => $i, ':name' => 'Not available',':iata' => 'NA',':icao' => 'NA',':latitude' => '0',':longitude' => '0',':altitude' => '0',':type' => 'NA',':city' => 'N/A',':country' => 'N/A',':home_link' => '',':wikipedia_link' => '',':image' => '',':image_thumb' => ''); |
|
| 716 | + $query_values = array(':airport_id' => $i, ':name' => 'Not available', ':iata' => 'NA', ':icao' => 'NA', ':latitude' => '0', ':longitude' => '0', ':altitude' => '0', ':type' => 'NA', ':city' => 'N/A', ':country' => 'N/A', ':home_link' => '', ':wikipedia_link' => '', ':image' => '', ':image_thumb' => ''); |
|
| 717 | 717 | try { |
| 718 | 718 | $Connection = new Connection(); |
| 719 | 719 | $sth = $Connection->db->prepare($query); |
| 720 | 720 | $sth->execute($query_values); |
| 721 | - } catch(PDOException $e) { |
|
| 721 | + } catch (PDOException $e) { |
|
| 722 | 722 | return "error : ".$e->getMessage(); |
| 723 | 723 | } |
| 724 | 724 | $i++; |
@@ -736,7 +736,7 @@ discard block |
||
| 736 | 736 | echo "Download data from ourairports.com...\n"; |
| 737 | 737 | $delimiter = ','; |
| 738 | 738 | $out_file = $tmp_dir.'airports.csv'; |
| 739 | - update_db::download('http://ourairports.com/data/airports.csv',$out_file); |
|
| 739 | + update_db::download('http://ourairports.com/data/airports.csv', $out_file); |
|
| 740 | 740 | if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
| 741 | 741 | echo "Add data from ourairports.com...\n"; |
| 742 | 742 | |
@@ -747,32 +747,32 @@ discard block |
||
| 747 | 747 | //$Connection->db->beginTransaction(); |
| 748 | 748 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 749 | 749 | { |
| 750 | - if(!$header) $header = $row; |
|
| 750 | + if (!$header) $header = $row; |
|
| 751 | 751 | else { |
| 752 | 752 | $data = array(); |
| 753 | 753 | $data = array_combine($header, $row); |
| 754 | 754 | try { |
| 755 | 755 | $sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE `icao` = :icao'); |
| 756 | 756 | $sth->execute(array(':icao' => $data['gps_code'])); |
| 757 | - } catch(PDOException $e) { |
|
| 757 | + } catch (PDOException $e) { |
|
| 758 | 758 | return "error : ".$e->getMessage(); |
| 759 | 759 | } |
| 760 | 760 | if ($sth->fetchColumn() > 0) { |
| 761 | 761 | $query = 'UPDATE airport SET `type` = :type WHERE icao = :icao'; |
| 762 | 762 | try { |
| 763 | 763 | $sth = $Connection->db->prepare($query); |
| 764 | - $sth->execute(array(':icao' => $data['gps_code'],':type' => $data['type'])); |
|
| 765 | - } catch(PDOException $e) { |
|
| 764 | + $sth->execute(array(':icao' => $data['gps_code'], ':type' => $data['type'])); |
|
| 765 | + } catch (PDOException $e) { |
|
| 766 | 766 | return "error : ".$e->getMessage(); |
| 767 | 767 | } |
| 768 | 768 | } else { |
| 769 | 769 | $query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`) |
| 770 | 770 | VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link)"; |
| 771 | - $query_values = array(':airport_id' => $i, ':name' => $data['name'],':iata' => $data['iata_code'],':icao' => $data['gps_code'],':latitude' => $data['latitude_deg'],':longitude' => $data['longitude_deg'],':altitude' => $data['elevation_ft'],':type' => $data['type'],':city' => $data['municipality'],':country' => $data['iso_country'],':home_link' => $data['home_link'],':wikipedia_link' => $data['wikipedia_link']); |
|
| 771 | + $query_values = array(':airport_id' => $i, ':name' => $data['name'], ':iata' => $data['iata_code'], ':icao' => $data['gps_code'], ':latitude' => $data['latitude_deg'], ':longitude' => $data['longitude_deg'], ':altitude' => $data['elevation_ft'], ':type' => $data['type'], ':city' => $data['municipality'], ':country' => $data['iso_country'], ':home_link' => $data['home_link'], ':wikipedia_link' => $data['wikipedia_link']); |
|
| 772 | 772 | try { |
| 773 | 773 | $sth = $Connection->db->prepare($query); |
| 774 | 774 | $sth->execute($query_values); |
| 775 | - } catch(PDOException $e) { |
|
| 775 | + } catch (PDOException $e) { |
|
| 776 | 776 | return "error : ".$e->getMessage(); |
| 777 | 777 | } |
| 778 | 778 | $i++; |
@@ -785,7 +785,7 @@ discard block |
||
| 785 | 785 | |
| 786 | 786 | echo "Download data from another free database...\n"; |
| 787 | 787 | $out_file = $tmp_dir.'GlobalAirportDatabase.zip'; |
| 788 | - update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file); |
|
| 788 | + update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip', $out_file); |
|
| 789 | 789 | if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
| 790 | 790 | update_db::unzip($out_file); |
| 791 | 791 | $header = NULL; |
@@ -797,15 +797,15 @@ discard block |
||
| 797 | 797 | //$Connection->db->beginTransaction(); |
| 798 | 798 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 799 | 799 | { |
| 800 | - if(!$header) $header = $row; |
|
| 800 | + if (!$header) $header = $row; |
|
| 801 | 801 | else { |
| 802 | 802 | $data = $row; |
| 803 | 803 | |
| 804 | 804 | $query = 'UPDATE airport SET `city` = :city, `country` = :country WHERE icao = :icao'; |
| 805 | 805 | try { |
| 806 | 806 | $sth = $Connection->db->prepare($query); |
| 807 | - $sth->execute(array(':icao' => $data[0],':city' => ucwords(strtolower($data[3])),':country' => ucwords(strtolower($data[4])))); |
|
| 808 | - } catch(PDOException $e) { |
|
| 807 | + $sth->execute(array(':icao' => $data[0], ':city' => ucwords(strtolower($data[3])), ':country' => ucwords(strtolower($data[4])))); |
|
| 808 | + } catch (PDOException $e) { |
|
| 809 | 809 | return "error : ".$e->getMessage(); |
| 810 | 810 | } |
| 811 | 811 | } |
@@ -819,15 +819,15 @@ discard block |
||
| 819 | 819 | try { |
| 820 | 820 | $sth = $Connection->db->prepare("SELECT icao FROM airport WHERE `name` LIKE '%Air Base%'"); |
| 821 | 821 | $sth->execute(); |
| 822 | - } catch(PDOException $e) { |
|
| 822 | + } catch (PDOException $e) { |
|
| 823 | 823 | return "error : ".$e->getMessage(); |
| 824 | 824 | } |
| 825 | 825 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
| 826 | 826 | $query2 = 'UPDATE airport SET `type` = :type WHERE icao = :icao'; |
| 827 | 827 | try { |
| 828 | 828 | $sth2 = $Connection->db->prepare($query2); |
| 829 | - $sth2->execute(array(':icao' => $row['icao'],':type' => 'military')); |
|
| 830 | - } catch(PDOException $e) { |
|
| 829 | + $sth2->execute(array(':icao' => $row['icao'], ':type' => 'military')); |
|
| 830 | + } catch (PDOException $e) { |
|
| 831 | 831 | return "error : ".$e->getMessage(); |
| 832 | 832 | } |
| 833 | 833 | } |
@@ -851,7 +851,7 @@ discard block |
||
| 851 | 851 | $Connection = new Connection(); |
| 852 | 852 | $sth = $Connection->db->prepare($query); |
| 853 | 853 | $sth->execute(array(':source' => 'translation.csv')); |
| 854 | - } catch(PDOException $e) { |
|
| 854 | + } catch (PDOException $e) { |
|
| 855 | 855 | return "error : ".$e->getMessage(); |
| 856 | 856 | } |
| 857 | 857 | |
@@ -868,7 +868,7 @@ discard block |
||
| 868 | 868 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 869 | 869 | { |
| 870 | 870 | $i++; |
| 871 | - if($i > 12) { |
|
| 871 | + if ($i > 12) { |
|
| 872 | 872 | $data = $row; |
| 873 | 873 | $operator = $data[2]; |
| 874 | 874 | if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) { |
@@ -876,7 +876,7 @@ discard block |
||
| 876 | 876 | //echo substr($operator, 0, 2)."\n";; |
| 877 | 877 | if (count($airline_array) > 0) { |
| 878 | 878 | //print_r($airline_array); |
| 879 | - $operator = $airline_array[0]['icao'].substr($operator,2); |
|
| 879 | + $operator = $airline_array[0]['icao'].substr($operator, 2); |
|
| 880 | 880 | } |
| 881 | 881 | } |
| 882 | 882 | |
@@ -884,14 +884,14 @@ discard block |
||
| 884 | 884 | if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) { |
| 885 | 885 | $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2)); |
| 886 | 886 | if (count($airline_array) > 0) { |
| 887 | - $operator_correct = $airline_array[0]['icao'].substr($operator_correct,2); |
|
| 887 | + $operator_correct = $airline_array[0]['icao'].substr($operator_correct, 2); |
|
| 888 | 888 | } |
| 889 | 889 | } |
| 890 | 890 | $query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)'; |
| 891 | 891 | try { |
| 892 | 892 | $sth = $Connection->db->prepare($query); |
| 893 | - $sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $operator,':Operator_correct' => $operator_correct, ':source' => 'translation.csv')); |
|
| 894 | - } catch(PDOException $e) { |
|
| 893 | + $sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $operator, ':Operator_correct' => $operator_correct, ':source' => 'translation.csv')); |
|
| 894 | + } catch (PDOException $e) { |
|
| 895 | 895 | return "error : ".$e->getMessage(); |
| 896 | 896 | } |
| 897 | 897 | } |
@@ -911,7 +911,7 @@ discard block |
||
| 911 | 911 | $Connection = new Connection(); |
| 912 | 912 | $sth = $Connection->db->prepare($query); |
| 913 | 913 | $sth->execute(array(':source' => 'website_fam')); |
| 914 | - } catch(PDOException $e) { |
|
| 914 | + } catch (PDOException $e) { |
|
| 915 | 915 | return "error : ".$e->getMessage(); |
| 916 | 916 | } |
| 917 | 917 | |
@@ -931,8 +931,8 @@ discard block |
||
| 931 | 931 | $query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)'; |
| 932 | 932 | try { |
| 933 | 933 | $sth = $Connection->db->prepare($query); |
| 934 | - $sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $data[2],':Operator_correct' => $data[3], ':source' => 'website_fam')); |
|
| 935 | - } catch(PDOException $e) { |
|
| 934 | + $sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $data[2], ':Operator_correct' => $data[3], ':source' => 'website_fam')); |
|
| 935 | + } catch (PDOException $e) { |
|
| 936 | 936 | return "error : ".$e->getMessage(); |
| 937 | 937 | } |
| 938 | 938 | } |
@@ -944,7 +944,7 @@ discard block |
||
| 944 | 944 | return ''; |
| 945 | 945 | } |
| 946 | 946 | |
| 947 | - public static function tle($filename,$tletype) { |
|
| 947 | + public static function tle($filename, $tletype) { |
|
| 948 | 948 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 949 | 949 | global $tmp_dir, $globalTransaction; |
| 950 | 950 | //$Spotter = new Spotter(); |
@@ -954,7 +954,7 @@ discard block |
||
| 954 | 954 | $Connection = new Connection(); |
| 955 | 955 | $sth = $Connection->db->prepare($query); |
| 956 | 956 | $sth->execute(array(':source' => $filename)); |
| 957 | - } catch(PDOException $e) { |
|
| 957 | + } catch (PDOException $e) { |
|
| 958 | 958 | return "error : ".$e->getMessage(); |
| 959 | 959 | } |
| 960 | 960 | |
@@ -979,8 +979,8 @@ discard block |
||
| 979 | 979 | $query = 'INSERT INTO tle (tle_name,tle_tle1,tle_tle2,tle_type,tle_source) VALUES (:name, :tle1, :tle2, :type, :source)'; |
| 980 | 980 | try { |
| 981 | 981 | $sth = $Connection->db->prepare($query); |
| 982 | - $sth->execute(array(':name' => $dbdata['name'],':tle1' => $dbdata['tle1'],':tle2' => $dbdata['tle2'], ':type' => $tletype,':source' => $filename)); |
|
| 983 | - } catch(PDOException $e) { |
|
| 982 | + $sth->execute(array(':name' => $dbdata['name'], ':tle1' => $dbdata['tle1'], ':tle2' => $dbdata['tle2'], ':type' => $tletype, ':source' => $filename)); |
|
| 983 | + } catch (PDOException $e) { |
|
| 984 | 984 | return "error : ".$e->getMessage(); |
| 985 | 985 | } |
| 986 | 986 | |
@@ -1000,28 +1000,28 @@ discard block |
||
| 1000 | 1000 | */ |
| 1001 | 1001 | private static function table2array($data) { |
| 1002 | 1002 | $html = str_get_html($data); |
| 1003 | - $tabledata=array(); |
|
| 1004 | - foreach($html->find('tr') as $element) |
|
| 1003 | + $tabledata = array(); |
|
| 1004 | + foreach ($html->find('tr') as $element) |
|
| 1005 | 1005 | { |
| 1006 | 1006 | $td = array(); |
| 1007 | - foreach( $element->find('th') as $row) |
|
| 1007 | + foreach ($element->find('th') as $row) |
|
| 1008 | 1008 | { |
| 1009 | 1009 | $td [] = trim($row->plaintext); |
| 1010 | 1010 | } |
| 1011 | - $td=array_filter($td); |
|
| 1011 | + $td = array_filter($td); |
|
| 1012 | 1012 | $tabledata[] = $td; |
| 1013 | 1013 | |
| 1014 | 1014 | $td = array(); |
| 1015 | 1015 | $tdi = array(); |
| 1016 | - foreach( $element->find('td') as $row) |
|
| 1016 | + foreach ($element->find('td') as $row) |
|
| 1017 | 1017 | { |
| 1018 | 1018 | $td [] = trim($row->plaintext); |
| 1019 | 1019 | $tdi [] = trim($row->innertext); |
| 1020 | 1020 | } |
| 1021 | - $td=array_filter($td); |
|
| 1022 | - $tdi=array_filter($tdi); |
|
| 1021 | + $td = array_filter($td); |
|
| 1022 | + $tdi = array_filter($tdi); |
|
| 1023 | 1023 | // $tabledata[]=array_merge($td,$tdi); |
| 1024 | - $tabledata[]=$td; |
|
| 1024 | + $tabledata[] = $td; |
|
| 1025 | 1025 | } |
| 1026 | 1026 | return(array_filter($tabledata)); |
| 1027 | 1027 | } |
@@ -1094,13 +1094,13 @@ discard block |
||
| 1094 | 1094 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1095 | 1095 | { |
| 1096 | 1096 | $i++; |
| 1097 | - if($i > 3 && count($row) > 2) { |
|
| 1097 | + if ($i > 3 && count($row) > 2) { |
|
| 1098 | 1098 | $data = array_values(array_filter($row)); |
| 1099 | 1099 | $cntdata = count($data); |
| 1100 | 1100 | if ($cntdata > 10) { |
| 1101 | 1101 | $value = $data[9]; |
| 1102 | 1102 | |
| 1103 | - for ($i =10;$i < $cntdata;$i++) { |
|
| 1103 | + for ($i = 10; $i < $cntdata; $i++) { |
|
| 1104 | 1104 | $value .= ' '.$data[$i]; |
| 1105 | 1105 | } |
| 1106 | 1106 | $data[9] = $value; |
@@ -1110,8 +1110,8 @@ discard block |
||
| 1110 | 1110 | $query = 'INSERT INTO waypoints (name_begin,latitude_begin,longitude_begin,name_end,latitude_end,longitude_end,high,base,top,segment_name) VALUES (:name_begin, :latitude_begin, :longitude_begin, :name_end, :latitude_end, :longitude_end, :high, :base, :top, :segment_name)'; |
| 1111 | 1111 | try { |
| 1112 | 1112 | $sth = $Connection->db->prepare($query); |
| 1113 | - $sth->execute(array(':name_begin' => $data[0],':latitude_begin' => $data[1],':longitude_begin' => $data[2],':name_end' => $data[3], ':latitude_end' => $data[4], ':longitude_end' => $data[5], ':high' => $data[6], ':base' => $data[7], ':top' => $data[8], ':segment_name' => $data[9])); |
|
| 1114 | - } catch(PDOException $e) { |
|
| 1113 | + $sth->execute(array(':name_begin' => $data[0], ':latitude_begin' => $data[1], ':longitude_begin' => $data[2], ':name_end' => $data[3], ':latitude_end' => $data[4], ':longitude_end' => $data[5], ':high' => $data[6], ':base' => $data[7], ':top' => $data[8], ':segment_name' => $data[9])); |
|
| 1114 | + } catch (PDOException $e) { |
|
| 1115 | 1115 | return "error : ".$e->getMessage(); |
| 1116 | 1116 | } |
| 1117 | 1117 | } |
@@ -1132,7 +1132,7 @@ discard block |
||
| 1132 | 1132 | $Connection = new Connection(); |
| 1133 | 1133 | $sth = $Connection->db->prepare($query); |
| 1134 | 1134 | $sth->execute(); |
| 1135 | - } catch(PDOException $e) { |
|
| 1135 | + } catch (PDOException $e) { |
|
| 1136 | 1136 | return "error : ".$e->getMessage(); |
| 1137 | 1137 | } |
| 1138 | 1138 | |
@@ -1144,12 +1144,12 @@ discard block |
||
| 1144 | 1144 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 1145 | 1145 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1146 | 1146 | { |
| 1147 | - if(count($row) > 1) { |
|
| 1147 | + if (count($row) > 1) { |
|
| 1148 | 1148 | $query = "INSERT INTO airlines (name,icao,active,forsource) VALUES (:name, :icao, 'Y','ivao')"; |
| 1149 | 1149 | try { |
| 1150 | 1150 | $sth = $Connection->db->prepare($query); |
| 1151 | - $sth->execute(array(':name' => $row[1],':icao' => $row[0])); |
|
| 1152 | - } catch(PDOException $e) { |
|
| 1151 | + $sth->execute(array(':name' => $row[1], ':icao' => $row[0])); |
|
| 1152 | + } catch (PDOException $e) { |
|
| 1153 | 1153 | return "error : ".$e->getMessage(); |
| 1154 | 1154 | } |
| 1155 | 1155 | } |
@@ -1169,21 +1169,21 @@ discard block |
||
| 1169 | 1169 | try { |
| 1170 | 1170 | $sth = $Connection->db->prepare($query); |
| 1171 | 1171 | $sth->execute(); |
| 1172 | - } catch(PDOException $e) { |
|
| 1172 | + } catch (PDOException $e) { |
|
| 1173 | 1173 | return "error : ".$e->getMessage(); |
| 1174 | 1174 | } |
| 1175 | 1175 | } |
| 1176 | 1176 | |
| 1177 | 1177 | |
| 1178 | - if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
| 1178 | + if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz', $tmp_dir.'airspace.sql'); |
|
| 1179 | 1179 | else { |
| 1180 | - update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
| 1180 | + update_db::gunzip('../db/pgsql/airspace.sql.gz', $tmp_dir.'airspace.sql'); |
|
| 1181 | 1181 | $query = "CREATE EXTENSION postgis"; |
| 1182 | - $Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']); |
|
| 1182 | + $Connection = new Connection(null, null, $_SESSION['database_root'], $_SESSION['database_rootpass']); |
|
| 1183 | 1183 | try { |
| 1184 | 1184 | $sth = $Connection->db->prepare($query); |
| 1185 | 1185 | $sth->execute(); |
| 1186 | - } catch(PDOException $e) { |
|
| 1186 | + } catch (PDOException $e) { |
|
| 1187 | 1187 | return "error : ".$e->getMessage(); |
| 1188 | 1188 | } |
| 1189 | 1189 | } |
@@ -1196,7 +1196,7 @@ discard block |
||
| 1196 | 1196 | include_once('class.create_db.php'); |
| 1197 | 1197 | require_once(dirname(__FILE__).'/../require/class.NOTAM.php'); |
| 1198 | 1198 | if ($globalDebug) echo "NOTAM from FlightAirMap website : Download..."; |
| 1199 | - update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz'); |
|
| 1199 | + update_db::download('http://data.flightairmap.fr/data/notam.txt.gz', $tmp_dir.'notam.txt.gz'); |
|
| 1200 | 1200 | $error = ''; |
| 1201 | 1201 | if (file_exists($tmp_dir.'notam.txt.gz')) { |
| 1202 | 1202 | if ($globalDebug) echo "Gunzip..."; |
@@ -1228,14 +1228,14 @@ discard block |
||
| 1228 | 1228 | try { |
| 1229 | 1229 | $sth = $Connection->db->prepare($query); |
| 1230 | 1230 | $sth->execute(); |
| 1231 | - } catch(PDOException $e) { |
|
| 1231 | + } catch (PDOException $e) { |
|
| 1232 | 1232 | echo "error : ".$e->getMessage(); |
| 1233 | 1233 | } |
| 1234 | 1234 | } |
| 1235 | 1235 | if ($globalDBdriver == 'mysql') { |
| 1236 | - update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql'); |
|
| 1236 | + update_db::gunzip('../db/countries.sql.gz', $tmp_dir.'countries.sql'); |
|
| 1237 | 1237 | } else { |
| 1238 | - update_db::gunzip('../db/pgsql/countries.sql.gz',$tmp_dir.'countries.sql'); |
|
| 1238 | + update_db::gunzip('../db/pgsql/countries.sql.gz', $tmp_dir.'countries.sql'); |
|
| 1239 | 1239 | } |
| 1240 | 1240 | $error = create_db::import_file($tmp_dir.'countries.sql'); |
| 1241 | 1241 | return $error; |
@@ -1248,7 +1248,7 @@ discard block |
||
| 1248 | 1248 | // update_db::unzip($tmp_dir.'AptNav.zip'); |
| 1249 | 1249 | // update_db::download('https://gitorious.org/fg/fgdata/raw/e81f8a15424a175a7b715f8f7eb8f4147b802a27:Navaids/awy.dat.gz',$tmp_dir.'awy.dat.gz'); |
| 1250 | 1250 | // update_db::download('http://sourceforge.net/p/flightgear/fgdata/ci/next/tree/Navaids/awy.dat.gz?format=raw',$tmp_dir.'awy.dat.gz','http://sourceforge.net'); |
| 1251 | - update_db::download('http://pkgs.fedoraproject.org/repo/extras/FlightGear-Atlas/awy.dat.gz/f530c9d1c4b31a288ba88dcc8224268b/awy.dat.gz',$tmp_dir.'awy.dat.gz','http://sourceforge.net'); |
|
| 1251 | + update_db::download('http://pkgs.fedoraproject.org/repo/extras/FlightGear-Atlas/awy.dat.gz/f530c9d1c4b31a288ba88dcc8224268b/awy.dat.gz', $tmp_dir.'awy.dat.gz', 'http://sourceforge.net'); |
|
| 1252 | 1252 | update_db::gunzip($tmp_dir.'awy.dat.gz'); |
| 1253 | 1253 | $error = update_db::waypoints($tmp_dir.'awy.dat'); |
| 1254 | 1254 | return $error; |
@@ -1268,7 +1268,7 @@ discard block |
||
| 1268 | 1268 | update_db::ivao_airlines($tmp_dir.'data/airlines.dat'); |
| 1269 | 1269 | if ($globalDebug) echo "Copy airlines logos to airlines images directory..."; |
| 1270 | 1270 | if (is_writable(dirname(__FILE__).'/../images/airlines')) { |
| 1271 | - if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
| 1271 | + if (!$Common->xcopy($tmp_dir.'logos/', dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
| 1272 | 1272 | } else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
| 1273 | 1273 | } else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
| 1274 | 1274 | if ($error != '') { |
@@ -1281,7 +1281,7 @@ discard block |
||
| 1281 | 1281 | global $tmp_dir, $globalDebug; |
| 1282 | 1282 | $error = ''; |
| 1283 | 1283 | if ($globalDebug) echo "Routes : Download..."; |
| 1284 | - update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz'); |
|
| 1284 | + update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz', $tmp_dir.'StandingData.sqb.gz'); |
|
| 1285 | 1285 | if (file_exists($tmp_dir.'StandingData.sqb.gz')) { |
| 1286 | 1286 | if ($globalDebug) echo "Gunzip..."; |
| 1287 | 1287 | update_db::gunzip($tmp_dir.'StandingData.sqb.gz'); |
@@ -1297,7 +1297,7 @@ discard block |
||
| 1297 | 1297 | global $tmp_dir, $globalDebug; |
| 1298 | 1298 | $error = ''; |
| 1299 | 1299 | if ($globalDebug) echo "Schedules Oneworld : Download..."; |
| 1300 | - update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz'); |
|
| 1300 | + update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz', $tmp_dir.'oneworld.csv.gz'); |
|
| 1301 | 1301 | if (file_exists($tmp_dir.'oneworld.csv.gz')) { |
| 1302 | 1302 | if ($globalDebug) echo "Gunzip..."; |
| 1303 | 1303 | update_db::gunzip($tmp_dir.'oneworld.csv.gz'); |
@@ -1313,7 +1313,7 @@ discard block |
||
| 1313 | 1313 | global $tmp_dir, $globalDebug; |
| 1314 | 1314 | $error = ''; |
| 1315 | 1315 | if ($globalDebug) echo "Schedules Skyteam : Download..."; |
| 1316 | - update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz'); |
|
| 1316 | + update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz', $tmp_dir.'skyteam.csv.gz'); |
|
| 1317 | 1317 | if (file_exists($tmp_dir.'skyteam.csv.gz')) { |
| 1318 | 1318 | if ($globalDebug) echo "Gunzip..."; |
| 1319 | 1319 | update_db::gunzip($tmp_dir.'skyteam.csv.gz'); |
@@ -1341,7 +1341,7 @@ discard block |
||
| 1341 | 1341 | */ |
| 1342 | 1342 | if ($globalDebug) echo "Modes : Download..."; |
| 1343 | 1343 | // update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
| 1344 | - update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz',$tmp_dir.'basestation_latest.gz'); |
|
| 1344 | + update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz', $tmp_dir.'basestation_latest.gz'); |
|
| 1345 | 1345 | // if (file_exists($tmp_dir.'basestation_latest.zip')) { |
| 1346 | 1346 | if (file_exists($tmp_dir.'basestation_latest.gz')) { |
| 1347 | 1347 | if ($globalDebug) echo "Unzip..."; |
@@ -1359,7 +1359,7 @@ discard block |
||
| 1359 | 1359 | public static function update_ModeS_flarm() { |
| 1360 | 1360 | global $tmp_dir, $globalDebug; |
| 1361 | 1361 | if ($globalDebug) echo "Modes Flarmnet: Download..."; |
| 1362 | - update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln'); |
|
| 1362 | + update_db::download('http://flarmnet.org/files/data.fln', $tmp_dir.'data.fln'); |
|
| 1363 | 1363 | if (file_exists($tmp_dir.'data.fln')) { |
| 1364 | 1364 | if ($globalDebug) echo "Add to DB..."; |
| 1365 | 1365 | $error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln'); |
@@ -1373,7 +1373,7 @@ discard block |
||
| 1373 | 1373 | public static function update_ModeS_ogn() { |
| 1374 | 1374 | global $tmp_dir, $globalDebug; |
| 1375 | 1375 | if ($globalDebug) echo "Modes OGN: Download..."; |
| 1376 | - update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv'); |
|
| 1376 | + update_db::download('http://ddb.glidernet.org/download/', $tmp_dir.'ogn.csv'); |
|
| 1377 | 1377 | if (file_exists($tmp_dir.'ogn.csv')) { |
| 1378 | 1378 | if ($globalDebug) echo "Add to DB..."; |
| 1379 | 1379 | $error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv'); |
@@ -1388,173 +1388,173 @@ discard block |
||
| 1388 | 1388 | global $tmp_dir, $globalDebug; |
| 1389 | 1389 | |
| 1390 | 1390 | if ($globalDebug) echo "Owner France: Download..."; |
| 1391 | - update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv'); |
|
| 1391 | + update_db::download('http://antonakis.co.uk/registers/France.txt', $tmp_dir.'owner_f.csv'); |
|
| 1392 | 1392 | if (file_exists($tmp_dir.'owner_f.csv')) { |
| 1393 | 1393 | if ($globalDebug) echo "Add to DB..."; |
| 1394 | - $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F'); |
|
| 1394 | + $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv', 'F'); |
|
| 1395 | 1395 | } else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
| 1396 | 1396 | if ($error != '') { |
| 1397 | 1397 | return $error; |
| 1398 | 1398 | } elseif ($globalDebug) echo "Done\n"; |
| 1399 | 1399 | |
| 1400 | 1400 | if ($globalDebug) echo "Owner Ireland: Download..."; |
| 1401 | - update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv'); |
|
| 1401 | + update_db::download('http://antonakis.co.uk/registers/Ireland.txt', $tmp_dir.'owner_ei.csv'); |
|
| 1402 | 1402 | if (file_exists($tmp_dir.'owner_ei.csv')) { |
| 1403 | 1403 | if ($globalDebug) echo "Add to DB..."; |
| 1404 | - $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI'); |
|
| 1404 | + $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv', 'EI'); |
|
| 1405 | 1405 | } else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
| 1406 | 1406 | if ($error != '') { |
| 1407 | 1407 | return $error; |
| 1408 | 1408 | } elseif ($globalDebug) echo "Done\n"; |
| 1409 | 1409 | if ($globalDebug) echo "Owner Switzerland: Download..."; |
| 1410 | - update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv'); |
|
| 1410 | + update_db::download('http://antonakis.co.uk/registers/Switzerland.txt', $tmp_dir.'owner_hb.csv'); |
|
| 1411 | 1411 | if (file_exists($tmp_dir.'owner_hb.csv')) { |
| 1412 | 1412 | if ($globalDebug) echo "Add to DB..."; |
| 1413 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB'); |
|
| 1413 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv', 'HB'); |
|
| 1414 | 1414 | } else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
| 1415 | 1415 | if ($error != '') { |
| 1416 | 1416 | return $error; |
| 1417 | 1417 | } elseif ($globalDebug) echo "Done\n"; |
| 1418 | 1418 | if ($globalDebug) echo "Owner Czech Republic: Download..."; |
| 1419 | - update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv'); |
|
| 1419 | + update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt', $tmp_dir.'owner_ok.csv'); |
|
| 1420 | 1420 | if (file_exists($tmp_dir.'owner_ok.csv')) { |
| 1421 | 1421 | if ($globalDebug) echo "Add to DB..."; |
| 1422 | - $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK'); |
|
| 1422 | + $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv', 'OK'); |
|
| 1423 | 1423 | } else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
| 1424 | 1424 | if ($error != '') { |
| 1425 | 1425 | return $error; |
| 1426 | 1426 | } elseif ($globalDebug) echo "Done\n"; |
| 1427 | 1427 | if ($globalDebug) echo "Owner Australia: Download..."; |
| 1428 | - update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv'); |
|
| 1428 | + update_db::download('http://antonakis.co.uk/registers/Australia.txt', $tmp_dir.'owner_vh.csv'); |
|
| 1429 | 1429 | if (file_exists($tmp_dir.'owner_vh.csv')) { |
| 1430 | 1430 | if ($globalDebug) echo "Add to DB..."; |
| 1431 | - $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH'); |
|
| 1431 | + $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv', 'VH'); |
|
| 1432 | 1432 | } else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
| 1433 | 1433 | if ($error != '') { |
| 1434 | 1434 | return $error; |
| 1435 | 1435 | } elseif ($globalDebug) echo "Done\n"; |
| 1436 | 1436 | if ($globalDebug) echo "Owner Austria: Download..."; |
| 1437 | - update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv'); |
|
| 1437 | + update_db::download('http://antonakis.co.uk/registers/Austria.txt', $tmp_dir.'owner_oe.csv'); |
|
| 1438 | 1438 | if (file_exists($tmp_dir.'owner_oe.csv')) { |
| 1439 | 1439 | if ($globalDebug) echo "Add to DB..."; |
| 1440 | - $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE'); |
|
| 1440 | + $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv', 'OE'); |
|
| 1441 | 1441 | } else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
| 1442 | 1442 | if ($error != '') { |
| 1443 | 1443 | return $error; |
| 1444 | 1444 | } elseif ($globalDebug) echo "Done\n"; |
| 1445 | 1445 | if ($globalDebug) echo "Owner Chile: Download..."; |
| 1446 | - update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv'); |
|
| 1446 | + update_db::download('http://antonakis.co.uk/registers/Chile.txt', $tmp_dir.'owner_cc.csv'); |
|
| 1447 | 1447 | if (file_exists($tmp_dir.'owner_cc.csv')) { |
| 1448 | 1448 | if ($globalDebug) echo "Add to DB..."; |
| 1449 | - $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC'); |
|
| 1449 | + $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv', 'CC'); |
|
| 1450 | 1450 | } else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
| 1451 | 1451 | if ($error != '') { |
| 1452 | 1452 | return $error; |
| 1453 | 1453 | } elseif ($globalDebug) echo "Done\n"; |
| 1454 | 1454 | if ($globalDebug) echo "Owner Colombia: Download..."; |
| 1455 | - update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv'); |
|
| 1455 | + update_db::download('http://antonakis.co.uk/registers/Colombia.txt', $tmp_dir.'owner_hj.csv'); |
|
| 1456 | 1456 | if (file_exists($tmp_dir.'owner_hj.csv')) { |
| 1457 | 1457 | if ($globalDebug) echo "Add to DB..."; |
| 1458 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ'); |
|
| 1458 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv', 'HJ'); |
|
| 1459 | 1459 | } else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
| 1460 | 1460 | if ($error != '') { |
| 1461 | 1461 | return $error; |
| 1462 | 1462 | } elseif ($globalDebug) echo "Done\n"; |
| 1463 | 1463 | if ($globalDebug) echo "Owner Bosnia Herzegobina: Download..."; |
| 1464 | - update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv'); |
|
| 1464 | + update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt', $tmp_dir.'owner_e7.csv'); |
|
| 1465 | 1465 | if (file_exists($tmp_dir.'owner_e7.csv')) { |
| 1466 | 1466 | if ($globalDebug) echo "Add to DB..."; |
| 1467 | - $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7'); |
|
| 1467 | + $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv', 'E7'); |
|
| 1468 | 1468 | } else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
| 1469 | 1469 | if ($error != '') { |
| 1470 | 1470 | return $error; |
| 1471 | 1471 | } elseif ($globalDebug) echo "Done\n"; |
| 1472 | 1472 | if ($globalDebug) echo "Owner Brazil: Download..."; |
| 1473 | - update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv'); |
|
| 1473 | + update_db::download('http://antonakis.co.uk/registers/Brazil.txt', $tmp_dir.'owner_pp.csv'); |
|
| 1474 | 1474 | if (file_exists($tmp_dir.'owner_pp.csv')) { |
| 1475 | 1475 | if ($globalDebug) echo "Add to DB..."; |
| 1476 | - $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP'); |
|
| 1476 | + $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv', 'PP'); |
|
| 1477 | 1477 | } else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
| 1478 | 1478 | if ($error != '') { |
| 1479 | 1479 | return $error; |
| 1480 | 1480 | } elseif ($globalDebug) echo "Done\n"; |
| 1481 | 1481 | if ($globalDebug) echo "Owner Cayman Islands: Download..."; |
| 1482 | - update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv'); |
|
| 1482 | + update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt', $tmp_dir.'owner_vp.csv'); |
|
| 1483 | 1483 | if (file_exists($tmp_dir.'owner_vp.csv')) { |
| 1484 | 1484 | if ($globalDebug) echo "Add to DB..."; |
| 1485 | - $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP'); |
|
| 1485 | + $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv', 'VP'); |
|
| 1486 | 1486 | } else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
| 1487 | 1487 | if ($error != '') { |
| 1488 | 1488 | return $error; |
| 1489 | 1489 | } elseif ($globalDebug) echo "Done\n"; |
| 1490 | 1490 | if ($globalDebug) echo "Owner Croatia: Download..."; |
| 1491 | - update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv'); |
|
| 1491 | + update_db::download('http://antonakis.co.uk/registers/Croatia.txt', $tmp_dir.'owner_9a.csv'); |
|
| 1492 | 1492 | if (file_exists($tmp_dir.'owner_9a.csv')) { |
| 1493 | 1493 | if ($globalDebug) echo "Add to DB..."; |
| 1494 | - $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A'); |
|
| 1494 | + $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv', '9A'); |
|
| 1495 | 1495 | } else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
| 1496 | 1496 | if ($error != '') { |
| 1497 | 1497 | return $error; |
| 1498 | 1498 | } elseif ($globalDebug) echo "Done\n"; |
| 1499 | 1499 | if ($globalDebug) echo "Owner Luxembourg: Download..."; |
| 1500 | - update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv'); |
|
| 1500 | + update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt', $tmp_dir.'owner_lx.csv'); |
|
| 1501 | 1501 | if (file_exists($tmp_dir.'owner_lx.csv')) { |
| 1502 | 1502 | if ($globalDebug) echo "Add to DB..."; |
| 1503 | - $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX'); |
|
| 1503 | + $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv', 'LX'); |
|
| 1504 | 1504 | } else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
| 1505 | 1505 | if ($error != '') { |
| 1506 | 1506 | return $error; |
| 1507 | 1507 | } elseif ($globalDebug) echo "Done\n"; |
| 1508 | 1508 | if ($globalDebug) echo "Owner Maldives: Download..."; |
| 1509 | - update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv'); |
|
| 1509 | + update_db::download('http://antonakis.co.uk/registers/Maldives.txt', $tmp_dir.'owner_8q.csv'); |
|
| 1510 | 1510 | if (file_exists($tmp_dir.'owner_8q.csv')) { |
| 1511 | 1511 | if ($globalDebug) echo "Add to DB..."; |
| 1512 | - $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q'); |
|
| 1512 | + $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv', '8Q'); |
|
| 1513 | 1513 | } else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
| 1514 | 1514 | if ($error != '') { |
| 1515 | 1515 | return $error; |
| 1516 | 1516 | } elseif ($globalDebug) echo "Done\n"; |
| 1517 | 1517 | if ($globalDebug) echo "Owner New Zealand: Download..."; |
| 1518 | - update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv'); |
|
| 1518 | + update_db::download('http://antonakis.co.uk/registers/NewZealand.txt', $tmp_dir.'owner_zk.csv'); |
|
| 1519 | 1519 | if (file_exists($tmp_dir.'owner_zk.csv')) { |
| 1520 | 1520 | if ($globalDebug) echo "Add to DB..."; |
| 1521 | - $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK'); |
|
| 1521 | + $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv', 'ZK'); |
|
| 1522 | 1522 | } else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
| 1523 | 1523 | if ($error != '') { |
| 1524 | 1524 | return $error; |
| 1525 | 1525 | } elseif ($globalDebug) echo "Done\n"; |
| 1526 | 1526 | if ($globalDebug) echo "Owner Papua New Guinea: Download..."; |
| 1527 | - update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv'); |
|
| 1527 | + update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt', $tmp_dir.'owner_p2.csv'); |
|
| 1528 | 1528 | if (file_exists($tmp_dir.'owner_p2.csv')) { |
| 1529 | 1529 | if ($globalDebug) echo "Add to DB..."; |
| 1530 | - $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2'); |
|
| 1530 | + $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv', 'P2'); |
|
| 1531 | 1531 | } else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
| 1532 | 1532 | if ($error != '') { |
| 1533 | 1533 | return $error; |
| 1534 | 1534 | } elseif ($globalDebug) echo "Done\n"; |
| 1535 | 1535 | if ($globalDebug) echo "Owner Slovakia: Download..."; |
| 1536 | - update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv'); |
|
| 1536 | + update_db::download('http://antonakis.co.uk/registers/Slovakia.txt', $tmp_dir.'owner_om.csv'); |
|
| 1537 | 1537 | if (file_exists($tmp_dir.'owner_om.csv')) { |
| 1538 | 1538 | if ($globalDebug) echo "Add to DB..."; |
| 1539 | - $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM'); |
|
| 1539 | + $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv', 'OM'); |
|
| 1540 | 1540 | } else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
| 1541 | 1541 | if ($error != '') { |
| 1542 | 1542 | return $error; |
| 1543 | 1543 | } elseif ($globalDebug) echo "Done\n"; |
| 1544 | 1544 | if ($globalDebug) echo "Owner Ecuador: Download..."; |
| 1545 | - update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv'); |
|
| 1545 | + update_db::download('http://antonakis.co.uk/registers/Ecuador.txt', $tmp_dir.'owner_hc.csv'); |
|
| 1546 | 1546 | if (file_exists($tmp_dir.'owner_hc.csv')) { |
| 1547 | 1547 | if ($globalDebug) echo "Add to DB..."; |
| 1548 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC'); |
|
| 1548 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv', 'HC'); |
|
| 1549 | 1549 | } else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
| 1550 | 1550 | if ($error != '') { |
| 1551 | 1551 | return $error; |
| 1552 | 1552 | } elseif ($globalDebug) echo "Done\n"; |
| 1553 | 1553 | if ($globalDebug) echo "Owner Iceland: Download..."; |
| 1554 | - update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv'); |
|
| 1554 | + update_db::download('http://antonakis.co.uk/registers/Iceland.txt', $tmp_dir.'owner_tf.csv'); |
|
| 1555 | 1555 | if (file_exists($tmp_dir.'owner_tf.csv')) { |
| 1556 | 1556 | if ($globalDebug) echo "Add to DB..."; |
| 1557 | - $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF'); |
|
| 1557 | + $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv', 'TF'); |
|
| 1558 | 1558 | } else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
| 1559 | 1559 | if ($error != '') { |
| 1560 | 1560 | return $error; |
@@ -1566,7 +1566,7 @@ discard block |
||
| 1566 | 1566 | global $tmp_dir, $globalDebug; |
| 1567 | 1567 | $error = ''; |
| 1568 | 1568 | if ($globalDebug) echo "Translation : Download..."; |
| 1569 | - update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip'); |
|
| 1569 | + update_db::download('http://www.acarsd.org/download/translation.php', $tmp_dir.'translation.zip'); |
|
| 1570 | 1570 | if (file_exists($tmp_dir.'translation.zip')) { |
| 1571 | 1571 | if ($globalDebug) echo "Unzip..."; |
| 1572 | 1572 | update_db::unzip($tmp_dir.'translation.zip'); |
@@ -1582,7 +1582,7 @@ discard block |
||
| 1582 | 1582 | public static function update_translation_fam() { |
| 1583 | 1583 | global $tmp_dir, $globalDebug; |
| 1584 | 1584 | if ($globalDebug) echo "Translation from FlightAirMap website : Download..."; |
| 1585 | - update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz'); |
|
| 1585 | + update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz', $tmp_dir.'translation.tsv.gz'); |
|
| 1586 | 1586 | if (file_exists($tmp_dir.'translation.tsv.gz')) { |
| 1587 | 1587 | if ($globalDebug) echo "Gunzip..."; |
| 1588 | 1588 | update_db::gunzip($tmp_dir.'translation.tsv.gz'); |
@@ -1601,18 +1601,18 @@ discard block |
||
| 1601 | 1601 | $error = ''; |
| 1602 | 1602 | if ($globalDebug) echo "Airspace from FlightAirMap website : Download..."; |
| 1603 | 1603 | if ($globalDBdriver == 'mysql') { |
| 1604 | - update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); |
|
| 1604 | + update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5'); |
|
| 1605 | 1605 | } else { |
| 1606 | - update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); |
|
| 1606 | + update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5'); |
|
| 1607 | 1607 | } |
| 1608 | 1608 | if (file_exists($tmp_dir.'airspace.sql.gz.md5')) { |
| 1609 | - $airspace_md5_file = explode(' ',file_get_contents($tmp_dir.'airspace.sql.gz.md5')); |
|
| 1609 | + $airspace_md5_file = explode(' ', file_get_contents($tmp_dir.'airspace.sql.gz.md5')); |
|
| 1610 | 1610 | $airspace_md5 = $airspace_md5_file[0]; |
| 1611 | 1611 | if (!update_db::check_airspace_version($airspace_md5)) { |
| 1612 | 1612 | if ($globalDBdriver == 'mysql') { |
| 1613 | - update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz',$tmp_dir.'airspace.sql.gz'); |
|
| 1613 | + update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz', $tmp_dir.'airspace.sql.gz'); |
|
| 1614 | 1614 | } else { |
| 1615 | - update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz'); |
|
| 1615 | + update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz', $tmp_dir.'airspace.sql.gz'); |
|
| 1616 | 1616 | } |
| 1617 | 1617 | if (file_exists($tmp_dir.'airspace.sql.gz')) { |
| 1618 | 1618 | if ($globalDebug) echo "Gunzip..."; |
@@ -1624,7 +1624,7 @@ discard block |
||
| 1624 | 1624 | try { |
| 1625 | 1625 | $sth = $Connection->db->prepare($query); |
| 1626 | 1626 | $sth->execute(); |
| 1627 | - } catch(PDOException $e) { |
|
| 1627 | + } catch (PDOException $e) { |
|
| 1628 | 1628 | return "error : ".$e->getMessage(); |
| 1629 | 1629 | } |
| 1630 | 1630 | } |
@@ -1642,15 +1642,15 @@ discard block |
||
| 1642 | 1642 | public static function update_tle() { |
| 1643 | 1643 | global $tmp_dir, $globalDebug; |
| 1644 | 1644 | if ($globalDebug) echo "Download TLE : Download..."; |
| 1645 | - $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', |
|
| 1646 | - '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', |
|
| 1647 | - 'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt'); |
|
| 1645 | + $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', |
|
| 1646 | + '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', |
|
| 1647 | + 'engineering.txt', 'education.txt', 'military.txt', 'radar.txt', 'cubesat.txt', 'other.txt', 'tle-new.txt'); |
|
| 1648 | 1648 | foreach ($alltle as $filename) { |
| 1649 | 1649 | if ($globalDebug) echo "downloading ".$filename.'...'; |
| 1650 | - update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename); |
|
| 1650 | + update_db::download('http://celestrak.com/NORAD/elements/'.$filename, $tmp_dir.$filename); |
|
| 1651 | 1651 | if (file_exists($tmp_dir.$filename)) { |
| 1652 | 1652 | if ($globalDebug) echo "Add to DB ".$filename."..."; |
| 1653 | - $error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename)); |
|
| 1653 | + $error = update_db::tle($tmp_dir.$filename, str_replace('.txt', '', $filename)); |
|
| 1654 | 1654 | } else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
| 1655 | 1655 | if ($error != '') { |
| 1656 | 1656 | echo $error."\n"; |
@@ -1663,32 +1663,32 @@ discard block |
||
| 1663 | 1663 | global $tmp_dir, $globalDebug; |
| 1664 | 1664 | $error = ''; |
| 1665 | 1665 | if ($globalDebug) echo "Models from FlightAirMap website : Download..."; |
| 1666 | - update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum'); |
|
| 1666 | + update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', $tmp_dir.'models.md5sum'); |
|
| 1667 | 1667 | if (file_exists($tmp_dir.'models.md5sum')) { |
| 1668 | 1668 | if ($globalDebug) echo "Check files...\n"; |
| 1669 | 1669 | $newmodelsdb = array(); |
| 1670 | - if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) { |
|
| 1671 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
| 1670 | + if (($handle = fopen($tmp_dir.'models.md5sum', 'r')) !== FALSE) { |
|
| 1671 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
| 1672 | 1672 | $model = trim($row[2]); |
| 1673 | 1673 | $newmodelsdb[$model] = trim($row[0]); |
| 1674 | 1674 | } |
| 1675 | 1675 | } |
| 1676 | 1676 | $modelsdb = array(); |
| 1677 | 1677 | if (file_exists(dirname(__FILE__).'/../models/models.md5sum')) { |
| 1678 | - if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum','r')) !== FALSE) { |
|
| 1679 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
| 1678 | + if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum', 'r')) !== FALSE) { |
|
| 1679 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
| 1680 | 1680 | $model = trim($row[2]); |
| 1681 | 1681 | $modelsdb[$model] = trim($row[0]); |
| 1682 | 1682 | } |
| 1683 | 1683 | } |
| 1684 | 1684 | } |
| 1685 | - $diff = array_diff($newmodelsdb,$modelsdb); |
|
| 1685 | + $diff = array_diff($newmodelsdb, $modelsdb); |
|
| 1686 | 1686 | foreach ($diff as $key => $value) { |
| 1687 | 1687 | if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n"; |
| 1688 | - update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key); |
|
| 1688 | + update_db::download('http://data.flightairmap.fr/data/models/'.$key, dirname(__FILE__).'/../models/'.$key); |
|
| 1689 | 1689 | |
| 1690 | 1690 | } |
| 1691 | - update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum'); |
|
| 1691 | + update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', dirname(__FILE__).'/../models/models.md5sum'); |
|
| 1692 | 1692 | } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
| 1693 | 1693 | if ($error != '') { |
| 1694 | 1694 | return $error; |
@@ -1700,32 +1700,32 @@ discard block |
||
| 1700 | 1700 | global $tmp_dir, $globalDebug; |
| 1701 | 1701 | $error = ''; |
| 1702 | 1702 | if ($globalDebug) echo "Space models from FlightAirMap website : Download..."; |
| 1703 | - update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum'); |
|
| 1703 | + update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', $tmp_dir.'space_models.md5sum'); |
|
| 1704 | 1704 | if (file_exists($tmp_dir.'space_models.md5sum')) { |
| 1705 | 1705 | if ($globalDebug) echo "Check files...\n"; |
| 1706 | 1706 | $newmodelsdb = array(); |
| 1707 | - if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) { |
|
| 1708 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
| 1707 | + if (($handle = fopen($tmp_dir.'space_models.md5sum', 'r')) !== FALSE) { |
|
| 1708 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
| 1709 | 1709 | $model = trim($row[2]); |
| 1710 | 1710 | $newmodelsdb[$model] = trim($row[0]); |
| 1711 | 1711 | } |
| 1712 | 1712 | } |
| 1713 | 1713 | $modelsdb = array(); |
| 1714 | 1714 | if (file_exists(dirname(__FILE__).'/../models/space/space_models.md5sum')) { |
| 1715 | - if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum','r')) !== FALSE) { |
|
| 1716 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
| 1715 | + if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum', 'r')) !== FALSE) { |
|
| 1716 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
| 1717 | 1717 | $model = trim($row[2]); |
| 1718 | 1718 | $modelsdb[$model] = trim($row[0]); |
| 1719 | 1719 | } |
| 1720 | 1720 | } |
| 1721 | 1721 | } |
| 1722 | - $diff = array_diff($newmodelsdb,$modelsdb); |
|
| 1722 | + $diff = array_diff($newmodelsdb, $modelsdb); |
|
| 1723 | 1723 | foreach ($diff as $key => $value) { |
| 1724 | 1724 | if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n"; |
| 1725 | - update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key); |
|
| 1725 | + update_db::download('http://data.flightairmap.fr/data/models/space/'.$key, dirname(__FILE__).'/../models/space/'.$key); |
|
| 1726 | 1726 | |
| 1727 | 1727 | } |
| 1728 | - update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum'); |
|
| 1728 | + update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', dirname(__FILE__).'/../models/space/space_models.md5sum'); |
|
| 1729 | 1729 | } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
| 1730 | 1730 | if ($error != '') { |
| 1731 | 1731 | return $error; |
@@ -1748,8 +1748,8 @@ discard block |
||
| 1748 | 1748 | */ |
| 1749 | 1749 | if (file_exists($tmp_dir.'aircrafts.html')) { |
| 1750 | 1750 | //var_dump(file_get_html($tmp_dir.'aircrafts.html')); |
| 1751 | - $fh = fopen($tmp_dir.'aircrafts.html',"r"); |
|
| 1752 | - $result = fread($fh,100000000); |
|
| 1751 | + $fh = fopen($tmp_dir.'aircrafts.html', "r"); |
|
| 1752 | + $result = fread($fh, 100000000); |
|
| 1753 | 1753 | //echo $result; |
| 1754 | 1754 | //var_dump(str_get_html($result)); |
| 1755 | 1755 | //print_r(self::table2array($result)); |
@@ -1767,23 +1767,23 @@ discard block |
||
| 1767 | 1767 | $Connection = new Connection(); |
| 1768 | 1768 | $sth = $Connection->db->prepare($query); |
| 1769 | 1769 | $sth->execute(); |
| 1770 | - } catch(PDOException $e) { |
|
| 1770 | + } catch (PDOException $e) { |
|
| 1771 | 1771 | return "error : ".$e->getMessage(); |
| 1772 | 1772 | } |
| 1773 | 1773 | |
| 1774 | 1774 | $error = ''; |
| 1775 | 1775 | if ($globalDebug) echo "Notam : Download..."; |
| 1776 | - update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss'); |
|
| 1776 | + update_db::download($globalNOTAMSource, $tmp_dir.'notam.rss'); |
|
| 1777 | 1777 | if (file_exists($tmp_dir.'notam.rss')) { |
| 1778 | - $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true); |
|
| 1778 | + $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')), true); |
|
| 1779 | 1779 | foreach ($notams['channel']['item'] as $notam) { |
| 1780 | - $title = explode(':',$notam['title']); |
|
| 1780 | + $title = explode(':', $notam['title']); |
|
| 1781 | 1781 | $data['ref'] = trim($title[0]); |
| 1782 | 1782 | unset($title[0]); |
| 1783 | - $data['title'] = trim(implode(':',$title)); |
|
| 1784 | - $description = strip_tags($notam['description'],'<pre>'); |
|
| 1785 | - preg_match(':^(.*?)<pre>:',$description,$match); |
|
| 1786 | - $q = explode('/',$match[1]); |
|
| 1783 | + $data['title'] = trim(implode(':', $title)); |
|
| 1784 | + $description = strip_tags($notam['description'], '<pre>'); |
|
| 1785 | + preg_match(':^(.*?)<pre>:', $description, $match); |
|
| 1786 | + $q = explode('/', $match[1]); |
|
| 1787 | 1787 | $data['fir'] = $q[0]; |
| 1788 | 1788 | $data['code'] = $q[1]; |
| 1789 | 1789 | $ifrvfr = $q[2]; |
@@ -1799,30 +1799,30 @@ discard block |
||
| 1799 | 1799 | $data['lower_limit'] = $q[5]; |
| 1800 | 1800 | $data['upper_limit'] = $q[6]; |
| 1801 | 1801 | $latlonrad = $q[7]; |
| 1802 | - sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius); |
|
| 1803 | - $latitude = $Common->convertDec($las,'latitude'); |
|
| 1804 | - $longitude = $Common->convertDec($lns,'longitude'); |
|
| 1802 | + sscanf($latlonrad, '%4c%c%5c%c%3d', $las, $lac, $lns, $lnc, $radius); |
|
| 1803 | + $latitude = $Common->convertDec($las, 'latitude'); |
|
| 1804 | + $longitude = $Common->convertDec($lns, 'longitude'); |
|
| 1805 | 1805 | if ($lac == 'S') $latitude = '-'.$latitude; |
| 1806 | 1806 | if ($lnc == 'W') $longitude = '-'.$longitude; |
| 1807 | 1807 | $data['center_latitude'] = $latitude; |
| 1808 | 1808 | $data['center_longitude'] = $longitude; |
| 1809 | 1809 | $data['radius'] = intval($radius); |
| 1810 | 1810 | |
| 1811 | - preg_match(':<pre>(.*?)</pre>:',$description,$match); |
|
| 1811 | + preg_match(':<pre>(.*?)</pre>:', $description, $match); |
|
| 1812 | 1812 | $data['text'] = $match[1]; |
| 1813 | - preg_match(':</pre>(.*?)$:',$description,$match); |
|
| 1813 | + preg_match(':</pre>(.*?)$:', $description, $match); |
|
| 1814 | 1814 | $fromto = $match[1]; |
| 1815 | - preg_match('#FROM:(.*?)TO:#',$fromto,$match); |
|
| 1815 | + preg_match('#FROM:(.*?)TO:#', $fromto, $match); |
|
| 1816 | 1816 | $fromall = trim($match[1]); |
| 1817 | - preg_match('#^(.*?) \((.*?)\)$#',$fromall,$match); |
|
| 1817 | + preg_match('#^(.*?) \((.*?)\)$#', $fromall, $match); |
|
| 1818 | 1818 | $from = trim($match[1]); |
| 1819 | - $data['date_begin'] = date("Y-m-d H:i:s",strtotime($from)); |
|
| 1820 | - preg_match('#TO:(.*?)$#',$fromto,$match); |
|
| 1819 | + $data['date_begin'] = date("Y-m-d H:i:s", strtotime($from)); |
|
| 1820 | + preg_match('#TO:(.*?)$#', $fromto, $match); |
|
| 1821 | 1821 | $toall = trim($match[1]); |
| 1822 | - if (!preg_match(':Permanent:',$toall)) { |
|
| 1823 | - preg_match('#^(.*?) \((.*?)\)#',$toall,$match); |
|
| 1822 | + if (!preg_match(':Permanent:', $toall)) { |
|
| 1823 | + preg_match('#^(.*?) \((.*?)\)#', $toall, $match); |
|
| 1824 | 1824 | $to = trim($match[1]); |
| 1825 | - $data['date_end'] = date("Y-m-d H:i:s",strtotime($to)); |
|
| 1825 | + $data['date_end'] = date("Y-m-d H:i:s", strtotime($to)); |
|
| 1826 | 1826 | $data['permanent'] = 0; |
| 1827 | 1827 | } else { |
| 1828 | 1828 | $data['date_end'] = NULL; |
@@ -1830,7 +1830,7 @@ discard block |
||
| 1830 | 1830 | } |
| 1831 | 1831 | $data['full_notam'] = $notam['title'].'<br>'.$notam['description']; |
| 1832 | 1832 | $NOTAM = new NOTAM(); |
| 1833 | - $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']); |
|
| 1833 | + $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']); |
|
| 1834 | 1834 | unset($data); |
| 1835 | 1835 | } |
| 1836 | 1836 | } else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
@@ -1853,16 +1853,16 @@ discard block |
||
| 1853 | 1853 | $Connection = new Connection(); |
| 1854 | 1854 | $sth = $Connection->db->prepare($query); |
| 1855 | 1855 | $sth->execute(); |
| 1856 | - } catch(PDOException $e) { |
|
| 1856 | + } catch (PDOException $e) { |
|
| 1857 | 1857 | return "error : ".$e->getMessage(); |
| 1858 | 1858 | } |
| 1859 | 1859 | } |
| 1860 | 1860 | $Common = new Common(); |
| 1861 | 1861 | $airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json'); |
| 1862 | - $airspace_json = json_decode($airspace_lst,true); |
|
| 1862 | + $airspace_json = json_decode($airspace_lst, true); |
|
| 1863 | 1863 | foreach ($airspace_json['records'] as $airspace) { |
| 1864 | 1864 | if ($globalDebug) echo $airspace['name']."...\n"; |
| 1865 | - update_db::download($airspace['uri'],$tmp_dir.$airspace['name']); |
|
| 1865 | + update_db::download($airspace['uri'], $tmp_dir.$airspace['name']); |
|
| 1866 | 1866 | if (file_exists($tmp_dir.$airspace['name'])) { |
| 1867 | 1867 | file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name']))); |
| 1868 | 1868 | //system('recode l9..utf8 '.$tmp_dir.$airspace['name']); |
@@ -1886,7 +1886,7 @@ discard block |
||
| 1886 | 1886 | $Connection = new Connection(); |
| 1887 | 1887 | $sth = $Connection->db->prepare($query); |
| 1888 | 1888 | $sth->execute(); |
| 1889 | - } catch(PDOException $e) { |
|
| 1889 | + } catch (PDOException $e) { |
|
| 1890 | 1890 | return "error : ".$e->getMessage(); |
| 1891 | 1891 | } |
| 1892 | 1892 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -1901,7 +1901,7 @@ discard block |
||
| 1901 | 1901 | $Connection = new Connection(); |
| 1902 | 1902 | $sth = $Connection->db->prepare($query); |
| 1903 | 1903 | $sth->execute(); |
| 1904 | - } catch(PDOException $e) { |
|
| 1904 | + } catch (PDOException $e) { |
|
| 1905 | 1905 | return "error : ".$e->getMessage(); |
| 1906 | 1906 | } |
| 1907 | 1907 | } |
@@ -1912,7 +1912,7 @@ discard block |
||
| 1912 | 1912 | $Connection = new Connection(); |
| 1913 | 1913 | $sth = $Connection->db->prepare($query); |
| 1914 | 1914 | $sth->execute(array(':version' => $version)); |
| 1915 | - } catch(PDOException $e) { |
|
| 1915 | + } catch (PDOException $e) { |
|
| 1916 | 1916 | return "error : ".$e->getMessage(); |
| 1917 | 1917 | } |
| 1918 | 1918 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -1928,7 +1928,7 @@ discard block |
||
| 1928 | 1928 | $Connection = new Connection(); |
| 1929 | 1929 | $sth = $Connection->db->prepare($query); |
| 1930 | 1930 | $sth->execute(array(':version' => $version)); |
| 1931 | - } catch(PDOException $e) { |
|
| 1931 | + } catch (PDOException $e) { |
|
| 1932 | 1932 | return "error : ".$e->getMessage(); |
| 1933 | 1933 | } |
| 1934 | 1934 | } |
@@ -1944,7 +1944,7 @@ discard block |
||
| 1944 | 1944 | $Connection = new Connection(); |
| 1945 | 1945 | $sth = $Connection->db->prepare($query); |
| 1946 | 1946 | $sth->execute(); |
| 1947 | - } catch(PDOException $e) { |
|
| 1947 | + } catch (PDOException $e) { |
|
| 1948 | 1948 | return "error : ".$e->getMessage(); |
| 1949 | 1949 | } |
| 1950 | 1950 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -1959,7 +1959,7 @@ discard block |
||
| 1959 | 1959 | $Connection = new Connection(); |
| 1960 | 1960 | $sth = $Connection->db->prepare($query); |
| 1961 | 1961 | $sth->execute(); |
| 1962 | - } catch(PDOException $e) { |
|
| 1962 | + } catch (PDOException $e) { |
|
| 1963 | 1963 | return "error : ".$e->getMessage(); |
| 1964 | 1964 | } |
| 1965 | 1965 | } |
@@ -1974,7 +1974,7 @@ discard block |
||
| 1974 | 1974 | $Connection = new Connection(); |
| 1975 | 1975 | $sth = $Connection->db->prepare($query); |
| 1976 | 1976 | $sth->execute(); |
| 1977 | - } catch(PDOException $e) { |
|
| 1977 | + } catch (PDOException $e) { |
|
| 1978 | 1978 | return "error : ".$e->getMessage(); |
| 1979 | 1979 | } |
| 1980 | 1980 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -1989,7 +1989,7 @@ discard block |
||
| 1989 | 1989 | $Connection = new Connection(); |
| 1990 | 1990 | $sth = $Connection->db->prepare($query); |
| 1991 | 1991 | $sth->execute(); |
| 1992 | - } catch(PDOException $e) { |
|
| 1992 | + } catch (PDOException $e) { |
|
| 1993 | 1993 | return "error : ".$e->getMessage(); |
| 1994 | 1994 | } |
| 1995 | 1995 | } |
@@ -2005,7 +2005,7 @@ discard block |
||
| 2005 | 2005 | $Connection = new Connection(); |
| 2006 | 2006 | $sth = $Connection->db->prepare($query); |
| 2007 | 2007 | $sth->execute(); |
| 2008 | - } catch(PDOException $e) { |
|
| 2008 | + } catch (PDOException $e) { |
|
| 2009 | 2009 | return "error : ".$e->getMessage(); |
| 2010 | 2010 | } |
| 2011 | 2011 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2020,7 +2020,7 @@ discard block |
||
| 2020 | 2020 | $Connection = new Connection(); |
| 2021 | 2021 | $sth = $Connection->db->prepare($query); |
| 2022 | 2022 | $sth->execute(); |
| 2023 | - } catch(PDOException $e) { |
|
| 2023 | + } catch (PDOException $e) { |
|
| 2024 | 2024 | return "error : ".$e->getMessage(); |
| 2025 | 2025 | } |
| 2026 | 2026 | } |
@@ -2035,7 +2035,7 @@ discard block |
||
| 2035 | 2035 | $Connection = new Connection(); |
| 2036 | 2036 | $sth = $Connection->db->prepare($query); |
| 2037 | 2037 | $sth->execute(); |
| 2038 | - } catch(PDOException $e) { |
|
| 2038 | + } catch (PDOException $e) { |
|
| 2039 | 2039 | return "error : ".$e->getMessage(); |
| 2040 | 2040 | } |
| 2041 | 2041 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2050,7 +2050,7 @@ discard block |
||
| 2050 | 2050 | $Connection = new Connection(); |
| 2051 | 2051 | $sth = $Connection->db->prepare($query); |
| 2052 | 2052 | $sth->execute(); |
| 2053 | - } catch(PDOException $e) { |
|
| 2053 | + } catch (PDOException $e) { |
|
| 2054 | 2054 | return "error : ".$e->getMessage(); |
| 2055 | 2055 | } |
| 2056 | 2056 | } |
@@ -2065,7 +2065,7 @@ discard block |
||
| 2065 | 2065 | $Connection = new Connection(); |
| 2066 | 2066 | $sth = $Connection->db->prepare($query); |
| 2067 | 2067 | $sth->execute(); |
| 2068 | - } catch(PDOException $e) { |
|
| 2068 | + } catch (PDOException $e) { |
|
| 2069 | 2069 | return "error : ".$e->getMessage(); |
| 2070 | 2070 | } |
| 2071 | 2071 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2080,7 +2080,7 @@ discard block |
||
| 2080 | 2080 | $Connection = new Connection(); |
| 2081 | 2081 | $sth = $Connection->db->prepare($query); |
| 2082 | 2082 | $sth->execute(); |
| 2083 | - } catch(PDOException $e) { |
|
| 2083 | + } catch (PDOException $e) { |
|
| 2084 | 2084 | return "error : ".$e->getMessage(); |
| 2085 | 2085 | } |
| 2086 | 2086 | } |
@@ -16,7 +16,9 @@ discard block |
||
| 16 | 16 | curl_setopt($ch, CURLOPT_URL, $url); |
| 17 | 17 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
| 18 | 18 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
| 19 | - if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
| 19 | + if ($referer != '') { |
|
| 20 | + curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
| 21 | + } |
|
| 20 | 22 | curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5'); |
| 21 | 23 | curl_setopt($ch, CURLOPT_FILE, $fp); |
| 22 | 24 | curl_exec($ch); |
@@ -27,12 +29,16 @@ discard block |
||
| 27 | 29 | public static function gunzip($in_file,$out_file_name = '') { |
| 28 | 30 | //echo $in_file.' -> '.$out_file_name."\n"; |
| 29 | 31 | $buffer_size = 4096; // read 4kb at a time |
| 30 | - if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); |
|
| 32 | + if ($out_file_name == '') { |
|
| 33 | + $out_file_name = str_replace('.gz', '', $in_file); |
|
| 34 | + } |
|
| 31 | 35 | if ($in_file != '' && file_exists($in_file)) { |
| 32 | 36 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
| 33 | - if (function_exists('gzopen')) $file = gzopen($in_file,'rb'); |
|
| 34 | - elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb'); |
|
| 35 | - else { |
|
| 37 | + if (function_exists('gzopen')) { |
|
| 38 | + $file = gzopen($in_file,'rb'); |
|
| 39 | + } elseif (function_exists('gzopen64')) { |
|
| 40 | + $file = gzopen64($in_file,'rb'); |
|
| 41 | + } else { |
|
| 36 | 42 | echo 'gzopen not available'; |
| 37 | 43 | die; |
| 38 | 44 | } |
@@ -53,8 +59,12 @@ discard block |
||
| 53 | 59 | if ($res === TRUE) { |
| 54 | 60 | $zip->extractTo($path); |
| 55 | 61 | $zip->close(); |
| 56 | - } else return false; |
|
| 57 | - } else return false; |
|
| 62 | + } else { |
|
| 63 | + return false; |
|
| 64 | + } |
|
| 65 | + } else { |
|
| 66 | + return false; |
|
| 67 | + } |
|
| 58 | 68 | } |
| 59 | 69 | |
| 60 | 70 | public static function connect_sqlite($database) { |
@@ -69,7 +79,9 @@ discard block |
||
| 69 | 79 | public static function retrieve_route_sqlite_to_dest($database_file) { |
| 70 | 80 | global $globalDebug, $globalTransaction; |
| 71 | 81 | //$query = 'TRUNCATE TABLE routes'; |
| 72 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
| 82 | + if ($globalDebug) { |
|
| 83 | + echo " - Delete previous routes from DB -"; |
|
| 84 | + } |
|
| 73 | 85 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
| 74 | 86 | $Connection = new Connection(); |
| 75 | 87 | try { |
@@ -80,7 +92,9 @@ discard block |
||
| 80 | 92 | return "error : ".$e->getMessage(); |
| 81 | 93 | } |
| 82 | 94 | |
| 83 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
| 95 | + if ($globalDebug) { |
|
| 96 | + echo " - Add routes to DB -"; |
|
| 97 | + } |
|
| 84 | 98 | update_db::connect_sqlite($database_file); |
| 85 | 99 | //$query = 'select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID'; |
| 86 | 100 | $query = "select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao, rstp.allstop AS AllStop from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID LEFT JOIN (select RouteId,GROUP_CONCAT(icao,' ') as allstop from routestop left join Airport as air ON routestop.AirportId = air.AirportID group by RouteID) AS rstp ON Route.RouteID = rstp.RouteID"; |
@@ -95,15 +109,21 @@ discard block |
||
| 95 | 109 | $Connection = new Connection(); |
| 96 | 110 | $sth_dest = $Connection->db->prepare($query_dest); |
| 97 | 111 | try { |
| 98 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 112 | + if ($globalTransaction) { |
|
| 113 | + $Connection->db->beginTransaction(); |
|
| 114 | + } |
|
| 99 | 115 | while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
| 100 | 116 | //$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
| 101 | 117 | $query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
| 102 | 118 | $sth_dest->execute($query_dest_values); |
| 103 | 119 | } |
| 104 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 120 | + if ($globalTransaction) { |
|
| 121 | + $Connection->db->commit(); |
|
| 122 | + } |
|
| 105 | 123 | } catch(PDOException $e) { |
| 106 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
| 124 | + if ($globalTransaction) { |
|
| 125 | + $Connection->db->rollBack(); |
|
| 126 | + } |
|
| 107 | 127 | return "error : ".$e->getMessage(); |
| 108 | 128 | } |
| 109 | 129 | return ''; |
@@ -111,7 +131,9 @@ discard block |
||
| 111 | 131 | public static function retrieve_route_oneworld($database_file) { |
| 112 | 132 | global $globalDebug, $globalTransaction; |
| 113 | 133 | //$query = 'TRUNCATE TABLE routes'; |
| 114 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
| 134 | + if ($globalDebug) { |
|
| 135 | + echo " - Delete previous routes from DB -"; |
|
| 136 | + } |
|
| 115 | 137 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
| 116 | 138 | $Connection = new Connection(); |
| 117 | 139 | try { |
@@ -122,14 +144,18 @@ discard block |
||
| 122 | 144 | return "error : ".$e->getMessage(); |
| 123 | 145 | } |
| 124 | 146 | |
| 125 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
| 147 | + if ($globalDebug) { |
|
| 148 | + echo " - Add routes to DB -"; |
|
| 149 | + } |
|
| 126 | 150 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 127 | 151 | $Spotter = new Spotter(); |
| 128 | 152 | if ($fh = fopen($database_file,"r")) { |
| 129 | 153 | $query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)'; |
| 130 | 154 | $Connection = new Connection(); |
| 131 | 155 | $sth_dest = $Connection->db->prepare($query_dest); |
| 132 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 156 | + if ($globalTransaction) { |
|
| 157 | + $Connection->db->beginTransaction(); |
|
| 158 | + } |
|
| 133 | 159 | while (!feof($fh)) { |
| 134 | 160 | $line = fgetcsv($fh,9999,','); |
| 135 | 161 | if ($line[0] != '') { |
@@ -138,13 +164,17 @@ discard block |
||
| 138 | 164 | $query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld'); |
| 139 | 165 | $sth_dest->execute($query_dest_values); |
| 140 | 166 | } catch(PDOException $e) { |
| 141 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
| 167 | + if ($globalTransaction) { |
|
| 168 | + $Connection->db->rollBack(); |
|
| 169 | + } |
|
| 142 | 170 | return "error : ".$e->getMessage(); |
| 143 | 171 | } |
| 144 | 172 | } |
| 145 | 173 | } |
| 146 | 174 | } |
| 147 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 175 | + if ($globalTransaction) { |
|
| 176 | + $Connection->db->commit(); |
|
| 177 | + } |
|
| 148 | 178 | } |
| 149 | 179 | return ''; |
| 150 | 180 | } |
@@ -152,7 +182,9 @@ discard block |
||
| 152 | 182 | public static function retrieve_route_skyteam($database_file) { |
| 153 | 183 | global $globalDebug, $globalTransaction; |
| 154 | 184 | //$query = 'TRUNCATE TABLE routes'; |
| 155 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
| 185 | + if ($globalDebug) { |
|
| 186 | + echo " - Delete previous routes from DB -"; |
|
| 187 | + } |
|
| 156 | 188 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
| 157 | 189 | $Connection = new Connection(); |
| 158 | 190 | try { |
@@ -163,7 +195,9 @@ discard block |
||
| 163 | 195 | return "error : ".$e->getMessage(); |
| 164 | 196 | } |
| 165 | 197 | |
| 166 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
| 198 | + if ($globalDebug) { |
|
| 199 | + echo " - Add routes to DB -"; |
|
| 200 | + } |
|
| 167 | 201 | |
| 168 | 202 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 169 | 203 | $Spotter = new Spotter(); |
@@ -172,7 +206,9 @@ discard block |
||
| 172 | 206 | $Connection = new Connection(); |
| 173 | 207 | $sth_dest = $Connection->db->prepare($query_dest); |
| 174 | 208 | try { |
| 175 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 209 | + if ($globalTransaction) { |
|
| 210 | + $Connection->db->beginTransaction(); |
|
| 211 | + } |
|
| 176 | 212 | while (!feof($fh)) { |
| 177 | 213 | $line = fgetcsv($fh,9999,','); |
| 178 | 214 | if ($line[0] != '') { |
@@ -183,9 +219,13 @@ discard block |
||
| 183 | 219 | } |
| 184 | 220 | } |
| 185 | 221 | } |
| 186 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 222 | + if ($globalTransaction) { |
|
| 223 | + $Connection->db->commit(); |
|
| 224 | + } |
|
| 187 | 225 | } catch(PDOException $e) { |
| 188 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
| 226 | + if ($globalTransaction) { |
|
| 227 | + $Connection->db->rollBack(); |
|
| 228 | + } |
|
| 189 | 229 | return "error : ".$e->getMessage(); |
| 190 | 230 | } |
| 191 | 231 | } |
@@ -228,11 +268,16 @@ discard block |
||
| 228 | 268 | $sth_dest = $Connection->db->prepare($query_dest); |
| 229 | 269 | $sth_dest_owner = $Connection->db->prepare($query_dest_owner); |
| 230 | 270 | try { |
| 231 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 271 | + if ($globalTransaction) { |
|
| 272 | + $Connection->db->beginTransaction(); |
|
| 273 | + } |
|
| 232 | 274 | while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
| 233 | 275 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
| 234 | - if ($values['UserString4'] == 'M') $type = 'military'; |
|
| 235 | - else $type = null; |
|
| 276 | + if ($values['UserString4'] == 'M') { |
|
| 277 | + $type = 'military'; |
|
| 278 | + } else { |
|
| 279 | + $type = null; |
|
| 280 | + } |
|
| 236 | 281 | $query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type); |
| 237 | 282 | $sth_dest->execute($query_dest_values); |
| 238 | 283 | if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') { |
@@ -240,7 +285,9 @@ discard block |
||
| 240 | 285 | $sth_dest_owner->execute($query_dest_owner_values); |
| 241 | 286 | } |
| 242 | 287 | } |
| 243 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 288 | + if ($globalTransaction) { |
|
| 289 | + $Connection->db->commit(); |
|
| 290 | + } |
|
| 244 | 291 | } catch(PDOException $e) { |
| 245 | 292 | return "error : ".$e->getMessage(); |
| 246 | 293 | } |
@@ -276,7 +323,9 @@ discard block |
||
| 276 | 323 | $Connection = new Connection(); |
| 277 | 324 | $sth_dest = $Connection->db->prepare($query_dest); |
| 278 | 325 | try { |
| 279 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 326 | + if ($globalTransaction) { |
|
| 327 | + $Connection->db->beginTransaction(); |
|
| 328 | + } |
|
| 280 | 329 | while (!feof($fh)) { |
| 281 | 330 | $values = array(); |
| 282 | 331 | $line = $Common->hex2str(fgets($fh,9999)); |
@@ -287,7 +336,9 @@ discard block |
||
| 287 | 336 | // Check if we can find ICAO, else set it to GLID |
| 288 | 337 | $aircraft_name_split = explode(' ',$aircraft_name); |
| 289 | 338 | $search_more = ''; |
| 290 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 339 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) { |
|
| 340 | + $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 341 | + } |
|
| 291 | 342 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
| 292 | 343 | $sth_search = $Connection->db->prepare($query_search); |
| 293 | 344 | try { |
@@ -300,7 +351,9 @@ discard block |
||
| 300 | 351 | } catch(PDOException $e) { |
| 301 | 352 | return "error : ".$e->getMessage(); |
| 302 | 353 | } |
| 303 | - if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID'; |
|
| 354 | + if (!isset($values['ICAOTypeCode'])) { |
|
| 355 | + $values['ICAOTypeCode'] = 'GLID'; |
|
| 356 | + } |
|
| 304 | 357 | // Add data to db |
| 305 | 358 | if ($values['ModeS'] != '' && $values['Registration'] != '' && $values['Registration'] != '0000') { |
| 306 | 359 | //$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']); |
@@ -309,7 +362,9 @@ discard block |
||
| 309 | 362 | $sth_dest->execute($query_dest_values); |
| 310 | 363 | } |
| 311 | 364 | } |
| 312 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 365 | + if ($globalTransaction) { |
|
| 366 | + $Connection->db->commit(); |
|
| 367 | + } |
|
| 313 | 368 | } catch(PDOException $e) { |
| 314 | 369 | return "error : ".$e->getMessage(); |
| 315 | 370 | } |
@@ -345,7 +400,9 @@ discard block |
||
| 345 | 400 | $Connection = new Connection(); |
| 346 | 401 | $sth_dest = $Connection->db->prepare($query_dest); |
| 347 | 402 | try { |
| 348 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 403 | + if ($globalTransaction) { |
|
| 404 | + $Connection->db->beginTransaction(); |
|
| 405 | + } |
|
| 349 | 406 | $tmp = fgetcsv($fh,9999,',',"'"); |
| 350 | 407 | while (!feof($fh)) { |
| 351 | 408 | $line = fgetcsv($fh,9999,',',"'"); |
@@ -358,13 +415,17 @@ discard block |
||
| 358 | 415 | // Check if we can find ICAO, else set it to GLID |
| 359 | 416 | $aircraft_name_split = explode(' ',$aircraft_name); |
| 360 | 417 | $search_more = ''; |
| 361 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 418 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) { |
|
| 419 | + $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 420 | + } |
|
| 362 | 421 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
| 363 | 422 | $sth_search = $Connection->db->prepare($query_search); |
| 364 | 423 | try { |
| 365 | 424 | $sth_search->execute(); |
| 366 | 425 | $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
| 367 | - if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
|
| 426 | + if (isset($result['icao']) && $result['icao'] != '') { |
|
| 427 | + $values['ICAOTypeCode'] = $result['icao']; |
|
| 428 | + } |
|
| 368 | 429 | } catch(PDOException $e) { |
| 369 | 430 | return "error : ".$e->getMessage(); |
| 370 | 431 | } |
@@ -377,7 +438,9 @@ discard block |
||
| 377 | 438 | $sth_dest->execute($query_dest_values); |
| 378 | 439 | } |
| 379 | 440 | } |
| 380 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 441 | + if ($globalTransaction) { |
|
| 442 | + $Connection->db->commit(); |
|
| 443 | + } |
|
| 381 | 444 | } catch(PDOException $e) { |
| 382 | 445 | return "error : ".$e->getMessage(); |
| 383 | 446 | } |
@@ -413,7 +476,9 @@ discard block |
||
| 413 | 476 | $Connection = new Connection(); |
| 414 | 477 | $sth_dest = $Connection->db->prepare($query_dest); |
| 415 | 478 | try { |
| 416 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 479 | + if ($globalTransaction) { |
|
| 480 | + $Connection->db->beginTransaction(); |
|
| 481 | + } |
|
| 417 | 482 | $tmp = fgetcsv($fh,9999,',','"'); |
| 418 | 483 | while (!feof($fh)) { |
| 419 | 484 | $line = fgetcsv($fh,9999,',','"'); |
@@ -423,16 +488,22 @@ discard block |
||
| 423 | 488 | $values['registration'] = $line[0]; |
| 424 | 489 | $values['base'] = $line[4]; |
| 425 | 490 | $values['owner'] = $line[5]; |
| 426 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
| 427 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 491 | + if ($line[6] == '') { |
|
| 492 | + $values['date_first_reg'] = null; |
|
| 493 | + } else { |
|
| 494 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 495 | + } |
|
| 428 | 496 | $values['cancel'] = $line[7]; |
| 429 | 497 | } elseif ($country == 'EI') { |
| 430 | 498 | // TODO : add modeS & reg to aircraft_modes |
| 431 | 499 | $values['registration'] = $line[0]; |
| 432 | 500 | $values['base'] = $line[3]; |
| 433 | 501 | $values['owner'] = $line[2]; |
| 434 | - if ($line[1] == '') $values['date_first_reg'] = null; |
|
| 435 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
| 502 | + if ($line[1] == '') { |
|
| 503 | + $values['date_first_reg'] = null; |
|
| 504 | + } else { |
|
| 505 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
| 506 | + } |
|
| 436 | 507 | $values['cancel'] = ''; |
| 437 | 508 | } elseif ($country == 'HB') { |
| 438 | 509 | // TODO : add modeS & reg to aircraft_modes |
@@ -446,16 +517,22 @@ discard block |
||
| 446 | 517 | $values['registration'] = $line[3]; |
| 447 | 518 | $values['base'] = null; |
| 448 | 519 | $values['owner'] = $line[5]; |
| 449 | - if ($line[18] == '') $values['date_first_reg'] = null; |
|
| 450 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
| 520 | + if ($line[18] == '') { |
|
| 521 | + $values['date_first_reg'] = null; |
|
| 522 | + } else { |
|
| 523 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
| 524 | + } |
|
| 451 | 525 | $values['cancel'] = ''; |
| 452 | 526 | } elseif ($country == 'VH') { |
| 453 | 527 | // TODO : add modeS & reg to aircraft_modes |
| 454 | 528 | $values['registration'] = $line[0]; |
| 455 | 529 | $values['base'] = null; |
| 456 | 530 | $values['owner'] = $line[12]; |
| 457 | - if ($line[28] == '') $values['date_first_reg'] = null; |
|
| 458 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
| 531 | + if ($line[28] == '') { |
|
| 532 | + $values['date_first_reg'] = null; |
|
| 533 | + } else { |
|
| 534 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
| 535 | + } |
|
| 459 | 536 | |
| 460 | 537 | $values['cancel'] = $line[39]; |
| 461 | 538 | } elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { |
@@ -474,29 +551,41 @@ discard block |
||
| 474 | 551 | $values['registration'] = $line[0]; |
| 475 | 552 | $values['base'] = null; |
| 476 | 553 | $values['owner'] = $line[8]; |
| 477 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
| 478 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 554 | + if ($line[7] == '') { |
|
| 555 | + $values['date_first_reg'] = null; |
|
| 556 | + } else { |
|
| 557 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 558 | + } |
|
| 479 | 559 | $values['cancel'] = ''; |
| 480 | 560 | } elseif ($country == 'PP') { |
| 481 | 561 | $values['registration'] = $line[0]; |
| 482 | 562 | $values['base'] = null; |
| 483 | 563 | $values['owner'] = $line[4]; |
| 484 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
| 485 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 564 | + if ($line[6] == '') { |
|
| 565 | + $values['date_first_reg'] = null; |
|
| 566 | + } else { |
|
| 567 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 568 | + } |
|
| 486 | 569 | $values['cancel'] = $line[7]; |
| 487 | 570 | } elseif ($country == 'E7') { |
| 488 | 571 | $values['registration'] = $line[0]; |
| 489 | 572 | $values['base'] = null; |
| 490 | 573 | $values['owner'] = $line[4]; |
| 491 | - if ($line[5] == '') $values['date_first_reg'] = null; |
|
| 492 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
| 574 | + if ($line[5] == '') { |
|
| 575 | + $values['date_first_reg'] = null; |
|
| 576 | + } else { |
|
| 577 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
| 578 | + } |
|
| 493 | 579 | $values['cancel'] = ''; |
| 494 | 580 | } elseif ($country == '8Q') { |
| 495 | 581 | $values['registration'] = $line[0]; |
| 496 | 582 | $values['base'] = null; |
| 497 | 583 | $values['owner'] = $line[3]; |
| 498 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
| 499 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 584 | + if ($line[7] == '') { |
|
| 585 | + $values['date_first_reg'] = null; |
|
| 586 | + } else { |
|
| 587 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 588 | + } |
|
| 500 | 589 | $values['cancel'] = ''; |
| 501 | 590 | } elseif ($country == 'ZK' || $country == 'OM' || $country == 'TF') { |
| 502 | 591 | $values['registration'] = $line[0]; |
@@ -510,7 +599,9 @@ discard block |
||
| 510 | 599 | $sth_dest->execute($query_dest_values); |
| 511 | 600 | } |
| 512 | 601 | } |
| 513 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 602 | + if ($globalTransaction) { |
|
| 603 | + $Connection->db->commit(); |
|
| 604 | + } |
|
| 514 | 605 | } catch(PDOException $e) { |
| 515 | 606 | return "error : ".$e->getMessage(); |
| 516 | 607 | } |
@@ -644,25 +735,45 @@ discard block |
||
| 644 | 735 | VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)"; |
| 645 | 736 | $Connection = new Connection(); |
| 646 | 737 | $sth_dest = $Connection->db->prepare($query_dest); |
| 647 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 738 | + if ($globalTransaction) { |
|
| 739 | + $Connection->db->beginTransaction(); |
|
| 740 | + } |
|
| 648 | 741 | |
| 649 | 742 | $i = 0; |
| 650 | 743 | while($row = sparql_fetch_array($result)) |
| 651 | 744 | { |
| 652 | 745 | if ($i >= 1) { |
| 653 | 746 | //print_r($row); |
| 654 | - if (!isset($row['iata'])) $row['iata'] = ''; |
|
| 655 | - if (!isset($row['icao'])) $row['icao'] = ''; |
|
| 656 | - if (!isset($row['type'])) $row['type'] = ''; |
|
| 657 | - if (!isset($row['altitude'])) $row['altitude'] = ''; |
|
| 747 | + if (!isset($row['iata'])) { |
|
| 748 | + $row['iata'] = ''; |
|
| 749 | + } |
|
| 750 | + if (!isset($row['icao'])) { |
|
| 751 | + $row['icao'] = ''; |
|
| 752 | + } |
|
| 753 | + if (!isset($row['type'])) { |
|
| 754 | + $row['type'] = ''; |
|
| 755 | + } |
|
| 756 | + if (!isset($row['altitude'])) { |
|
| 757 | + $row['altitude'] = ''; |
|
| 758 | + } |
|
| 658 | 759 | if (isset($row['city_bis'])) { |
| 659 | 760 | $row['city'] = $row['city_bis']; |
| 660 | 761 | } |
| 661 | - if (!isset($row['city'])) $row['city'] = ''; |
|
| 662 | - if (!isset($row['country'])) $row['country'] = ''; |
|
| 663 | - if (!isset($row['homepage'])) $row['homepage'] = ''; |
|
| 664 | - if (!isset($row['wikipedia_page'])) $row['wikipedia_page'] = ''; |
|
| 665 | - if (!isset($row['name'])) continue; |
|
| 762 | + if (!isset($row['city'])) { |
|
| 763 | + $row['city'] = ''; |
|
| 764 | + } |
|
| 765 | + if (!isset($row['country'])) { |
|
| 766 | + $row['country'] = ''; |
|
| 767 | + } |
|
| 768 | + if (!isset($row['homepage'])) { |
|
| 769 | + $row['homepage'] = ''; |
|
| 770 | + } |
|
| 771 | + if (!isset($row['wikipedia_page'])) { |
|
| 772 | + $row['wikipedia_page'] = ''; |
|
| 773 | + } |
|
| 774 | + if (!isset($row['name'])) { |
|
| 775 | + continue; |
|
| 776 | + } |
|
| 666 | 777 | if (!isset($row['image'])) { |
| 667 | 778 | $row['image'] = ''; |
| 668 | 779 | $row['image_thumb'] = ''; |
@@ -698,7 +809,9 @@ discard block |
||
| 698 | 809 | |
| 699 | 810 | $i++; |
| 700 | 811 | } |
| 701 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 812 | + if ($globalTransaction) { |
|
| 813 | + $Connection->db->commit(); |
|
| 814 | + } |
|
| 702 | 815 | echo "Delete duplicate rows...\n"; |
| 703 | 816 | $query = 'ALTER IGNORE TABLE airport ADD UNIQUE INDEX icaoidx (icao)'; |
| 704 | 817 | try { |
@@ -710,7 +823,9 @@ discard block |
||
| 710 | 823 | } |
| 711 | 824 | |
| 712 | 825 | |
| 713 | - if ($globalDebug) echo "Insert Not available Airport...\n"; |
|
| 826 | + if ($globalDebug) { |
|
| 827 | + echo "Insert Not available Airport...\n"; |
|
| 828 | + } |
|
| 714 | 829 | $query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image`,`image_thumb`) |
| 715 | 830 | VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image, :image_thumb)"; |
| 716 | 831 | $query_values = array(':airport_id' => $i, ':name' => 'Not available',':iata' => 'NA',':icao' => 'NA',':latitude' => '0',':longitude' => '0',':altitude' => '0',':type' => 'NA',':city' => 'N/A',':country' => 'N/A',':home_link' => '',':wikipedia_link' => '',':image' => '',':image_thumb' => ''); |
@@ -737,7 +852,9 @@ discard block |
||
| 737 | 852 | $delimiter = ','; |
| 738 | 853 | $out_file = $tmp_dir.'airports.csv'; |
| 739 | 854 | update_db::download('http://ourairports.com/data/airports.csv',$out_file); |
| 740 | - if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
|
| 855 | + if (!file_exists($out_file) || !is_readable($out_file)) { |
|
| 856 | + return FALSE; |
|
| 857 | + } |
|
| 741 | 858 | echo "Add data from ourairports.com...\n"; |
| 742 | 859 | |
| 743 | 860 | $header = NULL; |
@@ -747,8 +864,9 @@ discard block |
||
| 747 | 864 | //$Connection->db->beginTransaction(); |
| 748 | 865 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 749 | 866 | { |
| 750 | - if(!$header) $header = $row; |
|
| 751 | - else { |
|
| 867 | + if(!$header) { |
|
| 868 | + $header = $row; |
|
| 869 | + } else { |
|
| 752 | 870 | $data = array(); |
| 753 | 871 | $data = array_combine($header, $row); |
| 754 | 872 | try { |
@@ -786,7 +904,9 @@ discard block |
||
| 786 | 904 | echo "Download data from another free database...\n"; |
| 787 | 905 | $out_file = $tmp_dir.'GlobalAirportDatabase.zip'; |
| 788 | 906 | update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file); |
| 789 | - if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
|
| 907 | + if (!file_exists($out_file) || !is_readable($out_file)) { |
|
| 908 | + return FALSE; |
|
| 909 | + } |
|
| 790 | 910 | update_db::unzip($out_file); |
| 791 | 911 | $header = NULL; |
| 792 | 912 | echo "Add data from another free database...\n"; |
@@ -797,8 +917,9 @@ discard block |
||
| 797 | 917 | //$Connection->db->beginTransaction(); |
| 798 | 918 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 799 | 919 | { |
| 800 | - if(!$header) $header = $row; |
|
| 801 | - else { |
|
| 920 | + if(!$header) { |
|
| 921 | + $header = $row; |
|
| 922 | + } else { |
|
| 802 | 923 | $data = $row; |
| 803 | 924 | |
| 804 | 925 | $query = 'UPDATE airport SET `city` = :city, `country` = :country WHERE icao = :icao'; |
@@ -1090,7 +1211,9 @@ discard block |
||
| 1090 | 1211 | if (($handle = fopen($filename, 'r')) !== FALSE) |
| 1091 | 1212 | { |
| 1092 | 1213 | $i = 0; |
| 1093 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1214 | + if ($globalTransaction) { |
|
| 1215 | + $Connection->db->beginTransaction(); |
|
| 1216 | + } |
|
| 1094 | 1217 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1095 | 1218 | { |
| 1096 | 1219 | $i++; |
@@ -1118,7 +1241,9 @@ discard block |
||
| 1118 | 1241 | } |
| 1119 | 1242 | } |
| 1120 | 1243 | fclose($handle); |
| 1121 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1244 | + if ($globalTransaction) { |
|
| 1245 | + $Connection->db->commit(); |
|
| 1246 | + } |
|
| 1122 | 1247 | } |
| 1123 | 1248 | return ''; |
| 1124 | 1249 | } |
@@ -1141,7 +1266,9 @@ discard block |
||
| 1141 | 1266 | $Connection = new Connection(); |
| 1142 | 1267 | if (($handle = fopen($filename, 'r')) !== FALSE) |
| 1143 | 1268 | { |
| 1144 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1269 | + if ($globalTransaction) { |
|
| 1270 | + $Connection->db->beginTransaction(); |
|
| 1271 | + } |
|
| 1145 | 1272 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1146 | 1273 | { |
| 1147 | 1274 | if(count($row) > 1) { |
@@ -1155,7 +1282,9 @@ discard block |
||
| 1155 | 1282 | } |
| 1156 | 1283 | } |
| 1157 | 1284 | fclose($handle); |
| 1158 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1285 | + if ($globalTransaction) { |
|
| 1286 | + $Connection->db->commit(); |
|
| 1287 | + } |
|
| 1159 | 1288 | } |
| 1160 | 1289 | return ''; |
| 1161 | 1290 | } |
@@ -1175,8 +1304,9 @@ discard block |
||
| 1175 | 1304 | } |
| 1176 | 1305 | |
| 1177 | 1306 | |
| 1178 | - if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
| 1179 | - else { |
|
| 1307 | + if ($globalDBdriver == 'mysql') { |
|
| 1308 | + update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
| 1309 | + } else { |
|
| 1180 | 1310 | update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
| 1181 | 1311 | $query = "CREATE EXTENSION postgis"; |
| 1182 | 1312 | $Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']); |
@@ -1195,20 +1325,30 @@ discard block |
||
| 1195 | 1325 | global $tmp_dir, $globalDebug; |
| 1196 | 1326 | include_once('class.create_db.php'); |
| 1197 | 1327 | require_once(dirname(__FILE__).'/../require/class.NOTAM.php'); |
| 1198 | - if ($globalDebug) echo "NOTAM from FlightAirMap website : Download..."; |
|
| 1328 | + if ($globalDebug) { |
|
| 1329 | + echo "NOTAM from FlightAirMap website : Download..."; |
|
| 1330 | + } |
|
| 1199 | 1331 | update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz'); |
| 1200 | 1332 | $error = ''; |
| 1201 | 1333 | if (file_exists($tmp_dir.'notam.txt.gz')) { |
| 1202 | - if ($globalDebug) echo "Gunzip..."; |
|
| 1334 | + if ($globalDebug) { |
|
| 1335 | + echo "Gunzip..."; |
|
| 1336 | + } |
|
| 1203 | 1337 | update_db::gunzip($tmp_dir.'notam.txt.gz'); |
| 1204 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1338 | + if ($globalDebug) { |
|
| 1339 | + echo "Add to DB..."; |
|
| 1340 | + } |
|
| 1205 | 1341 | //$error = create_db::import_file($tmp_dir.'notam.sql'); |
| 1206 | 1342 | $NOTAM = new NOTAM(); |
| 1207 | 1343 | $NOTAM->updateNOTAMfromTextFile($tmp_dir.'notam.txt'); |
| 1208 | - } else $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed."; |
|
| 1344 | + } else { |
|
| 1345 | + $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed."; |
|
| 1346 | + } |
|
| 1209 | 1347 | if ($error != '') { |
| 1210 | 1348 | return $error; |
| 1211 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1349 | + } elseif ($globalDebug) { |
|
| 1350 | + echo "Done\n"; |
|
| 1351 | + } |
|
| 1212 | 1352 | return ''; |
| 1213 | 1353 | } |
| 1214 | 1354 | |
@@ -1262,67 +1402,111 @@ discard block |
||
| 1262 | 1402 | //if ($globalDebug) echo "IVAO : Download..."; |
| 1263 | 1403 | //update_db::download('http://fr.mirror.ivao.aero/software/ivae_feb2013.zip',$tmp_dir.'ivae_feb2013.zip'); |
| 1264 | 1404 | if (file_exists($tmp_dir.'ivae_feb2013.zip')) { |
| 1265 | - if ($globalDebug) echo "Unzip..."; |
|
| 1405 | + if ($globalDebug) { |
|
| 1406 | + echo "Unzip..."; |
|
| 1407 | + } |
|
| 1266 | 1408 | update_db::unzip($tmp_dir.'ivae_feb2013.zip'); |
| 1267 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1409 | + if ($globalDebug) { |
|
| 1410 | + echo "Add to DB..."; |
|
| 1411 | + } |
|
| 1268 | 1412 | update_db::ivao_airlines($tmp_dir.'data/airlines.dat'); |
| 1269 | - if ($globalDebug) echo "Copy airlines logos to airlines images directory..."; |
|
| 1413 | + if ($globalDebug) { |
|
| 1414 | + echo "Copy airlines logos to airlines images directory..."; |
|
| 1415 | + } |
|
| 1270 | 1416 | if (is_writable(dirname(__FILE__).'/../images/airlines')) { |
| 1271 | - if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
| 1272 | - } else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
|
| 1273 | - } else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
|
| 1417 | + if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) { |
|
| 1418 | + $error = "Failed to copy airlines logo."; |
|
| 1419 | + } |
|
| 1420 | + } else { |
|
| 1421 | + $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
|
| 1422 | + } |
|
| 1423 | + } else { |
|
| 1424 | + $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
|
| 1425 | + } |
|
| 1274 | 1426 | if ($error != '') { |
| 1275 | 1427 | return $error; |
| 1276 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1428 | + } elseif ($globalDebug) { |
|
| 1429 | + echo "Done\n"; |
|
| 1430 | + } |
|
| 1277 | 1431 | return ''; |
| 1278 | 1432 | } |
| 1279 | 1433 | |
| 1280 | 1434 | public static function update_routes() { |
| 1281 | 1435 | global $tmp_dir, $globalDebug; |
| 1282 | 1436 | $error = ''; |
| 1283 | - if ($globalDebug) echo "Routes : Download..."; |
|
| 1437 | + if ($globalDebug) { |
|
| 1438 | + echo "Routes : Download..."; |
|
| 1439 | + } |
|
| 1284 | 1440 | update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz'); |
| 1285 | 1441 | if (file_exists($tmp_dir.'StandingData.sqb.gz')) { |
| 1286 | - if ($globalDebug) echo "Gunzip..."; |
|
| 1442 | + if ($globalDebug) { |
|
| 1443 | + echo "Gunzip..."; |
|
| 1444 | + } |
|
| 1287 | 1445 | update_db::gunzip($tmp_dir.'StandingData.sqb.gz'); |
| 1288 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1446 | + if ($globalDebug) { |
|
| 1447 | + echo "Add to DB..."; |
|
| 1448 | + } |
|
| 1289 | 1449 | $error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb'); |
| 1290 | - } else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed."; |
|
| 1450 | + } else { |
|
| 1451 | + $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed."; |
|
| 1452 | + } |
|
| 1291 | 1453 | if ($error != '') { |
| 1292 | 1454 | return $error; |
| 1293 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1455 | + } elseif ($globalDebug) { |
|
| 1456 | + echo "Done\n"; |
|
| 1457 | + } |
|
| 1294 | 1458 | return ''; |
| 1295 | 1459 | } |
| 1296 | 1460 | public static function update_oneworld() { |
| 1297 | 1461 | global $tmp_dir, $globalDebug; |
| 1298 | 1462 | $error = ''; |
| 1299 | - if ($globalDebug) echo "Schedules Oneworld : Download..."; |
|
| 1463 | + if ($globalDebug) { |
|
| 1464 | + echo "Schedules Oneworld : Download..."; |
|
| 1465 | + } |
|
| 1300 | 1466 | update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz'); |
| 1301 | 1467 | if (file_exists($tmp_dir.'oneworld.csv.gz')) { |
| 1302 | - if ($globalDebug) echo "Gunzip..."; |
|
| 1468 | + if ($globalDebug) { |
|
| 1469 | + echo "Gunzip..."; |
|
| 1470 | + } |
|
| 1303 | 1471 | update_db::gunzip($tmp_dir.'oneworld.csv.gz'); |
| 1304 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1472 | + if ($globalDebug) { |
|
| 1473 | + echo "Add to DB..."; |
|
| 1474 | + } |
|
| 1305 | 1475 | $error = update_db::retrieve_route_oneworld($tmp_dir.'oneworld.csv'); |
| 1306 | - } else $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed."; |
|
| 1476 | + } else { |
|
| 1477 | + $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed."; |
|
| 1478 | + } |
|
| 1307 | 1479 | if ($error != '') { |
| 1308 | 1480 | return $error; |
| 1309 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1481 | + } elseif ($globalDebug) { |
|
| 1482 | + echo "Done\n"; |
|
| 1483 | + } |
|
| 1310 | 1484 | return ''; |
| 1311 | 1485 | } |
| 1312 | 1486 | public static function update_skyteam() { |
| 1313 | 1487 | global $tmp_dir, $globalDebug; |
| 1314 | 1488 | $error = ''; |
| 1315 | - if ($globalDebug) echo "Schedules Skyteam : Download..."; |
|
| 1489 | + if ($globalDebug) { |
|
| 1490 | + echo "Schedules Skyteam : Download..."; |
|
| 1491 | + } |
|
| 1316 | 1492 | update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz'); |
| 1317 | 1493 | if (file_exists($tmp_dir.'skyteam.csv.gz')) { |
| 1318 | - if ($globalDebug) echo "Gunzip..."; |
|
| 1494 | + if ($globalDebug) { |
|
| 1495 | + echo "Gunzip..."; |
|
| 1496 | + } |
|
| 1319 | 1497 | update_db::gunzip($tmp_dir.'skyteam.csv.gz'); |
| 1320 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1498 | + if ($globalDebug) { |
|
| 1499 | + echo "Add to DB..."; |
|
| 1500 | + } |
|
| 1321 | 1501 | $error = update_db::retrieve_route_skyteam($tmp_dir.'skyteam.csv'); |
| 1322 | - } else $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed."; |
|
| 1502 | + } else { |
|
| 1503 | + $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed."; |
|
| 1504 | + } |
|
| 1323 | 1505 | if ($error != '') { |
| 1324 | 1506 | return $error; |
| 1325 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1507 | + } elseif ($globalDebug) { |
|
| 1508 | + echo "Done\n"; |
|
| 1509 | + } |
|
| 1326 | 1510 | return ''; |
| 1327 | 1511 | } |
| 1328 | 1512 | public static function update_ModeS() { |
@@ -1339,259 +1523,457 @@ discard block |
||
| 1339 | 1523 | exit; |
| 1340 | 1524 | } elseif ($globalDebug) echo "Done\n"; |
| 1341 | 1525 | */ |
| 1342 | - if ($globalDebug) echo "Modes : Download..."; |
|
| 1343 | -// update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
|
| 1526 | + if ($globalDebug) { |
|
| 1527 | + echo "Modes : Download..."; |
|
| 1528 | + } |
|
| 1529 | + // update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
|
| 1344 | 1530 | update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz',$tmp_dir.'basestation_latest.gz'); |
| 1345 | 1531 | // if (file_exists($tmp_dir.'basestation_latest.zip')) { |
| 1346 | 1532 | if (file_exists($tmp_dir.'basestation_latest.gz')) { |
| 1347 | - if ($globalDebug) echo "Unzip..."; |
|
| 1348 | -// update_db::unzip($tmp_dir.'basestation_latest.zip'); |
|
| 1533 | + if ($globalDebug) { |
|
| 1534 | + echo "Unzip..."; |
|
| 1535 | + } |
|
| 1536 | + // update_db::unzip($tmp_dir.'basestation_latest.zip'); |
|
| 1349 | 1537 | update_db::gunzip($tmp_dir.'basestation_latest.gz'); |
| 1350 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1538 | + if ($globalDebug) { |
|
| 1539 | + echo "Add to DB..."; |
|
| 1540 | + } |
|
| 1351 | 1541 | $error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb'); |
| 1352 | - } else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed."; |
|
| 1542 | + } else { |
|
| 1543 | + $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed."; |
|
| 1544 | + } |
|
| 1353 | 1545 | if ($error != '') { |
| 1354 | 1546 | return $error; |
| 1355 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1547 | + } elseif ($globalDebug) { |
|
| 1548 | + echo "Done\n"; |
|
| 1549 | + } |
|
| 1356 | 1550 | return ''; |
| 1357 | 1551 | } |
| 1358 | 1552 | |
| 1359 | 1553 | public static function update_ModeS_flarm() { |
| 1360 | 1554 | global $tmp_dir, $globalDebug; |
| 1361 | - if ($globalDebug) echo "Modes Flarmnet: Download..."; |
|
| 1555 | + if ($globalDebug) { |
|
| 1556 | + echo "Modes Flarmnet: Download..."; |
|
| 1557 | + } |
|
| 1362 | 1558 | update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln'); |
| 1363 | 1559 | if (file_exists($tmp_dir.'data.fln')) { |
| 1364 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1560 | + if ($globalDebug) { |
|
| 1561 | + echo "Add to DB..."; |
|
| 1562 | + } |
|
| 1365 | 1563 | $error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln'); |
| 1366 | - } else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed."; |
|
| 1564 | + } else { |
|
| 1565 | + $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed."; |
|
| 1566 | + } |
|
| 1367 | 1567 | if ($error != '') { |
| 1368 | 1568 | return $error; |
| 1369 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1569 | + } elseif ($globalDebug) { |
|
| 1570 | + echo "Done\n"; |
|
| 1571 | + } |
|
| 1370 | 1572 | return ''; |
| 1371 | 1573 | } |
| 1372 | 1574 | |
| 1373 | 1575 | public static function update_ModeS_ogn() { |
| 1374 | 1576 | global $tmp_dir, $globalDebug; |
| 1375 | - if ($globalDebug) echo "Modes OGN: Download..."; |
|
| 1577 | + if ($globalDebug) { |
|
| 1578 | + echo "Modes OGN: Download..."; |
|
| 1579 | + } |
|
| 1376 | 1580 | update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv'); |
| 1377 | 1581 | if (file_exists($tmp_dir.'ogn.csv')) { |
| 1378 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1582 | + if ($globalDebug) { |
|
| 1583 | + echo "Add to DB..."; |
|
| 1584 | + } |
|
| 1379 | 1585 | $error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv'); |
| 1380 | - } else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed."; |
|
| 1586 | + } else { |
|
| 1587 | + $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed."; |
|
| 1588 | + } |
|
| 1381 | 1589 | if ($error != '') { |
| 1382 | 1590 | return $error; |
| 1383 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1591 | + } elseif ($globalDebug) { |
|
| 1592 | + echo "Done\n"; |
|
| 1593 | + } |
|
| 1384 | 1594 | return ''; |
| 1385 | 1595 | } |
| 1386 | 1596 | |
| 1387 | 1597 | public static function update_owner() { |
| 1388 | 1598 | global $tmp_dir, $globalDebug; |
| 1389 | 1599 | |
| 1390 | - if ($globalDebug) echo "Owner France: Download..."; |
|
| 1600 | + if ($globalDebug) { |
|
| 1601 | + echo "Owner France: Download..."; |
|
| 1602 | + } |
|
| 1391 | 1603 | update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv'); |
| 1392 | 1604 | if (file_exists($tmp_dir.'owner_f.csv')) { |
| 1393 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1605 | + if ($globalDebug) { |
|
| 1606 | + echo "Add to DB..."; |
|
| 1607 | + } |
|
| 1394 | 1608 | $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F'); |
| 1395 | - } else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
|
| 1609 | + } else { |
|
| 1610 | + $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
|
| 1611 | + } |
|
| 1396 | 1612 | if ($error != '') { |
| 1397 | 1613 | return $error; |
| 1398 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1614 | + } elseif ($globalDebug) { |
|
| 1615 | + echo "Done\n"; |
|
| 1616 | + } |
|
| 1399 | 1617 | |
| 1400 | - if ($globalDebug) echo "Owner Ireland: Download..."; |
|
| 1618 | + if ($globalDebug) { |
|
| 1619 | + echo "Owner Ireland: Download..."; |
|
| 1620 | + } |
|
| 1401 | 1621 | update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv'); |
| 1402 | 1622 | if (file_exists($tmp_dir.'owner_ei.csv')) { |
| 1403 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1623 | + if ($globalDebug) { |
|
| 1624 | + echo "Add to DB..."; |
|
| 1625 | + } |
|
| 1404 | 1626 | $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI'); |
| 1405 | - } else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
|
| 1627 | + } else { |
|
| 1628 | + $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
|
| 1629 | + } |
|
| 1406 | 1630 | if ($error != '') { |
| 1407 | 1631 | return $error; |
| 1408 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1409 | - if ($globalDebug) echo "Owner Switzerland: Download..."; |
|
| 1632 | + } elseif ($globalDebug) { |
|
| 1633 | + echo "Done\n"; |
|
| 1634 | + } |
|
| 1635 | + if ($globalDebug) { |
|
| 1636 | + echo "Owner Switzerland: Download..."; |
|
| 1637 | + } |
|
| 1410 | 1638 | update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv'); |
| 1411 | 1639 | if (file_exists($tmp_dir.'owner_hb.csv')) { |
| 1412 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1640 | + if ($globalDebug) { |
|
| 1641 | + echo "Add to DB..."; |
|
| 1642 | + } |
|
| 1413 | 1643 | $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB'); |
| 1414 | - } else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
|
| 1644 | + } else { |
|
| 1645 | + $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
|
| 1646 | + } |
|
| 1415 | 1647 | if ($error != '') { |
| 1416 | 1648 | return $error; |
| 1417 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1418 | - if ($globalDebug) echo "Owner Czech Republic: Download..."; |
|
| 1649 | + } elseif ($globalDebug) { |
|
| 1650 | + echo "Done\n"; |
|
| 1651 | + } |
|
| 1652 | + if ($globalDebug) { |
|
| 1653 | + echo "Owner Czech Republic: Download..."; |
|
| 1654 | + } |
|
| 1419 | 1655 | update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv'); |
| 1420 | 1656 | if (file_exists($tmp_dir.'owner_ok.csv')) { |
| 1421 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1657 | + if ($globalDebug) { |
|
| 1658 | + echo "Add to DB..."; |
|
| 1659 | + } |
|
| 1422 | 1660 | $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK'); |
| 1423 | - } else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
|
| 1661 | + } else { |
|
| 1662 | + $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
|
| 1663 | + } |
|
| 1424 | 1664 | if ($error != '') { |
| 1425 | 1665 | return $error; |
| 1426 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1427 | - if ($globalDebug) echo "Owner Australia: Download..."; |
|
| 1666 | + } elseif ($globalDebug) { |
|
| 1667 | + echo "Done\n"; |
|
| 1668 | + } |
|
| 1669 | + if ($globalDebug) { |
|
| 1670 | + echo "Owner Australia: Download..."; |
|
| 1671 | + } |
|
| 1428 | 1672 | update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv'); |
| 1429 | 1673 | if (file_exists($tmp_dir.'owner_vh.csv')) { |
| 1430 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1674 | + if ($globalDebug) { |
|
| 1675 | + echo "Add to DB..."; |
|
| 1676 | + } |
|
| 1431 | 1677 | $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH'); |
| 1432 | - } else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
|
| 1678 | + } else { |
|
| 1679 | + $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
|
| 1680 | + } |
|
| 1433 | 1681 | if ($error != '') { |
| 1434 | 1682 | return $error; |
| 1435 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1436 | - if ($globalDebug) echo "Owner Austria: Download..."; |
|
| 1683 | + } elseif ($globalDebug) { |
|
| 1684 | + echo "Done\n"; |
|
| 1685 | + } |
|
| 1686 | + if ($globalDebug) { |
|
| 1687 | + echo "Owner Austria: Download..."; |
|
| 1688 | + } |
|
| 1437 | 1689 | update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv'); |
| 1438 | 1690 | if (file_exists($tmp_dir.'owner_oe.csv')) { |
| 1439 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1691 | + if ($globalDebug) { |
|
| 1692 | + echo "Add to DB..."; |
|
| 1693 | + } |
|
| 1440 | 1694 | $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE'); |
| 1441 | - } else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
|
| 1695 | + } else { |
|
| 1696 | + $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
|
| 1697 | + } |
|
| 1442 | 1698 | if ($error != '') { |
| 1443 | 1699 | return $error; |
| 1444 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1445 | - if ($globalDebug) echo "Owner Chile: Download..."; |
|
| 1700 | + } elseif ($globalDebug) { |
|
| 1701 | + echo "Done\n"; |
|
| 1702 | + } |
|
| 1703 | + if ($globalDebug) { |
|
| 1704 | + echo "Owner Chile: Download..."; |
|
| 1705 | + } |
|
| 1446 | 1706 | update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv'); |
| 1447 | 1707 | if (file_exists($tmp_dir.'owner_cc.csv')) { |
| 1448 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1708 | + if ($globalDebug) { |
|
| 1709 | + echo "Add to DB..."; |
|
| 1710 | + } |
|
| 1449 | 1711 | $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC'); |
| 1450 | - } else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
|
| 1712 | + } else { |
|
| 1713 | + $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
|
| 1714 | + } |
|
| 1451 | 1715 | if ($error != '') { |
| 1452 | 1716 | return $error; |
| 1453 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1454 | - if ($globalDebug) echo "Owner Colombia: Download..."; |
|
| 1717 | + } elseif ($globalDebug) { |
|
| 1718 | + echo "Done\n"; |
|
| 1719 | + } |
|
| 1720 | + if ($globalDebug) { |
|
| 1721 | + echo "Owner Colombia: Download..."; |
|
| 1722 | + } |
|
| 1455 | 1723 | update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv'); |
| 1456 | 1724 | if (file_exists($tmp_dir.'owner_hj.csv')) { |
| 1457 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1725 | + if ($globalDebug) { |
|
| 1726 | + echo "Add to DB..."; |
|
| 1727 | + } |
|
| 1458 | 1728 | $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ'); |
| 1459 | - } else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
|
| 1729 | + } else { |
|
| 1730 | + $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
|
| 1731 | + } |
|
| 1460 | 1732 | if ($error != '') { |
| 1461 | 1733 | return $error; |
| 1462 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1463 | - if ($globalDebug) echo "Owner Bosnia Herzegobina: Download..."; |
|
| 1734 | + } elseif ($globalDebug) { |
|
| 1735 | + echo "Done\n"; |
|
| 1736 | + } |
|
| 1737 | + if ($globalDebug) { |
|
| 1738 | + echo "Owner Bosnia Herzegobina: Download..."; |
|
| 1739 | + } |
|
| 1464 | 1740 | update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv'); |
| 1465 | 1741 | if (file_exists($tmp_dir.'owner_e7.csv')) { |
| 1466 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1742 | + if ($globalDebug) { |
|
| 1743 | + echo "Add to DB..."; |
|
| 1744 | + } |
|
| 1467 | 1745 | $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7'); |
| 1468 | - } else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
|
| 1746 | + } else { |
|
| 1747 | + $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
|
| 1748 | + } |
|
| 1469 | 1749 | if ($error != '') { |
| 1470 | 1750 | return $error; |
| 1471 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1472 | - if ($globalDebug) echo "Owner Brazil: Download..."; |
|
| 1751 | + } elseif ($globalDebug) { |
|
| 1752 | + echo "Done\n"; |
|
| 1753 | + } |
|
| 1754 | + if ($globalDebug) { |
|
| 1755 | + echo "Owner Brazil: Download..."; |
|
| 1756 | + } |
|
| 1473 | 1757 | update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv'); |
| 1474 | 1758 | if (file_exists($tmp_dir.'owner_pp.csv')) { |
| 1475 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1759 | + if ($globalDebug) { |
|
| 1760 | + echo "Add to DB..."; |
|
| 1761 | + } |
|
| 1476 | 1762 | $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP'); |
| 1477 | - } else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
|
| 1763 | + } else { |
|
| 1764 | + $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
|
| 1765 | + } |
|
| 1478 | 1766 | if ($error != '') { |
| 1479 | 1767 | return $error; |
| 1480 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1481 | - if ($globalDebug) echo "Owner Cayman Islands: Download..."; |
|
| 1768 | + } elseif ($globalDebug) { |
|
| 1769 | + echo "Done\n"; |
|
| 1770 | + } |
|
| 1771 | + if ($globalDebug) { |
|
| 1772 | + echo "Owner Cayman Islands: Download..."; |
|
| 1773 | + } |
|
| 1482 | 1774 | update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv'); |
| 1483 | 1775 | if (file_exists($tmp_dir.'owner_vp.csv')) { |
| 1484 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1776 | + if ($globalDebug) { |
|
| 1777 | + echo "Add to DB..."; |
|
| 1778 | + } |
|
| 1485 | 1779 | $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP'); |
| 1486 | - } else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
|
| 1780 | + } else { |
|
| 1781 | + $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
|
| 1782 | + } |
|
| 1487 | 1783 | if ($error != '') { |
| 1488 | 1784 | return $error; |
| 1489 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1490 | - if ($globalDebug) echo "Owner Croatia: Download..."; |
|
| 1785 | + } elseif ($globalDebug) { |
|
| 1786 | + echo "Done\n"; |
|
| 1787 | + } |
|
| 1788 | + if ($globalDebug) { |
|
| 1789 | + echo "Owner Croatia: Download..."; |
|
| 1790 | + } |
|
| 1491 | 1791 | update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv'); |
| 1492 | 1792 | if (file_exists($tmp_dir.'owner_9a.csv')) { |
| 1493 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1793 | + if ($globalDebug) { |
|
| 1794 | + echo "Add to DB..."; |
|
| 1795 | + } |
|
| 1494 | 1796 | $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A'); |
| 1495 | - } else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
|
| 1797 | + } else { |
|
| 1798 | + $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
|
| 1799 | + } |
|
| 1496 | 1800 | if ($error != '') { |
| 1497 | 1801 | return $error; |
| 1498 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1499 | - if ($globalDebug) echo "Owner Luxembourg: Download..."; |
|
| 1802 | + } elseif ($globalDebug) { |
|
| 1803 | + echo "Done\n"; |
|
| 1804 | + } |
|
| 1805 | + if ($globalDebug) { |
|
| 1806 | + echo "Owner Luxembourg: Download..."; |
|
| 1807 | + } |
|
| 1500 | 1808 | update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv'); |
| 1501 | 1809 | if (file_exists($tmp_dir.'owner_lx.csv')) { |
| 1502 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1810 | + if ($globalDebug) { |
|
| 1811 | + echo "Add to DB..."; |
|
| 1812 | + } |
|
| 1503 | 1813 | $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX'); |
| 1504 | - } else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
|
| 1814 | + } else { |
|
| 1815 | + $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
|
| 1816 | + } |
|
| 1505 | 1817 | if ($error != '') { |
| 1506 | 1818 | return $error; |
| 1507 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1508 | - if ($globalDebug) echo "Owner Maldives: Download..."; |
|
| 1819 | + } elseif ($globalDebug) { |
|
| 1820 | + echo "Done\n"; |
|
| 1821 | + } |
|
| 1822 | + if ($globalDebug) { |
|
| 1823 | + echo "Owner Maldives: Download..."; |
|
| 1824 | + } |
|
| 1509 | 1825 | update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv'); |
| 1510 | 1826 | if (file_exists($tmp_dir.'owner_8q.csv')) { |
| 1511 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1827 | + if ($globalDebug) { |
|
| 1828 | + echo "Add to DB..."; |
|
| 1829 | + } |
|
| 1512 | 1830 | $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q'); |
| 1513 | - } else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
|
| 1831 | + } else { |
|
| 1832 | + $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
|
| 1833 | + } |
|
| 1514 | 1834 | if ($error != '') { |
| 1515 | 1835 | return $error; |
| 1516 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1517 | - if ($globalDebug) echo "Owner New Zealand: Download..."; |
|
| 1836 | + } elseif ($globalDebug) { |
|
| 1837 | + echo "Done\n"; |
|
| 1838 | + } |
|
| 1839 | + if ($globalDebug) { |
|
| 1840 | + echo "Owner New Zealand: Download..."; |
|
| 1841 | + } |
|
| 1518 | 1842 | update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv'); |
| 1519 | 1843 | if (file_exists($tmp_dir.'owner_zk.csv')) { |
| 1520 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1844 | + if ($globalDebug) { |
|
| 1845 | + echo "Add to DB..."; |
|
| 1846 | + } |
|
| 1521 | 1847 | $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK'); |
| 1522 | - } else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
|
| 1848 | + } else { |
|
| 1849 | + $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
|
| 1850 | + } |
|
| 1523 | 1851 | if ($error != '') { |
| 1524 | 1852 | return $error; |
| 1525 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1526 | - if ($globalDebug) echo "Owner Papua New Guinea: Download..."; |
|
| 1853 | + } elseif ($globalDebug) { |
|
| 1854 | + echo "Done\n"; |
|
| 1855 | + } |
|
| 1856 | + if ($globalDebug) { |
|
| 1857 | + echo "Owner Papua New Guinea: Download..."; |
|
| 1858 | + } |
|
| 1527 | 1859 | update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv'); |
| 1528 | 1860 | if (file_exists($tmp_dir.'owner_p2.csv')) { |
| 1529 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1861 | + if ($globalDebug) { |
|
| 1862 | + echo "Add to DB..."; |
|
| 1863 | + } |
|
| 1530 | 1864 | $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2'); |
| 1531 | - } else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
|
| 1865 | + } else { |
|
| 1866 | + $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
|
| 1867 | + } |
|
| 1532 | 1868 | if ($error != '') { |
| 1533 | 1869 | return $error; |
| 1534 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1535 | - if ($globalDebug) echo "Owner Slovakia: Download..."; |
|
| 1870 | + } elseif ($globalDebug) { |
|
| 1871 | + echo "Done\n"; |
|
| 1872 | + } |
|
| 1873 | + if ($globalDebug) { |
|
| 1874 | + echo "Owner Slovakia: Download..."; |
|
| 1875 | + } |
|
| 1536 | 1876 | update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv'); |
| 1537 | 1877 | if (file_exists($tmp_dir.'owner_om.csv')) { |
| 1538 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1878 | + if ($globalDebug) { |
|
| 1879 | + echo "Add to DB..."; |
|
| 1880 | + } |
|
| 1539 | 1881 | $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM'); |
| 1540 | - } else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
|
| 1882 | + } else { |
|
| 1883 | + $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
|
| 1884 | + } |
|
| 1541 | 1885 | if ($error != '') { |
| 1542 | 1886 | return $error; |
| 1543 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1544 | - if ($globalDebug) echo "Owner Ecuador: Download..."; |
|
| 1887 | + } elseif ($globalDebug) { |
|
| 1888 | + echo "Done\n"; |
|
| 1889 | + } |
|
| 1890 | + if ($globalDebug) { |
|
| 1891 | + echo "Owner Ecuador: Download..."; |
|
| 1892 | + } |
|
| 1545 | 1893 | update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv'); |
| 1546 | 1894 | if (file_exists($tmp_dir.'owner_hc.csv')) { |
| 1547 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1895 | + if ($globalDebug) { |
|
| 1896 | + echo "Add to DB..."; |
|
| 1897 | + } |
|
| 1548 | 1898 | $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC'); |
| 1549 | - } else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
|
| 1899 | + } else { |
|
| 1900 | + $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
|
| 1901 | + } |
|
| 1550 | 1902 | if ($error != '') { |
| 1551 | 1903 | return $error; |
| 1552 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1553 | - if ($globalDebug) echo "Owner Iceland: Download..."; |
|
| 1904 | + } elseif ($globalDebug) { |
|
| 1905 | + echo "Done\n"; |
|
| 1906 | + } |
|
| 1907 | + if ($globalDebug) { |
|
| 1908 | + echo "Owner Iceland: Download..."; |
|
| 1909 | + } |
|
| 1554 | 1910 | update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv'); |
| 1555 | 1911 | if (file_exists($tmp_dir.'owner_tf.csv')) { |
| 1556 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1912 | + if ($globalDebug) { |
|
| 1913 | + echo "Add to DB..."; |
|
| 1914 | + } |
|
| 1557 | 1915 | $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF'); |
| 1558 | - } else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
|
| 1916 | + } else { |
|
| 1917 | + $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
|
| 1918 | + } |
|
| 1559 | 1919 | if ($error != '') { |
| 1560 | 1920 | return $error; |
| 1561 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1921 | + } elseif ($globalDebug) { |
|
| 1922 | + echo "Done\n"; |
|
| 1923 | + } |
|
| 1562 | 1924 | return ''; |
| 1563 | 1925 | } |
| 1564 | 1926 | |
| 1565 | 1927 | public static function update_translation() { |
| 1566 | 1928 | global $tmp_dir, $globalDebug; |
| 1567 | 1929 | $error = ''; |
| 1568 | - if ($globalDebug) echo "Translation : Download..."; |
|
| 1930 | + if ($globalDebug) { |
|
| 1931 | + echo "Translation : Download..."; |
|
| 1932 | + } |
|
| 1569 | 1933 | update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip'); |
| 1570 | 1934 | if (file_exists($tmp_dir.'translation.zip')) { |
| 1571 | - if ($globalDebug) echo "Unzip..."; |
|
| 1935 | + if ($globalDebug) { |
|
| 1936 | + echo "Unzip..."; |
|
| 1937 | + } |
|
| 1572 | 1938 | update_db::unzip($tmp_dir.'translation.zip'); |
| 1573 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1939 | + if ($globalDebug) { |
|
| 1940 | + echo "Add to DB..."; |
|
| 1941 | + } |
|
| 1574 | 1942 | $error = update_db::translation(); |
| 1575 | - } else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed."; |
|
| 1943 | + } else { |
|
| 1944 | + $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed."; |
|
| 1945 | + } |
|
| 1576 | 1946 | if ($error != '') { |
| 1577 | 1947 | return $error; |
| 1578 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1948 | + } elseif ($globalDebug) { |
|
| 1949 | + echo "Done\n"; |
|
| 1950 | + } |
|
| 1579 | 1951 | return ''; |
| 1580 | 1952 | } |
| 1581 | 1953 | |
| 1582 | 1954 | public static function update_translation_fam() { |
| 1583 | 1955 | global $tmp_dir, $globalDebug; |
| 1584 | - if ($globalDebug) echo "Translation from FlightAirMap website : Download..."; |
|
| 1956 | + if ($globalDebug) { |
|
| 1957 | + echo "Translation from FlightAirMap website : Download..."; |
|
| 1958 | + } |
|
| 1585 | 1959 | update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz'); |
| 1586 | 1960 | if (file_exists($tmp_dir.'translation.tsv.gz')) { |
| 1587 | - if ($globalDebug) echo "Gunzip..."; |
|
| 1961 | + if ($globalDebug) { |
|
| 1962 | + echo "Gunzip..."; |
|
| 1963 | + } |
|
| 1588 | 1964 | update_db::gunzip($tmp_dir.'translation.tsv.gz'); |
| 1589 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1965 | + if ($globalDebug) { |
|
| 1966 | + echo "Add to DB..."; |
|
| 1967 | + } |
|
| 1590 | 1968 | $error = update_db::translation_fam(); |
| 1591 | - } else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed."; |
|
| 1969 | + } else { |
|
| 1970 | + $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed."; |
|
| 1971 | + } |
|
| 1592 | 1972 | if ($error != '') { |
| 1593 | 1973 | return $error; |
| 1594 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1974 | + } elseif ($globalDebug) { |
|
| 1975 | + echo "Done\n"; |
|
| 1976 | + } |
|
| 1595 | 1977 | return ''; |
| 1596 | 1978 | } |
| 1597 | 1979 | |
@@ -1599,7 +1981,9 @@ discard block |
||
| 1599 | 1981 | global $tmp_dir, $globalDebug, $globalDBdriver; |
| 1600 | 1982 | include_once('class.create_db.php'); |
| 1601 | 1983 | $error = ''; |
| 1602 | - if ($globalDebug) echo "Airspace from FlightAirMap website : Download..."; |
|
| 1984 | + if ($globalDebug) { |
|
| 1985 | + echo "Airspace from FlightAirMap website : Download..."; |
|
| 1986 | + } |
|
| 1603 | 1987 | if ($globalDBdriver == 'mysql') { |
| 1604 | 1988 | update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); |
| 1605 | 1989 | } else { |
@@ -1615,9 +1999,13 @@ discard block |
||
| 1615 | 1999 | update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz'); |
| 1616 | 2000 | } |
| 1617 | 2001 | if (file_exists($tmp_dir.'airspace.sql.gz')) { |
| 1618 | - if ($globalDebug) echo "Gunzip..."; |
|
| 2002 | + if ($globalDebug) { |
|
| 2003 | + echo "Gunzip..."; |
|
| 2004 | + } |
|
| 1619 | 2005 | update_db::gunzip($tmp_dir.'airspace.sql.gz'); |
| 1620 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2006 | + if ($globalDebug) { |
|
| 2007 | + echo "Add to DB..."; |
|
| 2008 | + } |
|
| 1621 | 2009 | $Connection = new Connection(); |
| 1622 | 2010 | if ($Connection->tableExists('airspace')) { |
| 1623 | 2011 | $query = 'DROP TABLE airspace'; |
@@ -1630,31 +2018,47 @@ discard block |
||
| 1630 | 2018 | } |
| 1631 | 2019 | $error = create_db::import_file($tmp_dir.'airspace.sql'); |
| 1632 | 2020 | update_db::insert_airspace_version($airspace_md5); |
| 1633 | - } else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed."; |
|
| 2021 | + } else { |
|
| 2022 | + $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed."; |
|
| 2023 | + } |
|
| 1634 | 2024 | } |
| 1635 | - } else $error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed."; |
|
| 2025 | + } else { |
|
| 2026 | + $error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed."; |
|
| 2027 | + } |
|
| 1636 | 2028 | if ($error != '') { |
| 1637 | 2029 | return $error; |
| 1638 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2030 | + } elseif ($globalDebug) { |
|
| 2031 | + echo "Done\n"; |
|
| 2032 | + } |
|
| 1639 | 2033 | return ''; |
| 1640 | 2034 | } |
| 1641 | 2035 | |
| 1642 | 2036 | public static function update_tle() { |
| 1643 | 2037 | global $tmp_dir, $globalDebug; |
| 1644 | - if ($globalDebug) echo "Download TLE : Download..."; |
|
| 2038 | + if ($globalDebug) { |
|
| 2039 | + echo "Download TLE : Download..."; |
|
| 2040 | + } |
|
| 1645 | 2041 | $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', |
| 1646 | 2042 | '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', |
| 1647 | 2043 | 'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt'); |
| 1648 | 2044 | foreach ($alltle as $filename) { |
| 1649 | - if ($globalDebug) echo "downloading ".$filename.'...'; |
|
| 2045 | + if ($globalDebug) { |
|
| 2046 | + echo "downloading ".$filename.'...'; |
|
| 2047 | + } |
|
| 1650 | 2048 | update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename); |
| 1651 | 2049 | if (file_exists($tmp_dir.$filename)) { |
| 1652 | - if ($globalDebug) echo "Add to DB ".$filename."..."; |
|
| 2050 | + if ($globalDebug) { |
|
| 2051 | + echo "Add to DB ".$filename."..."; |
|
| 2052 | + } |
|
| 1653 | 2053 | $error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename)); |
| 1654 | - } else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
|
| 2054 | + } else { |
|
| 2055 | + $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
|
| 2056 | + } |
|
| 1655 | 2057 | if ($error != '') { |
| 1656 | 2058 | echo $error."\n"; |
| 1657 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2059 | + } elseif ($globalDebug) { |
|
| 2060 | + echo "Done\n"; |
|
| 2061 | + } |
|
| 1658 | 2062 | } |
| 1659 | 2063 | return ''; |
| 1660 | 2064 | } |
@@ -1662,10 +2066,14 @@ discard block |
||
| 1662 | 2066 | public static function update_models() { |
| 1663 | 2067 | global $tmp_dir, $globalDebug; |
| 1664 | 2068 | $error = ''; |
| 1665 | - if ($globalDebug) echo "Models from FlightAirMap website : Download..."; |
|
| 2069 | + if ($globalDebug) { |
|
| 2070 | + echo "Models from FlightAirMap website : Download..."; |
|
| 2071 | + } |
|
| 1666 | 2072 | update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum'); |
| 1667 | 2073 | if (file_exists($tmp_dir.'models.md5sum')) { |
| 1668 | - if ($globalDebug) echo "Check files...\n"; |
|
| 2074 | + if ($globalDebug) { |
|
| 2075 | + echo "Check files...\n"; |
|
| 2076 | + } |
|
| 1669 | 2077 | $newmodelsdb = array(); |
| 1670 | 2078 | if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) { |
| 1671 | 2079 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -1684,25 +2092,35 @@ discard block |
||
| 1684 | 2092 | } |
| 1685 | 2093 | $diff = array_diff($newmodelsdb,$modelsdb); |
| 1686 | 2094 | foreach ($diff as $key => $value) { |
| 1687 | - if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n"; |
|
| 2095 | + if ($globalDebug) { |
|
| 2096 | + echo 'Downloading model '.$key.' ...'."\n"; |
|
| 2097 | + } |
|
| 1688 | 2098 | update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key); |
| 1689 | 2099 | |
| 1690 | 2100 | } |
| 1691 | 2101 | update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum'); |
| 1692 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 2102 | + } else { |
|
| 2103 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 2104 | + } |
|
| 1693 | 2105 | if ($error != '') { |
| 1694 | 2106 | return $error; |
| 1695 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2107 | + } elseif ($globalDebug) { |
|
| 2108 | + echo "Done\n"; |
|
| 2109 | + } |
|
| 1696 | 2110 | return ''; |
| 1697 | 2111 | } |
| 1698 | 2112 | |
| 1699 | 2113 | public static function update_space_models() { |
| 1700 | 2114 | global $tmp_dir, $globalDebug; |
| 1701 | 2115 | $error = ''; |
| 1702 | - if ($globalDebug) echo "Space models from FlightAirMap website : Download..."; |
|
| 2116 | + if ($globalDebug) { |
|
| 2117 | + echo "Space models from FlightAirMap website : Download..."; |
|
| 2118 | + } |
|
| 1703 | 2119 | update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum'); |
| 1704 | 2120 | if (file_exists($tmp_dir.'space_models.md5sum')) { |
| 1705 | - if ($globalDebug) echo "Check files...\n"; |
|
| 2121 | + if ($globalDebug) { |
|
| 2122 | + echo "Check files...\n"; |
|
| 2123 | + } |
|
| 1706 | 2124 | $newmodelsdb = array(); |
| 1707 | 2125 | if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) { |
| 1708 | 2126 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -1721,15 +2139,21 @@ discard block |
||
| 1721 | 2139 | } |
| 1722 | 2140 | $diff = array_diff($newmodelsdb,$modelsdb); |
| 1723 | 2141 | foreach ($diff as $key => $value) { |
| 1724 | - if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n"; |
|
| 2142 | + if ($globalDebug) { |
|
| 2143 | + echo 'Downloading space model '.$key.' ...'."\n"; |
|
| 2144 | + } |
|
| 1725 | 2145 | update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key); |
| 1726 | 2146 | |
| 1727 | 2147 | } |
| 1728 | 2148 | update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum'); |
| 1729 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 2149 | + } else { |
|
| 2150 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 2151 | + } |
|
| 1730 | 2152 | if ($error != '') { |
| 1731 | 2153 | return $error; |
| 1732 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2154 | + } elseif ($globalDebug) { |
|
| 2155 | + echo "Done\n"; |
|
| 2156 | + } |
|
| 1733 | 2157 | return ''; |
| 1734 | 2158 | } |
| 1735 | 2159 | |
@@ -1772,7 +2196,9 @@ discard block |
||
| 1772 | 2196 | } |
| 1773 | 2197 | |
| 1774 | 2198 | $error = ''; |
| 1775 | - if ($globalDebug) echo "Notam : Download..."; |
|
| 2199 | + if ($globalDebug) { |
|
| 2200 | + echo "Notam : Download..."; |
|
| 2201 | + } |
|
| 1776 | 2202 | update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss'); |
| 1777 | 2203 | if (file_exists($tmp_dir.'notam.rss')) { |
| 1778 | 2204 | $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true); |
@@ -1787,14 +2213,30 @@ discard block |
||
| 1787 | 2213 | $data['fir'] = $q[0]; |
| 1788 | 2214 | $data['code'] = $q[1]; |
| 1789 | 2215 | $ifrvfr = $q[2]; |
| 1790 | - if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR'; |
|
| 1791 | - if ($ifrvfr == 'I') $data['rules'] = 'IFR'; |
|
| 1792 | - if ($ifrvfr == 'V') $data['rules'] = 'VFR'; |
|
| 1793 | - if ($q[4] == 'A') $data['scope'] = 'Airport warning'; |
|
| 1794 | - if ($q[4] == 'E') $data['scope'] = 'Enroute warning'; |
|
| 1795 | - if ($q[4] == 'W') $data['scope'] = 'Navigation warning'; |
|
| 1796 | - if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning'; |
|
| 1797 | - if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning'; |
|
| 2216 | + if ($ifrvfr == 'IV') { |
|
| 2217 | + $data['rules'] = 'IFR/VFR'; |
|
| 2218 | + } |
|
| 2219 | + if ($ifrvfr == 'I') { |
|
| 2220 | + $data['rules'] = 'IFR'; |
|
| 2221 | + } |
|
| 2222 | + if ($ifrvfr == 'V') { |
|
| 2223 | + $data['rules'] = 'VFR'; |
|
| 2224 | + } |
|
| 2225 | + if ($q[4] == 'A') { |
|
| 2226 | + $data['scope'] = 'Airport warning'; |
|
| 2227 | + } |
|
| 2228 | + if ($q[4] == 'E') { |
|
| 2229 | + $data['scope'] = 'Enroute warning'; |
|
| 2230 | + } |
|
| 2231 | + if ($q[4] == 'W') { |
|
| 2232 | + $data['scope'] = 'Navigation warning'; |
|
| 2233 | + } |
|
| 2234 | + if ($q[4] == 'AE') { |
|
| 2235 | + $data['scope'] = 'Airport/Enroute warning'; |
|
| 2236 | + } |
|
| 2237 | + if ($q[4] == 'AW') { |
|
| 2238 | + $data['scope'] = 'Airport/Navigation warning'; |
|
| 2239 | + } |
|
| 1798 | 2240 | //$data['scope'] = $q[4]; |
| 1799 | 2241 | $data['lower_limit'] = $q[5]; |
| 1800 | 2242 | $data['upper_limit'] = $q[6]; |
@@ -1802,8 +2244,12 @@ discard block |
||
| 1802 | 2244 | sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius); |
| 1803 | 2245 | $latitude = $Common->convertDec($las,'latitude'); |
| 1804 | 2246 | $longitude = $Common->convertDec($lns,'longitude'); |
| 1805 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
| 1806 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
| 2247 | + if ($lac == 'S') { |
|
| 2248 | + $latitude = '-'.$latitude; |
|
| 2249 | + } |
|
| 2250 | + if ($lnc == 'W') { |
|
| 2251 | + $longitude = '-'.$longitude; |
|
| 2252 | + } |
|
| 1807 | 2253 | $data['center_latitude'] = $latitude; |
| 1808 | 2254 | $data['center_longitude'] = $longitude; |
| 1809 | 2255 | $data['radius'] = intval($radius); |
@@ -1833,10 +2279,14 @@ discard block |
||
| 1833 | 2279 | $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']); |
| 1834 | 2280 | unset($data); |
| 1835 | 2281 | } |
| 1836 | - } else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
|
| 2282 | + } else { |
|
| 2283 | + $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
|
| 2284 | + } |
|
| 1837 | 2285 | if ($error != '') { |
| 1838 | 2286 | return $error; |
| 1839 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2287 | + } elseif ($globalDebug) { |
|
| 2288 | + echo "Done\n"; |
|
| 2289 | + } |
|
| 1840 | 2290 | return ''; |
| 1841 | 2291 | } |
| 1842 | 2292 | |
@@ -1861,7 +2311,9 @@ discard block |
||
| 1861 | 2311 | $airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json'); |
| 1862 | 2312 | $airspace_json = json_decode($airspace_lst,true); |
| 1863 | 2313 | foreach ($airspace_json['records'] as $airspace) { |
| 1864 | - if ($globalDebug) echo $airspace['name']."...\n"; |
|
| 2314 | + if ($globalDebug) { |
|
| 2315 | + echo $airspace['name']."...\n"; |
|
| 2316 | + } |
|
| 1865 | 2317 | update_db::download($airspace['uri'],$tmp_dir.$airspace['name']); |
| 1866 | 2318 | if (file_exists($tmp_dir.$airspace['name'])) { |
| 1867 | 2319 | file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name']))); |
@@ -1890,8 +2342,11 @@ discard block |
||
| 1890 | 2342 | return "error : ".$e->getMessage(); |
| 1891 | 2343 | } |
| 1892 | 2344 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 1893 | - if ($row['nb'] > 0) return false; |
|
| 1894 | - else return true; |
|
| 2345 | + if ($row['nb'] > 0) { |
|
| 2346 | + return false; |
|
| 2347 | + } else { |
|
| 2348 | + return true; |
|
| 2349 | + } |
|
| 1895 | 2350 | } |
| 1896 | 2351 | |
| 1897 | 2352 | public static function insert_last_update() { |
@@ -1916,8 +2371,11 @@ discard block |
||
| 1916 | 2371 | return "error : ".$e->getMessage(); |
| 1917 | 2372 | } |
| 1918 | 2373 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 1919 | - if ($row['nb'] > 0) return true; |
|
| 1920 | - else return false; |
|
| 2374 | + if ($row['nb'] > 0) { |
|
| 2375 | + return true; |
|
| 2376 | + } else { |
|
| 2377 | + return false; |
|
| 2378 | + } |
|
| 1921 | 2379 | } |
| 1922 | 2380 | |
| 1923 | 2381 | |
@@ -1948,8 +2406,11 @@ discard block |
||
| 1948 | 2406 | return "error : ".$e->getMessage(); |
| 1949 | 2407 | } |
| 1950 | 2408 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 1951 | - if ($row['nb'] > 0) return false; |
|
| 1952 | - else return true; |
|
| 2409 | + if ($row['nb'] > 0) { |
|
| 2410 | + return false; |
|
| 2411 | + } else { |
|
| 2412 | + return true; |
|
| 2413 | + } |
|
| 1953 | 2414 | } |
| 1954 | 2415 | |
| 1955 | 2416 | public static function insert_last_notam_update() { |
@@ -1978,8 +2439,11 @@ discard block |
||
| 1978 | 2439 | return "error : ".$e->getMessage(); |
| 1979 | 2440 | } |
| 1980 | 2441 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 1981 | - if ($row['nb'] > 0) return false; |
|
| 1982 | - else return true; |
|
| 2442 | + if ($row['nb'] > 0) { |
|
| 2443 | + return false; |
|
| 2444 | + } else { |
|
| 2445 | + return true; |
|
| 2446 | + } |
|
| 1983 | 2447 | } |
| 1984 | 2448 | |
| 1985 | 2449 | public static function insert_last_airspace_update() { |
@@ -2009,8 +2473,11 @@ discard block |
||
| 2009 | 2473 | return "error : ".$e->getMessage(); |
| 2010 | 2474 | } |
| 2011 | 2475 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 2012 | - if ($row['nb'] > 0) return false; |
|
| 2013 | - else return true; |
|
| 2476 | + if ($row['nb'] > 0) { |
|
| 2477 | + return false; |
|
| 2478 | + } else { |
|
| 2479 | + return true; |
|
| 2480 | + } |
|
| 2014 | 2481 | } |
| 2015 | 2482 | |
| 2016 | 2483 | public static function insert_last_owner_update() { |
@@ -2039,8 +2506,11 @@ discard block |
||
| 2039 | 2506 | return "error : ".$e->getMessage(); |
| 2040 | 2507 | } |
| 2041 | 2508 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 2042 | - if ($row['nb'] > 0) return false; |
|
| 2043 | - else return true; |
|
| 2509 | + if ($row['nb'] > 0) { |
|
| 2510 | + return false; |
|
| 2511 | + } else { |
|
| 2512 | + return true; |
|
| 2513 | + } |
|
| 2044 | 2514 | } |
| 2045 | 2515 | |
| 2046 | 2516 | public static function insert_last_schedules_update() { |
@@ -2069,8 +2539,11 @@ discard block |
||
| 2069 | 2539 | return "error : ".$e->getMessage(); |
| 2070 | 2540 | } |
| 2071 | 2541 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 2072 | - if ($row['nb'] > 0) return false; |
|
| 2073 | - else return true; |
|
| 2542 | + if ($row['nb'] > 0) { |
|
| 2543 | + return false; |
|
| 2544 | + } else { |
|
| 2545 | + return true; |
|
| 2546 | + } |
|
| 2074 | 2547 | } |
| 2075 | 2548 | |
| 2076 | 2549 | public static function insert_last_tle_update() { |